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
|
|---|---|---|---|---|---|---|
45,801
|
Interpreting the random effect in a mixed-effect model
|
I'd suggest centering the interpretation around intraclass correlations:
For DV1, the total random variation not explained by the group differences (the fixed factor) is $\hat\sigma^2_{tot} = 6.2 + 67.7 + 50.2 = 124.1$, so that the total SD is $\hat\sigma_{tot}=11.14$. For DV2, these figures are $\hat\sigma^2_{tot} = 170.1$ and $\hat\sigma_{tot}=13.04$
For DV1, the correlation between two observations on the same subject but different times is $r_S = 6.2/124.1=.050$, while for DV2 it is $27.2/170.1 = .160$
For DV1, the correlation between two observations at the same time but different subjects is $r_T = 67.7/124.1=.546$, while for DV2 it is $17.7/170.1=.104$
For DV1, the correlation between two observations on the same subject and the same time is $r_{ST} = (6.2 + 67.7)/124.1 = 1-50.2/124.1=.595$, while for DV2 it is $1-125.2/170.1=.264$
Of course, point (4) may or may not be meaningful in your experiment. The largest correlation, by far is the Time one for DV1: Time effects contribute hugely to the variations in DV1.
I agree with ahfoss on avoiding the word "variability"
A bit more on intraclass correlation
Most experimental design books discuss this topic under "model II" or "random-effects models". Suppose that a measurement $Y$ follows $Y = \mu + S + E$ where $S$ is random variation among subjects and $E$ is error variance. Then $Var(Y) = Var(S)+Var(E) = \sigma^2_S + \sigma^2_E$. Now let $Y_1$ and $Y_2$ be two such measurements. Then in general,
$$Var(Y_1-Y_2)=Var(Y_1)+Var(Y_2)-2Cov(Y_1,Y_2) = 2(\sigma^2_S+\sigma^2_E)-2Cov(Y_1,Y_2)$$
If the measurements are on the same subject, then the $S$ term cancels out and we have
$$Var(Y_1-Y_2)=2\sigma^2_E$$
Equating these, we have
$$Cov(Y_1,Y_2) = (\sigma^2_S+\sigma^2_E) - \sigma^2_E = \sigma^2_S$$
and thus that $Corr(Y_1,Y_2) = \sigma^2_S / (\sigma^2_S+\sigma^2_E)$.
This is called the intraclass correlation because it is the correlation of two measurements in the same class. It is useful because having random effects in a model implies a correlation structure in the data, and this quantifies it. The above ideas apply when there are more random effects; you just add the variances of the random effects you are conditioning upon.
|
Interpreting the random effect in a mixed-effect model
|
I'd suggest centering the interpretation around intraclass correlations:
For DV1, the total random variation not explained by the group differences (the fixed factor) is $\hat\sigma^2_{tot} = 6.2 + 6
|
Interpreting the random effect in a mixed-effect model
I'd suggest centering the interpretation around intraclass correlations:
For DV1, the total random variation not explained by the group differences (the fixed factor) is $\hat\sigma^2_{tot} = 6.2 + 67.7 + 50.2 = 124.1$, so that the total SD is $\hat\sigma_{tot}=11.14$. For DV2, these figures are $\hat\sigma^2_{tot} = 170.1$ and $\hat\sigma_{tot}=13.04$
For DV1, the correlation between two observations on the same subject but different times is $r_S = 6.2/124.1=.050$, while for DV2 it is $27.2/170.1 = .160$
For DV1, the correlation between two observations at the same time but different subjects is $r_T = 67.7/124.1=.546$, while for DV2 it is $17.7/170.1=.104$
For DV1, the correlation between two observations on the same subject and the same time is $r_{ST} = (6.2 + 67.7)/124.1 = 1-50.2/124.1=.595$, while for DV2 it is $1-125.2/170.1=.264$
Of course, point (4) may or may not be meaningful in your experiment. The largest correlation, by far is the Time one for DV1: Time effects contribute hugely to the variations in DV1.
I agree with ahfoss on avoiding the word "variability"
A bit more on intraclass correlation
Most experimental design books discuss this topic under "model II" or "random-effects models". Suppose that a measurement $Y$ follows $Y = \mu + S + E$ where $S$ is random variation among subjects and $E$ is error variance. Then $Var(Y) = Var(S)+Var(E) = \sigma^2_S + \sigma^2_E$. Now let $Y_1$ and $Y_2$ be two such measurements. Then in general,
$$Var(Y_1-Y_2)=Var(Y_1)+Var(Y_2)-2Cov(Y_1,Y_2) = 2(\sigma^2_S+\sigma^2_E)-2Cov(Y_1,Y_2)$$
If the measurements are on the same subject, then the $S$ term cancels out and we have
$$Var(Y_1-Y_2)=2\sigma^2_E$$
Equating these, we have
$$Cov(Y_1,Y_2) = (\sigma^2_S+\sigma^2_E) - \sigma^2_E = \sigma^2_S$$
and thus that $Corr(Y_1,Y_2) = \sigma^2_S / (\sigma^2_S+\sigma^2_E)$.
This is called the intraclass correlation because it is the correlation of two measurements in the same class. It is useful because having random effects in a model implies a correlation structure in the data, and this quantifies it. The above ideas apply when there are more random effects; you just add the variances of the random effects you are conditioning upon.
|
Interpreting the random effect in a mixed-effect model
I'd suggest centering the interpretation around intraclass correlations:
For DV1, the total random variation not explained by the group differences (the fixed factor) is $\hat\sigma^2_{tot} = 6.2 + 6
|
45,802
|
Interpreting the random effect in a mixed-effect model
|
A few things. First, be careful with the general term "variability." In a general context it is fine, but if you are referring to variance or standard deviation specifically, use the correct term. Also, as per my comment to your statement, remember that these are variances of the distributions of subject- and time-specific intercepts.
Your statements (1) and (2) are not valid. If your goal in this analysis is to make an inference about absolute differences in variances between two variables with respect to a grouping, you would need some formal hypothesis test, which you have not implemented. You can make relative statements, however. You might modify (1) as "between-subject variability accounted for a greater proportion of the variance in DV2 compared to DV1"
Modify your remaining statements like this:
(3) Time accounted for a larger proportion of the variance in DV1 than subject
(4) modify as in (3), but how you define "similar" should be carefully considered based on your goals. In some contexts, a difference of 1 might be very meaningful...
(5) For DV1, time-specific means were drawn from a normal distribution with standard deviation 8 (assuming you have checked that normality assumptions hold, approximately)
|
Interpreting the random effect in a mixed-effect model
|
A few things. First, be careful with the general term "variability." In a general context it is fine, but if you are referring to variance or standard deviation specifically, use the correct term. Als
|
Interpreting the random effect in a mixed-effect model
A few things. First, be careful with the general term "variability." In a general context it is fine, but if you are referring to variance or standard deviation specifically, use the correct term. Also, as per my comment to your statement, remember that these are variances of the distributions of subject- and time-specific intercepts.
Your statements (1) and (2) are not valid. If your goal in this analysis is to make an inference about absolute differences in variances between two variables with respect to a grouping, you would need some formal hypothesis test, which you have not implemented. You can make relative statements, however. You might modify (1) as "between-subject variability accounted for a greater proportion of the variance in DV2 compared to DV1"
Modify your remaining statements like this:
(3) Time accounted for a larger proportion of the variance in DV1 than subject
(4) modify as in (3), but how you define "similar" should be carefully considered based on your goals. In some contexts, a difference of 1 might be very meaningful...
(5) For DV1, time-specific means were drawn from a normal distribution with standard deviation 8 (assuming you have checked that normality assumptions hold, approximately)
|
Interpreting the random effect in a mixed-effect model
A few things. First, be careful with the general term "variability." In a general context it is fine, but if you are referring to variance or standard deviation specifically, use the correct term. Als
|
45,803
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
|
Just because an analysis is sensitive to changes to the model doesn't necessarily imply that the researcher tried many models and then published the one that worked.
One need only hypothesize the existence of a number of researchers each considering a somewhat similar question, each trying only one analysis, and the first one that tries the 'successful' model is the one who published.
The lack of any sensitivity analysis would then be more an indication of incompetence or carelessness rather than actual significance hunting by any one individual.
That's not to say it (significance hunting) never happens, it's just that you can't tell by the mere existence of such a situation that it was what went on in any particular case. In practice I see ignorant incompetence or flat carelessness (in the face of the publish or perish mentality, it's no surprise at all - what's the payoff for taking the time to do things with proper care?) much more often than deliberate misconduct; all it takes above that is a large enough cohort of people thinking about similar questions for all those "special case" results that don't really generalize to eventually turn up in the literature.
The source of what is effective significance hunting, even when everyone tries only one model is the existence of journals that want to publish 'significant' results. They act to create results that can't be reproduced (that are noise, basically). If the journals want to publish results that are nearly all false positives, all they need do is continue as they are.
Even many journals that have an official policy geared toward avoiding these problems nevertheless have a de facto policy of only publishing significant results, because they accept the practices and recommendations of reviewers who insist on them in spite of the stated policy.
To get better results, they need to actively encourage a focus on sizes of effects, and concentrate a significant fraction of effort on publishing well-conducted studies that find nothing. [If the professional groups and journal editorial boards - and editors - can't comprehend the scientific importance of not finding anything going on (and the very dire consequences of ignoring the null results), they should probably get out of that business and go into something relatively more scientifically honest, like running a psychic reading phone line. At the least, any pretence of rigor should be dropped.]
In the vein of suggesting that may people are not doing it deliberately, here are a few more-or-less unconscious 'dirty tricks' that can inflate rates of finding significant results:
doing model/variable selection without accounting for the effect of it. This is probably the biggest one, it can happen at a number of points in the research, and the researcher may not even be conscious that they're doing it (sometimes it's subtle).
Indeed, the basic 'modelling cycle' paradigm (like the flowchart found in Box and Jenkins, say) leads to this issue. That's not a criticism of that flowchart, by the way - but one must properly deal with the effect of these procedures.
It's worth reading Frank Harrell's book (Regression Modelling Strategies), in particular chapter 4. Related information can be found in a number of other places.
focusing on model-assessment (particularly looking at things like normality, homoskedasticity or considering the addition of interaction terms or terms to pick up curvature), or just focusing harder on it when nothing is found - and then trying a new analysis when some failure of assumptions is detected - than when a desired result is found.
trying to find out if there's a better post-hoc procedure when the first one you tried doesn't give the result you needed.
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
|
Just because an analysis is sensitive to changes to the model doesn't necessarily imply that the researcher tried many models and then published the one that worked.
One need only hypothesize the exis
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
Just because an analysis is sensitive to changes to the model doesn't necessarily imply that the researcher tried many models and then published the one that worked.
One need only hypothesize the existence of a number of researchers each considering a somewhat similar question, each trying only one analysis, and the first one that tries the 'successful' model is the one who published.
The lack of any sensitivity analysis would then be more an indication of incompetence or carelessness rather than actual significance hunting by any one individual.
That's not to say it (significance hunting) never happens, it's just that you can't tell by the mere existence of such a situation that it was what went on in any particular case. In practice I see ignorant incompetence or flat carelessness (in the face of the publish or perish mentality, it's no surprise at all - what's the payoff for taking the time to do things with proper care?) much more often than deliberate misconduct; all it takes above that is a large enough cohort of people thinking about similar questions for all those "special case" results that don't really generalize to eventually turn up in the literature.
The source of what is effective significance hunting, even when everyone tries only one model is the existence of journals that want to publish 'significant' results. They act to create results that can't be reproduced (that are noise, basically). If the journals want to publish results that are nearly all false positives, all they need do is continue as they are.
Even many journals that have an official policy geared toward avoiding these problems nevertheless have a de facto policy of only publishing significant results, because they accept the practices and recommendations of reviewers who insist on them in spite of the stated policy.
To get better results, they need to actively encourage a focus on sizes of effects, and concentrate a significant fraction of effort on publishing well-conducted studies that find nothing. [If the professional groups and journal editorial boards - and editors - can't comprehend the scientific importance of not finding anything going on (and the very dire consequences of ignoring the null results), they should probably get out of that business and go into something relatively more scientifically honest, like running a psychic reading phone line. At the least, any pretence of rigor should be dropped.]
In the vein of suggesting that may people are not doing it deliberately, here are a few more-or-less unconscious 'dirty tricks' that can inflate rates of finding significant results:
doing model/variable selection without accounting for the effect of it. This is probably the biggest one, it can happen at a number of points in the research, and the researcher may not even be conscious that they're doing it (sometimes it's subtle).
Indeed, the basic 'modelling cycle' paradigm (like the flowchart found in Box and Jenkins, say) leads to this issue. That's not a criticism of that flowchart, by the way - but one must properly deal with the effect of these procedures.
It's worth reading Frank Harrell's book (Regression Modelling Strategies), in particular chapter 4. Related information can be found in a number of other places.
focusing on model-assessment (particularly looking at things like normality, homoskedasticity or considering the addition of interaction terms or terms to pick up curvature), or just focusing harder on it when nothing is found - and then trying a new analysis when some failure of assumptions is detected - than when a desired result is found.
trying to find out if there's a better post-hoc procedure when the first one you tried doesn't give the result you needed.
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
Just because an analysis is sensitive to changes to the model doesn't necessarily imply that the researcher tried many models and then published the one that worked.
One need only hypothesize the exis
|
45,804
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
|
not even robust to small changes in the modeling setup
I'm analytical chemist/chemometrician. In my field, the related key words
related to demonstrating/stating how robust the model/the whole analytical method is against certain influences are robustness and ruggedness (There's a whole body of literature including regulations on these topics). They are applied to the whole method, not only to the data analysis, but the same principles apply (how much do the analysis results deteriorate if e.g. pH varies, a different lab does the work, some features are excluded, etc.).
The key point is that you have to sit down and think hard and put together a list of conditions to test the ruggedness for.
As for the robustness of data analyses, here's some literature that may be of interest to you:
One robustness parameter that is very easy to determine is the robustness/stability of model and predictions against perturbing the training data. In my work, that is e.g. "How much do models/predicitons vary if few training patients are exchanged for other training patients?" Such measures you can basically get for free if you are anyways doing repeated/iterated $k$-fold cross validation.
Beleites, C. & Salzer, R. Assessing and improving the stability of chemometric models in small sample size situations Anal Bioanal Chem, 2008, 390, 1261-1271.
DOI: 10.1007/s00216-007-1818-6
Dixon, S. J. & Brereton, R. G. Comparison of performance of five common classifiers represented as boundary methods: Euclidean Distance to Centroids, Linear Discriminant Analysis, Quadratic Discriminant Analysis, Learning Vector Quantization and Support Vector Machines, as dependent on data structure Chemometrics and Intelligent Laboratory Systems, 2009, 95, 1 - 17.
DOI: 10.1016/j.chemolab.2008.07.010
Here's a paper simulating different perturbing influences on measurements and then looking at the deterioration of the predictions:
Sattlecker, M.; Stone, N.; Smith, J. & Bessant, C. Assessment of robustness and transferability of classification models built for cancer diagnostics using Raman spectroscopy J Raman Spectrosc, 2010, 897-903.
DOI: 10.1002/jrs.2798
If you read German, I could send you my Diplom where I tried to find a good set of pre-processing steps for infrared spectra. It turned out that other than having a general sensible choice (from physical/chemical/biological knowledge of the application and the measurements), the only tested pre-processing method where the choice actually had a consistent influence was applying a rather strict quality control filter.
E.g. there's no question that normalization is needed because of the experimental set-up, but the actual choice e.g. min-max vs. area normalization didn't show any consistent influence. In turn, I conclude that the analysis is reasonably robust against the particular normalization method.
now about the dirty tricks:
All kinds of things that lead to optimistic bias in validation results
Data leaks between training and test data
not splitting the data properly = at the topmost level in the data hierarchy (e.g. treating samples prepared from the same stock solution as independent, treating multiple measurements from the same patient/same time series as independent, etc.)
Data-driven feature reduction (PCA, PLS) done on the whole data set, "validating" only the last level of the model (e.g. the regression done in PCA score space).
Same is true for any kind of pre-processing that involves more than one case: all these have to be done on the training data only, and then the results are applied to the test data.
Model selection bias: Also data-driven model optimization/selection without outer validation of the final model is a kind of data leak.
Creating "self-fulfilling prophecies" in the modeling process
assign reference labels for classification using a cluster analysis
exclude cases because they don't fit into the model without reporting proper criteria for outlier exclusion
(Note that in some applications an automated decistion/filter to reject bad cases/measurements that are out of the specified domain of applicability is possible and sensible, though)
(test) data sets not representative for the application. E.g. the applications I work on frequently deal with medical diagnoses. There are always difficult/borderline cases where it is hard to obtain reference diagnoses. However, excluding such cases from the data analysis creates an artificially easy problem that excludes all those cases for which the model would be needed most.
For a discussion in the context of semi-supervised models see
Berget, I. & Næs, T. Using unclassified observations for improving classifiers J Chemom, 2004, 18, 103-111. DOI: 10.1002/cem.857
claiming that (resampling) validation results for unknown cases generalize to unknown future cases. Also leading to an optimistic bias (bullet 1).
Jumping from observations e.g. on cell line data or xenografts to conclusions about humans. Or from few precisely specified and selected groups of humans to applicability as medical screening tool, etc.
Not having enough test cases to warrant the conclusion. At least a rough sanity check on the validation results should be done (e.g. is the confidence interval for the validation results narrow enough to allow practically relevant conclusions, i.e. with respect to what would be considered very good, reasonable, bad and too-bad-to-dare-reporting models.)
Humans are biased towards recognizing patterns (as opposed to overlooking patterns). This can also lead to setting up too complex models which are overfit and not robust at all.
All these points involve a trade-off between what is good and sensible and what is too much, and/or which influencing factors are important and which are not. Personally, I can live happily with modeling where all kinds of decisions are done by the data analyst as long as these decisions are reported and justified.
OTOH, I think one needs to judge carfully which level of validation is sensible in a given application. All (or most of these) these points can make sense in certain situations, but they limit the conclusions that can be drawn. Which in itself is IMHO not a problem - this is just a very normal way to "pay" for using a method can can be practically applied. Problems IMHO arise from not being aware of the limitations.
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
|
not even robust to small changes in the modeling setup
I'm analytical chemist/chemometrician. In my field, the related key words
related to demonstrating/stating how robust the model/the whole analy
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
not even robust to small changes in the modeling setup
I'm analytical chemist/chemometrician. In my field, the related key words
related to demonstrating/stating how robust the model/the whole analytical method is against certain influences are robustness and ruggedness (There's a whole body of literature including regulations on these topics). They are applied to the whole method, not only to the data analysis, but the same principles apply (how much do the analysis results deteriorate if e.g. pH varies, a different lab does the work, some features are excluded, etc.).
The key point is that you have to sit down and think hard and put together a list of conditions to test the ruggedness for.
As for the robustness of data analyses, here's some literature that may be of interest to you:
One robustness parameter that is very easy to determine is the robustness/stability of model and predictions against perturbing the training data. In my work, that is e.g. "How much do models/predicitons vary if few training patients are exchanged for other training patients?" Such measures you can basically get for free if you are anyways doing repeated/iterated $k$-fold cross validation.
Beleites, C. & Salzer, R. Assessing and improving the stability of chemometric models in small sample size situations Anal Bioanal Chem, 2008, 390, 1261-1271.
DOI: 10.1007/s00216-007-1818-6
Dixon, S. J. & Brereton, R. G. Comparison of performance of five common classifiers represented as boundary methods: Euclidean Distance to Centroids, Linear Discriminant Analysis, Quadratic Discriminant Analysis, Learning Vector Quantization and Support Vector Machines, as dependent on data structure Chemometrics and Intelligent Laboratory Systems, 2009, 95, 1 - 17.
DOI: 10.1016/j.chemolab.2008.07.010
Here's a paper simulating different perturbing influences on measurements and then looking at the deterioration of the predictions:
Sattlecker, M.; Stone, N.; Smith, J. & Bessant, C. Assessment of robustness and transferability of classification models built for cancer diagnostics using Raman spectroscopy J Raman Spectrosc, 2010, 897-903.
DOI: 10.1002/jrs.2798
If you read German, I could send you my Diplom where I tried to find a good set of pre-processing steps for infrared spectra. It turned out that other than having a general sensible choice (from physical/chemical/biological knowledge of the application and the measurements), the only tested pre-processing method where the choice actually had a consistent influence was applying a rather strict quality control filter.
E.g. there's no question that normalization is needed because of the experimental set-up, but the actual choice e.g. min-max vs. area normalization didn't show any consistent influence. In turn, I conclude that the analysis is reasonably robust against the particular normalization method.
now about the dirty tricks:
All kinds of things that lead to optimistic bias in validation results
Data leaks between training and test data
not splitting the data properly = at the topmost level in the data hierarchy (e.g. treating samples prepared from the same stock solution as independent, treating multiple measurements from the same patient/same time series as independent, etc.)
Data-driven feature reduction (PCA, PLS) done on the whole data set, "validating" only the last level of the model (e.g. the regression done in PCA score space).
Same is true for any kind of pre-processing that involves more than one case: all these have to be done on the training data only, and then the results are applied to the test data.
Model selection bias: Also data-driven model optimization/selection without outer validation of the final model is a kind of data leak.
Creating "self-fulfilling prophecies" in the modeling process
assign reference labels for classification using a cluster analysis
exclude cases because they don't fit into the model without reporting proper criteria for outlier exclusion
(Note that in some applications an automated decistion/filter to reject bad cases/measurements that are out of the specified domain of applicability is possible and sensible, though)
(test) data sets not representative for the application. E.g. the applications I work on frequently deal with medical diagnoses. There are always difficult/borderline cases where it is hard to obtain reference diagnoses. However, excluding such cases from the data analysis creates an artificially easy problem that excludes all those cases for which the model would be needed most.
For a discussion in the context of semi-supervised models see
Berget, I. & Næs, T. Using unclassified observations for improving classifiers J Chemom, 2004, 18, 103-111. DOI: 10.1002/cem.857
claiming that (resampling) validation results for unknown cases generalize to unknown future cases. Also leading to an optimistic bias (bullet 1).
Jumping from observations e.g. on cell line data or xenografts to conclusions about humans. Or from few precisely specified and selected groups of humans to applicability as medical screening tool, etc.
Not having enough test cases to warrant the conclusion. At least a rough sanity check on the validation results should be done (e.g. is the confidence interval for the validation results narrow enough to allow practically relevant conclusions, i.e. with respect to what would be considered very good, reasonable, bad and too-bad-to-dare-reporting models.)
Humans are biased towards recognizing patterns (as opposed to overlooking patterns). This can also lead to setting up too complex models which are overfit and not robust at all.
All these points involve a trade-off between what is good and sensible and what is too much, and/or which influencing factors are important and which are not. Personally, I can live happily with modeling where all kinds of decisions are done by the data analyst as long as these decisions are reported and justified.
OTOH, I think one needs to judge carfully which level of validation is sensible in a given application. All (or most of these) these points can make sense in certain situations, but they limit the conclusions that can be drawn. Which in itself is IMHO not a problem - this is just a very normal way to "pay" for using a method can can be practically applied. Problems IMHO arise from not being aware of the limitations.
|
Unwritten laws and dirty tricks to influence the outcome of a regression analysis
not even robust to small changes in the modeling setup
I'm analytical chemist/chemometrician. In my field, the related key words
related to demonstrating/stating how robust the model/the whole analy
|
45,805
|
Probability of seeing k faces that appear more than 3 times when rolling 10 dice
|
There is a simple elegant algebraic method. It amounts to little more than repeated pattern matching and replacement (with very simple patterns), making it efficient (at least for small problems like this one).
The aim is to compute the generating function for the number of faces appearing $k$ or more times out of $n$ rolls of a generalized "die" that has a finite number (say $m$) of faces with probabilities $\mathbf{p}=(p_1, p_2, \ldots, p_m)$ of appearing. This, by definition, is a polynomial
$$g(u; n,k,\mathbf{p}) = g_0 + g_1u + \cdots + g_ju^j + \cdots$$
where $g_j$ is the chance of exactly $j$ faces appearing $k$ or more times.
The particular question concerns the case $k=3$, $n=10$, and $\mathbf{p}=\left(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\right)$. To illustrate the process, though, consider a two-sided "die" with "faces" indexed by $1$ and $2$ having probabilities $p=\left(\frac{1}{2},\frac{1}{2}\right)$ of appearing: a "fair coin." Let's decrease $n$ to $5$ and $k$ to $2$ to keep the expressions short.
Begin with a generating function of the die itself,
$$f(\mathbf{x}; \mathbf{p}) = p_1 x_1 + p_2 x_2 + \cdots +p_m x_m.$$
This is a polynomial in the $m$ variables $\mathbf{x}=\left(x_1, \ldots, x_m\right)$. For the fair coin,
$$f\left(\left(x_1,x_2\right); \left(\frac{1}{2},\frac{1}{2}\right)\right) = \frac{1}{2}x_1 + \frac{1}{2}x_2.$$
We can read all possible outcomes of $n$ throws by expanding $f(\mathbf{x},\mathbf{p})$ to the $n^\text{th}$ power.
$$f(\mathbf{x},\mathbf{p})^5 = \frac{x_1^5}{32}+\frac{5}{32} x_2 x_1^4+\frac{5}{16} x_2^2 x_1^3+\frac{5}{16} x_2^3 x_1^2+\frac{5}{32} x_2^4 x_1+\frac{x_2^5}{32}.$$
This says there is a $\frac{1}{32}$ chance of seeing five ones, a $\frac{5}{32}$ chance of four ones and one two, and so on.
The trick is to avoid doing this full calculation, which is pure brute force. Notice that we don't need most of it: we only need to recognize the terms where the power of $x_1$ or $x_2$ is $k=2$ or greater. The rest we can throw away. One way to accomplish this--which is made rigorous by the algebraic concept of a polynomial ideal--is to introduce $m$ new variables, say $u_1, u_2, \ldots, u_m$. We simply declare that $u_i = x_i^k$ for each $i$ and use this to simplify the expansion. Moreover, the rules of algebra imply we may perform the simplification by computing $f(\mathbf{x},\mathbf{p})^n$ recursively as
$$f(\mathbf{x},\mathbf{p})^n = f(\mathbf{x},\mathbf{p})f(\mathbf{x},\mathbf{p})^{n-1}$$
and doing the simplification at each step. In the example this procedure yields
$$f(\mathbf{x},\mathbf{p})^5 = \frac{1}{32} u_1^2 x_1+\frac{5}{32} u_1^2 x_2+\frac{5}{16} u_2 u_1 x_1+\frac{5}{16} u_2 u_1 x_2+\frac{5}{32} u_2^2 x_1+\frac{1}{32} u_2^2 x_2.$$
We may polish this off with a few more conversions. First, the appearance of any power of $u_i$ of $2$ or greater just reflects the fact that $x_i^k$ was found multiple times. For instance, $u_1^2$ means $x_1^k$ appeared twice--that is, $x_1$ appeared at least $2k$ times. Furthermore, after having computed $f\left(\mathbf{x},\mathbf{p}\right)^n$ we can ignore any powers of the $x_i$ still lying around. That is easily done by setting all the $x_i=1$. In the example the result of these two operations is
$$\frac{5 u_2 u_1}{8}+\frac{3 u_1}{16}+\frac{3 u_2}{16}.$$
All that remains to do is track the total degree of each monomial: $u_2u_1$ has degree $2$, indicating that two separate faces appeared at least $k$ times. $u_1$ and $u_2$ have degree $1$, indicating that exactly one face appeared at least $k$ times. The degree is easy to compute: set all the variables $u_i=u$ for a single variable $u$. In the example we have thereby found that
$$g(u;n,k,\mathbf{p}) = \frac{5 u^2}{8}+\frac{3 u}{8}.$$
(Interpretation: after five flips of a fair coin, there is a $3/8$ chance that exactly one face will be observed two or more times and a $5/8$ chance that both faces will be observed two or more times. These results are easily checked.)
For the setting in the question, with ten tosses of a fair die, these calculations yield
$$g\left(u; 10, 3, \left(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\right)\right)=\frac{4375 u^3}{209952}+\frac{52415 u^2}{139968}+\frac{225559 u}{419904}+\frac{175}{2592}.$$
From this we may easily compute any probabilities we wish. For instance, the event where two distinct faces each appear three or more times (and all other faces two times or fewer) has probability equal to the coefficient of $u^2$ and therefore is $52415/139968 \approx 0.374478.$
Using a computer algebra system, the code is remarkably short. The following is a Mathematica solution. All the work is done in the three middle lines, exactly following the foregoing description.
g[y_, p_List, n_Integer, k_Integer] /; n >= 1 && k >= 1 :=
Module[{f, x, u, a, i},
f = Sum[p[[i]] Subscript[x, i], {i, 1, Length[p]}]/Total[p];
Nest[(Expand[f #] /. {Power[Subscript[x,i_], a_] /; a == k -> Subscript[u,i]}) &, 1, n]
/. {Subscript[x, _] -> 1, Power[Subscript[u, _], _] -> y, Subscript[u, _] -> y}
]
g[u, ConstantArray[1/6, 6], 10, 3]
Execution took 0.2 seconds.
|
Probability of seeing k faces that appear more than 3 times when rolling 10 dice
|
There is a simple elegant algebraic method. It amounts to little more than repeated pattern matching and replacement (with very simple patterns), making it efficient (at least for small problems like
|
Probability of seeing k faces that appear more than 3 times when rolling 10 dice
There is a simple elegant algebraic method. It amounts to little more than repeated pattern matching and replacement (with very simple patterns), making it efficient (at least for small problems like this one).
The aim is to compute the generating function for the number of faces appearing $k$ or more times out of $n$ rolls of a generalized "die" that has a finite number (say $m$) of faces with probabilities $\mathbf{p}=(p_1, p_2, \ldots, p_m)$ of appearing. This, by definition, is a polynomial
$$g(u; n,k,\mathbf{p}) = g_0 + g_1u + \cdots + g_ju^j + \cdots$$
where $g_j$ is the chance of exactly $j$ faces appearing $k$ or more times.
The particular question concerns the case $k=3$, $n=10$, and $\mathbf{p}=\left(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\right)$. To illustrate the process, though, consider a two-sided "die" with "faces" indexed by $1$ and $2$ having probabilities $p=\left(\frac{1}{2},\frac{1}{2}\right)$ of appearing: a "fair coin." Let's decrease $n$ to $5$ and $k$ to $2$ to keep the expressions short.
Begin with a generating function of the die itself,
$$f(\mathbf{x}; \mathbf{p}) = p_1 x_1 + p_2 x_2 + \cdots +p_m x_m.$$
This is a polynomial in the $m$ variables $\mathbf{x}=\left(x_1, \ldots, x_m\right)$. For the fair coin,
$$f\left(\left(x_1,x_2\right); \left(\frac{1}{2},\frac{1}{2}\right)\right) = \frac{1}{2}x_1 + \frac{1}{2}x_2.$$
We can read all possible outcomes of $n$ throws by expanding $f(\mathbf{x},\mathbf{p})$ to the $n^\text{th}$ power.
$$f(\mathbf{x},\mathbf{p})^5 = \frac{x_1^5}{32}+\frac{5}{32} x_2 x_1^4+\frac{5}{16} x_2^2 x_1^3+\frac{5}{16} x_2^3 x_1^2+\frac{5}{32} x_2^4 x_1+\frac{x_2^5}{32}.$$
This says there is a $\frac{1}{32}$ chance of seeing five ones, a $\frac{5}{32}$ chance of four ones and one two, and so on.
The trick is to avoid doing this full calculation, which is pure brute force. Notice that we don't need most of it: we only need to recognize the terms where the power of $x_1$ or $x_2$ is $k=2$ or greater. The rest we can throw away. One way to accomplish this--which is made rigorous by the algebraic concept of a polynomial ideal--is to introduce $m$ new variables, say $u_1, u_2, \ldots, u_m$. We simply declare that $u_i = x_i^k$ for each $i$ and use this to simplify the expansion. Moreover, the rules of algebra imply we may perform the simplification by computing $f(\mathbf{x},\mathbf{p})^n$ recursively as
$$f(\mathbf{x},\mathbf{p})^n = f(\mathbf{x},\mathbf{p})f(\mathbf{x},\mathbf{p})^{n-1}$$
and doing the simplification at each step. In the example this procedure yields
$$f(\mathbf{x},\mathbf{p})^5 = \frac{1}{32} u_1^2 x_1+\frac{5}{32} u_1^2 x_2+\frac{5}{16} u_2 u_1 x_1+\frac{5}{16} u_2 u_1 x_2+\frac{5}{32} u_2^2 x_1+\frac{1}{32} u_2^2 x_2.$$
We may polish this off with a few more conversions. First, the appearance of any power of $u_i$ of $2$ or greater just reflects the fact that $x_i^k$ was found multiple times. For instance, $u_1^2$ means $x_1^k$ appeared twice--that is, $x_1$ appeared at least $2k$ times. Furthermore, after having computed $f\left(\mathbf{x},\mathbf{p}\right)^n$ we can ignore any powers of the $x_i$ still lying around. That is easily done by setting all the $x_i=1$. In the example the result of these two operations is
$$\frac{5 u_2 u_1}{8}+\frac{3 u_1}{16}+\frac{3 u_2}{16}.$$
All that remains to do is track the total degree of each monomial: $u_2u_1$ has degree $2$, indicating that two separate faces appeared at least $k$ times. $u_1$ and $u_2$ have degree $1$, indicating that exactly one face appeared at least $k$ times. The degree is easy to compute: set all the variables $u_i=u$ for a single variable $u$. In the example we have thereby found that
$$g(u;n,k,\mathbf{p}) = \frac{5 u^2}{8}+\frac{3 u}{8}.$$
(Interpretation: after five flips of a fair coin, there is a $3/8$ chance that exactly one face will be observed two or more times and a $5/8$ chance that both faces will be observed two or more times. These results are easily checked.)
For the setting in the question, with ten tosses of a fair die, these calculations yield
$$g\left(u; 10, 3, \left(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\right)\right)=\frac{4375 u^3}{209952}+\frac{52415 u^2}{139968}+\frac{225559 u}{419904}+\frac{175}{2592}.$$
From this we may easily compute any probabilities we wish. For instance, the event where two distinct faces each appear three or more times (and all other faces two times or fewer) has probability equal to the coefficient of $u^2$ and therefore is $52415/139968 \approx 0.374478.$
Using a computer algebra system, the code is remarkably short. The following is a Mathematica solution. All the work is done in the three middle lines, exactly following the foregoing description.
g[y_, p_List, n_Integer, k_Integer] /; n >= 1 && k >= 1 :=
Module[{f, x, u, a, i},
f = Sum[p[[i]] Subscript[x, i], {i, 1, Length[p]}]/Total[p];
Nest[(Expand[f #] /. {Power[Subscript[x,i_], a_] /; a == k -> Subscript[u,i]}) &, 1, n]
/. {Subscript[x, _] -> 1, Power[Subscript[u, _], _] -> y, Subscript[u, _] -> y}
]
g[u, ConstantArray[1/6, 6], 10, 3]
Execution took 0.2 seconds.
|
Probability of seeing k faces that appear more than 3 times when rolling 10 dice
There is a simple elegant algebraic method. It amounts to little more than repeated pattern matching and replacement (with very simple patterns), making it efficient (at least for small problems like
|
45,806
|
Intercept from standardized coefficients in logistic regression
|
Start with a simple logistic regression:
$\,\,\text{logit}(\mu) \,= \beta_0 + \beta_1 x\quad\quad$ (original)
$\quad\quad\quad\quad= \beta_0^* + \beta_1^* (x-\bar{x})/s_x\quad\quad$ (standardized x)
$\quad\quad\quad\quad= (\beta_0^* -\beta_1^*\bar{x}/s_x)+ (\beta_1^*/s_x) x$
So $\beta_1=\beta_1^*/s_x$ and $\beta_0=\beta_0^* -\beta_1^*\bar{x}/s_x$
More generally, the same manipulation yields
$\beta_0=\beta_0^* -\sum_{i=1}^p\beta_i^*\bar{x_i}/s_{x_i}$ and $\beta_i=\beta_i^*/s_{x_i}$
|
Intercept from standardized coefficients in logistic regression
|
Start with a simple logistic regression:
$\,\,\text{logit}(\mu) \,= \beta_0 + \beta_1 x\quad\quad$ (original)
$\quad\quad\quad\quad= \beta_0^* + \beta_1^* (x-\bar{x})/s_x\quad\quad$ (standardized x)
|
Intercept from standardized coefficients in logistic regression
Start with a simple logistic regression:
$\,\,\text{logit}(\mu) \,= \beta_0 + \beta_1 x\quad\quad$ (original)
$\quad\quad\quad\quad= \beta_0^* + \beta_1^* (x-\bar{x})/s_x\quad\quad$ (standardized x)
$\quad\quad\quad\quad= (\beta_0^* -\beta_1^*\bar{x}/s_x)+ (\beta_1^*/s_x) x$
So $\beta_1=\beta_1^*/s_x$ and $\beta_0=\beta_0^* -\beta_1^*\bar{x}/s_x$
More generally, the same manipulation yields
$\beta_0=\beta_0^* -\sum_{i=1}^p\beta_i^*\bar{x_i}/s_{x_i}$ and $\beta_i=\beta_i^*/s_{x_i}$
|
Intercept from standardized coefficients in logistic regression
Start with a simple logistic regression:
$\,\,\text{logit}(\mu) \,= \beta_0 + \beta_1 x\quad\quad$ (original)
$\quad\quad\quad\quad= \beta_0^* + \beta_1^* (x-\bar{x})/s_x\quad\quad$ (standardized x)
|
45,807
|
How to get confidence on classification predictions with multi-class Vowpal Wabbit
|
Unfortunately, because of the filter tree / elimination implementation in ECT, getting a measure of confidence is not straight-forward. If you can sacrifice some speed, using -oaa with logistic loss and the -r (--raw_predictions) option gives you raw scores that you can convert to a normalized measure of relative "confidence". Say you have a file like this in "ect.dat":
1 ex1| a
2 ex2| a b
3 ex3| c d e
2 ex4| b a
1 ex5| f g
We run the one-against-all:
vw --oaa 3 ect.dat -f oaa.model --loss_function logistic
Then run prediction with raw scores output:
vw -t -i oaa.model ect.dat -p oaa.predict -r oaa.rawp
You get predictions in oaa.predict:
1.000000 ex1
2.000000 ex2
3.000000 ex3
2.000000 ex4
1.000000 ex5
and raw scores for each class in oaa.rawp:
1:0.0345831 2:-0.0888872 3:-0.533179 ex1
1:-0.241225 2:0.170322 3:-0.749773 ex2
1:-0.426383 2:-0.502638 3:0.154067 ex3
1:-0.241225 2:0.170322 3:-0.749773 ex4
1:0.307398 2:-0.387151 3:-0.502747 ex5
You can map these using 1/(1+exp(-score)) and then normalize in various ways to get something like these:
1:0.62144216 2:0.5328338 3:0.20096953 ex1
1:0.57251362 2:0.71125717 3:0.1433303 ex2
1:0.37941591 2:0.29294807 3:0.66095287 ex3
1:0.57251362 2:0.71125717 3:0.1433303 ex4
1:0.72177734 2:0.37525053 3:0.2704246 ex5
Once you have a significantly large data set scored, you can plot threshold in steps of 0.1, for instance, against percent correct if using that threshold to score, to get an idea of what threshold will give you, say, 95% correct for class 1, and so on.
This discussion might be useful.
|
How to get confidence on classification predictions with multi-class Vowpal Wabbit
|
Unfortunately, because of the filter tree / elimination implementation in ECT, getting a measure of confidence is not straight-forward. If you can sacrifice some speed, using -oaa with logistic loss
|
How to get confidence on classification predictions with multi-class Vowpal Wabbit
Unfortunately, because of the filter tree / elimination implementation in ECT, getting a measure of confidence is not straight-forward. If you can sacrifice some speed, using -oaa with logistic loss and the -r (--raw_predictions) option gives you raw scores that you can convert to a normalized measure of relative "confidence". Say you have a file like this in "ect.dat":
1 ex1| a
2 ex2| a b
3 ex3| c d e
2 ex4| b a
1 ex5| f g
We run the one-against-all:
vw --oaa 3 ect.dat -f oaa.model --loss_function logistic
Then run prediction with raw scores output:
vw -t -i oaa.model ect.dat -p oaa.predict -r oaa.rawp
You get predictions in oaa.predict:
1.000000 ex1
2.000000 ex2
3.000000 ex3
2.000000 ex4
1.000000 ex5
and raw scores for each class in oaa.rawp:
1:0.0345831 2:-0.0888872 3:-0.533179 ex1
1:-0.241225 2:0.170322 3:-0.749773 ex2
1:-0.426383 2:-0.502638 3:0.154067 ex3
1:-0.241225 2:0.170322 3:-0.749773 ex4
1:0.307398 2:-0.387151 3:-0.502747 ex5
You can map these using 1/(1+exp(-score)) and then normalize in various ways to get something like these:
1:0.62144216 2:0.5328338 3:0.20096953 ex1
1:0.57251362 2:0.71125717 3:0.1433303 ex2
1:0.37941591 2:0.29294807 3:0.66095287 ex3
1:0.57251362 2:0.71125717 3:0.1433303 ex4
1:0.72177734 2:0.37525053 3:0.2704246 ex5
Once you have a significantly large data set scored, you can plot threshold in steps of 0.1, for instance, against percent correct if using that threshold to score, to get an idea of what threshold will give you, say, 95% correct for class 1, and so on.
This discussion might be useful.
|
How to get confidence on classification predictions with multi-class Vowpal Wabbit
Unfortunately, because of the filter tree / elimination implementation in ECT, getting a measure of confidence is not straight-forward. If you can sacrifice some speed, using -oaa with logistic loss
|
45,808
|
Multilevel models including random slopes: how to calculate variance
|
Let me start with simpler models (detailed answers below), and let me use a slightly different notation (NB: random effecs at different levels assumed to be uncorrelated).
Model 1 (Two levels, random intercept, fixed slope). There are $N$
observations of $J$ students:
$$\begin{align}y_{ij}&=\pi_{0j}+\beta_1
X_{ij}+\varepsilon_{ij},\quad&\varepsilon_{ij}\sim\mathcal{N}(0,\sigma^2_\varepsilon)\\
\pi_{0j}&=\beta_0+b_{0j},\quad& b_{0j}\sim\mathcal{N}(0,\sigma^2_0)\end{align}$$.
If we substitute for $\pi_0$ and $\pi_1$ we get:
$$y_{ij}=\beta_0+\beta_1X_{ij}+(b_{0j}+\varepsilon_{ij})$$ so:
$$\begin{align}\text{Var}(y_{ij})&=\text{Var}(b_{0j}+\varepsilon_i)=\sigma^2_0+\sigma^2_\varepsilon
\\ \text{Cov}(y_{ij},y_{i'j})&=\sigma^2_0 \quad& i\ne i' \\
\text{Cov}(y_{ij},y_{i'j'})&=0 \quad& i\ne i',\;j\ne j' \end{align}$$ The
intraclass correlation coefficient:
$$\rho=\frac{\sigma^2_0}{\sigma^2_0+\sigma^2_\varepsilon}$$ measures the
proportion of the variance in the outcome that is between students. As to the
overall covariance matrix, it is (Goldstein,
Multilevel Statistical Models,
pg. 20): $$ \begin{bmatrix}
\sigma^2_0\mathbf{J}_{N_1}+\sigma^2_\varepsilon\mathbf{I}_{N_1} & 0 & \dots &
0 \\ \vdots & \vdots & \vdots & \vdots \\ \dots & \dots &
\sigma^2_0\mathbf{J}_{N_j}+\sigma^2_\varepsilon\mathbf{I}_{N_j} & 0 \\ \vdots
& \vdots & \vdots & \vdots \\ 0 & 0 & 0 &
\sigma^2_0\mathbf{J}_{N_J}+\sigma^2_\varepsilon\mathbf{I}_{N_J}
\end{bmatrix}$$ where $N_j$ is the number of observations for student $j$,
$\mathbf{J}_{N_j}$ is the $(N_j\times N_j)$ matrix of ones and
$\mathbf{I}_{N_j}$ is the $(N_j\times N_j)$ identity matrix. For example, if
there are $J=2$ students and $N_1=3,N_1=2$ observations:
$$\begin{bmatrix}
\sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 & \sigma^2_0 & 0 & 0 \\
\sigma^2_0 & \sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 & 0 & 0 \\
\sigma^2_0 & \sigma^2_0 & \sigma^2_0+\sigma^2_\varepsilon & 0 & 0 \\ 0 & 0 & 0
& \sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 \\ 0 & 0 & 0 & \sigma^2_0 &
\sigma^2_0+\sigma^2_\varepsilon
\end{bmatrix}=(\sigma^2_0+\sigma^2_\varepsilon) \begin{bmatrix} 1 & \rho &
\rho & 0 & 0 \\ \rho & 1 & \rho & 0 & 0 \\ \rho & \rho & 1 & 0 & 0 \\ 0 & 0 &
0 & 1 & \rho \\ 0 & 0 & 0 & \rho & 1 \end{bmatrix}$$
Model 2 (Three levels, random intercept, fixed slope). There are $N$ observations, $J$ students, and $K$ schools:
$$\begin{align}
y_{ijk}&=\pi_{0jk}+\beta_1 X_{ijk}+\varepsilon_{ijk},\quad&\varepsilon_{iij}\sim\mathcal{N}(0,\sigma^2_\varepsilon) \\
\pi_{0jk} &= \gamma_{0k}+b_{0jk},\quad& b_{0jk}\sim\mathcal{N}(0,\sigma^2_0) \\
\gamma_{0k} &= \beta_0 + b_{0k},\quad & b_{0k}\sim\mathcal{N}(0,\tau^2_0)
\end{align}$$
The composite model is:
$$y_{ijk}=\beta_0+\beta_1 X_{ijk}+ (b_{0k}+b_{0jk}+\varepsilon_{ijk})$$
and:
$$\text{Var}(y_{ijk})=\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon$$
Instead of one intraclass correlation coefficient, several correlation coefficients may be defined:
$(\tau^2_0+\sigma^2_0)/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among students;
$\tau^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among schools;
$\sigma^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among students within schools;
$\sigma^2_\varepsilon/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance within students.
The covariance matrix is complex. If there are $K=3$ schools, a covariance matrix looks like (Rodriguez):
$$(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)\begin{bmatrix}
1 & \rho_1 & \rho_2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\rho_1 & 1 & \rho_2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\rho_2 & \rho_2 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & \rho_1 & \rho_2 & \rho_2 & 0 & 0 & 0\\
0 & 0 & 0 & \rho_1 & 1 & \rho_2 & \rho_2 & 0 & 0 & 0 \\
0 & 0 & 0 & \rho_2 & \rho_2 & 1 & \rho_1 & 0 & 0 & 0 \\
0 & 0 & 0 & \rho_2 & \rho_2 & \rho_1 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & \rho_1 & \rho_2 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \rho_1 & 1 & \rho_2 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \rho_2 & \rho_2 & 1
\end{bmatrix}$$
where $\rho_1=(\tau^2_0+\sigma^2_0)/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$ and $\rho_2=\tau^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$.
Model 3 (Two levels, random intercept and slope). We let $\pi_1$ vary across the students in Model 1:
$$\begin{align}y_{ij}&=\pi_{0j}+\pi_1 X_{ij}+\varepsilon_{ij},\quad&\varepsilon_i\sim\mathcal{N}(0,\sigma^2_\varepsilon)\\
\pi_{0j}&=\beta_0+b_{0j},\quad& b_{0j}\sim\mathcal{N}(0,\sigma^2_0)\\
\pi_1 &= \beta_1+b_{1j},\quad& b_{1j}\sim\mathcal{N}(0,\sigma^2_1)
\end{align}$$
but now we must represent the dispersion of the level-2 random effects as a covariance matrix:
$$\text{Var}(\mathbf{b}_j)=\text{Var}\begin{bmatrix} b_{0j} \\ b_{1j} \end{bmatrix}
=\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}$$
The combined model is:
$$y_{ij}=\beta_0+\beta_1X_{ij}+(b_{0j}+b_{1j}X_{ij}+\varepsilon_{ij})$$
so (Goldstein, Multilevel Statistical Models, pg. 22):
$$\begin{align}\text{Var}(y_{ij})&=\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}'+\sigma^2_\varepsilon \\
\text{Cov}(y_{ij},y_{i'j})&=\sigma^2_0+2\sigma_{01}(X_{ij}+X_{i'j})+\sigma^2_1 X_{ij} X_{i'j} \\
\text{Cov}(y_{ij},y_{i'j'})&=0
\end{align}$$
The overall covariance matrix is still block diagonal but the blocks are: $\left(\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}\text{Var}(\mathbf{b}_j)\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}'\right)\mathbf{J}_{N_j}+\sigma^2_\varepsilon\mathbf{I}_{N_j}$.
We could define:
$$\rho=\frac{\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2}{\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2+\sigma^2_\varepsilon}$$
but it is not a correlation coefficient like the previous ones. The correlation between two observations is given by:
$$\frac{\sigma^2_0+2\sigma_{01}(X_{ij}+X_{i'j})+\sigma^2_1 X_{ij} X_{i'j}}
{\sqrt{(\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2+\sigma^2_\varepsilon)(\sigma^2_0+2\sigma_{01}X_{i'j}+\sigma^2_1 X_{i'j}^2+\sigma^2_\varepsilon)}}$$
Its value is a function of $X$, so there is not a unique correlation coefficient, but several coefficients that can be calculated for any value of the predictor variable(s) (Goldstein et al., Partitioning variation in multilevel models).
Model 4 (Three levels, random intercept and slope). We let $\pi_1$ vary across the students in Model 2:
$$\begin{align}
y_{ijk}&=\pi_{0jk}+\pi_{1jk} X_{ijk}+\varepsilon_{ijk},\quad&\varepsilon_{iij}\sim\mathcal{N}(0,\sigma^2_\varepsilon) \\
\pi_{0jk} &= \gamma_{0k}+b_{0jk},\quad& b_{0jk}\sim\mathcal{N}(0,\sigma^2_0) \\
\pi_{1jk} &= \gamma_{1k}+b_{1jk},\quad& b_{1jk}\sim\mathcal{N}(0,\sigma^2_1) \\
\gamma_{0k} &= \beta_0 + b_{0k},\quad & b_{0k}\sim\mathcal{N}(0,\tau^2_0) \\
\gamma_{1k} &= \beta_1 + b_{1k},\quad & b_{1k}\sim\mathcal{N}(0,\tau^2_1)
\end{align}$$
The covariance matrices for level-2 and level-3 are:
$$\text{Var}(\mathbf{b}_j)=\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}\qquad\qquad
\text{Var}(\mathbf{b}_k)=\begin{bmatrix} \tau^2_0 & \tau_{01} \\ \tau_{01} & \tau^2_1 \end{bmatrix}$$
The composite model is:
$$y_{ijk}=\beta_0 + \beta_1 X_{ijk} + (b_{0jk}+b_{1jk}
X_{ijk})+(b_{0k}+b_{1k} X_{ijk}) + \varepsilon_{ijk}$$
and the variance at level-1 is:
$$\text{Var}(y_{ijk})=\text{Var}(b_{0jk}+b_{1jk}
X_{ijk})+\text{Var}(b_{0k}+b_{1k} X_{ijk})+\text{Var}(\varepsilon_{ijk})$$
where $\text{Var}(b_{0jk}+b_{1jk} X_{ijk})$ is the variance at level-2 and
$\text{Var}(b_{0k}+b_{1k} X_{ijk})$ is the variance at level-3. They
depend on the value of $X$ as in Model 3.
Now:
Multilevel models including random slopes: how to calculate variance
I hope it is somewhat clear now.
$Y_{ijk}=\beta_0+\beta_1*Time+b_k+b_{jk}+\epsilon_{ijk}$
I'write: $Y_{ijk}=\beta_0+\beta_1\text{Time}+b_{0k}+b_{0jk}$ (Model 2) to
highlight that $b_{0k}$ and $b_{0jk}$ randomize $\beta_0$.
I add a random slope per school:
$Y_{ijk}=\beta_0+\beta_1* Time+b_{0k}+b_{1k}*Time+b_{jk}+\epsilon_{ijk}$
Is in this model the variation of $b_{0k}$ still meaningful?
I'd write: $Y_{ijk}=\beta_0+\beta_1\text{Time}+b_{0k}+b_{1k}\text{Time}+b_{0jk}+\epsilon_{ijk}$, i.e.:
$$Y_{ijk}=(\beta_0+b_{0jk}+b_{0k})+(\beta_1+b_{1k})\text{Time}+\epsilon_{ijk}$$
where $(\beta_0+b_{0jk}+b_{0k})$ is the random intercept per student within a
school and per school, and $(\beta_1+b_{1k})$ is the random slope
per school (Model 4 with $b_{1jk}=E(b_{1jk})=0$, $\sigma^2_1=0$.)
As to $b_{0k}$, the random intercept per school, it is even more meaningful
than $b_{1k}$! "Given that among multilevel modelers random slopes tend to be
more popular than heteroscedasticity, unrecognized heteroscedasticity may show
up in the form of a fitted model with a random slope [...] which then may
disappear if the heteroscedasticity is modeled" (Snijders and Berkhof,
Diagnostic Checks for Multilevel Models, §3.2.1).
Is my intuition correct that the variation between different schools
increases over time, as the random slopes drive the schools further apart?
In all the above models I have assumed that all random effects are
uncorrelated and that their variances are constant. Is these assumptions hold,
then covariances increase quadratically with time (see conjectures'
answer). However, if the $\tau$ variances and covariances decrease with time you could
observe a somewhat different pattern.
BTW, your plot does show a different pattern and suggests a bit of
heteroscedasticity more than a random slope.
the covariance between students within the same school is given by:
$\text{Cov}_{school}=\frac{\sigma^2_3}{\sigma^2_1+\sigma^2_2+\sigma^2_3}$
What is this covariance if a random intercept is included?
That is not a covariance, it is the $\rho_2$ correlation coefficient in
Model 2. The covariance between two schools depends on Time.
|
Multilevel models including random slopes: how to calculate variance
|
Let me start with simpler models (detailed answers below), and let me use a slightly different notation (NB: random effecs at different levels assumed to be uncorrelated).
Model 1 (Two levels, random
|
Multilevel models including random slopes: how to calculate variance
Let me start with simpler models (detailed answers below), and let me use a slightly different notation (NB: random effecs at different levels assumed to be uncorrelated).
Model 1 (Two levels, random intercept, fixed slope). There are $N$
observations of $J$ students:
$$\begin{align}y_{ij}&=\pi_{0j}+\beta_1
X_{ij}+\varepsilon_{ij},\quad&\varepsilon_{ij}\sim\mathcal{N}(0,\sigma^2_\varepsilon)\\
\pi_{0j}&=\beta_0+b_{0j},\quad& b_{0j}\sim\mathcal{N}(0,\sigma^2_0)\end{align}$$.
If we substitute for $\pi_0$ and $\pi_1$ we get:
$$y_{ij}=\beta_0+\beta_1X_{ij}+(b_{0j}+\varepsilon_{ij})$$ so:
$$\begin{align}\text{Var}(y_{ij})&=\text{Var}(b_{0j}+\varepsilon_i)=\sigma^2_0+\sigma^2_\varepsilon
\\ \text{Cov}(y_{ij},y_{i'j})&=\sigma^2_0 \quad& i\ne i' \\
\text{Cov}(y_{ij},y_{i'j'})&=0 \quad& i\ne i',\;j\ne j' \end{align}$$ The
intraclass correlation coefficient:
$$\rho=\frac{\sigma^2_0}{\sigma^2_0+\sigma^2_\varepsilon}$$ measures the
proportion of the variance in the outcome that is between students. As to the
overall covariance matrix, it is (Goldstein,
Multilevel Statistical Models,
pg. 20): $$ \begin{bmatrix}
\sigma^2_0\mathbf{J}_{N_1}+\sigma^2_\varepsilon\mathbf{I}_{N_1} & 0 & \dots &
0 \\ \vdots & \vdots & \vdots & \vdots \\ \dots & \dots &
\sigma^2_0\mathbf{J}_{N_j}+\sigma^2_\varepsilon\mathbf{I}_{N_j} & 0 \\ \vdots
& \vdots & \vdots & \vdots \\ 0 & 0 & 0 &
\sigma^2_0\mathbf{J}_{N_J}+\sigma^2_\varepsilon\mathbf{I}_{N_J}
\end{bmatrix}$$ where $N_j$ is the number of observations for student $j$,
$\mathbf{J}_{N_j}$ is the $(N_j\times N_j)$ matrix of ones and
$\mathbf{I}_{N_j}$ is the $(N_j\times N_j)$ identity matrix. For example, if
there are $J=2$ students and $N_1=3,N_1=2$ observations:
$$\begin{bmatrix}
\sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 & \sigma^2_0 & 0 & 0 \\
\sigma^2_0 & \sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 & 0 & 0 \\
\sigma^2_0 & \sigma^2_0 & \sigma^2_0+\sigma^2_\varepsilon & 0 & 0 \\ 0 & 0 & 0
& \sigma^2_0+\sigma^2_\varepsilon & \sigma^2_0 \\ 0 & 0 & 0 & \sigma^2_0 &
\sigma^2_0+\sigma^2_\varepsilon
\end{bmatrix}=(\sigma^2_0+\sigma^2_\varepsilon) \begin{bmatrix} 1 & \rho &
\rho & 0 & 0 \\ \rho & 1 & \rho & 0 & 0 \\ \rho & \rho & 1 & 0 & 0 \\ 0 & 0 &
0 & 1 & \rho \\ 0 & 0 & 0 & \rho & 1 \end{bmatrix}$$
Model 2 (Three levels, random intercept, fixed slope). There are $N$ observations, $J$ students, and $K$ schools:
$$\begin{align}
y_{ijk}&=\pi_{0jk}+\beta_1 X_{ijk}+\varepsilon_{ijk},\quad&\varepsilon_{iij}\sim\mathcal{N}(0,\sigma^2_\varepsilon) \\
\pi_{0jk} &= \gamma_{0k}+b_{0jk},\quad& b_{0jk}\sim\mathcal{N}(0,\sigma^2_0) \\
\gamma_{0k} &= \beta_0 + b_{0k},\quad & b_{0k}\sim\mathcal{N}(0,\tau^2_0)
\end{align}$$
The composite model is:
$$y_{ijk}=\beta_0+\beta_1 X_{ijk}+ (b_{0k}+b_{0jk}+\varepsilon_{ijk})$$
and:
$$\text{Var}(y_{ijk})=\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon$$
Instead of one intraclass correlation coefficient, several correlation coefficients may be defined:
$(\tau^2_0+\sigma^2_0)/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among students;
$\tau^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among schools;
$\sigma^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance among students within schools;
$\sigma^2_\varepsilon/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$: the proportion of variance within students.
The covariance matrix is complex. If there are $K=3$ schools, a covariance matrix looks like (Rodriguez):
$$(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)\begin{bmatrix}
1 & \rho_1 & \rho_2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\rho_1 & 1 & \rho_2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\rho_2 & \rho_2 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & \rho_1 & \rho_2 & \rho_2 & 0 & 0 & 0\\
0 & 0 & 0 & \rho_1 & 1 & \rho_2 & \rho_2 & 0 & 0 & 0 \\
0 & 0 & 0 & \rho_2 & \rho_2 & 1 & \rho_1 & 0 & 0 & 0 \\
0 & 0 & 0 & \rho_2 & \rho_2 & \rho_1 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & \rho_1 & \rho_2 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \rho_1 & 1 & \rho_2 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \rho_2 & \rho_2 & 1
\end{bmatrix}$$
where $\rho_1=(\tau^2_0+\sigma^2_0)/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$ and $\rho_2=\tau^2_0/(\tau^2_0+\sigma^2_0+\sigma^2_\varepsilon)$.
Model 3 (Two levels, random intercept and slope). We let $\pi_1$ vary across the students in Model 1:
$$\begin{align}y_{ij}&=\pi_{0j}+\pi_1 X_{ij}+\varepsilon_{ij},\quad&\varepsilon_i\sim\mathcal{N}(0,\sigma^2_\varepsilon)\\
\pi_{0j}&=\beta_0+b_{0j},\quad& b_{0j}\sim\mathcal{N}(0,\sigma^2_0)\\
\pi_1 &= \beta_1+b_{1j},\quad& b_{1j}\sim\mathcal{N}(0,\sigma^2_1)
\end{align}$$
but now we must represent the dispersion of the level-2 random effects as a covariance matrix:
$$\text{Var}(\mathbf{b}_j)=\text{Var}\begin{bmatrix} b_{0j} \\ b_{1j} \end{bmatrix}
=\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}$$
The combined model is:
$$y_{ij}=\beta_0+\beta_1X_{ij}+(b_{0j}+b_{1j}X_{ij}+\varepsilon_{ij})$$
so (Goldstein, Multilevel Statistical Models, pg. 22):
$$\begin{align}\text{Var}(y_{ij})&=\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}'+\sigma^2_\varepsilon \\
\text{Cov}(y_{ij},y_{i'j})&=\sigma^2_0+2\sigma_{01}(X_{ij}+X_{i'j})+\sigma^2_1 X_{ij} X_{i'j} \\
\text{Cov}(y_{ij},y_{i'j'})&=0
\end{align}$$
The overall covariance matrix is still block diagonal but the blocks are: $\left(\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}\text{Var}(\mathbf{b}_j)\begin{bmatrix} \mathbf{1} & \mathbf{X} \end{bmatrix}'\right)\mathbf{J}_{N_j}+\sigma^2_\varepsilon\mathbf{I}_{N_j}$.
We could define:
$$\rho=\frac{\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2}{\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2+\sigma^2_\varepsilon}$$
but it is not a correlation coefficient like the previous ones. The correlation between two observations is given by:
$$\frac{\sigma^2_0+2\sigma_{01}(X_{ij}+X_{i'j})+\sigma^2_1 X_{ij} X_{i'j}}
{\sqrt{(\sigma^2_0+2\sigma_{01}X_{ij}+\sigma^2_1 X_{ij}^2+\sigma^2_\varepsilon)(\sigma^2_0+2\sigma_{01}X_{i'j}+\sigma^2_1 X_{i'j}^2+\sigma^2_\varepsilon)}}$$
Its value is a function of $X$, so there is not a unique correlation coefficient, but several coefficients that can be calculated for any value of the predictor variable(s) (Goldstein et al., Partitioning variation in multilevel models).
Model 4 (Three levels, random intercept and slope). We let $\pi_1$ vary across the students in Model 2:
$$\begin{align}
y_{ijk}&=\pi_{0jk}+\pi_{1jk} X_{ijk}+\varepsilon_{ijk},\quad&\varepsilon_{iij}\sim\mathcal{N}(0,\sigma^2_\varepsilon) \\
\pi_{0jk} &= \gamma_{0k}+b_{0jk},\quad& b_{0jk}\sim\mathcal{N}(0,\sigma^2_0) \\
\pi_{1jk} &= \gamma_{1k}+b_{1jk},\quad& b_{1jk}\sim\mathcal{N}(0,\sigma^2_1) \\
\gamma_{0k} &= \beta_0 + b_{0k},\quad & b_{0k}\sim\mathcal{N}(0,\tau^2_0) \\
\gamma_{1k} &= \beta_1 + b_{1k},\quad & b_{1k}\sim\mathcal{N}(0,\tau^2_1)
\end{align}$$
The covariance matrices for level-2 and level-3 are:
$$\text{Var}(\mathbf{b}_j)=\begin{bmatrix} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{bmatrix}\qquad\qquad
\text{Var}(\mathbf{b}_k)=\begin{bmatrix} \tau^2_0 & \tau_{01} \\ \tau_{01} & \tau^2_1 \end{bmatrix}$$
The composite model is:
$$y_{ijk}=\beta_0 + \beta_1 X_{ijk} + (b_{0jk}+b_{1jk}
X_{ijk})+(b_{0k}+b_{1k} X_{ijk}) + \varepsilon_{ijk}$$
and the variance at level-1 is:
$$\text{Var}(y_{ijk})=\text{Var}(b_{0jk}+b_{1jk}
X_{ijk})+\text{Var}(b_{0k}+b_{1k} X_{ijk})+\text{Var}(\varepsilon_{ijk})$$
where $\text{Var}(b_{0jk}+b_{1jk} X_{ijk})$ is the variance at level-2 and
$\text{Var}(b_{0k}+b_{1k} X_{ijk})$ is the variance at level-3. They
depend on the value of $X$ as in Model 3.
Now:
Multilevel models including random slopes: how to calculate variance
I hope it is somewhat clear now.
$Y_{ijk}=\beta_0+\beta_1*Time+b_k+b_{jk}+\epsilon_{ijk}$
I'write: $Y_{ijk}=\beta_0+\beta_1\text{Time}+b_{0k}+b_{0jk}$ (Model 2) to
highlight that $b_{0k}$ and $b_{0jk}$ randomize $\beta_0$.
I add a random slope per school:
$Y_{ijk}=\beta_0+\beta_1* Time+b_{0k}+b_{1k}*Time+b_{jk}+\epsilon_{ijk}$
Is in this model the variation of $b_{0k}$ still meaningful?
I'd write: $Y_{ijk}=\beta_0+\beta_1\text{Time}+b_{0k}+b_{1k}\text{Time}+b_{0jk}+\epsilon_{ijk}$, i.e.:
$$Y_{ijk}=(\beta_0+b_{0jk}+b_{0k})+(\beta_1+b_{1k})\text{Time}+\epsilon_{ijk}$$
where $(\beta_0+b_{0jk}+b_{0k})$ is the random intercept per student within a
school and per school, and $(\beta_1+b_{1k})$ is the random slope
per school (Model 4 with $b_{1jk}=E(b_{1jk})=0$, $\sigma^2_1=0$.)
As to $b_{0k}$, the random intercept per school, it is even more meaningful
than $b_{1k}$! "Given that among multilevel modelers random slopes tend to be
more popular than heteroscedasticity, unrecognized heteroscedasticity may show
up in the form of a fitted model with a random slope [...] which then may
disappear if the heteroscedasticity is modeled" (Snijders and Berkhof,
Diagnostic Checks for Multilevel Models, §3.2.1).
Is my intuition correct that the variation between different schools
increases over time, as the random slopes drive the schools further apart?
In all the above models I have assumed that all random effects are
uncorrelated and that their variances are constant. Is these assumptions hold,
then covariances increase quadratically with time (see conjectures'
answer). However, if the $\tau$ variances and covariances decrease with time you could
observe a somewhat different pattern.
BTW, your plot does show a different pattern and suggests a bit of
heteroscedasticity more than a random slope.
the covariance between students within the same school is given by:
$\text{Cov}_{school}=\frac{\sigma^2_3}{\sigma^2_1+\sigma^2_2+\sigma^2_3}$
What is this covariance if a random intercept is included?
That is not a covariance, it is the $\rho_2$ correlation coefficient in
Model 2. The covariance between two schools depends on Time.
|
Multilevel models including random slopes: how to calculate variance
Let me start with simpler models (detailed answers below), and let me use a slightly different notation (NB: random effecs at different levels assumed to be uncorrelated).
Model 1 (Two levels, random
|
45,809
|
Multilevel models including random slopes: how to calculate variance
|
I believe your intuition is correct.
With the following model, ranging over schools $k$, individual within school $j$ and observation within individual within school $i$. (If I get your notation right).
$Y_{ijk}=\beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{jk} + ϵ_{ijk}$
With
$b_{1k} \sim N(0,\sigma_4^2)$, $b_{0k} \sim N(0,\sigma_3^2)$, $b_{jk} \sim N(0,\sigma_2^2)$, $\epsilon_{ijk} \sim N(0,\sigma_1^2)$
And assuming all random effects and error terms are pairwise independent.
Then for two two distinct individuals,$h$ and $j$, in the same school at the same time:
$\text{Cov}(Y_{ijk},Y_{ihk})=\text{Cov}(\beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{jk} + ϵ_{ijk}, \beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{hk} + ϵ_{ihk})$
$=\text{Var}(b_{0k}) + t^2 \text{Var}(b_{1k})$
So the covariance increases quadratically with time. The example in the text above looks like a correlation, but the question is about covariance. This also means the series are not stationary.
Also, to me the series in the plot look like you could argue they should be modelled with a single slope.
|
Multilevel models including random slopes: how to calculate variance
|
I believe your intuition is correct.
With the following model, ranging over schools $k$, individual within school $j$ and observation within individual within school $i$. (If I get your notation righ
|
Multilevel models including random slopes: how to calculate variance
I believe your intuition is correct.
With the following model, ranging over schools $k$, individual within school $j$ and observation within individual within school $i$. (If I get your notation right).
$Y_{ijk}=\beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{jk} + ϵ_{ijk}$
With
$b_{1k} \sim N(0,\sigma_4^2)$, $b_{0k} \sim N(0,\sigma_3^2)$, $b_{jk} \sim N(0,\sigma_2^2)$, $\epsilon_{ijk} \sim N(0,\sigma_1^2)$
And assuming all random effects and error terms are pairwise independent.
Then for two two distinct individuals,$h$ and $j$, in the same school at the same time:
$\text{Cov}(Y_{ijk},Y_{ihk})=\text{Cov}(\beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{jk} + ϵ_{ijk}, \beta_0+\beta_1 t + b_{0k} + b_{1k}t + b_{hk} + ϵ_{ihk})$
$=\text{Var}(b_{0k}) + t^2 \text{Var}(b_{1k})$
So the covariance increases quadratically with time. The example in the text above looks like a correlation, but the question is about covariance. This also means the series are not stationary.
Also, to me the series in the plot look like you could argue they should be modelled with a single slope.
|
Multilevel models including random slopes: how to calculate variance
I believe your intuition is correct.
With the following model, ranging over schools $k$, individual within school $j$ and observation within individual within school $i$. (If I get your notation righ
|
45,810
|
Can someone give a clear-cut idea of $E(X|X<Y)$?
|
The i.i.d requirement creates useful symmetries, so indeed there is a factor of $1/2$ in some formulas. The following is one attempt to interpret "looks like" in a useful and intuitive fashion.
The possibilities for $(X,Y)$ partition into three events: $X\lt Y,$ $X\gt Y,$ and $X=Y.$
Therefore, assuming all expectations exist,
$$\mathbb{E}(X+Y) = \mathbb{E}(X+Y\ |\ X\lt Y) \Pr(X\lt Y) + \mathbb{E}(X+Y\ |\ X\gt Y) \Pr(X\gt Y) \\+ \mathbb{E}(X+Y\ |\ X= Y) \Pr(X= Y).$$
Writing $p_0$ for $\Pr(X=Y)$, the symmetry $X\to Y, Y\to X$ shows that the remaining probability of $1-p_0$ is equally split over the events $X\lt Y$ and $X\gt Y$:
$$\Pr(X\lt Y) = \Pr(Y\lt X) = \Pr(X \gt Y) = \frac{1-p_0}{2}.$$
The same symmetry shows the first two conditional expectations are equal while the third reduces to
$$\mathbb{E}(X+Y\ |\ X= Y) \Pr(X=Y) = 2\mathbb{E}(X | X=Y)p_0.$$
Write
$$\mu_0 = \mathbb{E}(X | X=Y).$$
Solving for the conditional expectation yields
$$\mathbb{E}(X+Y\ |\ X \lt Y) = 2 \frac{\mu - \mu_0p_0}{1-p_0}.$$
Similar (but slightly easier) manipulations show that
$$\mathbb{E}(Y - X \ |\ X \lt Y) = \frac{\mathbb{E}(|Y-X|)}{1-p_0}.$$
Because $X = \frac{1}{2}\left((X+Y) - (Y-X)\right),$
$$\mathbb{E}(X \ |\ X \lt Y) = \frac{\mu - \mu_0p_0 - \mathbb{E}(|Y-X|)/2}{1-p_0}.$$
To begin understanding this, suppose the common distribution of $X$ and $Y$ is continuous: this implies $p_0=0$. The foregoing expression reduces to
$$\mathbb{E}(X \ |\ X \lt Y) = \mu - \mathbb{E}(|Y-X|)/2,$$
(wherein the expected factor of $1/2$ clearly appears). That is,
For continuous distributions, the conditional expectation of $X$, given that $X\lt Y$, is less than the unconditional expectation of $X$ by half the expected size of the difference $|Y-X|$.
(This result is intuitively obvious: the amount by which the conditional expectation of $X$ falls below the unconditional expectation must be exactly the amount by which the conditional expectation of $Y$ exceeds the unconditional expectation and those two amounts sum to the expected difference.)
The additional terms $\mu_0$ and $p_0$ can now be understood as corrections for the possibility that $X=Y$. They are a little harder to obtain intuitively, which is why some care was taken with the foregoing analysis.
|
Can someone give a clear-cut idea of $E(X|X<Y)$?
|
The i.i.d requirement creates useful symmetries, so indeed there is a factor of $1/2$ in some formulas. The following is one attempt to interpret "looks like" in a useful and intuitive fashion.
The
|
Can someone give a clear-cut idea of $E(X|X<Y)$?
The i.i.d requirement creates useful symmetries, so indeed there is a factor of $1/2$ in some formulas. The following is one attempt to interpret "looks like" in a useful and intuitive fashion.
The possibilities for $(X,Y)$ partition into three events: $X\lt Y,$ $X\gt Y,$ and $X=Y.$
Therefore, assuming all expectations exist,
$$\mathbb{E}(X+Y) = \mathbb{E}(X+Y\ |\ X\lt Y) \Pr(X\lt Y) + \mathbb{E}(X+Y\ |\ X\gt Y) \Pr(X\gt Y) \\+ \mathbb{E}(X+Y\ |\ X= Y) \Pr(X= Y).$$
Writing $p_0$ for $\Pr(X=Y)$, the symmetry $X\to Y, Y\to X$ shows that the remaining probability of $1-p_0$ is equally split over the events $X\lt Y$ and $X\gt Y$:
$$\Pr(X\lt Y) = \Pr(Y\lt X) = \Pr(X \gt Y) = \frac{1-p_0}{2}.$$
The same symmetry shows the first two conditional expectations are equal while the third reduces to
$$\mathbb{E}(X+Y\ |\ X= Y) \Pr(X=Y) = 2\mathbb{E}(X | X=Y)p_0.$$
Write
$$\mu_0 = \mathbb{E}(X | X=Y).$$
Solving for the conditional expectation yields
$$\mathbb{E}(X+Y\ |\ X \lt Y) = 2 \frac{\mu - \mu_0p_0}{1-p_0}.$$
Similar (but slightly easier) manipulations show that
$$\mathbb{E}(Y - X \ |\ X \lt Y) = \frac{\mathbb{E}(|Y-X|)}{1-p_0}.$$
Because $X = \frac{1}{2}\left((X+Y) - (Y-X)\right),$
$$\mathbb{E}(X \ |\ X \lt Y) = \frac{\mu - \mu_0p_0 - \mathbb{E}(|Y-X|)/2}{1-p_0}.$$
To begin understanding this, suppose the common distribution of $X$ and $Y$ is continuous: this implies $p_0=0$. The foregoing expression reduces to
$$\mathbb{E}(X \ |\ X \lt Y) = \mu - \mathbb{E}(|Y-X|)/2,$$
(wherein the expected factor of $1/2$ clearly appears). That is,
For continuous distributions, the conditional expectation of $X$, given that $X\lt Y$, is less than the unconditional expectation of $X$ by half the expected size of the difference $|Y-X|$.
(This result is intuitively obvious: the amount by which the conditional expectation of $X$ falls below the unconditional expectation must be exactly the amount by which the conditional expectation of $Y$ exceeds the unconditional expectation and those two amounts sum to the expected difference.)
The additional terms $\mu_0$ and $p_0$ can now be understood as corrections for the possibility that $X=Y$. They are a little harder to obtain intuitively, which is why some care was taken with the foregoing analysis.
|
Can someone give a clear-cut idea of $E(X|X<Y)$?
The i.i.d requirement creates useful symmetries, so indeed there is a factor of $1/2$ in some formulas. The following is one attempt to interpret "looks like" in a useful and intuitive fashion.
The
|
45,811
|
Trend in residuals vs dependent - but not in residuals vs fitted
|
1) The residuals and the fitted are uncorrelated by construction. In fact if there was any correlation between them, there would be uncaptured linear trend in the data - we could get a closer fit by changing the coefficients until they were uncorrelated.
2) The residuals and the y-variable are always positively correlated. This is a necessary consequence of (1).
$$cov(e,y) = cov(e,e+\hat y) =
\sigma^2+0 = \sigma^2$$
So it would be surprising if there wasn't a trend in that first plot.
Consider a simulated example -
Note that by plotting residuals against observed, it's equivalent to using slanted axes in the residuals vs fitted plot:
The reason for the high observed (the grey slanted lines mark constant observed, the ones to the far right are high) being associated with high residuals is clear here, as it the reason for them being only positive near the end.
|
Trend in residuals vs dependent - but not in residuals vs fitted
|
1) The residuals and the fitted are uncorrelated by construction. In fact if there was any correlation between them, there would be uncaptured linear trend in the data - we could get a closer fit by c
|
Trend in residuals vs dependent - but not in residuals vs fitted
1) The residuals and the fitted are uncorrelated by construction. In fact if there was any correlation between them, there would be uncaptured linear trend in the data - we could get a closer fit by changing the coefficients until they were uncorrelated.
2) The residuals and the y-variable are always positively correlated. This is a necessary consequence of (1).
$$cov(e,y) = cov(e,e+\hat y) =
\sigma^2+0 = \sigma^2$$
So it would be surprising if there wasn't a trend in that first plot.
Consider a simulated example -
Note that by plotting residuals against observed, it's equivalent to using slanted axes in the residuals vs fitted plot:
The reason for the high observed (the grey slanted lines mark constant observed, the ones to the far right are high) being associated with high residuals is clear here, as it the reason for them being only positive near the end.
|
Trend in residuals vs dependent - but not in residuals vs fitted
1) The residuals and the fitted are uncorrelated by construction. In fact if there was any correlation between them, there would be uncaptured linear trend in the data - we could get a closer fit by c
|
45,812
|
Decision Tree - Splitting Factor Variables
|
rpart treats differently ordinal and nominal qualitative variables (factors, in R parlance). For your first variable, provided it has been defined as an ordered factor, the only splits considered would be:
{tiny} {small, medium, large, huge},
{tiny,small} {medium, large, huge},
{tiny,small,medium} {large, huge}
{tiny,small,medium,large}{huge}
while for a purely nominal variable, all $2^{k-1} -1$ posible splits ($k$ = number of levels) would be tested. Of course, this cannot be done with $k$ very large, so you might have to compromise aggregating levels.
|
Decision Tree - Splitting Factor Variables
|
rpart treats differently ordinal and nominal qualitative variables (factors, in R parlance). For your first variable, provided it has been defined as an ordered factor, the only splits considered woul
|
Decision Tree - Splitting Factor Variables
rpart treats differently ordinal and nominal qualitative variables (factors, in R parlance). For your first variable, provided it has been defined as an ordered factor, the only splits considered would be:
{tiny} {small, medium, large, huge},
{tiny,small} {medium, large, huge},
{tiny,small,medium} {large, huge}
{tiny,small,medium,large}{huge}
while for a purely nominal variable, all $2^{k-1} -1$ posible splits ($k$ = number of levels) would be tested. Of course, this cannot be done with $k$ very large, so you might have to compromise aggregating levels.
|
Decision Tree - Splitting Factor Variables
rpart treats differently ordinal and nominal qualitative variables (factors, in R parlance). For your first variable, provided it has been defined as an ordered factor, the only splits considered woul
|
45,813
|
Decision Tree - Splitting Factor Variables
|
Most decision trees do not consider ordinal factors but just categorical and numerical factors. You can code ordinal factors as numerical if you want to build trees more efficiently. However, if you use them as categorical a tree can help you check whether your data or ordinal codification has any inconsistency.
Most decision tree implementations use variations of information gain for classification tasks or squared error for regression tasks. They use the same technique for each split independently of the type of factor.
To learn how trees work with different types of data and different parameters (number of nodes, weights, sampling, etc) I recommend you to use inline sources from BigML in (FREE) development mode. For example, using the data below you can get easily get nice interactive model like this https://bigml.com/shared/model/sddxt90nauxqTTSjRCGyEwmp175
size, city, weather
tiny, New Orleans, good
small, Birmingham, good
medium, Jackson, bad
large, Miami, bad,
huge, Atlanta, good
|
Decision Tree - Splitting Factor Variables
|
Most decision trees do not consider ordinal factors but just categorical and numerical factors. You can code ordinal factors as numerical if you want to build trees more efficiently. However, if you u
|
Decision Tree - Splitting Factor Variables
Most decision trees do not consider ordinal factors but just categorical and numerical factors. You can code ordinal factors as numerical if you want to build trees more efficiently. However, if you use them as categorical a tree can help you check whether your data or ordinal codification has any inconsistency.
Most decision tree implementations use variations of information gain for classification tasks or squared error for regression tasks. They use the same technique for each split independently of the type of factor.
To learn how trees work with different types of data and different parameters (number of nodes, weights, sampling, etc) I recommend you to use inline sources from BigML in (FREE) development mode. For example, using the data below you can get easily get nice interactive model like this https://bigml.com/shared/model/sddxt90nauxqTTSjRCGyEwmp175
size, city, weather
tiny, New Orleans, good
small, Birmingham, good
medium, Jackson, bad
large, Miami, bad,
huge, Atlanta, good
|
Decision Tree - Splitting Factor Variables
Most decision trees do not consider ordinal factors but just categorical and numerical factors. You can code ordinal factors as numerical if you want to build trees more efficiently. However, if you u
|
45,814
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
Some very basic sample size calculations are discussed here:
http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm
http://www.itl.nist.gov/div898/handbook/prc/section2/prc242.htm
For a basic introduction, the book by Moore and McCabe - Introduction to the Practice of Statistics covers some of the basics in chapter 6.
Some deeper discussion is in
Russell V.Lenth, 2001.
"Some Practical Guidelines for Effective Sample Size Determination"
The American Statistician, August 2001, Vol. 55, No.3
Edit:
I just noticed that I had left out Jacob Cohen's book. I meant to mention it -
Statistical Power Analysis for the Behavioural Sciences
I don't know this book, but I've seen some people recommend
Chow S, Shao J, Wang H. 2008.
Sample Size Calculations in Clinical Research.
2nd Ed. Chapman & Hall/CRC Biostatistics Series.
As I said in comments, I tend to use simulation.
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
Some very basic sample size calculations are discussed here:
http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm
http://www.itl.nist.gov/div898/handbook/prc/section2/prc242.htm
For a basic
|
Book recommendation: sample size determination for hypothesis testing of the mean
Some very basic sample size calculations are discussed here:
http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm
http://www.itl.nist.gov/div898/handbook/prc/section2/prc242.htm
For a basic introduction, the book by Moore and McCabe - Introduction to the Practice of Statistics covers some of the basics in chapter 6.
Some deeper discussion is in
Russell V.Lenth, 2001.
"Some Practical Guidelines for Effective Sample Size Determination"
The American Statistician, August 2001, Vol. 55, No.3
Edit:
I just noticed that I had left out Jacob Cohen's book. I meant to mention it -
Statistical Power Analysis for the Behavioural Sciences
I don't know this book, but I've seen some people recommend
Chow S, Shao J, Wang H. 2008.
Sample Size Calculations in Clinical Research.
2nd Ed. Chapman & Hall/CRC Biostatistics Series.
As I said in comments, I tend to use simulation.
|
Book recommendation: sample size determination for hypothesis testing of the mean
Some very basic sample size calculations are discussed here:
http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm
http://www.itl.nist.gov/div898/handbook/prc/section2/prc242.htm
For a basic
|
45,815
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
I will try to provide some answers, while also giving the disclaimer that I am the author (Ryan) of one of the books that was mentioned.
First, I would also recommend the paper by Lenth that was mentioned, as I always provide my students with that paper in the online courses on sample size determination that I teach.
Regarding the costs of books on this subject, the list price of my book is 110 dollars but it can be purchased at one of the "discount" sites (such as half.com) for well under 100 dollars.
I have a copy of the book by Chow, Shao, and Wang, which is at a somewhat high mathematical level and is a good source for biosatisticians and others with sufficient mathematical expertise. One Amazon reviewer has expressed frustration at the number of errors in the book. I've found one or two but it is impossible to write a statistics book that is completely free of errors.
It is true that complex cases, such as mixed models, are generally not covered in books on the subject, but relatively few books have been written on sample size determination. Cohen's book was for many years the standard book on the subject, but it was published 26 years ago and is thus outdated. If you read Lenth's paper, you will see that he debunks Cohen's use of small, medium, and large effect sizes, referring to them as "shirt sizes". :-) I agree with Russ Lenth on that, whom I have known for almost 30 years.
Much research is needed om sample size determination but this is not a subject that interests statisticians.
PASS is the most comprehensive software package for sample size determination and it does have mixed model capability. It uses simulation to determine sample size, even in some cases where analytical results are known.
Tom Ryan
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
I will try to provide some answers, while also giving the disclaimer that I am the author (Ryan) of one of the books that was mentioned.
First, I would also recommend the paper by Lenth that was ment
|
Book recommendation: sample size determination for hypothesis testing of the mean
I will try to provide some answers, while also giving the disclaimer that I am the author (Ryan) of one of the books that was mentioned.
First, I would also recommend the paper by Lenth that was mentioned, as I always provide my students with that paper in the online courses on sample size determination that I teach.
Regarding the costs of books on this subject, the list price of my book is 110 dollars but it can be purchased at one of the "discount" sites (such as half.com) for well under 100 dollars.
I have a copy of the book by Chow, Shao, and Wang, which is at a somewhat high mathematical level and is a good source for biosatisticians and others with sufficient mathematical expertise. One Amazon reviewer has expressed frustration at the number of errors in the book. I've found one or two but it is impossible to write a statistics book that is completely free of errors.
It is true that complex cases, such as mixed models, are generally not covered in books on the subject, but relatively few books have been written on sample size determination. Cohen's book was for many years the standard book on the subject, but it was published 26 years ago and is thus outdated. If you read Lenth's paper, you will see that he debunks Cohen's use of small, medium, and large effect sizes, referring to them as "shirt sizes". :-) I agree with Russ Lenth on that, whom I have known for almost 30 years.
Much research is needed om sample size determination but this is not a subject that interests statisticians.
PASS is the most comprehensive software package for sample size determination and it does have mixed model capability. It uses simulation to determine sample size, even in some cases where analytical results are known.
Tom Ryan
|
Book recommendation: sample size determination for hypothesis testing of the mean
I will try to provide some answers, while also giving the disclaimer that I am the author (Ryan) of one of the books that was mentioned.
First, I would also recommend the paper by Lenth that was ment
|
45,816
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
This is a broad question and there are books on the subject. How Many Subjects?: Statistical Power Analysis in Research (Second Edition) is one that many have found accessible.
See also the link Good text on Clinical Trials? provided in a comment.
|
Book recommendation: sample size determination for hypothesis testing of the mean
|
This is a broad question and there are books on the subject. How Many Subjects?: Statistical Power Analysis in Research (Second Edition) is one that many have found accessible.
See also the link Good
|
Book recommendation: sample size determination for hypothesis testing of the mean
This is a broad question and there are books on the subject. How Many Subjects?: Statistical Power Analysis in Research (Second Edition) is one that many have found accessible.
See also the link Good text on Clinical Trials? provided in a comment.
|
Book recommendation: sample size determination for hypothesis testing of the mean
This is a broad question and there are books on the subject. How Many Subjects?: Statistical Power Analysis in Research (Second Edition) is one that many have found accessible.
See also the link Good
|
45,817
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
|
First you need to decide whether you need model/parameter selection, or just model. Once your model is fixed, bootstrap seems make more sense to determine how your modeling procedure performs.
If you are implementing cross validation on multiple dataset, just randomly partition the data without considering their labels. It is possible sometimes that one label in test data set does not even gets trained, and it counts into the validation error. Usually a 10-fold cross-validation is highly recommended to repeat 50-100 times for stability.
You may try to avoid class imbalance issue (thus indirectly reduce the odds of the excluded label event mentioned above), but if your data really suffers from this problem, there are several re-sampling strategies in my previous answer in this post.
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
|
First you need to decide whether you need model/parameter selection, or just model. Once your model is fixed, bootstrap seems make more sense to determine how your modeling procedure performs.
If yo
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
First you need to decide whether you need model/parameter selection, or just model. Once your model is fixed, bootstrap seems make more sense to determine how your modeling procedure performs.
If you are implementing cross validation on multiple dataset, just randomly partition the data without considering their labels. It is possible sometimes that one label in test data set does not even gets trained, and it counts into the validation error. Usually a 10-fold cross-validation is highly recommended to repeat 50-100 times for stability.
You may try to avoid class imbalance issue (thus indirectly reduce the odds of the excluded label event mentioned above), but if your data really suffers from this problem, there are several re-sampling strategies in my previous answer in this post.
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
First you need to decide whether you need model/parameter selection, or just model. Once your model is fixed, bootstrap seems make more sense to determine how your modeling procedure performs.
If yo
|
45,818
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
|
I think you would generally not want to incorporate the known classifications into the selection of training and test samples. If you do that, the proportion of each class in the testing sample will always be the same as the proportions in the sample used to train the machine you are, but you actually want sampling variation between training and test to see how the classifier performs in real situations like that.
Basically, just randomly partition your data set into 10 folds ignoring the classification variable.
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
|
I think you would generally not want to incorporate the known classifications into the selection of training and test samples. If you do that, the proportion of each class in the testing sample will a
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
I think you would generally not want to incorporate the known classifications into the selection of training and test samples. If you do that, the proportion of each class in the testing sample will always be the same as the proportions in the sample used to train the machine you are, but you actually want sampling variation between training and test to see how the classifier performs in real situations like that.
Basically, just randomly partition your data set into 10 folds ignoring the classification variable.
|
How exactly to partition training-set for k-fold cross validation on multi-class dataset?
I think you would generally not want to incorporate the known classifications into the selection of training and test samples. If you do that, the proportion of each class in the testing sample will a
|
45,819
|
Eigenvalues of correlation matrices exhibit exponential decay
|
Everything has already been pretty much figured out in the comments, thanks to @AndyW, @whuber, and @UriCohen, but I would still like to write it up as a coherent answer.
First, let me illustrate the original question. Here is the eigenspectrum of some actual real data (neural recordings) that I happen to work with right now. First few (~20-30) PCs obviously carry some signal, but after that the eigenvalues start slowly decreasing in what does seem like an exponential fashion: note that the middle part of the spectrum is almost a straight line on this log-plot. I am not showing the last part of the spectrum, because there the eigenvalues decrease pretty much to 0, due to some temporal smoothing that I used before PCA.
Question is: why exponential decay?
The answer is, I believe, that any high-dimensional real data are highly contaminated by noise, so the bulk of the eigenspectrum shows the spectral behaviour of pure noise. What is the spectrum of a random covariance matrix? Turns out, there is a nice asymptotic result given by Marchenko–Pastur distribution, see the pdf of the original 1967 paper in Russian if you like.
Marchenko and Pastur tell us to consider a random data matrix of $N\times D$ size filled with independent Gaussian random values from $\mathcal{N}(0,\sigma^2)$. If $\sigma^2=1$ and $N=D$, then in the limit $N \to \infty$ the distribution of eigenvalues of its covariance matrix is given by $$\mu(x)=\frac{\sqrt{4x-x^2}}{2\pi x}.$$
Let us verify. I generated a random matrix of the $1000 \times 1000$ size, computed its covariance matrix and then calculated the eigenspectrum. The first subplot below shows the covariance matrix. The second shows the distribution (histogram) of the eigenvalues and the Marchenko-Pastur function given above. It does fit perfectly.
But we are interested not so much in the distribution of eigenvalues, but in the eigenspectrum itself. If we draw 1000 values from the Marchenko-Pastur distribution (forming the spectrum) and sort them in decreasing order, then the resulting function will be given by $S(x)=(1-M(x))^{-1}$ rescaled to $[1, 1000]$, where $M(x)$ is the Marchenko-Pastur cumulative distribution function, i.e. $M(x) = \int_0^x \mu(t) dt$. The third subplot on the figure above shows the empirical spectrum vs Marchenko-Pastur fit.
It is quite a mess to compute $M(x)$, here is Wolfram Alpha's attempt. But we can note that $\mu(x)$ in the middle of its domain (around $x\approx 2$) is very well approximated by a straight line. This means that $M(x)$ will be approximately quadratic, and so its inverse $S(x) \sim \mathrm{const}-\sqrt{x}$.
In other words, the decay is not exponential at all, it is a square-root decay! However, funny enough, it is close enough to the exponential shape so that on the log-plot (see the fourth subplot above) the middle part of the spectrum looks pretty straight.
|
Eigenvalues of correlation matrices exhibit exponential decay
|
Everything has already been pretty much figured out in the comments, thanks to @AndyW, @whuber, and @UriCohen, but I would still like to write it up as a coherent answer.
First, let me illustrate the
|
Eigenvalues of correlation matrices exhibit exponential decay
Everything has already been pretty much figured out in the comments, thanks to @AndyW, @whuber, and @UriCohen, but I would still like to write it up as a coherent answer.
First, let me illustrate the original question. Here is the eigenspectrum of some actual real data (neural recordings) that I happen to work with right now. First few (~20-30) PCs obviously carry some signal, but after that the eigenvalues start slowly decreasing in what does seem like an exponential fashion: note that the middle part of the spectrum is almost a straight line on this log-plot. I am not showing the last part of the spectrum, because there the eigenvalues decrease pretty much to 0, due to some temporal smoothing that I used before PCA.
Question is: why exponential decay?
The answer is, I believe, that any high-dimensional real data are highly contaminated by noise, so the bulk of the eigenspectrum shows the spectral behaviour of pure noise. What is the spectrum of a random covariance matrix? Turns out, there is a nice asymptotic result given by Marchenko–Pastur distribution, see the pdf of the original 1967 paper in Russian if you like.
Marchenko and Pastur tell us to consider a random data matrix of $N\times D$ size filled with independent Gaussian random values from $\mathcal{N}(0,\sigma^2)$. If $\sigma^2=1$ and $N=D$, then in the limit $N \to \infty$ the distribution of eigenvalues of its covariance matrix is given by $$\mu(x)=\frac{\sqrt{4x-x^2}}{2\pi x}.$$
Let us verify. I generated a random matrix of the $1000 \times 1000$ size, computed its covariance matrix and then calculated the eigenspectrum. The first subplot below shows the covariance matrix. The second shows the distribution (histogram) of the eigenvalues and the Marchenko-Pastur function given above. It does fit perfectly.
But we are interested not so much in the distribution of eigenvalues, but in the eigenspectrum itself. If we draw 1000 values from the Marchenko-Pastur distribution (forming the spectrum) and sort them in decreasing order, then the resulting function will be given by $S(x)=(1-M(x))^{-1}$ rescaled to $[1, 1000]$, where $M(x)$ is the Marchenko-Pastur cumulative distribution function, i.e. $M(x) = \int_0^x \mu(t) dt$. The third subplot on the figure above shows the empirical spectrum vs Marchenko-Pastur fit.
It is quite a mess to compute $M(x)$, here is Wolfram Alpha's attempt. But we can note that $\mu(x)$ in the middle of its domain (around $x\approx 2$) is very well approximated by a straight line. This means that $M(x)$ will be approximately quadratic, and so its inverse $S(x) \sim \mathrm{const}-\sqrt{x}$.
In other words, the decay is not exponential at all, it is a square-root decay! However, funny enough, it is close enough to the exponential shape so that on the log-plot (see the fourth subplot above) the middle part of the spectrum looks pretty straight.
|
Eigenvalues of correlation matrices exhibit exponential decay
Everything has already been pretty much figured out in the comments, thanks to @AndyW, @whuber, and @UriCohen, but I would still like to write it up as a coherent answer.
First, let me illustrate the
|
45,820
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
|
This is a compound Poisson distribution
The law of total variance gets you the answer.
Note that this answer doesn't rely on the normality of the $X$'s at all; it applies to any distribution with mean $\mu$ and variance $\sigma^2$.
In the following, $N$ is the Poisson r.v., $X$'s are individual components, $Y$ is the sum of components, $Y|N$ is the sum of components given a specific count of terms, $N$:
$$\text {Var}_{Y}(Y)=E_{N}\left[\text {Var}_{{Y|N}}(Y)\right]+\text {Var}_{N}\left[E_{{Y|N}}(Y)\right]$$
Substituting in:
$$=\text {E}_{N}\left[N\text {Var}_{X}(X)\right]+\text {Var}_{N}\left[N\text {E}_{X}(X)\right]\,$$
$$=\text {E}_{N}\left[N\sigma^2\right]+\text {Var}_{N}\left[N \mu\right]\,$$
$$=\sigma^2\text {E}_{N}\left[N\right]+\mu^2\text {Var}_{N}\left[N \right]\,$$
$$=\sigma^2\lambda+\mu^2\lambda$$
$$=(\sigma^2+\mu^2)\lambda$$
(... which is also $\lambda E(X^2)$)
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
|
This is a compound Poisson distribution
The law of total variance gets you the answer.
Note that this answer doesn't rely on the normality of the $X$'s at all; it applies to any distribution with mean
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
This is a compound Poisson distribution
The law of total variance gets you the answer.
Note that this answer doesn't rely on the normality of the $X$'s at all; it applies to any distribution with mean $\mu$ and variance $\sigma^2$.
In the following, $N$ is the Poisson r.v., $X$'s are individual components, $Y$ is the sum of components, $Y|N$ is the sum of components given a specific count of terms, $N$:
$$\text {Var}_{Y}(Y)=E_{N}\left[\text {Var}_{{Y|N}}(Y)\right]+\text {Var}_{N}\left[E_{{Y|N}}(Y)\right]$$
Substituting in:
$$=\text {E}_{N}\left[N\text {Var}_{X}(X)\right]+\text {Var}_{N}\left[N\text {E}_{X}(X)\right]\,$$
$$=\text {E}_{N}\left[N\sigma^2\right]+\text {Var}_{N}\left[N \mu\right]\,$$
$$=\sigma^2\text {E}_{N}\left[N\right]+\mu^2\text {Var}_{N}\left[N \right]\,$$
$$=\sigma^2\lambda+\mu^2\lambda$$
$$=(\sigma^2+\mu^2)\lambda$$
(... which is also $\lambda E(X^2)$)
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
This is a compound Poisson distribution
The law of total variance gets you the answer.
Note that this answer doesn't rely on the normality of the $X$'s at all; it applies to any distribution with mean
|
45,821
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
|
Here's the answer I got through trial and error, which seems to come close to Monte Carlo simulated estimates in every scenario I have tried.
$\text{Var} = λ(μ^2+σ^2)$
(Edit: Yes, this agrees with Glen_b's updated answer, much to my delight!)
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
|
Here's the answer I got through trial and error, which seems to come close to Monte Carlo simulated estimates in every scenario I have tried.
$\text{Var} = λ(μ^2+σ^2)$
(Edit: Yes, this agrees with Gle
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
Here's the answer I got through trial and error, which seems to come close to Monte Carlo simulated estimates in every scenario I have tried.
$\text{Var} = λ(μ^2+σ^2)$
(Edit: Yes, this agrees with Glen_b's updated answer, much to my delight!)
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
Here's the answer I got through trial and error, which seems to come close to Monte Carlo simulated estimates in every scenario I have tried.
$\text{Var} = λ(μ^2+σ^2)$
(Edit: Yes, this agrees with Gle
|
45,822
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
|
By the law of the product of variances, if two random variables are independent, the variance of their product $\ D(X*Y)$ = $\ E(X)^2*D(X)+E(Y)^2*D(Y)+D(X)*D(Y)$
which is $\ E(X^2)*E(Y^2)-E(X)^2*E(Y)^2$.
So, if the distributions are Poisson and Normal, I'd guess it's $\lambda*σ^2$.
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
|
By the law of the product of variances, if two random variables are independent, the variance of their product $\ D(X*Y)$ = $\ E(X)^2*D(X)+E(Y)^2*D(Y)+D(X)*D(Y)$
which is $\ E(X^2)*E(Y^2)-E(X)^2*E(Y)^
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variables
By the law of the product of variances, if two random variables are independent, the variance of their product $\ D(X*Y)$ = $\ E(X)^2*D(X)+E(Y)^2*D(Y)+D(X)*D(Y)$
which is $\ E(X^2)*E(Y^2)-E(X)^2*E(Y)^2$.
So, if the distributions are Poisson and Normal, I'd guess it's $\lambda*σ^2$.
|
Variance of the sum of a Poisson-distributed random number of (normally distributed) random variable
By the law of the product of variances, if two random variables are independent, the variance of their product $\ D(X*Y)$ = $\ E(X)^2*D(X)+E(Y)^2*D(Y)+D(X)*D(Y)$
which is $\ E(X^2)*E(Y^2)-E(X)^2*E(Y)^
|
45,823
|
How to describe/explain the shape of a distribution which has two peaks?
|
To describe such a two-peak shape to another person, you'd call it 'bimodal' (which just means 'two modes' - generally taken to be two local modes, even though only one of them might be 'the mode' of the distribution).
You could then seek to describe the locations and spreads and relative proportions or heights of the peaks (this might be done visually, or more formally, for example with Gaussian mixture model).
e.g. as a first, simple description, I might say "the distribution appears to be bimodal with the main peak at around 290 and a lower peak around 670"
- and then if necessary give additional detail on the relative heights at or widths-of/ areas-under the curve around the peaks, if any of those details matter to your audience (e.g. something along the lines of "the spread of the peak around the main mode is wider than that around the smaller mode").
If we're thinking in terms of something close to a Gaussian mixture model, there's a slight suggestion of a third "bump" coming in near 420, but its close enough to the bigger mode that it doesn't make a separate peak.
Those red marks you got using rug are the actual data values; for each observation, one red mark is placed in the margin (akin to the marks you see with stripchart(Boston$tax,pch="|")). You'd normally mark them with thin lines rather than wide lines as you have there. Because the values are placed at the edge of a plot, the marks look a little like the fringe tassels on the edges of a rug. That has nothing to do with the kernel density estimate itself (other than showing the data from which the KDE was computed), it's just adding a different kind of information to the plot; you could use rug to add information to various other displays of the data. A rug-plot is just a marginal (to some main plot) one-dimensional plot of the data values.
A rug plot is not as informative when the data has a lot of repeated values (as the tax variable does - for example, there are 132 values at 666 which are all drawn one on top of the other); you can normally improve that with a little bit of 'jitter', but there are so many repeated values that even rug(jitter(x,amount=20)) doesn't distinguish the values. For that situation might be better to use transparency and a smaller amount of jitter, or some other indication, such as a dot plot:
plot(density(Boston$tax),col=3) #$
stripchart(Boston$tax,add=TRUE,pch=16,cex=.03,at=-0.00013,method="stack",col=8)
|
How to describe/explain the shape of a distribution which has two peaks?
|
To describe such a two-peak shape to another person, you'd call it 'bimodal' (which just means 'two modes' - generally taken to be two local modes, even though only one of them might be 'the mode' of
|
How to describe/explain the shape of a distribution which has two peaks?
To describe such a two-peak shape to another person, you'd call it 'bimodal' (which just means 'two modes' - generally taken to be two local modes, even though only one of them might be 'the mode' of the distribution).
You could then seek to describe the locations and spreads and relative proportions or heights of the peaks (this might be done visually, or more formally, for example with Gaussian mixture model).
e.g. as a first, simple description, I might say "the distribution appears to be bimodal with the main peak at around 290 and a lower peak around 670"
- and then if necessary give additional detail on the relative heights at or widths-of/ areas-under the curve around the peaks, if any of those details matter to your audience (e.g. something along the lines of "the spread of the peak around the main mode is wider than that around the smaller mode").
If we're thinking in terms of something close to a Gaussian mixture model, there's a slight suggestion of a third "bump" coming in near 420, but its close enough to the bigger mode that it doesn't make a separate peak.
Those red marks you got using rug are the actual data values; for each observation, one red mark is placed in the margin (akin to the marks you see with stripchart(Boston$tax,pch="|")). You'd normally mark them with thin lines rather than wide lines as you have there. Because the values are placed at the edge of a plot, the marks look a little like the fringe tassels on the edges of a rug. That has nothing to do with the kernel density estimate itself (other than showing the data from which the KDE was computed), it's just adding a different kind of information to the plot; you could use rug to add information to various other displays of the data. A rug-plot is just a marginal (to some main plot) one-dimensional plot of the data values.
A rug plot is not as informative when the data has a lot of repeated values (as the tax variable does - for example, there are 132 values at 666 which are all drawn one on top of the other); you can normally improve that with a little bit of 'jitter', but there are so many repeated values that even rug(jitter(x,amount=20)) doesn't distinguish the values. For that situation might be better to use transparency and a smaller amount of jitter, or some other indication, such as a dot plot:
plot(density(Boston$tax),col=3) #$
stripchart(Boston$tax,add=TRUE,pch=16,cex=.03,at=-0.00013,method="stack",col=8)
|
How to describe/explain the shape of a distribution which has two peaks?
To describe such a two-peak shape to another person, you'd call it 'bimodal' (which just means 'two modes' - generally taken to be two local modes, even though only one of them might be 'the mode' of
|
45,824
|
95% confidence interval for a given data set
|
A few comments:
Your title "95% confidence interval for a given data set" is misleading. Confidence intervals are calculated for computed values like means. It doesn't mean anything really to have a confidence interval for a data set.
Your proposed method will work with huge data sets, but will fail with small data sets. Why? Because the outlier itself increases the SD (assuming you are computing the SD from your actual values). With small data sets (say n=4), it is impossible for any outlier to be more than 2 SD from the mean. Try it! The most SD that a value can be from the mean is (n-1)/sqrt(n), where n is sample size.
There are established methods for determining outliers assuming the other values are sampled from a Gaussian distribution. Look up Grubbs test, for one of the most widely used tests.
Deciding what to do with outliers is tricky.
|
95% confidence interval for a given data set
|
A few comments:
Your title "95% confidence interval for a given data set" is misleading. Confidence intervals are calculated for computed values like means. It doesn't mean anything really to have a
|
95% confidence interval for a given data set
A few comments:
Your title "95% confidence interval for a given data set" is misleading. Confidence intervals are calculated for computed values like means. It doesn't mean anything really to have a confidence interval for a data set.
Your proposed method will work with huge data sets, but will fail with small data sets. Why? Because the outlier itself increases the SD (assuming you are computing the SD from your actual values). With small data sets (say n=4), it is impossible for any outlier to be more than 2 SD from the mean. Try it! The most SD that a value can be from the mean is (n-1)/sqrt(n), where n is sample size.
There are established methods for determining outliers assuming the other values are sampled from a Gaussian distribution. Look up Grubbs test, for one of the most widely used tests.
Deciding what to do with outliers is tricky.
|
95% confidence interval for a given data set
A few comments:
Your title "95% confidence interval for a given data set" is misleading. Confidence intervals are calculated for computed values like means. It doesn't mean anything really to have a
|
45,825
|
95% confidence interval for a given data set
|
An outlier is a surprising value.
Therefore, your method is flawed.
If the data set is large, then, if it is normally distributed, you expect some values beyond 2 sd from the mean. If the data set is small, and normally distributed, you don't expect values even 1 sd from the mean. e.g. it is not surprising that there are some 7 foot tall people in the USA.
In addition, you have calculated the mean and sd with the possible outliers IN the data. If the outliers are truly not part of the data (e.g. they are data entry errors; they got picked for the sample by mistake) then you should not have done this.
I would say that there are no really good statistical tests for outliers, even univariately. At best, there are ways to identify points that might be worth looking at. A better way than the one you propose is to graph the data. If you suppose it is normal, you could do a normal quantile plot. Even if you don't suppose it is normal, you could do a density plot.
In addition, you should always think of the substantive nature of the values. Is it *possible? E.g., among human adults, a weight of 500 pounds is possible (albeit very large). A weight of 5000 pounds is not.
|
95% confidence interval for a given data set
|
An outlier is a surprising value.
Therefore, your method is flawed.
If the data set is large, then, if it is normally distributed, you expect some values beyond 2 sd from the mean. If the data set is
|
95% confidence interval for a given data set
An outlier is a surprising value.
Therefore, your method is flawed.
If the data set is large, then, if it is normally distributed, you expect some values beyond 2 sd from the mean. If the data set is small, and normally distributed, you don't expect values even 1 sd from the mean. e.g. it is not surprising that there are some 7 foot tall people in the USA.
In addition, you have calculated the mean and sd with the possible outliers IN the data. If the outliers are truly not part of the data (e.g. they are data entry errors; they got picked for the sample by mistake) then you should not have done this.
I would say that there are no really good statistical tests for outliers, even univariately. At best, there are ways to identify points that might be worth looking at. A better way than the one you propose is to graph the data. If you suppose it is normal, you could do a normal quantile plot. Even if you don't suppose it is normal, you could do a density plot.
In addition, you should always think of the substantive nature of the values. Is it *possible? E.g., among human adults, a weight of 500 pounds is possible (albeit very large). A weight of 5000 pounds is not.
|
95% confidence interval for a given data set
An outlier is a surprising value.
Therefore, your method is flawed.
If the data set is large, then, if it is normally distributed, you expect some values beyond 2 sd from the mean. If the data set is
|
45,826
|
95% confidence interval for a given data set
|
Another approach you might consider is Tukey’s Outlier Filter. It is robust as well, since it is based on quantiles.
The idea behind is to classify as outlier data points that lies:
above 3rd quartile + 1.5 times the Inter Quartile Range (IQR, distance between the 1st and 3rd quartiles), and
below 1st quartile - 1.5 times the IQR.
The 1.5 range is arbitrary and was suggest empirically. You might use 3 instead to be more strict. Take care with asymmetric data, which would need an adjustment in the classification criterion.
Boxplot is a good plot to evaluate the points that may be considered outliers through this filter. See R example below applied to data posted by user603:
x <- c(-2.21,-1.84,-.95,-.91,-.36,-.19,-.11,-.1,.18,.3,.31,.43,.51,.64,.67,.72,1.22,1.35,8.1,17.6)
boxplot(x, range=3)
Reading suggestions:
SEO, Songwon. "A review and comparison of methods for detecting outliers in univariate data sets" (http://d-scholarship.pitt.edu/7948/1/Seo.pdf)
MASSART, Desire Luc et al. "Visual Presentation of Data by Means of Box Plots". (http://www.lcgceurope.com/lcgceurope/data/articlestandard/lcgceurope/132005/152912/article.pdf)
|
95% confidence interval for a given data set
|
Another approach you might consider is Tukey’s Outlier Filter. It is robust as well, since it is based on quantiles.
The idea behind is to classify as outlier data points that lies:
above 3rd quarti
|
95% confidence interval for a given data set
Another approach you might consider is Tukey’s Outlier Filter. It is robust as well, since it is based on quantiles.
The idea behind is to classify as outlier data points that lies:
above 3rd quartile + 1.5 times the Inter Quartile Range (IQR, distance between the 1st and 3rd quartiles), and
below 1st quartile - 1.5 times the IQR.
The 1.5 range is arbitrary and was suggest empirically. You might use 3 instead to be more strict. Take care with asymmetric data, which would need an adjustment in the classification criterion.
Boxplot is a good plot to evaluate the points that may be considered outliers through this filter. See R example below applied to data posted by user603:
x <- c(-2.21,-1.84,-.95,-.91,-.36,-.19,-.11,-.1,.18,.3,.31,.43,.51,.64,.67,.72,1.22,1.35,8.1,17.6)
boxplot(x, range=3)
Reading suggestions:
SEO, Songwon. "A review and comparison of methods for detecting outliers in univariate data sets" (http://d-scholarship.pitt.edu/7948/1/Seo.pdf)
MASSART, Desire Luc et al. "Visual Presentation of Data by Means of Box Plots". (http://www.lcgceurope.com/lcgceurope/data/articlestandard/lcgceurope/132005/152912/article.pdf)
|
95% confidence interval for a given data set
Another approach you might consider is Tukey’s Outlier Filter. It is robust as well, since it is based on quantiles.
The idea behind is to classify as outlier data points that lies:
above 3rd quarti
|
45,827
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Unfortunately you have few technical errors here.
You cannot make ARIMAX-model with library(forecast) function auto.arima. Xreg argument makes it regression model with ARMA errors. That is something which I had to learn hard way by wondering the results... :)
And you have to supply FUTURE values for the xreg argument in the forecast-function. Split your data into two parts: 1) one to fit model 2) future values for the exogenous variables. Auto.arima does not forecast future values of xreg variables by ARIMA-models.
If you want to try ARIMAX-models try library(TSA) with arimax-function which of course has different syntax than auto.arima - function... :)
EDIT:
Here is example for using auto.arima with xreg argument with data set having first data for model parameters estimation and then for forecasting.
library(forecast);
apu=read.table("demo_1.csv",sep=";",dec=",",header=TRUE);
apux=read.table("demo_2.csv",sep=";",dec=",",header=TRUE);
apuxx=read.table("demo_3_xreg.csv",sep=";",dec=",",header=TRUE);
apu2=ts(data=apu[2],start=c(2011,1),deltat=1/365);
apu3=ts(data=apu[3],start=c(2011,1),deltat=1/365);
apu4=ts(data=apux[1],start=c(2011,1),deltat=1/365);
Acf(apu2);
Pacf(apu2);
apu5=ts.intersect(apu3,apu4);
apu6=ts(data=apuxx[3],start=c(2013,263),deltat=1/365);
apu7=ts(data=apuxx[2],start=c(2013,263),deltat=1/365);
apu8=ts.intersect(apu6,apu7);
sarimax=auto.arima(apu2, d=NA, D=NA, max.p=5, max.q=5,
max.P=365, max.Q=365, max.order=5, start.p=2, start.q=2,
start.P=1, start.Q=1, stationary=FALSE, seasonal=TRUE,
ic=c("aicc","aic", "bic"), stepwise=TRUE, trace=FALSE,
approximation=(length(apu2)>100 | frequency(apu2)>12), xreg=apu5,
test=c("kpss","adf","pp"), seasonal.test=c("ocsb","ch"),
allowdrift=TRUE, lambda=0, parallel=FALSE, num.cores=NULL);
print(sarimax$arma);
print(accuracy(sarimax));
print(sarimax$coef);
plot(sarimax$residuals);
print(Box.test(sarimax$residuals,lag=30,type=c("Ljung-Box")));
sarimaxpredicts=forecast(sarimax, h=7,level=c(75,80,90,95), fan=FALSE, xreg=apu8, lambda=sarimax$lambda,bootstrap=FALSE, npaths=5000);
plot(sarimaxpredicts);
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Unfortunately you have few technical errors here.
You cannot make ARIMAX-model with library(forecast) function auto.arima. Xreg argument makes it regression model with ARMA errors. That is something
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Unfortunately you have few technical errors here.
You cannot make ARIMAX-model with library(forecast) function auto.arima. Xreg argument makes it regression model with ARMA errors. That is something which I had to learn hard way by wondering the results... :)
And you have to supply FUTURE values for the xreg argument in the forecast-function. Split your data into two parts: 1) one to fit model 2) future values for the exogenous variables. Auto.arima does not forecast future values of xreg variables by ARIMA-models.
If you want to try ARIMAX-models try library(TSA) with arimax-function which of course has different syntax than auto.arima - function... :)
EDIT:
Here is example for using auto.arima with xreg argument with data set having first data for model parameters estimation and then for forecasting.
library(forecast);
apu=read.table("demo_1.csv",sep=";",dec=",",header=TRUE);
apux=read.table("demo_2.csv",sep=";",dec=",",header=TRUE);
apuxx=read.table("demo_3_xreg.csv",sep=";",dec=",",header=TRUE);
apu2=ts(data=apu[2],start=c(2011,1),deltat=1/365);
apu3=ts(data=apu[3],start=c(2011,1),deltat=1/365);
apu4=ts(data=apux[1],start=c(2011,1),deltat=1/365);
Acf(apu2);
Pacf(apu2);
apu5=ts.intersect(apu3,apu4);
apu6=ts(data=apuxx[3],start=c(2013,263),deltat=1/365);
apu7=ts(data=apuxx[2],start=c(2013,263),deltat=1/365);
apu8=ts.intersect(apu6,apu7);
sarimax=auto.arima(apu2, d=NA, D=NA, max.p=5, max.q=5,
max.P=365, max.Q=365, max.order=5, start.p=2, start.q=2,
start.P=1, start.Q=1, stationary=FALSE, seasonal=TRUE,
ic=c("aicc","aic", "bic"), stepwise=TRUE, trace=FALSE,
approximation=(length(apu2)>100 | frequency(apu2)>12), xreg=apu5,
test=c("kpss","adf","pp"), seasonal.test=c("ocsb","ch"),
allowdrift=TRUE, lambda=0, parallel=FALSE, num.cores=NULL);
print(sarimax$arma);
print(accuracy(sarimax));
print(sarimax$coef);
plot(sarimax$residuals);
print(Box.test(sarimax$residuals,lag=30,type=c("Ljung-Box")));
sarimaxpredicts=forecast(sarimax, h=7,level=c(75,80,90,95), fan=FALSE, xreg=apu8, lambda=sarimax$lambda,bootstrap=FALSE, npaths=5000);
plot(sarimaxpredicts);
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Unfortunately you have few technical errors here.
You cannot make ARIMAX-model with library(forecast) function auto.arima. Xreg argument makes it regression model with ARMA errors. That is something
|
45,828
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Unobserved Components Model (UCM) is a state space modeling approach to time series forecasting and regression analysis. It is a very flexible modeling approach, easy to interpret method. I'm not trained in statistics. UCM is a very intuitive method that a non statistician like me could easily adopt and focus on solving the problem as opposed to spending time on model building. UCM is also a very general model and every sensible ARIMA has an UCM equivalent, however not all the UCM have an equivalent ARIMA model.
I used SAS to model the UCM. Hovwever, there are other tools such as Stata, Oxmetrics that also have UCM. I don't think there is an easy to use UCM package in R. There is an excellent text An Introduction to State Space Time Series Analysis by Jacques J.F. Commandeur (Author), Siem Jan Koopman (Author) that you could refer to.
Below is the code, that I used to model, I also regressed lag value of price, becuase it is reasonable to assume that current months price can have an effect on future months demand.
data demandm;
set demand;
weather_1 = lag(weather); *lag 1;
price_1 = lag(price); *lag 1;
weather_2 = lag2(weather); *lag 2;
price_2 = lag2(price); *lag 2;
if weather_2 = . then delete;
if price_2 = . then delete;
run;
ods graphics on ;
proc ucm data = demandm;
id date interval = month;
model demand =weather price price_1;
irregular p = 1;
season length = 12 variance = 0 noest plot = smooth;
estimate back=5 plot=(normal acf);
forecast lead=5 back=5 plot=decomp;
run ;
ods graphics off ;
About the code:
I created a dataset with lag1 and lag2 variable for weather and
price and deleted the first 2 observations because it does not include 2 lags.
I used a basic structural model in Proc UCM with only irregular
component and seasonal component. In addition, I regressed demand on
weather, current months price and past months price. All other
variable were not significant. I also held out last 5 months to see
how well this model predicts the unknown future data.
You could forecast the data by simply changing the forecast statement
within proc ucm, however you need to supply the independent variables
weather and price for future values.
Below is the output:
Irregular Error Variance 2.416887E12 3.6646E11 6.60 <.0001
Irregular AR_1 0.35428 0.10069 3.52 0.0004
Weather Coefficient 97713 11412.6 8.56 <.0001
Price Coefficient 496679 156407.4 3.18 0.0015
price_1 Coefficient -770025 164737.7 -4.67 <.0001
Since the analysis of residuals showed some pattern left, I modeled irregular component as an autoregressive order = 1. See the code in the irregular component where I have put p = 1. Price at lag2 and weather at both lags are not significant. With regards to significant individual variables,
Each unit change in weather has an increase of ~98,000 units in
demand.
Current months price has an increase of ~496,000 units of demand.
Current months increase in price has a ~770,000 unit decrease in next
months demand.
The model also automatically identified 2 outliers in July 2012 and August 2007 which can be corrected by changing the SAS code using a dummy code variables.
Below are some nice graphical outputs (read in clockwise):
the most important plot is the residual auto correlation which shows that there is no pattern left.
The season plot where you you can see there is an increase in demand during summer and winder and low demand in spring and fall. Seems intuitive, but the great strength of UCM is that it gives you an interpretable components such as this.
Final plot is the model with fitted data.
is the out of sample forecast, where you have 5 values that have been held out and the model applied as you can visually see, the current model fits the out of sample data very well, you could use this to compare other class of models.
Hope this is helpful.
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Unobserved Components Model (UCM) is a state space modeling approach to time series forecasting and regression analysis. It is a very flexible modeling approach, easy to interpret method. I'm not trai
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Unobserved Components Model (UCM) is a state space modeling approach to time series forecasting and regression analysis. It is a very flexible modeling approach, easy to interpret method. I'm not trained in statistics. UCM is a very intuitive method that a non statistician like me could easily adopt and focus on solving the problem as opposed to spending time on model building. UCM is also a very general model and every sensible ARIMA has an UCM equivalent, however not all the UCM have an equivalent ARIMA model.
I used SAS to model the UCM. Hovwever, there are other tools such as Stata, Oxmetrics that also have UCM. I don't think there is an easy to use UCM package in R. There is an excellent text An Introduction to State Space Time Series Analysis by Jacques J.F. Commandeur (Author), Siem Jan Koopman (Author) that you could refer to.
Below is the code, that I used to model, I also regressed lag value of price, becuase it is reasonable to assume that current months price can have an effect on future months demand.
data demandm;
set demand;
weather_1 = lag(weather); *lag 1;
price_1 = lag(price); *lag 1;
weather_2 = lag2(weather); *lag 2;
price_2 = lag2(price); *lag 2;
if weather_2 = . then delete;
if price_2 = . then delete;
run;
ods graphics on ;
proc ucm data = demandm;
id date interval = month;
model demand =weather price price_1;
irregular p = 1;
season length = 12 variance = 0 noest plot = smooth;
estimate back=5 plot=(normal acf);
forecast lead=5 back=5 plot=decomp;
run ;
ods graphics off ;
About the code:
I created a dataset with lag1 and lag2 variable for weather and
price and deleted the first 2 observations because it does not include 2 lags.
I used a basic structural model in Proc UCM with only irregular
component and seasonal component. In addition, I regressed demand on
weather, current months price and past months price. All other
variable were not significant. I also held out last 5 months to see
how well this model predicts the unknown future data.
You could forecast the data by simply changing the forecast statement
within proc ucm, however you need to supply the independent variables
weather and price for future values.
Below is the output:
Irregular Error Variance 2.416887E12 3.6646E11 6.60 <.0001
Irregular AR_1 0.35428 0.10069 3.52 0.0004
Weather Coefficient 97713 11412.6 8.56 <.0001
Price Coefficient 496679 156407.4 3.18 0.0015
price_1 Coefficient -770025 164737.7 -4.67 <.0001
Since the analysis of residuals showed some pattern left, I modeled irregular component as an autoregressive order = 1. See the code in the irregular component where I have put p = 1. Price at lag2 and weather at both lags are not significant. With regards to significant individual variables,
Each unit change in weather has an increase of ~98,000 units in
demand.
Current months price has an increase of ~496,000 units of demand.
Current months increase in price has a ~770,000 unit decrease in next
months demand.
The model also automatically identified 2 outliers in July 2012 and August 2007 which can be corrected by changing the SAS code using a dummy code variables.
Below are some nice graphical outputs (read in clockwise):
the most important plot is the residual auto correlation which shows that there is no pattern left.
The season plot where you you can see there is an increase in demand during summer and winder and low demand in spring and fall. Seems intuitive, but the great strength of UCM is that it gives you an interpretable components such as this.
Final plot is the model with fitted data.
is the out of sample forecast, where you have 5 values that have been held out and the model applied as you can visually see, the current model fits the out of sample data very well, you could use this to compare other class of models.
Hope this is helpful.
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Unobserved Components Model (UCM) is a state space modeling approach to time series forecasting and regression analysis. It is a very flexible modeling approach, easy to interpret method. I'm not trai
|
45,829
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Fortunately one doesn't have to assume the lag structure that is appropriate as this can be suggested via the Impulse Response Weights which can be(was) modified empirically via model diagnostics. Additionally one doesn't have to assume the number of seasonal indicators and their start dates as this can be easily found via Intervention Detection. Most importantly one doesn't have to assume that the error variance is constant as the Box-Cox test can be optionally automatically evaluated for different transforms. Finally one doesn't have to manually add Pulse Indicators as modern software will perform that.
Following is a model (using scaled data ) that was automatically developed by using the freely available demo from http://www.autobox.com/30day.exe .You can download this 30 day trial version yourself and duplicate these results in a matter of minutes ( without limiting guesses as to model form ). I was one of the developers of AUTOBOX and can vouch for it's thoroughness. If you have any questions/issues contact the folks at Automatic Forecasting Systems.
The Actual/Cleansed graph illustrates the points that seasonal indicators and pulses were identified.
The table of forecasts is here
with accompanying graph
In closing the Actual/Fit and Forecasts
The first period out forecast of 80 is higher than the observed value of 53 but with a standard deviation of approximately 28 , the value of 53 is about 1 standard deviation away. Forecasters forecast fo this first period out is more accurate but as somebody once said "one swallow does not make a summer" .
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
|
Fortunately one doesn't have to assume the lag structure that is appropriate as this can be suggested via the Impulse Response Weights which can be(was) modified empirically via model diagnostics. Add
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Fortunately one doesn't have to assume the lag structure that is appropriate as this can be suggested via the Impulse Response Weights which can be(was) modified empirically via model diagnostics. Additionally one doesn't have to assume the number of seasonal indicators and their start dates as this can be easily found via Intervention Detection. Most importantly one doesn't have to assume that the error variance is constant as the Box-Cox test can be optionally automatically evaluated for different transforms. Finally one doesn't have to manually add Pulse Indicators as modern software will perform that.
Following is a model (using scaled data ) that was automatically developed by using the freely available demo from http://www.autobox.com/30day.exe .You can download this 30 day trial version yourself and duplicate these results in a matter of minutes ( without limiting guesses as to model form ). I was one of the developers of AUTOBOX and can vouch for it's thoroughness. If you have any questions/issues contact the folks at Automatic Forecasting Systems.
The Actual/Cleansed graph illustrates the points that seasonal indicators and pulses were identified.
The table of forecasts is here
with accompanying graph
In closing the Actual/Fit and Forecasts
The first period out forecast of 80 is higher than the observed value of 53 but with a standard deviation of approximately 28 , the value of 53 is about 1 standard deviation away. Forecasters forecast fo this first period out is more accurate but as somebody once said "one swallow does not make a summer" .
|
Performing a time series ARIMA model on natural gas power demand using the forecast package from R
Fortunately one doesn't have to assume the lag structure that is appropriate as this can be suggested via the Impulse Response Weights which can be(was) modified empirically via model diagnostics. Add
|
45,830
|
Interpretation of p-value in comparing proportions between two small groups in R
|
You are mixing a couple of concepts (one of which is really outdated in the age of computers, but still persists anyways).
For numerical variables you should use the t-test when you are calculating the standard deviation(s) from the sample(s). If you know the true population standard deviation(s) then you can use the z-test (it is rare that you would know the standard deviation(s) but not the mean(s)). Before computers were easily available for doing statistics, we used tables to look up p-values or critical values. Some t-tables only went up to about 30 degrees of freedom since the values for more than 30 degrees of freedom are almost the same as the normal. This lead to the rule of using a z-test for large sample sizes (larger than your table went to) and the t-test for smaller values (that could be looked up on the t-table). But with modern computers and statistical software we can calculate the t values for any number of degrees of freedom. So we should always use the t-test for numerical variables when we do not know the population standard deviation and only use the z-test for the rare cases where we do know (or can assume from the null hypothesis) the population standard deviation.
When working with proportions the standard deviation is a function of the proportion and is therefore "known", so we never use the t-test for proportions. If the sample size is large enough relative to the proportions being tested then the binomial can be approximated by a normal distribution, so for large sample you can use the z-test. This can lead to the confusion (not unique to you). But for small samples on proportions you need to use a different test that is based on the binomial or hypergeometric distributions. One option is Fisher's exact test:
> fisher.test( cbind( c(2,9), c(18-2, 21-9) ) )
Fisher's Exact Test for Count Data
data: cbind(c(2, 9), c(18 - 2, 21 - 9))
p-value = 0.03749
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.01557731 1.06612067
sample estimates:
odds ratio
0.1744356
The confidence interval here is on the odds ratio rather than the difference of proportions.
|
Interpretation of p-value in comparing proportions between two small groups in R
|
You are mixing a couple of concepts (one of which is really outdated in the age of computers, but still persists anyways).
For numerical variables you should use the t-test when you are calculating th
|
Interpretation of p-value in comparing proportions between two small groups in R
You are mixing a couple of concepts (one of which is really outdated in the age of computers, but still persists anyways).
For numerical variables you should use the t-test when you are calculating the standard deviation(s) from the sample(s). If you know the true population standard deviation(s) then you can use the z-test (it is rare that you would know the standard deviation(s) but not the mean(s)). Before computers were easily available for doing statistics, we used tables to look up p-values or critical values. Some t-tables only went up to about 30 degrees of freedom since the values for more than 30 degrees of freedom are almost the same as the normal. This lead to the rule of using a z-test for large sample sizes (larger than your table went to) and the t-test for smaller values (that could be looked up on the t-table). But with modern computers and statistical software we can calculate the t values for any number of degrees of freedom. So we should always use the t-test for numerical variables when we do not know the population standard deviation and only use the z-test for the rare cases where we do know (or can assume from the null hypothesis) the population standard deviation.
When working with proportions the standard deviation is a function of the proportion and is therefore "known", so we never use the t-test for proportions. If the sample size is large enough relative to the proportions being tested then the binomial can be approximated by a normal distribution, so for large sample you can use the z-test. This can lead to the confusion (not unique to you). But for small samples on proportions you need to use a different test that is based on the binomial or hypergeometric distributions. One option is Fisher's exact test:
> fisher.test( cbind( c(2,9), c(18-2, 21-9) ) )
Fisher's Exact Test for Count Data
data: cbind(c(2, 9), c(18 - 2, 21 - 9))
p-value = 0.03749
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.01557731 1.06612067
sample estimates:
odds ratio
0.1744356
The confidence interval here is on the odds ratio rather than the difference of proportions.
|
Interpretation of p-value in comparing proportions between two small groups in R
You are mixing a couple of concepts (one of which is really outdated in the age of computers, but still persists anyways).
For numerical variables you should use the t-test when you are calculating th
|
45,831
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
|
The problem with the second approach is that the training set is smaller (half of the available data) than for the cross-validation approach ((k-1)/k of the available data). As most learning algorithms perform better the more data they are trained on, this means that the second approach gives a more pessimistically biased estimate of the performance of a model trained on all of the available data than the cross-validation based approach. Taken to its extreme, where k is the size of the available dataset (i.e. leave-one-out cross-validation) gives an almost unbiased estimate of generalisation performance.
However, as well as bias (whether the estimate is systematically wrong), there is also variance (how much the estimate varies depending on the selection of data over which it is calculated). If we use more data for training, this also reduces the variability of the performance of the resulting model, but it leaves less testing data, so the variance of the performance estimate increases. This means that there is usually a compromise between variance and bias in determining how much data can be used for training and for testing in each fold (i.e. in practice, leave-one-out cross-validation isn't optimal as while it is almost unbiased, it has a high variance, so the estimator has a higher error).
The more folds of the resampling procedure we use, the more we can reduce the variance of the estimator. With split sampling that is easy, just increase the number of folds. For cross-validation, we can perform cross-validation repeatedly, choosing a different partition of the data into k disjoint subsets each time and average. I often perform 100 random test-training splits (i.e. the second approach) but use a 90%/10% split between training and test data to reduce the bias of the estimator.
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
|
The problem with the second approach is that the training set is smaller (half of the available data) than for the cross-validation approach ((k-1)/k of the available data). As most learning algorith
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
The problem with the second approach is that the training set is smaller (half of the available data) than for the cross-validation approach ((k-1)/k of the available data). As most learning algorithms perform better the more data they are trained on, this means that the second approach gives a more pessimistically biased estimate of the performance of a model trained on all of the available data than the cross-validation based approach. Taken to its extreme, where k is the size of the available dataset (i.e. leave-one-out cross-validation) gives an almost unbiased estimate of generalisation performance.
However, as well as bias (whether the estimate is systematically wrong), there is also variance (how much the estimate varies depending on the selection of data over which it is calculated). If we use more data for training, this also reduces the variability of the performance of the resulting model, but it leaves less testing data, so the variance of the performance estimate increases. This means that there is usually a compromise between variance and bias in determining how much data can be used for training and for testing in each fold (i.e. in practice, leave-one-out cross-validation isn't optimal as while it is almost unbiased, it has a high variance, so the estimator has a higher error).
The more folds of the resampling procedure we use, the more we can reduce the variance of the estimator. With split sampling that is easy, just increase the number of folds. For cross-validation, we can perform cross-validation repeatedly, choosing a different partition of the data into k disjoint subsets each time and average. I often perform 100 random test-training splits (i.e. the second approach) but use a 90%/10% split between training and test data to reduce the bias of the estimator.
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
The problem with the second approach is that the training set is smaller (half of the available data) than for the cross-validation approach ((k-1)/k of the available data). As most learning algorith
|
45,832
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
|
@Dikran has already provided a detailed analysis. Cross validation helps you with model selection. According to Hoeffding inequality, the expected out-of-sample error can be estimated based on your validation error:
$E_{out} \leq E_{val} + O(\sqrt \frac{lnM}{K})$ where $M$ is the model number, and $K$ is the number among $N$ samples picked for validation. As you can see the larger $K$ may make the out of sample error better bounded in estimation. On the other hand, however, when you draw the learning curve, you many find small training number ($N-K$) lead to both large in-sample error and the validation error (bias), as the training number increases, two curves finally converges. So there is a trade-off between $K$, and $N-K$ actually, and the rule of thumb is usually $K = \frac{N}{10}$.
One more thing (might be off topic a little bit): more training samples may not reduce the variance, see my answer here.
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
|
@Dikran has already provided a detailed analysis. Cross validation helps you with model selection. According to Hoeffding inequality, the expected out-of-sample error can be estimated based on your va
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
@Dikran has already provided a detailed analysis. Cross validation helps you with model selection. According to Hoeffding inequality, the expected out-of-sample error can be estimated based on your validation error:
$E_{out} \leq E_{val} + O(\sqrt \frac{lnM}{K})$ where $M$ is the model number, and $K$ is the number among $N$ samples picked for validation. As you can see the larger $K$ may make the out of sample error better bounded in estimation. On the other hand, however, when you draw the learning curve, you many find small training number ($N-K$) lead to both large in-sample error and the validation error (bias), as the training number increases, two curves finally converges. So there is a trade-off between $K$, and $N-K$ actually, and the rule of thumb is usually $K = \frac{N}{10}$.
One more thing (might be off topic a little bit): more training samples may not reduce the variance, see my answer here.
|
Why is k-fold cross validation a better idea than k-times resampling true validation?
@Dikran has already provided a detailed analysis. Cross validation helps you with model selection. According to Hoeffding inequality, the expected out-of-sample error can be estimated based on your va
|
45,833
|
How many clusters for linear mixed models and GEE?
|
Recommendations for the number of groups and units per group are good at the study design phase. At this point in your research, you can only hope to produce decent estimates with the data that you have at hand, and that's probably the literature that you should be studying, and questions that you should be asking.
Behavior of the GEEs are asymptotic in $m$, so the more the merrier. I would say that $m=50$ is a moderate sample size (Teerenstra et. al. (2010) give references, behind the paid walls, that in turn say that sample sizes of less than $m=40$ clusters are insufficient); $m=200$ will probably be large enough for approximately symmetric data (not necessarily large enough for low proportions like single digit %, or badly overdispersed count data), while $m=10$ will be too small to really trust asymptotics.
Hox (1998) suggests the number of groups to be $m \ge 50$, and group sizes, $n/m \ge 20$, for asymptotics of the mixed models (which social scientists call multilevel models) to work well. (Think of this recommendation as a modest size educational study: enough classrooms/teachers with 20 students per class.) Maas and Hox (2005) updated these recommendations and studied smaller $m$, down to $m=10$, but they never thought of dropping the number of units in the group anywhere below 5. Some studies with low number of units per group are coming from Bell, Ferron and Kromrey (2008, 2010), although they concentrated on proportion of singletons (groups of size 1) rather than the size per se.
|
How many clusters for linear mixed models and GEE?
|
Recommendations for the number of groups and units per group are good at the study design phase. At this point in your research, you can only hope to produce decent estimates with the data that you ha
|
How many clusters for linear mixed models and GEE?
Recommendations for the number of groups and units per group are good at the study design phase. At this point in your research, you can only hope to produce decent estimates with the data that you have at hand, and that's probably the literature that you should be studying, and questions that you should be asking.
Behavior of the GEEs are asymptotic in $m$, so the more the merrier. I would say that $m=50$ is a moderate sample size (Teerenstra et. al. (2010) give references, behind the paid walls, that in turn say that sample sizes of less than $m=40$ clusters are insufficient); $m=200$ will probably be large enough for approximately symmetric data (not necessarily large enough for low proportions like single digit %, or badly overdispersed count data), while $m=10$ will be too small to really trust asymptotics.
Hox (1998) suggests the number of groups to be $m \ge 50$, and group sizes, $n/m \ge 20$, for asymptotics of the mixed models (which social scientists call multilevel models) to work well. (Think of this recommendation as a modest size educational study: enough classrooms/teachers with 20 students per class.) Maas and Hox (2005) updated these recommendations and studied smaller $m$, down to $m=10$, but they never thought of dropping the number of units in the group anywhere below 5. Some studies with low number of units per group are coming from Bell, Ferron and Kromrey (2008, 2010), although they concentrated on proportion of singletons (groups of size 1) rather than the size per se.
|
How many clusters for linear mixed models and GEE?
Recommendations for the number of groups and units per group are good at the study design phase. At this point in your research, you can only hope to produce decent estimates with the data that you ha
|
45,834
|
Factor analysis on a "rotating" subset of survey questions
|
Because the design incorporates planned missingness, the data can be assumed to be missing completely at random and an imputation procedure could be adopted to deal with the missing data. I'd go with this option if you really have no idea how the items should load/number of factors to extract, since missingness tends to be quite high in planned missingness designs to just do something like listwise or pairwise deletion.
If you have some idea of the number of factors and where the items should load, another option is to use a more exploratory CFA. In this case, SEM adequately handles the missing data using full-information maximum likelihood estimation. If you choose this option, keep in mind that fit indices tend to show artificially better fit the more missingness you have. More info here.
|
Factor analysis on a "rotating" subset of survey questions
|
Because the design incorporates planned missingness, the data can be assumed to be missing completely at random and an imputation procedure could be adopted to deal with the missing data. I'd go with
|
Factor analysis on a "rotating" subset of survey questions
Because the design incorporates planned missingness, the data can be assumed to be missing completely at random and an imputation procedure could be adopted to deal with the missing data. I'd go with this option if you really have no idea how the items should load/number of factors to extract, since missingness tends to be quite high in planned missingness designs to just do something like listwise or pairwise deletion.
If you have some idea of the number of factors and where the items should load, another option is to use a more exploratory CFA. In this case, SEM adequately handles the missing data using full-information maximum likelihood estimation. If you choose this option, keep in mind that fit indices tend to show artificially better fit the more missingness you have. More info here.
|
Factor analysis on a "rotating" subset of survey questions
Because the design incorporates planned missingness, the data can be assumed to be missing completely at random and an imputation procedure could be adopted to deal with the missing data. I'd go with
|
45,835
|
Factor analysis on a "rotating" subset of survey questions
|
EFA is based on the covariance between items. If items are well represented in the dataset, then you should be okay when estimating factor loadings and such. If you have many participants completing a large minority of random items, then your data should a good representation of the possible item combinations. This would thus look similar to if you only had participants complete all items. One issue is how completing only some of the items (or a specific subset) could impact response patterns, but I do not see this as a significant concern. A unorthodox method to be sure, but I cannot think of a salient critique (I stand to be corrected and down voted, which might occur shortly...).
This is basically like doing EFA with a ton of missing data, is it not? It still works, but you would need many more participants than usual since everyone is not completing everything.
|
Factor analysis on a "rotating" subset of survey questions
|
EFA is based on the covariance between items. If items are well represented in the dataset, then you should be okay when estimating factor loadings and such. If you have many participants completing a
|
Factor analysis on a "rotating" subset of survey questions
EFA is based on the covariance between items. If items are well represented in the dataset, then you should be okay when estimating factor loadings and such. If you have many participants completing a large minority of random items, then your data should a good representation of the possible item combinations. This would thus look similar to if you only had participants complete all items. One issue is how completing only some of the items (or a specific subset) could impact response patterns, but I do not see this as a significant concern. A unorthodox method to be sure, but I cannot think of a salient critique (I stand to be corrected and down voted, which might occur shortly...).
This is basically like doing EFA with a ton of missing data, is it not? It still works, but you would need many more participants than usual since everyone is not completing everything.
|
Factor analysis on a "rotating" subset of survey questions
EFA is based on the covariance between items. If items are well represented in the dataset, then you should be okay when estimating factor loadings and such. If you have many participants completing a
|
45,836
|
Factor analysis on a "rotating" subset of survey questions
|
This approach reminds me a lot of Synthetic Aperture Personality Assessment (SAPA). You may want to read further into it to see what you can learn about the method and judge how closely it resembles what you have in mind. If it's sufficiently equivalent for your purposes, the news appears to be good. This page says:
5) For some applications, data matrices are synthetically combined from sampling different items for different people. So called Synthetic Aperture Personality Assessement (SAPA) techniques allow the formation of large correlation or covariance matrices even though no one person has taken all of the items. To analyze such data sets, it is easy to form item composites based upon the covariance matrix of the items, rather than original data set. These matrices may then be analyzed using a number of functions (e.g., cluster.cor, factor.pa, ICLUST, principal , mat.regress, and factor2cluster.
|
Factor analysis on a "rotating" subset of survey questions
|
This approach reminds me a lot of Synthetic Aperture Personality Assessment (SAPA). You may want to read further into it to see what you can learn about the method and judge how closely it resembles w
|
Factor analysis on a "rotating" subset of survey questions
This approach reminds me a lot of Synthetic Aperture Personality Assessment (SAPA). You may want to read further into it to see what you can learn about the method and judge how closely it resembles what you have in mind. If it's sufficiently equivalent for your purposes, the news appears to be good. This page says:
5) For some applications, data matrices are synthetically combined from sampling different items for different people. So called Synthetic Aperture Personality Assessement (SAPA) techniques allow the formation of large correlation or covariance matrices even though no one person has taken all of the items. To analyze such data sets, it is easy to form item composites based upon the covariance matrix of the items, rather than original data set. These matrices may then be analyzed using a number of functions (e.g., cluster.cor, factor.pa, ICLUST, principal , mat.regress, and factor2cluster.
|
Factor analysis on a "rotating" subset of survey questions
This approach reminds me a lot of Synthetic Aperture Personality Assessment (SAPA). You may want to read further into it to see what you can learn about the method and judge how closely it resembles w
|
45,837
|
How to interpret interaction continuous variables in logistic regression?
|
When nnd is 0 a unit change in gonad is associated with a $(\exp(-1.5718 ) - 1)*100\% \approx -79 \% $ decrease in the odds of fullyspawned.
For every unit increase in nnd this effect of gonad increases by $(\exp( 0.6407 ) - 1)*100\% \approx 90 \%$.
So, when nnd is 1 the odds ratio for gonad is $1.9^1 \times .21 \approx .4$, that is, a unit change in gonad is now associated with only a $-60\%$ decrease in odds of fullyspawned. When nnd is 2 the odds ratio for gonad is $1.9^2 \times .21 \approx .76$, that is, a unit change in gonad is now associated with only a $-24\%$ decrease in odds of fullyspawned.
There are various examples on how to interpret interaction terms in this kind of model here.
|
How to interpret interaction continuous variables in logistic regression?
|
When nnd is 0 a unit change in gonad is associated with a $(\exp(-1.5718 ) - 1)*100\% \approx -79 \% $ decrease in the odds of fullyspawned.
For every unit increase in nnd this effect of gonad increa
|
How to interpret interaction continuous variables in logistic regression?
When nnd is 0 a unit change in gonad is associated with a $(\exp(-1.5718 ) - 1)*100\% \approx -79 \% $ decrease in the odds of fullyspawned.
For every unit increase in nnd this effect of gonad increases by $(\exp( 0.6407 ) - 1)*100\% \approx 90 \%$.
So, when nnd is 1 the odds ratio for gonad is $1.9^1 \times .21 \approx .4$, that is, a unit change in gonad is now associated with only a $-60\%$ decrease in odds of fullyspawned. When nnd is 2 the odds ratio for gonad is $1.9^2 \times .21 \approx .76$, that is, a unit change in gonad is now associated with only a $-24\%$ decrease in odds of fullyspawned.
There are various examples on how to interpret interaction terms in this kind of model here.
|
How to interpret interaction continuous variables in logistic regression?
When nnd is 0 a unit change in gonad is associated with a $(\exp(-1.5718 ) - 1)*100\% \approx -79 \% $ decrease in the odds of fullyspawned.
For every unit increase in nnd this effect of gonad increa
|
45,838
|
Error bars using median absolute deviation
|
It sounds like you're talking about what's sometimes called a regressogram, with a log-scaled x-variable.
There are a number of issues here, not necessarily in logical order:
the quantity you're plotting is a mean, so if you want to plot median absolute deviation, it's the MAD of the means you want.
your suggestion $\text{MAD}/\sqrt n$ leads to the question "when is the MAD of the mean equal to the MAD of the data divided by $\sqrt n$?"
when you say "it seems that median absolute deviation is a better estimator than mean absolute deviation" ... that depends what we're talking about - a better estimator of what?, and under what circumstances?
So, "when is the MAD of the mean equal to the MAD of the data divided by $\sqrt n$?"
The answer is, unlike the situation with standard deviation, this is not generally the case. The reason why standard deviations of averages scale as they do is that variances of independent random variables add (more precisely, the variance of the sum is the sum of the variances when the variables are independent), irrespective of the distributions of the components (as long as the variances all exist). It is this particular property that largely accounts for the popularity of variances and standard deviations.
Neither the median deviation, nor the mean deviation have that property in general.
However, when the data are normal, they will in effect inherit that property, since the ratio of the population mean deviation or median deviation to the standard deviation at a normal will be a constant, normals are closed under convolution, and standard deviations scale that way.
If the data were reasonably close to normal, it could perhaps be adequate.
What else might be done? One way to estimate the standard error of a statistic is via the bootstrap; for the mean deviation - being a mean - this should do well in large samples. Unfortunately, medians don't do so well under the bootstrap, and this issue will carry over to median absolute deviations.
If you have some probability model for your data, there's also simulation as a way of approaching the problem.
|
Error bars using median absolute deviation
|
It sounds like you're talking about what's sometimes called a regressogram, with a log-scaled x-variable.
There are a number of issues here, not necessarily in logical order:
the quantity you're plot
|
Error bars using median absolute deviation
It sounds like you're talking about what's sometimes called a regressogram, with a log-scaled x-variable.
There are a number of issues here, not necessarily in logical order:
the quantity you're plotting is a mean, so if you want to plot median absolute deviation, it's the MAD of the means you want.
your suggestion $\text{MAD}/\sqrt n$ leads to the question "when is the MAD of the mean equal to the MAD of the data divided by $\sqrt n$?"
when you say "it seems that median absolute deviation is a better estimator than mean absolute deviation" ... that depends what we're talking about - a better estimator of what?, and under what circumstances?
So, "when is the MAD of the mean equal to the MAD of the data divided by $\sqrt n$?"
The answer is, unlike the situation with standard deviation, this is not generally the case. The reason why standard deviations of averages scale as they do is that variances of independent random variables add (more precisely, the variance of the sum is the sum of the variances when the variables are independent), irrespective of the distributions of the components (as long as the variances all exist). It is this particular property that largely accounts for the popularity of variances and standard deviations.
Neither the median deviation, nor the mean deviation have that property in general.
However, when the data are normal, they will in effect inherit that property, since the ratio of the population mean deviation or median deviation to the standard deviation at a normal will be a constant, normals are closed under convolution, and standard deviations scale that way.
If the data were reasonably close to normal, it could perhaps be adequate.
What else might be done? One way to estimate the standard error of a statistic is via the bootstrap; for the mean deviation - being a mean - this should do well in large samples. Unfortunately, medians don't do so well under the bootstrap, and this issue will carry over to median absolute deviations.
If you have some probability model for your data, there's also simulation as a way of approaching the problem.
|
Error bars using median absolute deviation
It sounds like you're talking about what's sometimes called a regressogram, with a log-scaled x-variable.
There are a number of issues here, not necessarily in logical order:
the quantity you're plot
|
45,839
|
Error bars using median absolute deviation
|
A standard error means something. You don't just take any old statistic and divide by sqrt(n). Why not just plot your MAD and have your error bar a representation of variability in the data? If you want something to represent the quality of your median estimate then just calculate a confidence interval of the median.
|
Error bars using median absolute deviation
|
A standard error means something. You don't just take any old statistic and divide by sqrt(n). Why not just plot your MAD and have your error bar a representation of variability in the data? If you wa
|
Error bars using median absolute deviation
A standard error means something. You don't just take any old statistic and divide by sqrt(n). Why not just plot your MAD and have your error bar a representation of variability in the data? If you want something to represent the quality of your median estimate then just calculate a confidence interval of the median.
|
Error bars using median absolute deviation
A standard error means something. You don't just take any old statistic and divide by sqrt(n). Why not just plot your MAD and have your error bar a representation of variability in the data? If you wa
|
45,840
|
Error bars using median absolute deviation
|
Whatever you do, plot your raw data or minimally make them available some how.
If you choose median absolute deviation (MAD), do make it absolutely clear whether it is of deviations from the mean or the median, as I've seen MAD used as an abbreviation for both and in any case any ambiguity benefits no-one.
Plotting +/- MAD as error bars has a loose connection to the widely used box plots in which median and quartiles are shown in a box and there are various different recipes for what is shown outside the box.
MAD is approximately |quartile $-$ median| in a symmetric distribution. For a symmetric distribution it's immaterial whether MAD is MAD from median and or from mean or "quartile" is the upper or lower quartile. MAD will be similar to (upper q. $-$ median) and (median $-$ lower q.) even in many asymmetric distributions. There are various slightly different rules for quartiles, which may cause minor puzzles, but is not central here.
A bigger question is this: if outliers make your standard errors dubious, how come you want to show means, because they will be affected too? As @John implies, a median is clearly a possibility. Also, would you be better off on a logarithmic or other transformed scale for your y variable too?
|
Error bars using median absolute deviation
|
Whatever you do, plot your raw data or minimally make them available some how.
If you choose median absolute deviation (MAD), do make it absolutely clear whether it is of deviations from the mean or
|
Error bars using median absolute deviation
Whatever you do, plot your raw data or minimally make them available some how.
If you choose median absolute deviation (MAD), do make it absolutely clear whether it is of deviations from the mean or the median, as I've seen MAD used as an abbreviation for both and in any case any ambiguity benefits no-one.
Plotting +/- MAD as error bars has a loose connection to the widely used box plots in which median and quartiles are shown in a box and there are various different recipes for what is shown outside the box.
MAD is approximately |quartile $-$ median| in a symmetric distribution. For a symmetric distribution it's immaterial whether MAD is MAD from median and or from mean or "quartile" is the upper or lower quartile. MAD will be similar to (upper q. $-$ median) and (median $-$ lower q.) even in many asymmetric distributions. There are various slightly different rules for quartiles, which may cause minor puzzles, but is not central here.
A bigger question is this: if outliers make your standard errors dubious, how come you want to show means, because they will be affected too? As @John implies, a median is clearly a possibility. Also, would you be better off on a logarithmic or other transformed scale for your y variable too?
|
Error bars using median absolute deviation
Whatever you do, plot your raw data or minimally make them available some how.
If you choose median absolute deviation (MAD), do make it absolutely clear whether it is of deviations from the mean or
|
45,841
|
How to report the ratio of two sets of experimental results?
|
I would symmetrize the problem and recognize the matching by working with the logs of the individual ratios, say $z_i = \ln(x_i/y_i)$, getting the limits of a $100(1-\alpha)$% confidence interval for the mean of $z$ the usual way as $\bar{z} \pm t_{9,1-\alpha/2}\,s_z/\sqrt{10}$. (I know it's not strictly justified, but with such a small $n$ I prefer it to the bootstrap.)
|
How to report the ratio of two sets of experimental results?
|
I would symmetrize the problem and recognize the matching by working with the logs of the individual ratios, say $z_i = \ln(x_i/y_i)$, getting the limits of a $100(1-\alpha)$% confidence interval for
|
How to report the ratio of two sets of experimental results?
I would symmetrize the problem and recognize the matching by working with the logs of the individual ratios, say $z_i = \ln(x_i/y_i)$, getting the limits of a $100(1-\alpha)$% confidence interval for the mean of $z$ the usual way as $\bar{z} \pm t_{9,1-\alpha/2}\,s_z/\sqrt{10}$. (I know it's not strictly justified, but with such a small $n$ I prefer it to the bootstrap.)
|
How to report the ratio of two sets of experimental results?
I would symmetrize the problem and recognize the matching by working with the logs of the individual ratios, say $z_i = \ln(x_i/y_i)$, getting the limits of a $100(1-\alpha)$% confidence interval for
|
45,842
|
How to report the ratio of two sets of experimental results?
|
You ask a very interesting question. The key problem is, as you state, that the theoretical distribution of both $X$ and $Y$ is unknown. If it was known, however, it might be possible to derive the variance of the ratio and thus find a sample estimate of the standard error.
Suppose for a moment that both random variables follow a known distribution. As you noted, the normal distribution is a possibility, so that following the central limit theory the ratio is Cauchy distributed. I also think that response times to solve tasks are sometimes modelled by exponential distributions. Therefore, one could also assume the r.v. $X$ and $Y$ are exponentially distributed and their sum is hypoexponential.
More generally, the ratio of $sum(X)$ and $sum(Y)$ is ratio distributed. It is a known problem with ratio distributions, unfortunately, that they often do neither have an existing expectation (mean) nor variance. Therefore the s.e. of the mean often does not exist. This is also the case for the Cauchy distribution and the ratio of two exponential variables, as it is for other ratio distributions.
Fortunately, there are also ratios of distributions that have well-defined means and variances. In the following, I will assume the population mean of the ratio exists and construct an example based on this assumption.
In this case, you still do not know the distribution of your r.v. in practice. One option to get to the s.e. of the mean then is by non-parametric bootstrap, which I will demonstrate by example.
Suppose $X$ and $Y$ follow a scaled chi-square distribution with 1 and 5 degrees of freedom respectively. Then the ratio $sum(X)/sum(Y)$ is F-distributed with 1*n and 5*n degrees of freedom, where n is the number of summed r.v.. In practice n is the sample size.
n=10^3
df1=1
df2=5
X<-rchisq(n,df=df1)/(df1) #Scaled Chi-square distribution with df=df1
Y<-rchisq(n,df=df2)/(df2) #Scaled Chi-square distribution with df=df2
ratio<-sum(X)/sum(Y) # F-distributed with df1*n and df2*n degrees of freedom
You may verify that the mean of the F-distribution is known.
ratio #sample mean of ratio
df2*n/(df2*n-2) #theoretical mean of ratio (mean of F-distribution with df1 and df2)
Now suppose we have a small $n=10$ sized sample from the same distribution.
n=10
df1=1
df2=5
X<-rchisq(n,df=df1)/(df1) #Scaled Chi-square distribution with df=df1
Y<-rchisq(n,df=df2)/(df2) #Scaled Chi-square distribution with df=df2
ratio_sample<-sum(X)/sum(Y) # F-distributed
df2*n/(df2*n-2) #theoretical mean of ratio (mean of F-distribution with df1 and df2)
The bootstrap procedure samples with replacement from the data. I will draw 10,000 samples of size 10, respectively. I estimate the mean ratio, variance and s.d. of the bootstrapped distribution. The latter provides the s.e..
boot=10^4
data<-data.frame(X,Y)
bootsamples<-numeric()
for(i in 1:boot){
temp <- data[sample(n,n,replace=T),]
bootsamples[i]<-sum(temp$X)/sum(temp$Y)
}
ratio_var<-var(bootsamples)
ratio_se<-sqrt(ratio_var)
ratio_mean<-mean(bootsamples)
To summarize the results we can consider the classical confidence interval based on normal theory, but this is not immediately advisable due to the small sample size.
c(ratio_mean-1.965*ratio_se,ratio_mean+1.965*ratio_se) #Classical 95% CI based on asymptotics
Alternatively you may consider the 2.5 and 97.5 percentile of the bootstrapped distribution of ratios.
quantile(bootsamples,probs=c(.025,.975)) #Bootstrapped 95% CI
You may verify again that the bootstrapped confidence interval covers the true mean.
df2*n/(df2*n-2) #True mean
Again, I should stress that the bootstrap will only work, if the expectation of the ratio and its variance exist, which is not certain for ratios. In that case the s.e. of your ratio $avg$ would not exist either and the problem could not be solved.
|
How to report the ratio of two sets of experimental results?
|
You ask a very interesting question. The key problem is, as you state, that the theoretical distribution of both $X$ and $Y$ is unknown. If it was known, however, it might be possible to derive the va
|
How to report the ratio of two sets of experimental results?
You ask a very interesting question. The key problem is, as you state, that the theoretical distribution of both $X$ and $Y$ is unknown. If it was known, however, it might be possible to derive the variance of the ratio and thus find a sample estimate of the standard error.
Suppose for a moment that both random variables follow a known distribution. As you noted, the normal distribution is a possibility, so that following the central limit theory the ratio is Cauchy distributed. I also think that response times to solve tasks are sometimes modelled by exponential distributions. Therefore, one could also assume the r.v. $X$ and $Y$ are exponentially distributed and their sum is hypoexponential.
More generally, the ratio of $sum(X)$ and $sum(Y)$ is ratio distributed. It is a known problem with ratio distributions, unfortunately, that they often do neither have an existing expectation (mean) nor variance. Therefore the s.e. of the mean often does not exist. This is also the case for the Cauchy distribution and the ratio of two exponential variables, as it is for other ratio distributions.
Fortunately, there are also ratios of distributions that have well-defined means and variances. In the following, I will assume the population mean of the ratio exists and construct an example based on this assumption.
In this case, you still do not know the distribution of your r.v. in practice. One option to get to the s.e. of the mean then is by non-parametric bootstrap, which I will demonstrate by example.
Suppose $X$ and $Y$ follow a scaled chi-square distribution with 1 and 5 degrees of freedom respectively. Then the ratio $sum(X)/sum(Y)$ is F-distributed with 1*n and 5*n degrees of freedom, where n is the number of summed r.v.. In practice n is the sample size.
n=10^3
df1=1
df2=5
X<-rchisq(n,df=df1)/(df1) #Scaled Chi-square distribution with df=df1
Y<-rchisq(n,df=df2)/(df2) #Scaled Chi-square distribution with df=df2
ratio<-sum(X)/sum(Y) # F-distributed with df1*n and df2*n degrees of freedom
You may verify that the mean of the F-distribution is known.
ratio #sample mean of ratio
df2*n/(df2*n-2) #theoretical mean of ratio (mean of F-distribution with df1 and df2)
Now suppose we have a small $n=10$ sized sample from the same distribution.
n=10
df1=1
df2=5
X<-rchisq(n,df=df1)/(df1) #Scaled Chi-square distribution with df=df1
Y<-rchisq(n,df=df2)/(df2) #Scaled Chi-square distribution with df=df2
ratio_sample<-sum(X)/sum(Y) # F-distributed
df2*n/(df2*n-2) #theoretical mean of ratio (mean of F-distribution with df1 and df2)
The bootstrap procedure samples with replacement from the data. I will draw 10,000 samples of size 10, respectively. I estimate the mean ratio, variance and s.d. of the bootstrapped distribution. The latter provides the s.e..
boot=10^4
data<-data.frame(X,Y)
bootsamples<-numeric()
for(i in 1:boot){
temp <- data[sample(n,n,replace=T),]
bootsamples[i]<-sum(temp$X)/sum(temp$Y)
}
ratio_var<-var(bootsamples)
ratio_se<-sqrt(ratio_var)
ratio_mean<-mean(bootsamples)
To summarize the results we can consider the classical confidence interval based on normal theory, but this is not immediately advisable due to the small sample size.
c(ratio_mean-1.965*ratio_se,ratio_mean+1.965*ratio_se) #Classical 95% CI based on asymptotics
Alternatively you may consider the 2.5 and 97.5 percentile of the bootstrapped distribution of ratios.
quantile(bootsamples,probs=c(.025,.975)) #Bootstrapped 95% CI
You may verify again that the bootstrapped confidence interval covers the true mean.
df2*n/(df2*n-2) #True mean
Again, I should stress that the bootstrap will only work, if the expectation of the ratio and its variance exist, which is not certain for ratios. In that case the s.e. of your ratio $avg$ would not exist either and the problem could not be solved.
|
How to report the ratio of two sets of experimental results?
You ask a very interesting question. The key problem is, as you state, that the theoretical distribution of both $X$ and $Y$ is unknown. If it was known, however, it might be possible to derive the va
|
45,843
|
How to report the ratio of two sets of experimental results?
|
Why doesn't the Taylor expansion look right?
If you want a symmetric statistic, you can try look at the difference instead $\bar{x}-\bar{y}$, it is easy enough to work out the variance of $\bar{x}-\bar{y}$ with any distribution (not just normal) for $X, Y$, provided the variance exist (uniform??). This difference should be symmetric around 0. And you can use t-test to do the test.
Back to the ratio, if you really want to stick to the ratio, you can use the permutation test to work out the interval estimate. In R, it would look something like:
N=10
x=runif(N,1,3) # your data x
y=runif(N,10,30) # your data y
ratio=mean(x)/mean(y)
NP=100
stat=rep(NA,NP)
for(i in 1:NP){
id<-sample.int(2*N,size=N,replace=F)
stat[i]=mean(c(x,y)[id])/mean(c(x,y)[-id])
}
CI=quantile(stat,c(0.025,0.975))
print(CI);print(ratio)
(ratio<CI[2])&(ratio>CI[1])
|
How to report the ratio of two sets of experimental results?
|
Why doesn't the Taylor expansion look right?
If you want a symmetric statistic, you can try look at the difference instead $\bar{x}-\bar{y}$, it is easy enough to work out the variance of $\bar{x}-\
|
How to report the ratio of two sets of experimental results?
Why doesn't the Taylor expansion look right?
If you want a symmetric statistic, you can try look at the difference instead $\bar{x}-\bar{y}$, it is easy enough to work out the variance of $\bar{x}-\bar{y}$ with any distribution (not just normal) for $X, Y$, provided the variance exist (uniform??). This difference should be symmetric around 0. And you can use t-test to do the test.
Back to the ratio, if you really want to stick to the ratio, you can use the permutation test to work out the interval estimate. In R, it would look something like:
N=10
x=runif(N,1,3) # your data x
y=runif(N,10,30) # your data y
ratio=mean(x)/mean(y)
NP=100
stat=rep(NA,NP)
for(i in 1:NP){
id<-sample.int(2*N,size=N,replace=F)
stat[i]=mean(c(x,y)[id])/mean(c(x,y)[-id])
}
CI=quantile(stat,c(0.025,0.975))
print(CI);print(ratio)
(ratio<CI[2])&(ratio>CI[1])
|
How to report the ratio of two sets of experimental results?
Why doesn't the Taylor expansion look right?
If you want a symmetric statistic, you can try look at the difference instead $\bar{x}-\bar{y}$, it is easy enough to work out the variance of $\bar{x}-\
|
45,844
|
How to report the ratio of two sets of experimental results?
|
Given that you have so few data points, it hardly makes sense to use all those statistical assumptions.. why not just report the standard statistics: mean x_i/y_i, median x_i/y_i, percentile etc.
|
How to report the ratio of two sets of experimental results?
|
Given that you have so few data points, it hardly makes sense to use all those statistical assumptions.. why not just report the standard statistics: mean x_i/y_i, median x_i/y_i, percentile etc.
|
How to report the ratio of two sets of experimental results?
Given that you have so few data points, it hardly makes sense to use all those statistical assumptions.. why not just report the standard statistics: mean x_i/y_i, median x_i/y_i, percentile etc.
|
How to report the ratio of two sets of experimental results?
Given that you have so few data points, it hardly makes sense to use all those statistical assumptions.. why not just report the standard statistics: mean x_i/y_i, median x_i/y_i, percentile etc.
|
45,845
|
Show that for a Geometric distribution, the probability generating function is given by $\frac{ps}{1-qs}$, $q=1-p$
|
It's normal you'd arrive at the wrong answer in this case. The problem is that your index is wrong. There are two definitions for the pdf of a geometric distribution. The one you use, where $E(X)=\frac{1}{p}$ is defined from 1 to infinity. At zero it is not defined. So, the generating function needs to take this into account, as well.
$$\pi(s)=E(S^X)=\sum^\infty_{i=1}q^{i-1}ps^i$$
$$= ps\sum^\infty_{i=1}(qs)^{i-1}=ps\sum^\infty_{i=0}(qs)^i$$
$$=\frac{ps}{1-qs}$$
If you use the alternative definition, where $P(Y=y)=q^ip$, then the pdf is defined at zero. In this case the generating function converges to $\frac{p}{1-qs}$.
As for what $s$ represents, as far as I know it represents nothing. Generating functions are derived functions that hold information in their coefficients. They are sometimes left as an infinite sum, sometimes they have a closed form expression. Take a look at the wikipedia article, which give some examples of how they can be used. Here and here.wiki article probability generating functions and wiki article generating functions
|
Show that for a Geometric distribution, the probability generating function is given by $\frac{ps}{1
|
It's normal you'd arrive at the wrong answer in this case. The problem is that your index is wrong. There are two definitions for the pdf of a geometric distribution. The one you use, where $E(X)=\fra
|
Show that for a Geometric distribution, the probability generating function is given by $\frac{ps}{1-qs}$, $q=1-p$
It's normal you'd arrive at the wrong answer in this case. The problem is that your index is wrong. There are two definitions for the pdf of a geometric distribution. The one you use, where $E(X)=\frac{1}{p}$ is defined from 1 to infinity. At zero it is not defined. So, the generating function needs to take this into account, as well.
$$\pi(s)=E(S^X)=\sum^\infty_{i=1}q^{i-1}ps^i$$
$$= ps\sum^\infty_{i=1}(qs)^{i-1}=ps\sum^\infty_{i=0}(qs)^i$$
$$=\frac{ps}{1-qs}$$
If you use the alternative definition, where $P(Y=y)=q^ip$, then the pdf is defined at zero. In this case the generating function converges to $\frac{p}{1-qs}$.
As for what $s$ represents, as far as I know it represents nothing. Generating functions are derived functions that hold information in their coefficients. They are sometimes left as an infinite sum, sometimes they have a closed form expression. Take a look at the wikipedia article, which give some examples of how they can be used. Here and here.wiki article probability generating functions and wiki article generating functions
|
Show that for a Geometric distribution, the probability generating function is given by $\frac{ps}{1
It's normal you'd arrive at the wrong answer in this case. The problem is that your index is wrong. There are two definitions for the pdf of a geometric distribution. The one you use, where $E(X)=\fra
|
45,846
|
Why does my proof for showing that the Kaplan-Meier estimate is unbiased not work?
|
The flaw in your argument is that $\hat\Lambda(t)-\Lambda(t)$ is not a martingale for all times $t$. It is only a martingale up to the time $T$ when the experiment ends, that is, when the last survivor either dies or becomes censored (i.e. drops out of the study). After that, $\Lambda(t)$ continues to increase but $\hat\Lambda(t)$ does not.
Now, if the last survivor in the sample actually dies, then at this point it doesn't matter that $\hat\Lambda(t)-\Lambda(t)$ stops being a martingale, because $\hat S(t)=0$ and therefore $\hat S(t)/S(t)$ will continue to be a martingale. So without censored data, the K-M estimator is in fact unbiased (it is pretty easy to show this directly without stochastic processes).
However, if censoring exists, this raises the possibility that the last remaining survivor will become censored rather than die. In this case $\hat S(t)$ will never drop to zero, and so $\hat S(t)/S(t)$ will cease to be a martingale at time $T$. This possibility -- that the last survivor becomes censored -- is the source of bias in the K-M estimator.
|
Why does my proof for showing that the Kaplan-Meier estimate is unbiased not work?
|
The flaw in your argument is that $\hat\Lambda(t)-\Lambda(t)$ is not a martingale for all times $t$. It is only a martingale up to the time $T$ when the experiment ends, that is, when the last surviv
|
Why does my proof for showing that the Kaplan-Meier estimate is unbiased not work?
The flaw in your argument is that $\hat\Lambda(t)-\Lambda(t)$ is not a martingale for all times $t$. It is only a martingale up to the time $T$ when the experiment ends, that is, when the last survivor either dies or becomes censored (i.e. drops out of the study). After that, $\Lambda(t)$ continues to increase but $\hat\Lambda(t)$ does not.
Now, if the last survivor in the sample actually dies, then at this point it doesn't matter that $\hat\Lambda(t)-\Lambda(t)$ stops being a martingale, because $\hat S(t)=0$ and therefore $\hat S(t)/S(t)$ will continue to be a martingale. So without censored data, the K-M estimator is in fact unbiased (it is pretty easy to show this directly without stochastic processes).
However, if censoring exists, this raises the possibility that the last remaining survivor will become censored rather than die. In this case $\hat S(t)$ will never drop to zero, and so $\hat S(t)/S(t)$ will cease to be a martingale at time $T$. This possibility -- that the last survivor becomes censored -- is the source of bias in the K-M estimator.
|
Why does my proof for showing that the Kaplan-Meier estimate is unbiased not work?
The flaw in your argument is that $\hat\Lambda(t)-\Lambda(t)$ is not a martingale for all times $t$. It is only a martingale up to the time $T$ when the experiment ends, that is, when the last surviv
|
45,847
|
What do p-values for levels of a categorical variable represent in Poisson regression?
|
The model coefficients are estimated contrasts based on how the data frame generates contrasts in the factor levels for density. Take a look at this:
fit <- glm(events ~ as.factor(density), df, family = poisson)
model.matrix(fit)
To see how these contrasts are estimated, store the GLM as an object in the workspace. The intercept in this case is now the average log rate when density is equal to 1 (which is the log of 1, i.e. close to 0). Each of the parameters, such as the first, which is labeled as.factor(density)2 is the log relative rate comparing events when density is equal to 2 versus density equal to 1.
Each of these model parameters has a known limiting asymptotic distribution due to the central limit theorem. The theory on this is well understood, but a bit advanced. Consult McCullagh & Nelder, "Generalized Linear Models" for a statement of the result. Basically, as with linear regression, the natural parameters in the generalized linear models converge to a normal distribution under replications of the study. Thus, we can calculate the limiting distribution under the null hypothesis and calculate the probability of observing model coefficients as inconsistent or more inconsistent than what was experimentally obtained. This is very similar to the usual interpretation of a $p$-value as obtained from OLS model parameters, or simple Pearson tests of contingency tables, or the t-test.
Note that, had you removed the as.factor coding of density, you would have estimated an averaged log relative rate comparing values of density differing by 1 unit, and the intercept would have been the interpolated to be the log event rate when density=0, which may or may not be a useless quantity. The log relative rates in the data you generated are not constant, so the model effects would represent an "averaged effect".
For instance:
## the actual relative rates comparing subsequent density values
relRates <- exp(diff(log(1:5))
modelFit <- glm(events ~ density, data=df, family=poisson)
## model based relative rate, weighted by random data
exp(coef(modelFit))[2]
## the approximate average log relative rate, converted to relative rate
exp(mean(log(relRates))
|
What do p-values for levels of a categorical variable represent in Poisson regression?
|
The model coefficients are estimated contrasts based on how the data frame generates contrasts in the factor levels for density. Take a look at this:
fit <- glm(events ~ as.factor(density), df, family
|
What do p-values for levels of a categorical variable represent in Poisson regression?
The model coefficients are estimated contrasts based on how the data frame generates contrasts in the factor levels for density. Take a look at this:
fit <- glm(events ~ as.factor(density), df, family = poisson)
model.matrix(fit)
To see how these contrasts are estimated, store the GLM as an object in the workspace. The intercept in this case is now the average log rate when density is equal to 1 (which is the log of 1, i.e. close to 0). Each of the parameters, such as the first, which is labeled as.factor(density)2 is the log relative rate comparing events when density is equal to 2 versus density equal to 1.
Each of these model parameters has a known limiting asymptotic distribution due to the central limit theorem. The theory on this is well understood, but a bit advanced. Consult McCullagh & Nelder, "Generalized Linear Models" for a statement of the result. Basically, as with linear regression, the natural parameters in the generalized linear models converge to a normal distribution under replications of the study. Thus, we can calculate the limiting distribution under the null hypothesis and calculate the probability of observing model coefficients as inconsistent or more inconsistent than what was experimentally obtained. This is very similar to the usual interpretation of a $p$-value as obtained from OLS model parameters, or simple Pearson tests of contingency tables, or the t-test.
Note that, had you removed the as.factor coding of density, you would have estimated an averaged log relative rate comparing values of density differing by 1 unit, and the intercept would have been the interpolated to be the log event rate when density=0, which may or may not be a useless quantity. The log relative rates in the data you generated are not constant, so the model effects would represent an "averaged effect".
For instance:
## the actual relative rates comparing subsequent density values
relRates <- exp(diff(log(1:5))
modelFit <- glm(events ~ density, data=df, family=poisson)
## model based relative rate, weighted by random data
exp(coef(modelFit))[2]
## the approximate average log relative rate, converted to relative rate
exp(mean(log(relRates))
|
What do p-values for levels of a categorical variable represent in Poisson regression?
The model coefficients are estimated contrasts based on how the data frame generates contrasts in the factor levels for density. Take a look at this:
fit <- glm(events ~ as.factor(density), df, family
|
45,848
|
What do p-values for levels of a categorical variable represent in Poisson regression?
|
R, by default, uses reference cell coding (which I explain here: regression-based-for-example-on-days-of-week). Note that, this is called using "treatment contrasts" in R. (Many types of coding schemes are described at UCLA's stats help site.)
As @COOLSerdash states, the p-values for your indicated factor levels are testing the null hypothesis that their intercepts are equivalent to the intercept of the reference category. The intercept for your reference level is simply called (Intercept) in the output. The null hypothesis tested there is that the data come from a population where the true value is $0$. (I am referring to "intercepts" here, whereas you are referring to "means", but remember that if you don't have a continuous variable, i.e. you only have y~1, the intercept = the mean.)
Let's take a quick look at the Poisson model:
$$
\ln(E(Y)) = \ln(\lambda) = \beta_0 + \beta_1X \\
$$
$$
\lambda = \exp(\beta_0 + \beta_1X) \\
$$
Since you have no $X$, it's just $\ln(\lambda) = \beta_0$. If $\beta_0 = 0$, then $\lambda = \exp(0) = 1$. Hence that is what is being tested for the reference category.
We can also look at this in R:
> set.seed(1234)
> y = rpois(10000, 1)
> summary(glm(y~1, family="poisson"))
...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.0009995 0.0099950 0.1 0.92
...
> exp(0.0009995)
[1] 1.001
> mean(y)
[1] 1.001
> y2 = rpois(1000, 2)
> summary(glm(y2~1, family="poisson"))
...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.72900 0.02196 33.19 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
...
> exp(0.72900)
[1] 2.073007
> mean(y2)
[1] 2.073
|
What do p-values for levels of a categorical variable represent in Poisson regression?
|
R, by default, uses reference cell coding (which I explain here: regression-based-for-example-on-days-of-week). Note that, this is called using "treatment contrasts" in R. (Many types of coding schem
|
What do p-values for levels of a categorical variable represent in Poisson regression?
R, by default, uses reference cell coding (which I explain here: regression-based-for-example-on-days-of-week). Note that, this is called using "treatment contrasts" in R. (Many types of coding schemes are described at UCLA's stats help site.)
As @COOLSerdash states, the p-values for your indicated factor levels are testing the null hypothesis that their intercepts are equivalent to the intercept of the reference category. The intercept for your reference level is simply called (Intercept) in the output. The null hypothesis tested there is that the data come from a population where the true value is $0$. (I am referring to "intercepts" here, whereas you are referring to "means", but remember that if you don't have a continuous variable, i.e. you only have y~1, the intercept = the mean.)
Let's take a quick look at the Poisson model:
$$
\ln(E(Y)) = \ln(\lambda) = \beta_0 + \beta_1X \\
$$
$$
\lambda = \exp(\beta_0 + \beta_1X) \\
$$
Since you have no $X$, it's just $\ln(\lambda) = \beta_0$. If $\beta_0 = 0$, then $\lambda = \exp(0) = 1$. Hence that is what is being tested for the reference category.
We can also look at this in R:
> set.seed(1234)
> y = rpois(10000, 1)
> summary(glm(y~1, family="poisson"))
...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.0009995 0.0099950 0.1 0.92
...
> exp(0.0009995)
[1] 1.001
> mean(y)
[1] 1.001
> y2 = rpois(1000, 2)
> summary(glm(y2~1, family="poisson"))
...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.72900 0.02196 33.19 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
...
> exp(0.72900)
[1] 2.073007
> mean(y2)
[1] 2.073
|
What do p-values for levels of a categorical variable represent in Poisson regression?
R, by default, uses reference cell coding (which I explain here: regression-based-for-example-on-days-of-week). Note that, this is called using "treatment contrasts" in R. (Many types of coding schem
|
45,849
|
How to interpret and compare models in Cox regression?
|
Disclaimer: As in the comments, these are not ways to ensure best prediction, but rather the musings of an epidemiologist on model building for survival models trying to elucidate the relationship between an outcome O and an exposure E with a number of covariates:
The goal of these is not actually to make the best predictive model, or the strongest association, but rather to come up with a model that contains all the variables necessary to have an unbiased estimate of the effect of E on O (given no residual confounding - i.e. we didn't forget/overlook/have no idea a particular thing is important), without including anything else.
Because your models aren't "nested", i.e. you're not comparing "A, B and C" versus "A and B" versus "Just A", you really can't use a direct comparison of the log likelihoods, including the likelihood ratio test.
Making your modeling decisions based on p-values is also fairly perilous - a huge amount of discussion could be made about this, but I'd suggest as starting literature checking out a copy of Modern Epidemiology 3rd Edition, or browsing some of the works of Sander Greenland, or perhaps Charles Poole. That should put you off p-value model selection fairly quickly :)
If you're just looking for the "best fitting" version of non-nested Cox models, you could use something like Akaike information criterion (AIC) which Stata should report, or the Bayesian information criterion (BIC). These give you a decent picture of the relative strength of each model fit - you're looking for the model with the lowest AIC or BIC. These give you a picture of the predictive power of the model compared to the amount of variables in it, trying to give a balance between model parsimony and fit. I tend to use this if what I'm trying to decide on is the form of a variable to include (i.e. should I use A, or also include a term for A^2?). But not so much in the "Which variables do I include" stage.
The way I decide on variables is using a mix of these:
I build what I believe is a working causal model of the relationship using a Directed Acyclic Graph (DAG) to show all the relationships between E, O and my variables of interest. There are many introductions on how to do this, and some would argue that once you have done a DAG and found the variables you need to control for (see said online tutorials) you're done. My confidence in this varies based on whether or not I'm working in a known, well-studied area, or am paving new territory.
If I don't want to be finished there, or I'm not sure about some of my choices, I might use a change-in-estimate approach, including variables that change my estimate of the association between E and O by more than 10% or something of that nature. This lets you keep the variables that have an impact on your estimate, but get rid of those that don't, even if they might theoretically have been important because of your DAG.
Finally, sometimes I do just use a p-value cutoff, but I tend to make this extremely generous - I'm not looking to only include variables with small p-values, but any variable that even faintly shows that it might have importance, so my cutoff is something like p < 0.25.
I'd again recommend a copy of Modern Epidemiology 3rd Edition, they've got a very good treatment of model selection.
|
How to interpret and compare models in Cox regression?
|
Disclaimer: As in the comments, these are not ways to ensure best prediction, but rather the musings of an epidemiologist on model building for survival models trying to elucidate the relationship bet
|
How to interpret and compare models in Cox regression?
Disclaimer: As in the comments, these are not ways to ensure best prediction, but rather the musings of an epidemiologist on model building for survival models trying to elucidate the relationship between an outcome O and an exposure E with a number of covariates:
The goal of these is not actually to make the best predictive model, or the strongest association, but rather to come up with a model that contains all the variables necessary to have an unbiased estimate of the effect of E on O (given no residual confounding - i.e. we didn't forget/overlook/have no idea a particular thing is important), without including anything else.
Because your models aren't "nested", i.e. you're not comparing "A, B and C" versus "A and B" versus "Just A", you really can't use a direct comparison of the log likelihoods, including the likelihood ratio test.
Making your modeling decisions based on p-values is also fairly perilous - a huge amount of discussion could be made about this, but I'd suggest as starting literature checking out a copy of Modern Epidemiology 3rd Edition, or browsing some of the works of Sander Greenland, or perhaps Charles Poole. That should put you off p-value model selection fairly quickly :)
If you're just looking for the "best fitting" version of non-nested Cox models, you could use something like Akaike information criterion (AIC) which Stata should report, or the Bayesian information criterion (BIC). These give you a decent picture of the relative strength of each model fit - you're looking for the model with the lowest AIC or BIC. These give you a picture of the predictive power of the model compared to the amount of variables in it, trying to give a balance between model parsimony and fit. I tend to use this if what I'm trying to decide on is the form of a variable to include (i.e. should I use A, or also include a term for A^2?). But not so much in the "Which variables do I include" stage.
The way I decide on variables is using a mix of these:
I build what I believe is a working causal model of the relationship using a Directed Acyclic Graph (DAG) to show all the relationships between E, O and my variables of interest. There are many introductions on how to do this, and some would argue that once you have done a DAG and found the variables you need to control for (see said online tutorials) you're done. My confidence in this varies based on whether or not I'm working in a known, well-studied area, or am paving new territory.
If I don't want to be finished there, or I'm not sure about some of my choices, I might use a change-in-estimate approach, including variables that change my estimate of the association between E and O by more than 10% or something of that nature. This lets you keep the variables that have an impact on your estimate, but get rid of those that don't, even if they might theoretically have been important because of your DAG.
Finally, sometimes I do just use a p-value cutoff, but I tend to make this extremely generous - I'm not looking to only include variables with small p-values, but any variable that even faintly shows that it might have importance, so my cutoff is something like p < 0.25.
I'd again recommend a copy of Modern Epidemiology 3rd Edition, they've got a very good treatment of model selection.
|
How to interpret and compare models in Cox regression?
Disclaimer: As in the comments, these are not ways to ensure best prediction, but rather the musings of an epidemiologist on model building for survival models trying to elucidate the relationship bet
|
45,850
|
What distribution to use for this QQ plot?
|
I'll turn my comments into an answer; I can delete this or add more if necessary.
Based on your original qq-plot, it appears to me that the tails of your distribution may be too short--at least relative to the normal distribution. (This is based on my interpretation that the data values are on the Y axis "Ordered Values" and the theoretical quantiles are on the X axis.) As a result of this, the evident symmetry, and the slight bowing in the middle, I wondered if it might be a uniform distribution or something similar. I discussed the interpretation of qq-plots here: qq-plot does not match histogram.
Edit 2 noted that the kurtosis was given as $-1$. I like this resource for thinking about kurtosis, which notes that kurtosis cannot be lower than $1$, thus SciPy has given you excess kurtosis (which is kurtosis - 3). The Wikipedia page for kurtosis lists the kurtosis for the uniform distribution as $-1$, which is consistent with my guess about the qq-plot.
Edit 3 posts a qq-plot against the uniform, which fits rather well, but the tails now seem slightly too heavy. It's worth noting that the uniform distribution is actually a special case of the beta distribution where the parameters are $(1,1)$. Thus, it's possible you have a beta that is very close to (1,1), but not actually quite (1,1) (ie, not quite uniform). Something like $(.9, .9)$, might serve as an initial guess. Of course, the validity of this hunch depends on how much data you have as to whether that slight divergence is reliable. You can read more about the beta distribution in this excellent thread: what-is-intuition-behind-beta-distribution.
|
What distribution to use for this QQ plot?
|
I'll turn my comments into an answer; I can delete this or add more if necessary.
Based on your original qq-plot, it appears to me that the tails of your distribution may be too short--at least relat
|
What distribution to use for this QQ plot?
I'll turn my comments into an answer; I can delete this or add more if necessary.
Based on your original qq-plot, it appears to me that the tails of your distribution may be too short--at least relative to the normal distribution. (This is based on my interpretation that the data values are on the Y axis "Ordered Values" and the theoretical quantiles are on the X axis.) As a result of this, the evident symmetry, and the slight bowing in the middle, I wondered if it might be a uniform distribution or something similar. I discussed the interpretation of qq-plots here: qq-plot does not match histogram.
Edit 2 noted that the kurtosis was given as $-1$. I like this resource for thinking about kurtosis, which notes that kurtosis cannot be lower than $1$, thus SciPy has given you excess kurtosis (which is kurtosis - 3). The Wikipedia page for kurtosis lists the kurtosis for the uniform distribution as $-1$, which is consistent with my guess about the qq-plot.
Edit 3 posts a qq-plot against the uniform, which fits rather well, but the tails now seem slightly too heavy. It's worth noting that the uniform distribution is actually a special case of the beta distribution where the parameters are $(1,1)$. Thus, it's possible you have a beta that is very close to (1,1), but not actually quite (1,1) (ie, not quite uniform). Something like $(.9, .9)$, might serve as an initial guess. Of course, the validity of this hunch depends on how much data you have as to whether that slight divergence is reliable. You can read more about the beta distribution in this excellent thread: what-is-intuition-behind-beta-distribution.
|
What distribution to use for this QQ plot?
I'll turn my comments into an answer; I can delete this or add more if necessary.
Based on your original qq-plot, it appears to me that the tails of your distribution may be too short--at least relat
|
45,851
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
|
In simple terms, imagine you fix one parameter, say the intercept, and estimate the slope. The question is: as you vary the fixed parameter, will your slope estimate change? It will to some degree, and the strength/direction of the effect is the correlation of the parameters.
Suppose you have a simple linear regression with a positive slope in the first quadrant (x and y are positive). If you begin to move the intercept up the y axis, then your slope will have to correspondingly decrease in order to pass through the data. In this case, the intercept and slope are negatively correlated. In any particular setting, the strength of the correlation will depend on the nature of the data (location, spread, etc.)
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
|
In simple terms, imagine you fix one parameter, say the intercept, and estimate the slope. The question is: as you vary the fixed parameter, will your slope estimate change? It will to some degree, an
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
In simple terms, imagine you fix one parameter, say the intercept, and estimate the slope. The question is: as you vary the fixed parameter, will your slope estimate change? It will to some degree, and the strength/direction of the effect is the correlation of the parameters.
Suppose you have a simple linear regression with a positive slope in the first quadrant (x and y are positive). If you begin to move the intercept up the y axis, then your slope will have to correspondingly decrease in order to pass through the data. In this case, the intercept and slope are negatively correlated. In any particular setting, the strength of the correlation will depend on the nature of the data (location, spread, etc.)
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
In simple terms, imagine you fix one parameter, say the intercept, and estimate the slope. The question is: as you vary the fixed parameter, will your slope estimate change? It will to some degree, an
|
45,852
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
|
Just in case, the correlation refers to the estimated parameters, and springs from the fact that they are derived using the same data. It does not imply a correlation between the unknown parameters being estimated, which being constants (in the frequentist approach), cannot have "correlation". In that sense, it does not have an "intuitive" explanation because it is a consequence of the estimation procedure itself, and does not reflect some aspect of the real-world phenomenon under study.
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
|
Just in case, the correlation refers to the estimated parameters, and springs from the fact that they are derived using the same data. It does not imply a correlation between the unknown parameters be
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
Just in case, the correlation refers to the estimated parameters, and springs from the fact that they are derived using the same data. It does not imply a correlation between the unknown parameters being estimated, which being constants (in the frequentist approach), cannot have "correlation". In that sense, it does not have an "intuitive" explanation because it is a consequence of the estimation procedure itself, and does not reflect some aspect of the real-world phenomenon under study.
|
How to interpret parameter estimates correlated with the intercept parameter estimate?
Just in case, the correlation refers to the estimated parameters, and springs from the fact that they are derived using the same data. It does not imply a correlation between the unknown parameters be
|
45,853
|
Difference between fixed effects models in R (plm) and Stata (xtreg)
|
Welcome to the site, @gwatson! You are right that effect = "twoways" sets up both "individual" and "year" effects.
I tested with Produc data from R package plm and found the main results are the same (see the codes and outputs below). The only apparent difference I found is the year effect, which is caused by contrast (xtreg sets the first year as reference, while plm directly estimates the effect for each year).
## R code
data("Produc", package = "plm")
zz <- plm(gsp ~ unemp + lag(gsp), data = Produc, index = c("state","year"), method = "within", effect = "twoways")
summary(zz)
## plm output
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
unemp -5.4525e+02 6.8611e+01 -7.9469 7.614e-15 ***
lag(gsp) 1.0125e+00 9.1789e-03 110.3029 < 2.2e-16 ***
## Stata code
use Produc, clear
xtset state year, yearly
xtreg gsp unemp l.gsp i.year, fe
## xtreg output
------------------------------------------------------------------------------
gsp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
unemp | -545.246 68.61136 -7.95 0.000 -679.9537 -410.5383
gsp L1.| 1.012464 .0091789 110.30 0.000 .9944422 1.030485
-------------+----------------------------------------------------------------
|
Difference between fixed effects models in R (plm) and Stata (xtreg)
|
Welcome to the site, @gwatson! You are right that effect = "twoways" sets up both "individual" and "year" effects.
I tested with Produc data from R package plm and found the main results are the same
|
Difference between fixed effects models in R (plm) and Stata (xtreg)
Welcome to the site, @gwatson! You are right that effect = "twoways" sets up both "individual" and "year" effects.
I tested with Produc data from R package plm and found the main results are the same (see the codes and outputs below). The only apparent difference I found is the year effect, which is caused by contrast (xtreg sets the first year as reference, while plm directly estimates the effect for each year).
## R code
data("Produc", package = "plm")
zz <- plm(gsp ~ unemp + lag(gsp), data = Produc, index = c("state","year"), method = "within", effect = "twoways")
summary(zz)
## plm output
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
unemp -5.4525e+02 6.8611e+01 -7.9469 7.614e-15 ***
lag(gsp) 1.0125e+00 9.1789e-03 110.3029 < 2.2e-16 ***
## Stata code
use Produc, clear
xtset state year, yearly
xtreg gsp unemp l.gsp i.year, fe
## xtreg output
------------------------------------------------------------------------------
gsp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
unemp | -545.246 68.61136 -7.95 0.000 -679.9537 -410.5383
gsp L1.| 1.012464 .0091789 110.30 0.000 .9944422 1.030485
-------------+----------------------------------------------------------------
|
Difference between fixed effects models in R (plm) and Stata (xtreg)
Welcome to the site, @gwatson! You are right that effect = "twoways" sets up both "individual" and "year" effects.
I tested with Produc data from R package plm and found the main results are the same
|
45,854
|
Why does my ROC curve look like this (is it correct?)
|
ROC curve 101
An ROC curve visualizes the predictive performance of a classifier for various levels of conservatism (measured by confidence scores). In simple terms, it illustrates the price you pay in terms of false positive rate to increase the true positive rate. The conservatism is controlled via thresholds on confidence scores to assign the positive and negative label.
The x-axis can be interpreted as a measure of liberalism of the classifier, depicting its false positive rate (1-specificity). The y-axis represents how well it is at detecting positives, depicting the classifier's true positive rate (sensitivity). A perfect classifier's ROC curve passes through $(0,1)$, meaning it can classify all positives correctly without a single false positive. This results in an area under the curve of exactly $1$.
Intuitively, a more conservative classifier (which labels less stuff as positive) has higher precision and lower sensitivity than a more liberal one. When the threshold for positive prediction decreases (e.g. the required positive confidence score decreases), both the false positive rate and sensitivity rise monotonically. This is why an ROC curve always increases monotonically.
Plotting an ROC curve
You need not compute the predictions for various thresholds as you say. Computing an ROC curve is done based on the ranking produced by your classifier (e.g. your logistic regression model).
Use the model to predict every single test point once. You'll get a vector of confidence scores, let's call it $\mathbf{\hat{Y}}$. Using this vector you can produce the full ROC curve (or atleast an estimate thereof). The distinct values in $\mathbf{\hat{Y}}$ are your thresholds. Since you use logistic regression, the confidence scores in $\mathbf{\hat{Y}}$ are probabilities, e.g. in $[0,1]$.
Now, simply iterate over the sorted values and adjust TP/TN/FP/FN as you go and you can compute the ROC curve point by point. The amount of points in your ROC curve is equal to the length of $\mathbf{\hat{Y}}$, assuming there are no ties in prediction.
To plot the final result, use a function that plots in zero order hold (ZOH), rather than linear interpolation between points, like MATLAB's stairs or R's staircase.plot. Also keep this in mind when computing the area under the curve (AUC). If you use linear interpolation instead of ZOH to compute AUC, you actually end up with the area under the convex hull (AUCH).
|
Why does my ROC curve look like this (is it correct?)
|
ROC curve 101
An ROC curve visualizes the predictive performance of a classifier for various levels of conservatism (measured by confidence scores). In simple terms, it illustrates the price you pay i
|
Why does my ROC curve look like this (is it correct?)
ROC curve 101
An ROC curve visualizes the predictive performance of a classifier for various levels of conservatism (measured by confidence scores). In simple terms, it illustrates the price you pay in terms of false positive rate to increase the true positive rate. The conservatism is controlled via thresholds on confidence scores to assign the positive and negative label.
The x-axis can be interpreted as a measure of liberalism of the classifier, depicting its false positive rate (1-specificity). The y-axis represents how well it is at detecting positives, depicting the classifier's true positive rate (sensitivity). A perfect classifier's ROC curve passes through $(0,1)$, meaning it can classify all positives correctly without a single false positive. This results in an area under the curve of exactly $1$.
Intuitively, a more conservative classifier (which labels less stuff as positive) has higher precision and lower sensitivity than a more liberal one. When the threshold for positive prediction decreases (e.g. the required positive confidence score decreases), both the false positive rate and sensitivity rise monotonically. This is why an ROC curve always increases monotonically.
Plotting an ROC curve
You need not compute the predictions for various thresholds as you say. Computing an ROC curve is done based on the ranking produced by your classifier (e.g. your logistic regression model).
Use the model to predict every single test point once. You'll get a vector of confidence scores, let's call it $\mathbf{\hat{Y}}$. Using this vector you can produce the full ROC curve (or atleast an estimate thereof). The distinct values in $\mathbf{\hat{Y}}$ are your thresholds. Since you use logistic regression, the confidence scores in $\mathbf{\hat{Y}}$ are probabilities, e.g. in $[0,1]$.
Now, simply iterate over the sorted values and adjust TP/TN/FP/FN as you go and you can compute the ROC curve point by point. The amount of points in your ROC curve is equal to the length of $\mathbf{\hat{Y}}$, assuming there are no ties in prediction.
To plot the final result, use a function that plots in zero order hold (ZOH), rather than linear interpolation between points, like MATLAB's stairs or R's staircase.plot. Also keep this in mind when computing the area under the curve (AUC). If you use linear interpolation instead of ZOH to compute AUC, you actually end up with the area under the convex hull (AUCH).
|
Why does my ROC curve look like this (is it correct?)
ROC curve 101
An ROC curve visualizes the predictive performance of a classifier for various levels of conservatism (measured by confidence scores). In simple terms, it illustrates the price you pay i
|
45,855
|
Covariates considered moderator or control variables?
|
A control variable (confounder, potential omitted variable) is a variable you include in the model because you suspect it is confounding the main relationship you are interested in (so it is suspected to be related to both the main independent variable (explanatory variable, predictor, treatment) of interest and to the dependent (outcome) variable.
A moderator is a variable which changes the effect of the main independent variable on the outcome variable, so it interacts with the main independent variable.
A mediating variable is a variable that translates fully or partially the effect of the main independent variable on the outcome.
A covariate is in my opinion unspecified and could refer to either of these.
A variable that is suspected to be related with the outcome variable but not with the main independent variable of interest is a covariate but not a control variable (as it does not control for anything).
A variable that is suspected to be related to the main independent variable of interest but not to the outcome would be an instrumental variable.
To come back to your concrete questions:
since you don't use them it matters little what you called them - alternative predictors (causal factors), unmodelled effects, etc are all options
definitely no controls or covariates, these are just sample selection criteria
see above
|
Covariates considered moderator or control variables?
|
A control variable (confounder, potential omitted variable) is a variable you include in the model because you suspect it is confounding the main relationship you are interested in (so it is suspected
|
Covariates considered moderator or control variables?
A control variable (confounder, potential omitted variable) is a variable you include in the model because you suspect it is confounding the main relationship you are interested in (so it is suspected to be related to both the main independent variable (explanatory variable, predictor, treatment) of interest and to the dependent (outcome) variable.
A moderator is a variable which changes the effect of the main independent variable on the outcome variable, so it interacts with the main independent variable.
A mediating variable is a variable that translates fully or partially the effect of the main independent variable on the outcome.
A covariate is in my opinion unspecified and could refer to either of these.
A variable that is suspected to be related with the outcome variable but not with the main independent variable of interest is a covariate but not a control variable (as it does not control for anything).
A variable that is suspected to be related to the main independent variable of interest but not to the outcome would be an instrumental variable.
To come back to your concrete questions:
since you don't use them it matters little what you called them - alternative predictors (causal factors), unmodelled effects, etc are all options
definitely no controls or covariates, these are just sample selection criteria
see above
|
Covariates considered moderator or control variables?
A control variable (confounder, potential omitted variable) is a variable you include in the model because you suspect it is confounding the main relationship you are interested in (so it is suspected
|
45,856
|
Derive percentiles from binned data
|
It is quite easy actually.
Let's say the sum of the counts is N, and you that you want the 0.3 (30%) bottom percentile. This means the threshold value will occur after 0.3*N counts.
Now you look at the cumulative distribution, and when it reaches 0.3*N, you have the value. It is very easy to implement.
For example, you had this:
Value No. of occurrences
1 2
2 4
3 2
4 3
So you convert it into the cumulative:
Value No. of occurrences
<=1 2
<=2 6
<=3 8
<=4 11
Here N=11 so 0.3*11=3.3. This happens in the second bin, so the 0.3 percentile is 2.
|
Derive percentiles from binned data
|
It is quite easy actually.
Let's say the sum of the counts is N, and you that you want the 0.3 (30%) bottom percentile. This means the threshold value will occur after 0.3*N counts.
Now you look at th
|
Derive percentiles from binned data
It is quite easy actually.
Let's say the sum of the counts is N, and you that you want the 0.3 (30%) bottom percentile. This means the threshold value will occur after 0.3*N counts.
Now you look at the cumulative distribution, and when it reaches 0.3*N, you have the value. It is very easy to implement.
For example, you had this:
Value No. of occurrences
1 2
2 4
3 2
4 3
So you convert it into the cumulative:
Value No. of occurrences
<=1 2
<=2 6
<=3 8
<=4 11
Here N=11 so 0.3*11=3.3. This happens in the second bin, so the 0.3 percentile is 2.
|
Derive percentiles from binned data
It is quite easy actually.
Let's say the sum of the counts is N, and you that you want the 0.3 (30%) bottom percentile. This means the threshold value will occur after 0.3*N counts.
Now you look at th
|
45,857
|
Derive percentiles from binned data
|
PercentileBinnedData is an implementation of the algorithm described above that I have developed, QuickSort will ensure that your binned data is sorted in increasing order
Function PercentileBinnedData(rng As Range, percentile As Double) As Double
Dim v As Variant
v = rng.Value
QuickSortArray v, , , 1 ' sort 2D array
Dim i As Long
Dim totalOccurences As Long
'Convert to cumalative distribution
For i = LBound(v, 1) To UBound(v, 1)
If i < UBound(v, 1) Then
v(i + 1, 2) = v(i + 1, 2) + v(i, 2)
End If
Next i
totalOccurences = v(UBound(v, 1), 2) ' number of occurences is equal to last number of occurences
Dim rank As Double: rank = percentile * totalOccurences
For i = LBound(v, 1) To UBound(v, 1)
If i = LBound(v, 1) And rank <= v(i, 2) Then
PercentileBinnedData = v(i, 1)
End If
If i > LBound(v, 1) Then
If rank > v(i - 1, 2) And rank <= v(i, 2) Then
PercentileBinnedData = v(i, 1)
End If
End If
Next i
End Function
Public Sub QuickSortArray(ByRef SortArray As Variant, Optional lngMin As Long = -1, Optional lngMax As Long = -1, Optional lngColumn As Long = 0)
On Error Resume Next
'Sort a 2-Dimensional array
' SampleUsage: sort arrData by the contents of column 3
'
' QuickSortArray arrData, , , 3
'
'Posted by Jim Rech 10/20/98 Excel.Programming
'Modifications, Nigel Heffernan:
' ' Escape failed comparison with empty variant
' ' Defensive coding: check inputs
Dim i As Long
Dim j As Long
Dim varMid As Variant
Dim arrRowTemp As Variant
Dim lngColTemp As Long
If IsEmpty(SortArray) Then
Exit Sub
End If
If InStr(TypeName(SortArray), "()") < 1 Then 'IsArray() is somewhat broken: Look for brackets in the type name
Exit Sub
End If
If lngMin = -1 Then
lngMin = LBound(SortArray, 1)
End If
If lngMax = -1 Then
lngMax = UBound(SortArray, 1)
End If
If lngMin >= lngMax Then ' no sorting required
Exit Sub
End If
i = lngMin
j = lngMax
varMid = Empty
varMid = SortArray((lngMin + lngMax) \ 2, lngColumn)
' We send 'Empty' and invalid data items to the end of the list:
If IsObject(varMid) Then ' note that we don't check isObject(SortArray(n)) - varMid *might* pick up a valid default member or property
i = lngMax
j = lngMin
ElseIf IsEmpty(varMid) Then
i = lngMax
j = lngMin
ElseIf IsNull(varMid) Then
i = lngMax
j = lngMin
ElseIf varMid = "" Then
i = lngMax
j = lngMin
ElseIf VarType(varMid) = vbError Then
i = lngMax
j = lngMin
ElseIf VarType(varMid) > 17 Then
i = lngMax
j = lngMin
End If
While i <= j
While SortArray(i, lngColumn) < varMid And i < lngMax
i = i + 1
Wend
While varMid < SortArray(j, lngColumn) And j > lngMin
j = j - 1
Wend
If i <= j Then
' Swap the rows
ReDim arrRowTemp(LBound(SortArray, 2) To UBound(SortArray, 2))
For lngColTemp = LBound(SortArray, 2) To UBound(SortArray, 2)
arrRowTemp(lngColTemp) = SortArray(i, lngColTemp)
SortArray(i, lngColTemp) = SortArray(j, lngColTemp)
SortArray(j, lngColTemp) = arrRowTemp(lngColTemp)
Next lngColTemp
Erase arrRowTemp
i = i + 1
j = j - 1
End If
Wend
If (lngMin < j) Then Call QuickSortArray(SortArray, lngMin, j, lngColumn)
If (i < lngMax) Then Call QuickSortArray(SortArray, i, lngMax, lngColumn)
End Sub
|
Derive percentiles from binned data
|
PercentileBinnedData is an implementation of the algorithm described above that I have developed, QuickSort will ensure that your binned data is sorted in increasing order
Function PercentileBinnedDat
|
Derive percentiles from binned data
PercentileBinnedData is an implementation of the algorithm described above that I have developed, QuickSort will ensure that your binned data is sorted in increasing order
Function PercentileBinnedData(rng As Range, percentile As Double) As Double
Dim v As Variant
v = rng.Value
QuickSortArray v, , , 1 ' sort 2D array
Dim i As Long
Dim totalOccurences As Long
'Convert to cumalative distribution
For i = LBound(v, 1) To UBound(v, 1)
If i < UBound(v, 1) Then
v(i + 1, 2) = v(i + 1, 2) + v(i, 2)
End If
Next i
totalOccurences = v(UBound(v, 1), 2) ' number of occurences is equal to last number of occurences
Dim rank As Double: rank = percentile * totalOccurences
For i = LBound(v, 1) To UBound(v, 1)
If i = LBound(v, 1) And rank <= v(i, 2) Then
PercentileBinnedData = v(i, 1)
End If
If i > LBound(v, 1) Then
If rank > v(i - 1, 2) And rank <= v(i, 2) Then
PercentileBinnedData = v(i, 1)
End If
End If
Next i
End Function
Public Sub QuickSortArray(ByRef SortArray As Variant, Optional lngMin As Long = -1, Optional lngMax As Long = -1, Optional lngColumn As Long = 0)
On Error Resume Next
'Sort a 2-Dimensional array
' SampleUsage: sort arrData by the contents of column 3
'
' QuickSortArray arrData, , , 3
'
'Posted by Jim Rech 10/20/98 Excel.Programming
'Modifications, Nigel Heffernan:
' ' Escape failed comparison with empty variant
' ' Defensive coding: check inputs
Dim i As Long
Dim j As Long
Dim varMid As Variant
Dim arrRowTemp As Variant
Dim lngColTemp As Long
If IsEmpty(SortArray) Then
Exit Sub
End If
If InStr(TypeName(SortArray), "()") < 1 Then 'IsArray() is somewhat broken: Look for brackets in the type name
Exit Sub
End If
If lngMin = -1 Then
lngMin = LBound(SortArray, 1)
End If
If lngMax = -1 Then
lngMax = UBound(SortArray, 1)
End If
If lngMin >= lngMax Then ' no sorting required
Exit Sub
End If
i = lngMin
j = lngMax
varMid = Empty
varMid = SortArray((lngMin + lngMax) \ 2, lngColumn)
' We send 'Empty' and invalid data items to the end of the list:
If IsObject(varMid) Then ' note that we don't check isObject(SortArray(n)) - varMid *might* pick up a valid default member or property
i = lngMax
j = lngMin
ElseIf IsEmpty(varMid) Then
i = lngMax
j = lngMin
ElseIf IsNull(varMid) Then
i = lngMax
j = lngMin
ElseIf varMid = "" Then
i = lngMax
j = lngMin
ElseIf VarType(varMid) = vbError Then
i = lngMax
j = lngMin
ElseIf VarType(varMid) > 17 Then
i = lngMax
j = lngMin
End If
While i <= j
While SortArray(i, lngColumn) < varMid And i < lngMax
i = i + 1
Wend
While varMid < SortArray(j, lngColumn) And j > lngMin
j = j - 1
Wend
If i <= j Then
' Swap the rows
ReDim arrRowTemp(LBound(SortArray, 2) To UBound(SortArray, 2))
For lngColTemp = LBound(SortArray, 2) To UBound(SortArray, 2)
arrRowTemp(lngColTemp) = SortArray(i, lngColTemp)
SortArray(i, lngColTemp) = SortArray(j, lngColTemp)
SortArray(j, lngColTemp) = arrRowTemp(lngColTemp)
Next lngColTemp
Erase arrRowTemp
i = i + 1
j = j - 1
End If
Wend
If (lngMin < j) Then Call QuickSortArray(SortArray, lngMin, j, lngColumn)
If (i < lngMax) Then Call QuickSortArray(SortArray, i, lngMax, lngColumn)
End Sub
|
Derive percentiles from binned data
PercentileBinnedData is an implementation of the algorithm described above that I have developed, QuickSort will ensure that your binned data is sorted in increasing order
Function PercentileBinnedDat
|
45,858
|
Using a gamm4 model to predict estimates in new data
|
I'm not sure what you want here.
Have you looked at ?predict.gam
# Load the gamm4 package
library(gamm4)
# Using gamm4's built-in data simulation capabilities to give us some data:
set.seed(100)
dat <- gamSim(6, n=100, scale=2)
# Fitting a model and plotting it:
mod <- gamm4(y~s(x0)+s(x1)+s(x2), data=dat, random = ~ (1|fac))
plot(mod$gam, pages=1)
# Generating some new data for which you'd like predictions:
newdat <- data.frame(x0 = runif(100), x1 = runif(100), x2 = runif(100))
# Getting predicted outcomes for new data
# These include the splines but ignore other REs
predictions = predict(mod$gam, newdata=newdat, se.fit = TRUE)
# Consolidating new data and predictions
newdat = cbind(newdat, predictions)
# If you want CIs
newdat <- within(newdat, {
lower = fit-1.96*se.fit
upper = fit+1.96*se.fit
})
# Plot, for example, the predicted outcomes as a function of x1...
library(ggplot2)
egplot <- ggplot(newdat, aes(x=x1, y=fit)) +
geom_smooth() + geom_point()
egplot
See here for some possible assistance
|
Using a gamm4 model to predict estimates in new data
|
I'm not sure what you want here.
Have you looked at ?predict.gam
# Load the gamm4 package
library(gamm4)
# Using gamm4's built-in data simulation capabilities to give us some data:
set.seed(100)
dat
|
Using a gamm4 model to predict estimates in new data
I'm not sure what you want here.
Have you looked at ?predict.gam
# Load the gamm4 package
library(gamm4)
# Using gamm4's built-in data simulation capabilities to give us some data:
set.seed(100)
dat <- gamSim(6, n=100, scale=2)
# Fitting a model and plotting it:
mod <- gamm4(y~s(x0)+s(x1)+s(x2), data=dat, random = ~ (1|fac))
plot(mod$gam, pages=1)
# Generating some new data for which you'd like predictions:
newdat <- data.frame(x0 = runif(100), x1 = runif(100), x2 = runif(100))
# Getting predicted outcomes for new data
# These include the splines but ignore other REs
predictions = predict(mod$gam, newdata=newdat, se.fit = TRUE)
# Consolidating new data and predictions
newdat = cbind(newdat, predictions)
# If you want CIs
newdat <- within(newdat, {
lower = fit-1.96*se.fit
upper = fit+1.96*se.fit
})
# Plot, for example, the predicted outcomes as a function of x1...
library(ggplot2)
egplot <- ggplot(newdat, aes(x=x1, y=fit)) +
geom_smooth() + geom_point()
egplot
See here for some possible assistance
|
Using a gamm4 model to predict estimates in new data
I'm not sure what you want here.
Have you looked at ?predict.gam
# Load the gamm4 package
library(gamm4)
# Using gamm4's built-in data simulation capabilities to give us some data:
set.seed(100)
dat
|
45,859
|
Is there any intuitive meaning to the quantity P(A|B)P(B|C)?
|
There are several good visual and physical metaphors to help the intuition. I offer one of each.
Conditional probabilities of the form $\Pr(A|C)$ can be represented on graphs where the events $C$ and $A$ are nodes, a directed edge connects $C$ to $A$, and the edge is weighted by this probability. This graphical metaphor, variously known as a "probability tree" or "hierarchical network," visualizes two axiomatic properties of probability.
Path probabilities are products of edge probabilities: $\Pr(A,B,C) = \left[\Pr(A|B)\Pr(B|C)\right]\Pr(C)$. The nodes $C,B,A$ form a path along this tree from $C$ to $A$. The left hand side is the chance of this path; the right hand side is the product of the chance of being at the beginning and the chance of following the path. That latter chance, the "path probability" (written in brackets), is the product of the conditional probabilities.
Total probabilities are sums over all possible disjoint paths: $\Pr(A) = \Pr(A|B_1)\Pr(B_1) + \Pr(A|B_2)\Pr(B_2) + \cdots + \Pr(A|B_n)\Pr(B_n)$ where $B_1, B_2, \ldots, B_n$ are mutually exclusive events comprising all the incoming nodes at $A$.
The notation suggests flow from right to left. It might be more felicitous to use a different symbol and employ infix (rather than prefix) notation for conditional probabilities, writing $\Pr(B|C)$ as "$B\overset{\Pr}{\leftarrow} C$", perhaps. Then, using this purely syntactic modification, we could write the key part of (1) as
$$A\overset{\Pr}{\leftarrow}B\overset{\Pr}{\leftarrow} C = (A\overset{\Pr}{\leftarrow} B)(B\overset{\Pr}{\leftarrow} C) = \Pr(A|B)\Pr(B|C),$$
which is visually obvious. We might also invent a shorthand for (2) along the lines of
$$A\overset{\Pr}{\leftarrow}\{B_i\}\overset{\Pr}{\leftarrow} C = \sum_i A\overset{\Pr}{\leftarrow}B_i\overset{\Pr}{\leftarrow} C = \sum_i \Pr(A|B_i)\Pr(B_i|C).$$
These axioms work exactly as if probability were a conserved fluid flowing through the graph. Think of water in pipes (or electricity in perfectly insulated widely separated wires). Absolute probabilities like $\Pr(C)$ are total amounts of water available at nodes. Conditional probabilities like $\Pr(B|C)$ are the proportions of water flowing out of one node $C$ into another node $B$. The first axiom asserts that the proportion (relative to the origin $C$) of water/probability flowing from $C$ to $A$ through an intermediate node $B$ is the proportion from $C$ to $B$ multiplied by the proportion from $B$ to $A$: it merely expresses the arithmetic of proportions or fractions. (Engineers might think of this as a statement about probabilities connected in series.) The second axiom says that the water/probability flowing from $C$ to $A$ is the sum of amounts of water/probability flowing through a collection of intermediate points $B_i$, no two of which are connected. (Engineers will refer to this as a parallel connection.) This is what it means to be conserved: no probability is gained, lost, or transferred among edges as it flows through the graph.
|
Is there any intuitive meaning to the quantity P(A|B)P(B|C)?
|
There are several good visual and physical metaphors to help the intuition. I offer one of each.
Conditional probabilities of the form $\Pr(A|C)$ can be represented on graphs where the events $C$ and
|
Is there any intuitive meaning to the quantity P(A|B)P(B|C)?
There are several good visual and physical metaphors to help the intuition. I offer one of each.
Conditional probabilities of the form $\Pr(A|C)$ can be represented on graphs where the events $C$ and $A$ are nodes, a directed edge connects $C$ to $A$, and the edge is weighted by this probability. This graphical metaphor, variously known as a "probability tree" or "hierarchical network," visualizes two axiomatic properties of probability.
Path probabilities are products of edge probabilities: $\Pr(A,B,C) = \left[\Pr(A|B)\Pr(B|C)\right]\Pr(C)$. The nodes $C,B,A$ form a path along this tree from $C$ to $A$. The left hand side is the chance of this path; the right hand side is the product of the chance of being at the beginning and the chance of following the path. That latter chance, the "path probability" (written in brackets), is the product of the conditional probabilities.
Total probabilities are sums over all possible disjoint paths: $\Pr(A) = \Pr(A|B_1)\Pr(B_1) + \Pr(A|B_2)\Pr(B_2) + \cdots + \Pr(A|B_n)\Pr(B_n)$ where $B_1, B_2, \ldots, B_n$ are mutually exclusive events comprising all the incoming nodes at $A$.
The notation suggests flow from right to left. It might be more felicitous to use a different symbol and employ infix (rather than prefix) notation for conditional probabilities, writing $\Pr(B|C)$ as "$B\overset{\Pr}{\leftarrow} C$", perhaps. Then, using this purely syntactic modification, we could write the key part of (1) as
$$A\overset{\Pr}{\leftarrow}B\overset{\Pr}{\leftarrow} C = (A\overset{\Pr}{\leftarrow} B)(B\overset{\Pr}{\leftarrow} C) = \Pr(A|B)\Pr(B|C),$$
which is visually obvious. We might also invent a shorthand for (2) along the lines of
$$A\overset{\Pr}{\leftarrow}\{B_i\}\overset{\Pr}{\leftarrow} C = \sum_i A\overset{\Pr}{\leftarrow}B_i\overset{\Pr}{\leftarrow} C = \sum_i \Pr(A|B_i)\Pr(B_i|C).$$
These axioms work exactly as if probability were a conserved fluid flowing through the graph. Think of water in pipes (or electricity in perfectly insulated widely separated wires). Absolute probabilities like $\Pr(C)$ are total amounts of water available at nodes. Conditional probabilities like $\Pr(B|C)$ are the proportions of water flowing out of one node $C$ into another node $B$. The first axiom asserts that the proportion (relative to the origin $C$) of water/probability flowing from $C$ to $A$ through an intermediate node $B$ is the proportion from $C$ to $B$ multiplied by the proportion from $B$ to $A$: it merely expresses the arithmetic of proportions or fractions. (Engineers might think of this as a statement about probabilities connected in series.) The second axiom says that the water/probability flowing from $C$ to $A$ is the sum of amounts of water/probability flowing through a collection of intermediate points $B_i$, no two of which are connected. (Engineers will refer to this as a parallel connection.) This is what it means to be conserved: no probability is gained, lost, or transferred among edges as it flows through the graph.
|
Is there any intuitive meaning to the quantity P(A|B)P(B|C)?
There are several good visual and physical metaphors to help the intuition. I offer one of each.
Conditional probabilities of the form $\Pr(A|C)$ can be represented on graphs where the events $C$ and
|
45,860
|
F test and t test in linear regression model
|
The misunderstanding is your first premise "F test and $t$-test are performed between two populations", this is incorrect or at least incomplete. The $t$-test that is next to a coefficient tests the null hypothesis that that coefficient equals 0. If the corresponding variable is binary, for example 0 = male, 1 = female, then that describes the two populations but with the added complication that you also adjust for the other covariates in your model. If that variable is continuous, for example years of education, you can think of comparing someone with 0 years of education with someone with 1 years of education, and comparing someone with 1 years of education with someone with 2 years of education, etc, with the constraint that each step has the same effect on the expected outcome and again with the complication that you adjust for the other covariates in your model.
An F-test after linear regression tests the null hypothesis that all coefficients in your model except the constant are equal to 0. So the groups that you are comparing is even more complex.
|
F test and t test in linear regression model
|
The misunderstanding is your first premise "F test and $t$-test are performed between two populations", this is incorrect or at least incomplete. The $t$-test that is next to a coefficient tests the n
|
F test and t test in linear regression model
The misunderstanding is your first premise "F test and $t$-test are performed between two populations", this is incorrect or at least incomplete. The $t$-test that is next to a coefficient tests the null hypothesis that that coefficient equals 0. If the corresponding variable is binary, for example 0 = male, 1 = female, then that describes the two populations but with the added complication that you also adjust for the other covariates in your model. If that variable is continuous, for example years of education, you can think of comparing someone with 0 years of education with someone with 1 years of education, and comparing someone with 1 years of education with someone with 2 years of education, etc, with the constraint that each step has the same effect on the expected outcome and again with the complication that you adjust for the other covariates in your model.
An F-test after linear regression tests the null hypothesis that all coefficients in your model except the constant are equal to 0. So the groups that you are comparing is even more complex.
|
F test and t test in linear regression model
The misunderstanding is your first premise "F test and $t$-test are performed between two populations", this is incorrect or at least incomplete. The $t$-test that is next to a coefficient tests the n
|
45,861
|
F test and t test in linear regression model
|
Some notations in the very beginning, I'm using z~N(0,1), u~χ2(p), v~χ2(q) and z, u and v are mutually independent(important condition)
t = z/sqrt(u/p). For each of the coefficient βj, if you test whether h0: βj =0. Then (βj-0)/1 is basically z, and sample variances (n-2)S^2~χ2(n-2), then you also have your bottom part. So when t is large, which means it deviates from the H0 (significant p-value) and we reject Ho.
F = (u/p)/(v/q), where u could have non-central parameters λ. How do you get two independent χ2 in general linear regression? Estimated βhat (the whole vector) and estimated sample variance s^2 are always independent. So F-test in linear regression basically are (SSR/k)/(SSE/(n-k-1)). (SSR: sum of squares of regression SSE: sum of squares of error). Under H0: β=0, top will have central chi-square (and therefore non-central F), otherwise, it will follow non-central test statistics. So if you want to know relationship between t and F, then think about the simple linear regression. Y=Xb+a (b is a scalar), then t-test for b and overall F test are the same thing.
For (one-way) ANOVA, there are lots of statistical stuff regarding the non-full rank X matrix and estimable functions stuff, I don't want to burden you with all that. But the basic idea is, for example we have 4 treatment in covid-19, and we want to compare whether there is difference between the 4 groups. Then overall F = \sum{n=1}^{4-1}(Fi)/(4-1) for total (4-1) linearly independent orthogonal contrasts. So if the overall F has a big value, we would reject H0: no difference between 4 groups.
Lol I just realized you asked this question so many years ago and probably not confused anymore. But if there's any chance you're still interested, you can check out 'Linear model in statistics' book for more rigorous explanations. I was reviewing the book for my qualifier and happened to bump into this :)
|
F test and t test in linear regression model
|
Some notations in the very beginning, I'm using z~N(0,1), u~χ2(p), v~χ2(q) and z, u and v are mutually independent(important condition)
t = z/sqrt(u/p). For each of the coefficient βj, if you test wh
|
F test and t test in linear regression model
Some notations in the very beginning, I'm using z~N(0,1), u~χ2(p), v~χ2(q) and z, u and v are mutually independent(important condition)
t = z/sqrt(u/p). For each of the coefficient βj, if you test whether h0: βj =0. Then (βj-0)/1 is basically z, and sample variances (n-2)S^2~χ2(n-2), then you also have your bottom part. So when t is large, which means it deviates from the H0 (significant p-value) and we reject Ho.
F = (u/p)/(v/q), where u could have non-central parameters λ. How do you get two independent χ2 in general linear regression? Estimated βhat (the whole vector) and estimated sample variance s^2 are always independent. So F-test in linear regression basically are (SSR/k)/(SSE/(n-k-1)). (SSR: sum of squares of regression SSE: sum of squares of error). Under H0: β=0, top will have central chi-square (and therefore non-central F), otherwise, it will follow non-central test statistics. So if you want to know relationship between t and F, then think about the simple linear regression. Y=Xb+a (b is a scalar), then t-test for b and overall F test are the same thing.
For (one-way) ANOVA, there are lots of statistical stuff regarding the non-full rank X matrix and estimable functions stuff, I don't want to burden you with all that. But the basic idea is, for example we have 4 treatment in covid-19, and we want to compare whether there is difference between the 4 groups. Then overall F = \sum{n=1}^{4-1}(Fi)/(4-1) for total (4-1) linearly independent orthogonal contrasts. So if the overall F has a big value, we would reject H0: no difference between 4 groups.
Lol I just realized you asked this question so many years ago and probably not confused anymore. But if there's any chance you're still interested, you can check out 'Linear model in statistics' book for more rigorous explanations. I was reviewing the book for my qualifier and happened to bump into this :)
|
F test and t test in linear regression model
Some notations in the very beginning, I'm using z~N(0,1), u~χ2(p), v~χ2(q) and z, u and v are mutually independent(important condition)
t = z/sqrt(u/p). For each of the coefficient βj, if you test wh
|
45,862
|
Are latent variable models modelling causality?
|
Not necessarily.
Or, perhaps a better answer is, "it depends on what you mean by causality".
It is presumed, in the latent factor model, that the individual items measure the latent factor; that's really the point. So, on, e.g. the MMPI, the different questions are supposed to be measuring aspects of personality, and the purpose of factor analysis is to uncover those latent factors.
But does this mean that the personality factors "cause" the answers to the question?
The answer is philosophy, not statistics.
(StasK's edits:) To put it differently, there is nothing magic about latent variable models that immediately let you jump to the causality conclusions. It's just an extension of regression analysis to unobserved variables, that's all. If you trust regression with observational data to draw causal conclusions, you can likewise trust latent variable models. This may be discipline-specific, as some disciplines (biostat) only accept randomized experiments as the golden standard for establishing causality, while others (education research) may be happy with something less golden and less standard.
|
Are latent variable models modelling causality?
|
Not necessarily.
Or, perhaps a better answer is, "it depends on what you mean by causality".
It is presumed, in the latent factor model, that the individual items measure the latent factor; that's re
|
Are latent variable models modelling causality?
Not necessarily.
Or, perhaps a better answer is, "it depends on what you mean by causality".
It is presumed, in the latent factor model, that the individual items measure the latent factor; that's really the point. So, on, e.g. the MMPI, the different questions are supposed to be measuring aspects of personality, and the purpose of factor analysis is to uncover those latent factors.
But does this mean that the personality factors "cause" the answers to the question?
The answer is philosophy, not statistics.
(StasK's edits:) To put it differently, there is nothing magic about latent variable models that immediately let you jump to the causality conclusions. It's just an extension of regression analysis to unobserved variables, that's all. If you trust regression with observational data to draw causal conclusions, you can likewise trust latent variable models. This may be discipline-specific, as some disciplines (biostat) only accept randomized experiments as the golden standard for establishing causality, while others (education research) may be happy with something less golden and less standard.
|
Are latent variable models modelling causality?
Not necessarily.
Or, perhaps a better answer is, "it depends on what you mean by causality".
It is presumed, in the latent factor model, that the individual items measure the latent factor; that's re
|
45,863
|
What is a "posterior median"?
|
Well, you have posterior means, posterior modes, posterior standard deviations... any functional relationship calculated in a probability density can be calculated in a posterior density.
|
What is a "posterior median"?
|
Well, you have posterior means, posterior modes, posterior standard deviations... any functional relationship calculated in a probability density can be calculated in a posterior density.
|
What is a "posterior median"?
Well, you have posterior means, posterior modes, posterior standard deviations... any functional relationship calculated in a probability density can be calculated in a posterior density.
|
What is a "posterior median"?
Well, you have posterior means, posterior modes, posterior standard deviations... any functional relationship calculated in a probability density can be calculated in a posterior density.
|
45,864
|
Probability that a random number will be the largest from sets
|
When you pick randomly and independently from three random variables $A$, $B$, and $C$, having (cumulative) distributions $F_A$, $F_B$, and $F_C$ and corresponding distribution functions $f_A$, $f_B$, and $f_C$, then by definition of independence the chance that all three numbers are less than some value $x$ equals
$$\Pr(\max(A,B,C) \le x) = F_A(x)F_B(x)F_C(x).$$
Differentiation with respect to $x$ (via the product rule) gives the PDF of the max as
$$f_{\max(A,B,C)} = f_A(x)F_B(x)F_C(x) + F_A(x)f_B(x)F_C(x) + F_A(x)F_B(x)f_C(x).$$
That sure looks like a decomposition corresponding to $A$, $B$, and $C$. Indeed, the first term (by definition) tells us that the chance that $x \lt A \le x+dx$ and $B \le x$ and $C \le x$ is $f_A(x)F_B(x)F_C(x)dx$. Integrating that over all $x$ would then give the chance that $A$ exceeds both $B$ and $C$.
In the present situation, $\int_\mathbb{R} f_A(x)F_B(x)F_C(x)dx = 17/8910 \approx .00191,$ for instance.
The formula clearly generalizes to any finite number of independent random variables having any distributions you please.
|
Probability that a random number will be the largest from sets
|
When you pick randomly and independently from three random variables $A$, $B$, and $C$, having (cumulative) distributions $F_A$, $F_B$, and $F_C$ and corresponding distribution functions $f_A$, $f_B$,
|
Probability that a random number will be the largest from sets
When you pick randomly and independently from three random variables $A$, $B$, and $C$, having (cumulative) distributions $F_A$, $F_B$, and $F_C$ and corresponding distribution functions $f_A$, $f_B$, and $f_C$, then by definition of independence the chance that all three numbers are less than some value $x$ equals
$$\Pr(\max(A,B,C) \le x) = F_A(x)F_B(x)F_C(x).$$
Differentiation with respect to $x$ (via the product rule) gives the PDF of the max as
$$f_{\max(A,B,C)} = f_A(x)F_B(x)F_C(x) + F_A(x)f_B(x)F_C(x) + F_A(x)F_B(x)f_C(x).$$
That sure looks like a decomposition corresponding to $A$, $B$, and $C$. Indeed, the first term (by definition) tells us that the chance that $x \lt A \le x+dx$ and $B \le x$ and $C \le x$ is $f_A(x)F_B(x)F_C(x)dx$. Integrating that over all $x$ would then give the chance that $A$ exceeds both $B$ and $C$.
In the present situation, $\int_\mathbb{R} f_A(x)F_B(x)F_C(x)dx = 17/8910 \approx .00191,$ for instance.
The formula clearly generalizes to any finite number of independent random variables having any distributions you please.
|
Probability that a random number will be the largest from sets
When you pick randomly and independently from three random variables $A$, $B$, and $C$, having (cumulative) distributions $F_A$, $F_B$, and $F_C$ and corresponding distribution functions $f_A$, $f_B$,
|
45,865
|
Relation between observed power and p-value?
|
Answers to question 1,2,3,4 ($Z$-test)
The decreasing link between the $p$-value and the observed power is intuitively highly expected: the $p$-value $p^{\text{obs}}$ is low when the observed sample mean $\bar y^{\text{obs}}$ is high ($H_1$ favoured), and since $\bar y^{\text{obs}} = \hat\mu$ the observed power is high because the power function $\mu \mapsto \Pr(\text{reject } H_0) $ is increasing.
Below is a mathematical proof.
Assume $n$ independent observations $y^{\text{obs}}_1, \ldots, y^{\text{obs}}_n$ from ${\cal N}(\mu, \sigma^2)$ with known $\sigma$. The $Z$-test consists of rejecting the null hypothesis $H_0:\{\mu=0\}$ in favour of $H_1:\{\mu >0\}$ when the sample mean $\bar y \sim {\cal N}(\mu, {(\sigma/\sqrt{n})}^2)$ is high. Thus the $p$-value is $$p^{\text{obs}}=\Pr({\cal N}(0, {(\sigma/\sqrt{n})}^2) > \bar y^{\text{obs}})=1-\Phi\left(\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \right) \quad (\ast)$$ where $\Phi$ is the cumulative distribution of ${\cal N}(0,1)$.
Thus, choosing a significance level $\alpha$, one rejects $H_0$ when $p^{\text{obs}} \leq \alpha$, and this equivalent to $$\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \geq \Phi^{-1}(1-\alpha)=:z_\alpha.$$ But $\frac{\sqrt{n}\bar y}{\sigma} \sim {\cal N}(\delta,1)$ with $\boxed{\delta=\delta(\mu)=\frac{\sqrt{n}\mu}{\sigma}}$, therefore the probability that the above inequality occurs is $\Pr({\cal N}(\delta,1) \geq z_\alpha) = 1-\Phi(z_\alpha-\delta)$. We have just derived the power function $$\mu \mapsto \Pr(\text{reject } H_0) =1-\Phi(z_\alpha-\delta(\mu))$$ which is, as expected, an increasing function:
alpha <- 5/100
z_alpha <- qnorm(alpha, lower.tail=FALSE)
n <- 6
sigma <- 1
pow <- function(mu){
delta <- sqrt(n)*mu/sigma
1-pnorm(z_alpha-delta)
}
curve(pow(x), from=0, to=2, xlab=expression(mu), ylab="Power")
The observed power is the power function evaluated at the estimate $\hat\mu=\bar y^{\text{obs}}$ of the unknown parameter $\mu$. This gives $1-\Phi\left(z_\alpha- \frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \right)$, but the formula $(\ast)$ for the $p$-value $p^{\text{obs}}$ shows that $$\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma}=z_{p^{\text{obs}}}.$$
An answer to question 5 ($F$-tests)
For example, the decreasing one-to-one correspondence between the $p$-value and the observed power also holds for any $F$-test of linear hypotheses in classical Gaussian linear models, and this can be shown as follows. All notations are fixed here. The $p$-value is the probability that a $F$-distribution exceeds the observed statistic $f^{\text{obs}}$. The power only depends on the parameters through the noncentrality parameter $\boxed{\lambda=\frac{{\Vert P_Z \mu\Vert}^2}{\sigma^2}}$, and it is an increasing function of $\lambda$ (noncentral $F$ distributions are stochastically increasing with the noncentrality parameter $\lambda$). The observed power approach consists of evaluating the power at $\lambda=\hat\lambda$ obtained by replacing $\mu$ and $\sigma$ in $\lambda$ with their estimates $\hat\mu$ and $\hat\sigma$. If we use the classical estimates then one has the relation $\boxed{f^{\text{obs}}=\frac{\hat\lambda}{m-\ell}}$. Then it is easy to conclude.
In my reply to Tim's previous question I shared a link to some R code evaluating the observed power as a function of the $p$-value.
|
Relation between observed power and p-value?
|
Answers to question 1,2,3,4 ($Z$-test)
The decreasing link between the $p$-value and the observed power is intuitively highly expected: the $p$-value $p^{\text{obs}}$ is low when the observed sample m
|
Relation between observed power and p-value?
Answers to question 1,2,3,4 ($Z$-test)
The decreasing link between the $p$-value and the observed power is intuitively highly expected: the $p$-value $p^{\text{obs}}$ is low when the observed sample mean $\bar y^{\text{obs}}$ is high ($H_1$ favoured), and since $\bar y^{\text{obs}} = \hat\mu$ the observed power is high because the power function $\mu \mapsto \Pr(\text{reject } H_0) $ is increasing.
Below is a mathematical proof.
Assume $n$ independent observations $y^{\text{obs}}_1, \ldots, y^{\text{obs}}_n$ from ${\cal N}(\mu, \sigma^2)$ with known $\sigma$. The $Z$-test consists of rejecting the null hypothesis $H_0:\{\mu=0\}$ in favour of $H_1:\{\mu >0\}$ when the sample mean $\bar y \sim {\cal N}(\mu, {(\sigma/\sqrt{n})}^2)$ is high. Thus the $p$-value is $$p^{\text{obs}}=\Pr({\cal N}(0, {(\sigma/\sqrt{n})}^2) > \bar y^{\text{obs}})=1-\Phi\left(\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \right) \quad (\ast)$$ where $\Phi$ is the cumulative distribution of ${\cal N}(0,1)$.
Thus, choosing a significance level $\alpha$, one rejects $H_0$ when $p^{\text{obs}} \leq \alpha$, and this equivalent to $$\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \geq \Phi^{-1}(1-\alpha)=:z_\alpha.$$ But $\frac{\sqrt{n}\bar y}{\sigma} \sim {\cal N}(\delta,1)$ with $\boxed{\delta=\delta(\mu)=\frac{\sqrt{n}\mu}{\sigma}}$, therefore the probability that the above inequality occurs is $\Pr({\cal N}(\delta,1) \geq z_\alpha) = 1-\Phi(z_\alpha-\delta)$. We have just derived the power function $$\mu \mapsto \Pr(\text{reject } H_0) =1-\Phi(z_\alpha-\delta(\mu))$$ which is, as expected, an increasing function:
alpha <- 5/100
z_alpha <- qnorm(alpha, lower.tail=FALSE)
n <- 6
sigma <- 1
pow <- function(mu){
delta <- sqrt(n)*mu/sigma
1-pnorm(z_alpha-delta)
}
curve(pow(x), from=0, to=2, xlab=expression(mu), ylab="Power")
The observed power is the power function evaluated at the estimate $\hat\mu=\bar y^{\text{obs}}$ of the unknown parameter $\mu$. This gives $1-\Phi\left(z_\alpha- \frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma} \right)$, but the formula $(\ast)$ for the $p$-value $p^{\text{obs}}$ shows that $$\frac{\sqrt{n}\bar y^{\text{obs}}}{\sigma}=z_{p^{\text{obs}}}.$$
An answer to question 5 ($F$-tests)
For example, the decreasing one-to-one correspondence between the $p$-value and the observed power also holds for any $F$-test of linear hypotheses in classical Gaussian linear models, and this can be shown as follows. All notations are fixed here. The $p$-value is the probability that a $F$-distribution exceeds the observed statistic $f^{\text{obs}}$. The power only depends on the parameters through the noncentrality parameter $\boxed{\lambda=\frac{{\Vert P_Z \mu\Vert}^2}{\sigma^2}}$, and it is an increasing function of $\lambda$ (noncentral $F$ distributions are stochastically increasing with the noncentrality parameter $\lambda$). The observed power approach consists of evaluating the power at $\lambda=\hat\lambda$ obtained by replacing $\mu$ and $\sigma$ in $\lambda$ with their estimates $\hat\mu$ and $\hat\sigma$. If we use the classical estimates then one has the relation $\boxed{f^{\text{obs}}=\frac{\hat\lambda}{m-\ell}}$. Then it is easy to conclude.
In my reply to Tim's previous question I shared a link to some R code evaluating the observed power as a function of the $p$-value.
|
Relation between observed power and p-value?
Answers to question 1,2,3,4 ($Z$-test)
The decreasing link between the $p$-value and the observed power is intuitively highly expected: the $p$-value $p^{\text{obs}}$ is low when the observed sample m
|
45,866
|
Propagation of uncertainty through a linear system of equations
|
Let me translate into statistician. So $B$ is a random variable where $B = \beta + \varepsilon$, with $\text{Var}(\varepsilon)$ = $\Sigma_B$, for $\Sigma_B$ known. An observation is taken, and the observed value of $B$ is $b$.
Assuming $A$ is invertible, the solution of $Ax = b$ is $A^{-1}b$. Let $C = A^{-1}$ for the moment.
$\text{Var}(Cb) = C\,\text{Var}(b)\,C^\top = A^{-1} \Sigma_B (A^{-1})^\top$
If the two components of $b$ are independent, then $\Sigma_B$ is diagonal, with diagonal the squares of your $\sigma$'s. That variance-covariance matrix of $x$ is in general not diagonal, meaning the values are correlated. The square roots of the diagonal elements of $ A^{-1} \Sigma_B (A^{-1})^\top$ are the standard deviations of the components of $x$.
This approach applies to more than two dimensions as well.
|
Propagation of uncertainty through a linear system of equations
|
Let me translate into statistician. So $B$ is a random variable where $B = \beta + \varepsilon$, with $\text{Var}(\varepsilon)$ = $\Sigma_B$, for $\Sigma_B$ known. An observation is taken, and the obs
|
Propagation of uncertainty through a linear system of equations
Let me translate into statistician. So $B$ is a random variable where $B = \beta + \varepsilon$, with $\text{Var}(\varepsilon)$ = $\Sigma_B$, for $\Sigma_B$ known. An observation is taken, and the observed value of $B$ is $b$.
Assuming $A$ is invertible, the solution of $Ax = b$ is $A^{-1}b$. Let $C = A^{-1}$ for the moment.
$\text{Var}(Cb) = C\,\text{Var}(b)\,C^\top = A^{-1} \Sigma_B (A^{-1})^\top$
If the two components of $b$ are independent, then $\Sigma_B$ is diagonal, with diagonal the squares of your $\sigma$'s. That variance-covariance matrix of $x$ is in general not diagonal, meaning the values are correlated. The square roots of the diagonal elements of $ A^{-1} \Sigma_B (A^{-1})^\top$ are the standard deviations of the components of $x$.
This approach applies to more than two dimensions as well.
|
Propagation of uncertainty through a linear system of equations
Let me translate into statistician. So $B$ is a random variable where $B = \beta + \varepsilon$, with $\text{Var}(\varepsilon)$ = $\Sigma_B$, for $\Sigma_B$ known. An observation is taken, and the obs
|
45,867
|
Bayesian posterior: mean vs highest probability
|
I think the frequentist analogues are that of estimating equations to posterior mean and maximum likelihood to posterior mode. They are not equivalent by any means, but have some important similarities. When you estimate a posterior mode, you're doing Bayesian "maximum likelihood".
The posterior mode is not often preferred because the sampling distribution of this value can be very irregular. That's for two reasons: the posterior may have many local maximae and mode estimation is very inefficient except when making strong assumptions. These points are moot when doing exact Bayes, in which case the posterior is known to fall into a parametric family. But doing Gibbs Sampling all higgeldy piggeldy will not guarantee that the posterior falls into any "known" family of distributions.
In basic probability problems, it's easy to obtain exact expressions for posteriors when there are constraining assumptions made about the distribution of sample data and the specification of the prior. In practice, this is rarely the case and posteriors in finite (small) samples can be bumpy, ugly things.
The sampling distribution of the posterior mode does have some convergence properties, like any estimator. But none so well understood and explored as those of the posterior mean. It's so often the efficient estimator in frequentist problems, little wonder it is preferred in the Bayesian world as well.
|
Bayesian posterior: mean vs highest probability
|
I think the frequentist analogues are that of estimating equations to posterior mean and maximum likelihood to posterior mode. They are not equivalent by any means, but have some important similaritie
|
Bayesian posterior: mean vs highest probability
I think the frequentist analogues are that of estimating equations to posterior mean and maximum likelihood to posterior mode. They are not equivalent by any means, but have some important similarities. When you estimate a posterior mode, you're doing Bayesian "maximum likelihood".
The posterior mode is not often preferred because the sampling distribution of this value can be very irregular. That's for two reasons: the posterior may have many local maximae and mode estimation is very inefficient except when making strong assumptions. These points are moot when doing exact Bayes, in which case the posterior is known to fall into a parametric family. But doing Gibbs Sampling all higgeldy piggeldy will not guarantee that the posterior falls into any "known" family of distributions.
In basic probability problems, it's easy to obtain exact expressions for posteriors when there are constraining assumptions made about the distribution of sample data and the specification of the prior. In practice, this is rarely the case and posteriors in finite (small) samples can be bumpy, ugly things.
The sampling distribution of the posterior mode does have some convergence properties, like any estimator. But none so well understood and explored as those of the posterior mean. It's so often the efficient estimator in frequentist problems, little wonder it is preferred in the Bayesian world as well.
|
Bayesian posterior: mean vs highest probability
I think the frequentist analogues are that of estimating equations to posterior mean and maximum likelihood to posterior mode. They are not equivalent by any means, but have some important similaritie
|
45,868
|
Bayesian posterior: mean vs highest probability
|
Both are used (along with the median). Which is "best" depends on the context of how you are going to use it. Generally to a Bayesian the whole posterior distribution is interesting, not just one single number from it. Also interesting is the Credible intervals, but again you have choices, do you want the Highest Posterior Density? or the interval with equal probability in each tail? The HPD gives the narrowest interval, but the second means that when it does not contain the truth it is equally likely to miss on either side. There are other ways to construct the interval as well.
So, How do you plan to use your single number? If it is the answer to a test or homework problem then use whatever your teacher specifies. If you want to gain understanding, then use the entire posterior. If this is for a client then you should start with a CI at a minimum, a single number will likely be misleading.
|
Bayesian posterior: mean vs highest probability
|
Both are used (along with the median). Which is "best" depends on the context of how you are going to use it. Generally to a Bayesian the whole posterior distribution is interesting, not just one si
|
Bayesian posterior: mean vs highest probability
Both are used (along with the median). Which is "best" depends on the context of how you are going to use it. Generally to a Bayesian the whole posterior distribution is interesting, not just one single number from it. Also interesting is the Credible intervals, but again you have choices, do you want the Highest Posterior Density? or the interval with equal probability in each tail? The HPD gives the narrowest interval, but the second means that when it does not contain the truth it is equally likely to miss on either side. There are other ways to construct the interval as well.
So, How do you plan to use your single number? If it is the answer to a test or homework problem then use whatever your teacher specifies. If you want to gain understanding, then use the entire posterior. If this is for a client then you should start with a CI at a minimum, a single number will likely be misleading.
|
Bayesian posterior: mean vs highest probability
Both are used (along with the median). Which is "best" depends on the context of how you are going to use it. Generally to a Bayesian the whole posterior distribution is interesting, not just one si
|
45,869
|
Bayesian posterior: mean vs highest probability
|
It's not always the case that the mean is more relevant than the mode. That is part of the value of representing the full distribution within the Bayesian approach, if you have the full distribution you can extract whatever statistical information is required.
The average of the distribution, will often be useful for describing the net (summed or averaged) result of multiple trials due to the central limit theorem;
which indicates that the average of a large number of trials converges to the mean of the underlying distribution.
However, in other cases, knowing the mode, or a description of the distribution near the mode, can also be useful, e.g. using the method of steepest descent approximation.
|
Bayesian posterior: mean vs highest probability
|
It's not always the case that the mean is more relevant than the mode. That is part of the value of representing the full distribution within the Bayesian approach, if you have the full distribution
|
Bayesian posterior: mean vs highest probability
It's not always the case that the mean is more relevant than the mode. That is part of the value of representing the full distribution within the Bayesian approach, if you have the full distribution you can extract whatever statistical information is required.
The average of the distribution, will often be useful for describing the net (summed or averaged) result of multiple trials due to the central limit theorem;
which indicates that the average of a large number of trials converges to the mean of the underlying distribution.
However, in other cases, knowing the mode, or a description of the distribution near the mode, can also be useful, e.g. using the method of steepest descent approximation.
|
Bayesian posterior: mean vs highest probability
It's not always the case that the mean is more relevant than the mode. That is part of the value of representing the full distribution within the Bayesian approach, if you have the full distribution
|
45,870
|
'Stationarity requirement' why?
|
First let's decide what form of stationarity you are asking about. There are two types:
(1) strict stationarity: All aspects of a time series behavior are not dependent on time. i.e. for every m & n the distribtions of $\newcommand{\Cov}{\operatorname{Cov}}Z_t, Z_{t1}, \dots, Z_{t+m+n}$ are the same.
(2) weak stationarity (sometimes called covariance stationary): if $\mu, \sigma^2,\gamma$ are unchanged by shifts in time.
-strict stationarity and weak stationarity are equivalent for Gaussian processes, since a normal distribution is uniquely characterized by its first two moments.
Let's assume that we're talking about weak stationarity here because you seem to be asking about correlation.
Formulas for covariance:
$\gamma = \Cov(Z_t,Z_{t+k})$ = $E[Z_t -\mu]E[Z_{t+k}-\mu]$
$\rho = \frac{\Cov(Z_t,Z_{t+k})}{\sigma_{Z(t)}\sigma_{Z(t+k)}}$
So covariance and correlation are both functions of the mean and variance.
So for example, if the series is consistently increasing over time, the sample mean and variance will grow with the size of the sample, and they will always underestimate the mean and variance in future periods. And if the mean and variance of a series are not well-defined, then neither are its correlations with other variables. For this reason you should also be cautious about trying to extrapolate regression models fitted to nonstationary data.
Most statistical forecasting methods are based on the assumption that the time series can be rendered approximately stationary (i.e., "stationarized") through the use of mathematical transformations. A stationarized series is relatively easy to predict: you simply predict that its statistical properties will be the same in the future as they have been in the past!
I stole the last two paragraphs from this article from Duke University's website. They described it better than I could have.
http://people.duke.edu/~rnau/411diff.htm
There are multiple methods for making a time series stationary, which include detrending and first differencing. You can find many descriptions of both on websites. The Duke U link above explains first differencing. Forecasts and means/variances can be made with the detrended model, and then the model can be converted back to the original.
|
'Stationarity requirement' why?
|
First let's decide what form of stationarity you are asking about. There are two types:
(1) strict stationarity: All aspects of a time series behavior are not dependent on time. i.e. for every m &
|
'Stationarity requirement' why?
First let's decide what form of stationarity you are asking about. There are two types:
(1) strict stationarity: All aspects of a time series behavior are not dependent on time. i.e. for every m & n the distribtions of $\newcommand{\Cov}{\operatorname{Cov}}Z_t, Z_{t1}, \dots, Z_{t+m+n}$ are the same.
(2) weak stationarity (sometimes called covariance stationary): if $\mu, \sigma^2,\gamma$ are unchanged by shifts in time.
-strict stationarity and weak stationarity are equivalent for Gaussian processes, since a normal distribution is uniquely characterized by its first two moments.
Let's assume that we're talking about weak stationarity here because you seem to be asking about correlation.
Formulas for covariance:
$\gamma = \Cov(Z_t,Z_{t+k})$ = $E[Z_t -\mu]E[Z_{t+k}-\mu]$
$\rho = \frac{\Cov(Z_t,Z_{t+k})}{\sigma_{Z(t)}\sigma_{Z(t+k)}}$
So covariance and correlation are both functions of the mean and variance.
So for example, if the series is consistently increasing over time, the sample mean and variance will grow with the size of the sample, and they will always underestimate the mean and variance in future periods. And if the mean and variance of a series are not well-defined, then neither are its correlations with other variables. For this reason you should also be cautious about trying to extrapolate regression models fitted to nonstationary data.
Most statistical forecasting methods are based on the assumption that the time series can be rendered approximately stationary (i.e., "stationarized") through the use of mathematical transformations. A stationarized series is relatively easy to predict: you simply predict that its statistical properties will be the same in the future as they have been in the past!
I stole the last two paragraphs from this article from Duke University's website. They described it better than I could have.
http://people.duke.edu/~rnau/411diff.htm
There are multiple methods for making a time series stationary, which include detrending and first differencing. You can find many descriptions of both on websites. The Duke U link above explains first differencing. Forecasts and means/variances can be made with the detrended model, and then the model can be converted back to the original.
|
'Stationarity requirement' why?
First let's decide what form of stationarity you are asking about. There are two types:
(1) strict stationarity: All aspects of a time series behavior are not dependent on time. i.e. for every m &
|
45,871
|
'Stationarity requirement' why?
|
I am new in Time series analysis (TSA), but my basic understanding is that the main aim of TSA is forecasting. A time series is made up of several components: Trend, Seasonal, cyclical, and irregular. By transforming or 'stationarizing' the series, its statistical properties (mean, variance) are easily forecasted as they remain fixed. The trend and seasonal components remain unchanged. The analysis is then mainly concentrated on forecasting the irregular component. Feel free to correct me if I am wrong.
|
'Stationarity requirement' why?
|
I am new in Time series analysis (TSA), but my basic understanding is that the main aim of TSA is forecasting. A time series is made up of several components: Trend, Seasonal, cyclical, and irregular.
|
'Stationarity requirement' why?
I am new in Time series analysis (TSA), but my basic understanding is that the main aim of TSA is forecasting. A time series is made up of several components: Trend, Seasonal, cyclical, and irregular. By transforming or 'stationarizing' the series, its statistical properties (mean, variance) are easily forecasted as they remain fixed. The trend and seasonal components remain unchanged. The analysis is then mainly concentrated on forecasting the irregular component. Feel free to correct me if I am wrong.
|
'Stationarity requirement' why?
I am new in Time series analysis (TSA), but my basic understanding is that the main aim of TSA is forecasting. A time series is made up of several components: Trend, Seasonal, cyclical, and irregular.
|
45,872
|
Is a larger beta weight a better predictor than a high t-statistic?
|
It would help if you could answer @whuber's question. However, in general, this question cannot be answered.
The reason is that variables are almost always on incommensurate scales. Consider the typical study that involves human subjects (as in medical research or the social and behavioral sciences), what covariates do we typically have? It is quite common to include $\text{sex}$, $\text{age}$, $\text{weight}$, $\text{height}$, etc. Now ask yourself: How many years makes you male? How many centimeters equals a kilogram? Etc. These cannot be equated. However, the ability of knowledge of one variable to help you differentiate amongst possible values of another variable is a function not only of the slope of the relationship between the two variables in question, but also of how spread out those values are1. That is, you cannot elide the issue of the incommensurable units with which your variables are measured. Thus, @StocSim's answer, while commonly believed, will not work: the significance of your variables (their p-values, t statistics, etc.) is related to how spread out those variables are in your dataset and there is no absolute2 way to determine whether the range of your $\text{heights}$ is comparable to the range of your $\text{ages}$.
1 See my answer here: how-do-you-interpret-a-low-coefficient-yet-statistically-significant-with-a-high, for more along these lines.
2 It may be possible to equate variables by recourse to something else, e.g., how much it would cost to increase the amount of different variables. Note, however, that this will change over time with changes in technology, the market, etc.
|
Is a larger beta weight a better predictor than a high t-statistic?
|
It would help if you could answer @whuber's question. However, in general, this question cannot be answered.
The reason is that variables are almost always on incommensurate scales. Consider the t
|
Is a larger beta weight a better predictor than a high t-statistic?
It would help if you could answer @whuber's question. However, in general, this question cannot be answered.
The reason is that variables are almost always on incommensurate scales. Consider the typical study that involves human subjects (as in medical research or the social and behavioral sciences), what covariates do we typically have? It is quite common to include $\text{sex}$, $\text{age}$, $\text{weight}$, $\text{height}$, etc. Now ask yourself: How many years makes you male? How many centimeters equals a kilogram? Etc. These cannot be equated. However, the ability of knowledge of one variable to help you differentiate amongst possible values of another variable is a function not only of the slope of the relationship between the two variables in question, but also of how spread out those values are1. That is, you cannot elide the issue of the incommensurable units with which your variables are measured. Thus, @StocSim's answer, while commonly believed, will not work: the significance of your variables (their p-values, t statistics, etc.) is related to how spread out those variables are in your dataset and there is no absolute2 way to determine whether the range of your $\text{heights}$ is comparable to the range of your $\text{ages}$.
1 See my answer here: how-do-you-interpret-a-low-coefficient-yet-statistically-significant-with-a-high, for more along these lines.
2 It may be possible to equate variables by recourse to something else, e.g., how much it would cost to increase the amount of different variables. Note, however, that this will change over time with changes in technology, the market, etc.
|
Is a larger beta weight a better predictor than a high t-statistic?
It would help if you could answer @whuber's question. However, in general, this question cannot be answered.
The reason is that variables are almost always on incommensurate scales. Consider the t
|
45,873
|
Is a larger beta weight a better predictor than a high t-statistic?
|
$\beta$ and t-stat tell very different bits of information about a variable's effect in a statistical model and they are not exchangeable:
$\beta$ (standardized effect size) is far more important. It tells how strong or meaningful the effect is. B (unstandardized effect size) is usually easier to interpret and so is preferred to explain what the results actually mean in real-world terms, but $\beta$ (standardized effect size) is more useful for comparing the relative strength of effects between various variables, since the B measures are on different scales.
t-stat (statistical significance) is also important, but it only tells you how reliable the measure of $\beta$ is. That's all it does. It absolutely does not tell you how important a variable is, and although it is very, very widely misused in that way, that is a misuse. (The same, of course, applies not only to the t-stat, but to all measures of statistical significance.)
Taken together, the $\beta$ and t-stat give you the effect size and how reliable is the estimation of the effect size. There are four general possible scenarios:
High $\beta$ and signficant t-stat: The high $\beta$ means that the variable is indeed important and the significant t means that you can trust that the high $\beta$ is reliable.
High $\beta$ but insignficant t-stat: The high $\beta$ means that the variable is possibly important, but the insignificant t means that you cannot trust this result because your sample size is too small for you to be confident in the results.
Low $\beta$ but signficant t-stat: The low $\beta$ means that the variable is not important and the significant t means that you can trust that the low $\beta$ is reliable.
Low $\beta$ and insignficant t-stat: The low $\beta$ means that the variable is possibly not important, but the insignificant t means that you cannot trust this result because your sample size is too small for you to be confident in the results. However, since an unimportant effect of the variable would require a very large sample to register a significant t, if the sample is reasonably large and $\beta$ is quite low, it is reasonable to conclude that the variable probably has very little, if any, effect.
In an ideal world, all t-stats should always be statistically significant; if you have a huge sample size, then this should always be the case. In practice, the harder it is to collect the data, the harder it is to get a large sample size. Thus, #4 (low $\beta$, insignficant t) is often interpreted as a low or non-existent effect. However, if the sample size is not sufficiently large, then #2 (high $\beta$, insignficant t) cannot be ruled out as a non-existent effect. It simply means that your sample size isn't large enough for you to be sure, but there might indeed be an effect.
|
Is a larger beta weight a better predictor than a high t-statistic?
|
$\beta$ and t-stat tell very different bits of information about a variable's effect in a statistical model and they are not exchangeable:
$\beta$ (standardized effect size) is far more important. It
|
Is a larger beta weight a better predictor than a high t-statistic?
$\beta$ and t-stat tell very different bits of information about a variable's effect in a statistical model and they are not exchangeable:
$\beta$ (standardized effect size) is far more important. It tells how strong or meaningful the effect is. B (unstandardized effect size) is usually easier to interpret and so is preferred to explain what the results actually mean in real-world terms, but $\beta$ (standardized effect size) is more useful for comparing the relative strength of effects between various variables, since the B measures are on different scales.
t-stat (statistical significance) is also important, but it only tells you how reliable the measure of $\beta$ is. That's all it does. It absolutely does not tell you how important a variable is, and although it is very, very widely misused in that way, that is a misuse. (The same, of course, applies not only to the t-stat, but to all measures of statistical significance.)
Taken together, the $\beta$ and t-stat give you the effect size and how reliable is the estimation of the effect size. There are four general possible scenarios:
High $\beta$ and signficant t-stat: The high $\beta$ means that the variable is indeed important and the significant t means that you can trust that the high $\beta$ is reliable.
High $\beta$ but insignficant t-stat: The high $\beta$ means that the variable is possibly important, but the insignificant t means that you cannot trust this result because your sample size is too small for you to be confident in the results.
Low $\beta$ but signficant t-stat: The low $\beta$ means that the variable is not important and the significant t means that you can trust that the low $\beta$ is reliable.
Low $\beta$ and insignficant t-stat: The low $\beta$ means that the variable is possibly not important, but the insignificant t means that you cannot trust this result because your sample size is too small for you to be confident in the results. However, since an unimportant effect of the variable would require a very large sample to register a significant t, if the sample is reasonably large and $\beta$ is quite low, it is reasonable to conclude that the variable probably has very little, if any, effect.
In an ideal world, all t-stats should always be statistically significant; if you have a huge sample size, then this should always be the case. In practice, the harder it is to collect the data, the harder it is to get a large sample size. Thus, #4 (low $\beta$, insignficant t) is often interpreted as a low or non-existent effect. However, if the sample size is not sufficiently large, then #2 (high $\beta$, insignficant t) cannot be ruled out as a non-existent effect. It simply means that your sample size isn't large enough for you to be sure, but there might indeed be an effect.
|
Is a larger beta weight a better predictor than a high t-statistic?
$\beta$ and t-stat tell very different bits of information about a variable's effect in a statistical model and they are not exchangeable:
$\beta$ (standardized effect size) is far more important. It
|
45,874
|
Is a larger beta weight a better predictor than a high t-statistic?
|
You're getting at two distinct concepts:
Statistical significance
Material significance, some notion of practical significance.
In economics, people call number (2) economic significance. In biology, I imagine they call it biological significance.
Statistical significance can be seen from the p-value (assuming your standard errors etc... are done properly). Material significance, economic significance is a more field, problem specific question.
Is a 0.05% difference in return materially important? Almost certainly no for high risk venture capital investing, but almost certainly yes for short term rates on near risk free securities.
Is aerodynamic drag requiring 5 watts of power at 25 mph materially important? Almost certainly not for a car, but quite possibly yes for a pro racing cyclist.
Does a big number imply material significance?
Of course not because you can always make a number big by measuring in tiny units!
What if you standardize a variable by its standard error, making the estimated coefficient at least invariant to units?
This may be better, but as @Gung discusses, it still doesn't answer how this effect relates to other effects. Is the $\beta$ in question measuring the effect of a small brook flowing into the Niagra river while the massive Niagra falls is nearby?
Answering the question of whether an effect is materially important is inherently field and problem specific. Generally speaking, you want to capture the materially important effects when forecasting.
|
Is a larger beta weight a better predictor than a high t-statistic?
|
You're getting at two distinct concepts:
Statistical significance
Material significance, some notion of practical significance.
In economics, people call number (2) economic significance. In biology
|
Is a larger beta weight a better predictor than a high t-statistic?
You're getting at two distinct concepts:
Statistical significance
Material significance, some notion of practical significance.
In economics, people call number (2) economic significance. In biology, I imagine they call it biological significance.
Statistical significance can be seen from the p-value (assuming your standard errors etc... are done properly). Material significance, economic significance is a more field, problem specific question.
Is a 0.05% difference in return materially important? Almost certainly no for high risk venture capital investing, but almost certainly yes for short term rates on near risk free securities.
Is aerodynamic drag requiring 5 watts of power at 25 mph materially important? Almost certainly not for a car, but quite possibly yes for a pro racing cyclist.
Does a big number imply material significance?
Of course not because you can always make a number big by measuring in tiny units!
What if you standardize a variable by its standard error, making the estimated coefficient at least invariant to units?
This may be better, but as @Gung discusses, it still doesn't answer how this effect relates to other effects. Is the $\beta$ in question measuring the effect of a small brook flowing into the Niagra river while the massive Niagra falls is nearby?
Answering the question of whether an effect is materially important is inherently field and problem specific. Generally speaking, you want to capture the materially important effects when forecasting.
|
Is a larger beta weight a better predictor than a high t-statistic?
You're getting at two distinct concepts:
Statistical significance
Material significance, some notion of practical significance.
In economics, people call number (2) economic significance. In biology
|
45,875
|
Is a larger beta weight a better predictor than a high t-statistic?
|
Beta weight itself does not say much.You should also consider its standart deviation, therefore t statistic is better for you to understand which variable(a or b) has a greater effect.
|
Is a larger beta weight a better predictor than a high t-statistic?
|
Beta weight itself does not say much.You should also consider its standart deviation, therefore t statistic is better for you to understand which variable(a or b) has a greater effect.
|
Is a larger beta weight a better predictor than a high t-statistic?
Beta weight itself does not say much.You should also consider its standart deviation, therefore t statistic is better for you to understand which variable(a or b) has a greater effect.
|
Is a larger beta weight a better predictor than a high t-statistic?
Beta weight itself does not say much.You should also consider its standart deviation, therefore t statistic is better for you to understand which variable(a or b) has a greater effect.
|
45,876
|
Using Duan Smear factor on a two-part model
|
The OLS model is the model of expected cost given that there is a non-zero cost. Therefore by conditionality principal you simply don't use the data that has zero observed cost when fitting that part of the model.
Reading between the lines I'm guessing your real issue is how to calculate the Duan factors. The duan factors are usually calculated by using the residuals and so without getting the residuals how do you calculate the duan factors?
The key here is to look carefully at the model and think about what the Duan factors are there for.
You want to know the expected loss $E[L]$. This is given by the expected loss given non-zero loss times the probability of loss, $E[L] = E[L|L>0]P(L>0)$. The Duan factors come in because you are not fitting your model to $E[L|L>0]$, but rather to $E[\log(L)|L>0]$. The Duan Smearing attempts to correct for this bias using the residuals of the fit. It should now be clear that the correct thing to do here is to only use the residuals from the OLS fit when calculating the DS factor.
Effectively treat this as two separate bits of analysis. First discard all the zero losses, then with the data that remains fit your OLS model and calculate the DS factor. The put your dataset back together and fit the logistic model.
|
Using Duan Smear factor on a two-part model
|
The OLS model is the model of expected cost given that there is a non-zero cost. Therefore by conditionality principal you simply don't use the data that has zero observed cost when fitting that part
|
Using Duan Smear factor on a two-part model
The OLS model is the model of expected cost given that there is a non-zero cost. Therefore by conditionality principal you simply don't use the data that has zero observed cost when fitting that part of the model.
Reading between the lines I'm guessing your real issue is how to calculate the Duan factors. The duan factors are usually calculated by using the residuals and so without getting the residuals how do you calculate the duan factors?
The key here is to look carefully at the model and think about what the Duan factors are there for.
You want to know the expected loss $E[L]$. This is given by the expected loss given non-zero loss times the probability of loss, $E[L] = E[L|L>0]P(L>0)$. The Duan factors come in because you are not fitting your model to $E[L|L>0]$, but rather to $E[\log(L)|L>0]$. The Duan Smearing attempts to correct for this bias using the residuals of the fit. It should now be clear that the correct thing to do here is to only use the residuals from the OLS fit when calculating the DS factor.
Effectively treat this as two separate bits of analysis. First discard all the zero losses, then with the data that remains fit your OLS model and calculate the DS factor. The put your dataset back together and fit the logistic model.
|
Using Duan Smear factor on a two-part model
The OLS model is the model of expected cost given that there is a non-zero cost. Therefore by conditionality principal you simply don't use the data that has zero observed cost when fitting that part
|
45,877
|
Using Duan Smear factor on a two-part model
|
I have not seen the Duan smearing correction used in this way, but at first blush, it seems sensible. Here's the intuition.
The general re-transformation problem we have is that we want to get \begin{equation}E[y_i \vert x_i]=\exp (x_i'\beta) \cdot E[\exp (u_i)].\end{equation} For the first term, you can use the exponentiated prediction from the logged model. The second is more tricky. If we assume normality and independence, we can approximate the second term with $\exp (\frac{\hat \sigma^2}{2}),$ where we use the RMSE from the logged regression for the unobserved $\sigma$. Or we can use a weaker assumption of $iid$ on $u_i$, and use the sample average of the exponentiated residuals from the logged model for the second term.* That's the Duan "smearing" approach.
If you have access to Cameron and Trivedi's Microeconometrics Using Stata, take a look at chapter 16, in general, and table 16.2, in particular. There they give expressions for the conditional and unconditional means of expenditure when the outcome is in logs.
However, they are using a probit for the first stage, and making assumptions about joint normality and homoskedasticity of the errors in the two stages, so it's a slightly different model than the weaker $iid $ assumptions of the Duan approach with the logit. But the intuition carries over.
Combining the intuition from the first paragraph and their table, we have that \begin{equation}E[y_2 \mid x,y_2>0 ] = \exp (x_2' \beta) \cdot \exp( \frac{ \sigma^2_2}{2} )\end{equation} and \begin{equation}E[y_2 \mid x ] = \exp (x_2' \beta) \cdot \exp(\frac{ \sigma^2_2}{2} ) \cdot \Phi(x_1' \beta).\end{equation} The $\sigma_2$ is the variance in the logged expenditure equation, which you can approximate as above. The subscripts indicate the stage (since you can have different predictors). The $\Phi$ is just the probability of going to see the doc from the probit first stage, which is like your logit.
Thus, it seems that as long as you maintain the assumption that the two stages are independent, all you need to do is multiply by $\frac{1}{N}\sum_i^N \exp (\hat u_i)$ if you want the expected positive expenditure. You will also need to create out of sample predictions for the expenditure for those who did not get to see the doc.
Addendum:
Stata now has the a user-written tpmcommand that deals really nicely with this problem.
* If you're worried about heteroskedasticity, you might try smearing by group. For example, you might try an age-group specific average residual.
|
Using Duan Smear factor on a two-part model
|
I have not seen the Duan smearing correction used in this way, but at first blush, it seems sensible. Here's the intuition.
The general re-transformation problem we have is that we want to get \begin{
|
Using Duan Smear factor on a two-part model
I have not seen the Duan smearing correction used in this way, but at first blush, it seems sensible. Here's the intuition.
The general re-transformation problem we have is that we want to get \begin{equation}E[y_i \vert x_i]=\exp (x_i'\beta) \cdot E[\exp (u_i)].\end{equation} For the first term, you can use the exponentiated prediction from the logged model. The second is more tricky. If we assume normality and independence, we can approximate the second term with $\exp (\frac{\hat \sigma^2}{2}),$ where we use the RMSE from the logged regression for the unobserved $\sigma$. Or we can use a weaker assumption of $iid$ on $u_i$, and use the sample average of the exponentiated residuals from the logged model for the second term.* That's the Duan "smearing" approach.
If you have access to Cameron and Trivedi's Microeconometrics Using Stata, take a look at chapter 16, in general, and table 16.2, in particular. There they give expressions for the conditional and unconditional means of expenditure when the outcome is in logs.
However, they are using a probit for the first stage, and making assumptions about joint normality and homoskedasticity of the errors in the two stages, so it's a slightly different model than the weaker $iid $ assumptions of the Duan approach with the logit. But the intuition carries over.
Combining the intuition from the first paragraph and their table, we have that \begin{equation}E[y_2 \mid x,y_2>0 ] = \exp (x_2' \beta) \cdot \exp( \frac{ \sigma^2_2}{2} )\end{equation} and \begin{equation}E[y_2 \mid x ] = \exp (x_2' \beta) \cdot \exp(\frac{ \sigma^2_2}{2} ) \cdot \Phi(x_1' \beta).\end{equation} The $\sigma_2$ is the variance in the logged expenditure equation, which you can approximate as above. The subscripts indicate the stage (since you can have different predictors). The $\Phi$ is just the probability of going to see the doc from the probit first stage, which is like your logit.
Thus, it seems that as long as you maintain the assumption that the two stages are independent, all you need to do is multiply by $\frac{1}{N}\sum_i^N \exp (\hat u_i)$ if you want the expected positive expenditure. You will also need to create out of sample predictions for the expenditure for those who did not get to see the doc.
Addendum:
Stata now has the a user-written tpmcommand that deals really nicely with this problem.
* If you're worried about heteroskedasticity, you might try smearing by group. For example, you might try an age-group specific average residual.
|
Using Duan Smear factor on a two-part model
I have not seen the Duan smearing correction used in this way, but at first blush, it seems sensible. Here's the intuition.
The general re-transformation problem we have is that we want to get \begin{
|
45,878
|
Methods for evaluating predictive models in two-outcome systems
|
The following is taken from a related answer I gave here:
Suppose your model does indeed predict A has a 40% chance and B has a 60% chance. In some circumstances you might wish to convert this into a classification that B will happen (since it is more likely than A). Once converted into a classification, every prediction is either right or wrong, and there are a number of interesting ways to tally those right and wrong answers. One is straight accuracy (the percentage of right answers). Others include precision and recall or F-measure. As others have mentioned, you may wish to look at the ROC curve. Furthermore, your context may supply a specific cost matrix that rewards true positives differently from true negatives and/or penalizes false positives differently from false negatives.
However, I don't think that's what you are really looking for. If you said B has a 60% chance of happening and I said it had a 99% chance of happening, we have very different predictions even though they would both get mapped to B in a simple classification system. If A happens instead, you are just kind of wrong while I am very wrong, so I'd hope that I would receive a stiffer penalty than you. When your model actually produces probabilities, a scoring rule is a measure of performance of your probability predictions. Specifically you probably want a proper scoring rule, meaning that the score is optimized for well-calibrated results.
A common example of a scoring rule is the Brier score: $$BS = \frac{1}{N}\sum\limits _{t=1}^{N}(f_t-o_t)^2$$ where $f_t$ is the forecasted probability of the event happening and $o_t$ is 1 if the event did happen and 0 if it did not.
Of course the type of scoring rule you choose might depend on what type of event you are trying to predict. However, this should give you some ideas to research further.
I'll add a caveat that regardless of what you do, when assessing your model this way I suggest you look at your metric on out-of-sample data (that is, data not used to build your model). This can be done through cross-validation. Perhaps more simply you can build your model on one dataset and then assess it on another (being careful not to let inferences from the out-of-sample spill into the in-sample modeling).
As for your 2nd point about comparing the methods, in short, yes some methods are different. You might be interested in Some Comparisons among Quadratic,
Spherical, and Logarithmic Scoring Rules by J. Eric Bickel. You might also be interested in Winkler and Murphy's Nonlinear Utility and the Probability Score. With nonlinear utility functions, risk-taking modelers will prefer to reports probabilities closer to certainty (towards 0 or 1 probability) whereas risk-avoiders will prefer to hedge to probabilities closer to .5 (or $\frac{1}{R}$ in the case of $R$ classes).
As for your 3rd point about translating to more than two outcomes, there are two main approaches I know of. One would be to calculate a separate score for each type of event. So if there are events A, B, and C, we create one score for forecasting A vs. not A, one for B vs. not B, and one for C vs. not C. In effect this turns our problem into many binary problems. The other approach is to effectively sum the scores over all classes. In the case of the Brier score that would look like this (assuming $R$ distinct classes): $$ BS = \frac{1}{N}\sum\limits _{t=1}^{N}\sum\limits _{i=1}^{R}(f_{ti}-o_{ti})^2$$
|
Methods for evaluating predictive models in two-outcome systems
|
The following is taken from a related answer I gave here:
Suppose your model does indeed predict A has a 40% chance and B has a 60% chance. In some circumstances you might wish to convert this into
|
Methods for evaluating predictive models in two-outcome systems
The following is taken from a related answer I gave here:
Suppose your model does indeed predict A has a 40% chance and B has a 60% chance. In some circumstances you might wish to convert this into a classification that B will happen (since it is more likely than A). Once converted into a classification, every prediction is either right or wrong, and there are a number of interesting ways to tally those right and wrong answers. One is straight accuracy (the percentage of right answers). Others include precision and recall or F-measure. As others have mentioned, you may wish to look at the ROC curve. Furthermore, your context may supply a specific cost matrix that rewards true positives differently from true negatives and/or penalizes false positives differently from false negatives.
However, I don't think that's what you are really looking for. If you said B has a 60% chance of happening and I said it had a 99% chance of happening, we have very different predictions even though they would both get mapped to B in a simple classification system. If A happens instead, you are just kind of wrong while I am very wrong, so I'd hope that I would receive a stiffer penalty than you. When your model actually produces probabilities, a scoring rule is a measure of performance of your probability predictions. Specifically you probably want a proper scoring rule, meaning that the score is optimized for well-calibrated results.
A common example of a scoring rule is the Brier score: $$BS = \frac{1}{N}\sum\limits _{t=1}^{N}(f_t-o_t)^2$$ where $f_t$ is the forecasted probability of the event happening and $o_t$ is 1 if the event did happen and 0 if it did not.
Of course the type of scoring rule you choose might depend on what type of event you are trying to predict. However, this should give you some ideas to research further.
I'll add a caveat that regardless of what you do, when assessing your model this way I suggest you look at your metric on out-of-sample data (that is, data not used to build your model). This can be done through cross-validation. Perhaps more simply you can build your model on one dataset and then assess it on another (being careful not to let inferences from the out-of-sample spill into the in-sample modeling).
As for your 2nd point about comparing the methods, in short, yes some methods are different. You might be interested in Some Comparisons among Quadratic,
Spherical, and Logarithmic Scoring Rules by J. Eric Bickel. You might also be interested in Winkler and Murphy's Nonlinear Utility and the Probability Score. With nonlinear utility functions, risk-taking modelers will prefer to reports probabilities closer to certainty (towards 0 or 1 probability) whereas risk-avoiders will prefer to hedge to probabilities closer to .5 (or $\frac{1}{R}$ in the case of $R$ classes).
As for your 3rd point about translating to more than two outcomes, there are two main approaches I know of. One would be to calculate a separate score for each type of event. So if there are events A, B, and C, we create one score for forecasting A vs. not A, one for B vs. not B, and one for C vs. not C. In effect this turns our problem into many binary problems. The other approach is to effectively sum the scores over all classes. In the case of the Brier score that would look like this (assuming $R$ distinct classes): $$ BS = \frac{1}{N}\sum\limits _{t=1}^{N}\sum\limits _{i=1}^{R}(f_{ti}-o_{ti})^2$$
|
Methods for evaluating predictive models in two-outcome systems
The following is taken from a related answer I gave here:
Suppose your model does indeed predict A has a 40% chance and B has a 60% chance. In some circumstances you might wish to convert this into
|
45,879
|
Methods for evaluating predictive models in two-outcome systems
|
Predictive accuracy and AUC are quite limited in certain aspects. Try the Bayesian Information Reward (BIR), which addresses all your bullet points.
The intuition of BIR is as follows: a bettor is rewarded not just for identifying the ultimate winners and losers (0's and 1's), but more importantly for identifying the appropriate odds. Furthermore, it goes a step ahead and compares all predictions with the prior probabilities.
Let's say you have a list of 10 Arsenal games with possible outcomes: Win or Lose. The formula for binary classification rewarding per game is:
where, p is your model's prediction for a particular football game, and p' is the prior probability of Arsenal winning the game. As you can see, you treat the correct and incorrect classifications differently. For instance, if I know beforehand that p'=0.6, and my predictor model produced p =0.6, it is rewarded 0 since it is not conveying any new information.
BIR is not limited to binary classifications but is generalised for multinomial classification problems as well.
|
Methods for evaluating predictive models in two-outcome systems
|
Predictive accuracy and AUC are quite limited in certain aspects. Try the Bayesian Information Reward (BIR), which addresses all your bullet points.
The intuition of BIR is as follows: a bettor is rew
|
Methods for evaluating predictive models in two-outcome systems
Predictive accuracy and AUC are quite limited in certain aspects. Try the Bayesian Information Reward (BIR), which addresses all your bullet points.
The intuition of BIR is as follows: a bettor is rewarded not just for identifying the ultimate winners and losers (0's and 1's), but more importantly for identifying the appropriate odds. Furthermore, it goes a step ahead and compares all predictions with the prior probabilities.
Let's say you have a list of 10 Arsenal games with possible outcomes: Win or Lose. The formula for binary classification rewarding per game is:
where, p is your model's prediction for a particular football game, and p' is the prior probability of Arsenal winning the game. As you can see, you treat the correct and incorrect classifications differently. For instance, if I know beforehand that p'=0.6, and my predictor model produced p =0.6, it is rewarded 0 since it is not conveying any new information.
BIR is not limited to binary classifications but is generalised for multinomial classification problems as well.
|
Methods for evaluating predictive models in two-outcome systems
Predictive accuracy and AUC are quite limited in certain aspects. Try the Bayesian Information Reward (BIR), which addresses all your bullet points.
The intuition of BIR is as follows: a bettor is rew
|
45,880
|
Methods for evaluating predictive models in two-outcome systems
|
The idea of concordance probability ($c$-index; ROC area) is a special case of a $U$-statistic. A $U$-statistic is available for testing what you want by asking the following question: How much more concordant with the outcome is model 1 than model 2? "More concordant" can be taken to mean that in a pair of observations, model 1's predictions are concordant but model 2's are not. Or it can be taken to mean that model 1 is concordant and 2 is not, or if both are concordant, the spread of predictions from model 1 is larger than the two predictions from model 2.
This provides a method for comparing predictive discrimination of two models that is much more powerful than comparing two ROC areas because the pairings of observations are preserved. The method requires no arbitrary dichotomization.
This is implemented in the R Hmisc package's rcorrp.cens function.
|
Methods for evaluating predictive models in two-outcome systems
|
The idea of concordance probability ($c$-index; ROC area) is a special case of a $U$-statistic. A $U$-statistic is available for testing what you want by asking the following question: How much more
|
Methods for evaluating predictive models in two-outcome systems
The idea of concordance probability ($c$-index; ROC area) is a special case of a $U$-statistic. A $U$-statistic is available for testing what you want by asking the following question: How much more concordant with the outcome is model 1 than model 2? "More concordant" can be taken to mean that in a pair of observations, model 1's predictions are concordant but model 2's are not. Or it can be taken to mean that model 1 is concordant and 2 is not, or if both are concordant, the spread of predictions from model 1 is larger than the two predictions from model 2.
This provides a method for comparing predictive discrimination of two models that is much more powerful than comparing two ROC areas because the pairings of observations are preserved. The method requires no arbitrary dichotomization.
This is implemented in the R Hmisc package's rcorrp.cens function.
|
Methods for evaluating predictive models in two-outcome systems
The idea of concordance probability ($c$-index; ROC area) is a special case of a $U$-statistic. A $U$-statistic is available for testing what you want by asking the following question: How much more
|
45,881
|
For "Was this page helpful" data, should I take response rate into account?
|
In answer to your question, you should take response rate into account as it is giving you extra information.
The point is that if there are pages with low response rates and low ratings, then it is possible that many people were looking for different information, rather than judging the quality of the page, and that some of those who did rate were say that the information did not help their particular situation, rather than being low quality. You need to investigate what question they actually wanted to ask which led them to that particular page to see what might be missing.
|
For "Was this page helpful" data, should I take response rate into account?
|
In answer to your question, you should take response rate into account as it is giving you extra information.
The point is that if there are pages with low response rates and low ratings, then it is
|
For "Was this page helpful" data, should I take response rate into account?
In answer to your question, you should take response rate into account as it is giving you extra information.
The point is that if there are pages with low response rates and low ratings, then it is possible that many people were looking for different information, rather than judging the quality of the page, and that some of those who did rate were say that the information did not help their particular situation, rather than being low quality. You need to investigate what question they actually wanted to ask which led them to that particular page to see what might be missing.
|
For "Was this page helpful" data, should I take response rate into account?
In answer to your question, you should take response rate into account as it is giving you extra information.
The point is that if there are pages with low response rates and low ratings, then it is
|
45,882
|
For "Was this page helpful" data, should I take response rate into account?
|
Requests of this type often get answers from two groups: The extremely pleased and extremely displeased, while people who are sort of generally satisfied don't bother. Although I don't know of research into page ratings specifically, I've seen this with response cards in other situations (e.g. rating of hotel service).
|
For "Was this page helpful" data, should I take response rate into account?
|
Requests of this type often get answers from two groups: The extremely pleased and extremely displeased, while people who are sort of generally satisfied don't bother. Although I don't know of researc
|
For "Was this page helpful" data, should I take response rate into account?
Requests of this type often get answers from two groups: The extremely pleased and extremely displeased, while people who are sort of generally satisfied don't bother. Although I don't know of research into page ratings specifically, I've seen this with response cards in other situations (e.g. rating of hotel service).
|
For "Was this page helpful" data, should I take response rate into account?
Requests of this type often get answers from two groups: The extremely pleased and extremely displeased, while people who are sort of generally satisfied don't bother. Although I don't know of researc
|
45,883
|
Required conditions for using a t-test
|
First, you have to understand why there are two tests, for a same quantity. Let's say you have a sample $x_1, \dots, x_n$, drawn from an unknown distribution and you want to test if the mean of the distribution is zero or not.
So you compute the sample mean $\overline x = {1\over n} \sum_{i=1}^n x_i$. And you compute the sample variance $s^2 = {1\over n-1} \sum_{i=1}^n (x_i-\overline x)^2$. And finally, you reduce $\overline x$ by the standard error $s = \sqrt{s^2}$, considering ${\overline x \over s/\sqrt n}$.
There are two cases :
the underlying distribution is normal ; then ${\overline x \over s/\sqrt n}$ is distributed like a $t$ distribution (if the mean is zero), and you use a $t$ test. This is an exact procedure.
you don’t know whether the underlying distribution is normal or not. If $n$ is big enough, the central limit theorem tells you that ${\overline x \over s/\sqrt n}$ is approximately distributed like a standard normal distribution (if the mean is zero), and you use a $z$ test. This is an approximate procedure.
What you were stating are just guidelines to help you decide if the assumptions required for $t$ test are satisfied.
I don’t get rule 3. For me, it is just false. If the distribution is skewed, it is not normal, and you have no reason to think that the $t$ test will perform better than the $z$ test.
|
Required conditions for using a t-test
|
First, you have to understand why there are two tests, for a same quantity. Let's say you have a sample $x_1, \dots, x_n$, drawn from an unknown distribution and you want to test if the mean of the di
|
Required conditions for using a t-test
First, you have to understand why there are two tests, for a same quantity. Let's say you have a sample $x_1, \dots, x_n$, drawn from an unknown distribution and you want to test if the mean of the distribution is zero or not.
So you compute the sample mean $\overline x = {1\over n} \sum_{i=1}^n x_i$. And you compute the sample variance $s^2 = {1\over n-1} \sum_{i=1}^n (x_i-\overline x)^2$. And finally, you reduce $\overline x$ by the standard error $s = \sqrt{s^2}$, considering ${\overline x \over s/\sqrt n}$.
There are two cases :
the underlying distribution is normal ; then ${\overline x \over s/\sqrt n}$ is distributed like a $t$ distribution (if the mean is zero), and you use a $t$ test. This is an exact procedure.
you don’t know whether the underlying distribution is normal or not. If $n$ is big enough, the central limit theorem tells you that ${\overline x \over s/\sqrt n}$ is approximately distributed like a standard normal distribution (if the mean is zero), and you use a $z$ test. This is an approximate procedure.
What you were stating are just guidelines to help you decide if the assumptions required for $t$ test are satisfied.
I don’t get rule 3. For me, it is just false. If the distribution is skewed, it is not normal, and you have no reason to think that the $t$ test will perform better than the $z$ test.
|
Required conditions for using a t-test
First, you have to understand why there are two tests, for a same quantity. Let's say you have a sample $x_1, \dots, x_n$, drawn from an unknown distribution and you want to test if the mean of the di
|
45,884
|
Required conditions for using a t-test
|
You can actually use the t-test if you like -- it's just more conservative. As your sample size grows larger, the Central Limit Theorem says that the distribution of your mean approaches a normal distribution, regardless of the underlying population distribution. Therefore, you can use the Z-test, since that compares your statistic with a normal distribution.
|
Required conditions for using a t-test
|
You can actually use the t-test if you like -- it's just more conservative. As your sample size grows larger, the Central Limit Theorem says that the distribution of your mean approaches a normal dis
|
Required conditions for using a t-test
You can actually use the t-test if you like -- it's just more conservative. As your sample size grows larger, the Central Limit Theorem says that the distribution of your mean approaches a normal distribution, regardless of the underlying population distribution. Therefore, you can use the Z-test, since that compares your statistic with a normal distribution.
|
Required conditions for using a t-test
You can actually use the t-test if you like -- it's just more conservative. As your sample size grows larger, the Central Limit Theorem says that the distribution of your mean approaches a normal dis
|
45,885
|
Required conditions for using a t-test
|
I believe the reason for the third rule is in its need to adhere to CLT, and therefore be nearly normal. CLT states that a sampling distribution model is relatively normal for a large sampling frame, regardless of the distribution of the population, as long as the sampled individuals are independent.
This 10% rule is to protect the independence of the sampled individuals when sampling without replacement by sampling only a small fraction of the population, assuring that any relation can be generally minimized by randomization.
If you want to see the mechanics on why this percentage is chosen, University of Texas explains it more in depth here: https://web.ma.utexas.edu/users/mks/M358KInstr/TenPctCond.pdf [WHERE DOES THE 10% CONDITION COME FROM?][1],
But I sourced my general information off of "Stats, Modeling the World" 1st ed.
|
Required conditions for using a t-test
|
I believe the reason for the third rule is in its need to adhere to CLT, and therefore be nearly normal. CLT states that a sampling distribution model is relatively normal for a large sampling frame,
|
Required conditions for using a t-test
I believe the reason for the third rule is in its need to adhere to CLT, and therefore be nearly normal. CLT states that a sampling distribution model is relatively normal for a large sampling frame, regardless of the distribution of the population, as long as the sampled individuals are independent.
This 10% rule is to protect the independence of the sampled individuals when sampling without replacement by sampling only a small fraction of the population, assuring that any relation can be generally minimized by randomization.
If you want to see the mechanics on why this percentage is chosen, University of Texas explains it more in depth here: https://web.ma.utexas.edu/users/mks/M358KInstr/TenPctCond.pdf [WHERE DOES THE 10% CONDITION COME FROM?][1],
But I sourced my general information off of "Stats, Modeling the World" 1st ed.
|
Required conditions for using a t-test
I believe the reason for the third rule is in its need to adhere to CLT, and therefore be nearly normal. CLT states that a sampling distribution model is relatively normal for a large sampling frame,
|
45,886
|
Required conditions for using a t-test
|
I don't see the necessity for the comparison. T-test and Z-test I believe, operate under different conditions. T-test is Parametric, while Z-test is one of the known four nonparametric equivalent. Please somebody should correct me if my assumption wrong.
|
Required conditions for using a t-test
|
I don't see the necessity for the comparison. T-test and Z-test I believe, operate under different conditions. T-test is Parametric, while Z-test is one of the known four nonparametric equivalent. Ple
|
Required conditions for using a t-test
I don't see the necessity for the comparison. T-test and Z-test I believe, operate under different conditions. T-test is Parametric, while Z-test is one of the known four nonparametric equivalent. Please somebody should correct me if my assumption wrong.
|
Required conditions for using a t-test
I don't see the necessity for the comparison. T-test and Z-test I believe, operate under different conditions. T-test is Parametric, while Z-test is one of the known four nonparametric equivalent. Ple
|
45,887
|
Expected value of a transformed random variable
|
In general, the expectation of $g(X)$ can often be approximated using a Taylor expansion around the mean; let $a=E(X)$
$$g(X) = g(a) + g'(a) (X-a) + \frac{1}{2!}g''(a) (X-a)^2 +\cdots$$
$$E[g(X)] = g(a) + \frac{1}{2!}g^{(2)}(a) \, m_2 + \frac{1}{3!} g^{(3)}(a) \, m_3 + \cdots $$
where $g^{(n)}(a)$ is the $n-$th derivative of $g(X)$ evaluated at the mean, and $m_k$ is the $k-$th centered moment of $X$.
In our case, $g(X)=X \log(X)$ and $g^{(n)}(a) = (-1)^n (n-2)! \; a^{-(n-1)}$ for $n>1$
So the expasion takes the form
$$ E[X \log X] \approx a \log a + \frac{1} {2 \times 1} \frac{m_2}{a} - \frac{1}{3 \times 2}\frac{m_3}{a^2} + \frac{1} {4 \times 3}\frac{m_4}{a^3} -\cdots$$
For the Binomial $(N,p)$, we get
$$ E[X \log X] \approx Np \log( Np) + \frac{1-p}{2} - \frac{(1-p)(1-2p)}{6 Np } + \cdots$$
And for the Hypergeometrix $(N, n, m)$
$$ E[X \log X] \approx a \log(a) + \frac{m}{2 (n+m)} - \cdots$$
where $a=E(X)=\frac{n N}{m+n}$ and i was too lazy to compute the next term.
It's seen that these are useful as asymptotic expansions, for $N \to \infty$.
For finite $N$, this should be not be used if $a \lesssim 1$.
Here are a few values, for the Binomial aproximation up to the third moment:
p=0.2 p=0.5 p=0.8
exact approx exact approx exact approx
N 5 0.4907 0.3200 2.5811 2.5407 5.6542 5.6502
N 10 1.8545 1.7463 8.3123 8.2972 16.740 16.738
N 20 5.9740 5.9252 23.283 23.276 44.463 44.463
As cardinal points out in the comments, using the mean-value form for the error of the truncated Taylor expansion, if we truncate at an odd-moment term, (as I did for the Binomial above) we see that the error must be positive, and hence we have obtained a lower bound of the exact value. This can also be proven using Jensen's inequality, because $g(x)=x \log x$ is a convex function.
|
Expected value of a transformed random variable
|
In general, the expectation of $g(X)$ can often be approximated using a Taylor expansion around the mean; let $a=E(X)$
$$g(X) = g(a) + g'(a) (X-a) + \frac{1}{2!}g''(a) (X-a)^2 +\cdots$$
$$E[g(X)] = g(
|
Expected value of a transformed random variable
In general, the expectation of $g(X)$ can often be approximated using a Taylor expansion around the mean; let $a=E(X)$
$$g(X) = g(a) + g'(a) (X-a) + \frac{1}{2!}g''(a) (X-a)^2 +\cdots$$
$$E[g(X)] = g(a) + \frac{1}{2!}g^{(2)}(a) \, m_2 + \frac{1}{3!} g^{(3)}(a) \, m_3 + \cdots $$
where $g^{(n)}(a)$ is the $n-$th derivative of $g(X)$ evaluated at the mean, and $m_k$ is the $k-$th centered moment of $X$.
In our case, $g(X)=X \log(X)$ and $g^{(n)}(a) = (-1)^n (n-2)! \; a^{-(n-1)}$ for $n>1$
So the expasion takes the form
$$ E[X \log X] \approx a \log a + \frac{1} {2 \times 1} \frac{m_2}{a} - \frac{1}{3 \times 2}\frac{m_3}{a^2} + \frac{1} {4 \times 3}\frac{m_4}{a^3} -\cdots$$
For the Binomial $(N,p)$, we get
$$ E[X \log X] \approx Np \log( Np) + \frac{1-p}{2} - \frac{(1-p)(1-2p)}{6 Np } + \cdots$$
And for the Hypergeometrix $(N, n, m)$
$$ E[X \log X] \approx a \log(a) + \frac{m}{2 (n+m)} - \cdots$$
where $a=E(X)=\frac{n N}{m+n}$ and i was too lazy to compute the next term.
It's seen that these are useful as asymptotic expansions, for $N \to \infty$.
For finite $N$, this should be not be used if $a \lesssim 1$.
Here are a few values, for the Binomial aproximation up to the third moment:
p=0.2 p=0.5 p=0.8
exact approx exact approx exact approx
N 5 0.4907 0.3200 2.5811 2.5407 5.6542 5.6502
N 10 1.8545 1.7463 8.3123 8.2972 16.740 16.738
N 20 5.9740 5.9252 23.283 23.276 44.463 44.463
As cardinal points out in the comments, using the mean-value form for the error of the truncated Taylor expansion, if we truncate at an odd-moment term, (as I did for the Binomial above) we see that the error must be positive, and hence we have obtained a lower bound of the exact value. This can also be proven using Jensen's inequality, because $g(x)=x \log x$ is a convex function.
|
Expected value of a transformed random variable
In general, the expectation of $g(X)$ can often be approximated using a Taylor expansion around the mean; let $a=E(X)$
$$g(X) = g(a) + g'(a) (X-a) + \frac{1}{2!}g''(a) (X-a)^2 +\cdots$$
$$E[g(X)] = g(
|
45,888
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
|
I like to use the caret package for predictive modeling, as it provided a unified interface to a variety of algorithms, including nnet. It's very easy to get predicted probabilities for any model that supports them, neural networks included:
set.seed(42)
require(caret)
model <- train(Species~., data=iris, method='nnet',
trControl=trainControl(method='cv'))
model
probs <- predict(model, iris, type='prob')
head(probs)
setosa versicolor virginica
1 0.9881512 0.01143536 0.0004134043
2 0.9839565 0.01550938 0.0005341130
3 0.9866016 0.01293839 0.0004599962
4 0.9820605 0.01735453 0.0005849775
5 0.9884653 0.01113064 0.0004040207
6 0.9875201 0.01204961 0.0004302507
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
|
I like to use the caret package for predictive modeling, as it provided a unified interface to a variety of algorithms, including nnet. It's very easy to get predicted probabilities for any model tha
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
I like to use the caret package for predictive modeling, as it provided a unified interface to a variety of algorithms, including nnet. It's very easy to get predicted probabilities for any model that supports them, neural networks included:
set.seed(42)
require(caret)
model <- train(Species~., data=iris, method='nnet',
trControl=trainControl(method='cv'))
model
probs <- predict(model, iris, type='prob')
head(probs)
setosa versicolor virginica
1 0.9881512 0.01143536 0.0004134043
2 0.9839565 0.01550938 0.0005341130
3 0.9866016 0.01293839 0.0004599962
4 0.9820605 0.01735453 0.0005849775
5 0.9884653 0.01113064 0.0004040207
6 0.9875201 0.01204961 0.0004302507
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
I like to use the caret package for predictive modeling, as it provided a unified interface to a variety of algorithms, including nnet. It's very easy to get predicted probabilities for any model tha
|
45,889
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
|
I would second the recommendation of an "ensemble" method such as Random Forests. There is a variant of RF, "randomSurvivalForest" that is specific to survival analysis. Here is a link to the the R manual for the package randomSurvivalForest.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
|
I would second the recommendation of an "ensemble" method such as Random Forests. There is a variant of RF, "randomSurvivalForest" that is specific to survival analysis. Here is a link to the the R ma
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
I would second the recommendation of an "ensemble" method such as Random Forests. There is a variant of RF, "randomSurvivalForest" that is specific to survival analysis. Here is a link to the the R manual for the package randomSurvivalForest.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
I would second the recommendation of an "ensemble" method such as Random Forests. There is a variant of RF, "randomSurvivalForest" that is specific to survival analysis. Here is a link to the the R ma
|
45,890
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
|
you can try for example the glm function with the family=binomial and the logit link (or the probit) doing a logistic regression, which outputs are probabilitys.. Here you have a link
logistic regression R
You also can try with trees or with "ensembles" of trees , boosting, bagging or random forest wuth packages like rpart ,randomForest etc If your dependent variable is 1/0 you will have outcomes with estimated proportions.
CART trees R
randomForest CRAN
.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
|
you can try for example the glm function with the family=binomial and the logit link (or the probit) doing a logistic regression, which outputs are probabilitys.. Here you have a link
logistic regress
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
you can try for example the glm function with the family=binomial and the logit link (or the probit) doing a logistic regression, which outputs are probabilitys.. Here you have a link
logistic regression R
You also can try with trees or with "ensembles" of trees , boosting, bagging or random forest wuth packages like rpart ,randomForest etc If your dependent variable is 1/0 you will have outcomes with estimated proportions.
CART trees R
randomForest CRAN
.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
you can try for example the glm function with the family=binomial and the logit link (or the probit) doing a logistic regression, which outputs are probabilitys.. Here you have a link
logistic regress
|
45,891
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
|
You might also want to look at package RSNNS, which provides an R interface to the package SNNS, with ample functionality for general neural networks.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
|
You might also want to look at package RSNNS, which provides an R interface to the package SNNS, with ample functionality for general neural networks.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algorithms
You might also want to look at package RSNNS, which provides an R interface to the package SNNS, with ample functionality for general neural networks.
|
Methods & CRAN packages to predict probability using neural networks or others machine learning algo
You might also want to look at package RSNNS, which provides an R interface to the package SNNS, with ample functionality for general neural networks.
|
45,892
|
R fitting Poisson distribution with weighting
|
Note that 'fitdistr does nothing but maximum likelihood estimation. That is to say, you can do it by yourself by writing down the likelihood. Below is an example for the poisson distribution in R. It can be adapted to upweight/downweight the contribution to the likelihood of each data.
density (as in R) $$f(x; \lambda) = \lambda^x \frac{\exp(-\lambda)}{x!}, \qquad \lambda > 0$$
likelihood $$L(\lambda; \mathbf{x}) = \prod_{i=1}^n \left\{ \lambda^{x_i} \frac{\exp(-\lambda)}{x_i!} \right\} $$
log-likelihood
$$\ell(\lambda; \mathbf{x}) = \sum_{i=1}^n \left\{ x_i \log(\lambda) - \lambda - \log(x_i!) \right\}$$
2nd derivatie of $\ell$:
$$ \frac{d^2 \ell}{d\lambda^2}(\lambda; \mathbf{x}) = \sum_{i=1}^n - \frac{x_i}{\lambda^2} = -\frac{1}{\lambda^2} n\bar{x}$$
#------data------
set.seed(730)
sample <- rpois(1000, 10)
#----------------
################################################################################
# Using 'fitdistr' #
################################################################################
library(MASS)
fitdistr(x=sample, densfun="Poisson")
lambda
10.1240000
( 0.1006181)
################################################################################
# writing down the log-likelihood explicitly #
################################################################################
#------minus log-likelihood------
mloglik <- function(lambda2, sample) #lambda2 = log(lambda) in (-\infty, \infty)
{
- sum(sample * lambda2 - exp(lambda2) - log(factorial(sample)))
}
#--------------------------------
#------optimisation------
res <- nlm(f=mloglik, p=1, sample=sample)
#------------------------
#------recover lambda------
lambda <- exp(res$estimate)
round(lambda, 7)
[1] 10.12399
#--------------------------
#------standard error------
#square root of negative inverse second derivative of the log-likelihood
se <- lambda / sqrt(length(sample) * mean(sample))
round(se, 7)
[1] 0.100618
#--------------------------
|
R fitting Poisson distribution with weighting
|
Note that 'fitdistr does nothing but maximum likelihood estimation. That is to say, you can do it by yourself by writing down the likelihood. Below is an example for the poisson distribution in R. It
|
R fitting Poisson distribution with weighting
Note that 'fitdistr does nothing but maximum likelihood estimation. That is to say, you can do it by yourself by writing down the likelihood. Below is an example for the poisson distribution in R. It can be adapted to upweight/downweight the contribution to the likelihood of each data.
density (as in R) $$f(x; \lambda) = \lambda^x \frac{\exp(-\lambda)}{x!}, \qquad \lambda > 0$$
likelihood $$L(\lambda; \mathbf{x}) = \prod_{i=1}^n \left\{ \lambda^{x_i} \frac{\exp(-\lambda)}{x_i!} \right\} $$
log-likelihood
$$\ell(\lambda; \mathbf{x}) = \sum_{i=1}^n \left\{ x_i \log(\lambda) - \lambda - \log(x_i!) \right\}$$
2nd derivatie of $\ell$:
$$ \frac{d^2 \ell}{d\lambda^2}(\lambda; \mathbf{x}) = \sum_{i=1}^n - \frac{x_i}{\lambda^2} = -\frac{1}{\lambda^2} n\bar{x}$$
#------data------
set.seed(730)
sample <- rpois(1000, 10)
#----------------
################################################################################
# Using 'fitdistr' #
################################################################################
library(MASS)
fitdistr(x=sample, densfun="Poisson")
lambda
10.1240000
( 0.1006181)
################################################################################
# writing down the log-likelihood explicitly #
################################################################################
#------minus log-likelihood------
mloglik <- function(lambda2, sample) #lambda2 = log(lambda) in (-\infty, \infty)
{
- sum(sample * lambda2 - exp(lambda2) - log(factorial(sample)))
}
#--------------------------------
#------optimisation------
res <- nlm(f=mloglik, p=1, sample=sample)
#------------------------
#------recover lambda------
lambda <- exp(res$estimate)
round(lambda, 7)
[1] 10.12399
#--------------------------
#------standard error------
#square root of negative inverse second derivative of the log-likelihood
se <- lambda / sqrt(length(sample) * mean(sample))
round(se, 7)
[1] 0.100618
#--------------------------
|
R fitting Poisson distribution with weighting
Note that 'fitdistr does nothing but maximum likelihood estimation. That is to say, you can do it by yourself by writing down the likelihood. Below is an example for the poisson distribution in R. It
|
45,893
|
R fitting Poisson distribution with weighting
|
If you're looking to do this just for the poisson distribution (where you're just estimating the point estimate of the one parameter lambda), you could use the glm function:
fit2 <- glm(randoms ~ 1, family = poisson(link = "log"),
weights = weighting[1:15])
As a check,
fit1 <- glm(randoms ~ 1, family = poisson(link = "log"))
all.equal(unname(exp(coef(fit1))), unname(fit$estimate))
# [1] TRUE
And another check:
randoms2 <- rep(randoms, weighting[1:15])
fit3 <- glm(randoms2 ~ 1, family = poisson(link = "log"))
all.equal(exp(coef(fit3)), exp(coef(fit2)))
# [1] TRUE
|
R fitting Poisson distribution with weighting
|
If you're looking to do this just for the poisson distribution (where you're just estimating the point estimate of the one parameter lambda), you could use the glm function:
fit2 <- glm(randoms ~ 1, f
|
R fitting Poisson distribution with weighting
If you're looking to do this just for the poisson distribution (where you're just estimating the point estimate of the one parameter lambda), you could use the glm function:
fit2 <- glm(randoms ~ 1, family = poisson(link = "log"),
weights = weighting[1:15])
As a check,
fit1 <- glm(randoms ~ 1, family = poisson(link = "log"))
all.equal(unname(exp(coef(fit1))), unname(fit$estimate))
# [1] TRUE
And another check:
randoms2 <- rep(randoms, weighting[1:15])
fit3 <- glm(randoms2 ~ 1, family = poisson(link = "log"))
all.equal(exp(coef(fit3)), exp(coef(fit2)))
# [1] TRUE
|
R fitting Poisson distribution with weighting
If you're looking to do this just for the poisson distribution (where you're just estimating the point estimate of the one parameter lambda), you could use the glm function:
fit2 <- glm(randoms ~ 1, f
|
45,894
|
R fitting Poisson distribution with weighting
|
If you look at the likelihood, the only bit of it that depends on both lambda and the x's is product lambda^x_i, which is lambda^{sum x_i}. Thus the sum of the x's, or equivalently the sample mean, is a sufficient statistic for lambda.
What that means is that you "fit a Poisson" by estimating the mean, using the sample mean. (And then you look at how well the Poisson with that mean fits your data.)
To go back to the OP's problem of weighting, all that means is that you calculate a weighted mean, and use that to estimate lambda with.
|
R fitting Poisson distribution with weighting
|
If you look at the likelihood, the only bit of it that depends on both lambda and the x's is product lambda^x_i, which is lambda^{sum x_i}. Thus the sum of the x's, or equivalently the sample mean, is
|
R fitting Poisson distribution with weighting
If you look at the likelihood, the only bit of it that depends on both lambda and the x's is product lambda^x_i, which is lambda^{sum x_i}. Thus the sum of the x's, or equivalently the sample mean, is a sufficient statistic for lambda.
What that means is that you "fit a Poisson" by estimating the mean, using the sample mean. (And then you look at how well the Poisson with that mean fits your data.)
To go back to the OP's problem of weighting, all that means is that you calculate a weighted mean, and use that to estimate lambda with.
|
R fitting Poisson distribution with weighting
If you look at the likelihood, the only bit of it that depends on both lambda and the x's is product lambda^x_i, which is lambda^{sum x_i}. Thus the sum of the x's, or equivalently the sample mean, is
|
45,895
|
Interpret regression coefficients after WLS
|
There is no change in the interpretation of the parameters since the parameters being estimated are algebraically identical between the linear regression model with heteroskedasticity and the transformed model, OLS on which gives the WLS estimator.
Let us take this at a leisurely pace.
Linear regression model
The linear regression model (potentially with heteroskedasticity) is the following
$$
\begin{align}
Y_i &= \beta_0 + \beta_1 X_{1i} + \dots + \beta_K X_{Ki} + \varepsilon_i \\
\mathbb{E}(\varepsilon_i \mid X_{1i}, \ldots, X_{Ki}) &= 0
\end{align}
$$
This is equivalent to the model for the conditional mean for $Y_i$,
$$
\mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki}) = \beta_0 + \sum_{k=1}^K \beta_k X_{ki}
$$
Interpretation of parameters
From here, we can get at the standard interpretation of the parameters of the linear regression model as marginal effects, that is
$$
\dfrac{\partial \mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki})}{\partial X_{ki}} = \beta_k
$$
This states, that the regression coefficient of a regressor is the effect of a unit change in that regressor on the conditional mean of the outcome variable. Note that this interpretation is made independent of the heteroskedasticity assumption in the model. This is the interpretation that the estimated parameters retain, for OLS and WLS.
Transformed linear regression model
Now consider that we transform the original regression model, under the assumption that the error heteroskedasticity has the following form
$$
\mathbb{E}(\varepsilon_i^2\mid X_{1i}, \ldots, X_{Ki}) = \sigma^2 X_{ki}.
$$
The transformed model is
$$
\frac{Y_i}{\sqrt{X_{ki}}} = \beta_0 \frac{1}{\sqrt{X_{ki}}} + \beta_1\frac{X_{1i}}{\sqrt{X_{ki}}} + \ldots+\beta_k \frac{X_{ki}}{\sqrt{X_{ki}}} +\ldots + \beta_K \frac{X_{Ki}}{\sqrt{X_{Ki}}} + \underbrace{\frac{\varepsilon_i}{\sqrt{X_{Ki}}}}_{\equiv \nu_i}
$$
Aside: A more usual simple model for heteroskedasticity is
$$
\mathbb{E}(\varepsilon_i^2\mid X_{1i}, \ldots, X_{Ki}) = \sigma^2 X_k^2
$$
in order to preserve the positiveness of the second moment.
Note that the model is now a classical linear regression model, since
$$
\begin{align}
\mathbb{E}(\nu_i\mid X_{1i}, \ldots, X_{Ki}) &= 0 \\
\mathbb{E}(\nu_i^2\mid X_{1i}, \ldots, X_{Ki}) &= \sigma^2
\end{align}
$$
Therefore, OLS estimates of the parameters from this transformed model (that is, the WLS estimator) are BLUE, which is the whole point of the exercise. Note that a constant should not be included in the estimation of this model. Also note that I have used the original conditioning regressors as conditioning variables, rather than the transformed regressors, since it is easy to see that the same functions are measurable with respect to the two conditioning sets.
Interpretation of parameters
The transformed model is equivalent to
$$
\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right) = \beta_0 \frac{1}{\sqrt{X_{ki}}} + \sum_{l=1}^K\beta_l\frac{X_{li}}{\sqrt{X_{ki}}}
$$
This is now the crucial part -- consider the expressions for the marginal effect on the transformed outcome w.r.t. to one of the original regressors, and w.r.t. the transformed regressors.
$$
\begin{align}
\frac{\partial \mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right)}{\partial X_{li}} &= \beta_l \frac{\partial X_{li}/\sqrt{X_{ki}}}{\partial X_{li}} \\
&= \beta_l
\end{align}
$$
The same as before! Here I have used the fact that
$$
\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right) = \frac{1}{\sqrt{X_{ki}}}\mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki})
$$
since conditioning variables are treated as constant by the expectations operator.
On the other hand, if I find the marginal effect with respect to the transformed regressor, I get
$$
\frac{\partial\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right)}{\partial \frac{X_{li}}{\sqrt{X_{ki}}}} = \beta_l \sqrt{X_{ki}}
$$
which is clearly not the same as the parameter being estimated. To elaborate, this is the interpretation you are asking about -- "are the $\beta$s estimated by WLS the effect of a unit change in the rescaled regressors?" The answer, as demonstrated here, is no.
Why this makes sense
Note that you formulate the model the way you do (in terms of the original outcomes and regressors) because you are interested in the parameters of that model (the original $\beta_k$s). Features such as heteroskedasticty reduce the efficiency of the OLS estimated parameters and you might want to correct for that using WLS, and (F)GLS. But it would be slightly counterproductive if this changed the interpretation of the model parameters that you are interested in. The key is in the way you say it -- OLS and WLS estimates of the model parameters, implying one set of population parameters being estimated by both estimators. This can be formalised by saying that the OLS and WLS parameters are consistent for the same population parameters, however, they differ in their asymptotic efficiency.
What most applied economists do
Most applied economists would rather their parameters were close to the truth with high probability as the sample size grows, i.e., that is their parameter estimates were consistent. A crucial aspect of WLS and FGLS is that they require the specification of an auxiliary model for the heteroskedasticity, in order to get at the extra efficiency afforded by those estimators. However, the price of getting this auxiliary model wrong is that the property of consistency is lost. Most applied economists prefer to simply use White robust standard errors to correct the estimates of the standard errors of OLS estimates, and live with the lower efficiency of their estimators.
|
Interpret regression coefficients after WLS
|
There is no change in the interpretation of the parameters since the parameters being estimated are algebraically identical between the linear regression model with heteroskedasticity and the transfor
|
Interpret regression coefficients after WLS
There is no change in the interpretation of the parameters since the parameters being estimated are algebraically identical between the linear regression model with heteroskedasticity and the transformed model, OLS on which gives the WLS estimator.
Let us take this at a leisurely pace.
Linear regression model
The linear regression model (potentially with heteroskedasticity) is the following
$$
\begin{align}
Y_i &= \beta_0 + \beta_1 X_{1i} + \dots + \beta_K X_{Ki} + \varepsilon_i \\
\mathbb{E}(\varepsilon_i \mid X_{1i}, \ldots, X_{Ki}) &= 0
\end{align}
$$
This is equivalent to the model for the conditional mean for $Y_i$,
$$
\mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki}) = \beta_0 + \sum_{k=1}^K \beta_k X_{ki}
$$
Interpretation of parameters
From here, we can get at the standard interpretation of the parameters of the linear regression model as marginal effects, that is
$$
\dfrac{\partial \mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki})}{\partial X_{ki}} = \beta_k
$$
This states, that the regression coefficient of a regressor is the effect of a unit change in that regressor on the conditional mean of the outcome variable. Note that this interpretation is made independent of the heteroskedasticity assumption in the model. This is the interpretation that the estimated parameters retain, for OLS and WLS.
Transformed linear regression model
Now consider that we transform the original regression model, under the assumption that the error heteroskedasticity has the following form
$$
\mathbb{E}(\varepsilon_i^2\mid X_{1i}, \ldots, X_{Ki}) = \sigma^2 X_{ki}.
$$
The transformed model is
$$
\frac{Y_i}{\sqrt{X_{ki}}} = \beta_0 \frac{1}{\sqrt{X_{ki}}} + \beta_1\frac{X_{1i}}{\sqrt{X_{ki}}} + \ldots+\beta_k \frac{X_{ki}}{\sqrt{X_{ki}}} +\ldots + \beta_K \frac{X_{Ki}}{\sqrt{X_{Ki}}} + \underbrace{\frac{\varepsilon_i}{\sqrt{X_{Ki}}}}_{\equiv \nu_i}
$$
Aside: A more usual simple model for heteroskedasticity is
$$
\mathbb{E}(\varepsilon_i^2\mid X_{1i}, \ldots, X_{Ki}) = \sigma^2 X_k^2
$$
in order to preserve the positiveness of the second moment.
Note that the model is now a classical linear regression model, since
$$
\begin{align}
\mathbb{E}(\nu_i\mid X_{1i}, \ldots, X_{Ki}) &= 0 \\
\mathbb{E}(\nu_i^2\mid X_{1i}, \ldots, X_{Ki}) &= \sigma^2
\end{align}
$$
Therefore, OLS estimates of the parameters from this transformed model (that is, the WLS estimator) are BLUE, which is the whole point of the exercise. Note that a constant should not be included in the estimation of this model. Also note that I have used the original conditioning regressors as conditioning variables, rather than the transformed regressors, since it is easy to see that the same functions are measurable with respect to the two conditioning sets.
Interpretation of parameters
The transformed model is equivalent to
$$
\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right) = \beta_0 \frac{1}{\sqrt{X_{ki}}} + \sum_{l=1}^K\beta_l\frac{X_{li}}{\sqrt{X_{ki}}}
$$
This is now the crucial part -- consider the expressions for the marginal effect on the transformed outcome w.r.t. to one of the original regressors, and w.r.t. the transformed regressors.
$$
\begin{align}
\frac{\partial \mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right)}{\partial X_{li}} &= \beta_l \frac{\partial X_{li}/\sqrt{X_{ki}}}{\partial X_{li}} \\
&= \beta_l
\end{align}
$$
The same as before! Here I have used the fact that
$$
\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right) = \frac{1}{\sqrt{X_{ki}}}\mathbb{E}(Y_i \mid X_{1i}, \ldots, X_{Ki})
$$
since conditioning variables are treated as constant by the expectations operator.
On the other hand, if I find the marginal effect with respect to the transformed regressor, I get
$$
\frac{\partial\mathbb{E}\left(\frac{Y_i}{\sqrt{X_{ki}}}\mid X_{1i}, \ldots, X_{Ki}\right)}{\partial \frac{X_{li}}{\sqrt{X_{ki}}}} = \beta_l \sqrt{X_{ki}}
$$
which is clearly not the same as the parameter being estimated. To elaborate, this is the interpretation you are asking about -- "are the $\beta$s estimated by WLS the effect of a unit change in the rescaled regressors?" The answer, as demonstrated here, is no.
Why this makes sense
Note that you formulate the model the way you do (in terms of the original outcomes and regressors) because you are interested in the parameters of that model (the original $\beta_k$s). Features such as heteroskedasticty reduce the efficiency of the OLS estimated parameters and you might want to correct for that using WLS, and (F)GLS. But it would be slightly counterproductive if this changed the interpretation of the model parameters that you are interested in. The key is in the way you say it -- OLS and WLS estimates of the model parameters, implying one set of population parameters being estimated by both estimators. This can be formalised by saying that the OLS and WLS parameters are consistent for the same population parameters, however, they differ in their asymptotic efficiency.
What most applied economists do
Most applied economists would rather their parameters were close to the truth with high probability as the sample size grows, i.e., that is their parameter estimates were consistent. A crucial aspect of WLS and FGLS is that they require the specification of an auxiliary model for the heteroskedasticity, in order to get at the extra efficiency afforded by those estimators. However, the price of getting this auxiliary model wrong is that the property of consistency is lost. Most applied economists prefer to simply use White robust standard errors to correct the estimates of the standard errors of OLS estimates, and live with the lower efficiency of their estimators.
|
Interpret regression coefficients after WLS
There is no change in the interpretation of the parameters since the parameters being estimated are algebraically identical between the linear regression model with heteroskedasticity and the transfor
|
45,896
|
What is the interpretation of "generalized" partial correlations?
|
Partial correlation coefficient inhabits the domain of linear relationships/regression. You admitted this yourself when giving the definition for partial r in your question. Partial r is just another way of standardazing the linear regression coefficient, the other way being the standardized coefficient beta. So, partial r cannot exist in the context other than that where usual (zero-order) Pearson r exists; it itself is the Pearson correlation, only refined after washing out some "irrelevant" information from it by means of linear algebra.
Spearman rho - as you might be aware - is just Pearson r computed on ranked data rather than raw data. So, as long as you agree to treat the ranks as the "raw data" (that is, treat ranking as just preprocessing) you may carry the concept of partial r, including interpretation, over to Spearman rho.
Situation with Kendall tau is different. This coefficient, unlike Spearman's, is not based on linear correlation/regression. It has its own ideology maths and interpretation, these of Goodman-Kruskal gamma. Therefore, notion of partial r is inapplicable to it, and if you apply that recursive formula you mention to a matrix of tau's that will mean that you believe its entries are Pearson r's!. If there is possible a proper analogue of "partial correlation" for tau, it must be computed by a very different formula exploiting the concept of conditional probability of co-occurrence instead of linear regression between residuals. (See e.g. Ebuh GU and Oyeka ICA. A Nonparametric Method for Estimating Partial Correlation Coefficient.)
|
What is the interpretation of "generalized" partial correlations?
|
Partial correlation coefficient inhabits the domain of linear relationships/regression. You admitted this yourself when giving the definition for partial r in your question. Partial r is just another
|
What is the interpretation of "generalized" partial correlations?
Partial correlation coefficient inhabits the domain of linear relationships/regression. You admitted this yourself when giving the definition for partial r in your question. Partial r is just another way of standardazing the linear regression coefficient, the other way being the standardized coefficient beta. So, partial r cannot exist in the context other than that where usual (zero-order) Pearson r exists; it itself is the Pearson correlation, only refined after washing out some "irrelevant" information from it by means of linear algebra.
Spearman rho - as you might be aware - is just Pearson r computed on ranked data rather than raw data. So, as long as you agree to treat the ranks as the "raw data" (that is, treat ranking as just preprocessing) you may carry the concept of partial r, including interpretation, over to Spearman rho.
Situation with Kendall tau is different. This coefficient, unlike Spearman's, is not based on linear correlation/regression. It has its own ideology maths and interpretation, these of Goodman-Kruskal gamma. Therefore, notion of partial r is inapplicable to it, and if you apply that recursive formula you mention to a matrix of tau's that will mean that you believe its entries are Pearson r's!. If there is possible a proper analogue of "partial correlation" for tau, it must be computed by a very different formula exploiting the concept of conditional probability of co-occurrence instead of linear regression between residuals. (See e.g. Ebuh GU and Oyeka ICA. A Nonparametric Method for Estimating Partial Correlation Coefficient.)
|
What is the interpretation of "generalized" partial correlations?
Partial correlation coefficient inhabits the domain of linear relationships/regression. You admitted this yourself when giving the definition for partial r in your question. Partial r is just another
|
45,897
|
Claiming validity of a study's negative finding
|
"Are these enough to have confidence in the negative finding of our study" - it depends on what you mean by "have confidence". Can you walk away and say "The association is negative, we're done here". No. You can be confident that, having looked at it several ways, you're not detecting an association in your data.
But confidence in the negative finding as a reflection of "truth"? Not really. The confidence one should have in your findings aren't a function of the sheer amount of analysis you throw at it. One could, for example, use ever more elaborate regression techniques to look at their data set in entirely new and novel ways, but if their subjects are misclassified, or they've missed a major confounding variable, then they simply have an impressive volume of incorrect results.
There are other considerations as well. Your study may be underpowered. Smaller studies are more underpowered, but it's possible to be both underpowered and lucky. Similarly, you may simply be experiencing some amount of random variation - some number of studies looking at a "Capital-T Truth, God's Eye View" positive effect will still find negative or null findings. It's possible you study was one of these.
If we assume that your data was collected correctly however, and bias from things like misclassification and confounding are minimal, I think you can be confident in your finding for your study population, and you can be confident that your findings suggest that the association is negative. But a sheer mass of analysis on a single study population does not a body of evidence make.
|
Claiming validity of a study's negative finding
|
"Are these enough to have confidence in the negative finding of our study" - it depends on what you mean by "have confidence". Can you walk away and say "The association is negative, we're done here".
|
Claiming validity of a study's negative finding
"Are these enough to have confidence in the negative finding of our study" - it depends on what you mean by "have confidence". Can you walk away and say "The association is negative, we're done here". No. You can be confident that, having looked at it several ways, you're not detecting an association in your data.
But confidence in the negative finding as a reflection of "truth"? Not really. The confidence one should have in your findings aren't a function of the sheer amount of analysis you throw at it. One could, for example, use ever more elaborate regression techniques to look at their data set in entirely new and novel ways, but if their subjects are misclassified, or they've missed a major confounding variable, then they simply have an impressive volume of incorrect results.
There are other considerations as well. Your study may be underpowered. Smaller studies are more underpowered, but it's possible to be both underpowered and lucky. Similarly, you may simply be experiencing some amount of random variation - some number of studies looking at a "Capital-T Truth, God's Eye View" positive effect will still find negative or null findings. It's possible you study was one of these.
If we assume that your data was collected correctly however, and bias from things like misclassification and confounding are minimal, I think you can be confident in your finding for your study population, and you can be confident that your findings suggest that the association is negative. But a sheer mass of analysis on a single study population does not a body of evidence make.
|
Claiming validity of a study's negative finding
"Are these enough to have confidence in the negative finding of our study" - it depends on what you mean by "have confidence". Can you walk away and say "The association is negative, we're done here".
|
45,898
|
Claiming validity of a study's negative finding
|
This is a really great question! Negative studies need to be published more often in the literature to reduce or eliminate publication bias. I like it that you have done so many thoughtful analyses.
EpiGrad provides some good caveats in his answer. However I think there is a glass half full way to look at this that should be considered. One thing that I did not see on your list was a meta analysis. I think you could do one and should add all the well designed and comparable studies (having negative or positive results). If the analysis leads to a negative conclusion I think it strengthens your case.
Also tradition has it that in classical hypothesis testing the negative result is the null hypothesis and the alternative is the positive result that the investigator is trying to provide statistical inference to reject this null hypothesis. Studies are designed to have sample sizes that maximize the power (making it likely that you will reject the null hypothesis when your alternative is correct).
In pharmaceutical clinical trials the FDA will sometimes give approval to drugs that are shown to be non-inferior to a control (or equivalent in other cases such as approval of a generic drug). These studies involve reversing the null and alternative hypotheses. These studies are powered to reject inferiority (or non-equivalence). If you can look at the data this way and reject a null hypothesis that the biomarker works I think that will overcome EpiGrads valid criticism.
Because the Neyman-Pearson approach to hypothesis tesing is controlled by sample size considerations to reject the null hypothesis through the power of the test and is not designed to "prove" the null hypothesis statistician always warn users that if the null hypothesis is not reject you should not conclude that the null is accepted. Switching the null and alternative finesses this problem.
|
Claiming validity of a study's negative finding
|
This is a really great question! Negative studies need to be published more often in the literature to reduce or eliminate publication bias. I like it that you have done so many thoughtful analyses.
|
Claiming validity of a study's negative finding
This is a really great question! Negative studies need to be published more often in the literature to reduce or eliminate publication bias. I like it that you have done so many thoughtful analyses.
EpiGrad provides some good caveats in his answer. However I think there is a glass half full way to look at this that should be considered. One thing that I did not see on your list was a meta analysis. I think you could do one and should add all the well designed and comparable studies (having negative or positive results). If the analysis leads to a negative conclusion I think it strengthens your case.
Also tradition has it that in classical hypothesis testing the negative result is the null hypothesis and the alternative is the positive result that the investigator is trying to provide statistical inference to reject this null hypothesis. Studies are designed to have sample sizes that maximize the power (making it likely that you will reject the null hypothesis when your alternative is correct).
In pharmaceutical clinical trials the FDA will sometimes give approval to drugs that are shown to be non-inferior to a control (or equivalent in other cases such as approval of a generic drug). These studies involve reversing the null and alternative hypotheses. These studies are powered to reject inferiority (or non-equivalence). If you can look at the data this way and reject a null hypothesis that the biomarker works I think that will overcome EpiGrads valid criticism.
Because the Neyman-Pearson approach to hypothesis tesing is controlled by sample size considerations to reject the null hypothesis through the power of the test and is not designed to "prove" the null hypothesis statistician always warn users that if the null hypothesis is not reject you should not conclude that the null is accepted. Switching the null and alternative finesses this problem.
|
Claiming validity of a study's negative finding
This is a really great question! Negative studies need to be published more often in the literature to reduce or eliminate publication bias. I like it that you have done so many thoughtful analyses.
|
45,899
|
Robust correlation in R? [closed]
|
MASS::cov.rob (link to man page) has two methods for robust covariances, which you can standardize to correlations with cov2cor. @whuber is right that the "best" method will depend on what you want to do with it, though..
|
Robust correlation in R? [closed]
|
MASS::cov.rob (link to man page) has two methods for robust covariances, which you can standardize to correlations with cov2cor. @whuber is right that the "best" method will depend on what you want t
|
Robust correlation in R? [closed]
MASS::cov.rob (link to man page) has two methods for robust covariances, which you can standardize to correlations with cov2cor. @whuber is right that the "best" method will depend on what you want to do with it, though..
|
Robust correlation in R? [closed]
MASS::cov.rob (link to man page) has two methods for robust covariances, which you can standardize to correlations with cov2cor. @whuber is right that the "best" method will depend on what you want t
|
45,900
|
Robust correlation in R? [closed]
|
I implemented these correlation measures in R, it is super easy using robustbase package:
http://www.stat.tugraz.at/AJS/ausg111+2/111+2Shevlyakov.pdf
The assessment of performance for contaminated sample case is provided in the end of the article (for n=20 and n=1000). You may concentrate on $Q_n$ correlation, it works the best according to the assessment.
UPD: I recently found myself googling for a robust correlation code in R and found out this thread again. Here is the code:
robust_correlation <- function(robust_std, estimation_of_center_x, estimation_of_center_y, x, y) {
square_root_of_two <- sqrt(2)
std_of_x <- robust_std(x)
std_of_y <- robust_std(y)
first_component = (x - estimation_of_center_x) / (square_root_of_two * std_of_x)
second_component = (y - estimation_of_center_y) / (square_root_of_two * std_of_y)
u = first_component + second_component
v = first_component - second_component
var_of_u = robust_std(u) ** 2
var_of_v = robust_std(v) ** 2
r = (var_of_u - var_of_v) / (var_of_u + var_of_v + 10**-10)
return®
}
|
Robust correlation in R? [closed]
|
I implemented these correlation measures in R, it is super easy using robustbase package:
http://www.stat.tugraz.at/AJS/ausg111+2/111+2Shevlyakov.pdf
The assessment of performance for contaminated sam
|
Robust correlation in R? [closed]
I implemented these correlation measures in R, it is super easy using robustbase package:
http://www.stat.tugraz.at/AJS/ausg111+2/111+2Shevlyakov.pdf
The assessment of performance for contaminated sample case is provided in the end of the article (for n=20 and n=1000). You may concentrate on $Q_n$ correlation, it works the best according to the assessment.
UPD: I recently found myself googling for a robust correlation code in R and found out this thread again. Here is the code:
robust_correlation <- function(robust_std, estimation_of_center_x, estimation_of_center_y, x, y) {
square_root_of_two <- sqrt(2)
std_of_x <- robust_std(x)
std_of_y <- robust_std(y)
first_component = (x - estimation_of_center_x) / (square_root_of_two * std_of_x)
second_component = (y - estimation_of_center_y) / (square_root_of_two * std_of_y)
u = first_component + second_component
v = first_component - second_component
var_of_u = robust_std(u) ** 2
var_of_v = robust_std(v) ** 2
r = (var_of_u - var_of_v) / (var_of_u + var_of_v + 10**-10)
return®
}
|
Robust correlation in R? [closed]
I implemented these correlation measures in R, it is super easy using robustbase package:
http://www.stat.tugraz.at/AJS/ausg111+2/111+2Shevlyakov.pdf
The assessment of performance for contaminated sam
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.