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
|
|---|---|---|---|---|---|---|
44,401
|
Solving a practical machine learning problem
|
I have seen statements like "We pick representative samples...". This
is an absurd statement...
I agree with you on this. And I don't think representative sampling is what they do (anymore). My understanding is that they analyse big data with distributed computing, using technology like Hadoop, Spark, and MLLib. I am sure they write their proprietary and complex machine learning / analysis libraries on top of these.
The algorithms for these "distributable" systems are coded differently than how you and I would code them in e.g. R, Matlab or Python. They need to be scalable and parallelisable, which is an issue for some algorithms. MLLib, for instance, currently only supports some very basic algorithms (list available on their website).
|
Solving a practical machine learning problem
|
I have seen statements like "We pick representative samples...". This
is an absurd statement...
I agree with you on this. And I don't think representative sampling is what they do (anymore). My und
|
Solving a practical machine learning problem
I have seen statements like "We pick representative samples...". This
is an absurd statement...
I agree with you on this. And I don't think representative sampling is what they do (anymore). My understanding is that they analyse big data with distributed computing, using technology like Hadoop, Spark, and MLLib. I am sure they write their proprietary and complex machine learning / analysis libraries on top of these.
The algorithms for these "distributable" systems are coded differently than how you and I would code them in e.g. R, Matlab or Python. They need to be scalable and parallelisable, which is an issue for some algorithms. MLLib, for instance, currently only supports some very basic algorithms (list available on their website).
|
Solving a practical machine learning problem
I have seen statements like "We pick representative samples...". This
is an absurd statement...
I agree with you on this. And I don't think representative sampling is what they do (anymore). My und
|
44,402
|
Solving a practical machine learning problem
|
Beyond subsampling and divide-and-conquer distributed computing, both important and useful, there are many other ways of solving such problems. To name just a couple, parallel coordinate descent (iterate on each variable independently, combine solutions later), and online methods, like stochastic gradient descent (SGD).
Have a look at https://github.com/JohnLangford/vowpal_wabbit for quite a widely used approach to online learning with SGD. Also Alex Smola has done quite a bit of work on large-scale learning.
|
Solving a practical machine learning problem
|
Beyond subsampling and divide-and-conquer distributed computing, both important and useful, there are many other ways of solving such problems. To name just a couple, parallel coordinate descent (iter
|
Solving a practical machine learning problem
Beyond subsampling and divide-and-conquer distributed computing, both important and useful, there are many other ways of solving such problems. To name just a couple, parallel coordinate descent (iterate on each variable independently, combine solutions later), and online methods, like stochastic gradient descent (SGD).
Have a look at https://github.com/JohnLangford/vowpal_wabbit for quite a widely used approach to online learning with SGD. Also Alex Smola has done quite a bit of work on large-scale learning.
|
Solving a practical machine learning problem
Beyond subsampling and divide-and-conquer distributed computing, both important and useful, there are many other ways of solving such problems. To name just a couple, parallel coordinate descent (iter
|
44,403
|
Solving a practical machine learning problem
|
Massively parallel matrix inversion is actually doable with open source software such as MUMPS, although I'm not sure how it would scale to 10bio rows. It's used for large scale finite elements in automotive so it's industrial strength for sure.
As for the class of algorithms used, it's a multifrontal approach (divide the matrix into zones that don't 'interfere' with each other in the sense of cholesky-like outer product updates, solve each part and gather rectangular 'interference' updates). Much more details on the mumps website, http://mumps.enseeiht.fr/ .
Now if you're just doing linear regression, the result will be x = (AtA)-1At b and you can probably parallelize the computation of the covar matrix (AtA) and the error term efficiently to run on different machines and then aggregate the results. This supposes A has only a few columns.
|
Solving a practical machine learning problem
|
Massively parallel matrix inversion is actually doable with open source software such as MUMPS, although I'm not sure how it would scale to 10bio rows. It's used for large scale finite elements in aut
|
Solving a practical machine learning problem
Massively parallel matrix inversion is actually doable with open source software such as MUMPS, although I'm not sure how it would scale to 10bio rows. It's used for large scale finite elements in automotive so it's industrial strength for sure.
As for the class of algorithms used, it's a multifrontal approach (divide the matrix into zones that don't 'interfere' with each other in the sense of cholesky-like outer product updates, solve each part and gather rectangular 'interference' updates). Much more details on the mumps website, http://mumps.enseeiht.fr/ .
Now if you're just doing linear regression, the result will be x = (AtA)-1At b and you can probably parallelize the computation of the covar matrix (AtA) and the error term efficiently to run on different machines and then aggregate the results. This supposes A has only a few columns.
|
Solving a practical machine learning problem
Massively parallel matrix inversion is actually doable with open source software such as MUMPS, although I'm not sure how it would scale to 10bio rows. It's used for large scale finite elements in aut
|
44,404
|
Solving a practical machine learning problem
|
Thank you all for your comments. Turns out Apache spark does L1 penalized regressions. I found links to training videos here which some of you may find helpful.
Turns out the folk at Google who seriously studied this problem and founded the Map-Reduce architecture were Jeff Dean and Sanjay Ghemawat, both of whom have become silicon-valley rockstars. Jeff Dean has his own Chuck Norris persona!!!
http://www.quora.com/What-are-all-the-Jeff-Dean-facts?share=1
|
Solving a practical machine learning problem
|
Thank you all for your comments. Turns out Apache spark does L1 penalized regressions. I found links to training videos here which some of you may find helpful.
Turns out the folk at Google who serio
|
Solving a practical machine learning problem
Thank you all for your comments. Turns out Apache spark does L1 penalized regressions. I found links to training videos here which some of you may find helpful.
Turns out the folk at Google who seriously studied this problem and founded the Map-Reduce architecture were Jeff Dean and Sanjay Ghemawat, both of whom have become silicon-valley rockstars. Jeff Dean has his own Chuck Norris persona!!!
http://www.quora.com/What-are-all-the-Jeff-Dean-facts?share=1
|
Solving a practical machine learning problem
Thank you all for your comments. Turns out Apache spark does L1 penalized regressions. I found links to training videos here which some of you may find helpful.
Turns out the folk at Google who serio
|
44,405
|
What to claim when we don't reject the null hypothesis? [duplicate]
|
"We fail to reject the null" is the correct answer. Rather than say, for example, "there is no difference" we should write "no difference was detected".
Clearly, with not enough replicates or large measurement error you are likely to not be able to detect even large effects. So maybe the difference is there, but you failed to see it?
As Maarten Buis writes in the comment: "Absence of evidence is not evidence of absence". (Personally, I am careful with the word "evidence".)
|
What to claim when we don't reject the null hypothesis? [duplicate]
|
"We fail to reject the null" is the correct answer. Rather than say, for example, "there is no difference" we should write "no difference was detected".
Clearly, with not enough replicates or large me
|
What to claim when we don't reject the null hypothesis? [duplicate]
"We fail to reject the null" is the correct answer. Rather than say, for example, "there is no difference" we should write "no difference was detected".
Clearly, with not enough replicates or large measurement error you are likely to not be able to detect even large effects. So maybe the difference is there, but you failed to see it?
As Maarten Buis writes in the comment: "Absence of evidence is not evidence of absence". (Personally, I am careful with the word "evidence".)
|
What to claim when we don't reject the null hypothesis? [duplicate]
"We fail to reject the null" is the correct answer. Rather than say, for example, "there is no difference" we should write "no difference was detected".
Clearly, with not enough replicates or large me
|
44,406
|
What to claim when we don't reject the null hypothesis? [duplicate]
|
I would include three things:
The phrase "Insufficient evidence to reject". Shows that with more evidence, e.g. more data, or repeating the experiment with a different random selection of data, you might have rejected.
The significance level. At a higher significance level you might have rejected the null hypothesis.
What your conclusion is. "The data is consistent with" is a good phrase here.
As an example, putting these altogether for an experiment to determine the effect of cognitive behavioural therapy (CBT) on addressing insomnia
"There was insufficient evidence to reject the null hypothesis that CBT increased the amount of sleep at the 5% significance level. The data is consistent with CBT having no effect on insomnia."
|
What to claim when we don't reject the null hypothesis? [duplicate]
|
I would include three things:
The phrase "Insufficient evidence to reject". Shows that with more evidence, e.g. more data, or repeating the experiment with a different random selection of data, you m
|
What to claim when we don't reject the null hypothesis? [duplicate]
I would include three things:
The phrase "Insufficient evidence to reject". Shows that with more evidence, e.g. more data, or repeating the experiment with a different random selection of data, you might have rejected.
The significance level. At a higher significance level you might have rejected the null hypothesis.
What your conclusion is. "The data is consistent with" is a good phrase here.
As an example, putting these altogether for an experiment to determine the effect of cognitive behavioural therapy (CBT) on addressing insomnia
"There was insufficient evidence to reject the null hypothesis that CBT increased the amount of sleep at the 5% significance level. The data is consistent with CBT having no effect on insomnia."
|
What to claim when we don't reject the null hypothesis? [duplicate]
I would include three things:
The phrase "Insufficient evidence to reject". Shows that with more evidence, e.g. more data, or repeating the experiment with a different random selection of data, you m
|
44,407
|
Do I have to learn SAS if I want to go into industry?
|
you have to figure what is that you're interested in:
programming statistics in R
programming statistics
statistics
programming
If your answer is 2-4, then it shouldn't matter which language you use. if you already know R and don't want to learn SAS, then get certified in SAS. this will increase your chances of getting employed at places where they require SAS. once employed, you'll learn SAS and use it, and it wouldn't bother you at all.
Only if your answer is 1., you're in a tough spot regardless of the industry. I frankly don't understand personal attachments to particular languages and tools, especially for a young guy in the beginning of a career. it makes a sense for 60 year old dude who simply doesn't want to spend his precious time on learning something new when he can simply ride on what he already learned during his long life. learn SAS, Stata, Gauss, Python... you have plenty of time ahead.
|
Do I have to learn SAS if I want to go into industry?
|
you have to figure what is that you're interested in:
programming statistics in R
programming statistics
statistics
programming
If your answer is 2-4, then it shouldn't matter which language you u
|
Do I have to learn SAS if I want to go into industry?
you have to figure what is that you're interested in:
programming statistics in R
programming statistics
statistics
programming
If your answer is 2-4, then it shouldn't matter which language you use. if you already know R and don't want to learn SAS, then get certified in SAS. this will increase your chances of getting employed at places where they require SAS. once employed, you'll learn SAS and use it, and it wouldn't bother you at all.
Only if your answer is 1., you're in a tough spot regardless of the industry. I frankly don't understand personal attachments to particular languages and tools, especially for a young guy in the beginning of a career. it makes a sense for 60 year old dude who simply doesn't want to spend his precious time on learning something new when he can simply ride on what he already learned during his long life. learn SAS, Stata, Gauss, Python... you have plenty of time ahead.
|
Do I have to learn SAS if I want to go into industry?
you have to figure what is that you're interested in:
programming statistics in R
programming statistics
statistics
programming
If your answer is 2-4, then it shouldn't matter which language you u
|
44,408
|
Do I have to learn SAS if I want to go into industry?
|
SAS is extremely expensive as an enterprise wide solution. It is used by some large organisations specially in banking and insurance. Many companies today are taking a different approach, looking for less expensive and scalable solutions. Open source is getting a lot of traction even in large organisations.
I would start with R programming and maybe Python. Once you have enough exposure to these, and if you decide to learn SAS, it will be a lot easier to digest.
|
Do I have to learn SAS if I want to go into industry?
|
SAS is extremely expensive as an enterprise wide solution. It is used by some large organisations specially in banking and insurance. Many companies today are taking a different approach, looking for
|
Do I have to learn SAS if I want to go into industry?
SAS is extremely expensive as an enterprise wide solution. It is used by some large organisations specially in banking and insurance. Many companies today are taking a different approach, looking for less expensive and scalable solutions. Open source is getting a lot of traction even in large organisations.
I would start with R programming and maybe Python. Once you have enough exposure to these, and if you decide to learn SAS, it will be a lot easier to digest.
|
Do I have to learn SAS if I want to go into industry?
SAS is extremely expensive as an enterprise wide solution. It is used by some large organisations specially in banking and insurance. Many companies today are taking a different approach, looking for
|
44,409
|
Intuition for consequences of multicollinearity
|
Let us first distinguish between perfect multi-collinearity (model matrix not of full rank, so that usual matrix inversions fail. Usually due to misspecification of the predictors) and non-perfect multi-collinearity (some of the predictors are correlated without leading to computational problems). This answer is about the second type, which occurs in almost any multivariable linear model since the predictors have no reason to be uncorrelated.
A simple example with strong multi-collinearity is a quadratic regression. So the only predictors are $X_1 = X$ and $X_2=X^2$:
set.seed(60)
X1 <- abs(rnorm(60))
X2 <- X1^2
cor(X1,X2) # Result: 0.967
This example illustrates your questions/claims:
1. Multicollinearity doesnt affect the regression of the model as a whole.
Let's have a look at an example model:
Y <- 0.5*X1 + X2 + rnorm(60)
fit <- lm(Y~X1+X2)
summary(fit)
#Result
[...]
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.3439 0.3214 -1.070 0.289
X1 1.3235 0.8323 1.590 0.117
X2 0.5861 0.3931 1.491 0.141
Residual standard error: 1.014 on 57 degrees of freedom
Multiple R-squared: 0.7147, Adjusted R-squared: 0.7047
F-statistic: 71.39 on 2 and 57 DF, p-value: 2.996e-16
Global statements about the model are just fine:
R-Squared: $X$ explains about 71% of the variability of $Y$
Global F-test: At the 5% level, there is really an association between $X$ and $Y$
Predictions: For persons with $X$-value 2, a best guess for his $Y$-value is
$$
-0.3439 + 1.3235\cdot 2 + 0.5861 \cdot 2^2 = 4.6475
$$
2. But if we start looking at the effect of individual variable Xs on the explained variable, then we are going to have inaccurate estimates.
The estimates are accurate, this is not the problem. The problem with the standard interpretation of isolated effects is that we hold all other predictors fixed, which is strange if there are strong correlations to those other predictors. In our example it is even wrong to say "the average $Y$ value increases by 1.3235 if we increase $X_1$ by 1 and hold $X_2$ fixed, because $X_2 = X_1^2$. Since we cannot interpret isolated effects descriptively, also all inductive statements about them are not useful: Look at the t-tests in the output. Both are above the 5% level, although the global test of association gives us a p-value below 5%. The null hypothesis of such a t-test is "the effect of the predictor is zero" or, in other words, "the inclusion of this predictor does not increase the true R-squared in the population". Because $X_1$ and $X_2$ are almost perfectly correlated, the model has almost the same R-squared if we drop one of the two variables:
summary(lm(Y~X1))
# Gives
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.7033 0.2148 -3.274 0.00179 **
X1 2.5232 0.2151 11.733 < 2e-16 ***
Residual standard error: 1.025 on 58 degrees of freedom
Multiple R-squared: 0.7036, Adjusted R-squared: 0.6985
F-statistic: 137.7 on 1 and 58 DF, p-value: < 2.2e-16
This already illustrates the first part of the statement:
One other thing to keep in mind is that the tests on the individual coefficients each assume that all of the other predictors are in the model. In other words each predictor is not significant as long as all of the other predictors are in the model. There must be some interaction or interdependence between two or more of your predictors.
The last statement here is plainly wrong.
|
Intuition for consequences of multicollinearity
|
Let us first distinguish between perfect multi-collinearity (model matrix not of full rank, so that usual matrix inversions fail. Usually due to misspecification of the predictors) and non-perfect mul
|
Intuition for consequences of multicollinearity
Let us first distinguish between perfect multi-collinearity (model matrix not of full rank, so that usual matrix inversions fail. Usually due to misspecification of the predictors) and non-perfect multi-collinearity (some of the predictors are correlated without leading to computational problems). This answer is about the second type, which occurs in almost any multivariable linear model since the predictors have no reason to be uncorrelated.
A simple example with strong multi-collinearity is a quadratic regression. So the only predictors are $X_1 = X$ and $X_2=X^2$:
set.seed(60)
X1 <- abs(rnorm(60))
X2 <- X1^2
cor(X1,X2) # Result: 0.967
This example illustrates your questions/claims:
1. Multicollinearity doesnt affect the regression of the model as a whole.
Let's have a look at an example model:
Y <- 0.5*X1 + X2 + rnorm(60)
fit <- lm(Y~X1+X2)
summary(fit)
#Result
[...]
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.3439 0.3214 -1.070 0.289
X1 1.3235 0.8323 1.590 0.117
X2 0.5861 0.3931 1.491 0.141
Residual standard error: 1.014 on 57 degrees of freedom
Multiple R-squared: 0.7147, Adjusted R-squared: 0.7047
F-statistic: 71.39 on 2 and 57 DF, p-value: 2.996e-16
Global statements about the model are just fine:
R-Squared: $X$ explains about 71% of the variability of $Y$
Global F-test: At the 5% level, there is really an association between $X$ and $Y$
Predictions: For persons with $X$-value 2, a best guess for his $Y$-value is
$$
-0.3439 + 1.3235\cdot 2 + 0.5861 \cdot 2^2 = 4.6475
$$
2. But if we start looking at the effect of individual variable Xs on the explained variable, then we are going to have inaccurate estimates.
The estimates are accurate, this is not the problem. The problem with the standard interpretation of isolated effects is that we hold all other predictors fixed, which is strange if there are strong correlations to those other predictors. In our example it is even wrong to say "the average $Y$ value increases by 1.3235 if we increase $X_1$ by 1 and hold $X_2$ fixed, because $X_2 = X_1^2$. Since we cannot interpret isolated effects descriptively, also all inductive statements about them are not useful: Look at the t-tests in the output. Both are above the 5% level, although the global test of association gives us a p-value below 5%. The null hypothesis of such a t-test is "the effect of the predictor is zero" or, in other words, "the inclusion of this predictor does not increase the true R-squared in the population". Because $X_1$ and $X_2$ are almost perfectly correlated, the model has almost the same R-squared if we drop one of the two variables:
summary(lm(Y~X1))
# Gives
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.7033 0.2148 -3.274 0.00179 **
X1 2.5232 0.2151 11.733 < 2e-16 ***
Residual standard error: 1.025 on 58 degrees of freedom
Multiple R-squared: 0.7036, Adjusted R-squared: 0.6985
F-statistic: 137.7 on 1 and 58 DF, p-value: < 2.2e-16
This already illustrates the first part of the statement:
One other thing to keep in mind is that the tests on the individual coefficients each assume that all of the other predictors are in the model. In other words each predictor is not significant as long as all of the other predictors are in the model. There must be some interaction or interdependence between two or more of your predictors.
The last statement here is plainly wrong.
|
Intuition for consequences of multicollinearity
Let us first distinguish between perfect multi-collinearity (model matrix not of full rank, so that usual matrix inversions fail. Usually due to misspecification of the predictors) and non-perfect mul
|
44,410
|
Intuition for consequences of multicollinearity
|
Another problem, in addition to those @Michael gave, is that when there is strong near-colinearity, small changes in the input data can lead to large changes in the output.
I made up some data (taking wild guesses at the average lengths of legs and torso (in inches) and weight (in pounds) for adult humans).
set.seed(1230101)
lengthleg <- rnorm(100, 30, 5)
lengthtorso <- lengthleg + rnorm(100, 0, 1)
weight <- 1.2*lengthleg + 1.8*lengthtorso + rnorm(100, 0, 10)
m1 <- lm(weight~lengthleg + lengthtorso)
coef(m1)
the first time through, I got coefficients of -5.93, 0.43 and 2.73. Rerunning everything except set.seed gave me -9.91, 1.12 and 2.18.
|
Intuition for consequences of multicollinearity
|
Another problem, in addition to those @Michael gave, is that when there is strong near-colinearity, small changes in the input data can lead to large changes in the output.
I made up some data (takin
|
Intuition for consequences of multicollinearity
Another problem, in addition to those @Michael gave, is that when there is strong near-colinearity, small changes in the input data can lead to large changes in the output.
I made up some data (taking wild guesses at the average lengths of legs and torso (in inches) and weight (in pounds) for adult humans).
set.seed(1230101)
lengthleg <- rnorm(100, 30, 5)
lengthtorso <- lengthleg + rnorm(100, 0, 1)
weight <- 1.2*lengthleg + 1.8*lengthtorso + rnorm(100, 0, 10)
m1 <- lm(weight~lengthleg + lengthtorso)
coef(m1)
the first time through, I got coefficients of -5.93, 0.43 and 2.73. Rerunning everything except set.seed gave me -9.91, 1.12 and 2.18.
|
Intuition for consequences of multicollinearity
Another problem, in addition to those @Michael gave, is that when there is strong near-colinearity, small changes in the input data can lead to large changes in the output.
I made up some data (takin
|
44,411
|
Learning probability bad reasoning. Conditional and unconditional
|
For (a), a simple way to look at is that you've reduced your probability space to only the combinations that have at least one boy:
BB = 1/3
BG = 1/3
GB = 1/3
GG is no longer a possibility based on the fact that your neighbor said he had at least one boy. Of the possibilities remaining, you're left with a 2/3 probability that he has a girl. The information he gave you reduced the probability of him having a girl from 3/4 to 2/3. Formally, this can be shown as follows: $$P(At\ least\ one\ girl|At\ least\ one\ boy) = \frac{P(At\ least\ one\ girl\ \cap At\ least\ one\ boy)}{P(At\ least\ one\ boy)} $$
From your original box, we can see the probability of having at least one boy and at least one girl is BG + GB = 0.25 + 0.25 = 0.5, but we need to divide by the probability of at least one boy, which is BB + BG + GB = 0.25 + 0.25 + 0.25 = 0.75, so we get $\frac{\tfrac{1}{2}}{\tfrac{3}{4}} = \frac{2}{3}$.
For (b), now that we've seen a boy, the only uncertainty remaining is the gender of the other child, and given no other information, the probability of the other child being female is 1/2, which is the answer.
|
Learning probability bad reasoning. Conditional and unconditional
|
For (a), a simple way to look at is that you've reduced your probability space to only the combinations that have at least one boy:
BB = 1/3
BG = 1/3
GB = 1/3
GG is no longer a possibility based on t
|
Learning probability bad reasoning. Conditional and unconditional
For (a), a simple way to look at is that you've reduced your probability space to only the combinations that have at least one boy:
BB = 1/3
BG = 1/3
GB = 1/3
GG is no longer a possibility based on the fact that your neighbor said he had at least one boy. Of the possibilities remaining, you're left with a 2/3 probability that he has a girl. The information he gave you reduced the probability of him having a girl from 3/4 to 2/3. Formally, this can be shown as follows: $$P(At\ least\ one\ girl|At\ least\ one\ boy) = \frac{P(At\ least\ one\ girl\ \cap At\ least\ one\ boy)}{P(At\ least\ one\ boy)} $$
From your original box, we can see the probability of having at least one boy and at least one girl is BG + GB = 0.25 + 0.25 = 0.5, but we need to divide by the probability of at least one boy, which is BB + BG + GB = 0.25 + 0.25 + 0.25 = 0.75, so we get $\frac{\tfrac{1}{2}}{\tfrac{3}{4}} = \frac{2}{3}$.
For (b), now that we've seen a boy, the only uncertainty remaining is the gender of the other child, and given no other information, the probability of the other child being female is 1/2, which is the answer.
|
Learning probability bad reasoning. Conditional and unconditional
For (a), a simple way to look at is that you've reduced your probability space to only the combinations that have at least one boy:
BB = 1/3
BG = 1/3
GB = 1/3
GG is no longer a possibility based on t
|
44,412
|
Learning probability bad reasoning. Conditional and unconditional
|
Another way to show this (part a ) is to write the Bayes rule as follows:
P(B|G) = P(G)P(B|G) / P(~G)P(B|~G) + P(G)P(B|G)
= (0.5 * 0.5) / (0.5*0.25 + 0.5*0.5) = 2/3
|
Learning probability bad reasoning. Conditional and unconditional
|
Another way to show this (part a ) is to write the Bayes rule as follows:
P(B|G) = P(G)P(B|G) / P(~G)P(B|~G) + P(G)P(B|G)
= (0.5 * 0.5) / (0.5*0.25 + 0.5*0.5) = 2/3
|
Learning probability bad reasoning. Conditional and unconditional
Another way to show this (part a ) is to write the Bayes rule as follows:
P(B|G) = P(G)P(B|G) / P(~G)P(B|~G) + P(G)P(B|G)
= (0.5 * 0.5) / (0.5*0.25 + 0.5*0.5) = 2/3
|
Learning probability bad reasoning. Conditional and unconditional
Another way to show this (part a ) is to write the Bayes rule as follows:
P(B|G) = P(G)P(B|G) / P(~G)P(B|~G) + P(G)P(B|G)
= (0.5 * 0.5) / (0.5*0.25 + 0.5*0.5) = 2/3
|
44,413
|
Questions on standard deviation of a time series
|
Thirty years ago, John Emerson provided a simple explanation of an extremely useful generalization of this phenomenon. Here is the essence of it.
Suppose you have batches of data (which could include a set of windows across a time series, for instance) and you summarize each with some measure of its "level" (a mean or median, perhaps) and a measure of its "spread" (a standard deviation or interquartile range, perhaps), with both statistics expressed in the same units as the data. We seek some monotonic, increasing transformation $\phi$ for which the spread of the transformed data is approximately constant: a spread-stabilizing transformation. We might as well pick a nice smooth transformation, so we are free to assume $\phi$ is analytic (can be expanded in a Taylor series).
Emerson finds $\phi$ based on the apparent relationship between the median, $\nu$, and the interquartile range, $\tau$. The reason for using an IQR (or any symmetric measure of spread based on quantiles: quartiles work well but aren't essential) is that in any batch the $q^\text{th}$ quantile of the transformed data $\phi(x_j)$ coincides with $\phi$ applied to the $q^\text{th}$ quantile of the original data $(x_j)$. (This is not generally true for other measures of spread.) Using quantile-based statistics is not a serious limitation: if the batches of data have roughly the same shape, then the median and IQR will be in the same proportion to any other reasonable measures of location and spread, so Emerson's analysis will produce the correct $\phi$ to stabilize other measures of spread, such as the standard deviation.
The idea is to approximate $\phi$ to second order at $\nu$ and track what it does to the spread $\tau(\nu)$. To that end, express the quartiles as displacements from the median, using the spread $\tau(\nu)$ as the natural measure of distance. The upper quartile can be written as $\nu+\lambda(\nu)\tau(\nu)$ with $0 \le \lambda(\nu) \le 1$; the lower quartile therefore must be $\nu-(1-\lambda(\nu))\tau(\nu)$. Applying $\phi$ and writing out its Taylor series we find that the new quartiles are
$$\phi(\nu) + \phi'(\nu)\left(\lambda(\nu)\tau(\nu)\right) + \frac{1}{2!}\phi''(\nu)\left(\lambda(\nu)\tau(\nu)\right)^2 + o(\tau(\nu)^2)$$
and
$$\phi(\nu) - \phi'(\nu)\left(1-\lambda(\nu)\tau(\nu)\right) + \frac{1}{2!}\phi''(\nu)\left(1-\lambda(\nu)\tau(\nu)\right)^2 + o(\tau(\nu)^2).$$
The new IQR is obtained by subtraction. The zeroth order terms cancel, the first order terms just multiply the original spread, and the second order terms give something that needs analyzing:
$$\phi'(\nu)\tau(\nu) + \frac{1}{2!}\phi''(\nu)\left(2\lambda(\nu)\tau(\nu)-1\right) + o(\tau(\nu)^2).$$
At this point Emerson argues that the second-order term is negligible, for several reasons:
If the median is roughly centered between the quartiles (that is, the middle half of each batch is roughly symmetric), then $\lambda(\nu)\approx 1/2 \approx 1 - \lambda(\nu)$, making $\left(2\lambda(\nu)-1\right)$ small.
If $\phi$ is not too "strong," it shouldn't be terribly curved near the median, making $\phi''(\nu)$ also small.
(As an example of (2) Emerson offers the case of $\phi = \log$ where $\nu=10$, pointing out that $\phi'(\nu) = 1/\nu = 0.1$ and $\phi''(\nu) = -1/\nu^2 = -0.01$, a "relatively small" value. This looks specious to me, for if we were merely to change the units of measure of the data (as from meters to kilometers) we might now find that $\nu=0.01$, for which $\phi'(\nu)=100$ and $\phi''(\nu)=10000$! The mistake here is that the values $100$ and $10000$ aren't even comparable: they are in different units. What we should be concerned about is the product $\phi''(\nu)\tau(\nu)^2$, because it overestimates how much $\phi$ will change between the two quartiles. To pursue Emerson's example, if the data are positive and their median is $\nu=10$, then likely the lower quartile is close to $10$ and we can hope the upper quartile isn't too far from it, either. In this case $\tau(10) \ll 10$, so $\phi''(10)\tau(10)^2 \ll 0.01 \times (10^2) \ll 1,$ justifying dropping the second-order term. Although this paragraph may seem technical, it provides insight into just why this analysis works and suggests how to identify cases where it might fail or at least should be mistrusted.)
The upshot is that to stabilize the spread, the derivative of the transformation (applied at the middle of the batch, $\nu$) needs to be inversely proportional to the spread itself (provided the quartiles are not both asymmetrically placed and far from the median as a proportion of the median). Because this inverse proportion needs to hold for the entire range of locational values of the batches, we immediately obtain the general solution
$$\phi(\nu) \propto \int^\nu \frac{dx}{\tau(x)}.$$
The situation posited in the question is that the spread is proportional to the level: $\tau(\nu) \propto \nu$. The solution is
$$\phi(\nu) \propto \int^\nu \frac{dx}{x} = \log(\nu),$$
QED.
To put this general result into practice, we make a spread-versus-level plot. Its objective, beyond visualizing how the spreads relate to the levels for the batches, often is to find a Box-Cox (power) transformation $\phi$. We easily see that if $\phi(\nu) \propto \nu^p$ for some power $p\ne 1$, then $\tau(\nu) \propto \nu^{1-p}$. When $p=1$, $\tau(\nu) \propto \log(\nu)$. Therefore, we should seek a power function fit to the spread ($\tau$)-versus-level ($\nu$) plot. A simple way to do this is to fit a straight line on log-log axes, preferably using a method that is resistant to outlying or unusual values. (A visual fit is usually fine but is hard to automate.) The slope of the line is the power $1-p$. For instance, when the spread is proportional to the level the line will have slope $1 = 1-p$ yielding $p=0$, corresponding to the logarithm.
Here is a synthetic example. Let's generate independent samples of squared Poisson variates with different levels (theory tells us the variance-stabilizing power transformation is $p=1/4$). The figure shows the spread-vs-level plot, boxplots of the original batches (with medians removed so we can readily compare their spreads), and similar boxplots of the transformed batches. The improvement is clear. In this case the spread-vs-level method works spectacularly well: the slope of the plot is $3/4$, indicating $p=1-3/4=1/4$ is the spread-stabilizing power, exactly as predicted theoretically. (In my experience this method works more often than not, but still should be considered only as a guide or starting point for refining the Box-Cox parameter.)
Here is the R code that produced this example.
#
# Create data.
#
set.seed(17)
k <- 8 # Number of batches
n <- rpois(k, 20) # Batch sizes
lambda <- exp(rnorm(k, 1.5)) # Levels
x.l <- lapply(1:k, function(i) rpois(n[i], lambda[i])^2)
#
# Make a spread-vs-level plot.
#
medians <- sapply(x.l, median)
IQRs <- sapply(x.l, function(y) diff(quantile(y, c(1/4, 3/4))))
par(mfrow=c(1,3))
plot(log(medians), log(IQRs), main="Spread vs. Level",
xlab="Log median", ylab="Log IQR")
#
# Fit a line to the plot.
# NB The fit is weighted by batch size; this was not suggested by Emerson
# but is a good idea when batches differ substantially in size.
#
library(MASS)
ab <- rlm(log(IQRs) ~ log(medians), weights=n)
abline(coef(ab), col="Red")
p <- 1 - coef(ab)[2] # The Box-Cox parameter to stabilize spread
#
# Look at how well the batches have been stabilized.
#
i <- order(medians)
boxplot(lapply(x.l, function(y) y-median(y))[i], main="Data (medians removed)")
boxplot(lapply(x.l, function(y) {z <- (y^p - 1)/p; z - median(z)})[i],
main=paste("Box-Cox (",round(p,2),")", sep=""))
Reference
John D. Emerson, Mathematical Aspects of Transformation. In Hoaglin, David C., Frederick Mosteller, and John W. Tukey, eds, Understanding Robust and Exploratory Data Analysis. John Wiley & Sons, 1983.
|
Questions on standard deviation of a time series
|
Thirty years ago, John Emerson provided a simple explanation of an extremely useful generalization of this phenomenon. Here is the essence of it.
Suppose you have batches of data (which could include
|
Questions on standard deviation of a time series
Thirty years ago, John Emerson provided a simple explanation of an extremely useful generalization of this phenomenon. Here is the essence of it.
Suppose you have batches of data (which could include a set of windows across a time series, for instance) and you summarize each with some measure of its "level" (a mean or median, perhaps) and a measure of its "spread" (a standard deviation or interquartile range, perhaps), with both statistics expressed in the same units as the data. We seek some monotonic, increasing transformation $\phi$ for which the spread of the transformed data is approximately constant: a spread-stabilizing transformation. We might as well pick a nice smooth transformation, so we are free to assume $\phi$ is analytic (can be expanded in a Taylor series).
Emerson finds $\phi$ based on the apparent relationship between the median, $\nu$, and the interquartile range, $\tau$. The reason for using an IQR (or any symmetric measure of spread based on quantiles: quartiles work well but aren't essential) is that in any batch the $q^\text{th}$ quantile of the transformed data $\phi(x_j)$ coincides with $\phi$ applied to the $q^\text{th}$ quantile of the original data $(x_j)$. (This is not generally true for other measures of spread.) Using quantile-based statistics is not a serious limitation: if the batches of data have roughly the same shape, then the median and IQR will be in the same proportion to any other reasonable measures of location and spread, so Emerson's analysis will produce the correct $\phi$ to stabilize other measures of spread, such as the standard deviation.
The idea is to approximate $\phi$ to second order at $\nu$ and track what it does to the spread $\tau(\nu)$. To that end, express the quartiles as displacements from the median, using the spread $\tau(\nu)$ as the natural measure of distance. The upper quartile can be written as $\nu+\lambda(\nu)\tau(\nu)$ with $0 \le \lambda(\nu) \le 1$; the lower quartile therefore must be $\nu-(1-\lambda(\nu))\tau(\nu)$. Applying $\phi$ and writing out its Taylor series we find that the new quartiles are
$$\phi(\nu) + \phi'(\nu)\left(\lambda(\nu)\tau(\nu)\right) + \frac{1}{2!}\phi''(\nu)\left(\lambda(\nu)\tau(\nu)\right)^2 + o(\tau(\nu)^2)$$
and
$$\phi(\nu) - \phi'(\nu)\left(1-\lambda(\nu)\tau(\nu)\right) + \frac{1}{2!}\phi''(\nu)\left(1-\lambda(\nu)\tau(\nu)\right)^2 + o(\tau(\nu)^2).$$
The new IQR is obtained by subtraction. The zeroth order terms cancel, the first order terms just multiply the original spread, and the second order terms give something that needs analyzing:
$$\phi'(\nu)\tau(\nu) + \frac{1}{2!}\phi''(\nu)\left(2\lambda(\nu)\tau(\nu)-1\right) + o(\tau(\nu)^2).$$
At this point Emerson argues that the second-order term is negligible, for several reasons:
If the median is roughly centered between the quartiles (that is, the middle half of each batch is roughly symmetric), then $\lambda(\nu)\approx 1/2 \approx 1 - \lambda(\nu)$, making $\left(2\lambda(\nu)-1\right)$ small.
If $\phi$ is not too "strong," it shouldn't be terribly curved near the median, making $\phi''(\nu)$ also small.
(As an example of (2) Emerson offers the case of $\phi = \log$ where $\nu=10$, pointing out that $\phi'(\nu) = 1/\nu = 0.1$ and $\phi''(\nu) = -1/\nu^2 = -0.01$, a "relatively small" value. This looks specious to me, for if we were merely to change the units of measure of the data (as from meters to kilometers) we might now find that $\nu=0.01$, for which $\phi'(\nu)=100$ and $\phi''(\nu)=10000$! The mistake here is that the values $100$ and $10000$ aren't even comparable: they are in different units. What we should be concerned about is the product $\phi''(\nu)\tau(\nu)^2$, because it overestimates how much $\phi$ will change between the two quartiles. To pursue Emerson's example, if the data are positive and their median is $\nu=10$, then likely the lower quartile is close to $10$ and we can hope the upper quartile isn't too far from it, either. In this case $\tau(10) \ll 10$, so $\phi''(10)\tau(10)^2 \ll 0.01 \times (10^2) \ll 1,$ justifying dropping the second-order term. Although this paragraph may seem technical, it provides insight into just why this analysis works and suggests how to identify cases where it might fail or at least should be mistrusted.)
The upshot is that to stabilize the spread, the derivative of the transformation (applied at the middle of the batch, $\nu$) needs to be inversely proportional to the spread itself (provided the quartiles are not both asymmetrically placed and far from the median as a proportion of the median). Because this inverse proportion needs to hold for the entire range of locational values of the batches, we immediately obtain the general solution
$$\phi(\nu) \propto \int^\nu \frac{dx}{\tau(x)}.$$
The situation posited in the question is that the spread is proportional to the level: $\tau(\nu) \propto \nu$. The solution is
$$\phi(\nu) \propto \int^\nu \frac{dx}{x} = \log(\nu),$$
QED.
To put this general result into practice, we make a spread-versus-level plot. Its objective, beyond visualizing how the spreads relate to the levels for the batches, often is to find a Box-Cox (power) transformation $\phi$. We easily see that if $\phi(\nu) \propto \nu^p$ for some power $p\ne 1$, then $\tau(\nu) \propto \nu^{1-p}$. When $p=1$, $\tau(\nu) \propto \log(\nu)$. Therefore, we should seek a power function fit to the spread ($\tau$)-versus-level ($\nu$) plot. A simple way to do this is to fit a straight line on log-log axes, preferably using a method that is resistant to outlying or unusual values. (A visual fit is usually fine but is hard to automate.) The slope of the line is the power $1-p$. For instance, when the spread is proportional to the level the line will have slope $1 = 1-p$ yielding $p=0$, corresponding to the logarithm.
Here is a synthetic example. Let's generate independent samples of squared Poisson variates with different levels (theory tells us the variance-stabilizing power transformation is $p=1/4$). The figure shows the spread-vs-level plot, boxplots of the original batches (with medians removed so we can readily compare their spreads), and similar boxplots of the transformed batches. The improvement is clear. In this case the spread-vs-level method works spectacularly well: the slope of the plot is $3/4$, indicating $p=1-3/4=1/4$ is the spread-stabilizing power, exactly as predicted theoretically. (In my experience this method works more often than not, but still should be considered only as a guide or starting point for refining the Box-Cox parameter.)
Here is the R code that produced this example.
#
# Create data.
#
set.seed(17)
k <- 8 # Number of batches
n <- rpois(k, 20) # Batch sizes
lambda <- exp(rnorm(k, 1.5)) # Levels
x.l <- lapply(1:k, function(i) rpois(n[i], lambda[i])^2)
#
# Make a spread-vs-level plot.
#
medians <- sapply(x.l, median)
IQRs <- sapply(x.l, function(y) diff(quantile(y, c(1/4, 3/4))))
par(mfrow=c(1,3))
plot(log(medians), log(IQRs), main="Spread vs. Level",
xlab="Log median", ylab="Log IQR")
#
# Fit a line to the plot.
# NB The fit is weighted by batch size; this was not suggested by Emerson
# but is a good idea when batches differ substantially in size.
#
library(MASS)
ab <- rlm(log(IQRs) ~ log(medians), weights=n)
abline(coef(ab), col="Red")
p <- 1 - coef(ab)[2] # The Box-Cox parameter to stabilize spread
#
# Look at how well the batches have been stabilized.
#
i <- order(medians)
boxplot(lapply(x.l, function(y) y-median(y))[i], main="Data (medians removed)")
boxplot(lapply(x.l, function(y) {z <- (y^p - 1)/p; z - median(z)})[i],
main=paste("Box-Cox (",round(p,2),")", sep=""))
Reference
John D. Emerson, Mathematical Aspects of Transformation. In Hoaglin, David C., Frederick Mosteller, and John W. Tukey, eds, Understanding Robust and Exploratory Data Analysis. John Wiley & Sons, 1983.
|
Questions on standard deviation of a time series
Thirty years ago, John Emerson provided a simple explanation of an extremely useful generalization of this phenomenon. Here is the essence of it.
Suppose you have batches of data (which could include
|
44,414
|
Questions on standard deviation of a time series
|
Level here is to be understood as mean.
This is an approximation at best, but it does not depend on data being a time series, let alone economic data!
For a fairly detailed discussion in a wider setting, see
J.H. Curtiss. 1943.
On transformations used in the analysis of variance.
Annals of Mathematical Statistics 14: 107-122.
Link
A side-comment important to some kinds of statistics users is that standard deviation being proportional to mean clearly implies that their ratio is a constant. That ratio is the coefficient of variation, which is therefore a natural property for description in this circumstance.
|
Questions on standard deviation of a time series
|
Level here is to be understood as mean.
This is an approximation at best, but it does not depend on data being a time series, let alone economic data!
For a fairly detailed discussion in a wider setti
|
Questions on standard deviation of a time series
Level here is to be understood as mean.
This is an approximation at best, but it does not depend on data being a time series, let alone economic data!
For a fairly detailed discussion in a wider setting, see
J.H. Curtiss. 1943.
On transformations used in the analysis of variance.
Annals of Mathematical Statistics 14: 107-122.
Link
A side-comment important to some kinds of statistics users is that standard deviation being proportional to mean clearly implies that their ratio is a constant. That ratio is the coefficient of variation, which is therefore a natural property for description in this circumstance.
|
Questions on standard deviation of a time series
Level here is to be understood as mean.
This is an approximation at best, but it does not depend on data being a time series, let alone economic data!
For a fairly detailed discussion in a wider setti
|
44,415
|
Questions on standard deviation of a time series
|
We can view the time series as a realization of a sequence of random variables $Y_t$, where $Y_t$ has expected value $X_t$ (the level) and, in the case you describe, standard deviation proportional to $X_t$ - let's say it is $c X_t$ for some constant $c$. So for a fixed value of $t$, we can view $X_t$ as a constant and $Y_t$ as a random variable.
If the distribution of $Y_t$ is normal, and we take logarithms, then we get data $\ln Y_t$. We typically do this only if the standard deviation of $Y_t$ is small, relative to its mean - in particular, we don't want to have negative values $Y_t$. If we assume $Y_t$ is normally distributed and its standard deviation is much smaller than its mean (i.e., $c \ll 1$), then $\ln Y_t$ is approximately normally distributed with mean $\ln X_t$. The deviations from the mean are then approximately equal to $\ln Y_t - \ln X_t = \ln \frac{Y_t}{X_t}$. Since $Y_t$ was normally distributed with mean $X_t$ and standard deviation $c X_t$, the quotient $\frac{Y_t}{X_t}$ is normally distributed with mean 1 and standard deviation $c$. Using $c \ll 1$, we can approximate the distribution of its logarithm as having mean 0 and standard deviation $c$.
Now we can let $t$ vary again, and we see that $\ln Y_t$ has a standard deviation that doesn't depend on $t$ - in other words, it's constant.
|
Questions on standard deviation of a time series
|
We can view the time series as a realization of a sequence of random variables $Y_t$, where $Y_t$ has expected value $X_t$ (the level) and, in the case you describe, standard deviation proportional to
|
Questions on standard deviation of a time series
We can view the time series as a realization of a sequence of random variables $Y_t$, where $Y_t$ has expected value $X_t$ (the level) and, in the case you describe, standard deviation proportional to $X_t$ - let's say it is $c X_t$ for some constant $c$. So for a fixed value of $t$, we can view $X_t$ as a constant and $Y_t$ as a random variable.
If the distribution of $Y_t$ is normal, and we take logarithms, then we get data $\ln Y_t$. We typically do this only if the standard deviation of $Y_t$ is small, relative to its mean - in particular, we don't want to have negative values $Y_t$. If we assume $Y_t$ is normally distributed and its standard deviation is much smaller than its mean (i.e., $c \ll 1$), then $\ln Y_t$ is approximately normally distributed with mean $\ln X_t$. The deviations from the mean are then approximately equal to $\ln Y_t - \ln X_t = \ln \frac{Y_t}{X_t}$. Since $Y_t$ was normally distributed with mean $X_t$ and standard deviation $c X_t$, the quotient $\frac{Y_t}{X_t}$ is normally distributed with mean 1 and standard deviation $c$. Using $c \ll 1$, we can approximate the distribution of its logarithm as having mean 0 and standard deviation $c$.
Now we can let $t$ vary again, and we see that $\ln Y_t$ has a standard deviation that doesn't depend on $t$ - in other words, it's constant.
|
Questions on standard deviation of a time series
We can view the time series as a realization of a sequence of random variables $Y_t$, where $Y_t$ has expected value $X_t$ (the level) and, in the case you describe, standard deviation proportional to
|
44,416
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
|
Here is an example using the R rms package orm function. The three variables are defined in the original question above. First we see which of 3 families yields the most parallelism.
require(rms)
row <- 0
for(gvar in list(pred_1, pred_2)) {
row <- row + 1; col <- 0
for(fun in list(qlogis, qnorm, function(y) -log(-log(y)))) {
col <- col + 1
print(Ecdf(~resp, groups=gvar, fun=fun,
main=paste(c('pred_1','pred_2')[row],
c('logit','probit','log-log')[col])),
split=c(col,row,3,2), more=row < 2 | col < 3)
}
}
The proportional odds model does as well as any as judged by the logit transform of the ECDF. Next fit the model, assess the global null hypothesis (P=0.175) and plot predicted means. pred_1 is treated as linear.
f <- orm(resp ~ pred_1 + pred_2)
f
Logistic (Proportional Odds) Ordinal Regression Model
orm(formula = resp ~ pred_1 + pred_2)
Model Likelihood Discrimination Rank Discrim.
Ratio Test Indexes Indexes
Obs 120 LR chi2 4.96 R2 0.041 rho 0.183
Unique Y 41 d.f. 3 g 0.407
Median Y 0.06666667 Pr(> chi2) 0.1751 gr 1.502
max |deriv| 2e-07 Score chi2 4.94 |Pr(Y>=median)-0.5| 0.077
Pr(> chi2) 0.1761
Coef S.E. Wald Z Pr(>|Z|)
pred_1 -0.0097 0.0046 -2.11 0.0346
pred_2=b 0.2822 0.3909 0.72 0.4703
pred_2=c 0.0734 0.3923 0.19 0.8517
anova(f)
Wald Statistics Response: resp
Factor Chi-Square d.f. P
pred_1 4.47 1 0.0346
pred_2 0.57 2 0.7531
TOTAL 4.88 3 0.1809
dd <- datadist(pred_1, pred_2); options(datadist='dd')
bar <- Mean(f)
plot(Predict(f, fun=bar), ylab='Predicted Mean')
Plot predicted odds ratios. For the numeric predictor, use inter-quartile-range odds ratio.
plot(summary(f), log=TRUE)
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
|
Here is an example using the R rms package orm function. The three variables are defined in the original question above. First we see which of 3 families yields the most parallelism.
require(rms)
ro
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
Here is an example using the R rms package orm function. The three variables are defined in the original question above. First we see which of 3 families yields the most parallelism.
require(rms)
row <- 0
for(gvar in list(pred_1, pred_2)) {
row <- row + 1; col <- 0
for(fun in list(qlogis, qnorm, function(y) -log(-log(y)))) {
col <- col + 1
print(Ecdf(~resp, groups=gvar, fun=fun,
main=paste(c('pred_1','pred_2')[row],
c('logit','probit','log-log')[col])),
split=c(col,row,3,2), more=row < 2 | col < 3)
}
}
The proportional odds model does as well as any as judged by the logit transform of the ECDF. Next fit the model, assess the global null hypothesis (P=0.175) and plot predicted means. pred_1 is treated as linear.
f <- orm(resp ~ pred_1 + pred_2)
f
Logistic (Proportional Odds) Ordinal Regression Model
orm(formula = resp ~ pred_1 + pred_2)
Model Likelihood Discrimination Rank Discrim.
Ratio Test Indexes Indexes
Obs 120 LR chi2 4.96 R2 0.041 rho 0.183
Unique Y 41 d.f. 3 g 0.407
Median Y 0.06666667 Pr(> chi2) 0.1751 gr 1.502
max |deriv| 2e-07 Score chi2 4.94 |Pr(Y>=median)-0.5| 0.077
Pr(> chi2) 0.1761
Coef S.E. Wald Z Pr(>|Z|)
pred_1 -0.0097 0.0046 -2.11 0.0346
pred_2=b 0.2822 0.3909 0.72 0.4703
pred_2=c 0.0734 0.3923 0.19 0.8517
anova(f)
Wald Statistics Response: resp
Factor Chi-Square d.f. P
pred_1 4.47 1 0.0346
pred_2 0.57 2 0.7531
TOTAL 4.88 3 0.1809
dd <- datadist(pred_1, pred_2); options(datadist='dd')
bar <- Mean(f)
plot(Predict(f, fun=bar), ylab='Predicted Mean')
Plot predicted odds ratios. For the numeric predictor, use inter-quartile-range odds ratio.
plot(summary(f), log=TRUE)
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
Here is an example using the R rms package orm function. The three variables are defined in the original question above. First we see which of 3 families yields the most parallelism.
require(rms)
ro
|
44,417
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
|
For regular (OLS) regression your response variable does not have to be normally distributed. The model assumes that the residuals from your model are normally distributed. You can first run regular regression and check the residuals, e.g.
m1 <- lm(resp~pred1 + pred2)
plot(m1)
This might be "good enough" but technically, since the response variable is bounded, it isn't quite right.
One method is to transform the response, e.g. by the arcsine transformation. Given that you don't have the data that made up the proportions, you can try:
library(scales)
transresp <- asn_tras(resp)
see this page for more on this method.
Another idea would be beta regression, which allows for a bounded response. R has a betareg package.
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
|
For regular (OLS) regression your response variable does not have to be normally distributed. The model assumes that the residuals from your model are normally distributed. You can first run regular r
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
For regular (OLS) regression your response variable does not have to be normally distributed. The model assumes that the residuals from your model are normally distributed. You can first run regular regression and check the residuals, e.g.
m1 <- lm(resp~pred1 + pred2)
plot(m1)
This might be "good enough" but technically, since the response variable is bounded, it isn't quite right.
One method is to transform the response, e.g. by the arcsine transformation. Given that you don't have the data that made up the proportions, you can try:
library(scales)
transresp <- asn_tras(resp)
see this page for more on this method.
Another idea would be beta regression, which allows for a bounded response. R has a betareg package.
|
Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
For regular (OLS) regression your response variable does not have to be normally distributed. The model assumes that the residuals from your model are normally distributed. You can first run regular r
|
44,418
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
One option is to still use the KS test statistic, but instead of using the standard p-value from the KS test (which as you say is not appropriate when estimating from the data), calculate the p-value using a permutation test. The basic steps would be:
Calculate the KS test statistic for the data as is (divided by the estimates).
Now combine the 2 datasets (already divided) and randomly split them into 2 sets of 10,000 (or whatever the original sample size was) and compute the KS test for these new "samples".
Repeat the above many times (999, or 9,999).
The p-value is the proportion of test statistics that are as extreme or more extreme than your original test statistic.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
One option is to still use the KS test statistic, but instead of using the standard p-value from the KS test (which as you say is not appropriate when estimating from the data), calculate the p-value
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
One option is to still use the KS test statistic, but instead of using the standard p-value from the KS test (which as you say is not appropriate when estimating from the data), calculate the p-value using a permutation test. The basic steps would be:
Calculate the KS test statistic for the data as is (divided by the estimates).
Now combine the 2 datasets (already divided) and randomly split them into 2 sets of 10,000 (or whatever the original sample size was) and compute the KS test for these new "samples".
Repeat the above many times (999, or 9,999).
The p-value is the proportion of test statistics that are as extreme or more extreme than your original test statistic.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
One option is to still use the KS test statistic, but instead of using the standard p-value from the KS test (which as you say is not appropriate when estimating from the data), calculate the p-value
|
44,419
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
I can't make much sense of the question on any level. The detail about the values being integers is really important!
It appears that you are using a random number generator for uniform integers with different ranges (else how do you know that your distribution is uniform?). When you sample from a distribution on [0, 10] then there are 11 possible values and the mean of the distribution is necessarily 5. This is not a case where you are estimating the mean from sample data; you know the mean. Similarly, the distribution on [0, 100] has 101 possible values and the mean of such a distribution is 50. Extending this, the usual general advice about location, scale and shape parameters and Kolmogorov-Smirnov tests is irrelevant, because the range of a uniform distribution defines the distribution uniquely.
If you scale by the mean of each distribution, then the possible values are 0, 0.2, ..., 1.8, 2 in one case and 0, 0.02, ..., 1.98, 2 which in principle are not exactly the same distribution. With a large enough sample size, a Kolmogorov-Smirnov test might detect this, but the problem is that K-S test can't tell what fraction of any discrepancy is (a) sampling variation (b) the difference in domain of the distributions (c) something else.
If you used a random number generator then your question boils down (other than the question of different domains) to whether the generator is any good and you will need better and different tests to find flaws in the random number generator of any respectable statistical software.
It's possible that you just have data on 0, 1, ..., 9, 10 and 0, 1, ..., 99, 100 and your hypothesis is that both distributions are uniform, in which case problem #2 still bites. I'd still argue that the means are part of the hypothesis and don't need to be estimated from the data.
A personal prejudice is that the Kolmogorov-Smirnov test is overrated any way. If it reveals a problem, you need other methods to find out what the problem is. With 10,000 data points important discrepancies will show up on a quantile-quantile plot of the two distributions and/or quantile plots of each separately.
Alternatively, the histograms should clearly be flat and that is an easy thing to try.
How well the K-S test works with discrete distributions is also a crucial question. Others will be deeper into the literature and theory, but my instinct is that discreteness doesn't help.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
I can't make much sense of the question on any level. The detail about the values being integers is really important!
It appears that you are using a random number generator for uniform integers wit
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
I can't make much sense of the question on any level. The detail about the values being integers is really important!
It appears that you are using a random number generator for uniform integers with different ranges (else how do you know that your distribution is uniform?). When you sample from a distribution on [0, 10] then there are 11 possible values and the mean of the distribution is necessarily 5. This is not a case where you are estimating the mean from sample data; you know the mean. Similarly, the distribution on [0, 100] has 101 possible values and the mean of such a distribution is 50. Extending this, the usual general advice about location, scale and shape parameters and Kolmogorov-Smirnov tests is irrelevant, because the range of a uniform distribution defines the distribution uniquely.
If you scale by the mean of each distribution, then the possible values are 0, 0.2, ..., 1.8, 2 in one case and 0, 0.02, ..., 1.98, 2 which in principle are not exactly the same distribution. With a large enough sample size, a Kolmogorov-Smirnov test might detect this, but the problem is that K-S test can't tell what fraction of any discrepancy is (a) sampling variation (b) the difference in domain of the distributions (c) something else.
If you used a random number generator then your question boils down (other than the question of different domains) to whether the generator is any good and you will need better and different tests to find flaws in the random number generator of any respectable statistical software.
It's possible that you just have data on 0, 1, ..., 9, 10 and 0, 1, ..., 99, 100 and your hypothesis is that both distributions are uniform, in which case problem #2 still bites. I'd still argue that the means are part of the hypothesis and don't need to be estimated from the data.
A personal prejudice is that the Kolmogorov-Smirnov test is overrated any way. If it reveals a problem, you need other methods to find out what the problem is. With 10,000 data points important discrepancies will show up on a quantile-quantile plot of the two distributions and/or quantile plots of each separately.
Alternatively, the histograms should clearly be flat and that is an easy thing to try.
How well the K-S test works with discrete distributions is also a crucial question. Others will be deeper into the literature and theory, but my instinct is that discreteness doesn't help.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
I can't make much sense of the question on any level. The detail about the values being integers is really important!
It appears that you are using a random number generator for uniform integers wit
|
44,420
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
It may be possible that a distribution-free test like the Wilcoxon-Mann-Whitney, which is a test based on rank, not value. In your example, multiplying all the values from Data1 will not change their respective iinternal ranks, but now they will be on the same "scale" as Data2. As such, the MWW test may provide you with insight as to whether or not "rescaled" Data1 is "different" from Data2. Of course there will be "clusters" in Data1 and probably none in Data2, in which case you may want to consider some type of kernel smoothing.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
|
It may be possible that a distribution-free test like the Wilcoxon-Mann-Whitney, which is a test based on rank, not value. In your example, multiplying all the values from Data1 will not change their
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
It may be possible that a distribution-free test like the Wilcoxon-Mann-Whitney, which is a test based on rank, not value. In your example, multiplying all the values from Data1 will not change their respective iinternal ranks, but now they will be on the same "scale" as Data2. As such, the MWW test may provide you with insight as to whether or not "rescaled" Data1 is "different" from Data2. Of course there will be "clusters" in Data1 and probably none in Data2, in which case you may want to consider some type of kernel smoothing.
|
Alternative to Kolmogorov-Smirnov test when parameters are estimated from the data
It may be possible that a distribution-free test like the Wilcoxon-Mann-Whitney, which is a test based on rank, not value. In your example, multiplying all the values from Data1 will not change their
|
44,421
|
Can one measure the degree of empirical data being Gaussian?
|
There are an infinite number of ways of being non-Gaussian.
For example, you mentioned skewness and kurtosis - while those measures are certainly ways of identifying distributions that aren't Gaussian, and they can be combined into a single measure of deviation from Gaussian-ness* (and even form the basis of some common tests of normality), they're terrible at identifying distributions that have the same skewness and kurtosis as a normal but are distinctly non-normal.
* (see the tests by Bowman and Shenton and the better known - but less well-done, I think - work of Jarque and Bera)
Here's an example of the density of one such distribution:
It's bimodal, but has skewness 0, and kurtosis 3.00 (i.e. an excess kurtosis of 0), the same as the normal.
A measure based on skewness and kurtosis is going to be terrible at identifying distributions such as these. Of course, if you're not worried about such possibilities, this may not matter - if you mainly want to pick up cases where the skewness and kurtosis deviate from those of the normal, a test based on those two measures is relatively powerful.
(Incidentally, the Shapiro-Wilk test is fairly good at spotting this one.)
Ultimately, choosing such a measure (whether you intend to formally test it or not) is a matter of finding things that are good at distinguishing the particular kinds of non-normality you care about. (In hypothesis-test-ese, the ones that have good power against the specific alternatives of interest.)
So work out what features you want to 'see' best, and choose a measure that is good at seeing those things.
The chi-square you mention probably refers to the chi-square goodness of fit test. It's generally a very weak test of goodness of fit for anything other than distributions over nominal categories. (Alternatively, it might be a reference to the asymptotic chi-square distribution of the Jarque-Bera type test. Be warned, the asymptotics there 'kick in' very slowly - you need a very large n for the distribution of the test statistic to be close to normal -- see Bowman and Shenton's paper -- which predates the one by Jarque and Bera. My own simulations from back in the 80s suggest that n=200 is not close to adequate - at least for the sort of adherence to significance levels I'd look for - but it's generally pretty reasonable by about n=500)
Popular tests of normality would start with the Shapiro-Wilk and Shapiro-Francia. The Anderson-Darling** test can be adapted to work with parameter estimation and has good power. There's also smooth tests of goodness of fit (see the little book by Rayner and Best by that name, and their many papers, as well as the more recent book on Smooth tests in R); the smooth test for normality is quite powerful.
** With hypothesis tests that assume a completely specified distribution, such as the Kolmogorov-Smirnov and the Anderson-Darling, avoid using tests of normality based off estimated parameter values. The tests don't have the right properties, unless you account for that effect. In the case of the K-S, you end up with what's called a Lilliefors test. With the A-D it's still called an A-D test and if you check the book by D'Agostino & Stephens I mention below, there are approximations which adapt the usual test that seem to work quite well even with fairly small n.
If you don't want a formal hypothesis test, just about any of the usual test statistics can be adapted to be a measure that has some kind of interpretation or other as a measure of non-normality. For example, a Shapiro-Francia test statistic can be seen as a rescaled version of a squared correlation of observations with their normal scores (expected normal order statistics), and such a measure is an excellent accompaniment to a normal QQ plot.
I want to determine if these data are Gaussian.
I bet you a dollar they aren't Gaussian, and I bet you don't even need a test to tell that. What you really want to know is likely something else.
Note that usually the interesting question isn't 'are my data normal' (the answer is almost always 'obviously not', even before you collect any observations). The interesting question is 'how badly will the non-normality I have affect whatever I am trying to do?' ... and that's usually better judged by some measure of how non-normal it is, rather than a p-value.
Good places to start reading about goodness of fit (if you have access to a suitable library) would be the book Goodness of Fit Techniques by D'Agostino and Stephens and the aforementioned book on smooth tests by Rayner and Best; alternatively there are many papers and discussions you can find online, including many answers relating to goodness of fit here. Outside of some papers that are online, smooth tests can be hard to find information on, but one of Cosma Shalizi's courses has some excellent notes see here that serve as a (somewhat mathematical) introduction to the ideas.
[Goodness of fit is a surprisingly big area.]
For additional useful points, see also here or here or here or here
|
Can one measure the degree of empirical data being Gaussian?
|
There are an infinite number of ways of being non-Gaussian.
For example, you mentioned skewness and kurtosis - while those measures are certainly ways of identifying distributions that aren't Gaussian
|
Can one measure the degree of empirical data being Gaussian?
There are an infinite number of ways of being non-Gaussian.
For example, you mentioned skewness and kurtosis - while those measures are certainly ways of identifying distributions that aren't Gaussian, and they can be combined into a single measure of deviation from Gaussian-ness* (and even form the basis of some common tests of normality), they're terrible at identifying distributions that have the same skewness and kurtosis as a normal but are distinctly non-normal.
* (see the tests by Bowman and Shenton and the better known - but less well-done, I think - work of Jarque and Bera)
Here's an example of the density of one such distribution:
It's bimodal, but has skewness 0, and kurtosis 3.00 (i.e. an excess kurtosis of 0), the same as the normal.
A measure based on skewness and kurtosis is going to be terrible at identifying distributions such as these. Of course, if you're not worried about such possibilities, this may not matter - if you mainly want to pick up cases where the skewness and kurtosis deviate from those of the normal, a test based on those two measures is relatively powerful.
(Incidentally, the Shapiro-Wilk test is fairly good at spotting this one.)
Ultimately, choosing such a measure (whether you intend to formally test it or not) is a matter of finding things that are good at distinguishing the particular kinds of non-normality you care about. (In hypothesis-test-ese, the ones that have good power against the specific alternatives of interest.)
So work out what features you want to 'see' best, and choose a measure that is good at seeing those things.
The chi-square you mention probably refers to the chi-square goodness of fit test. It's generally a very weak test of goodness of fit for anything other than distributions over nominal categories. (Alternatively, it might be a reference to the asymptotic chi-square distribution of the Jarque-Bera type test. Be warned, the asymptotics there 'kick in' very slowly - you need a very large n for the distribution of the test statistic to be close to normal -- see Bowman and Shenton's paper -- which predates the one by Jarque and Bera. My own simulations from back in the 80s suggest that n=200 is not close to adequate - at least for the sort of adherence to significance levels I'd look for - but it's generally pretty reasonable by about n=500)
Popular tests of normality would start with the Shapiro-Wilk and Shapiro-Francia. The Anderson-Darling** test can be adapted to work with parameter estimation and has good power. There's also smooth tests of goodness of fit (see the little book by Rayner and Best by that name, and their many papers, as well as the more recent book on Smooth tests in R); the smooth test for normality is quite powerful.
** With hypothesis tests that assume a completely specified distribution, such as the Kolmogorov-Smirnov and the Anderson-Darling, avoid using tests of normality based off estimated parameter values. The tests don't have the right properties, unless you account for that effect. In the case of the K-S, you end up with what's called a Lilliefors test. With the A-D it's still called an A-D test and if you check the book by D'Agostino & Stephens I mention below, there are approximations which adapt the usual test that seem to work quite well even with fairly small n.
If you don't want a formal hypothesis test, just about any of the usual test statistics can be adapted to be a measure that has some kind of interpretation or other as a measure of non-normality. For example, a Shapiro-Francia test statistic can be seen as a rescaled version of a squared correlation of observations with their normal scores (expected normal order statistics), and such a measure is an excellent accompaniment to a normal QQ plot.
I want to determine if these data are Gaussian.
I bet you a dollar they aren't Gaussian, and I bet you don't even need a test to tell that. What you really want to know is likely something else.
Note that usually the interesting question isn't 'are my data normal' (the answer is almost always 'obviously not', even before you collect any observations). The interesting question is 'how badly will the non-normality I have affect whatever I am trying to do?' ... and that's usually better judged by some measure of how non-normal it is, rather than a p-value.
Good places to start reading about goodness of fit (if you have access to a suitable library) would be the book Goodness of Fit Techniques by D'Agostino and Stephens and the aforementioned book on smooth tests by Rayner and Best; alternatively there are many papers and discussions you can find online, including many answers relating to goodness of fit here. Outside of some papers that are online, smooth tests can be hard to find information on, but one of Cosma Shalizi's courses has some excellent notes see here that serve as a (somewhat mathematical) introduction to the ideas.
[Goodness of fit is a surprisingly big area.]
For additional useful points, see also here or here or here or here
|
Can one measure the degree of empirical data being Gaussian?
There are an infinite number of ways of being non-Gaussian.
For example, you mentioned skewness and kurtosis - while those measures are certainly ways of identifying distributions that aren't Gaussian
|
44,422
|
Does lm() use partial correlation - R Squared Change?
|
Another function that you might find useful is lm.sumSquares in the lmSupport package. Basically, if you have the following model:
mod1 <- lm(dv ~ iv1 + iv2 + iv3, data = d)
Executing the following will give you the delta R squared (the semipartial correlation squared) and PRE (the partial correlation squared) for iv1, iv2, and iv3:
lm.sumSquares(mod1)
lmSupport also contains the function lm.deltaR2 that allows you to compare custom models against each other to obtain the change in R squared and the F-statistic associated with the R squared change. So, going back to the above example, if you also had this second model:
mod2 <- lm(dv ~ iv1 + iv2 + iv3 + iv4 + iv5, data = d)
Then you could do the following to obtain the R squared change for adding iv4 and iv5 and the accompanying F statistic and p-value:
lm.deltaR2(mod1, mod2)
Hope that helps!
|
Does lm() use partial correlation - R Squared Change?
|
Another function that you might find useful is lm.sumSquares in the lmSupport package. Basically, if you have the following model:
mod1 <- lm(dv ~ iv1 + iv2 + iv3, data = d)
Executing the following
|
Does lm() use partial correlation - R Squared Change?
Another function that you might find useful is lm.sumSquares in the lmSupport package. Basically, if you have the following model:
mod1 <- lm(dv ~ iv1 + iv2 + iv3, data = d)
Executing the following will give you the delta R squared (the semipartial correlation squared) and PRE (the partial correlation squared) for iv1, iv2, and iv3:
lm.sumSquares(mod1)
lmSupport also contains the function lm.deltaR2 that allows you to compare custom models against each other to obtain the change in R squared and the F-statistic associated with the R squared change. So, going back to the above example, if you also had this second model:
mod2 <- lm(dv ~ iv1 + iv2 + iv3 + iv4 + iv5, data = d)
Then you could do the following to obtain the R squared change for adding iv4 and iv5 and the accompanying F statistic and p-value:
lm.deltaR2(mod1, mod2)
Hope that helps!
|
Does lm() use partial correlation - R Squared Change?
Another function that you might find useful is lm.sumSquares in the lmSupport package. Basically, if you have the following model:
mod1 <- lm(dv ~ iv1 + iv2 + iv3, data = d)
Executing the following
|
44,423
|
Does lm() use partial correlation - R Squared Change?
|
R doesn't use partial correlations to determine reported p-values from lm.
Indeed, you can examine the code that computes the p-values for yourself; if you type
> summary.lm
you will see the code of the function includes the following:
ans$coefficients <- cbind(est, se, tval, 2 * pt(abs(tval),
rdf, lower.tail = FALSE))
which shows that for each variable, the p-value is computed from the t value by looking up t tail-areas
It is quite easy to compute changes in R^2 between models if you need to do that, but I expect one of the many packages on CRAN does it already.
|
Does lm() use partial correlation - R Squared Change?
|
R doesn't use partial correlations to determine reported p-values from lm.
Indeed, you can examine the code that computes the p-values for yourself; if you type
> summary.lm
you will see the code of
|
Does lm() use partial correlation - R Squared Change?
R doesn't use partial correlations to determine reported p-values from lm.
Indeed, you can examine the code that computes the p-values for yourself; if you type
> summary.lm
you will see the code of the function includes the following:
ans$coefficients <- cbind(est, se, tval, 2 * pt(abs(tval),
rdf, lower.tail = FALSE))
which shows that for each variable, the p-value is computed from the t value by looking up t tail-areas
It is quite easy to compute changes in R^2 between models if you need to do that, but I expect one of the many packages on CRAN does it already.
|
Does lm() use partial correlation - R Squared Change?
R doesn't use partial correlations to determine reported p-values from lm.
Indeed, you can examine the code that computes the p-values for yourself; if you type
> summary.lm
you will see the code of
|
44,424
|
Does lm() use partial correlation - R Squared Change?
|
I'm no R expert but I've looked into this same issue (your 2nd and 3rd questions) and found the following.
You do need first to run the lm command for each model separately.
If a formal test of the F associated with the change is of interest to you, you can formally compare successive models using anova, e.g., anova(MyModel1, MyModel2).
This anova test will only work if each solution is based on the same subset of cases. So you may need to run a command at the outset such as mydata=na.omit(mydata).
EDIT: the relaimpo package's calc.relimp command ("relative importance") calculates delta rsq for each predictor when entered last (its semipartial rsq) and/or when entered first (its zero-order rsq).
install.packages("relaimpo", dep=c("Depends"))
library(relaimpo)
calc.relimp( MyRegressionModel, type = c("last", "first") )
|
Does lm() use partial correlation - R Squared Change?
|
I'm no R expert but I've looked into this same issue (your 2nd and 3rd questions) and found the following.
You do need first to run the lm command for each model separately.
If a formal test of the F
|
Does lm() use partial correlation - R Squared Change?
I'm no R expert but I've looked into this same issue (your 2nd and 3rd questions) and found the following.
You do need first to run the lm command for each model separately.
If a formal test of the F associated with the change is of interest to you, you can formally compare successive models using anova, e.g., anova(MyModel1, MyModel2).
This anova test will only work if each solution is based on the same subset of cases. So you may need to run a command at the outset such as mydata=na.omit(mydata).
EDIT: the relaimpo package's calc.relimp command ("relative importance") calculates delta rsq for each predictor when entered last (its semipartial rsq) and/or when entered first (its zero-order rsq).
install.packages("relaimpo", dep=c("Depends"))
library(relaimpo)
calc.relimp( MyRegressionModel, type = c("last", "first") )
|
Does lm() use partial correlation - R Squared Change?
I'm no R expert but I've looked into this same issue (your 2nd and 3rd questions) and found the following.
You do need first to run the lm command for each model separately.
If a formal test of the F
|
44,425
|
Does the Tukey HSD test correct for multiple comparisons?
|
It is not necessary to correct for multiple comparisons when using Tukey's HSD. The procedure was developed specifically to account for multiple comparison and maintains experiment-wise alpha at the specified level (conventionally .05). Page 210 of Maxwell and Delaney's book on experimental design has explanations and examples of the procedure.
|
Does the Tukey HSD test correct for multiple comparisons?
|
It is not necessary to correct for multiple comparisons when using Tukey's HSD. The procedure was developed specifically to account for multiple comparison and maintains experiment-wise alpha at the s
|
Does the Tukey HSD test correct for multiple comparisons?
It is not necessary to correct for multiple comparisons when using Tukey's HSD. The procedure was developed specifically to account for multiple comparison and maintains experiment-wise alpha at the specified level (conventionally .05). Page 210 of Maxwell and Delaney's book on experimental design has explanations and examples of the procedure.
|
Does the Tukey HSD test correct for multiple comparisons?
It is not necessary to correct for multiple comparisons when using Tukey's HSD. The procedure was developed specifically to account for multiple comparison and maintains experiment-wise alpha at the s
|
44,426
|
Increase sample size for significant correlation
|
I take it that you are investigating whether the correlation between two quantities is larger than $0$ and that you wish to know how many patients you need for your study to be able to show that it really is larger. In other words, I assume that you are using a one-sided test.
First of all, even if you collect a million samples, there is no guarantee that you will get a significant result. If the correlation actually is $0$, then you likely won't get a significant result. But even if it is non-zero, there is always a possibility that you, due to randomness, won't get a significant result.
Second, how large the sample needs to be depends on how large the true correlation is.
I ran a quick computer simulation ($10,000$ repetitions) to investigate how large the sample size needs to be in order to get a high probability of a significant result. It is based on the assumption that the quantities that you measure are normally distributed. If that is not the case, then these calculations will be in error. Not necessarily a large error, but nevertheless in error.
The plots below show what the probability of getting a significant ($p<0.05$) result (called the power of the test) for different sample sizes ($n$) and different true values of the population correlation (rho=$\rho$):
If $\rho=0.2$ and $n=80$, the probability of a significant result is roughly $50~\%$. If $\rho=0.1$ and $n=80$, the probability is about $20~\%$. As you can see, it is easier to detect a large correlation than a small one.
What is typically done in these cases is to say "if $\rho=0.2$ then I want at least an $80~\%$ probability of a significant result" and to choose the smallest $n$ that satisifies that condition.
As a final remark, there are sequential sampling methods where you collect more samples until you get a significant result, but there are some caveats to them. If you're thinking of using such a sampling strategy I recommend that you consult a statistican to make sure that you use it in the right way.
|
Increase sample size for significant correlation
|
I take it that you are investigating whether the correlation between two quantities is larger than $0$ and that you wish to know how many patients you need for your study to be able to show that it re
|
Increase sample size for significant correlation
I take it that you are investigating whether the correlation between two quantities is larger than $0$ and that you wish to know how many patients you need for your study to be able to show that it really is larger. In other words, I assume that you are using a one-sided test.
First of all, even if you collect a million samples, there is no guarantee that you will get a significant result. If the correlation actually is $0$, then you likely won't get a significant result. But even if it is non-zero, there is always a possibility that you, due to randomness, won't get a significant result.
Second, how large the sample needs to be depends on how large the true correlation is.
I ran a quick computer simulation ($10,000$ repetitions) to investigate how large the sample size needs to be in order to get a high probability of a significant result. It is based on the assumption that the quantities that you measure are normally distributed. If that is not the case, then these calculations will be in error. Not necessarily a large error, but nevertheless in error.
The plots below show what the probability of getting a significant ($p<0.05$) result (called the power of the test) for different sample sizes ($n$) and different true values of the population correlation (rho=$\rho$):
If $\rho=0.2$ and $n=80$, the probability of a significant result is roughly $50~\%$. If $\rho=0.1$ and $n=80$, the probability is about $20~\%$. As you can see, it is easier to detect a large correlation than a small one.
What is typically done in these cases is to say "if $\rho=0.2$ then I want at least an $80~\%$ probability of a significant result" and to choose the smallest $n$ that satisifies that condition.
As a final remark, there are sequential sampling methods where you collect more samples until you get a significant result, but there are some caveats to them. If you're thinking of using such a sampling strategy I recommend that you consult a statistican to make sure that you use it in the right way.
|
Increase sample size for significant correlation
I take it that you are investigating whether the correlation between two quantities is larger than $0$ and that you wish to know how many patients you need for your study to be able to show that it re
|
44,427
|
Increase sample size for significant correlation
|
It depends on the test that was performed and the assumptions you make. I will assume that you want to calculate the sample size that would give a significant p-value at 0.05 given that the value of $\rho$ is still 0.2.
You can use the approximation
$$t = \rho\sqrt{\frac{n-2}{1-\rho^2}}$$
where $t$ has an approximate Student's t distribution. Since the value of $\rho$ is fixed, you need to find the value of $n$ such that $t$ is the 97.5-th percentile of a t distribution witn $n-2$ degrees of freedom. In your case I find a cutoff for $n = 97$.
|
Increase sample size for significant correlation
|
It depends on the test that was performed and the assumptions you make. I will assume that you want to calculate the sample size that would give a significant p-value at 0.05 given that the value of $
|
Increase sample size for significant correlation
It depends on the test that was performed and the assumptions you make. I will assume that you want to calculate the sample size that would give a significant p-value at 0.05 given that the value of $\rho$ is still 0.2.
You can use the approximation
$$t = \rho\sqrt{\frac{n-2}{1-\rho^2}}$$
where $t$ has an approximate Student's t distribution. Since the value of $\rho$ is fixed, you need to find the value of $n$ such that $t$ is the 97.5-th percentile of a t distribution witn $n-2$ degrees of freedom. In your case I find a cutoff for $n = 97$.
|
Increase sample size for significant correlation
It depends on the test that was performed and the assumptions you make. I will assume that you want to calculate the sample size that would give a significant p-value at 0.05 given that the value of $
|
44,428
|
Practical significance, especially with percents: "standard" measure and threshold
|
I do a lot of statistical consulting and am commonly ask the question "How many subjects do I need to recruit?" I always address the sample size question in terms of "clinical" or "practical" significance. To address that I ask them to describe how large a difference "effect size" would they want to have to claim a difference between the groups. What you call a test of "statistical" significance is really a test of practical significance because even though the critical value is set based on a standard statistical significance level such as 0.05, the sample size is dictated by the power to detect a clinically or practically significant difference. There is no standar way to do this because the level that is called clinically significant is subjective and rightfully so.
|
Practical significance, especially with percents: "standard" measure and threshold
|
I do a lot of statistical consulting and am commonly ask the question "How many subjects do I need to recruit?" I always address the sample size question in terms of "clinical" or "practical" signifi
|
Practical significance, especially with percents: "standard" measure and threshold
I do a lot of statistical consulting and am commonly ask the question "How many subjects do I need to recruit?" I always address the sample size question in terms of "clinical" or "practical" significance. To address that I ask them to describe how large a difference "effect size" would they want to have to claim a difference between the groups. What you call a test of "statistical" significance is really a test of practical significance because even though the critical value is set based on a standard statistical significance level such as 0.05, the sample size is dictated by the power to detect a clinically or practically significant difference. There is no standar way to do this because the level that is called clinically significant is subjective and rightfully so.
|
Practical significance, especially with percents: "standard" measure and threshold
I do a lot of statistical consulting and am commonly ask the question "How many subjects do I need to recruit?" I always address the sample size question in terms of "clinical" or "practical" signifi
|
44,429
|
Practical significance, especially with percents: "standard" measure and threshold
|
I don't think there is any kind of test for practical significance because it really depends on the field or the problem. Sorry.
For example, if you find that implementing a certain policy increases revenue by $0.0000001, (some negligibly small amount) even though this might be statistically significant, i.e, p-value < 0.05, practically the policy has negligible effect, so it is not practically significant. But the only way to tell about whether results are practically significant is too have good understanding of the problem. In some other cases coefficient of 0.0000001 could be very practically significant.
So basically, first you use statistical tools to see if something is statistically significant, and then use your knowledge of the field to see if something is practically significant. That's ideal case of course. Very often people try to pretend that their results are practically significant if they are statistically significant.
|
Practical significance, especially with percents: "standard" measure and threshold
|
I don't think there is any kind of test for practical significance because it really depends on the field or the problem. Sorry.
For example, if you find that implementing a certain policy increases r
|
Practical significance, especially with percents: "standard" measure and threshold
I don't think there is any kind of test for practical significance because it really depends on the field or the problem. Sorry.
For example, if you find that implementing a certain policy increases revenue by $0.0000001, (some negligibly small amount) even though this might be statistically significant, i.e, p-value < 0.05, practically the policy has negligible effect, so it is not practically significant. But the only way to tell about whether results are practically significant is too have good understanding of the problem. In some other cases coefficient of 0.0000001 could be very practically significant.
So basically, first you use statistical tools to see if something is statistically significant, and then use your knowledge of the field to see if something is practically significant. That's ideal case of course. Very often people try to pretend that their results are practically significant if they are statistically significant.
|
Practical significance, especially with percents: "standard" measure and threshold
I don't think there is any kind of test for practical significance because it really depends on the field or the problem. Sorry.
For example, if you find that implementing a certain policy increases r
|
44,430
|
Practical significance, especially with percents: "standard" measure and threshold
|
More than likely, if you're writing a paper, you're well on your way to what you need for practical significance. You've reviewed the literature and studied the subject matter and people have said, either explicitly or implicitly, what a practically significant amount is. All you need to do is cite that literature and use it in your article. If you want something just on the utility of effect sizes just google search effect size and your field (and perhaps cohen, 1962). Often there are effect size promotion papers specific to various disciplines. You could also look at Cohen 1962 as an example of how this kind of problem is approached (but not an example of what effect size is practically significant in your case-- it's unfortunate typical use).
There is no odds ratio that's a gold standard but I'm a bit surprised you're having a hard to explaining one. I suppose it's not surprising giving most textbook treatments. Betting uses odds ratios all of the time and people are familiar with it. If you need to explain it use that analogy. The odds of "Come by Chance" winning the race is 3:1 (or 3). Most people know what that means in payout. And they can see it's the number of times the horse is expected to lose the race (3) against the number of times it would win (1), or 75% of the time.
Of course, if this isn't just some proportion but something like a diagnostic odds ratio it's probably best to also be expressing things in specificity and sensitivity as well. Odds ratios alone miss bias in that case (and other similar ones where it is important).
|
Practical significance, especially with percents: "standard" measure and threshold
|
More than likely, if you're writing a paper, you're well on your way to what you need for practical significance. You've reviewed the literature and studied the subject matter and people have said, e
|
Practical significance, especially with percents: "standard" measure and threshold
More than likely, if you're writing a paper, you're well on your way to what you need for practical significance. You've reviewed the literature and studied the subject matter and people have said, either explicitly or implicitly, what a practically significant amount is. All you need to do is cite that literature and use it in your article. If you want something just on the utility of effect sizes just google search effect size and your field (and perhaps cohen, 1962). Often there are effect size promotion papers specific to various disciplines. You could also look at Cohen 1962 as an example of how this kind of problem is approached (but not an example of what effect size is practically significant in your case-- it's unfortunate typical use).
There is no odds ratio that's a gold standard but I'm a bit surprised you're having a hard to explaining one. I suppose it's not surprising giving most textbook treatments. Betting uses odds ratios all of the time and people are familiar with it. If you need to explain it use that analogy. The odds of "Come by Chance" winning the race is 3:1 (or 3). Most people know what that means in payout. And they can see it's the number of times the horse is expected to lose the race (3) against the number of times it would win (1), or 75% of the time.
Of course, if this isn't just some proportion but something like a diagnostic odds ratio it's probably best to also be expressing things in specificity and sensitivity as well. Odds ratios alone miss bias in that case (and other similar ones where it is important).
|
Practical significance, especially with percents: "standard" measure and threshold
More than likely, if you're writing a paper, you're well on your way to what you need for practical significance. You've reviewed the literature and studied the subject matter and people have said, e
|
44,431
|
Practical significance, especially with percents: "standard" measure and threshold
|
After further reading, here is one possible answer to my own question. If you have other answers along the same lines, please post them as well.
Cohen's h from Cohen (1988).
$h = |2\arcsin\sqrt{p_1}-2\arcsin\sqrt{p_2}|$
Qualification of effect sizes, with the disclaimer that they might be different in other disciplines,
$h = 0.2$: "small"
$h = 0.5$: "medium"
$h = 0.8$: "large"
In R, http://rss.acs.unt.edu/Rdoc/library/pwr/html/ES.h.html
|
Practical significance, especially with percents: "standard" measure and threshold
|
After further reading, here is one possible answer to my own question. If you have other answers along the same lines, please post them as well.
Cohen's h from Cohen (1988).
$h = |2\arcsin\sqrt{p_1}-2
|
Practical significance, especially with percents: "standard" measure and threshold
After further reading, here is one possible answer to my own question. If you have other answers along the same lines, please post them as well.
Cohen's h from Cohen (1988).
$h = |2\arcsin\sqrt{p_1}-2\arcsin\sqrt{p_2}|$
Qualification of effect sizes, with the disclaimer that they might be different in other disciplines,
$h = 0.2$: "small"
$h = 0.5$: "medium"
$h = 0.8$: "large"
In R, http://rss.acs.unt.edu/Rdoc/library/pwr/html/ES.h.html
|
Practical significance, especially with percents: "standard" measure and threshold
After further reading, here is one possible answer to my own question. If you have other answers along the same lines, please post them as well.
Cohen's h from Cohen (1988).
$h = |2\arcsin\sqrt{p_1}-2
|
44,432
|
Outlier removal prior to mixed-effect modelling
|
Having taken a look at paper cited, it's not quite as bad as I thought -- they basically suggest normality testing as a way to identify extreme outliers that might screw up the analysis, and they say that mixed modeling allows less "aggressive" outlier identification/removal. (They use the terms "minimal trimming" and "mild" vs "aggressive" a priori data screening/outlier removal, which at a quick glance I don't see defined precisely in the paper: perhaps they're defined in the references??)
At least pre-screening according to strictly specified rules, based only on the response variable without taking the predictors into account, does not lead to the danger of data snooping (as opposed to, say, running an initial analysis without screening and then going back and screening only if you find the results not to your liking).
I still don't like it though, and would probably say that only results that are qualitatively robust to the presence or absence of outliers should be taken completely seriously.) However, my previous answer on r-help still holds:
outlier detection etc. should be done on the conditional distributions, not marginal distributions -- given a strong effect of a qualitative predictor, the marginal distribution will be multimodal = not normal at all (I don't see how Baayen and Milin get away with this);
as you suggest, 1/21 values of $p<0.05$ is very close to the expectation in the null case.
I would personally prefer that you skip a priori test-based screening completely (removing physically impossible/very long values as suggested in the paper is perfectly sensible) and use model criticism instead (as suggested by the paper), but you do have to conform to the norms of your community where they are not completely outrageous. If possible, compare your results with screened vs. unscreened data and see that they are qualitatively similar.
|
Outlier removal prior to mixed-effect modelling
|
Having taken a look at paper cited, it's not quite as bad as I thought -- they basically suggest normality testing as a way to identify extreme outliers that might screw up the analysis, and they say
|
Outlier removal prior to mixed-effect modelling
Having taken a look at paper cited, it's not quite as bad as I thought -- they basically suggest normality testing as a way to identify extreme outliers that might screw up the analysis, and they say that mixed modeling allows less "aggressive" outlier identification/removal. (They use the terms "minimal trimming" and "mild" vs "aggressive" a priori data screening/outlier removal, which at a quick glance I don't see defined precisely in the paper: perhaps they're defined in the references??)
At least pre-screening according to strictly specified rules, based only on the response variable without taking the predictors into account, does not lead to the danger of data snooping (as opposed to, say, running an initial analysis without screening and then going back and screening only if you find the results not to your liking).
I still don't like it though, and would probably say that only results that are qualitatively robust to the presence or absence of outliers should be taken completely seriously.) However, my previous answer on r-help still holds:
outlier detection etc. should be done on the conditional distributions, not marginal distributions -- given a strong effect of a qualitative predictor, the marginal distribution will be multimodal = not normal at all (I don't see how Baayen and Milin get away with this);
as you suggest, 1/21 values of $p<0.05$ is very close to the expectation in the null case.
I would personally prefer that you skip a priori test-based screening completely (removing physically impossible/very long values as suggested in the paper is perfectly sensible) and use model criticism instead (as suggested by the paper), but you do have to conform to the norms of your community where they are not completely outrageous. If possible, compare your results with screened vs. unscreened data and see that they are qualitatively similar.
|
Outlier removal prior to mixed-effect modelling
Having taken a look at paper cited, it's not quite as bad as I thought -- they basically suggest normality testing as a way to identify extreme outliers that might screw up the analysis, and they say
|
44,433
|
Outlier removal prior to mixed-effect modelling
|
If you are absolutely certain that nobody will ever critically review your analysis, consider it skeptically, or just need to be convinced of your results, then go ahead and remove the outliers (but if this is the case then there is probably no need to do the analysis at all).
If you remove outliers then you open yourself to accusations of cherry-picking only those data points that confirm your preconceptions.
If you are concerned about the normality assumptions (and note that it is the residuals, not the response that need to be normal) then you should consider a method that uses all the data, but does not depend on normality rather than deleting points (e.g. data tranformations, permutation tests, bootstrap, or other non-parametric approaches).
If you have points that are true outliers without obvious explanation, then examining why they are different may lead to more interesting findings than the original analysis.
Note that the common tests of normality generally have poor power to find important differences when they matter and high power to find minor differences when they don't matter. Decisions about using normal based inference or not should come from your knowledge (and that of other researchers) of the science that produces the data. While the canned normality tests were developed by people who were probably smarter than me and possibly smarter than you, it cannot be expected of them that they knew (at the time they developed the test) more about your data and your questions than you do.
|
Outlier removal prior to mixed-effect modelling
|
If you are absolutely certain that nobody will ever critically review your analysis, consider it skeptically, or just need to be convinced of your results, then go ahead and remove the outliers (but i
|
Outlier removal prior to mixed-effect modelling
If you are absolutely certain that nobody will ever critically review your analysis, consider it skeptically, or just need to be convinced of your results, then go ahead and remove the outliers (but if this is the case then there is probably no need to do the analysis at all).
If you remove outliers then you open yourself to accusations of cherry-picking only those data points that confirm your preconceptions.
If you are concerned about the normality assumptions (and note that it is the residuals, not the response that need to be normal) then you should consider a method that uses all the data, but does not depend on normality rather than deleting points (e.g. data tranformations, permutation tests, bootstrap, or other non-parametric approaches).
If you have points that are true outliers without obvious explanation, then examining why they are different may lead to more interesting findings than the original analysis.
Note that the common tests of normality generally have poor power to find important differences when they matter and high power to find minor differences when they don't matter. Decisions about using normal based inference or not should come from your knowledge (and that of other researchers) of the science that produces the data. While the canned normality tests were developed by people who were probably smarter than me and possibly smarter than you, it cannot be expected of them that they knew (at the time they developed the test) more about your data and your questions than you do.
|
Outlier removal prior to mixed-effect modelling
If you are absolutely certain that nobody will ever critically review your analysis, consider it skeptically, or just need to be convinced of your results, then go ahead and remove the outliers (but i
|
44,434
|
Is there a test for independence in a Bernoulli process?
|
I think you can devise a big number of tests, and the good choice depends on the alternate hypothesis you have in mind... I just have a few remarks. I place this post under community wiki as I feel it can be improved a lot.
The first think I would think to: divide your sample in n subsamples of size k; if the experiments are independents, in sample number $i$ the number $X_i$ of successes is a $\mathcal Bin(k,p)$, so you have $n$ independent values $X_1, \dots, X_n$ of a binomial variable. This can be tested by a $\chi^2$ test. (The choice of $n,k$ will depend on the total sample size...)
Considering your remark about the process sticking for a number of trials, it seems that you think of positive correlation between successive experiments. I think the above test can be powerful in this case. However you can consider the length of runs in your sequence of trials: denoting $L_1$ (resp. $L_0$) the length of a 1 run (resp. of a 0 run), you have
$$\mathbb P(L_1 = k) = p^{k-1} (1-p),$$
$$\mathbb P(L_0 = k) =(1-p)^{k-1} p.$$ These are geometric distributions, beware: in some softwares like R, $k$ is shifted by $1$. You can again test for goodness of fit of the observed values.
I don’t know how the preceding suggestion performs as compared to Wald–Wolfowitz runs test.
Special attention has been given to the case where $p={1\over 2}$, as this is the case of a sequence of random bits generated by a Random Number Generator. A number of tests has been devised by George Marsaglia, under the name Diehard test battery. You can surely generalize (most of) these tests to the case $p \ne {1\over 2}$. (But is it worth it?)
|
Is there a test for independence in a Bernoulli process?
|
I think you can devise a big number of tests, and the good choice depends on the alternate hypothesis you have in mind... I just have a few remarks. I place this post under community wiki as I feel it
|
Is there a test for independence in a Bernoulli process?
I think you can devise a big number of tests, and the good choice depends on the alternate hypothesis you have in mind... I just have a few remarks. I place this post under community wiki as I feel it can be improved a lot.
The first think I would think to: divide your sample in n subsamples of size k; if the experiments are independents, in sample number $i$ the number $X_i$ of successes is a $\mathcal Bin(k,p)$, so you have $n$ independent values $X_1, \dots, X_n$ of a binomial variable. This can be tested by a $\chi^2$ test. (The choice of $n,k$ will depend on the total sample size...)
Considering your remark about the process sticking for a number of trials, it seems that you think of positive correlation between successive experiments. I think the above test can be powerful in this case. However you can consider the length of runs in your sequence of trials: denoting $L_1$ (resp. $L_0$) the length of a 1 run (resp. of a 0 run), you have
$$\mathbb P(L_1 = k) = p^{k-1} (1-p),$$
$$\mathbb P(L_0 = k) =(1-p)^{k-1} p.$$ These are geometric distributions, beware: in some softwares like R, $k$ is shifted by $1$. You can again test for goodness of fit of the observed values.
I don’t know how the preceding suggestion performs as compared to Wald–Wolfowitz runs test.
Special attention has been given to the case where $p={1\over 2}$, as this is the case of a sequence of random bits generated by a Random Number Generator. A number of tests has been devised by George Marsaglia, under the name Diehard test battery. You can surely generalize (most of) these tests to the case $p \ne {1\over 2}$. (But is it worth it?)
|
Is there a test for independence in a Bernoulli process?
I think you can devise a big number of tests, and the good choice depends on the alternate hypothesis you have in mind... I just have a few remarks. I place this post under community wiki as I feel it
|
44,435
|
Is there a test for independence in a Bernoulli process?
|
Let the sequence of values be realizations of random variables $X_i$, $1\le i\le n$, each identically distributed as a Bernoulli($p$) variable (with $p$ unknown). When they are independent, the sequence is a Markov chain with transition probabilities
$$\Pr(x \to 0) = 1-p, \quad \Pr(x \to 1) = p$$
for $x = 0,1$. The sequence yields $n-1$ (presumably) independent transitions $X_i \to X_{i+1}$, $1\le i\le n-1$, which can be summarized as a $2 \times 2$ matrix of their counts. Independence of the sequence implies independence of this table. So, test the table for independence and reject the hypothesis of an independent sequence if the test is significant.
For example, here is a sequence of 24 binary outcomes:
1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0
The 23 transitions in this sequence are 1->1, 1->1 , ..., 1->0, 0->0, 0->0. Their table of counts is
To: 0 1
From 0: 3 2
1: 3 15
Its chi-squared statistic is 1.8947. The p-value (using the chi-squared approximation, which is not very good due to the small cell counts in the table) is 0.1687: no evidence of dependence. Indeed, these 24 values were generated randomly and independently with a 2/3 chance of the outcome 1 and a 1/3 chance of a 0 (i.e., $p=2/3$).
If the hypothesis of independence is not rejected, you can continue to test for higher-order dependence or seasonal dependence (by checking transitions from season to season, rather than between consecutive values).
Here is sample R code to compute the chi-squared test p-values for any desired order (1, 2, ...) and to simulate the null distribution (which can be used for a more accurate permutation test of the independence hypotheses if you wish).
set.seed(17)
x<-rbinom(256,1,2/3) # Sample data generated with the null distribution.
cc <- function(x,k) { # Chi-squared test of kth order independence in x.
n <- length(x)-k-1
m <- sapply(1:k, function(j) x[j:(n+j)])
y <- m %*% (2^(0:(k-1))) # Classifies length-k subsequences of x
chisq.test(y, x[(k+1):length(x)])$p.value
}
sapply(1:2, function(k) cc(x,k)) # P-values for chi-squared tests of orders 1, 2.
order <- 1 # Use 2 for second order, etc.
hist(replicate(999, cc(sample(x),order))) # Simulated null distribution of the p-value.
|
Is there a test for independence in a Bernoulli process?
|
Let the sequence of values be realizations of random variables $X_i$, $1\le i\le n$, each identically distributed as a Bernoulli($p$) variable (with $p$ unknown). When they are independent, the seque
|
Is there a test for independence in a Bernoulli process?
Let the sequence of values be realizations of random variables $X_i$, $1\le i\le n$, each identically distributed as a Bernoulli($p$) variable (with $p$ unknown). When they are independent, the sequence is a Markov chain with transition probabilities
$$\Pr(x \to 0) = 1-p, \quad \Pr(x \to 1) = p$$
for $x = 0,1$. The sequence yields $n-1$ (presumably) independent transitions $X_i \to X_{i+1}$, $1\le i\le n-1$, which can be summarized as a $2 \times 2$ matrix of their counts. Independence of the sequence implies independence of this table. So, test the table for independence and reject the hypothesis of an independent sequence if the test is significant.
For example, here is a sequence of 24 binary outcomes:
1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0
The 23 transitions in this sequence are 1->1, 1->1 , ..., 1->0, 0->0, 0->0. Their table of counts is
To: 0 1
From 0: 3 2
1: 3 15
Its chi-squared statistic is 1.8947. The p-value (using the chi-squared approximation, which is not very good due to the small cell counts in the table) is 0.1687: no evidence of dependence. Indeed, these 24 values were generated randomly and independently with a 2/3 chance of the outcome 1 and a 1/3 chance of a 0 (i.e., $p=2/3$).
If the hypothesis of independence is not rejected, you can continue to test for higher-order dependence or seasonal dependence (by checking transitions from season to season, rather than between consecutive values).
Here is sample R code to compute the chi-squared test p-values for any desired order (1, 2, ...) and to simulate the null distribution (which can be used for a more accurate permutation test of the independence hypotheses if you wish).
set.seed(17)
x<-rbinom(256,1,2/3) # Sample data generated with the null distribution.
cc <- function(x,k) { # Chi-squared test of kth order independence in x.
n <- length(x)-k-1
m <- sapply(1:k, function(j) x[j:(n+j)])
y <- m %*% (2^(0:(k-1))) # Classifies length-k subsequences of x
chisq.test(y, x[(k+1):length(x)])$p.value
}
sapply(1:2, function(k) cc(x,k)) # P-values for chi-squared tests of orders 1, 2.
order <- 1 # Use 2 for second order, etc.
hist(replicate(999, cc(sample(x),order))) # Simulated null distribution of the p-value.
|
Is there a test for independence in a Bernoulli process?
Let the sequence of values be realizations of random variables $X_i$, $1\le i\le n$, each identically distributed as a Bernoulli($p$) variable (with $p$ unknown). When they are independent, the seque
|
44,436
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
|
Read this article:
Murdock, D, Tsai, Y, and Adcock, J (2008) _P-Values are Random
Variables_. The American Statistician. (62) 242-245.
It talks about the fact that if the null hypothesis is true then the p-value is a uniform random variable. This means that you are just as likely to see a p-value of 0.09, 0.06, 0.01, or 0.99. (when the null is false in a way that the test is designed to detect then the p-value is a random variable with values closer to 0 being more common).
Here is an added example (in R):
> out1 <- replicate(1000, ks.test(rt(100, 10), pnorm)$p.value )
> out2 <- replicate(1000, ks.test(rt(100, 50), pnorm)$p.value )
>
> mean(out1 < out2)
[1] 0.522
This simulated data from a t distribution with 10 df and a t distribution with 50 degrees of freedom and does the ks-test on each simulated dataset and gets the p-value. Then it looks at each pair and sees how often the p-value for 10df is smaller than the p-value for 50df (the 50df should be "more normal" than the 10 df). But the simulations only get this right 52.2% of the time, only slightly better than flipping a coin. I would not want to base any important decisions on something like this.
Now if you are comparing something that is very non-normal to something close to normal, then the p-values will probably show this, but then a simple histogram or qqplot would also make this obvious.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
|
Read this article:
Murdock, D, Tsai, Y, and Adcock, J (2008) _P-Values are Random
Variables_. The American Statistician. (62) 242-245.
It talks about the fact that if the null hypothesis is true t
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
Read this article:
Murdock, D, Tsai, Y, and Adcock, J (2008) _P-Values are Random
Variables_. The American Statistician. (62) 242-245.
It talks about the fact that if the null hypothesis is true then the p-value is a uniform random variable. This means that you are just as likely to see a p-value of 0.09, 0.06, 0.01, or 0.99. (when the null is false in a way that the test is designed to detect then the p-value is a random variable with values closer to 0 being more common).
Here is an added example (in R):
> out1 <- replicate(1000, ks.test(rt(100, 10), pnorm)$p.value )
> out2 <- replicate(1000, ks.test(rt(100, 50), pnorm)$p.value )
>
> mean(out1 < out2)
[1] 0.522
This simulated data from a t distribution with 10 df and a t distribution with 50 degrees of freedom and does the ks-test on each simulated dataset and gets the p-value. Then it looks at each pair and sees how often the p-value for 10df is smaller than the p-value for 50df (the 50df should be "more normal" than the 10 df). But the simulations only get this right 52.2% of the time, only slightly better than flipping a coin. I would not want to base any important decisions on something like this.
Now if you are comparing something that is very non-normal to something close to normal, then the p-values will probably show this, but then a simple histogram or qqplot would also make this obvious.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
Read this article:
Murdock, D, Tsai, Y, and Adcock, J (2008) _P-Values are Random
Variables_. The American Statistician. (62) 242-245.
It talks about the fact that if the null hypothesis is true t
|
44,437
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
|
In general, the lower the p-value, the less belief you attach to your null hypothesis (in fact, the p-value is the chance that, if the null hypothesis were true, a test statistic so extreme (or more) as the one obtained from your sample would be obtained).
As such, it is reasonable to say that the lower the p-value, the more confident you are that there may be an alternative out there that is more probable to give this extreme statistic. As we are typically aiming to dis"prove" the null hypothesis (e.g. show that a coefficient in a regression is not zero), typically we say that lower p-values imply better results.
With the K-S test, it's a bit different: in fact, here, we typically hope that the null hypothesis is true. Therein lies the problem: at "best" we can say there is overwhelming evidence that the null hypothesis is not true (when the p-value is really low), or that the test we used did not provide evidence against the null hypothesis (e.g. if you find a p-value of 0.5). Unfortunately, there is nothing to say that there isn't an alternative out there (for K-S it could be e.g. the T-distribution instead of normal) that would give even better results!
In this manner, it is not a good idea to call the higher p-value "a better result". At most you could say that there is "less evidence against" its null hypothesis.
If there is some sound reason for applying the hard threshold of 5% (which in truth generally is rather arbitrary), it doesn't matter anyway, like you indicate.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
|
In general, the lower the p-value, the less belief you attach to your null hypothesis (in fact, the p-value is the chance that, if the null hypothesis were true, a test statistic so extreme (or more)
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
In general, the lower the p-value, the less belief you attach to your null hypothesis (in fact, the p-value is the chance that, if the null hypothesis were true, a test statistic so extreme (or more) as the one obtained from your sample would be obtained).
As such, it is reasonable to say that the lower the p-value, the more confident you are that there may be an alternative out there that is more probable to give this extreme statistic. As we are typically aiming to dis"prove" the null hypothesis (e.g. show that a coefficient in a regression is not zero), typically we say that lower p-values imply better results.
With the K-S test, it's a bit different: in fact, here, we typically hope that the null hypothesis is true. Therein lies the problem: at "best" we can say there is overwhelming evidence that the null hypothesis is not true (when the p-value is really low), or that the test we used did not provide evidence against the null hypothesis (e.g. if you find a p-value of 0.5). Unfortunately, there is nothing to say that there isn't an alternative out there (for K-S it could be e.g. the T-distribution instead of normal) that would give even better results!
In this manner, it is not a good idea to call the higher p-value "a better result". At most you could say that there is "less evidence against" its null hypothesis.
If there is some sound reason for applying the hard threshold of 5% (which in truth generally is rather arbitrary), it doesn't matter anyway, like you indicate.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
In general, the lower the p-value, the less belief you attach to your null hypothesis (in fact, the p-value is the chance that, if the null hypothesis were true, a test statistic so extreme (or more)
|
44,438
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
|
The smaller p value represents stronger evidence against the null hypothesis, but it may not be that the first distribution is "better or more normal" than the second. Instead, it may be less easily distinguished from a normal distribution.
Note that the amount of evidence against the null hypothesis in a p value of 0.06 or 0.09 is quite small. However, if your samples are small then the power of the K-S test to provide evidence is also small.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
|
The smaller p value represents stronger evidence against the null hypothesis, but it may not be that the first distribution is "better or more normal" than the second. Instead, it may be less easily d
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is more normal?
The smaller p value represents stronger evidence against the null hypothesis, but it may not be that the first distribution is "better or more normal" than the second. Instead, it may be less easily distinguished from a normal distribution.
Note that the amount of evidence against the null hypothesis in a p value of 0.06 or 0.09 is quite small. However, if your samples are small then the power of the K-S test to provide evidence is also small.
|
Can you compare p-values of Kolmogorov Smirnov tests of normality of two variables to say which is m
The smaller p value represents stronger evidence against the null hypothesis, but it may not be that the first distribution is "better or more normal" than the second. Instead, it may be less easily d
|
44,439
|
What university level statistics courses are considered advanced/hard?
|
It really depends what your company is doing. Are you looking for machine learning experts? Data visualisation experts? Data mining experts?
When I interview statistics PhDs I like to ask them questions about linear regression, as I feel that anyone claiming to be an expert in statistics should at the very minimum be able to explain linear regression to me, and it's surprising how many can't.
Apart from that I'd consider it to be a good sign if they can have a good discussion about model selection/validation procedures, the concept of training and validation sets, cross-validation etc. If they know about classification algorithms (k-NN, SVM, decision trees etc) and can discuss their strengths/weaknesses that's even better.
I find that the particular courses they've studied are rarely a good indicator, and are only really useful for steering the discussion in the interview. If they're claiming to have studied something on their CV, I expect them to be able to discuss it at length.
|
What university level statistics courses are considered advanced/hard?
|
It really depends what your company is doing. Are you looking for machine learning experts? Data visualisation experts? Data mining experts?
When I interview statistics PhDs I like to ask them questio
|
What university level statistics courses are considered advanced/hard?
It really depends what your company is doing. Are you looking for machine learning experts? Data visualisation experts? Data mining experts?
When I interview statistics PhDs I like to ask them questions about linear regression, as I feel that anyone claiming to be an expert in statistics should at the very minimum be able to explain linear regression to me, and it's surprising how many can't.
Apart from that I'd consider it to be a good sign if they can have a good discussion about model selection/validation procedures, the concept of training and validation sets, cross-validation etc. If they know about classification algorithms (k-NN, SVM, decision trees etc) and can discuss their strengths/weaknesses that's even better.
I find that the particular courses they've studied are rarely a good indicator, and are only really useful for steering the discussion in the interview. If they're claiming to have studied something on their CV, I expect them to be able to discuss it at length.
|
What university level statistics courses are considered advanced/hard?
It really depends what your company is doing. Are you looking for machine learning experts? Data visualisation experts? Data mining experts?
When I interview statistics PhDs I like to ask them questio
|
44,440
|
What university level statistics courses are considered advanced/hard?
|
I agree with Chris on most of what he says. Additionally, I'd like to add that without knowing the institutions or universities in detail, just looking at grades would be very misleading. I could easily give a relevant example; I have recently graduated with a masters in engineering mathematics; and taken a variety of statistics courses (with good grades) but I couldnt work in any statistics intensive job right now. That doesn't mean that my uni sucks, but mostly that I didn't manage to learn much out of my statistics courses during university...
Apart from the candidate's knowledge on statistics, I'd also highly value good communication skills; as any cross-disciplinary project eventually boils down to communication problems between experts of different fields. Any test on how well the candidate can share his expertise with others should be a good measure on that.
Furthermore, good computer/programming skills (and no just R is not enough, IMHO) is surely a big plus. If the person has some background in mathematical modeling, it'd be a cherry on the cake :)
|
What university level statistics courses are considered advanced/hard?
|
I agree with Chris on most of what he says. Additionally, I'd like to add that without knowing the institutions or universities in detail, just looking at grades would be very misleading. I could easi
|
What university level statistics courses are considered advanced/hard?
I agree with Chris on most of what he says. Additionally, I'd like to add that without knowing the institutions or universities in detail, just looking at grades would be very misleading. I could easily give a relevant example; I have recently graduated with a masters in engineering mathematics; and taken a variety of statistics courses (with good grades) but I couldnt work in any statistics intensive job right now. That doesn't mean that my uni sucks, but mostly that I didn't manage to learn much out of my statistics courses during university...
Apart from the candidate's knowledge on statistics, I'd also highly value good communication skills; as any cross-disciplinary project eventually boils down to communication problems between experts of different fields. Any test on how well the candidate can share his expertise with others should be a good measure on that.
Furthermore, good computer/programming skills (and no just R is not enough, IMHO) is surely a big plus. If the person has some background in mathematical modeling, it'd be a cherry on the cake :)
|
What university level statistics courses are considered advanced/hard?
I agree with Chris on most of what he says. Additionally, I'd like to add that without knowing the institutions or universities in detail, just looking at grades would be very misleading. I could easi
|
44,441
|
What university level statistics courses are considered advanced/hard?
|
Chris really nailed the data minining stuff. If you need someone who can also look at experimental data, you can stop all but the most versatile of statisticians dead in their tracks by asking them to explain a split-plot experiment.
|
What university level statistics courses are considered advanced/hard?
|
Chris really nailed the data minining stuff. If you need someone who can also look at experimental data, you can stop all but the most versatile of statisticians dead in their tracks by asking them t
|
What university level statistics courses are considered advanced/hard?
Chris really nailed the data minining stuff. If you need someone who can also look at experimental data, you can stop all but the most versatile of statisticians dead in their tracks by asking them to explain a split-plot experiment.
|
What university level statistics courses are considered advanced/hard?
Chris really nailed the data minining stuff. If you need someone who can also look at experimental data, you can stop all but the most versatile of statisticians dead in their tracks by asking them t
|
44,442
|
Is there a name for 10% best individual grades?
|
If I understand you correctly, you may refer to Percentiles, perhaps espacially Quartiles.
Perhaps you can elaborate a little more on which percentages should be enclosed in each bin, to get a more accurate answer.
UPDATE: Based on the comments below decile seems to be the term you want. For your data these can easily achieved via R (note the differences from your example):
> x = c(1.2, 1.3, 2.1, 2.4, 2.7, 3.0, 3.2, 4.1, 4.2, 4.5)
> quantile(x,c(0.9,0.8,0.7,0.6))
90% 80% 70% 60%
4.23 4.12 3.47 3.08
> x[x > quantile(x,0.9)]
[1] 4.5
> x[x > quantile(x,0.8) & x < quantile(x,0.9)]
[1] 4.2
> x[x > quantile(x,0.7) & x < quantile(x,0.8)]
[1] 4.1
> x[x < quantile(x,0.7)]
[1] 1.2 1.3 2.1 2.4 2.7 3.0 3.2
You can then tell the speakers you are in the 10th decile, 9th decile, 8th decile, or 7th and worse decile (or something with above the 90th percentile, ...). But from my point, the problem will always be to name the catch all (i.e. worst) category.
|
Is there a name for 10% best individual grades?
|
If I understand you correctly, you may refer to Percentiles, perhaps espacially Quartiles.
Perhaps you can elaborate a little more on which percentages should be enclosed in each bin, to get a more ac
|
Is there a name for 10% best individual grades?
If I understand you correctly, you may refer to Percentiles, perhaps espacially Quartiles.
Perhaps you can elaborate a little more on which percentages should be enclosed in each bin, to get a more accurate answer.
UPDATE: Based on the comments below decile seems to be the term you want. For your data these can easily achieved via R (note the differences from your example):
> x = c(1.2, 1.3, 2.1, 2.4, 2.7, 3.0, 3.2, 4.1, 4.2, 4.5)
> quantile(x,c(0.9,0.8,0.7,0.6))
90% 80% 70% 60%
4.23 4.12 3.47 3.08
> x[x > quantile(x,0.9)]
[1] 4.5
> x[x > quantile(x,0.8) & x < quantile(x,0.9)]
[1] 4.2
> x[x > quantile(x,0.7) & x < quantile(x,0.8)]
[1] 4.1
> x[x < quantile(x,0.7)]
[1] 1.2 1.3 2.1 2.4 2.7 3.0 3.2
You can then tell the speakers you are in the 10th decile, 9th decile, 8th decile, or 7th and worse decile (or something with above the 90th percentile, ...). But from my point, the problem will always be to name the catch all (i.e. worst) category.
|
Is there a name for 10% best individual grades?
If I understand you correctly, you may refer to Percentiles, perhaps espacially Quartiles.
Perhaps you can elaborate a little more on which percentages should be enclosed in each bin, to get a more ac
|
44,443
|
Is there a name for 10% best individual grades?
|
You have the answer you asked for, but along with how to communicate this information you might also want to think about how to asses the reliability & precision of the scores. If the evaluators aren't really using the same standards, the scores will furnish a misleading measure of the quality of the speakers no matter how you decide to categorize them. Also, even if the evaluators are reliable in this sense, your rankings should be sensitive to the standard error in their measurements (likely to be large if you have only a modest number of evaluators): you don't want to imply that there are meaningful differences among speakers whose scores differ by amounts that are comparable to the level of background noise in your data. If you aren't in a position to furnish genuinely informative quantitative feedback, you are better off, in my view, picking one or two evaluators you trust to give the speakers' qualitative feedback informed by the evaluators' own observations & by their assessments of whatever evidence they have on the reactions of others.
|
Is there a name for 10% best individual grades?
|
You have the answer you asked for, but along with how to communicate this information you might also want to think about how to asses the reliability & precision of the scores. If the evaluators aren'
|
Is there a name for 10% best individual grades?
You have the answer you asked for, but along with how to communicate this information you might also want to think about how to asses the reliability & precision of the scores. If the evaluators aren't really using the same standards, the scores will furnish a misleading measure of the quality of the speakers no matter how you decide to categorize them. Also, even if the evaluators are reliable in this sense, your rankings should be sensitive to the standard error in their measurements (likely to be large if you have only a modest number of evaluators): you don't want to imply that there are meaningful differences among speakers whose scores differ by amounts that are comparable to the level of background noise in your data. If you aren't in a position to furnish genuinely informative quantitative feedback, you are better off, in my view, picking one or two evaluators you trust to give the speakers' qualitative feedback informed by the evaluators' own observations & by their assessments of whatever evidence they have on the reactions of others.
|
Is there a name for 10% best individual grades?
You have the answer you asked for, but along with how to communicate this information you might also want to think about how to asses the reliability & precision of the scores. If the evaluators aren'
|
44,444
|
Is there a name for 10% best individual grades?
|
In addition to the existing answers, you may find it useful to read up about test norms, a well established topic in psychology and education.
Test Norms: Their Use and Interpretation.
http://psychassessment.com.au/PDF/Chapter%2004.pdf
Google 'test norms'
|
Is there a name for 10% best individual grades?
|
In addition to the existing answers, you may find it useful to read up about test norms, a well established topic in psychology and education.
Test Norms: Their Use and Interpretation.
http://psychas
|
Is there a name for 10% best individual grades?
In addition to the existing answers, you may find it useful to read up about test norms, a well established topic in psychology and education.
Test Norms: Their Use and Interpretation.
http://psychassessment.com.au/PDF/Chapter%2004.pdf
Google 'test norms'
|
Is there a name for 10% best individual grades?
In addition to the existing answers, you may find it useful to read up about test norms, a well established topic in psychology and education.
Test Norms: Their Use and Interpretation.
http://psychas
|
44,445
|
Is there a name for 10% best individual grades?
|
I'd like to add another cautionary note, and a suggestion. When asked for a 1-5 rating, I usually think up some scale, like:
worst ever
real bad
ok
great
awesome
If your raters did similarly, taking an average is somewhat questionable; the difference between "worst ever" and "real bad" may be larger than the difference between "great" and "awesome". In jargon, your data may be somewhere between ordinal and interval (see http://en.wikipedia.org/wiki/Level_of_measurement).
For this reason, I'd suggest that you give your speakers a histogram of their ratings as part of their feedback. And maybe even rank speakers by percent of their ratings above, say, 3, rather than by their mean rating.
|
Is there a name for 10% best individual grades?
|
I'd like to add another cautionary note, and a suggestion. When asked for a 1-5 rating, I usually think up some scale, like:
worst ever
real bad
ok
great
awesome
If your raters did similarly, taking
|
Is there a name for 10% best individual grades?
I'd like to add another cautionary note, and a suggestion. When asked for a 1-5 rating, I usually think up some scale, like:
worst ever
real bad
ok
great
awesome
If your raters did similarly, taking an average is somewhat questionable; the difference between "worst ever" and "real bad" may be larger than the difference between "great" and "awesome". In jargon, your data may be somewhere between ordinal and interval (see http://en.wikipedia.org/wiki/Level_of_measurement).
For this reason, I'd suggest that you give your speakers a histogram of their ratings as part of their feedback. And maybe even rank speakers by percent of their ratings above, say, 3, rather than by their mean rating.
|
Is there a name for 10% best individual grades?
I'd like to add another cautionary note, and a suggestion. When asked for a 1-5 rating, I usually think up some scale, like:
worst ever
real bad
ok
great
awesome
If your raters did similarly, taking
|
44,446
|
How to read large dataset in R [closed]
|
Two basic things:
That complaint addresses all of the memory in the R session, not just the one object that you're loading. And unless you're using something like ff, everything in your session is in memory.
One Windows, you need to specify how much memory can be used by R. Have a look at help(memory.limit). Even though you're using 64-bit, it won't default to use all your available memory.
Otherwise, you can consider using bigmemory to handle larger datasets if it's still a problem. Some relevant sources:
The High Performance Computing view on CRAN.
Dirk Eddelbuettel's tutorial on the subject.
Ryan Rosario's presentation on the subject.
As a final suggestion, you can try calling gc() to free up memory before running your command, although in principle R will do this automatically as it needs to.
|
How to read large dataset in R [closed]
|
Two basic things:
That complaint addresses all of the memory in the R session, not just the one object that you're loading. And unless you're using something like ff, everything in your session is i
|
How to read large dataset in R [closed]
Two basic things:
That complaint addresses all of the memory in the R session, not just the one object that you're loading. And unless you're using something like ff, everything in your session is in memory.
One Windows, you need to specify how much memory can be used by R. Have a look at help(memory.limit). Even though you're using 64-bit, it won't default to use all your available memory.
Otherwise, you can consider using bigmemory to handle larger datasets if it's still a problem. Some relevant sources:
The High Performance Computing view on CRAN.
Dirk Eddelbuettel's tutorial on the subject.
Ryan Rosario's presentation on the subject.
As a final suggestion, you can try calling gc() to free up memory before running your command, although in principle R will do this automatically as it needs to.
|
How to read large dataset in R [closed]
Two basic things:
That complaint addresses all of the memory in the R session, not just the one object that you're loading. And unless you're using something like ff, everything in your session is i
|
44,447
|
How to read large dataset in R [closed]
|
What platform are you running R on? How much physical and virtual memory does the machine have?
Also, you might find the following relevant: http://stat.ethz.ch/R-manual/R-devel/library/base/html/Memory-limits.html
|
How to read large dataset in R [closed]
|
What platform are you running R on? How much physical and virtual memory does the machine have?
Also, you might find the following relevant: http://stat.ethz.ch/R-manual/R-devel/library/base/html/Memo
|
How to read large dataset in R [closed]
What platform are you running R on? How much physical and virtual memory does the machine have?
Also, you might find the following relevant: http://stat.ethz.ch/R-manual/R-devel/library/base/html/Memory-limits.html
|
How to read large dataset in R [closed]
What platform are you running R on? How much physical and virtual memory does the machine have?
Also, you might find the following relevant: http://stat.ethz.ch/R-manual/R-devel/library/base/html/Memo
|
44,448
|
How to read large dataset in R [closed]
|
I,m totally agree with Dirk answer. One suggestion. I have found very useful the use of programming languages such as AWK or others when assessing large databases. So, I was able to filter the data I wanted to include in my analysis, reducing the final size of dataset.
Moreover, in your code you are duplicating the same data set twice (data and dataset). If you want to define your variables as factor, numeric, etc, you could use of colClasses option in the read.table function.
|
How to read large dataset in R [closed]
|
I,m totally agree with Dirk answer. One suggestion. I have found very useful the use of programming languages such as AWK or others when assessing large databases. So, I was able to filter the data I
|
How to read large dataset in R [closed]
I,m totally agree with Dirk answer. One suggestion. I have found very useful the use of programming languages such as AWK or others when assessing large databases. So, I was able to filter the data I wanted to include in my analysis, reducing the final size of dataset.
Moreover, in your code you are duplicating the same data set twice (data and dataset). If you want to define your variables as factor, numeric, etc, you could use of colClasses option in the read.table function.
|
How to read large dataset in R [closed]
I,m totally agree with Dirk answer. One suggestion. I have found very useful the use of programming languages such as AWK or others when assessing large databases. So, I was able to filter the data I
|
44,449
|
How to read large dataset in R [closed]
|
Since you're on 64-bit Windows, make sure that you have installed and are running the 64-bit version of R for Windows. Then, follow the instructions on Gary King's page:
How do I increase the memory for R?
|
How to read large dataset in R [closed]
|
Since you're on 64-bit Windows, make sure that you have installed and are running the 64-bit version of R for Windows. Then, follow the instructions on Gary King's page:
How do I increase the memory
|
How to read large dataset in R [closed]
Since you're on 64-bit Windows, make sure that you have installed and are running the 64-bit version of R for Windows. Then, follow the instructions on Gary King's page:
How do I increase the memory for R?
|
How to read large dataset in R [closed]
Since you're on 64-bit Windows, make sure that you have installed and are running the 64-bit version of R for Windows. Then, follow the instructions on Gary King's page:
How do I increase the memory
|
44,450
|
How to read large dataset in R [closed]
|
You can always use the filehash package which dumps the large dataset in the disk rather than in the system's memory. You need to be prepared to deal with the tradeoff though, due to slow read HDD times.
|
How to read large dataset in R [closed]
|
You can always use the filehash package which dumps the large dataset in the disk rather than in the system's memory. You need to be prepared to deal with the tradeoff though, due to slow read HDD tim
|
How to read large dataset in R [closed]
You can always use the filehash package which dumps the large dataset in the disk rather than in the system's memory. You need to be prepared to deal with the tradeoff though, due to slow read HDD times.
|
How to read large dataset in R [closed]
You can always use the filehash package which dumps the large dataset in the disk rather than in the system's memory. You need to be prepared to deal with the tradeoff though, due to slow read HDD tim
|
44,451
|
Orthogonal parametrization
|
In Maximum Likelihood, the term orthogonal parameters is used when you can achieve a clean factorization of a multi-parameter likelihood function. Say your data have two parameters $\theta$ and $\lambda$. If you can rewrite the joint likelihood:
$L(\theta, \lambda) = L_{1}(\theta) L_{2}(\lambda)$
then we call $\theta$ and $\lambda$ orthogonal parameters. The obvious case is when you have independence, but this is not necessary for the definition as long as factorization can be achieved. Orthogonal parameters are desirable because, if $\theta$ is of interest, then you can perform inference using $L_{1}$.
When we don't have orthogonal parameters, we try to find factorizations like
$L(\theta, \lambda) = L_{1}(\theta) L_{2}(\theta, \lambda)$
and perform inference using $L_1$. In this case, we must argue that the information loss due to excluding $L_{2}$ is low. This leads to the concept of marginal likelihood.
|
Orthogonal parametrization
|
In Maximum Likelihood, the term orthogonal parameters is used when you can achieve a clean factorization of a multi-parameter likelihood function. Say your data have two parameters $\theta$ and $\lam
|
Orthogonal parametrization
In Maximum Likelihood, the term orthogonal parameters is used when you can achieve a clean factorization of a multi-parameter likelihood function. Say your data have two parameters $\theta$ and $\lambda$. If you can rewrite the joint likelihood:
$L(\theta, \lambda) = L_{1}(\theta) L_{2}(\lambda)$
then we call $\theta$ and $\lambda$ orthogonal parameters. The obvious case is when you have independence, but this is not necessary for the definition as long as factorization can be achieved. Orthogonal parameters are desirable because, if $\theta$ is of interest, then you can perform inference using $L_{1}$.
When we don't have orthogonal parameters, we try to find factorizations like
$L(\theta, \lambda) = L_{1}(\theta) L_{2}(\theta, \lambda)$
and perform inference using $L_1$. In this case, we must argue that the information loss due to excluding $L_{2}$ is low. This leads to the concept of marginal likelihood.
|
Orthogonal parametrization
In Maximum Likelihood, the term orthogonal parameters is used when you can achieve a clean factorization of a multi-parameter likelihood function. Say your data have two parameters $\theta$ and $\lam
|
44,452
|
Orthogonal parametrization
|
This is a good, if underspecified question.
Simply put, obtaining an orthogonal parametrization allows for parameters of interest to be conveniently related to other parameters, particularly in establishing needed minimizations. Whether or not this is useful depends on what you are trying to do (in the case of some physics problems, for instance, orthogonal parametrization may obscure the symmetries of interest).
In the case of statistical inference, orthogonal parametrization can allow the use of statistics by way of minimization (or its dual) on orthogonal parameters. For instance, Cox and Reid use the orthogonality of nuisance parameters (and their appropriately applied maximum likelihood estimates) to construct a generalization of a liklihood ratio statistic for a parameter of interest.
To see how orthogonality allows for this requires an understanding of the properties of commonly used mathematical spaces and the construction of estimators, which is essentially an issue of information geometry. See Information Geometry, Bayesian Inference, Ideal Estimates and Error Decomposition for a lucid, but technical description of orthogonality and its role in statistical inference.
|
Orthogonal parametrization
|
This is a good, if underspecified question.
Simply put, obtaining an orthogonal parametrization allows for parameters of interest to be conveniently related to other parameters, particularly in esta
|
Orthogonal parametrization
This is a good, if underspecified question.
Simply put, obtaining an orthogonal parametrization allows for parameters of interest to be conveniently related to other parameters, particularly in establishing needed minimizations. Whether or not this is useful depends on what you are trying to do (in the case of some physics problems, for instance, orthogonal parametrization may obscure the symmetries of interest).
In the case of statistical inference, orthogonal parametrization can allow the use of statistics by way of minimization (or its dual) on orthogonal parameters. For instance, Cox and Reid use the orthogonality of nuisance parameters (and their appropriately applied maximum likelihood estimates) to construct a generalization of a liklihood ratio statistic for a parameter of interest.
To see how orthogonality allows for this requires an understanding of the properties of commonly used mathematical spaces and the construction of estimators, which is essentially an issue of information geometry. See Information Geometry, Bayesian Inference, Ideal Estimates and Error Decomposition for a lucid, but technical description of orthogonality and its role in statistical inference.
|
Orthogonal parametrization
This is a good, if underspecified question.
Simply put, obtaining an orthogonal parametrization allows for parameters of interest to be conveniently related to other parameters, particularly in esta
|
44,453
|
Overestimating the lower values and underestimating the higher values in Regression
|
This is just an effect of a model which only partially explains the observations. In such a case, this sort of effect is common. Possible choices include accepting that some things are random or trying to find better explanations for the observations; it may be impossible to get a better result with the data you have.
Here is an illustration of a linear model with a correlation between the observed variable and the explanatory variable of about $0.5$ (in some fields this is high, and in others low). The second chart is similar to yours. Generating some simulation data in R:
set.seed(2023)
X <- rnorm(1000)
Observed <- X*0.5 + rnorm(1000)*0.9
cor(X,Observed)
# 0.4996774
plot(X, Observed)
fit <- lm(Observed ~ X)
abline(fit)
you get a linear regression which looks like this, and you can see the positive correlation and noise. Nothing surprising here.
Now drawing the equivalent of your chart, you again get the obvious gap between the points and the blue diagonal. This is what happens with regression (and indeed is part of the etymology)
plot(Observed, fit$fitted.values, ylim=c(min(Observed),max(Observed)))
abline(0,1,col="blue")
This is in effect the same chart as previously with a reflection and some stretching and relocation. The point at the bottom the first chart has become the point at the far left of the second.
A better chart for seeing if there might be something wrong with the model, beyond a lot of noise, would be to plot residuals against fitted values and see whether there is a obvious pattern which could be addressed with a better model using the existing data. In this case there is no such obvious pattern. (The point I suggested looking at on the previous charts has now moved to the top and looks less special.)
plot(fit$fitted.values, fit$residuals)
|
Overestimating the lower values and underestimating the higher values in Regression
|
This is just an effect of a model which only partially explains the observations. In such a case, this sort of effect is common. Possible choices include accepting that some things are random or tryi
|
Overestimating the lower values and underestimating the higher values in Regression
This is just an effect of a model which only partially explains the observations. In such a case, this sort of effect is common. Possible choices include accepting that some things are random or trying to find better explanations for the observations; it may be impossible to get a better result with the data you have.
Here is an illustration of a linear model with a correlation between the observed variable and the explanatory variable of about $0.5$ (in some fields this is high, and in others low). The second chart is similar to yours. Generating some simulation data in R:
set.seed(2023)
X <- rnorm(1000)
Observed <- X*0.5 + rnorm(1000)*0.9
cor(X,Observed)
# 0.4996774
plot(X, Observed)
fit <- lm(Observed ~ X)
abline(fit)
you get a linear regression which looks like this, and you can see the positive correlation and noise. Nothing surprising here.
Now drawing the equivalent of your chart, you again get the obvious gap between the points and the blue diagonal. This is what happens with regression (and indeed is part of the etymology)
plot(Observed, fit$fitted.values, ylim=c(min(Observed),max(Observed)))
abline(0,1,col="blue")
This is in effect the same chart as previously with a reflection and some stretching and relocation. The point at the bottom the first chart has become the point at the far left of the second.
A better chart for seeing if there might be something wrong with the model, beyond a lot of noise, would be to plot residuals against fitted values and see whether there is a obvious pattern which could be addressed with a better model using the existing data. In this case there is no such obvious pattern. (The point I suggested looking at on the previous charts has now moved to the top and looks less special.)
plot(fit$fitted.values, fit$residuals)
|
Overestimating the lower values and underestimating the higher values in Regression
This is just an effect of a model which only partially explains the observations. In such a case, this sort of effect is common. Possible choices include accepting that some things are random or tryi
|
44,454
|
Overestimating the lower values and underestimating the higher values in Regression
|
I suspect that there is not a very strong "signal" in your data, meaning that for a given place in x-space there is a big variance in $y$, and therefore $y$ cannot be predicted very precisely. The implication is then that where big values of $y$ ("observed") occur, this is often not because the corresponding x-values that you use to "explain" the $y$ enforce a large $y$, but rather it can happen all over the place because of noise/variation. So it is not possible to predict/fit the biggest values well, and neither the smallest.
If you have already tried out much and this happens all the time, chances are this is how it is and you have to accept it. In some problems the x-values do not work very well as predictors.
|
Overestimating the lower values and underestimating the higher values in Regression
|
I suspect that there is not a very strong "signal" in your data, meaning that for a given place in x-space there is a big variance in $y$, and therefore $y$ cannot be predicted very precisely. The imp
|
Overestimating the lower values and underestimating the higher values in Regression
I suspect that there is not a very strong "signal" in your data, meaning that for a given place in x-space there is a big variance in $y$, and therefore $y$ cannot be predicted very precisely. The implication is then that where big values of $y$ ("observed") occur, this is often not because the corresponding x-values that you use to "explain" the $y$ enforce a large $y$, but rather it can happen all over the place because of noise/variation. So it is not possible to predict/fit the biggest values well, and neither the smallest.
If you have already tried out much and this happens all the time, chances are this is how it is and you have to accept it. In some problems the x-values do not work very well as predictors.
|
Overestimating the lower values and underestimating the higher values in Regression
I suspect that there is not a very strong "signal" in your data, meaning that for a given place in x-space there is a big variance in $y$, and therefore $y$ cannot be predicted very precisely. The imp
|
44,455
|
Overestimating the lower values and underestimating the higher values in Regression
|
[Edited as I misread the original question]
The way a Random Forest works, simplified, is that the computer tries to sort the observations into buckets, then calculates the average value within each bucket, and uses that as the score for everything in that bucket. This is done repeatedly, getting different bucketing rules, and then the final score for an observation is the average of the scores for all the buckets it was in.
One issue with Random Forest is that it can "top out": a set of observations can be sorted into the "highest bucket" (or the "lowest bucket"), and from there, no further distinction is made within the set. If the same set is topping out for each bucketing rule, then you're not going to be getting a different score for them.
Something along these lines appears to be happening with your predictions. Your model isn't predicting less than -1, or much more than 1, which suggests that the set all observations with a true value greater than 1 is topping out, and vice versa for less than -1.
Now, your data also seems to be much more sparse for those data points, so your model is probably prioritizing the more central ones. Furthermore, you may not have enough datapoints, regardless of what you do, to make predictions for those observations. Or the explanatory variable may just not be explanatory anymore at the extremes (for instance, age is a good predictor of height for schoolchildren, but not so much for adults; if you have that sort of relationship, there might not be anything you can do). But things you can try are:
Create separate models for the extremes
Look at your extremes and try to find distinguishing characteristics
Generate new features, such as doing a linear regression on the original features, and feeding the output of that into the Random Forest model as an input.
|
Overestimating the lower values and underestimating the higher values in Regression
|
[Edited as I misread the original question]
The way a Random Forest works, simplified, is that the computer tries to sort the observations into buckets, then calculates the average value within each b
|
Overestimating the lower values and underestimating the higher values in Regression
[Edited as I misread the original question]
The way a Random Forest works, simplified, is that the computer tries to sort the observations into buckets, then calculates the average value within each bucket, and uses that as the score for everything in that bucket. This is done repeatedly, getting different bucketing rules, and then the final score for an observation is the average of the scores for all the buckets it was in.
One issue with Random Forest is that it can "top out": a set of observations can be sorted into the "highest bucket" (or the "lowest bucket"), and from there, no further distinction is made within the set. If the same set is topping out for each bucketing rule, then you're not going to be getting a different score for them.
Something along these lines appears to be happening with your predictions. Your model isn't predicting less than -1, or much more than 1, which suggests that the set all observations with a true value greater than 1 is topping out, and vice versa for less than -1.
Now, your data also seems to be much more sparse for those data points, so your model is probably prioritizing the more central ones. Furthermore, you may not have enough datapoints, regardless of what you do, to make predictions for those observations. Or the explanatory variable may just not be explanatory anymore at the extremes (for instance, age is a good predictor of height for schoolchildren, but not so much for adults; if you have that sort of relationship, there might not be anything you can do). But things you can try are:
Create separate models for the extremes
Look at your extremes and try to find distinguishing characteristics
Generate new features, such as doing a linear regression on the original features, and feeding the output of that into the Random Forest model as an input.
|
Overestimating the lower values and underestimating the higher values in Regression
[Edited as I misread the original question]
The way a Random Forest works, simplified, is that the computer tries to sort the observations into buckets, then calculates the average value within each b
|
44,456
|
What is the R squared of a regression where none of the variables are collinear?
|
(Most of this a linear algebra question is disguise!)
If the $100\times100$ matrix $X$ is full-rank, that means the columns form a basis for $\mathbb R^{100}$. Since $y\in\mathbb R^{100}$, $y$ can be written as some linear combination of any basis for $\mathbb R^{100}$, such as the set of columns of $X$.
That is, the columns of $X$ perfectly predict $y$, and there is no prediction error (at least not in-sample). Consequently, $y=\hat y$, and $R^2=1$.
$$
R^2=1-\dfrac{
\overset{n}{\underset{i=1}{\sum}}\left(y_i-\hat y_i\right)^2
}{
\overset{n}{\underset{i=1}{\sum}}\left(y_i-\bar y\right)^2
}\\
=1-\dfrac{
\left. \overset{n}{\underset{i=1}{\sum}}\left(y_i-\hat y_i\right)^2 \middle/ n \right.
}{
\left. \overset{n}{\underset{i=1}{\sum}}\left(y_i-\bar y\right)^2 \middle/ n \right.
}
\\
1-\dfrac{
\text{var}(y-\hat y)
}{
\text{var}(y)
}\\
=1-\dfrac{0}{\text{var}(y)}=1
$$
(This assumes not all values of $y$ are equal, but if they are, that is not an interesting regression problem.)
With zero residual variance, it does not make much sense to talk about the t-stats for any of the coefficients, since t-stats divide by residual variance and dividing by zero is frowned upon.
|
What is the R squared of a regression where none of the variables are collinear?
|
(Most of this a linear algebra question is disguise!)
If the $100\times100$ matrix $X$ is full-rank, that means the columns form a basis for $\mathbb R^{100}$. Since $y\in\mathbb R^{100}$, $y$ can be
|
What is the R squared of a regression where none of the variables are collinear?
(Most of this a linear algebra question is disguise!)
If the $100\times100$ matrix $X$ is full-rank, that means the columns form a basis for $\mathbb R^{100}$. Since $y\in\mathbb R^{100}$, $y$ can be written as some linear combination of any basis for $\mathbb R^{100}$, such as the set of columns of $X$.
That is, the columns of $X$ perfectly predict $y$, and there is no prediction error (at least not in-sample). Consequently, $y=\hat y$, and $R^2=1$.
$$
R^2=1-\dfrac{
\overset{n}{\underset{i=1}{\sum}}\left(y_i-\hat y_i\right)^2
}{
\overset{n}{\underset{i=1}{\sum}}\left(y_i-\bar y\right)^2
}\\
=1-\dfrac{
\left. \overset{n}{\underset{i=1}{\sum}}\left(y_i-\hat y_i\right)^2 \middle/ n \right.
}{
\left. \overset{n}{\underset{i=1}{\sum}}\left(y_i-\bar y\right)^2 \middle/ n \right.
}
\\
1-\dfrac{
\text{var}(y-\hat y)
}{
\text{var}(y)
}\\
=1-\dfrac{0}{\text{var}(y)}=1
$$
(This assumes not all values of $y$ are equal, but if they are, that is not an interesting regression problem.)
With zero residual variance, it does not make much sense to talk about the t-stats for any of the coefficients, since t-stats divide by residual variance and dividing by zero is frowned upon.
|
What is the R squared of a regression where none of the variables are collinear?
(Most of this a linear algebra question is disguise!)
If the $100\times100$ matrix $X$ is full-rank, that means the columns form a basis for $\mathbb R^{100}$. Since $y\in\mathbb R^{100}$, $y$ can be
|
44,457
|
What is the R squared of a regression where none of the variables are collinear?
|
If none of the explanatory variables is colinear (i.e., each pair has zero correlation) then the coefficient-of-determination for the regresion is equal to the sum of the coefficients-of-determination for individual simple linear regessions of each explanatory variable against the response variable. If you would like to learn more about the relationships between collinearity and the coefficient-of-determination in linear regression, as wel as a broader geometric view of regression, you can find some discussion of this topic in my paper O'Neill (2019).
|
What is the R squared of a regression where none of the variables are collinear?
|
If none of the explanatory variables is colinear (i.e., each pair has zero correlation) then the coefficient-of-determination for the regresion is equal to the sum of the coefficients-of-determination
|
What is the R squared of a regression where none of the variables are collinear?
If none of the explanatory variables is colinear (i.e., each pair has zero correlation) then the coefficient-of-determination for the regresion is equal to the sum of the coefficients-of-determination for individual simple linear regessions of each explanatory variable against the response variable. If you would like to learn more about the relationships between collinearity and the coefficient-of-determination in linear regression, as wel as a broader geometric view of regression, you can find some discussion of this topic in my paper O'Neill (2019).
|
What is the R squared of a regression where none of the variables are collinear?
If none of the explanatory variables is colinear (i.e., each pair has zero correlation) then the coefficient-of-determination for the regresion is equal to the sum of the coefficients-of-determination
|
44,458
|
Central limit theorem and strong law of large numbers
|
In short: No.
A bit longer: Convergence in distribution does not directly imply, by any way, convergence almost-surely.
Much longer:
Given a random vector $X$, whose components are independent and identically distributed and its first two moments are finite - then the CLT says that asymptotically, the sample mean $\bar{X}_n$ converges to $\mu$ with rate $\sqrt{n}$ and asymptotic distribution $N(0,\sigma^2)$. That's convergence in distribution. It means that the CLT provides us with information regarding the rate in which the sample mean converges weakly to the population mean as sample size increases.
The Weak LLN says that the sample mean of a vector with a finite first moment, converges in probability to the population mean. That is, $\lim_{n\rightarrow\infty}P(\left| \bar{X}_n-\mu \right|>\epsilon)=0$. This means that no matter how small is the nonzero margin $\epsilon$ that we take, a sufficiently large sample would bring the difference between the sample mean and the population mean inside this margin. As you can see here, it is possible (under several conditions) that the CLT would imply the WLLN.
The Strong LLN says that the sample mean converges almost surely to the population mean. That is, $P\left(\lim_{n\rightarrow\infty}\bar{X}_n=\mu \right)=1$. This means that for a sufficiently large sample size, the probability of $\bar{X}_n$ not converging to $\mu$ is 0. That is a substantially stronger form of convergence, and cannot be directly implied from the CLT.
|
Central limit theorem and strong law of large numbers
|
In short: No.
A bit longer: Convergence in distribution does not directly imply, by any way, convergence almost-surely.
Much longer:
Given a random vector $X$, whose components are independent and ide
|
Central limit theorem and strong law of large numbers
In short: No.
A bit longer: Convergence in distribution does not directly imply, by any way, convergence almost-surely.
Much longer:
Given a random vector $X$, whose components are independent and identically distributed and its first two moments are finite - then the CLT says that asymptotically, the sample mean $\bar{X}_n$ converges to $\mu$ with rate $\sqrt{n}$ and asymptotic distribution $N(0,\sigma^2)$. That's convergence in distribution. It means that the CLT provides us with information regarding the rate in which the sample mean converges weakly to the population mean as sample size increases.
The Weak LLN says that the sample mean of a vector with a finite first moment, converges in probability to the population mean. That is, $\lim_{n\rightarrow\infty}P(\left| \bar{X}_n-\mu \right|>\epsilon)=0$. This means that no matter how small is the nonzero margin $\epsilon$ that we take, a sufficiently large sample would bring the difference between the sample mean and the population mean inside this margin. As you can see here, it is possible (under several conditions) that the CLT would imply the WLLN.
The Strong LLN says that the sample mean converges almost surely to the population mean. That is, $P\left(\lim_{n\rightarrow\infty}\bar{X}_n=\mu \right)=1$. This means that for a sufficiently large sample size, the probability of $\bar{X}_n$ not converging to $\mu$ is 0. That is a substantially stronger form of convergence, and cannot be directly implied from the CLT.
|
Central limit theorem and strong law of large numbers
In short: No.
A bit longer: Convergence in distribution does not directly imply, by any way, convergence almost-surely.
Much longer:
Given a random vector $X$, whose components are independent and ide
|
44,459
|
Central limit theorem and strong law of large numbers
|
As you suppose that $X_i$ are i.i.d. such that CLT holds then you suppose that $EX_1$ exists (because it is a term in CLT). Hence $X_i$ are i.i.d. with finite expectation and SLLN holds true.
|
Central limit theorem and strong law of large numbers
|
As you suppose that $X_i$ are i.i.d. such that CLT holds then you suppose that $EX_1$ exists (because it is a term in CLT). Hence $X_i$ are i.i.d. with finite expectation and SLLN holds true.
|
Central limit theorem and strong law of large numbers
As you suppose that $X_i$ are i.i.d. such that CLT holds then you suppose that $EX_1$ exists (because it is a term in CLT). Hence $X_i$ are i.i.d. with finite expectation and SLLN holds true.
|
Central limit theorem and strong law of large numbers
As you suppose that $X_i$ are i.i.d. such that CLT holds then you suppose that $EX_1$ exists (because it is a term in CLT). Hence $X_i$ are i.i.d. with finite expectation and SLLN holds true.
|
44,460
|
What happens if I change the range of a flat prior for Bayesian inference?
|
If you start with a uniform prior over the support of the parameter, you get the normalized likelihood back as the posterior (I'm going to restrict my attention to cases where the likelihood can be normalized to a density).
So if you start with some $\theta$ with support on $(0,1)$ and a likelihood that's proportional to a $B(\alpha,\beta)$ (for some $\alpha$ and $\beta$ say), then the posterior is that same beta distribution ($B(\alpha,\beta)$) back, naturally.
[Note that my $\alpha$ and $\beta$ are slightly different from yours. You didn't specify your binomial, doing so would probably simplify the discussion a little, but it's okay as is.]
If you replace that uniform prior with a "shorter" contiguous uniform one (i.e. whose support is wholly contained in the first one), you simply get a truncated version of the same $B(\alpha,\beta)$ posterior, where it's truncated to the support of the new prior.
The same idea applies to whatever other likelihood you might have.
(This is straightforward if you work with indicator notation.)
|
What happens if I change the range of a flat prior for Bayesian inference?
|
If you start with a uniform prior over the support of the parameter, you get the normalized likelihood back as the posterior (I'm going to restrict my attention to cases where the likelihood can be no
|
What happens if I change the range of a flat prior for Bayesian inference?
If you start with a uniform prior over the support of the parameter, you get the normalized likelihood back as the posterior (I'm going to restrict my attention to cases where the likelihood can be normalized to a density).
So if you start with some $\theta$ with support on $(0,1)$ and a likelihood that's proportional to a $B(\alpha,\beta)$ (for some $\alpha$ and $\beta$ say), then the posterior is that same beta distribution ($B(\alpha,\beta)$) back, naturally.
[Note that my $\alpha$ and $\beta$ are slightly different from yours. You didn't specify your binomial, doing so would probably simplify the discussion a little, but it's okay as is.]
If you replace that uniform prior with a "shorter" contiguous uniform one (i.e. whose support is wholly contained in the first one), you simply get a truncated version of the same $B(\alpha,\beta)$ posterior, where it's truncated to the support of the new prior.
The same idea applies to whatever other likelihood you might have.
(This is straightforward if you work with indicator notation.)
|
What happens if I change the range of a flat prior for Bayesian inference?
If you start with a uniform prior over the support of the parameter, you get the normalized likelihood back as the posterior (I'm going to restrict my attention to cases where the likelihood can be no
|
44,461
|
What happens if I change the range of a flat prior for Bayesian inference?
|
Comments:
If the prior distribution has support $[.1,1],$ then the posterior distribution has support contained in or equal to $[.1,1],$ so the posterior distribution could not be any ordinary (two-parameter) beta distribution.
Also, if one tries to use a normal prior for a binomial success
probability then it has to be truncated to have support $[0,1].$
Such a truncated normal prior is not conjugate to a binomial likelihood, so the posterior has to be computed by numerical
methods.
Moreover, there are inferential applications relating to the prevalence of a disease (which must lie in $[0,1])$ where fragmentary information from
medical screening tests in which traditional (non-Bayesian) inference can
lead to point and interval estimates of prevalence with nonsensical values outside of $[0,1].$ However, a Bayesian approach with a beta
prior must give point and interval estimates within $[0,1].$
One example is given here. [In this particular application, a Gibbs sampler is used to find the posterior distribution.]
Note: Undeniably, $\mathsf{Beta}(1,1) \equiv \mathsf{Unif}(0,1)$ is a
"flat" prior distribution for the binomial success probability $\theta.$ However, technically there is controversy whether this distribution is noninformative. The Jeffries prior $\mathsf{Beta}(.5,.5)$ has been
proposed as a more nearly noninformative prior distribution.
|
What happens if I change the range of a flat prior for Bayesian inference?
|
Comments:
If the prior distribution has support $[.1,1],$ then the posterior distribution has support contained in or equal to $[.1,1],$ so the posterior distribution could not be any ordinary (two-pa
|
What happens if I change the range of a flat prior for Bayesian inference?
Comments:
If the prior distribution has support $[.1,1],$ then the posterior distribution has support contained in or equal to $[.1,1],$ so the posterior distribution could not be any ordinary (two-parameter) beta distribution.
Also, if one tries to use a normal prior for a binomial success
probability then it has to be truncated to have support $[0,1].$
Such a truncated normal prior is not conjugate to a binomial likelihood, so the posterior has to be computed by numerical
methods.
Moreover, there are inferential applications relating to the prevalence of a disease (which must lie in $[0,1])$ where fragmentary information from
medical screening tests in which traditional (non-Bayesian) inference can
lead to point and interval estimates of prevalence with nonsensical values outside of $[0,1].$ However, a Bayesian approach with a beta
prior must give point and interval estimates within $[0,1].$
One example is given here. [In this particular application, a Gibbs sampler is used to find the posterior distribution.]
Note: Undeniably, $\mathsf{Beta}(1,1) \equiv \mathsf{Unif}(0,1)$ is a
"flat" prior distribution for the binomial success probability $\theta.$ However, technically there is controversy whether this distribution is noninformative. The Jeffries prior $\mathsf{Beta}(.5,.5)$ has been
proposed as a more nearly noninformative prior distribution.
|
What happens if I change the range of a flat prior for Bayesian inference?
Comments:
If the prior distribution has support $[.1,1],$ then the posterior distribution has support contained in or equal to $[.1,1],$ so the posterior distribution could not be any ordinary (two-pa
|
44,462
|
What happens if I change the range of a flat prior for Bayesian inference?
|
The standard proportionality result for the posterior still holds, but the posterior is now concentrated on the same restricted set as the prior. To see this, consider the general case where you restrict your prior to the set $\mathscr{D}$. If you use a prior proportionate to $\pi(\theta) \cdot \mathbb{I}(\theta \in \mathscr{D})$ then you get the posterior:
$$\pi(\theta|\mathbf{x}) \propto L_\mathbf{x}(\theta) \cdot \pi(\theta) \cdot \mathbb{I}(\theta \in \mathscr{D}),$$
which is proportionate to the unrestricted posterior, but restricted over the set $\mathscr{D}$.
|
What happens if I change the range of a flat prior for Bayesian inference?
|
The standard proportionality result for the posterior still holds, but the posterior is now concentrated on the same restricted set as the prior. To see this, consider the general case where you rest
|
What happens if I change the range of a flat prior for Bayesian inference?
The standard proportionality result for the posterior still holds, but the posterior is now concentrated on the same restricted set as the prior. To see this, consider the general case where you restrict your prior to the set $\mathscr{D}$. If you use a prior proportionate to $\pi(\theta) \cdot \mathbb{I}(\theta \in \mathscr{D})$ then you get the posterior:
$$\pi(\theta|\mathbf{x}) \propto L_\mathbf{x}(\theta) \cdot \pi(\theta) \cdot \mathbb{I}(\theta \in \mathscr{D}),$$
which is proportionate to the unrestricted posterior, but restricted over the set $\mathscr{D}$.
|
What happens if I change the range of a flat prior for Bayesian inference?
The standard proportionality result for the posterior still holds, but the posterior is now concentrated on the same restricted set as the prior. To see this, consider the general case where you rest
|
44,463
|
Probability after n steps
|
I think it's normal to see changes wrt parity because if in any of the previous states you hit $3$, you'll stay there, and otherwise, you'll end up alternating between 1 and 2. So, for example, for $n=1$, it's impossible to be in state $1$ because $X_0=1$ and you can only go to state $2$ or $3$.
Taking the power of the transition matrix is a straightforward way to calculate what you want. But, given the simplicity of the states, for ending at state $2$ after $n$ steps, you need to have odd parity and always alternate between states 1 and 2, i.e. each step is with $1/2$ prob. So, $P(X_n=2|X_0=1)=(1/2)^n$ if $n$ is odd, o/w it is $0$.
|
Probability after n steps
|
I think it's normal to see changes wrt parity because if in any of the previous states you hit $3$, you'll stay there, and otherwise, you'll end up alternating between 1 and 2. So, for example, for $n
|
Probability after n steps
I think it's normal to see changes wrt parity because if in any of the previous states you hit $3$, you'll stay there, and otherwise, you'll end up alternating between 1 and 2. So, for example, for $n=1$, it's impossible to be in state $1$ because $X_0=1$ and you can only go to state $2$ or $3$.
Taking the power of the transition matrix is a straightforward way to calculate what you want. But, given the simplicity of the states, for ending at state $2$ after $n$ steps, you need to have odd parity and always alternate between states 1 and 2, i.e. each step is with $1/2$ prob. So, $P(X_n=2|X_0=1)=(1/2)^n$ if $n$ is odd, o/w it is $0$.
|
Probability after n steps
I think it's normal to see changes wrt parity because if in any of the previous states you hit $3$, you'll stay there, and otherwise, you'll end up alternating between 1 and 2. So, for example, for $n
|
44,464
|
Probability after n steps
|
Gunes gives the answer by reasoning (which is probably what you should do for this exam).
A more general and straightforward method (but which requires more computation time) is the following:
You decompose the begin state as a sum of eigenvectors. Then you describe the evolution in terms of the evolution of those eigenvectors.
Compute the eigenvectors and eigenvalues
$$v_1 = \begin{bmatrix} 0\\0\\1\end{bmatrix}, \quad
v_2 = \begin{bmatrix} 1\\1\\-2\end{bmatrix}, \quad
v_3 = \begin{bmatrix} 1\\-1\\0\end{bmatrix}$$
$$\lambda_1= 1,\quad \lambda_2 = 0.5, \quad \lambda_3 = -0.5$$
Write the begin state as a linear sum of the eigenvectors
$$x_0 = a_1 v_1 + a_2 v_2 + a_3 v_3$$
In the example we got $a_1,a_2,a_3 = 1, 1/2,1/2$ or
$$\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} = 1 \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} + \frac{1}{2} \begin{bmatrix} 1 \\ 1 \\ -2 \end{bmatrix} + \frac{1}{2} \begin{bmatrix} 1 \\ -1 \\ 0 \end{bmatrix}$$
The solution will be (the eigenvector components of the begin state each individually multiply with a power of the eigenvalue)
$$x_n = a_1 \lambda_1^n v_1 + a_2 \lambda_2^n v_2 + a_3 \lambda_3^n v_3 $$
For the 2nd state this means
$$x_{n,2} = a_2 0.5^n - a_3 (-0.5)^n$$
and with the $a_i$ for this case it is
$$x_{n,2} = 0.5(0.5^n - (-0.5)^n)$$
Which is like gunes answer $x_{n,2} = 0$ for even $n$ and $x_{n,2} = 0.5^n$ for odd $n$.
I do not think that this is what you are supposed to do in your exam. But, you can use this knowledge to your advantage in the idea that you can use it to verify/check your result. You know of which form the solution must be, namely some sum of powers of the eigenvalues (of which one will equal 1 if it is a probability transition).
|
Probability after n steps
|
Gunes gives the answer by reasoning (which is probably what you should do for this exam).
A more general and straightforward method (but which requires more computation time) is the following:
You dec
|
Probability after n steps
Gunes gives the answer by reasoning (which is probably what you should do for this exam).
A more general and straightforward method (but which requires more computation time) is the following:
You decompose the begin state as a sum of eigenvectors. Then you describe the evolution in terms of the evolution of those eigenvectors.
Compute the eigenvectors and eigenvalues
$$v_1 = \begin{bmatrix} 0\\0\\1\end{bmatrix}, \quad
v_2 = \begin{bmatrix} 1\\1\\-2\end{bmatrix}, \quad
v_3 = \begin{bmatrix} 1\\-1\\0\end{bmatrix}$$
$$\lambda_1= 1,\quad \lambda_2 = 0.5, \quad \lambda_3 = -0.5$$
Write the begin state as a linear sum of the eigenvectors
$$x_0 = a_1 v_1 + a_2 v_2 + a_3 v_3$$
In the example we got $a_1,a_2,a_3 = 1, 1/2,1/2$ or
$$\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} = 1 \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} + \frac{1}{2} \begin{bmatrix} 1 \\ 1 \\ -2 \end{bmatrix} + \frac{1}{2} \begin{bmatrix} 1 \\ -1 \\ 0 \end{bmatrix}$$
The solution will be (the eigenvector components of the begin state each individually multiply with a power of the eigenvalue)
$$x_n = a_1 \lambda_1^n v_1 + a_2 \lambda_2^n v_2 + a_3 \lambda_3^n v_3 $$
For the 2nd state this means
$$x_{n,2} = a_2 0.5^n - a_3 (-0.5)^n$$
and with the $a_i$ for this case it is
$$x_{n,2} = 0.5(0.5^n - (-0.5)^n)$$
Which is like gunes answer $x_{n,2} = 0$ for even $n$ and $x_{n,2} = 0.5^n$ for odd $n$.
I do not think that this is what you are supposed to do in your exam. But, you can use this knowledge to your advantage in the idea that you can use it to verify/check your result. You know of which form the solution must be, namely some sum of powers of the eigenvalues (of which one will equal 1 if it is a probability transition).
|
Probability after n steps
Gunes gives the answer by reasoning (which is probably what you should do for this exam).
A more general and straightforward method (but which requires more computation time) is the following:
You dec
|
44,465
|
Probability after n steps
|
The very fact that the Markov chain can be characterized by a constant transition matrix means that it is homogeneous. It may be easier to understand the concepts that you're struggling with with a simpler matrix. Consider
$$A=\frac 1 3\left(\begin{array}{ccc}1 &2 \\ 2 & 1\end{array}\right)$$
This matrix will switch the relative sizes of the two states: if we have $v_2 = Av_1$, the first entry of $v_2$ will be greater than the second iff the first entry of $v_1$ is smaller than the second. So which entry is greater depends on the parity of the power of $A$.
However, remember that homogeneity is about conditional probability. While the behavior of a particular starting state depends on the parity of the power, the conditional behavior doesn't: if the first entry of $A^nv_1$ is greater than the second, then the second entry of $A^{n+1}v_1$ is greater than the first. That statement is true regardless of the parity of $n$. Homogeneity is what we can say about $A^{n+1}v$ conditional on $A^{n}v$. Since $A^{n+1}v$ is by definition equal to $A(A^{n}v)$, we know that the transition probabilities from $A^{n}v$ to $A^{n+1}v$ are constant, and given by $A$.
|
Probability after n steps
|
The very fact that the Markov chain can be characterized by a constant transition matrix means that it is homogeneous. It may be easier to understand the concepts that you're struggling with with a si
|
Probability after n steps
The very fact that the Markov chain can be characterized by a constant transition matrix means that it is homogeneous. It may be easier to understand the concepts that you're struggling with with a simpler matrix. Consider
$$A=\frac 1 3\left(\begin{array}{ccc}1 &2 \\ 2 & 1\end{array}\right)$$
This matrix will switch the relative sizes of the two states: if we have $v_2 = Av_1$, the first entry of $v_2$ will be greater than the second iff the first entry of $v_1$ is smaller than the second. So which entry is greater depends on the parity of the power of $A$.
However, remember that homogeneity is about conditional probability. While the behavior of a particular starting state depends on the parity of the power, the conditional behavior doesn't: if the first entry of $A^nv_1$ is greater than the second, then the second entry of $A^{n+1}v_1$ is greater than the first. That statement is true regardless of the parity of $n$. Homogeneity is what we can say about $A^{n+1}v$ conditional on $A^{n}v$. Since $A^{n+1}v$ is by definition equal to $A(A^{n}v)$, we know that the transition probabilities from $A^{n}v$ to $A^{n+1}v$ are constant, and given by $A$.
|
Probability after n steps
The very fact that the Markov chain can be characterized by a constant transition matrix means that it is homogeneous. It may be easier to understand the concepts that you're struggling with with a si
|
44,466
|
How to express descriptive statistics as statistical functionals - and why?
|
$dF(x) = f(x)dx$ is true when the probability measure of the random variable (or equivalently the CDF, $F(x)$) is absolutely continuous with respect to the Lebesgue Measure. What that means is that for all sets with Lebesgue measure zero, the measure also assigns measure 0. You can think of this as meaning that the Lebesgue measure and the distribution measure are measures of the same space. In this case, we can define a "derivative" of the distribution of $X$ with respect to the Lebesgue measure:
\begin{align}
\frac{dF(x)}{dx} = f(x)
\end{align}
where $f(x)$ is the probability density function. We can also think of this as a change of measure, a reweighting of the probability distribution measure and the Lebesque measure. In general this is an example of a radon-nikodym derivative.
So why introduce all of this machinery and notation to get back to a pdf?
The real magic is in the case that $F(x)$ is not absolutely continuous with the Lebesgue measure. For example, say we have a discrete random variable. Discrete random variables cannot have probability measures absolutely continuous with Lebesgue because they explicitly give positive measure to some countable set.
In the discrete case, we take the radon-nikodym with respect to the counting measure and the integrals in this case simplify as following:
\begin{align}
E[g(X)] = \int g(x)dF(x) = \sum_{x\in \mathcal{X}} g(x)P(X=x)
\end{align}
where $\mathcal{X}$ is the support of the discrete random variable $X$. In elementary statistics and probability books often discrete and continuous random variables are presented completely separately. Essentially we define the radon-nikodym derivative with respect to the counting measure, give it a special name (pmf) then talk about how we can construct integrals of interest with respect to these pmfs. Then we start all over defining the radon-nikodym derivative for continuous variables (pdfs) and reintroduce all the same concepts with respect to pdfs.
The measure theory framework allows us to generalize the concept to include both continuous and discrete random variables (as well as those which don't fit into either category) and introduce a standard notation that does not force us to make distinctions which are unimportant with respect to the underlying probability theory, fostering connections between concepts. The cost is obviously an investment in measure theory, which may not be feasible for all people interested in learning stats and probability.
|
How to express descriptive statistics as statistical functionals - and why?
|
$dF(x) = f(x)dx$ is true when the probability measure of the random variable (or equivalently the CDF, $F(x)$) is absolutely continuous with respect to the Lebesgue Measure. What that means is that fo
|
How to express descriptive statistics as statistical functionals - and why?
$dF(x) = f(x)dx$ is true when the probability measure of the random variable (or equivalently the CDF, $F(x)$) is absolutely continuous with respect to the Lebesgue Measure. What that means is that for all sets with Lebesgue measure zero, the measure also assigns measure 0. You can think of this as meaning that the Lebesgue measure and the distribution measure are measures of the same space. In this case, we can define a "derivative" of the distribution of $X$ with respect to the Lebesgue measure:
\begin{align}
\frac{dF(x)}{dx} = f(x)
\end{align}
where $f(x)$ is the probability density function. We can also think of this as a change of measure, a reweighting of the probability distribution measure and the Lebesque measure. In general this is an example of a radon-nikodym derivative.
So why introduce all of this machinery and notation to get back to a pdf?
The real magic is in the case that $F(x)$ is not absolutely continuous with the Lebesgue measure. For example, say we have a discrete random variable. Discrete random variables cannot have probability measures absolutely continuous with Lebesgue because they explicitly give positive measure to some countable set.
In the discrete case, we take the radon-nikodym with respect to the counting measure and the integrals in this case simplify as following:
\begin{align}
E[g(X)] = \int g(x)dF(x) = \sum_{x\in \mathcal{X}} g(x)P(X=x)
\end{align}
where $\mathcal{X}$ is the support of the discrete random variable $X$. In elementary statistics and probability books often discrete and continuous random variables are presented completely separately. Essentially we define the radon-nikodym derivative with respect to the counting measure, give it a special name (pmf) then talk about how we can construct integrals of interest with respect to these pmfs. Then we start all over defining the radon-nikodym derivative for continuous variables (pdfs) and reintroduce all the same concepts with respect to pdfs.
The measure theory framework allows us to generalize the concept to include both continuous and discrete random variables (as well as those which don't fit into either category) and introduce a standard notation that does not force us to make distinctions which are unimportant with respect to the underlying probability theory, fostering connections between concepts. The cost is obviously an investment in measure theory, which may not be feasible for all people interested in learning stats and probability.
|
How to express descriptive statistics as statistical functionals - and why?
$dF(x) = f(x)dx$ is true when the probability measure of the random variable (or equivalently the CDF, $F(x)$) is absolutely continuous with respect to the Lebesgue Measure. What that means is that fo
|
44,467
|
How to express descriptive statistics as statistical functionals - and why?
|
First a correction to the question: when writing
$$T_1(F) = \int x\text d F \qquad \text{or} \qquad T_2(F) = \int (x-T_1(F))^2\,\text d F$$
these quantities are not statistics but functionals of the distribution of the data. For instance, $T_1(F)=\mathbb E [X]$ is the mean of $F$. Functionals are thus generalised moments. (Statistics are coming into my second point, below.) As for the use of $\text D F$, this is a generic notation in measure theory and Tyrel Stokes's answer is excellent.
Concerning statistics, the motivation for the notation is at the core of the bootstrap approach: when estimating $T(F)$, one uses instead $T(\hat F_n)$ when $\hat F_n$ is the empirical distribution, based on the observed sample. Since this empirical distribution has a finite support, it does not enjoy a pdf wrt Lebesgue measure but has a pmf over the set defined by the observed sample. The reasoning is that, since $\hat F_n$ is a convergent approximation of $F$ (by the Glivenko-Cantelli theorem), the same should apply to $T(\hat F_n)$.
|
How to express descriptive statistics as statistical functionals - and why?
|
First a correction to the question: when writing
$$T_1(F) = \int x\text d F \qquad \text{or} \qquad T_2(F) = \int (x-T_1(F))^2\,\text d F$$
these quantities are not statistics but functionals of the d
|
How to express descriptive statistics as statistical functionals - and why?
First a correction to the question: when writing
$$T_1(F) = \int x\text d F \qquad \text{or} \qquad T_2(F) = \int (x-T_1(F))^2\,\text d F$$
these quantities are not statistics but functionals of the distribution of the data. For instance, $T_1(F)=\mathbb E [X]$ is the mean of $F$. Functionals are thus generalised moments. (Statistics are coming into my second point, below.) As for the use of $\text D F$, this is a generic notation in measure theory and Tyrel Stokes's answer is excellent.
Concerning statistics, the motivation for the notation is at the core of the bootstrap approach: when estimating $T(F)$, one uses instead $T(\hat F_n)$ when $\hat F_n$ is the empirical distribution, based on the observed sample. Since this empirical distribution has a finite support, it does not enjoy a pdf wrt Lebesgue measure but has a pmf over the set defined by the observed sample. The reasoning is that, since $\hat F_n$ is a convergent approximation of $F$ (by the Glivenko-Cantelli theorem), the same should apply to $T(\hat F_n)$.
|
How to express descriptive statistics as statistical functionals - and why?
First a correction to the question: when writing
$$T_1(F) = \int x\text d F \qquad \text{or} \qquad T_2(F) = \int (x-T_1(F))^2\,\text d F$$
these quantities are not statistics but functionals of the d
|
44,468
|
Clarification - Random Variable
|
I think Mr Blitzstein, when writing
$$P (X=a_j \text{ for some } j)=1$$
really meant that $X$ is always one of $a_1, a_2, \ldots$. So it always is $a_j$ for some $j$.
I'd write
$$ P(X \in \{a_1, a_2, \ldots\})=1$$
|
Clarification - Random Variable
|
I think Mr Blitzstein, when writing
$$P (X=a_j \text{ for some } j)=1$$
really meant that $X$ is always one of $a_1, a_2, \ldots$. So it always is $a_j$ for some $j$.
I'd write
$$ P(X \in \{a_1, a_2,
|
Clarification - Random Variable
I think Mr Blitzstein, when writing
$$P (X=a_j \text{ for some } j)=1$$
really meant that $X$ is always one of $a_1, a_2, \ldots$. So it always is $a_j$ for some $j$.
I'd write
$$ P(X \in \{a_1, a_2, \ldots\})=1$$
|
Clarification - Random Variable
I think Mr Blitzstein, when writing
$$P (X=a_j \text{ for some } j)=1$$
really meant that $X$ is always one of $a_1, a_2, \ldots$. So it always is $a_j$ for some $j$.
I'd write
$$ P(X \in \{a_1, a_2,
|
44,469
|
Clarification - Random Variable
|
The notation is the book is intentionally avoiding sums, but in this case it leads to confusion. I prefer the second expression below.
$$
P(X = a_j \text{ for some }a_j) = \sum_{i = 1}^n P\left(X = a_i\right) \,=\, 1
$$
In you formula, if I interpret "for some $j$", it is not correct. The variable X is not equal to a specific $a_j$ with probability one, but it is equal to one of the $a_j$ with probability one. Technically, since your expression sums over $j$, it doesn't make sense to say "for some $j$" at all. In the equality below, the left is a more informal but conventional way of leaving out the iterating variable, translating more explicitly to the expression on the right.
$$
\sum_{j}P\left(X = a_j\right) = \sum_{i = 1}^n P\left(X=a_i\right)
$$
It may be helpful to look ahead to a definition of a continuous random variable. A random variable is either continuous or discrete.
|
Clarification - Random Variable
|
The notation is the book is intentionally avoiding sums, but in this case it leads to confusion. I prefer the second expression below.
$$
P(X = a_j \text{ for some }a_j) = \sum_{i = 1}^n P\left(X = a
|
Clarification - Random Variable
The notation is the book is intentionally avoiding sums, but in this case it leads to confusion. I prefer the second expression below.
$$
P(X = a_j \text{ for some }a_j) = \sum_{i = 1}^n P\left(X = a_i\right) \,=\, 1
$$
In you formula, if I interpret "for some $j$", it is not correct. The variable X is not equal to a specific $a_j$ with probability one, but it is equal to one of the $a_j$ with probability one. Technically, since your expression sums over $j$, it doesn't make sense to say "for some $j$" at all. In the equality below, the left is a more informal but conventional way of leaving out the iterating variable, translating more explicitly to the expression on the right.
$$
\sum_{j}P\left(X = a_j\right) = \sum_{i = 1}^n P\left(X=a_i\right)
$$
It may be helpful to look ahead to a definition of a continuous random variable. A random variable is either continuous or discrete.
|
Clarification - Random Variable
The notation is the book is intentionally avoiding sums, but in this case it leads to confusion. I prefer the second expression below.
$$
P(X = a_j \text{ for some }a_j) = \sum_{i = 1}^n P\left(X = a
|
44,470
|
Variational Autoencoder and Covariance Matrix
|
The diagonal covariance matrix is an explicit statement about the kind of latent representation the researcher wants the model to learn: a representation that can be modeled as independent Gaussians.
Additionally, @Firebug points out in comments that a symmetric, PD matrix can be diagonalized without any loss of information. In other words, for some symmetric, PD matrix $A$, we can write $A=PDP^\top$ for $D$ some diagonal matrix and $P$ can be chosen to be orthonormal. This retains the same information in the sense that $A$ is rotated to have orthogonal coordinates.
Purely from the perspective of abstraction, there is no reason you must be limited to learning a latent representation that is composed of independent Gaussians. However, the computational side seems challenging.
The standard VAE encoder for a single sample produces latent parameters $(\mu, \sigma)$ its input. Then it uses the re-parameterization trick to draw random samples from that distribution. There are $d$ elements in each of $\mu$ and $\sigma$ so the total number of latent parameters is $2d$.
An alternative model that includes a covariance matrix would need some method to produce a covariance matrix, so the output of the encoder is $(\mu, \Sigma)$.
If your latent space has dimension $d$, you're doing inference on each of the $d$ elements of $\mu$ and each of the $\frac{d(d+1)}{2}$ elements of $\Sigma$ (because $\Sigma$ is symmetric by definition), for a total of $\frac{d(d+3)}{2}$ elements. Any time you have more than 1 latent dimension, the covariance matrix model will have more latent parameters to learn compared to the diagonal model.
Furthermore, the multivariate normal distribution requires that $\Sigma$ be positive definite, so we must somehow guarantee that, for each sample, we generate a PD matrix. (Using an alternative strategy, such as factorizing into standard deviations and correlation matrix $\Omega$, i.e. $\Sigma = (\sigma I) \Omega (\sigma I)$, will increase the number of effective parameters without solving the PD problem, since now we must guarantee that $\Omega$ is PD.)
Additionally, we must also be able to backprop that procedure so that the encoder weights can be updated. This may or may not be possible, depending on the strategy used to generate $\Sigma$ and draw a deviate from the multivariate Gaussian.
These three issues -- more parameters, assuring differentiability, positive definiteness -- are challenging.
If you're contemplating undertaking research to overcome these challenges, that's great! But one must ask, why is this a good model? What problems does it solve which are not solved by the diagonal Gaussian VAE model, or an alternative non-Gaussian VAE model (e.g. a Dirichlet VAE)?
|
Variational Autoencoder and Covariance Matrix
|
The diagonal covariance matrix is an explicit statement about the kind of latent representation the researcher wants the model to learn: a representation that can be modeled as independent Gaussians.
|
Variational Autoencoder and Covariance Matrix
The diagonal covariance matrix is an explicit statement about the kind of latent representation the researcher wants the model to learn: a representation that can be modeled as independent Gaussians.
Additionally, @Firebug points out in comments that a symmetric, PD matrix can be diagonalized without any loss of information. In other words, for some symmetric, PD matrix $A$, we can write $A=PDP^\top$ for $D$ some diagonal matrix and $P$ can be chosen to be orthonormal. This retains the same information in the sense that $A$ is rotated to have orthogonal coordinates.
Purely from the perspective of abstraction, there is no reason you must be limited to learning a latent representation that is composed of independent Gaussians. However, the computational side seems challenging.
The standard VAE encoder for a single sample produces latent parameters $(\mu, \sigma)$ its input. Then it uses the re-parameterization trick to draw random samples from that distribution. There are $d$ elements in each of $\mu$ and $\sigma$ so the total number of latent parameters is $2d$.
An alternative model that includes a covariance matrix would need some method to produce a covariance matrix, so the output of the encoder is $(\mu, \Sigma)$.
If your latent space has dimension $d$, you're doing inference on each of the $d$ elements of $\mu$ and each of the $\frac{d(d+1)}{2}$ elements of $\Sigma$ (because $\Sigma$ is symmetric by definition), for a total of $\frac{d(d+3)}{2}$ elements. Any time you have more than 1 latent dimension, the covariance matrix model will have more latent parameters to learn compared to the diagonal model.
Furthermore, the multivariate normal distribution requires that $\Sigma$ be positive definite, so we must somehow guarantee that, for each sample, we generate a PD matrix. (Using an alternative strategy, such as factorizing into standard deviations and correlation matrix $\Omega$, i.e. $\Sigma = (\sigma I) \Omega (\sigma I)$, will increase the number of effective parameters without solving the PD problem, since now we must guarantee that $\Omega$ is PD.)
Additionally, we must also be able to backprop that procedure so that the encoder weights can be updated. This may or may not be possible, depending on the strategy used to generate $\Sigma$ and draw a deviate from the multivariate Gaussian.
These three issues -- more parameters, assuring differentiability, positive definiteness -- are challenging.
If you're contemplating undertaking research to overcome these challenges, that's great! But one must ask, why is this a good model? What problems does it solve which are not solved by the diagonal Gaussian VAE model, or an alternative non-Gaussian VAE model (e.g. a Dirichlet VAE)?
|
Variational Autoencoder and Covariance Matrix
The diagonal covariance matrix is an explicit statement about the kind of latent representation the researcher wants the model to learn: a representation that can be modeled as independent Gaussians.
|
44,471
|
Variational Autoencoder and Covariance Matrix
|
I'm working on something like this now.
Let's say the researcher wants a full covariance latent variable $Z ~ N(mu, \Sigma)$. Like the multiplication trick from VAE, we can have a matrix multiplication trick. Still sample from a high dimensional unit Gaussian, $e \sim N(0, I)$.
There is this property of linear transformations of high D Gaussians: https://www.statlect.com/probability-distributions/normal-distribution-linear-combinations#hid2. If we want the transformed covariance to be $\Sigma$, we have to hit $e$ with the matrix square root of the proposal covariance $\Sigma^{1/2}e \sim N(0, \Sigma)$.
Someone above pointed out that $\Sigma$ must be symmetric positive definite. This can be modeled as a sum of rank 1 matrices, formed as the outer product of each component vector. This is a sum of quadratic forms, so we know it will at least be positive semidefinite. To get positive definite, we have to choose a sufficient number of component vectors. By CLT (> 30 components), the off diagonal entries will be zero mean Gaussian, while the main diagonal remains positive. The number of components needed in practice might depend on other factors.
I tried this with MNIST and got decent results. There might be a way to enforce PD by parametrizing $\Sigma$ with Inverse Wishart prior, but that also requires one of the parameters to be a symmetric PD matrix.
|
Variational Autoencoder and Covariance Matrix
|
I'm working on something like this now.
Let's say the researcher wants a full covariance latent variable $Z ~ N(mu, \Sigma)$. Like the multiplication trick from VAE, we can have a matrix multiplicati
|
Variational Autoencoder and Covariance Matrix
I'm working on something like this now.
Let's say the researcher wants a full covariance latent variable $Z ~ N(mu, \Sigma)$. Like the multiplication trick from VAE, we can have a matrix multiplication trick. Still sample from a high dimensional unit Gaussian, $e \sim N(0, I)$.
There is this property of linear transformations of high D Gaussians: https://www.statlect.com/probability-distributions/normal-distribution-linear-combinations#hid2. If we want the transformed covariance to be $\Sigma$, we have to hit $e$ with the matrix square root of the proposal covariance $\Sigma^{1/2}e \sim N(0, \Sigma)$.
Someone above pointed out that $\Sigma$ must be symmetric positive definite. This can be modeled as a sum of rank 1 matrices, formed as the outer product of each component vector. This is a sum of quadratic forms, so we know it will at least be positive semidefinite. To get positive definite, we have to choose a sufficient number of component vectors. By CLT (> 30 components), the off diagonal entries will be zero mean Gaussian, while the main diagonal remains positive. The number of components needed in practice might depend on other factors.
I tried this with MNIST and got decent results. There might be a way to enforce PD by parametrizing $\Sigma$ with Inverse Wishart prior, but that also requires one of the parameters to be a symmetric PD matrix.
|
Variational Autoencoder and Covariance Matrix
I'm working on something like this now.
Let's say the researcher wants a full covariance latent variable $Z ~ N(mu, \Sigma)$. Like the multiplication trick from VAE, we can have a matrix multiplicati
|
44,472
|
Variational Autoencoder and Covariance Matrix
|
A variational autoencoder is based on variational inference. The zero covariance is an assumption, mean-field variational family, which makes optimization easier, since the latent variables are independent.
Check chapter 2.3 of this paper: https://arxiv.org/abs/1601.00670
They also briefly dive into other families:
One way to expand the family is to add dependencies
between the variables (Saul and Jordan, 1996; Barber and Wiegerinck, 1999); this is called structured variational inference.
|
Variational Autoencoder and Covariance Matrix
|
A variational autoencoder is based on variational inference. The zero covariance is an assumption, mean-field variational family, which makes optimization easier, since the latent variables are indepe
|
Variational Autoencoder and Covariance Matrix
A variational autoencoder is based on variational inference. The zero covariance is an assumption, mean-field variational family, which makes optimization easier, since the latent variables are independent.
Check chapter 2.3 of this paper: https://arxiv.org/abs/1601.00670
They also briefly dive into other families:
One way to expand the family is to add dependencies
between the variables (Saul and Jordan, 1996; Barber and Wiegerinck, 1999); this is called structured variational inference.
|
Variational Autoencoder and Covariance Matrix
A variational autoencoder is based on variational inference. The zero covariance is an assumption, mean-field variational family, which makes optimization easier, since the latent variables are indepe
|
44,473
|
What is the best way to display confidence intervals around a proportion?
|
A pretty standard approach (most common for relative effect measures such as odds ratios, risk ratios, rate ratios and hazard ratios) is to use a figure with axes that show probabilities (i.e. all the axis labels show probabilities), but which are on the logit scale. I.e. the distance from 0.5 to 0.73 (0 to 1 on the logit scale) is the same as from 0.73 to 0.88 (1 to 2 on the logit scale). This is particularly useful, when multiple probabilities are being shown that people might visually compare to each other on the graph.
|
What is the best way to display confidence intervals around a proportion?
|
A pretty standard approach (most common for relative effect measures such as odds ratios, risk ratios, rate ratios and hazard ratios) is to use a figure with axes that show probabilities (i.e. all the
|
What is the best way to display confidence intervals around a proportion?
A pretty standard approach (most common for relative effect measures such as odds ratios, risk ratios, rate ratios and hazard ratios) is to use a figure with axes that show probabilities (i.e. all the axis labels show probabilities), but which are on the logit scale. I.e. the distance from 0.5 to 0.73 (0 to 1 on the logit scale) is the same as from 0.73 to 0.88 (1 to 2 on the logit scale). This is particularly useful, when multiple probabilities are being shown that people might visually compare to each other on the graph.
|
What is the best way to display confidence intervals around a proportion?
A pretty standard approach (most common for relative effect measures such as odds ratios, risk ratios, rate ratios and hazard ratios) is to use a figure with axes that show probabilities (i.e. all the
|
44,474
|
What is the best way to display confidence intervals around a proportion?
|
I would say that it is beneficial to show the asymmetric confidence intervals in order for readers to (better) realize that the odds ratio is asymmetric around its null value. Especially showing the figure rather than reporting the 95% CIs in the text makes this stronger/clearer.
The same of course holds for other types of ratios often used, e.g., risk ratio, or hazard ratios.
|
What is the best way to display confidence intervals around a proportion?
|
I would say that it is beneficial to show the asymmetric confidence intervals in order for readers to (better) realize that the odds ratio is asymmetric around its null value. Especially showing the f
|
What is the best way to display confidence intervals around a proportion?
I would say that it is beneficial to show the asymmetric confidence intervals in order for readers to (better) realize that the odds ratio is asymmetric around its null value. Especially showing the figure rather than reporting the 95% CIs in the text makes this stronger/clearer.
The same of course holds for other types of ratios often used, e.g., risk ratio, or hazard ratios.
|
What is the best way to display confidence intervals around a proportion?
I would say that it is beneficial to show the asymmetric confidence intervals in order for readers to (better) realize that the odds ratio is asymmetric around its null value. Especially showing the f
|
44,475
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
Suppose, as in the case of least squares methods, you are trying to solve a statistical estimation problem for a (vector-valued) parameter $\beta$ by minimizing an objective function $Q(\beta)$ (such as the sum of squares of the residuals). Ridge Regression "regularizes" the problem by adding a non-negative linear combination of the squares of the parameter, $P(\beta).$ $P$ is (obviously) differentiable with a unique global minimum at $\beta=0.$
The question asks, when is it possible for the global minimum of $Q+P$ to occur at $\beta=0$? Assume, as in least squares methods, that $Q$ is differentiable in a neighborhood of $0.$ Because $0$ is a global minimum for $Q+P$ it is a local minimum, implying all its partial derivatives are $0.$ The sum rule of differentiation implies
$$\frac{\partial}{\partial \beta_i}(Q(\beta) + P(\beta)) = \frac{\partial}{\partial \beta_i}Q(\beta) + \frac{\partial}{\partial \beta_i}P(\beta) = Q_i(\beta) + P_i(\beta)$$
is zero at $\beta=0.$ But since $P_i(0)=0$ for all $i,$ this implies $Q_i(0)=0$ for all $i,$ which makes $0$ at least a local minimum for the original objective function $Q.$ In the case of any least squares technique every local minimum is also a global minimum. This compels us to conclude that
Quadratic regularization of Least Squares procedures ("Ridge Regression") has $\beta=0$ as a solution if and only if $\beta=0$ is a solution of the original unregularized problem.
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
Suppose, as in the case of least squares methods, you are trying to solve a statistical estimation problem for a (vector-valued) parameter $\beta$ by minimizing an objective function $Q(\beta)$ (such
|
Is there any special case where ridge regression can shrink coefficients to zero?
Suppose, as in the case of least squares methods, you are trying to solve a statistical estimation problem for a (vector-valued) parameter $\beta$ by minimizing an objective function $Q(\beta)$ (such as the sum of squares of the residuals). Ridge Regression "regularizes" the problem by adding a non-negative linear combination of the squares of the parameter, $P(\beta).$ $P$ is (obviously) differentiable with a unique global minimum at $\beta=0.$
The question asks, when is it possible for the global minimum of $Q+P$ to occur at $\beta=0$? Assume, as in least squares methods, that $Q$ is differentiable in a neighborhood of $0.$ Because $0$ is a global minimum for $Q+P$ it is a local minimum, implying all its partial derivatives are $0.$ The sum rule of differentiation implies
$$\frac{\partial}{\partial \beta_i}(Q(\beta) + P(\beta)) = \frac{\partial}{\partial \beta_i}Q(\beta) + \frac{\partial}{\partial \beta_i}P(\beta) = Q_i(\beta) + P_i(\beta)$$
is zero at $\beta=0.$ But since $P_i(0)=0$ for all $i,$ this implies $Q_i(0)=0$ for all $i,$ which makes $0$ at least a local minimum for the original objective function $Q.$ In the case of any least squares technique every local minimum is also a global minimum. This compels us to conclude that
Quadratic regularization of Least Squares procedures ("Ridge Regression") has $\beta=0$ as a solution if and only if $\beta=0$ is a solution of the original unregularized problem.
|
Is there any special case where ridge regression can shrink coefficients to zero?
Suppose, as in the case of least squares methods, you are trying to solve a statistical estimation problem for a (vector-valued) parameter $\beta$ by minimizing an objective function $Q(\beta)$ (such
|
44,476
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
Traditional OLS ridge regression indeed will only return zero coefficients when a traditional OLS regression would also give you zero coefficients - the shrinkage for the other coefficients can approach zero but never actually become equal to zero. Likewise, if you use nonnegative least square ridge regression coefficients will also only become zero when they would be zero in a regular nonnegative least square (nnls) fit.
When adaptive penalty weights are used in ridge regression and such adaptive ridge regression is iterated things become a bit different though - in that case, some coefficients would asymptotically (after many iterations) tend to zero (or end up being smaller than the machine precision and be rounded off to zero) and by choosing appropriate adaptive weights you can use this scheme to approximate L0-pseudonorm penalized regression (which in combination with a well tuned lambda would approximate best subset selection). So in that case, iterative adaptive ridge regression could be used for variable selection, and this in fact works very well. You can find the details in this talk and in this paper. Basically, you just have to choose your lambdas with which you ridge penalize your p variables as lambda * penweights where penweights is a vector given by 1/(betahat^2+delta^2), where delta is a small number, e.g. 1E-5, and betahat are the estimated coefficients in the previous adaptive ridge iteration (in the first iteration they can be set to 1). Especially in combination with nonnegativity constraints (which can be imposed by fitting your ridge regression with nnls and row augmenting your covariate matrix with a matrix with the square root of your lambdas along the diagonal, i.e. as nnls(A=rbind(X, sqrt(lambdas) * diag(1, p)), b=c(y, rep(0,p)) )$x, this can converge quite fast, often converging to the L0-norm penalized solution in 10 or 20 iterations.
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
Traditional OLS ridge regression indeed will only return zero coefficients when a traditional OLS regression would also give you zero coefficients - the shrinkage for the other coefficients can approa
|
Is there any special case where ridge regression can shrink coefficients to zero?
Traditional OLS ridge regression indeed will only return zero coefficients when a traditional OLS regression would also give you zero coefficients - the shrinkage for the other coefficients can approach zero but never actually become equal to zero. Likewise, if you use nonnegative least square ridge regression coefficients will also only become zero when they would be zero in a regular nonnegative least square (nnls) fit.
When adaptive penalty weights are used in ridge regression and such adaptive ridge regression is iterated things become a bit different though - in that case, some coefficients would asymptotically (after many iterations) tend to zero (or end up being smaller than the machine precision and be rounded off to zero) and by choosing appropriate adaptive weights you can use this scheme to approximate L0-pseudonorm penalized regression (which in combination with a well tuned lambda would approximate best subset selection). So in that case, iterative adaptive ridge regression could be used for variable selection, and this in fact works very well. You can find the details in this talk and in this paper. Basically, you just have to choose your lambdas with which you ridge penalize your p variables as lambda * penweights where penweights is a vector given by 1/(betahat^2+delta^2), where delta is a small number, e.g. 1E-5, and betahat are the estimated coefficients in the previous adaptive ridge iteration (in the first iteration they can be set to 1). Especially in combination with nonnegativity constraints (which can be imposed by fitting your ridge regression with nnls and row augmenting your covariate matrix with a matrix with the square root of your lambdas along the diagonal, i.e. as nnls(A=rbind(X, sqrt(lambdas) * diag(1, p)), b=c(y, rep(0,p)) )$x, this can converge quite fast, often converging to the L0-norm penalized solution in 10 or 20 iterations.
|
Is there any special case where ridge regression can shrink coefficients to zero?
Traditional OLS ridge regression indeed will only return zero coefficients when a traditional OLS regression would also give you zero coefficients - the shrinkage for the other coefficients can approa
|
44,477
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
I think it can, and it does it actually very frequently (shrink some coefficient near zero). If you do an internet search for "images" and search for "ridge regression coefficient path" you will see the visual output of a large quantity of ridge regression models and their respective coefficient path output.
What you will notice is that very frequently some of the variable coefficients paths show actual coefficients flipping signs. By definition this entails that in the transition between one directional sign and the other, the respective coefficient has to cross through the zero barrier (the horizontal line in the graph defining zero). And, at such time the coefficient has to be very close to zero.
This actually leads to another major point. Ridge regression may not be nearly as robust as many people think. When you look at ridge regression coefficient paths, you will most often observe the most influential coefficients (with the highest standardized regression coefficients) being shrunk the most. And, that is a direct function of the ridge regression penalizing algorithm that shrinks the sum of squared regression coefficients. As mentioned, even worse is when Ridge regression causes a shift in the directional sign of your variable coefficients. Thus, you may be starting with a model that has much explanatory power supported by logic and economic theory. And, after you regularize it using Ridge regression (or Lasso and Elastic-net), you have a model that has nothing left from your original explanatory power, logic, etc. That is just something to watch out for with all regularization models.
|
Is there any special case where ridge regression can shrink coefficients to zero?
|
I think it can, and it does it actually very frequently (shrink some coefficient near zero). If you do an internet search for "images" and search for "ridge regression coefficient path" you will see
|
Is there any special case where ridge regression can shrink coefficients to zero?
I think it can, and it does it actually very frequently (shrink some coefficient near zero). If you do an internet search for "images" and search for "ridge regression coefficient path" you will see the visual output of a large quantity of ridge regression models and their respective coefficient path output.
What you will notice is that very frequently some of the variable coefficients paths show actual coefficients flipping signs. By definition this entails that in the transition between one directional sign and the other, the respective coefficient has to cross through the zero barrier (the horizontal line in the graph defining zero). And, at such time the coefficient has to be very close to zero.
This actually leads to another major point. Ridge regression may not be nearly as robust as many people think. When you look at ridge regression coefficient paths, you will most often observe the most influential coefficients (with the highest standardized regression coefficients) being shrunk the most. And, that is a direct function of the ridge regression penalizing algorithm that shrinks the sum of squared regression coefficients. As mentioned, even worse is when Ridge regression causes a shift in the directional sign of your variable coefficients. Thus, you may be starting with a model that has much explanatory power supported by logic and economic theory. And, after you regularize it using Ridge regression (or Lasso and Elastic-net), you have a model that has nothing left from your original explanatory power, logic, etc. That is just something to watch out for with all regularization models.
|
Is there any special case where ridge regression can shrink coefficients to zero?
I think it can, and it does it actually very frequently (shrink some coefficient near zero). If you do an internet search for "images" and search for "ridge regression coefficient path" you will see
|
44,478
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
|
It does not use a separate training and testing set. Instead, standard accuracy estimation in random forests takes advantage of an important feature: bagging, or bootstrap aggregation.
To construct a random forest, a large number of data subsets are generated by sampling with replacement from the full dataset. A separate decision tree is fit to each bootstrap data subset, the trees jointly forming the random forest. Each data point from the full dataset is present in approximately 2/3 of the bootstrap data subsets, and absent from the remaining 1/3. You can therefore use the 1/3 of trees that do not contain a point to predict what their value would be; these are called out-of-bag (OOB) estimates. This process avoids the overfitting problem (and arguably makes crossvalidation redundant for this purpose) since the points were not present in the trees used to predict them. By repeating this for every point in the full dataset and comparing the OOB predictions against the true values, you can calculate the accuracy of the random forest.
The mean decrease in accuracy metric (generally recommended) for a variable is calculated by permuting the values of this variable across the entire dataset and estimating how the accuracy of the random forest changes.
The mean decrease in Gini metric is explained this way by Breiman & Cutler (which I took from this helpful answer):
Every time a split of a node is made on variable m the gini impurity
criterion for the two descendent nodes is less than the parent node.
Adding up the gini decreases for each individual variable over all
trees in the forest gives a fast variable importance that is often
very consistent with the permutation importance measure.
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
|
It does not use a separate training and testing set. Instead, standard accuracy estimation in random forests takes advantage of an important feature: bagging, or bootstrap aggregation.
To construct a
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
It does not use a separate training and testing set. Instead, standard accuracy estimation in random forests takes advantage of an important feature: bagging, or bootstrap aggregation.
To construct a random forest, a large number of data subsets are generated by sampling with replacement from the full dataset. A separate decision tree is fit to each bootstrap data subset, the trees jointly forming the random forest. Each data point from the full dataset is present in approximately 2/3 of the bootstrap data subsets, and absent from the remaining 1/3. You can therefore use the 1/3 of trees that do not contain a point to predict what their value would be; these are called out-of-bag (OOB) estimates. This process avoids the overfitting problem (and arguably makes crossvalidation redundant for this purpose) since the points were not present in the trees used to predict them. By repeating this for every point in the full dataset and comparing the OOB predictions against the true values, you can calculate the accuracy of the random forest.
The mean decrease in accuracy metric (generally recommended) for a variable is calculated by permuting the values of this variable across the entire dataset and estimating how the accuracy of the random forest changes.
The mean decrease in Gini metric is explained this way by Breiman & Cutler (which I took from this helpful answer):
Every time a split of a node is made on variable m the gini impurity
criterion for the two descendent nodes is less than the parent node.
Adding up the gini decreases for each individual variable over all
trees in the forest gives a fast variable importance that is often
very consistent with the permutation importance measure.
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
It does not use a separate training and testing set. Instead, standard accuracy estimation in random forests takes advantage of an important feature: bagging, or bootstrap aggregation.
To construct a
|
44,479
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
|
In order to calculate mean decrease in accuracy randomForest doesn't use train and test sets per se it uses something called the out of bag sample. Since each tree is built using a bootstrap sample (a sample of the same size as your dataset sampled with replacement) there will be records that are in your dataset that are not used to build the tree, these records are called the out of bag (OOB) sample. You run these records down the tree and calculate their accuracy (you could think of the OOB records as your test set). In order to determine the mean decrease in accuracy you randomly permute one of the explanatory variables in your OOB sample and then rerun the OOB sample down the tree and recalculate the accuracy, the decrease you see in the accuracy is what the importance measure refers to.
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
|
In order to calculate mean decrease in accuracy randomForest doesn't use train and test sets per se it uses something called the out of bag sample. Since each tree is built using a bootstrap sample (
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
In order to calculate mean decrease in accuracy randomForest doesn't use train and test sets per se it uses something called the out of bag sample. Since each tree is built using a bootstrap sample (a sample of the same size as your dataset sampled with replacement) there will be records that are in your dataset that are not used to build the tree, these records are called the out of bag (OOB) sample. You run these records down the tree and calculate their accuracy (you could think of the OOB records as your test set). In order to determine the mean decrease in accuracy you randomly permute one of the explanatory variables in your OOB sample and then rerun the OOB sample down the tree and recalculate the accuracy, the decrease you see in the accuracy is what the importance measure refers to.
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
In order to calculate mean decrease in accuracy randomForest doesn't use train and test sets per se it uses something called the out of bag sample. Since each tree is built using a bootstrap sample (
|
44,480
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
|
If you want to have a more detailed description you can read the Wikipedia article that answers your questions:
https://en.wikipedia.org/wiki/Random_forest
and this post:
this is a nice post for a more detailed explanation:
https://www.quora.com/What-is-the-out-of-bag-error-in-random-forests-What-does-it-mean-Whats-a-typical-value-if-any-Why-would-it-be-higher-or-lower-than-a-typical-value
But in short and just to start you up:
1) the random forest algorithm generates a set of decision trees
2) each tree is trained on a different, randomly chosen subset of the data (ca. 2/3) and using a different, randomly chosen subset of the features. so each decision tree in the random forest has a different test and training sets (answers your second question)
3) for each element X_i of the data you can then compute an out of bag error (OOB error). briefly you consider all the trees in the RF that are trained on a set not containing X_i. you compute an OOB error counting the percentage of those trees that fail classifying X_i. averaging this error on all data you get the OOB. Accuracy = 1-OOB
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
|
If you want to have a more detailed description you can read the Wikipedia article that answers your questions:
https://en.wikipedia.org/wiki/Random_forest
and this post:
this is a nice post for a mor
|
In the R randomForest package for random forest feature selection, how is the dataset split for training and testing?
If you want to have a more detailed description you can read the Wikipedia article that answers your questions:
https://en.wikipedia.org/wiki/Random_forest
and this post:
this is a nice post for a more detailed explanation:
https://www.quora.com/What-is-the-out-of-bag-error-in-random-forests-What-does-it-mean-Whats-a-typical-value-if-any-Why-would-it-be-higher-or-lower-than-a-typical-value
But in short and just to start you up:
1) the random forest algorithm generates a set of decision trees
2) each tree is trained on a different, randomly chosen subset of the data (ca. 2/3) and using a different, randomly chosen subset of the features. so each decision tree in the random forest has a different test and training sets (answers your second question)
3) for each element X_i of the data you can then compute an out of bag error (OOB error). briefly you consider all the trees in the RF that are trained on a set not containing X_i. you compute an OOB error counting the percentage of those trees that fail classifying X_i. averaging this error on all data you get the OOB. Accuracy = 1-OOB
|
In the R randomForest package for random forest feature selection, how is the dataset split for trai
If you want to have a more detailed description you can read the Wikipedia article that answers your questions:
https://en.wikipedia.org/wiki/Random_forest
and this post:
this is a nice post for a mor
|
44,481
|
Why is it called standard “error” and not standard “uncertainty”?
|
The question "why is this term used, rather than this other term" is, like much terminology, a matter of historical happenstance. Sometimes the outcome is felicitous and sometimes less so. I think that with a little context it makes reasonable sense in this case.
Yule used it in 1897$^{[1]}$, in the context of a particular phrase that I think makes its intent pretty clear:
"We see that $\sigma_1\sqrt{1 - r^2}$ is the standard error made in estimating $x$"
[This is in turn quoted in the Oxford English Dictionary and is mentioned in the Standard Error entry (by John Aldrich) in $[2]$.]
Here it is with a little context (NB the journal is long out of copyright):
Yule later extended that use to estimating other quantities.
I think "the standard error-made-in-estimating" a quantity is clear enough, and once the origin is clear, the shorthand standard error isn't so obscure.
I'm not sure "uncertainty" would not be subject to similar issues (the technical meaning differing from the ordinary meaning); uncertainty might easily be interpreted as hesitation, for example. Whatever word we use we still have to make the actual technical meaning clear.
Of course, like the term or not, once people start to treat such a term as conventional, like the QWERTY keyboard, it's entrenched; you're pretty much stuck with it.
$[1]$ Yule, G.U. (1897), "On the Theory of Correlation," Journal of the Royal Statistical Society, 60, 812-854
$[2]$ Miller, J. "Earliest Known Uses of Some of the Words of Mathematics".
http://jeff560.tripod.com/s.html
(alternate: https://mathshistory.st-andrews.ac.uk/Miller/mathword/s/)
|
Why is it called standard “error” and not standard “uncertainty”?
|
The question "why is this term used, rather than this other term" is, like much terminology, a matter of historical happenstance. Sometimes the outcome is felicitous and sometimes less so. I think tha
|
Why is it called standard “error” and not standard “uncertainty”?
The question "why is this term used, rather than this other term" is, like much terminology, a matter of historical happenstance. Sometimes the outcome is felicitous and sometimes less so. I think that with a little context it makes reasonable sense in this case.
Yule used it in 1897$^{[1]}$, in the context of a particular phrase that I think makes its intent pretty clear:
"We see that $\sigma_1\sqrt{1 - r^2}$ is the standard error made in estimating $x$"
[This is in turn quoted in the Oxford English Dictionary and is mentioned in the Standard Error entry (by John Aldrich) in $[2]$.]
Here it is with a little context (NB the journal is long out of copyright):
Yule later extended that use to estimating other quantities.
I think "the standard error-made-in-estimating" a quantity is clear enough, and once the origin is clear, the shorthand standard error isn't so obscure.
I'm not sure "uncertainty" would not be subject to similar issues (the technical meaning differing from the ordinary meaning); uncertainty might easily be interpreted as hesitation, for example. Whatever word we use we still have to make the actual technical meaning clear.
Of course, like the term or not, once people start to treat such a term as conventional, like the QWERTY keyboard, it's entrenched; you're pretty much stuck with it.
$[1]$ Yule, G.U. (1897), "On the Theory of Correlation," Journal of the Royal Statistical Society, 60, 812-854
$[2]$ Miller, J. "Earliest Known Uses of Some of the Words of Mathematics".
http://jeff560.tripod.com/s.html
(alternate: https://mathshistory.st-andrews.ac.uk/Miller/mathword/s/)
|
Why is it called standard “error” and not standard “uncertainty”?
The question "why is this term used, rather than this other term" is, like much terminology, a matter of historical happenstance. Sometimes the outcome is felicitous and sometimes less so. I think tha
|
44,482
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
|
Loss is a negative utility. If you need an authoritative source for this, check the Statistical Decision Theory book by James O. Berger (p. 53):
Once $U(\theta, a)$ has been obtained, the loss function can simply be
defined as
$$ L(\theta, a) = -U(\theta, a). \tag{2.3} $$
The same is stated by Christian P. Robert in his book The Bayesian Choice, who introduces utility with the following notion (p. 54):
The notion of utility (defined as the opposite of loss) is used not
only in Statistics, but also in Economics and in other fields like
Game Theory where it is necessary to order consequences of actions or
decisions. Consequences (or rewards) are generic notions which
summarize the set of outcomes resulting from the decision-maker’s
action. In the simplest cases, it may be the monetary profit or loss
resulting from the decision. (...)
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
|
Loss is a negative utility. If you need an authoritative source for this, check the Statistical Decision Theory book by James O. Berger (p. 53):
Once $U(\theta, a)$ has been obtained, the loss functi
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
Loss is a negative utility. If you need an authoritative source for this, check the Statistical Decision Theory book by James O. Berger (p. 53):
Once $U(\theta, a)$ has been obtained, the loss function can simply be
defined as
$$ L(\theta, a) = -U(\theta, a). \tag{2.3} $$
The same is stated by Christian P. Robert in his book The Bayesian Choice, who introduces utility with the following notion (p. 54):
The notion of utility (defined as the opposite of loss) is used not
only in Statistics, but also in Economics and in other fields like
Game Theory where it is necessary to order consequences of actions or
decisions. Consequences (or rewards) are generic notions which
summarize the set of outcomes resulting from the decision-maker’s
action. In the simplest cases, it may be the monetary profit or loss
resulting from the decision. (...)
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
Loss is a negative utility. If you need an authoritative source for this, check the Statistical Decision Theory book by James O. Berger (p. 53):
Once $U(\theta, a)$ has been obtained, the loss functi
|
44,483
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
|
$U(x)=-\mathcal{L}(x)$. I cannot imagine you will find anything on the internet. I believe you can find a formal treatment of these functions in Geweke's "Contemporary Bayesian Econometrics and Statistics."
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
|
$U(x)=-\mathcal{L}(x)$. I cannot imagine you will find anything on the internet. I believe you can find a formal treatment of these functions in Geweke's "Contemporary Bayesian Econometrics and Stat
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
$U(x)=-\mathcal{L}(x)$. I cannot imagine you will find anything on the internet. I believe you can find a formal treatment of these functions in Geweke's "Contemporary Bayesian Econometrics and Statistics."
|
Is a loss function the flip side of a coin to a utility function, or are they not related?
$U(x)=-\mathcal{L}(x)$. I cannot imagine you will find anything on the internet. I believe you can find a formal treatment of these functions in Geweke's "Contemporary Bayesian Econometrics and Stat
|
44,484
|
R caret Naive Bayes (untuned) results differ from klaR
|
The problem lies in the fact that you use a different specification in the models.
In fit1 and fit2 you use the x and y combination, in fit3 the formula notation
If you switch all models in the formula notation (type ~ ., data = spam) you will see an Accuracy of 0.7135
If you switch all models in the x / y notation (spam, spam$type) you will see an Accuracy of 0.7266
There is probably someone who can explain why exactly this difference occurs. I have no idea except that it has something to do in the difference of how the S3 formula notation is processed versus the default notation of x and y.
|
R caret Naive Bayes (untuned) results differ from klaR
|
The problem lies in the fact that you use a different specification in the models.
In fit1 and fit2 you use the x and y combination, in fit3 the formula notation
If you switch all models in the formul
|
R caret Naive Bayes (untuned) results differ from klaR
The problem lies in the fact that you use a different specification in the models.
In fit1 and fit2 you use the x and y combination, in fit3 the formula notation
If you switch all models in the formula notation (type ~ ., data = spam) you will see an Accuracy of 0.7135
If you switch all models in the x / y notation (spam, spam$type) you will see an Accuracy of 0.7266
There is probably someone who can explain why exactly this difference occurs. I have no idea except that it has something to do in the difference of how the S3 formula notation is processed versus the default notation of x and y.
|
R caret Naive Bayes (untuned) results differ from klaR
The problem lies in the fact that you use a different specification in the models.
In fit1 and fit2 you use the x and y combination, in fit3 the formula notation
If you switch all models in the formul
|
44,485
|
R caret Naive Bayes (untuned) results differ from klaR
|
From my knowledge, for the first two models, you shouldn't be giving the whole spam data frame as the training variables (the class labels are considered as a feature in this case). Instead, you should use:
fit1 <- naiveBayes(spam[,-58], spam$type, type="raw")
this way it will produce the same results with (type ~., data=spam).
|
R caret Naive Bayes (untuned) results differ from klaR
|
From my knowledge, for the first two models, you shouldn't be giving the whole spam data frame as the training variables (the class labels are considered as a feature in this case). Instead, you shoul
|
R caret Naive Bayes (untuned) results differ from klaR
From my knowledge, for the first two models, you shouldn't be giving the whole spam data frame as the training variables (the class labels are considered as a feature in this case). Instead, you should use:
fit1 <- naiveBayes(spam[,-58], spam$type, type="raw")
this way it will produce the same results with (type ~., data=spam).
|
R caret Naive Bayes (untuned) results differ from klaR
From my knowledge, for the first two models, you shouldn't be giving the whole spam data frame as the training variables (the class labels are considered as a feature in this case). Instead, you shoul
|
44,486
|
R caret Naive Bayes (untuned) results differ from klaR
|
The difference is whether x includes the full matrix including class variable, or whether y is specifically excluded from x.
# y included in x -> Accuracy : 0.7266
fit3 <- train(
x=spam,
y=spam$type,
method = "nb",
trControl = trainControl(method="none"),
tuneGrid = data.frame(usekernel=FALSE,fL=0,adjust=FALSE))
pred3 <- predict(fit3, spam, type="raw")
#Warnings that probability is 0 for some cases
confusionMatrix(pred3, spam$type)
#Accuracy : 0.7266
is different to:
# y excluded from x -> #Accuracy : 0.7135
fit3 <- train(
x=spam[,-dim(spam)[2]],
y=spam$type,
method = "nb",
trControl = trainControl(method="none"),
tuneGrid = data.frame(usekernel=FALSE,fL=0,adjust=FALSE))
pred3 <- predict(fit3, spam, type="raw")
#Warnings that probability is 0 for some cases
confusionMatrix(pred3, spam$type)
#Accuracy : 0.7135
|
R caret Naive Bayes (untuned) results differ from klaR
|
The difference is whether x includes the full matrix including class variable, or whether y is specifically excluded from x.
# y included in x -> Accuracy : 0.7266
fit3 <- train(
x=spam,
y=spam
|
R caret Naive Bayes (untuned) results differ from klaR
The difference is whether x includes the full matrix including class variable, or whether y is specifically excluded from x.
# y included in x -> Accuracy : 0.7266
fit3 <- train(
x=spam,
y=spam$type,
method = "nb",
trControl = trainControl(method="none"),
tuneGrid = data.frame(usekernel=FALSE,fL=0,adjust=FALSE))
pred3 <- predict(fit3, spam, type="raw")
#Warnings that probability is 0 for some cases
confusionMatrix(pred3, spam$type)
#Accuracy : 0.7266
is different to:
# y excluded from x -> #Accuracy : 0.7135
fit3 <- train(
x=spam[,-dim(spam)[2]],
y=spam$type,
method = "nb",
trControl = trainControl(method="none"),
tuneGrid = data.frame(usekernel=FALSE,fL=0,adjust=FALSE))
pred3 <- predict(fit3, spam, type="raw")
#Warnings that probability is 0 for some cases
confusionMatrix(pred3, spam$type)
#Accuracy : 0.7135
|
R caret Naive Bayes (untuned) results differ from klaR
The difference is whether x includes the full matrix including class variable, or whether y is specifically excluded from x.
# y included in x -> Accuracy : 0.7266
fit3 <- train(
x=spam,
y=spam
|
44,487
|
Interpretation of bs(x) and gam Results
|
bs stands for basis spline. A complete understanding takes a bit of a digression into linear algebra.
First, a natural cubic spline is a very specific, rather rigid, species of curve. natural cubic splines come equipped with a collection of knots $x_1, x_2, \ldots, x_n$, and the definition is as follows.
To the left of the sequence of knots, a natural cubic spline is a line.
Between knots, a natural cubic spline is a third degree polynomial curve. Hence the cubic in the name.
At the knots, the curve must be continuous. At the knots, the derivative also must be continuous (no corner). At the knots, the second derivative must be continuous.
Here's a picture of a natural cubic spline:
Ok, now here's the first answer: including bs in a formula fits a natural cubic spline to your data. It can either:
Use every one of your data points as a potential knot.
Determine a sequence of knots with some heuristic, percentiles of the distribution of whatnot.
The fist case may seem insane, and inviting trouble, but there are good theoretical reasons to justify it. In the case you do not specify a degrees of freedom directly, it is possible to determine a "best" answer with cross validation strategies. Leave-one-out cross validation has an especially appealing form for splines (the optimal value can be determined in linear time).
How does the fitting happen? Well, it turns out that the collection of natural cubic splines with a specified set of knots is a vector space. That is, you can add two splines together, or scale a single spline, and what you get back is a spline. This vector space is finite dimensional (convincing yourself of this is a good way to test your understanding). Hence, the set of splines has a basis. Here's a picture of a basis of a space of splines with knots as $.1, .2, \ldots, .9$:
Once you have a basis $s_i$, any other specific spline can be written as a linear combination of the splines in the basis:
$$ s = \sum_i^n \alpha_i s_i $$
So fitting a spline to data goes from finding the best approximating curve from the collection of splines, to finding the values of $\alpha$ that, when combined with a fixed basis, result in a sum spline that best approximates your data.
So when you include bs in a model formula the following happens:
Depending on the model you're fitting, and the parameters you passed to bs, R chooses a set of knots, and a basis for the collection of splines with that set of knots.
R takes all the points in your data set, and feeds them into the basis of splines it chose. You can see this with model.matrix:
$ dd <- data.frame(x = c(0, 1, 2, 3, 4, 5))
$ model.matrix(~ bs(x, 2), data=dd)
(Intercept) bs(x, 2)1 bs(x, 2)2 bs(x, 2)3
1 1 0.000 0.000 0.000
2 1 0.384 0.096 0.008
3 1 0.432 0.288 0.064
4 1 0.288 0.432 0.216
5 1 0.096 0.384 0.512
6 1 0.000 0.000 1.000
R uses the resulting vectors as predictors in your model.
So to predict with the model, you ned to know what specific set of knots R chose and what specific basis it chose for the splines at those knots. You should be able to look a the documentation of either bs or gam to determine this information in any specific case.
|
Interpretation of bs(x) and gam Results
|
bs stands for basis spline. A complete understanding takes a bit of a digression into linear algebra.
First, a natural cubic spline is a very specific, rather rigid, species of curve. natural cubic
|
Interpretation of bs(x) and gam Results
bs stands for basis spline. A complete understanding takes a bit of a digression into linear algebra.
First, a natural cubic spline is a very specific, rather rigid, species of curve. natural cubic splines come equipped with a collection of knots $x_1, x_2, \ldots, x_n$, and the definition is as follows.
To the left of the sequence of knots, a natural cubic spline is a line.
Between knots, a natural cubic spline is a third degree polynomial curve. Hence the cubic in the name.
At the knots, the curve must be continuous. At the knots, the derivative also must be continuous (no corner). At the knots, the second derivative must be continuous.
Here's a picture of a natural cubic spline:
Ok, now here's the first answer: including bs in a formula fits a natural cubic spline to your data. It can either:
Use every one of your data points as a potential knot.
Determine a sequence of knots with some heuristic, percentiles of the distribution of whatnot.
The fist case may seem insane, and inviting trouble, but there are good theoretical reasons to justify it. In the case you do not specify a degrees of freedom directly, it is possible to determine a "best" answer with cross validation strategies. Leave-one-out cross validation has an especially appealing form for splines (the optimal value can be determined in linear time).
How does the fitting happen? Well, it turns out that the collection of natural cubic splines with a specified set of knots is a vector space. That is, you can add two splines together, or scale a single spline, and what you get back is a spline. This vector space is finite dimensional (convincing yourself of this is a good way to test your understanding). Hence, the set of splines has a basis. Here's a picture of a basis of a space of splines with knots as $.1, .2, \ldots, .9$:
Once you have a basis $s_i$, any other specific spline can be written as a linear combination of the splines in the basis:
$$ s = \sum_i^n \alpha_i s_i $$
So fitting a spline to data goes from finding the best approximating curve from the collection of splines, to finding the values of $\alpha$ that, when combined with a fixed basis, result in a sum spline that best approximates your data.
So when you include bs in a model formula the following happens:
Depending on the model you're fitting, and the parameters you passed to bs, R chooses a set of knots, and a basis for the collection of splines with that set of knots.
R takes all the points in your data set, and feeds them into the basis of splines it chose. You can see this with model.matrix:
$ dd <- data.frame(x = c(0, 1, 2, 3, 4, 5))
$ model.matrix(~ bs(x, 2), data=dd)
(Intercept) bs(x, 2)1 bs(x, 2)2 bs(x, 2)3
1 1 0.000 0.000 0.000
2 1 0.384 0.096 0.008
3 1 0.432 0.288 0.064
4 1 0.288 0.432 0.216
5 1 0.096 0.384 0.512
6 1 0.000 0.000 1.000
R uses the resulting vectors as predictors in your model.
So to predict with the model, you ned to know what specific set of knots R chose and what specific basis it chose for the splines at those knots. You should be able to look a the documentation of either bs or gam to determine this information in any specific case.
|
Interpretation of bs(x) and gam Results
bs stands for basis spline. A complete understanding takes a bit of a digression into linear algebra.
First, a natural cubic spline is a very specific, rather rigid, species of curve. natural cubic
|
44,488
|
Why do degrees of freedom impact statistical power?
|
In the Anderson and Rubin Statistic case you compute the test statistic directly from the model without using an estimator: your assumption is that at $\beta=\beta_0$ you have $\mathbb{E}\left( Z^\prime[Y-X\beta]\right)=0$. For each instrument $z_k$ you have a central limit theorem (CLT) $\sqrt{n}(\frac{1}{n}\sum_iz_{k,i}(y_i-x_i^\prime\beta_0))\overset{d}{\to} \mathcal{N}(0,\sigma^2_k)$. Stacking all the moments together you get a vector CLT: $\sqrt{n}(Z^\prime(Y-X\beta_0)/N)\overset{d}{\to} \mathcal{N}(0,V)$ where $V=var(\varepsilon_i Z_i)$. You can transform the normal vector into a $\chi^2$ distribution as follow:
$AR(\beta_0)=n(Z^\prime(Y-X\beta_0)/N)^\prime V^{-1} (Z^\prime(Y-X\beta_0)/N) \overset{d}{\to} \chi^2_{K}$.
This is the Anderson-Rubin test where $K$ the degrees of freedom is also the number of instruments. The more instruments you have, the larger $K$ and the larger the critical values for the $\chi^2$ distribution will be. Hence it becomes harder to reject when K is large. If your data is homoskedastic, then you can do a susbset test which is dominated by a $\chi^2$ with fewer degrees of freedom but this does not work in the heteroskedastic case if the parameters not in the subset are weakly identified... There is a long litterature on this, I think this summarizes the issue well: http://economics.mit.edu/files/9890
|
Why do degrees of freedom impact statistical power?
|
In the Anderson and Rubin Statistic case you compute the test statistic directly from the model without using an estimator: your assumption is that at $\beta=\beta_0$ you have $\mathbb{E}\left( Z^\pri
|
Why do degrees of freedom impact statistical power?
In the Anderson and Rubin Statistic case you compute the test statistic directly from the model without using an estimator: your assumption is that at $\beta=\beta_0$ you have $\mathbb{E}\left( Z^\prime[Y-X\beta]\right)=0$. For each instrument $z_k$ you have a central limit theorem (CLT) $\sqrt{n}(\frac{1}{n}\sum_iz_{k,i}(y_i-x_i^\prime\beta_0))\overset{d}{\to} \mathcal{N}(0,\sigma^2_k)$. Stacking all the moments together you get a vector CLT: $\sqrt{n}(Z^\prime(Y-X\beta_0)/N)\overset{d}{\to} \mathcal{N}(0,V)$ where $V=var(\varepsilon_i Z_i)$. You can transform the normal vector into a $\chi^2$ distribution as follow:
$AR(\beta_0)=n(Z^\prime(Y-X\beta_0)/N)^\prime V^{-1} (Z^\prime(Y-X\beta_0)/N) \overset{d}{\to} \chi^2_{K}$.
This is the Anderson-Rubin test where $K$ the degrees of freedom is also the number of instruments. The more instruments you have, the larger $K$ and the larger the critical values for the $\chi^2$ distribution will be. Hence it becomes harder to reject when K is large. If your data is homoskedastic, then you can do a susbset test which is dominated by a $\chi^2$ with fewer degrees of freedom but this does not work in the heteroskedastic case if the parameters not in the subset are weakly identified... There is a long litterature on this, I think this summarizes the issue well: http://economics.mit.edu/files/9890
|
Why do degrees of freedom impact statistical power?
In the Anderson and Rubin Statistic case you compute the test statistic directly from the model without using an estimator: your assumption is that at $\beta=\beta_0$ you have $\mathbb{E}\left( Z^\pri
|
44,489
|
Why do degrees of freedom impact statistical power?
|
In regression there are two kinds of degrees of freedom. As described well below, the denominator or error or residual d.f. is relevant to regression models that have residuals and residual variance. As shown above, this is strongly a function of the sample size, and the more the merrier. On the other hand, numerator d.f. (terminology comes from what's in the numerator of an $F$-test) is the number of free location/regression parameters. When a hypothesis test is conducted, the numerator d.f. is the number of regression parameters that uniquely define the hypothesis. It is the number of restrictions on the parameters.
Take two cases: a categorical variable having 4 levels and quadratic regression. The former has 3 parameters and the latter 2. Adding more categories or more powers of $x$ adds parameters and d.f. for hypothesis tests. Adding numerator d.f. is a good thing if the model has better fit so that the added parameters explain more variation in $Y$. It can be a bad thing if the added parameters don't explain enough extra $Y$ variation to make up for the fact that the critical value for a test statistic becomes more stringent as the numerator d.f. goes up. This happens in order to account for the extra chances you have to find an association. This is easy to see for $\chi^2$ tests where the critical value of the $\chi^2$ distribution keeps going up as (numerator) d.f. go up.
So what the conference speaker said about power being hurt is correct if you compared a low d.f. test with a higher d.f. test and the two versions of the model explained the same amount of variation in $Y$.
It is very important to know that if you ever gave the model "chances" to find associations, those chances must be encapsulated by having the right d.f. in the statistical test. It is not appropriate to excluded unimpressive terms from the model just to lower the d.f.
|
Why do degrees of freedom impact statistical power?
|
In regression there are two kinds of degrees of freedom. As described well below, the denominator or error or residual d.f. is relevant to regression models that have residuals and residual variance.
|
Why do degrees of freedom impact statistical power?
In regression there are two kinds of degrees of freedom. As described well below, the denominator or error or residual d.f. is relevant to regression models that have residuals and residual variance. As shown above, this is strongly a function of the sample size, and the more the merrier. On the other hand, numerator d.f. (terminology comes from what's in the numerator of an $F$-test) is the number of free location/regression parameters. When a hypothesis test is conducted, the numerator d.f. is the number of regression parameters that uniquely define the hypothesis. It is the number of restrictions on the parameters.
Take two cases: a categorical variable having 4 levels and quadratic regression. The former has 3 parameters and the latter 2. Adding more categories or more powers of $x$ adds parameters and d.f. for hypothesis tests. Adding numerator d.f. is a good thing if the model has better fit so that the added parameters explain more variation in $Y$. It can be a bad thing if the added parameters don't explain enough extra $Y$ variation to make up for the fact that the critical value for a test statistic becomes more stringent as the numerator d.f. goes up. This happens in order to account for the extra chances you have to find an association. This is easy to see for $\chi^2$ tests where the critical value of the $\chi^2$ distribution keeps going up as (numerator) d.f. go up.
So what the conference speaker said about power being hurt is correct if you compared a low d.f. test with a higher d.f. test and the two versions of the model explained the same amount of variation in $Y$.
It is very important to know that if you ever gave the model "chances" to find associations, those chances must be encapsulated by having the right d.f. in the statistical test. It is not appropriate to excluded unimpressive terms from the model just to lower the d.f.
|
Why do degrees of freedom impact statistical power?
In regression there are two kinds of degrees of freedom. As described well below, the denominator or error or residual d.f. is relevant to regression models that have residuals and residual variance.
|
44,490
|
Why do degrees of freedom impact statistical power?
|
Definition & Overview
Degrees of freedom is the number of values that are free to vary when when the value of some statistic, like $\bar{X}$ or $\hat{\sigma}^2$, is known. In other words, it is the number of values that need to be known in order to know all of the values.
Sometimes, such as in the $t$-distribution, degrees of freedom are a parameter of distribution just as mean and variance are parameters of the normal distribution. The degrees of freedom needs to be known in order to uniquely specify the $t$-distribution you are referring to.
Example with $\bar{X}$
As a very simple example, consider $\bar{X}$ with a sample size of $n$. If you know the values $X_1, X_2,..., X_{n-1}$ then you also know the value of $X_n$. So, we say that $\bar{X}$ has $n-1$ degrees of freedom.
$$X_n = n(\bar{X}) - \sum\limits_{i=1}^{n-1} X_i$$
Example with Simple Linear Regression
As a slightly more difficult example, consider the simple linear model $Y_i =\alpha+ \beta x_i + \epsilon_i$ for $i=1,...,n$. Recall the following two identities in linear regression
$$e_1 + e_2 + ... + e_n = 0$$
$$x_1e_1 + x_2e_2 + ... + x_ne_n = 0$$
where the residuals $e_i = \hat{Y}_i - Y_i$. Notice, if we know $e_1,..., e_{n-2}$ but $e_{n-1}$ and $e_n$ are unknown then the above identities give us two equations with two unknowns. Since the number of equations and the number of unknowns is the same, we can solve for $e_{n-1}$ and $e_n$. So, knowing the $n-2$ values $e_1,..., e_{n-2}$ allows us to know all of the values $e_1,...,e_n$ and so the residuals have $n-2$ degrees of freedom.
This can be easily generalized to a multiple linear regression situation with $p$ variables if one recalls that $X^Te = 0$.
Does this Cause a Problem?
If $p$ is close to $n$ we do not have much freedom in the estimates of our fitted values of $\hat{Y}_i$. This is because if we know $e_1,...,e_p$ we also will know $\hat{Y}_1,...,\hat{Y}_p$.
|
Why do degrees of freedom impact statistical power?
|
Definition & Overview
Degrees of freedom is the number of values that are free to vary when when the value of some statistic, like $\bar{X}$ or $\hat{\sigma}^2$, is known. In other words, it is the n
|
Why do degrees of freedom impact statistical power?
Definition & Overview
Degrees of freedom is the number of values that are free to vary when when the value of some statistic, like $\bar{X}$ or $\hat{\sigma}^2$, is known. In other words, it is the number of values that need to be known in order to know all of the values.
Sometimes, such as in the $t$-distribution, degrees of freedom are a parameter of distribution just as mean and variance are parameters of the normal distribution. The degrees of freedom needs to be known in order to uniquely specify the $t$-distribution you are referring to.
Example with $\bar{X}$
As a very simple example, consider $\bar{X}$ with a sample size of $n$. If you know the values $X_1, X_2,..., X_{n-1}$ then you also know the value of $X_n$. So, we say that $\bar{X}$ has $n-1$ degrees of freedom.
$$X_n = n(\bar{X}) - \sum\limits_{i=1}^{n-1} X_i$$
Example with Simple Linear Regression
As a slightly more difficult example, consider the simple linear model $Y_i =\alpha+ \beta x_i + \epsilon_i$ for $i=1,...,n$. Recall the following two identities in linear regression
$$e_1 + e_2 + ... + e_n = 0$$
$$x_1e_1 + x_2e_2 + ... + x_ne_n = 0$$
where the residuals $e_i = \hat{Y}_i - Y_i$. Notice, if we know $e_1,..., e_{n-2}$ but $e_{n-1}$ and $e_n$ are unknown then the above identities give us two equations with two unknowns. Since the number of equations and the number of unknowns is the same, we can solve for $e_{n-1}$ and $e_n$. So, knowing the $n-2$ values $e_1,..., e_{n-2}$ allows us to know all of the values $e_1,...,e_n$ and so the residuals have $n-2$ degrees of freedom.
This can be easily generalized to a multiple linear regression situation with $p$ variables if one recalls that $X^Te = 0$.
Does this Cause a Problem?
If $p$ is close to $n$ we do not have much freedom in the estimates of our fitted values of $\hat{Y}_i$. This is because if we know $e_1,...,e_p$ we also will know $\hat{Y}_1,...,\hat{Y}_p$.
|
Why do degrees of freedom impact statistical power?
Definition & Overview
Degrees of freedom is the number of values that are free to vary when when the value of some statistic, like $\bar{X}$ or $\hat{\sigma}^2$, is known. In other words, it is the n
|
44,491
|
How do you interpret a significant but weak correlation?
|
More meaningful in this case is the $\text{R}^2$ which explains the proportion of variation in your observations accounted by the association. For example if your $R$ was 0.1 (p= 0.005) due to the large sample size, it means 1% of the variation in tail lesions in pigs is accounted for by abscesses. In a multifactorial situation such associations though informative may not be very meaningful. Again be cautious since correlation does not imply causation.
|
How do you interpret a significant but weak correlation?
|
More meaningful in this case is the $\text{R}^2$ which explains the proportion of variation in your observations accounted by the association. For example if your $R$ was 0.1 (p= 0.005) due to the lar
|
How do you interpret a significant but weak correlation?
More meaningful in this case is the $\text{R}^2$ which explains the proportion of variation in your observations accounted by the association. For example if your $R$ was 0.1 (p= 0.005) due to the large sample size, it means 1% of the variation in tail lesions in pigs is accounted for by abscesses. In a multifactorial situation such associations though informative may not be very meaningful. Again be cautious since correlation does not imply causation.
|
How do you interpret a significant but weak correlation?
More meaningful in this case is the $\text{R}^2$ which explains the proportion of variation in your observations accounted by the association. For example if your $R$ was 0.1 (p= 0.005) due to the lar
|
44,492
|
How do you interpret a significant but weak correlation?
|
You could say it like this:
The association is small, but not zero.
However, I don't know that I'd call a V of 0.288 "small".
Don't confuse "statistically significant" with important. Statistical significance is very different from practical importance.
|
How do you interpret a significant but weak correlation?
|
You could say it like this:
The association is small, but not zero.
However, I don't know that I'd call a V of 0.288 "small".
Don't confuse "statistically significant" with important. Statistical
|
How do you interpret a significant but weak correlation?
You could say it like this:
The association is small, but not zero.
However, I don't know that I'd call a V of 0.288 "small".
Don't confuse "statistically significant" with important. Statistical significance is very different from practical importance.
|
How do you interpret a significant but weak correlation?
You could say it like this:
The association is small, but not zero.
However, I don't know that I'd call a V of 0.288 "small".
Don't confuse "statistically significant" with important. Statistical
|
44,493
|
How do you interpret a significant but weak correlation?
|
Adding on to @Glen_b 's excellent answer and your comments there.
As he said, it is significant but weak because the sample size is large enough to make a small effect significant. But now you need a way of showing the effect size. V is one such way, but it isn't intuitive to many and is not as well known as some other measures.
From your question, it seems like you have a 2x2 table of lesions (yes/no) and abscess (yes/no). You could then show that table; you could give the odds ratio or any of a number of other measures for 2x2 tables.
|
How do you interpret a significant but weak correlation?
|
Adding on to @Glen_b 's excellent answer and your comments there.
As he said, it is significant but weak because the sample size is large enough to make a small effect significant. But now you need a
|
How do you interpret a significant but weak correlation?
Adding on to @Glen_b 's excellent answer and your comments there.
As he said, it is significant but weak because the sample size is large enough to make a small effect significant. But now you need a way of showing the effect size. V is one such way, but it isn't intuitive to many and is not as well known as some other measures.
From your question, it seems like you have a 2x2 table of lesions (yes/no) and abscess (yes/no). You could then show that table; you could give the odds ratio or any of a number of other measures for 2x2 tables.
|
How do you interpret a significant but weak correlation?
Adding on to @Glen_b 's excellent answer and your comments there.
As he said, it is significant but weak because the sample size is large enough to make a small effect significant. But now you need a
|
44,494
|
How do you interpret a significant but weak correlation?
|
I like to comment on the perceived usefulness of the relationship. For instance:
The association is statistically significant but not practically relevant.
That being said, your association doesn't seem to be that weak.
|
How do you interpret a significant but weak correlation?
|
I like to comment on the perceived usefulness of the relationship. For instance:
The association is statistically significant but not practically relevant.
That being said, your association doesn't
|
How do you interpret a significant but weak correlation?
I like to comment on the perceived usefulness of the relationship. For instance:
The association is statistically significant but not practically relevant.
That being said, your association doesn't seem to be that weak.
|
How do you interpret a significant but weak correlation?
I like to comment on the perceived usefulness of the relationship. For instance:
The association is statistically significant but not practically relevant.
That being said, your association doesn't
|
44,495
|
How to get Sub-Training and Sub-Test from cross validation in Caret
|
So using 10-fold CV will split the data into 10 different sets of roughly the same size. The model is fit on 90% and the remaining 10% is used to estimate accuracy. This process continues "round robin" 9 more times.
The accuracy is the average of the 10 holdouts for each tuning value. For example:
> set.seed(1)
> train_control <- trainControl(method="cv", number=10,
+ savePredictions = TRUE)
> output <- train(Species~., data=iris, trControl=train_control, method="rpart2")
note: only 2 possible values of the max tree depth from the initial fit.
Truncating the grid to 2 .
There is a sub-object that has the hold-out estimates of accuracy for each fold, and averaging these gets you the reported value (the ones shown here are for the optimal value of Cp):
> output$resample
Accuracy Kappa Resample
1 0.8666667 0.8 Fold01
2 0.9333333 0.9 Fold02
3 1.0000000 1.0 Fold03
4 0.9333333 0.9 Fold04
5 0.9333333 0.9 Fold05
6 0.8000000 0.7 Fold06
7 1.0000000 1.0 Fold07
8 1.0000000 1.0 Fold08
9 0.9333333 0.9 Fold09
10 0.9333333 0.9 Fold10
> mean(output$resample$Accuracy)
[1] 0.9333333
> getTrainPerf(output)
TrainAccuracy TrainKappa method
1 0.9333333 0.9 rpart2
There is little value in getting predictions on the 90% each time. Since the same data is used to build the model, the predictions can be extremely optimistic (which is the motivation for using cross-validation in the first place).
If you want to see where the estimates in output$resample were created:
> ## For the model associated with optimal Cp value, here is the predictions on the
> ## first fold that was held-out
> first_holdout <- subset(output$pred, Resample == "Fold01")
> head(first_holdout)
pred obs rowIndex maxdepth Resample
1 setosa setosa 6 2 Fold01
2 setosa setosa 27 2 Fold01
3 setosa setosa 31 2 Fold01
4 setosa setosa 36 2 Fold01
5 setosa setosa 45 2 Fold01
6 versicolor versicolor 67 2 Fold01
If we get the accuracy for this set:
> postResample(first_holdout$pred, first_holdout$obs)
Accuracy Kappa
0.7666667 0.6500000
Max
|
How to get Sub-Training and Sub-Test from cross validation in Caret
|
So using 10-fold CV will split the data into 10 different sets of roughly the same size. The model is fit on 90% and the remaining 10% is used to estimate accuracy. This process continues "round robin
|
How to get Sub-Training and Sub-Test from cross validation in Caret
So using 10-fold CV will split the data into 10 different sets of roughly the same size. The model is fit on 90% and the remaining 10% is used to estimate accuracy. This process continues "round robin" 9 more times.
The accuracy is the average of the 10 holdouts for each tuning value. For example:
> set.seed(1)
> train_control <- trainControl(method="cv", number=10,
+ savePredictions = TRUE)
> output <- train(Species~., data=iris, trControl=train_control, method="rpart2")
note: only 2 possible values of the max tree depth from the initial fit.
Truncating the grid to 2 .
There is a sub-object that has the hold-out estimates of accuracy for each fold, and averaging these gets you the reported value (the ones shown here are for the optimal value of Cp):
> output$resample
Accuracy Kappa Resample
1 0.8666667 0.8 Fold01
2 0.9333333 0.9 Fold02
3 1.0000000 1.0 Fold03
4 0.9333333 0.9 Fold04
5 0.9333333 0.9 Fold05
6 0.8000000 0.7 Fold06
7 1.0000000 1.0 Fold07
8 1.0000000 1.0 Fold08
9 0.9333333 0.9 Fold09
10 0.9333333 0.9 Fold10
> mean(output$resample$Accuracy)
[1] 0.9333333
> getTrainPerf(output)
TrainAccuracy TrainKappa method
1 0.9333333 0.9 rpart2
There is little value in getting predictions on the 90% each time. Since the same data is used to build the model, the predictions can be extremely optimistic (which is the motivation for using cross-validation in the first place).
If you want to see where the estimates in output$resample were created:
> ## For the model associated with optimal Cp value, here is the predictions on the
> ## first fold that was held-out
> first_holdout <- subset(output$pred, Resample == "Fold01")
> head(first_holdout)
pred obs rowIndex maxdepth Resample
1 setosa setosa 6 2 Fold01
2 setosa setosa 27 2 Fold01
3 setosa setosa 31 2 Fold01
4 setosa setosa 36 2 Fold01
5 setosa setosa 45 2 Fold01
6 versicolor versicolor 67 2 Fold01
If we get the accuracy for this set:
> postResample(first_holdout$pred, first_holdout$obs)
Accuracy Kappa
0.7666667 0.6500000
Max
|
How to get Sub-Training and Sub-Test from cross validation in Caret
So using 10-fold CV will split the data into 10 different sets of roughly the same size. The model is fit on 90% and the remaining 10% is used to estimate accuracy. This process continues "round robin
|
44,496
|
How to determine the confidence interval or significance of a covariance estimate
|
John's answer is correct. I will just try and explain it a bit more clearly.
The covariance, $\sigma(x, y)$, is given as: $$\sigma(x, y)=E[(x-\mu_x)(y-\mu_y)]$$ to consider if a value f the covariance is significantly different from zero first consider what are the limits on the covariance. The range of covariance possible is $$-\sigma(x)\sigma(y)\leq\sigma(x, y)\leq\sigma(x)\sigma(y)$$ $\sigma(x)$ & $\sigma(y)$ are the standard deviations of your datasets. You can prove this result using the Cauchy-Schwarz inequality.
In this case you can see it is hard to define what covariance is significant as the range of values depends on the variance of your datasets. The logical thing to do here is to normalise the covariance to remove this effect. If we define the correlation as $$\rho(x, y) = \frac{\sigma(x, y)}{\sigma(x)\sigma(y))} $$ this has a range $-1\leq\rho\leq1$. This makes it much easier to determine when the value is close to zero.
Obviously the exact value that you consider significant will depend on your exact setup and how much correlation you think you can ignore.
|
How to determine the confidence interval or significance of a covariance estimate
|
John's answer is correct. I will just try and explain it a bit more clearly.
The covariance, $\sigma(x, y)$, is given as: $$\sigma(x, y)=E[(x-\mu_x)(y-\mu_y)]$$ to consider if a value f the covariance
|
How to determine the confidence interval or significance of a covariance estimate
John's answer is correct. I will just try and explain it a bit more clearly.
The covariance, $\sigma(x, y)$, is given as: $$\sigma(x, y)=E[(x-\mu_x)(y-\mu_y)]$$ to consider if a value f the covariance is significantly different from zero first consider what are the limits on the covariance. The range of covariance possible is $$-\sigma(x)\sigma(y)\leq\sigma(x, y)\leq\sigma(x)\sigma(y)$$ $\sigma(x)$ & $\sigma(y)$ are the standard deviations of your datasets. You can prove this result using the Cauchy-Schwarz inequality.
In this case you can see it is hard to define what covariance is significant as the range of values depends on the variance of your datasets. The logical thing to do here is to normalise the covariance to remove this effect. If we define the correlation as $$\rho(x, y) = \frac{\sigma(x, y)}{\sigma(x)\sigma(y))} $$ this has a range $-1\leq\rho\leq1$. This makes it much easier to determine when the value is close to zero.
Obviously the exact value that you consider significant will depend on your exact setup and how much correlation you think you can ignore.
|
How to determine the confidence interval or significance of a covariance estimate
John's answer is correct. I will just try and explain it a bit more clearly.
The covariance, $\sigma(x, y)$, is given as: $$\sigma(x, y)=E[(x-\mu_x)(y-\mu_y)]$$ to consider if a value f the covariance
|
44,497
|
How to determine the confidence interval or significance of a covariance estimate
|
Correlation can be calculated as the covariance divided by the geometric mean variance. It's the proportion of covariance given the variance. Therefore, the correlation includes the covariance you want to assess in a standardized way and has known solutions for your questions. If there's an issue with the scaling of the correlation then another useful way of examining your relationship would be the regression coefficient which is equivalent to the correlation in the scale of whatever you make the response variable.
It's important to correct for the variance because the covariance is the sum of the products of how much each variable deviates from it's mean. Therefore, if either or both of your returns has high variance then the covariance will be a larger number even if the relationship between the numbers is unchanged. Therefore, you need to scale the covariance by the variance and that's what the correlation does for you.
|
How to determine the confidence interval or significance of a covariance estimate
|
Correlation can be calculated as the covariance divided by the geometric mean variance. It's the proportion of covariance given the variance. Therefore, the correlation includes the covariance you wan
|
How to determine the confidence interval or significance of a covariance estimate
Correlation can be calculated as the covariance divided by the geometric mean variance. It's the proportion of covariance given the variance. Therefore, the correlation includes the covariance you want to assess in a standardized way and has known solutions for your questions. If there's an issue with the scaling of the correlation then another useful way of examining your relationship would be the regression coefficient which is equivalent to the correlation in the scale of whatever you make the response variable.
It's important to correct for the variance because the covariance is the sum of the products of how much each variable deviates from it's mean. Therefore, if either or both of your returns has high variance then the covariance will be a larger number even if the relationship between the numbers is unchanged. Therefore, you need to scale the covariance by the variance and that's what the correlation does for you.
|
How to determine the confidence interval or significance of a covariance estimate
Correlation can be calculated as the covariance divided by the geometric mean variance. It's the proportion of covariance given the variance. Therefore, the correlation includes the covariance you wan
|
44,498
|
How to calculate log-normal parameters using the mean and std of the given distribution
|
Let m and s be the mean and sd of $X$ on the original scale. The appropriate mean and sd on the log scale can be found after a little algebra to be
$E(\log(X)) = \log(m) - \frac{1}{2} \log [ (s/m)^2 +1]$
$sd(\log(X)) = \sqrt{\log [(s/m)^2 +1]}$
|
How to calculate log-normal parameters using the mean and std of the given distribution
|
Let m and s be the mean and sd of $X$ on the original scale. The appropriate mean and sd on the log scale can be found after a little algebra to be
$E(\log(X)) = \log(m) - \frac{1}{2} \log [ (s/m)^2
|
How to calculate log-normal parameters using the mean and std of the given distribution
Let m and s be the mean and sd of $X$ on the original scale. The appropriate mean and sd on the log scale can be found after a little algebra to be
$E(\log(X)) = \log(m) - \frac{1}{2} \log [ (s/m)^2 +1]$
$sd(\log(X)) = \sqrt{\log [(s/m)^2 +1]}$
|
How to calculate log-normal parameters using the mean and std of the given distribution
Let m and s be the mean and sd of $X$ on the original scale. The appropriate mean and sd on the log scale can be found after a little algebra to be
$E(\log(X)) = \log(m) - \frac{1}{2} \log [ (s/m)^2
|
44,499
|
Probability that the square of a random integer ends in 1
|
In fact that answer is not sufficiently justified given the information in the question.
It depends on the distribution over the positive integers. The question says "randomly chosen", and the burning question is "what the heck does that mean"?
The positive integers can't all be chosen with equal probability*, so the answer therefore depends on how you assign probability to the original set of positive integers.
* (if they think it's possible, they're welcome to attempt to explain how one actually does that, which might be fun to watch)
Even the Hint doesn't pin it down.
Let's consider the 1-digit integers, and the last digit of their squares:
1 2 3 4 5 6 7 8 9 0
1 4 9 6 5 6 9 4 1 0
No doubt they're saying "well, all those last digits have an equal chance of turning up, and so the chance that a square ends in 1 is 2/10. But there's no reasonable basis on which to assert that the last digits do have an equal chance of turning up.
For example, if we toss a coin until we observe a head, and count the number of tosses, that will give a distribution over the integers. With that distribution, the chance is a little over 0.5:
$$p = (\frac{1}{2}+(\frac{1}{2})^9)(1 + (\frac{1}{2})^{10} + (\frac{1}{2})^{20} +...)$$
$$ = \frac{1}{2}\frac{1+(\frac{1}{2})^{10}}{1 - (\frac{1}{2})^{10}}$$
Other answers are possible.
Now it's possible to find distributions for which 0.2 is the right answer, and it's even possible to come up with distributions for which you can immediately work it out from the above table of single digits and the knowledge of the distribution (most obviously, any distribution where the ratios on the single digits are preserved throughout the integers) - but the distributions for which it works are generally substantially less "obvious" or "natural" than say a geometric($\frac{1}{2}$) distribution, like the one I used above.
|
Probability that the square of a random integer ends in 1
|
In fact that answer is not sufficiently justified given the information in the question.
It depends on the distribution over the positive integers. The question says "randomly chosen", and the burning
|
Probability that the square of a random integer ends in 1
In fact that answer is not sufficiently justified given the information in the question.
It depends on the distribution over the positive integers. The question says "randomly chosen", and the burning question is "what the heck does that mean"?
The positive integers can't all be chosen with equal probability*, so the answer therefore depends on how you assign probability to the original set of positive integers.
* (if they think it's possible, they're welcome to attempt to explain how one actually does that, which might be fun to watch)
Even the Hint doesn't pin it down.
Let's consider the 1-digit integers, and the last digit of their squares:
1 2 3 4 5 6 7 8 9 0
1 4 9 6 5 6 9 4 1 0
No doubt they're saying "well, all those last digits have an equal chance of turning up, and so the chance that a square ends in 1 is 2/10. But there's no reasonable basis on which to assert that the last digits do have an equal chance of turning up.
For example, if we toss a coin until we observe a head, and count the number of tosses, that will give a distribution over the integers. With that distribution, the chance is a little over 0.5:
$$p = (\frac{1}{2}+(\frac{1}{2})^9)(1 + (\frac{1}{2})^{10} + (\frac{1}{2})^{20} +...)$$
$$ = \frac{1}{2}\frac{1+(\frac{1}{2})^{10}}{1 - (\frac{1}{2})^{10}}$$
Other answers are possible.
Now it's possible to find distributions for which 0.2 is the right answer, and it's even possible to come up with distributions for which you can immediately work it out from the above table of single digits and the knowledge of the distribution (most obviously, any distribution where the ratios on the single digits are preserved throughout the integers) - but the distributions for which it works are generally substantially less "obvious" or "natural" than say a geometric($\frac{1}{2}$) distribution, like the one I used above.
|
Probability that the square of a random integer ends in 1
In fact that answer is not sufficiently justified given the information in the question.
It depends on the distribution over the positive integers. The question says "randomly chosen", and the burning
|
44,500
|
Probability that the square of a random integer ends in 1
|
When a mathematician asks to pick a "random integer" or "random natural number," they usually have in mind a limiting process in which the numbers all "become equally probable." The process can be quite general: I believe all that you need is that (a) the relative probabilities of any two sets should converge and (b) the relative probabilities of any two finite sets should converge to the ratio of their cardinalities.
One nice set of distributions with these properties is the geometric, where the chance of $k\ge 1$ is given by
$${\Pr}_x(k) = (1-x)x^{k-1}$$
for a parameter $0 \lt x \lt 1$ and values $k\in \{1,2,\ldots\}.$ The figure plots these distributions for $x=0.9, 0.99, 0.999$ and $1\le k\le 100$: as $x$ gets close to $1$, the distributions gets flatter and flatter: more and more uniform.
The advantage of this particular family of probability measures is that the probability of any set $A$ of positive integers, such as those whose squares end in "1", is the limiting value of
$${\Pr}_x(A) = (1-x)\sum_{k\in A} x^{k-1}$$
as $x\to 1.$ This limiting value, which appears to be the product of something going to $0$ (that is, $1-x$) and something that is growing infinitely large (the unnormalized chance of $A$ as given by the sum), often can easily be computed using L'Hopital's Rule. Let's illustrate with the question in hand, where
$$A=\{1,9,11,19,21,\ldots\}=\{10i+1\ |\ i \ge 0\}\cup\{10i+9\ |\ i \ge 0\} = A_1\cup A_9.$$
Because $A_1$ and $A_9$ are disjoint, this breaks the probability calculation into two parts:
$${\Pr}_x(A) = {\Pr}_x(A_1) + {\Pr}_x(A_9) = (1-x)\left(\sum_{i=0}^\infty x^{10i+1} + \sum_{i=0}^\infty x^{10i+9}\right).$$
Both of these sums are geometric series with common ratios $x^{10},$ which reduces them to
$${\Pr}_x(A) = (1-x)\left(\frac{x}{1-x^{10}} + \frac{x^9}{1-x^{10}}\right) = \frac{(1-x)(x+x^9)}{1-x^{10}}.$$
Because both the numerator and the denominator of this fraction converge to $0$ as $x\to 1,$ L'Hopital's Rule says the limit can be found as the limiting ratio of the derivatives of the numerator and denominator:
$$\lim_{x\to 1}{\Pr}_x(A) = \lim_{x\to 1} \frac{1 - 2x + 9x^8 - 10x^9}{-10x^{9}} = \frac{-2}{-10}=\frac{2}{10}.$$
Clearly we did not just "consider only one-digit numbers" in the calculation--all the positive integers were involved--but because $A_1$ and $A_9$ are defined only in terms of the final digits ($1$ and $9$ respectively), in that sense we only have to be concerned about the final digits (in this particular problem).
|
Probability that the square of a random integer ends in 1
|
When a mathematician asks to pick a "random integer" or "random natural number," they usually have in mind a limiting process in which the numbers all "become equally probable." The process can be qu
|
Probability that the square of a random integer ends in 1
When a mathematician asks to pick a "random integer" or "random natural number," they usually have in mind a limiting process in which the numbers all "become equally probable." The process can be quite general: I believe all that you need is that (a) the relative probabilities of any two sets should converge and (b) the relative probabilities of any two finite sets should converge to the ratio of their cardinalities.
One nice set of distributions with these properties is the geometric, where the chance of $k\ge 1$ is given by
$${\Pr}_x(k) = (1-x)x^{k-1}$$
for a parameter $0 \lt x \lt 1$ and values $k\in \{1,2,\ldots\}.$ The figure plots these distributions for $x=0.9, 0.99, 0.999$ and $1\le k\le 100$: as $x$ gets close to $1$, the distributions gets flatter and flatter: more and more uniform.
The advantage of this particular family of probability measures is that the probability of any set $A$ of positive integers, such as those whose squares end in "1", is the limiting value of
$${\Pr}_x(A) = (1-x)\sum_{k\in A} x^{k-1}$$
as $x\to 1.$ This limiting value, which appears to be the product of something going to $0$ (that is, $1-x$) and something that is growing infinitely large (the unnormalized chance of $A$ as given by the sum), often can easily be computed using L'Hopital's Rule. Let's illustrate with the question in hand, where
$$A=\{1,9,11,19,21,\ldots\}=\{10i+1\ |\ i \ge 0\}\cup\{10i+9\ |\ i \ge 0\} = A_1\cup A_9.$$
Because $A_1$ and $A_9$ are disjoint, this breaks the probability calculation into two parts:
$${\Pr}_x(A) = {\Pr}_x(A_1) + {\Pr}_x(A_9) = (1-x)\left(\sum_{i=0}^\infty x^{10i+1} + \sum_{i=0}^\infty x^{10i+9}\right).$$
Both of these sums are geometric series with common ratios $x^{10},$ which reduces them to
$${\Pr}_x(A) = (1-x)\left(\frac{x}{1-x^{10}} + \frac{x^9}{1-x^{10}}\right) = \frac{(1-x)(x+x^9)}{1-x^{10}}.$$
Because both the numerator and the denominator of this fraction converge to $0$ as $x\to 1,$ L'Hopital's Rule says the limit can be found as the limiting ratio of the derivatives of the numerator and denominator:
$$\lim_{x\to 1}{\Pr}_x(A) = \lim_{x\to 1} \frac{1 - 2x + 9x^8 - 10x^9}{-10x^{9}} = \frac{-2}{-10}=\frac{2}{10}.$$
Clearly we did not just "consider only one-digit numbers" in the calculation--all the positive integers were involved--but because $A_1$ and $A_9$ are defined only in terms of the final digits ($1$ and $9$ respectively), in that sense we only have to be concerned about the final digits (in this particular problem).
|
Probability that the square of a random integer ends in 1
When a mathematician asks to pick a "random integer" or "random natural number," they usually have in mind a limiting process in which the numbers all "become equally probable." The process can be qu
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.