idx
int64 1
56k
| question
stringlengths 15
155
| answer
stringlengths 2
29.2k
β | question_cut
stringlengths 15
100
| answer_cut
stringlengths 2
200
β | conversation
stringlengths 47
29.3k
| conversation_cut
stringlengths 47
301
|
|---|---|---|---|---|---|---|
40,101
|
What is coskewness and how can it be calculated?
|
This link might help you get a clearer idea: http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/
It includes the mathematical definition along with a Matlab implementation.
|
What is coskewness and how can it be calculated?
|
This link might help you get a clearer idea: http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/
It includes the mathematical definition along with a Matlab implementation.
|
What is coskewness and how can it be calculated?
This link might help you get a clearer idea: http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/
It includes the mathematical definition along with a Matlab implementation.
|
What is coskewness and how can it be calculated?
This link might help you get a clearer idea: http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/
It includes the mathematical definition along with a Matlab implementation.
|
40,102
|
Covariate shift correction: standard implementation in R?
|
Take a look at the twang package on CRAN. It casts the problem in terms of observational studies and propensity scoring, but the application is the same. Read the primary academic article for many more details and discussion: "Propensity Score Estimation with Boosted Regression for Evaluating Adolescent Substance Abuse Treatment".
It's really a tricky area though. If there is test/train overlap then twang (or other propensity score analysis) can help you out. If there are areas of no overlap then best of luck to you. Also, you don't need to resample, just weight your training data by Pr(Test)/Pr(Train). The derivation of that is covered in the article above.
|
Covariate shift correction: standard implementation in R?
|
Take a look at the twang package on CRAN. It casts the problem in terms of observational studies and propensity scoring, but the application is the same. Read the primary academic article for many m
|
Covariate shift correction: standard implementation in R?
Take a look at the twang package on CRAN. It casts the problem in terms of observational studies and propensity scoring, but the application is the same. Read the primary academic article for many more details and discussion: "Propensity Score Estimation with Boosted Regression for Evaluating Adolescent Substance Abuse Treatment".
It's really a tricky area though. If there is test/train overlap then twang (or other propensity score analysis) can help you out. If there are areas of no overlap then best of luck to you. Also, you don't need to resample, just weight your training data by Pr(Test)/Pr(Train). The derivation of that is covered in the article above.
|
Covariate shift correction: standard implementation in R?
Take a look at the twang package on CRAN. It casts the problem in terms of observational studies and propensity scoring, but the application is the same. Read the primary academic article for many m
|
40,103
|
Covariate shift correction: standard implementation in R?
|
I don't know of any packaged functions to perform correction for co-variate shift, but here is something that might work.
You could build a random-forest classifier between the training and test set (to estimate test-set probabilities). You can then learn a random-forest on the training set by sampling according to the estimated test-set probabilities. This will alleviate your concern number 2, by allowing a non-linear function learner. (By the way, you can also try the mboost package, which has several flavors of boosting implemented and is much faster than randomForest.)
Kernel mean matching may work but wouldn't necessarily be any better than any other non-linear classifier that outputs class probabilities -- and furthermore requires choices on the kernel and its hyper-parameters.
|
Covariate shift correction: standard implementation in R?
|
I don't know of any packaged functions to perform correction for co-variate shift, but here is something that might work.
You could build a random-forest classifier between the training and test set
|
Covariate shift correction: standard implementation in R?
I don't know of any packaged functions to perform correction for co-variate shift, but here is something that might work.
You could build a random-forest classifier between the training and test set (to estimate test-set probabilities). You can then learn a random-forest on the training set by sampling according to the estimated test-set probabilities. This will alleviate your concern number 2, by allowing a non-linear function learner. (By the way, you can also try the mboost package, which has several flavors of boosting implemented and is much faster than randomForest.)
Kernel mean matching may work but wouldn't necessarily be any better than any other non-linear classifier that outputs class probabilities -- and furthermore requires choices on the kernel and its hyper-parameters.
|
Covariate shift correction: standard implementation in R?
I don't know of any packaged functions to perform correction for co-variate shift, but here is something that might work.
You could build a random-forest classifier between the training and test set
|
40,104
|
Non-intuitive answer from a Poisson regression
|
A brief (actually it turned out quite lengthy) update on material in the comments (as covered by @cardinal and myself above):
I think the main problems are arising from not specifying an offset variable (as per my comment above, see StasK's note on Interpretation of Coefficient answer) which would usually be the natural log of the population at risk (or person-time at risk.)
For Poisson regression to compare rates rather than counts, you need to specify an offset variable (which acts as a constant on the right hand side of the regression equation.)
In R, with this same dataset from http://data.princeton.edu/wws509/datasets/#smoking (which I'm storing as raw.dat, with variable names age, smoke, pop and dead) this would be:
# Make a factorial version of the smoking variable
raw.dat$smoke.f <- factor(raw.dat$smoke)
# For this variable 1 = non-smoker, 2 = cigar only,
# 3 = cigarettes + cigars, 4 = cigarettes only.
# Regression model:
poisson.smoke <- glm(dead ~ age + smoke.f, offset=log(pop),
family="poisson", data = raw.dat)
summary(poisson.smoke)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.738877 0.050009 -74.764 < 2e-16 ***
# age 0.333006 0.005591 59.559 < 2e-16 ***
# smoke.f2 0.032927 0.046894 0.702 0.483
# smoke.f3 0.236353 0.038597 6.124 9.15e-10 ***
# smoke.f4 0.437946 0.039803 11.003 < 2e-16 ***
So the coefficient for smoke.f2 (cigar only) compared to non-smokers is now 0.333, exponentiating this gives a rate ratio of 1.033 (95% CI 0.94, 1.13) so no particular evidence in this model of increased risk of lung cancer in cigar-only smokers compared to non-smokers.
Secondly: regarding the lack of interaction term between cigar and cigarette in your original model (and note that including an interaction term is at one level equivalent to treating cigar + cigarette as a distinct group, as per your second model and the example above, which leads to a model with the same number of parameters and the same solution, but some different interpretations of coefficients.)
This lack of interaction might be causing some issues, but with correct specification of the offset variable the coefficient is at least pointing in the correct direction:
# Make two indicator variables for cigar and smoking
raw.dat$cigar <- ifelse(raw.dat$smoking==2 | raw.dat$smoking==3, 1, 0)
raw.dat$cigarette <- ifelse(raw.dat$smoking==3 | raw.dat$smoking==4, 1, 0)
# Model treating these as independent:
poisson.sep.smoke <- glm(dead ~ age + cigar + cigarette, offset=log(pop),
family="poisson", data = raw.dat)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.648010 0.044886 -81.273 < 2e-16 ***
# age 0.334359 0.005576 59.959 < 2e-16 ***
# cigar -0.153685 0.021252 -7.232 4.77e-13 ***
# cigarette 0.312363 0.027301 11.442 < 2e-16 ***
And then including an interaction between the two: solution-wise, this is equivalent to having all four levels (with three dummy variables) as per my first model.
poisson.int.smoke <- glm(dead ~ age + cigar * cigarette, offset=log(pop),
family="poisson", data = raw.dat)
summary(poisson.int.smoke)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.738877 0.050009 -74.764 < 2e-16 ***
# age 0.333006 0.005591 59.559 < 2e-16 ***
# cigar 0.032927 0.046894 0.702 0.483
# cigarette 0.437946 0.039803 11.003 < 2e-16 ***
# cigar:cigarette -0.234519 0.052428 -4.473 7.71e-06 ***
So you can see that the interaction term (cigar:cigarette) is significant: in other words, the effects of cigar smoking and cigarette smoking are dependent on each other. This is the main advantage of specifying an interaction-term based model over the all-levels model, in that the interaction phenomenon (of independence between cigar and cigarette impact) is "automatically" tested in this scenario.
The cigar and cigarette coefficients here correspond to smoke.f2 and smoke.f4 before, and mathematically, the old coefficient for smoke.f3 is the sum of cigar, cigarette and cigar:cigarette terms in this model.
|
Non-intuitive answer from a Poisson regression
|
A brief (actually it turned out quite lengthy) update on material in the comments (as covered by @cardinal and myself above):
I think the main problems are arising from not specifying an offset variab
|
Non-intuitive answer from a Poisson regression
A brief (actually it turned out quite lengthy) update on material in the comments (as covered by @cardinal and myself above):
I think the main problems are arising from not specifying an offset variable (as per my comment above, see StasK's note on Interpretation of Coefficient answer) which would usually be the natural log of the population at risk (or person-time at risk.)
For Poisson regression to compare rates rather than counts, you need to specify an offset variable (which acts as a constant on the right hand side of the regression equation.)
In R, with this same dataset from http://data.princeton.edu/wws509/datasets/#smoking (which I'm storing as raw.dat, with variable names age, smoke, pop and dead) this would be:
# Make a factorial version of the smoking variable
raw.dat$smoke.f <- factor(raw.dat$smoke)
# For this variable 1 = non-smoker, 2 = cigar only,
# 3 = cigarettes + cigars, 4 = cigarettes only.
# Regression model:
poisson.smoke <- glm(dead ~ age + smoke.f, offset=log(pop),
family="poisson", data = raw.dat)
summary(poisson.smoke)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.738877 0.050009 -74.764 < 2e-16 ***
# age 0.333006 0.005591 59.559 < 2e-16 ***
# smoke.f2 0.032927 0.046894 0.702 0.483
# smoke.f3 0.236353 0.038597 6.124 9.15e-10 ***
# smoke.f4 0.437946 0.039803 11.003 < 2e-16 ***
So the coefficient for smoke.f2 (cigar only) compared to non-smokers is now 0.333, exponentiating this gives a rate ratio of 1.033 (95% CI 0.94, 1.13) so no particular evidence in this model of increased risk of lung cancer in cigar-only smokers compared to non-smokers.
Secondly: regarding the lack of interaction term between cigar and cigarette in your original model (and note that including an interaction term is at one level equivalent to treating cigar + cigarette as a distinct group, as per your second model and the example above, which leads to a model with the same number of parameters and the same solution, but some different interpretations of coefficients.)
This lack of interaction might be causing some issues, but with correct specification of the offset variable the coefficient is at least pointing in the correct direction:
# Make two indicator variables for cigar and smoking
raw.dat$cigar <- ifelse(raw.dat$smoking==2 | raw.dat$smoking==3, 1, 0)
raw.dat$cigarette <- ifelse(raw.dat$smoking==3 | raw.dat$smoking==4, 1, 0)
# Model treating these as independent:
poisson.sep.smoke <- glm(dead ~ age + cigar + cigarette, offset=log(pop),
family="poisson", data = raw.dat)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.648010 0.044886 -81.273 < 2e-16 ***
# age 0.334359 0.005576 59.959 < 2e-16 ***
# cigar -0.153685 0.021252 -7.232 4.77e-13 ***
# cigarette 0.312363 0.027301 11.442 < 2e-16 ***
And then including an interaction between the two: solution-wise, this is equivalent to having all four levels (with three dummy variables) as per my first model.
poisson.int.smoke <- glm(dead ~ age + cigar * cigarette, offset=log(pop),
family="poisson", data = raw.dat)
summary(poisson.int.smoke)
# snipped output from R:
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -3.738877 0.050009 -74.764 < 2e-16 ***
# age 0.333006 0.005591 59.559 < 2e-16 ***
# cigar 0.032927 0.046894 0.702 0.483
# cigarette 0.437946 0.039803 11.003 < 2e-16 ***
# cigar:cigarette -0.234519 0.052428 -4.473 7.71e-06 ***
So you can see that the interaction term (cigar:cigarette) is significant: in other words, the effects of cigar smoking and cigarette smoking are dependent on each other. This is the main advantage of specifying an interaction-term based model over the all-levels model, in that the interaction phenomenon (of independence between cigar and cigarette impact) is "automatically" tested in this scenario.
The cigar and cigarette coefficients here correspond to smoke.f2 and smoke.f4 before, and mathematically, the old coefficient for smoke.f3 is the sum of cigar, cigarette and cigar:cigarette terms in this model.
|
Non-intuitive answer from a Poisson regression
A brief (actually it turned out quite lengthy) update on material in the comments (as covered by @cardinal and myself above):
I think the main problems are arising from not specifying an offset variab
|
40,105
|
Where can I find time series data to assess accuracy of forecast? [closed]
|
The International Institute of Forecasters has some datasets (under "Resources"). One very commonly used dataset is the one from the M3 competition.
The Forecasting Principles website (affiliated with the IIF) has some datasets.
Here is the Time Series Data Library created by Rob Hyndman, which @IrishStat mentioned.
You can also look at the datasets for Rob Hyndman's online forecasting textbook.
I think the most commonly used dataset would be the one from the M3 competition. If you plan on publishing in the forecasting field, using this dataset will yield a certain recognition effect among referees. The original publication on the M3 competition is this one.
|
Where can I find time series data to assess accuracy of forecast? [closed]
|
The International Institute of Forecasters has some datasets (under "Resources"). One very commonly used dataset is the one from the M3 competition.
The Forecasting Principles website (affiliated with
|
Where can I find time series data to assess accuracy of forecast? [closed]
The International Institute of Forecasters has some datasets (under "Resources"). One very commonly used dataset is the one from the M3 competition.
The Forecasting Principles website (affiliated with the IIF) has some datasets.
Here is the Time Series Data Library created by Rob Hyndman, which @IrishStat mentioned.
You can also look at the datasets for Rob Hyndman's online forecasting textbook.
I think the most commonly used dataset would be the one from the M3 competition. If you plan on publishing in the forecasting field, using this dataset will yield a certain recognition effect among referees. The original publication on the M3 competition is this one.
|
Where can I find time series data to assess accuracy of forecast? [closed]
The International Institute of Forecasters has some datasets (under "Resources"). One very commonly used dataset is the one from the M3 competition.
The Forecasting Principles website (affiliated with
|
40,106
|
Precision and recall in a multi-class classification system?
|
For those who might be interested in an answer, this comes from a much more knowledgeable source than me (PhD candidate in NLP):
When doing multiclass classification, precision and recall are really
only properly defined for individual classes (you can average across
classes to get a general scores for the entire system, but it's not
really that useful; in my opinion, you're probably better off just
using overall accuracy as your metric of performance).
For an individual class, the false positives are those instances which
were classified as that class, but in fact aren't, and the true
negatives are those instances which are not that class, and were
indeed classified as not belonging to that class (regardless of
whether they were correctly classified).
|
Precision and recall in a multi-class classification system?
|
For those who might be interested in an answer, this comes from a much more knowledgeable source than me (PhD candidate in NLP):
When doing multiclass classification, precision and recall are really
|
Precision and recall in a multi-class classification system?
For those who might be interested in an answer, this comes from a much more knowledgeable source than me (PhD candidate in NLP):
When doing multiclass classification, precision and recall are really
only properly defined for individual classes (you can average across
classes to get a general scores for the entire system, but it's not
really that useful; in my opinion, you're probably better off just
using overall accuracy as your metric of performance).
For an individual class, the false positives are those instances which
were classified as that class, but in fact aren't, and the true
negatives are those instances which are not that class, and were
indeed classified as not belonging to that class (regardless of
whether they were correctly classified).
|
Precision and recall in a multi-class classification system?
For those who might be interested in an answer, this comes from a much more knowledgeable source than me (PhD candidate in NLP):
When doing multiclass classification, precision and recall are really
|
40,107
|
Factor analysis on multiply imputed data
|
Factor analysis or principal components analysis may indeed yield solutions whose answers are rotated or mirrored versions of each other, so averaging the person scores is not a good idea. Several authors have explored the use of Procrustes analysis to correct for the rotational indetermination, so try searching on 'multiple imputation' and 'procrustes'.
|
Factor analysis on multiply imputed data
|
Factor analysis or principal components analysis may indeed yield solutions whose answers are rotated or mirrored versions of each other, so averaging the person scores is not a good idea. Several aut
|
Factor analysis on multiply imputed data
Factor analysis or principal components analysis may indeed yield solutions whose answers are rotated or mirrored versions of each other, so averaging the person scores is not a good idea. Several authors have explored the use of Procrustes analysis to correct for the rotational indetermination, so try searching on 'multiple imputation' and 'procrustes'.
|
Factor analysis on multiply imputed data
Factor analysis or principal components analysis may indeed yield solutions whose answers are rotated or mirrored versions of each other, so averaging the person scores is not a good idea. Several aut
|
40,108
|
Factor analysis on multiply imputed data
|
Do confirmatory factor analysis instead, which would help fixing the loadings to have the same sign in all the imputations. At its heart, EFA is exploratory, while MI framework is that of parameter estimation. They just don't go together well: MI is not particularly suitable either for testing or exploratory analysis. EFA only makes sense if you know nothing about your data, which is rarely the case: if you designed the instrument, you must have had some idea in mind what you wanted to measure, and can just cut to the meat of that with CFA.
|
Factor analysis on multiply imputed data
|
Do confirmatory factor analysis instead, which would help fixing the loadings to have the same sign in all the imputations. At its heart, EFA is exploratory, while MI framework is that of parameter es
|
Factor analysis on multiply imputed data
Do confirmatory factor analysis instead, which would help fixing the loadings to have the same sign in all the imputations. At its heart, EFA is exploratory, while MI framework is that of parameter estimation. They just don't go together well: MI is not particularly suitable either for testing or exploratory analysis. EFA only makes sense if you know nothing about your data, which is rarely the case: if you designed the instrument, you must have had some idea in mind what you wanted to measure, and can just cut to the meat of that with CFA.
|
Factor analysis on multiply imputed data
Do confirmatory factor analysis instead, which would help fixing the loadings to have the same sign in all the imputations. At its heart, EFA is exploratory, while MI framework is that of parameter es
|
40,109
|
Elementary approach to higher order asymptotics
|
The higher order asymptotics books that I have on my shelf are Barndord-Nielsen and Cox, Brazzale, Davison and Reid, and Young and Smith (the very latter was my dissertation adviser, and I think he has a great ability to explain very complex concepts in a reasonably understandable way; his review of non-standard problems in likelihood inference is a must second reading in asymptotics, although it is nearly impossible to get short of asking him directly). The ultimate reference on Edgeworth expansions is probably Peter Hall's bootstrap book (1995). I would have to say that Rothenberg's chapter recommended by fg nu may be beating any of them in terms of clarity. Some books, like Rencher's Multivariate Analysis, just put Bartlett corrections everywhere without explaining much of them, but they motivate it as a small sample correction.
|
Elementary approach to higher order asymptotics
|
The higher order asymptotics books that I have on my shelf are Barndord-Nielsen and Cox, Brazzale, Davison and Reid, and Young and Smith (the very latter was my dissertation adviser, and I think he ha
|
Elementary approach to higher order asymptotics
The higher order asymptotics books that I have on my shelf are Barndord-Nielsen and Cox, Brazzale, Davison and Reid, and Young and Smith (the very latter was my dissertation adviser, and I think he has a great ability to explain very complex concepts in a reasonably understandable way; his review of non-standard problems in likelihood inference is a must second reading in asymptotics, although it is nearly impossible to get short of asking him directly). The ultimate reference on Edgeworth expansions is probably Peter Hall's bootstrap book (1995). I would have to say that Rothenberg's chapter recommended by fg nu may be beating any of them in terms of clarity. Some books, like Rencher's Multivariate Analysis, just put Bartlett corrections everywhere without explaining much of them, but they motivate it as a small sample correction.
|
Elementary approach to higher order asymptotics
The higher order asymptotics books that I have on my shelf are Barndord-Nielsen and Cox, Brazzale, Davison and Reid, and Young and Smith (the very latter was my dissertation adviser, and I think he ha
|
40,110
|
Elementary approach to higher order asymptotics
|
In addition to the other answer, a simpler book to read about this (and newer) is maybe Ronald Butler: "Saddlepoint approximations with applications". I guess it would be difficult to find a more elementary treatment than this!
As others mentioned Edgeworth approximations: Saddlepoint approximations can be seen as a tilted version of the Edgeworth approximation. The edgeworth approximations is more exact at the mean of the distribution we want to approximate. If we want to approximate the distribution at some point $x$ other than the mean, we can "tilt" the distribution by multiplying it with some exponential factor, so moving the mean to $x$, and using the Edgeworth approximation there. That is the saddlepoint approximation.
For more about the saddlepoint approximation see this post: How does saddlepoint approximation work?
|
Elementary approach to higher order asymptotics
|
In addition to the other answer, a simpler book to read about this (and newer) is maybe Ronald Butler: "Saddlepoint approximations with applications". I guess it would be difficult to find a more ele
|
Elementary approach to higher order asymptotics
In addition to the other answer, a simpler book to read about this (and newer) is maybe Ronald Butler: "Saddlepoint approximations with applications". I guess it would be difficult to find a more elementary treatment than this!
As others mentioned Edgeworth approximations: Saddlepoint approximations can be seen as a tilted version of the Edgeworth approximation. The edgeworth approximations is more exact at the mean of the distribution we want to approximate. If we want to approximate the distribution at some point $x$ other than the mean, we can "tilt" the distribution by multiplying it with some exponential factor, so moving the mean to $x$, and using the Edgeworth approximation there. That is the saddlepoint approximation.
For more about the saddlepoint approximation see this post: How does saddlepoint approximation work?
|
Elementary approach to higher order asymptotics
In addition to the other answer, a simpler book to read about this (and newer) is maybe Ronald Butler: "Saddlepoint approximations with applications". I guess it would be difficult to find a more ele
|
40,111
|
Understanding the predictive distribution in gaussian linear regression
|
The Posterior predictive distribution is a weighted average over your hypothesis space where each hypothesis is weighted by it's posterior probability. In Bayesian analysis, beliefs are expressed as entire distributions rather than point estimates. In your example, you have a posterior distribution over all possible weights. The fully Bayesian way to make a prediction is to marginalize out the weights by integrating over your posterior. There are alternatives to this such as taking the MAP value, which is the most probable weight value under your posterior, however that is not strictly Bayesian. It might help to review a smaller, more introductory Bayesian inference problem (e.g. inferring the mean of a Gaussian with known variance) to get your head around the concept, because it is rather fundamental to the entire approach.
|
Understanding the predictive distribution in gaussian linear regression
|
The Posterior predictive distribution is a weighted average over your hypothesis space where each hypothesis is weighted by it's posterior probability. In Bayesian analysis, beliefs are expressed as e
|
Understanding the predictive distribution in gaussian linear regression
The Posterior predictive distribution is a weighted average over your hypothesis space where each hypothesis is weighted by it's posterior probability. In Bayesian analysis, beliefs are expressed as entire distributions rather than point estimates. In your example, you have a posterior distribution over all possible weights. The fully Bayesian way to make a prediction is to marginalize out the weights by integrating over your posterior. There are alternatives to this such as taking the MAP value, which is the most probable weight value under your posterior, however that is not strictly Bayesian. It might help to review a smaller, more introductory Bayesian inference problem (e.g. inferring the mean of a Gaussian with known variance) to get your head around the concept, because it is rather fundamental to the entire approach.
|
Understanding the predictive distribution in gaussian linear regression
The Posterior predictive distribution is a weighted average over your hypothesis space where each hypothesis is weighted by it's posterior probability. In Bayesian analysis, beliefs are expressed as e
|
40,112
|
Understanding the predictive distribution in gaussian linear regression
|
The proof is simple. Ignore the Integral for a bit and check the definition of the Expectation (mean) and Covariance (Variance):
$f_{*}=x_{*}^Tw \implies \mathbb{E}[f_{*}]=x_{*}^T\mathbb{E}[w] \implies \mu_{f_{*}}=x_{*}^T\bar{w}=\sigma_n x_{*}^TA^{-1}Xy$
In the same sense: $\mathbb{E}[f_{*}f_{*}^T]=\mathbb{E}[x_{*}^Tw \,w^Tx_{*}]=x_{*}^T\mathbb{E}[w \,w^T]x_{*}=x_{*}^TA^{-1}x_{*}$.
I stumpled across the same point when reading the book.
|
Understanding the predictive distribution in gaussian linear regression
|
The proof is simple. Ignore the Integral for a bit and check the definition of the Expectation (mean) and Covariance (Variance):
$f_{*}=x_{*}^Tw \implies \mathbb{E}[f_{*}]=x_{*}^T\mathbb{E}[w] \impli
|
Understanding the predictive distribution in gaussian linear regression
The proof is simple. Ignore the Integral for a bit and check the definition of the Expectation (mean) and Covariance (Variance):
$f_{*}=x_{*}^Tw \implies \mathbb{E}[f_{*}]=x_{*}^T\mathbb{E}[w] \implies \mu_{f_{*}}=x_{*}^T\bar{w}=\sigma_n x_{*}^TA^{-1}Xy$
In the same sense: $\mathbb{E}[f_{*}f_{*}^T]=\mathbb{E}[x_{*}^Tw \,w^Tx_{*}]=x_{*}^T\mathbb{E}[w \,w^T]x_{*}=x_{*}^TA^{-1}x_{*}$.
I stumpled across the same point when reading the book.
|
Understanding the predictive distribution in gaussian linear regression
The proof is simple. Ignore the Integral for a bit and check the definition of the Expectation (mean) and Covariance (Variance):
$f_{*}=x_{*}^Tw \implies \mathbb{E}[f_{*}]=x_{*}^T\mathbb{E}[w] \impli
|
40,113
|
Understanding the predictive distribution in gaussian linear regression
|
This is my understanding which did not follow the thought of marginalization. Hope it is correct.
$f_* = x_*^Tw$ (This is equation 2.1 in the book)
Therefore,
$p(f_*|x_*,X,y) = p(x_*^Tw|x_*,X,y) = x_*^Tp(w|x_*,X,y) = x_*^Tp(w|X,y)$
(remember that $w$ is independent of $x_*$)
Therefore,
$p(f_*|x_*,X,y)= x_*^Tp(w|X,y)$, which is a linear transformation of a MVD $p(w|X,y)$.
We know that $p(w|X,y)\sim\mathcal{N}(\frac{1}{\sigma_n^2}A^{-1}Xy,A^{-1})$ (This is equation 2.8 in the book)
Hence, $p(f_*|x_*,X,y)\sim\mathcal{N}(\frac{1}{\sigma_n^2}x_*^TA^{-1}Xy,x_*^TA^{-1}x_*)$ (see the general theory below)
Here is more details on linear transformation of a MVD
Given $p(x)\sim\mathcal{N}(\mu_x, \Sigma_x)$ and $y=Zx$,
$p(y)\sim\mathcal{N}(Z\mu_x, Z\Sigma_xZ^T)$
|
Understanding the predictive distribution in gaussian linear regression
|
This is my understanding which did not follow the thought of marginalization. Hope it is correct.
$f_* = x_*^Tw$ (This is equation 2.1 in the book)
Therefore,
$p(f_*|x_*,X,y) = p(x_*^Tw|x_*,X,y) = x_
|
Understanding the predictive distribution in gaussian linear regression
This is my understanding which did not follow the thought of marginalization. Hope it is correct.
$f_* = x_*^Tw$ (This is equation 2.1 in the book)
Therefore,
$p(f_*|x_*,X,y) = p(x_*^Tw|x_*,X,y) = x_*^Tp(w|x_*,X,y) = x_*^Tp(w|X,y)$
(remember that $w$ is independent of $x_*$)
Therefore,
$p(f_*|x_*,X,y)= x_*^Tp(w|X,y)$, which is a linear transformation of a MVD $p(w|X,y)$.
We know that $p(w|X,y)\sim\mathcal{N}(\frac{1}{\sigma_n^2}A^{-1}Xy,A^{-1})$ (This is equation 2.8 in the book)
Hence, $p(f_*|x_*,X,y)\sim\mathcal{N}(\frac{1}{\sigma_n^2}x_*^TA^{-1}Xy,x_*^TA^{-1}x_*)$ (see the general theory below)
Here is more details on linear transformation of a MVD
Given $p(x)\sim\mathcal{N}(\mu_x, \Sigma_x)$ and $y=Zx$,
$p(y)\sim\mathcal{N}(Z\mu_x, Z\Sigma_xZ^T)$
|
Understanding the predictive distribution in gaussian linear regression
This is my understanding which did not follow the thought of marginalization. Hope it is correct.
$f_* = x_*^Tw$ (This is equation 2.1 in the book)
Therefore,
$p(f_*|x_*,X,y) = p(x_*^Tw|x_*,X,y) = x_
|
40,114
|
Understanding the predictive distribution in gaussian linear regression
|
The general idea of the "prediction distribution" has been expressed in @jerad's answer. In short, Bayesians regard everything as random, hence seeking for their distribution which preserves all the information. (Of course you can always derive a point estimator from it at the last step, for example by maximum vote principle)
Return to the formula, there are actually two equations:
Marginal equation:
$$
\begin{aligned}
p\left(f_{*} \mid x_{*}, X, y\right) &=\int p\left(f_{*} \mid x_{*}, w\right) p(w \mid X, y) d w
\end{aligned}
$$
Proof:
By marginal calculation
\begin{aligned}
p\left(f_{*} \mid x_{*}, X, y\right) &=\int p\left(f_{*} \mid x_{*}, w, X, y\right) p(w \mid x_{*}, X, y) d w
\end{aligned}
where by independance, $p(f_{*} \mid x_{*}, w, X, y) = p(f_{*} \mid x_{*}, w)$ and $p(w \mid x_{*}, X, y) = p(w \mid X, y)$
Derivation of normal distribution
Notice that $f_{*} = w^T x_{*}$, so $f_{*} \mid x_{*},w$ is actually deterministic. i.e. $p(f_{*} \mid x_{*},w) = \delta(w^T x_{*})$, integrate any distribution with a delta function is just an evaluation. Or you can just refer @Pantelis' answer which is simpler.
|
Understanding the predictive distribution in gaussian linear regression
|
The general idea of the "prediction distribution" has been expressed in @jerad's answer. In short, Bayesians regard everything as random, hence seeking for their distribution which preserves all the i
|
Understanding the predictive distribution in gaussian linear regression
The general idea of the "prediction distribution" has been expressed in @jerad's answer. In short, Bayesians regard everything as random, hence seeking for their distribution which preserves all the information. (Of course you can always derive a point estimator from it at the last step, for example by maximum vote principle)
Return to the formula, there are actually two equations:
Marginal equation:
$$
\begin{aligned}
p\left(f_{*} \mid x_{*}, X, y\right) &=\int p\left(f_{*} \mid x_{*}, w\right) p(w \mid X, y) d w
\end{aligned}
$$
Proof:
By marginal calculation
\begin{aligned}
p\left(f_{*} \mid x_{*}, X, y\right) &=\int p\left(f_{*} \mid x_{*}, w, X, y\right) p(w \mid x_{*}, X, y) d w
\end{aligned}
where by independance, $p(f_{*} \mid x_{*}, w, X, y) = p(f_{*} \mid x_{*}, w)$ and $p(w \mid x_{*}, X, y) = p(w \mid X, y)$
Derivation of normal distribution
Notice that $f_{*} = w^T x_{*}$, so $f_{*} \mid x_{*},w$ is actually deterministic. i.e. $p(f_{*} \mid x_{*},w) = \delta(w^T x_{*})$, integrate any distribution with a delta function is just an evaluation. Or you can just refer @Pantelis' answer which is simpler.
|
Understanding the predictive distribution in gaussian linear regression
The general idea of the "prediction distribution" has been expressed in @jerad's answer. In short, Bayesians regard everything as random, hence seeking for their distribution which preserves all the i
|
40,115
|
Covariance of INID order statistics
|
It is known. We can even make a more precise and slightly stronger statement.
The following demonstration rests on two ideas. The first is that for any random variable $X$, the conditional expectation
$$\mathbb{E}[X | X \le t]$$
is a non-decreasing function of $t$. This is geometrically obvious: as $t$ increases, the integral extends over a region that is widening to the right, thereby shifting the expectation to the right.
The second idea concerns any joint random variables $(X,Y)$. A general way to study their relationship is to "slice" $X$ and study the average value of $Y$ within each slice. More formally, we can consider the conditional expectations
$$\nu(x) = \mathbb{E}[Y | X=x]$$
as a function of $x$. This function contains more information than the sign of the covariance or correlation, which only tells us whether this function increases or decreases on average. In particular, if $\nu$ is nondecreasing, then $\text{Cov}(X,Y) \ge 0$. (The converse is not true, which is why non-decrease of $\nu$ is a stronger condition than a non-negative covariance.)
To apply these ideas, let $X_{(i)}, 1\le i \le n,$ be order statistics for $n$ independent (but not necessarily identically distributed) random variables. Pick $1 \le i \lt j \le n$ for further study. Because $X_{(i)}\le X_{(j)}$ (by their very definition), the condition $X_{(i)} \le X_{(j)} | X_{(j)} = t$ is equivalent to $X_{(i)} | X_{(i)} \le t$. The first idea now informs us that the expected value of $X_{(i)} | X_{(j)}$ is nondecreasing with respect to the value of $X_{(j)}$. Letting $X_{(i)}$ play the role of $X$ and $X_{(j)}$ the role of $Y$ in the second idea implies $\text{Cov}(X_{(i)}, X_{(j)}) \ge 0$, QED.
(It is possible for such covariances to equal zero. This will happen whenever the variables have no overlaps in their ranges, for instance, for then the order statistics coincide with the variables, whence they are independent, whence all their covariances must vanish.)
An imperfect illustration of these ideas is afforded by a simulation in which the sampling is repeated thousands of times and a scatterplot matrix is drawn showing the $(X_{(i)}, X_{(j)})$ pairs. These scatterplots approximate the true bivariate distributions of the order statistics. The preceding demonstration asserts that all reasonable smooths of the scatterplots in the lower diagonal of the matrix will be non-decreasing curves. (They may fail to do so due to a few outlying or high-leverage points: this is just the luck of the draw, not a counterexample!)
For instance, I simulated data that were drawn independently from a uniform distribution, a Gamma(3,2) distribution, another uniform distribution supported on [1,2], a J-shaped Beta distribution (Beta(1/10, 3)), and a Normal distribution (N(1/2, 1)). Here are the results after 5,000 samples were drawn:
Sure enough, all the smooths (red curves) are nondecreasing. (Well, there's a high-leverage point at the left in the X.1 vs X.2 plot that makes it look like the smooth might initially decrease slightly, but that's an artifact of this finite sample. That's why I characterized this simulation as an "imperfect" illustration.)
The R code to reproduce this figure follows.
n.data <- 5000
rvs <- c(runif,
function(n) rgamma(n, shape=3, rate=2),
function(n) runif(n, 1, 2),
function(n) rbeta(n, .1, 3),
function(n) rnorm(n, 1/2))
set.seed(17)
x <- data.frame(t(apply(sapply(rvs, function(f) f(n.data)), 1, sort)))
names(x) <- c("X.1", "X.2", "X.3", "X.4", "X.5")
panel.smooth <- function(x, y, ...) {
points(x,y, ...)
lines(lowess(x,y, f=.9), col="Red", lwd=2)
}
pairs(x, lower.panel=panel.smooth, cex=0.5, col="Gray")
|
Covariance of INID order statistics
|
It is known. We can even make a more precise and slightly stronger statement.
The following demonstration rests on two ideas. The first is that for any random variable $X$, the conditional expectati
|
Covariance of INID order statistics
It is known. We can even make a more precise and slightly stronger statement.
The following demonstration rests on two ideas. The first is that for any random variable $X$, the conditional expectation
$$\mathbb{E}[X | X \le t]$$
is a non-decreasing function of $t$. This is geometrically obvious: as $t$ increases, the integral extends over a region that is widening to the right, thereby shifting the expectation to the right.
The second idea concerns any joint random variables $(X,Y)$. A general way to study their relationship is to "slice" $X$ and study the average value of $Y$ within each slice. More formally, we can consider the conditional expectations
$$\nu(x) = \mathbb{E}[Y | X=x]$$
as a function of $x$. This function contains more information than the sign of the covariance or correlation, which only tells us whether this function increases or decreases on average. In particular, if $\nu$ is nondecreasing, then $\text{Cov}(X,Y) \ge 0$. (The converse is not true, which is why non-decrease of $\nu$ is a stronger condition than a non-negative covariance.)
To apply these ideas, let $X_{(i)}, 1\le i \le n,$ be order statistics for $n$ independent (but not necessarily identically distributed) random variables. Pick $1 \le i \lt j \le n$ for further study. Because $X_{(i)}\le X_{(j)}$ (by their very definition), the condition $X_{(i)} \le X_{(j)} | X_{(j)} = t$ is equivalent to $X_{(i)} | X_{(i)} \le t$. The first idea now informs us that the expected value of $X_{(i)} | X_{(j)}$ is nondecreasing with respect to the value of $X_{(j)}$. Letting $X_{(i)}$ play the role of $X$ and $X_{(j)}$ the role of $Y$ in the second idea implies $\text{Cov}(X_{(i)}, X_{(j)}) \ge 0$, QED.
(It is possible for such covariances to equal zero. This will happen whenever the variables have no overlaps in their ranges, for instance, for then the order statistics coincide with the variables, whence they are independent, whence all their covariances must vanish.)
An imperfect illustration of these ideas is afforded by a simulation in which the sampling is repeated thousands of times and a scatterplot matrix is drawn showing the $(X_{(i)}, X_{(j)})$ pairs. These scatterplots approximate the true bivariate distributions of the order statistics. The preceding demonstration asserts that all reasonable smooths of the scatterplots in the lower diagonal of the matrix will be non-decreasing curves. (They may fail to do so due to a few outlying or high-leverage points: this is just the luck of the draw, not a counterexample!)
For instance, I simulated data that were drawn independently from a uniform distribution, a Gamma(3,2) distribution, another uniform distribution supported on [1,2], a J-shaped Beta distribution (Beta(1/10, 3)), and a Normal distribution (N(1/2, 1)). Here are the results after 5,000 samples were drawn:
Sure enough, all the smooths (red curves) are nondecreasing. (Well, there's a high-leverage point at the left in the X.1 vs X.2 plot that makes it look like the smooth might initially decrease slightly, but that's an artifact of this finite sample. That's why I characterized this simulation as an "imperfect" illustration.)
The R code to reproduce this figure follows.
n.data <- 5000
rvs <- c(runif,
function(n) rgamma(n, shape=3, rate=2),
function(n) runif(n, 1, 2),
function(n) rbeta(n, .1, 3),
function(n) rnorm(n, 1/2))
set.seed(17)
x <- data.frame(t(apply(sapply(rvs, function(f) f(n.data)), 1, sort)))
names(x) <- c("X.1", "X.2", "X.3", "X.4", "X.5")
panel.smooth <- function(x, y, ...) {
points(x,y, ...)
lines(lowess(x,y, f=.9), col="Red", lwd=2)
}
pairs(x, lower.panel=panel.smooth, cex=0.5, col="Gray")
|
Covariance of INID order statistics
It is known. We can even make a more precise and slightly stronger statement.
The following demonstration rests on two ideas. The first is that for any random variable $X$, the conditional expectati
|
40,116
|
Number of trees for Random Forest optimization using recursive feature elimination
|
Optimizing ntree and mtry (above mtry=sqrt(#features) and ntree large enough for stabilization of OOB) is a dangerous area -- you need hard core nested cross-validation to be safe from overfitting, so you may end up doing more computations that you are trying to avoid.
I would say the better idea is not to use RFE -- with 200k features it will have terrible requirements and a minor chance to be stable. Instead, you can use some all-relevant RF wrapper like ACE or Boruta -- the set returned is likely to be larger than minimal-optimal, but still way smaller then the original and thus easier to be treated with RFE.
And remember to validate the feature selection regardless of the method (=
|
Number of trees for Random Forest optimization using recursive feature elimination
|
Optimizing ntree and mtry (above mtry=sqrt(#features) and ntree large enough for stabilization of OOB) is a dangerous area -- you need hard core nested cross-validation to be safe from overfitting, so
|
Number of trees for Random Forest optimization using recursive feature elimination
Optimizing ntree and mtry (above mtry=sqrt(#features) and ntree large enough for stabilization of OOB) is a dangerous area -- you need hard core nested cross-validation to be safe from overfitting, so you may end up doing more computations that you are trying to avoid.
I would say the better idea is not to use RFE -- with 200k features it will have terrible requirements and a minor chance to be stable. Instead, you can use some all-relevant RF wrapper like ACE or Boruta -- the set returned is likely to be larger than minimal-optimal, but still way smaller then the original and thus easier to be treated with RFE.
And remember to validate the feature selection regardless of the method (=
|
Number of trees for Random Forest optimization using recursive feature elimination
Optimizing ntree and mtry (above mtry=sqrt(#features) and ntree large enough for stabilization of OOB) is a dangerous area -- you need hard core nested cross-validation to be safe from overfitting, so
|
40,117
|
Number of trees for Random Forest optimization using recursive feature elimination
|
I'm actually doing an experiment with this right now. I work in text classification, so my training set is typically on the order of several hundred thousand features, and I'm looking at comparing a linear SVM (optimized for the c-parameter) against the weka implementation of random forests. I'm finding that, for my data, about 74 trees, and 32 features, thus far, seems to give pretty good performance. Of course, increasing these values tends to increase the AUC I observe, but it's in the thousandths digit place, generally. I'm still trying to understand how this algorithm is handling my data, but I suspect, based on the Breiman paper, that the more generally-useful features there are in your training set, the less important the number of trees parameter becomes. If you read the paper (and it's a really great paper), each tree consists of a random sampling of the features in your data, so, if there are a great many helpful ones in your set, you're more likely to find something useful in any particular tree. That said, I think it's always a good idea to optimize an algorithm for one's particular data. For my experiments, I've set aside a training/optimization set on which I am performing cross-validation across different parameter values. I'd be interested to hear what you find!
|
Number of trees for Random Forest optimization using recursive feature elimination
|
I'm actually doing an experiment with this right now. I work in text classification, so my training set is typically on the order of several hundred thousand features, and I'm looking at comparing a l
|
Number of trees for Random Forest optimization using recursive feature elimination
I'm actually doing an experiment with this right now. I work in text classification, so my training set is typically on the order of several hundred thousand features, and I'm looking at comparing a linear SVM (optimized for the c-parameter) against the weka implementation of random forests. I'm finding that, for my data, about 74 trees, and 32 features, thus far, seems to give pretty good performance. Of course, increasing these values tends to increase the AUC I observe, but it's in the thousandths digit place, generally. I'm still trying to understand how this algorithm is handling my data, but I suspect, based on the Breiman paper, that the more generally-useful features there are in your training set, the less important the number of trees parameter becomes. If you read the paper (and it's a really great paper), each tree consists of a random sampling of the features in your data, so, if there are a great many helpful ones in your set, you're more likely to find something useful in any particular tree. That said, I think it's always a good idea to optimize an algorithm for one's particular data. For my experiments, I've set aside a training/optimization set on which I am performing cross-validation across different parameter values. I'd be interested to hear what you find!
|
Number of trees for Random Forest optimization using recursive feature elimination
I'm actually doing an experiment with this right now. I work in text classification, so my training set is typically on the order of several hundred thousand features, and I'm looking at comparing a l
|
40,118
|
What is the difference between AdaBoost.M2, AdaBoost.M1, Gentle AdaBoost, RealAdaboost and the Original Adaboost?
|
A Survey of several of the variants can be found in the paper,
'Survey on Boosting Algorithms for Supervised and Semi-supervised Learning,' Artur Ferreira.
Generally, the Original AdaBoost returns the binary valued class that is the ensemble sign result of several combined models.
Real AdaBoost returns a real valued probability of class membership.
The other variants are covered in the paper, but less frequently mentioned in common literature. As I understand it, Gentle Adaboost produces a more stable ensemble model.
The AdaBoost.M1 and AdaBoost.M2 models are extensions to multi-class classifications (with M2 overcoming a restriction on the maximum error weights of classifiers from M1).
"Experiments with a New Boosting Algorithm," Yoav Freund and Robert E. Schapire.
|
What is the difference between AdaBoost.M2, AdaBoost.M1, Gentle AdaBoost, RealAdaboost and the Origi
|
A Survey of several of the variants can be found in the paper,
'Survey on Boosting Algorithms for Supervised and Semi-supervised Learning,' Artur Ferreira.
Generally, the Original AdaBoost returns the
|
What is the difference between AdaBoost.M2, AdaBoost.M1, Gentle AdaBoost, RealAdaboost and the Original Adaboost?
A Survey of several of the variants can be found in the paper,
'Survey on Boosting Algorithms for Supervised and Semi-supervised Learning,' Artur Ferreira.
Generally, the Original AdaBoost returns the binary valued class that is the ensemble sign result of several combined models.
Real AdaBoost returns a real valued probability of class membership.
The other variants are covered in the paper, but less frequently mentioned in common literature. As I understand it, Gentle Adaboost produces a more stable ensemble model.
The AdaBoost.M1 and AdaBoost.M2 models are extensions to multi-class classifications (with M2 overcoming a restriction on the maximum error weights of classifiers from M1).
"Experiments with a New Boosting Algorithm," Yoav Freund and Robert E. Schapire.
|
What is the difference between AdaBoost.M2, AdaBoost.M1, Gentle AdaBoost, RealAdaboost and the Origi
A Survey of several of the variants can be found in the paper,
'Survey on Boosting Algorithms for Supervised and Semi-supervised Learning,' Artur Ferreira.
Generally, the Original AdaBoost returns the
|
40,119
|
How to calculate power (or sample size) for a multiple comparison experiment?
|
If you have already done the experiment then there is little point in doing any power analyses. Where the P-values are small the power for the observed effect size and variability was large enough. Where the P-values are large then the power was small for the observed effect size and variability. Power analysis is useful for planning experiments, but not useful after the fact. See this paper by Hoenig & Helsey: http://www.tandfonline.com/doi/abs/10.1198/000313001300339897#preview
Your desire for a power analysis appears to be based on this statement "one must be sure that the results are 'real' and not just due to the small sample size", and so it is useful to consider it closely. Firstly, statistical analysis cannot tell you about the reality of a result--something that you probably know, given that you put the 'real' in quotes. Second, you imply that a small sample is more likely to yield a false positive result, when the reality is that a small sample is exactly as likely to do that as a large sample. The small sample is more likely to yield a false negative result.
If you want to be confident that the results yield reliable conclusions then you have to consider their nature in light of what is known about the system and, ideally, replicate the parts of the study that are most interesting or surprising. (I acknowledge that a well-judged statistical analysis is more helpful here than a poorly judged one: see Julien Sturnemann's answer for some suggestions.)
|
How to calculate power (or sample size) for a multiple comparison experiment?
|
If you have already done the experiment then there is little point in doing any power analyses. Where the P-values are small the power for the observed effect size and variability was large enough. Wh
|
How to calculate power (or sample size) for a multiple comparison experiment?
If you have already done the experiment then there is little point in doing any power analyses. Where the P-values are small the power for the observed effect size and variability was large enough. Where the P-values are large then the power was small for the observed effect size and variability. Power analysis is useful for planning experiments, but not useful after the fact. See this paper by Hoenig & Helsey: http://www.tandfonline.com/doi/abs/10.1198/000313001300339897#preview
Your desire for a power analysis appears to be based on this statement "one must be sure that the results are 'real' and not just due to the small sample size", and so it is useful to consider it closely. Firstly, statistical analysis cannot tell you about the reality of a result--something that you probably know, given that you put the 'real' in quotes. Second, you imply that a small sample is more likely to yield a false positive result, when the reality is that a small sample is exactly as likely to do that as a large sample. The small sample is more likely to yield a false negative result.
If you want to be confident that the results yield reliable conclusions then you have to consider their nature in light of what is known about the system and, ideally, replicate the parts of the study that are most interesting or surprising. (I acknowledge that a well-judged statistical analysis is more helpful here than a poorly judged one: see Julien Sturnemann's answer for some suggestions.)
|
How to calculate power (or sample size) for a multiple comparison experiment?
If you have already done the experiment then there is little point in doing any power analyses. Where the P-values are small the power for the observed effect size and variability was large enough. Wh
|
40,120
|
How to calculate power (or sample size) for a multiple comparison experiment?
|
I came upon your post and I really didn't know if my answer will be of any help to you because it would actually require to reconsider the whole analysis. However: your problem appears to be purely related to data-mining since you are actually trying to uncover the number and centers of latent clusters of individuals within your data without supervision (i.e. without an outcome variable that would easily allow you to separate these categories of individuals). There are several methods you might want to consider for unsupervised classification. Most of these will allow you to estimate the number of groups, the centroid as well as a measure of robustness and uncertainty. You can look at k-means methods and hierarchical clustering methods for a start. You may also consider visualizing your data using principal components before you consider statistical inference.
|
How to calculate power (or sample size) for a multiple comparison experiment?
|
I came upon your post and I really didn't know if my answer will be of any help to you because it would actually require to reconsider the whole analysis. However: your problem appears to be purely re
|
How to calculate power (or sample size) for a multiple comparison experiment?
I came upon your post and I really didn't know if my answer will be of any help to you because it would actually require to reconsider the whole analysis. However: your problem appears to be purely related to data-mining since you are actually trying to uncover the number and centers of latent clusters of individuals within your data without supervision (i.e. without an outcome variable that would easily allow you to separate these categories of individuals). There are several methods you might want to consider for unsupervised classification. Most of these will allow you to estimate the number of groups, the centroid as well as a measure of robustness and uncertainty. You can look at k-means methods and hierarchical clustering methods for a start. You may also consider visualizing your data using principal components before you consider statistical inference.
|
How to calculate power (or sample size) for a multiple comparison experiment?
I came upon your post and I really didn't know if my answer will be of any help to you because it would actually require to reconsider the whole analysis. However: your problem appears to be purely re
|
40,121
|
Understanding the output of lme
|
I will assume that the modeling assumptions you made are correct and you ran the program properly since your question only addresses the interpretation of the output.
In a linear model involving a single covariate, you can test for a linear association either by testing whether the slope coefficient is 0 or not or by testing that the Pearson correlation between the response and the covariate is 0 or not.
You tested the slope coefficient and got a small slope that is positive. The test for that coefficient being 0 had a p-value of 0.0166. If that p-value is below your desired significance level, you would conclude that there is some relationship between the covariate and response. Using a traditional significance level of 0.05, you would then reject the null hypothesis that there is no relationship. However, the slope appears to be small and the intercept is the dominant term in the model. Saying that the correlation is not zero is not the same as saying that the correlation is strong. You should look at say a 95% confidence interval for the correlation and think about what its upper bound is telling. If a strong correlation to you is, say, around 0.6 and the upper bound is, say, 0.1, this suggests that the correlation though probably greater than 0 is not strong.
Addressing your second question, if the p-value is not below your significance level, you don't conclude anything. What you know is that the data did not supply enough evidence that the correlation is different from 0. This could be because it is 0 or very close to 0. But more importantly, it could be that the sample size is not large enough to reach the conclusion that it is different from 0. Now if you instead address the issue of strong correlation and 0.6 is your definition of strong then it may be the case that the upper bound of the 95% confidence interval for the Pearson correlation is below (perhaps far below) 0.6 and you can still claim at least that the correlation is not strong. Understand that testing for strong correlation is different than testing for non-zero correlation and the p-value in your output address the latter test in my previous sentence and not the former.
|
Understanding the output of lme
|
I will assume that the modeling assumptions you made are correct and you ran the program properly since your question only addresses the interpretation of the output.
In a linear model involving a sin
|
Understanding the output of lme
I will assume that the modeling assumptions you made are correct and you ran the program properly since your question only addresses the interpretation of the output.
In a linear model involving a single covariate, you can test for a linear association either by testing whether the slope coefficient is 0 or not or by testing that the Pearson correlation between the response and the covariate is 0 or not.
You tested the slope coefficient and got a small slope that is positive. The test for that coefficient being 0 had a p-value of 0.0166. If that p-value is below your desired significance level, you would conclude that there is some relationship between the covariate and response. Using a traditional significance level of 0.05, you would then reject the null hypothesis that there is no relationship. However, the slope appears to be small and the intercept is the dominant term in the model. Saying that the correlation is not zero is not the same as saying that the correlation is strong. You should look at say a 95% confidence interval for the correlation and think about what its upper bound is telling. If a strong correlation to you is, say, around 0.6 and the upper bound is, say, 0.1, this suggests that the correlation though probably greater than 0 is not strong.
Addressing your second question, if the p-value is not below your significance level, you don't conclude anything. What you know is that the data did not supply enough evidence that the correlation is different from 0. This could be because it is 0 or very close to 0. But more importantly, it could be that the sample size is not large enough to reach the conclusion that it is different from 0. Now if you instead address the issue of strong correlation and 0.6 is your definition of strong then it may be the case that the upper bound of the 95% confidence interval for the Pearson correlation is below (perhaps far below) 0.6 and you can still claim at least that the correlation is not strong. Understand that testing for strong correlation is different than testing for non-zero correlation and the p-value in your output address the latter test in my previous sentence and not the former.
|
Understanding the output of lme
I will assume that the modeling assumptions you made are correct and you ran the program properly since your question only addresses the interpretation of the output.
In a linear model involving a sin
|
40,122
|
Understanding the output of lme
|
A further clarification. Your question asks whether this test provides evidence of a linear relation. In fact, linearity is an assumption of the model - the model does not test for linearity. Therefore, it is possible that the relationship between variables is, in fact, non-linear. In this case, the model could either show an effect or fail to show the effect.
So, going back to your question - taking into account what has already been posted here - the low p-value (high t-value) provides evidence of a relationship between your variables, but does not say anything about whether the relationship is linear or not (because this was assumed, rather than explicitly tested).
|
Understanding the output of lme
|
A further clarification. Your question asks whether this test provides evidence of a linear relation. In fact, linearity is an assumption of the model - the model does not test for linearity. Therefor
|
Understanding the output of lme
A further clarification. Your question asks whether this test provides evidence of a linear relation. In fact, linearity is an assumption of the model - the model does not test for linearity. Therefore, it is possible that the relationship between variables is, in fact, non-linear. In this case, the model could either show an effect or fail to show the effect.
So, going back to your question - taking into account what has already been posted here - the low p-value (high t-value) provides evidence of a relationship between your variables, but does not say anything about whether the relationship is linear or not (because this was assumed, rather than explicitly tested).
|
Understanding the output of lme
A further clarification. Your question asks whether this test provides evidence of a linear relation. In fact, linearity is an assumption of the model - the model does not test for linearity. Therefor
|
40,123
|
Identify different periods of variance in a time series
|
There is a lot of literature for testing the change in mean. If it is known that mean does not change, and you need to test the variance, you can convert the problem of testing for change in variance to the one of testing for change in mean with simple transformation.
Suppose your initial data is $X_i$, then define $Y_i=(X_i-\mu)^2$, where $\mu$ is the mean. Then the change in mean of $Y_i$, $EY_i=E(X_i-\mu)^2=Var(X_i)$ will be a change of variance in $X_i$.
|
Identify different periods of variance in a time series
|
There is a lot of literature for testing the change in mean. If it is known that mean does not change, and you need to test the variance, you can convert the problem of testing for change in variance
|
Identify different periods of variance in a time series
There is a lot of literature for testing the change in mean. If it is known that mean does not change, and you need to test the variance, you can convert the problem of testing for change in variance to the one of testing for change in mean with simple transformation.
Suppose your initial data is $X_i$, then define $Y_i=(X_i-\mu)^2$, where $\mu$ is the mean. Then the change in mean of $Y_i$, $EY_i=E(X_i-\mu)^2=Var(X_i)$ will be a change of variance in $X_i$.
|
Identify different periods of variance in a time series
There is a lot of literature for testing the change in mean. If it is known that mean does not change, and you need to test the variance, you can convert the problem of testing for change in variance
|
40,124
|
Identify different periods of variance in a time series
|
The changepoint package in R has a cpt.var function that can calculate changes in variance. There are two tests in that function one for data that can be assumed to be Normal distributed (default option dist="Normal") and one for nonparametric testing (option dist="CSS"). The CSS approach is Cumulative Sum of Squares and is detailed in Inclan & Tiao (1994) paper - further details in ?cpt.var.
Whilst you could square your data (as mpiktas points out in an answer) this can actually inhibit detection of changepoints where the change is small. Think of it, if you square a value that is greater than 1 it gets bigger but if it is smaller than 1 it gets smaller.
|
Identify different periods of variance in a time series
|
The changepoint package in R has a cpt.var function that can calculate changes in variance. There are two tests in that function one for data that can be assumed to be Normal distributed (default opt
|
Identify different periods of variance in a time series
The changepoint package in R has a cpt.var function that can calculate changes in variance. There are two tests in that function one for data that can be assumed to be Normal distributed (default option dist="Normal") and one for nonparametric testing (option dist="CSS"). The CSS approach is Cumulative Sum of Squares and is detailed in Inclan & Tiao (1994) paper - further details in ?cpt.var.
Whilst you could square your data (as mpiktas points out in an answer) this can actually inhibit detection of changepoints where the change is small. Think of it, if you square a value that is greater than 1 it gets bigger but if it is smaller than 1 it gets smaller.
|
Identify different periods of variance in a time series
The changepoint package in R has a cpt.var function that can calculate changes in variance. There are two tests in that function one for data that can be assumed to be Normal distributed (default opt
|
40,125
|
Identify different periods of variance in a time series
|
Variance change in a time series is discussed in http://www.unc.edu/~jbhill/tsay.pdf . This feature has been added to software available from http:..www.autobox.com. I am involved in the development/incorporation of this very important feature which has neen apparently ignored by SAS,SPSS and others.
|
Identify different periods of variance in a time series
|
Variance change in a time series is discussed in http://www.unc.edu/~jbhill/tsay.pdf . This feature has been added to software available from http:..www.autobox.com. I am involved in the development/i
|
Identify different periods of variance in a time series
Variance change in a time series is discussed in http://www.unc.edu/~jbhill/tsay.pdf . This feature has been added to software available from http:..www.autobox.com. I am involved in the development/incorporation of this very important feature which has neen apparently ignored by SAS,SPSS and others.
|
Identify different periods of variance in a time series
Variance change in a time series is discussed in http://www.unc.edu/~jbhill/tsay.pdf . This feature has been added to software available from http:..www.autobox.com. I am involved in the development/i
|
40,126
|
Identify different periods of variance in a time series
|
You can do this using the mcp package, provided you know the number of segments in advance:
model = list(
price ~ 1 + sigma(1), # Intercept and variance
~ 0 + sigma(1), # Change in variance, but not in mean
~ 0 + sigma(1) # same
)
library(mcp)
fit = mcp(model, df, par_x = "time")
You can infer the time at which these changes take place on top of slopes etc. as well. See more in the mcp article on modeling variance.
|
Identify different periods of variance in a time series
|
You can do this using the mcp package, provided you know the number of segments in advance:
model = list(
price ~ 1 + sigma(1), # Intercept and variance
~ 0 + sigma(1), # Change in variance,
|
Identify different periods of variance in a time series
You can do this using the mcp package, provided you know the number of segments in advance:
model = list(
price ~ 1 + sigma(1), # Intercept and variance
~ 0 + sigma(1), # Change in variance, but not in mean
~ 0 + sigma(1) # same
)
library(mcp)
fit = mcp(model, df, par_x = "time")
You can infer the time at which these changes take place on top of slopes etc. as well. See more in the mcp article on modeling variance.
|
Identify different periods of variance in a time series
You can do this using the mcp package, provided you know the number of segments in advance:
model = list(
price ~ 1 + sigma(1), # Intercept and variance
~ 0 + sigma(1), # Change in variance,
|
40,127
|
Equivalent of Kolmogorov-Smirnov test for integer data?
|
The Permutation test could be applied here as well. The idea is as follows.
Let $X_1,...,X_m\sim F$ and $Y_1,...,Y_n\sim G$ be two independent samples and consider testing the hypothesis $H_0:F=G$ vs. $H_1:F\neq G$. For this purpose, label your data as follows
\begin{array}{c c}
1 & X_1\\
1 & X_2\\
\vdots & \vdots\\
1 & X_m\\
2 & Y_1\\
2 & Y_2\\
\vdots & \vdots\\
2 & Y_n\\
\end{array}
Now, let $T$ be an statistic of the sample $S=\{X_1,...,X_m,Y_1,...,Y_n\}$ and the labels $L=\{1,1,...,2,2,...,2\}$.
If $H_0$ is true, then the labeling is superfluous.
Now, permute the group labels and recalculate the test statistic a large number of times, say $B$.
The one-sided p-value of this test is calculated as the proportion of sampled permutations where the difference in means was greater than or equal to $T(S,L)$. The two-sided p-value of the test is calculated as the proportion of sampled permutations where the absolute difference was greater than or equal to $\mbox{abs}(T(S,L))$. See
A toy example
Let $X_i \sim \text{Poisson}(10)$, $i=1,...,m=100$, and $Y_j \sim \text{Poisson}(11)$, $j=1,...,n=100$. Consider the statistic $T=\text{mean of Group 1} - \text{mean of Group 2}$. The permutation method using this statistic is implemented below.
rm(list=ls)
set.seed(1)
# Sample size
ns=100
#Simulated data
x = rpois(ns,11)
y = rpois(ns,10)
# Observed statistic
T.obs = mean(x) - mean(y)
# Pooled data
SL = rbind(cbind(rep(1,ns),x),cbind(rep(2,ns),y))
# Resampling
B=10000
T = rep(0,B)
for(i in 1:B){
samp = sample(SL[,1])
ind1 = which(samp==1)
ind2 = which(samp==2)
T[i] = mean( SL[ind1,2] )- mean( SL[ind2,2] )
}
# p-value
p.value = length(which(abs(T)>abs(T.obs)))/B
I do not know how robust is this method, but after some experiments it seems to perform moderately well. Note that the choice of the statitic $T$ is open and therefore one must be careful on making a meaningful choice in the context of your problem as the performance depends on both the statistic and the sample size.
I hope this helps.
|
Equivalent of Kolmogorov-Smirnov test for integer data?
|
The Permutation test could be applied here as well. The idea is as follows.
Let $X_1,...,X_m\sim F$ and $Y_1,...,Y_n\sim G$ be two independent samples and consider testing the hypothesis $H_0:F=G$ vs.
|
Equivalent of Kolmogorov-Smirnov test for integer data?
The Permutation test could be applied here as well. The idea is as follows.
Let $X_1,...,X_m\sim F$ and $Y_1,...,Y_n\sim G$ be two independent samples and consider testing the hypothesis $H_0:F=G$ vs. $H_1:F\neq G$. For this purpose, label your data as follows
\begin{array}{c c}
1 & X_1\\
1 & X_2\\
\vdots & \vdots\\
1 & X_m\\
2 & Y_1\\
2 & Y_2\\
\vdots & \vdots\\
2 & Y_n\\
\end{array}
Now, let $T$ be an statistic of the sample $S=\{X_1,...,X_m,Y_1,...,Y_n\}$ and the labels $L=\{1,1,...,2,2,...,2\}$.
If $H_0$ is true, then the labeling is superfluous.
Now, permute the group labels and recalculate the test statistic a large number of times, say $B$.
The one-sided p-value of this test is calculated as the proportion of sampled permutations where the difference in means was greater than or equal to $T(S,L)$. The two-sided p-value of the test is calculated as the proportion of sampled permutations where the absolute difference was greater than or equal to $\mbox{abs}(T(S,L))$. See
A toy example
Let $X_i \sim \text{Poisson}(10)$, $i=1,...,m=100$, and $Y_j \sim \text{Poisson}(11)$, $j=1,...,n=100$. Consider the statistic $T=\text{mean of Group 1} - \text{mean of Group 2}$. The permutation method using this statistic is implemented below.
rm(list=ls)
set.seed(1)
# Sample size
ns=100
#Simulated data
x = rpois(ns,11)
y = rpois(ns,10)
# Observed statistic
T.obs = mean(x) - mean(y)
# Pooled data
SL = rbind(cbind(rep(1,ns),x),cbind(rep(2,ns),y))
# Resampling
B=10000
T = rep(0,B)
for(i in 1:B){
samp = sample(SL[,1])
ind1 = which(samp==1)
ind2 = which(samp==2)
T[i] = mean( SL[ind1,2] )- mean( SL[ind2,2] )
}
# p-value
p.value = length(which(abs(T)>abs(T.obs)))/B
I do not know how robust is this method, but after some experiments it seems to perform moderately well. Note that the choice of the statitic $T$ is open and therefore one must be careful on making a meaningful choice in the context of your problem as the performance depends on both the statistic and the sample size.
I hope this helps.
|
Equivalent of Kolmogorov-Smirnov test for integer data?
The Permutation test could be applied here as well. The idea is as follows.
Let $X_1,...,X_m\sim F$ and $Y_1,...,Y_n\sim G$ be two independent samples and consider testing the hypothesis $H_0:F=G$ vs.
|
40,128
|
Equivalent of Kolmogorov-Smirnov test for integer data?
|
I would suggest the two sample chi square test where you bin the data and compare the binned total with an "expected number" that would fall within the binbased on the pooled sample. This has a generalization to k greater than 2. I am assuming that you are not requiring another test of the emprical cdf form. I think that entire class of test could have some trouble when there are a lot of ties.
Here is a reference that shows you precisely how the two-sample chi square test statistic is calculated along with the degrees of freedom for the asymptotic chi square distirbution.
|
Equivalent of Kolmogorov-Smirnov test for integer data?
|
I would suggest the two sample chi square test where you bin the data and compare the binned total with an "expected number" that would fall within the binbased on the pooled sample. This has a gener
|
Equivalent of Kolmogorov-Smirnov test for integer data?
I would suggest the two sample chi square test where you bin the data and compare the binned total with an "expected number" that would fall within the binbased on the pooled sample. This has a generalization to k greater than 2. I am assuming that you are not requiring another test of the emprical cdf form. I think that entire class of test could have some trouble when there are a lot of ties.
Here is a reference that shows you precisely how the two-sample chi square test statistic is calculated along with the degrees of freedom for the asymptotic chi square distirbution.
|
Equivalent of Kolmogorov-Smirnov test for integer data?
I would suggest the two sample chi square test where you bin the data and compare the binned total with an "expected number" that would fall within the binbased on the pooled sample. This has a gener
|
40,129
|
A problem in probability theory
|
You will need the following simple result.
Lemma. If $\mathrm{Var}[Z]=0$, then $Z=\mathrm{E}[Z]$, almost surely.
Proof (check cardinal's comment for a contrapositive argument). It is easy to check that
$$
\left\{ Z = \mathrm{E}[Z] \right\} = \bigcap_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| < \frac{1}{n} \right\} \, .
$$
By Tchebyshev's inequality, we have
$$
P \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} \leq n^2 \mathrm{Var}[Z] = 0 \, ,
$$
for every $n\geq 1$. Hence, using De Morgan's identity and the subadditivity of $P$, we have
$$
P\left\{ Z = \mathrm{E}[Z] \right\} = 1 - P\left(\bigcup_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\}\right) \geq 1 - \sum_{n\geq 1} P\left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} = 1 \, ,
$$
as desired.
Using the hints given by cardinal and whuber, you have what you need.
Proposition. If $X$ and $Y$ are integrable random variables such that $$\mathrm{Var}[X] = \mathrm{Var}[Y]=\mathrm{Cov}[X,Y] \, ,$$ then $X=Y+c$, almost surely, where the constant $c=\mathrm{E}[X]-\mathrm{E}[Y]$.
Proof. Defining $Z=X-Y$, the formula for the variance of the difference of two random variables gives
$$
\mathrm{Var}[Z]=\mathrm{Var}[X]+\mathrm{Var}[Y]-2\,\mathrm{Cov}[X,Y] = 2\,\mathrm{Cov}[X,Y] -2\,\mathrm{Cov}[X,Y] = 0 \, .
$$
The Lemma yields the desired result, since $\mathrm{E}[Z]=\mathrm{E}[X-Y]=\mathrm{E}[X]-\mathrm{E}[Y]$.
|
A problem in probability theory
|
You will need the following simple result.
Lemma. If $\mathrm{Var}[Z]=0$, then $Z=\mathrm{E}[Z]$, almost surely.
Proof (check cardinal's comment for a contrapositive argument). It is easy to check tha
|
A problem in probability theory
You will need the following simple result.
Lemma. If $\mathrm{Var}[Z]=0$, then $Z=\mathrm{E}[Z]$, almost surely.
Proof (check cardinal's comment for a contrapositive argument). It is easy to check that
$$
\left\{ Z = \mathrm{E}[Z] \right\} = \bigcap_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| < \frac{1}{n} \right\} \, .
$$
By Tchebyshev's inequality, we have
$$
P \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} \leq n^2 \mathrm{Var}[Z] = 0 \, ,
$$
for every $n\geq 1$. Hence, using De Morgan's identity and the subadditivity of $P$, we have
$$
P\left\{ Z = \mathrm{E}[Z] \right\} = 1 - P\left(\bigcup_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\}\right) \geq 1 - \sum_{n\geq 1} P\left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} = 1 \, ,
$$
as desired.
Using the hints given by cardinal and whuber, you have what you need.
Proposition. If $X$ and $Y$ are integrable random variables such that $$\mathrm{Var}[X] = \mathrm{Var}[Y]=\mathrm{Cov}[X,Y] \, ,$$ then $X=Y+c$, almost surely, where the constant $c=\mathrm{E}[X]-\mathrm{E}[Y]$.
Proof. Defining $Z=X-Y$, the formula for the variance of the difference of two random variables gives
$$
\mathrm{Var}[Z]=\mathrm{Var}[X]+\mathrm{Var}[Y]-2\,\mathrm{Cov}[X,Y] = 2\,\mathrm{Cov}[X,Y] -2\,\mathrm{Cov}[X,Y] = 0 \, .
$$
The Lemma yields the desired result, since $\mathrm{E}[Z]=\mathrm{E}[X-Y]=\mathrm{E}[X]-\mathrm{E}[Y]$.
|
A problem in probability theory
You will need the following simple result.
Lemma. If $\mathrm{Var}[Z]=0$, then $Z=\mathrm{E}[Z]$, almost surely.
Proof (check cardinal's comment for a contrapositive argument). It is easy to check tha
|
40,130
|
Confusion regarding correlation and mse
|
I suggest we look at the definitions.
$$ MSE = \frac{1}{n-2}\sum_{i=1}^n (Y_i -\hat{Y}_i)^2. $$
Again, by definition
$$ \hat{Y}_i = r\frac{S_y}{S_x}(X_i - \bar{X}) + \bar{Y}, $$
so
$$SSE = \sum_{i=1}^n \left( (Y_i - \bar{Y}) - r\frac{S_y}{S_x}(X_i - \bar{X}) \right) ^2 = (n-1)S_y^2 + (n-1)r^2S_y^2 - 2(n-1)r^2S_y^2,$$
so that
$$ MSE = \frac{n-1}{n-2}S_y^2 \left(1-r^2\right).$$
MSE depends on $r^2$, and as you mentioned, the lower the correlation, the higher MSE, but as you can see it depends as well on the variance of the response variable $S_y^2$. Actually, this is expected, because MSE has a unit (the square of the unit of $Y$) and the coefficient of correltion does not. For that reason you cannot usually compare MSE of different regressions models (for the same reason you cannot compare km2 and kg2).
Also note that multiplying the values of $Y$ by 10 would not change the coefficient of correlation between $Y$ and $X$ (what I think you call your ground truth), but it would multiply MSE by 100.
In short, you can use MSE to compare different predictors (the name of "ground truths" in regression models) to model the same response variable, but you cannot use MSE to compare different response variables modeled by the same predictor.
Update: after looking at your data directly (thanks for sending) I computed the following measures with complete cases (the ones where all three variables are observed which is only 163 out of 5,374,625):
$$MSE(Y_1|Y_3) = 0.00275; cor(Y1,Y3) = 0.85 \\
MSE(Y_2|Y_3) = 0.0208; cor(Y2, Y3) = 0.61$$
On the other hand, when taking only the pairwise complete cases needed for the computation I obtained the following:
$$MSE(Y1|Y3) = 0.00323; cor(Y2, Y3) = 0.766 \; (n=464) \\
MSE(Y2|Y3) = 0.0117; cor(Y2, Y3) = 0.785 \; (n=1280)$$
Notice how the correlation changes when taken on different datasets (and the order actually changes). Even though I believe that the upper part of my answer is correct, @whuber is right in his comment that you cannot draw any conclusion if your measures are taken on different datasets.
|
Confusion regarding correlation and mse
|
I suggest we look at the definitions.
$$ MSE = \frac{1}{n-2}\sum_{i=1}^n (Y_i -\hat{Y}_i)^2. $$
Again, by definition
$$ \hat{Y}_i = r\frac{S_y}{S_x}(X_i - \bar{X}) + \bar{Y}, $$
so
$$SSE = \sum_{i=1}^
|
Confusion regarding correlation and mse
I suggest we look at the definitions.
$$ MSE = \frac{1}{n-2}\sum_{i=1}^n (Y_i -\hat{Y}_i)^2. $$
Again, by definition
$$ \hat{Y}_i = r\frac{S_y}{S_x}(X_i - \bar{X}) + \bar{Y}, $$
so
$$SSE = \sum_{i=1}^n \left( (Y_i - \bar{Y}) - r\frac{S_y}{S_x}(X_i - \bar{X}) \right) ^2 = (n-1)S_y^2 + (n-1)r^2S_y^2 - 2(n-1)r^2S_y^2,$$
so that
$$ MSE = \frac{n-1}{n-2}S_y^2 \left(1-r^2\right).$$
MSE depends on $r^2$, and as you mentioned, the lower the correlation, the higher MSE, but as you can see it depends as well on the variance of the response variable $S_y^2$. Actually, this is expected, because MSE has a unit (the square of the unit of $Y$) and the coefficient of correltion does not. For that reason you cannot usually compare MSE of different regressions models (for the same reason you cannot compare km2 and kg2).
Also note that multiplying the values of $Y$ by 10 would not change the coefficient of correlation between $Y$ and $X$ (what I think you call your ground truth), but it would multiply MSE by 100.
In short, you can use MSE to compare different predictors (the name of "ground truths" in regression models) to model the same response variable, but you cannot use MSE to compare different response variables modeled by the same predictor.
Update: after looking at your data directly (thanks for sending) I computed the following measures with complete cases (the ones where all three variables are observed which is only 163 out of 5,374,625):
$$MSE(Y_1|Y_3) = 0.00275; cor(Y1,Y3) = 0.85 \\
MSE(Y_2|Y_3) = 0.0208; cor(Y2, Y3) = 0.61$$
On the other hand, when taking only the pairwise complete cases needed for the computation I obtained the following:
$$MSE(Y1|Y3) = 0.00323; cor(Y2, Y3) = 0.766 \; (n=464) \\
MSE(Y2|Y3) = 0.0117; cor(Y2, Y3) = 0.785 \; (n=1280)$$
Notice how the correlation changes when taken on different datasets (and the order actually changes). Even though I believe that the upper part of my answer is correct, @whuber is right in his comment that you cannot draw any conclusion if your measures are taken on different datasets.
|
Confusion regarding correlation and mse
I suggest we look at the definitions.
$$ MSE = \frac{1}{n-2}\sum_{i=1}^n (Y_i -\hat{Y}_i)^2. $$
Again, by definition
$$ \hat{Y}_i = r\frac{S_y}{S_x}(X_i - \bar{X}) + \bar{Y}, $$
so
$$SSE = \sum_{i=1}^
|
40,131
|
Confusion regarding correlation and mse
|
Correlation: The degree or extent to which variables are linearly related is called the correlation among variables.
MSE: If $T$ be an estimator of $\theta$. $MSE(T)$ is a measure of the spread of the values of $T$ around $\theta$
These two are different so don't be confused
|
Confusion regarding correlation and mse
|
Correlation: The degree or extent to which variables are linearly related is called the correlation among variables.
MSE: If $T$ be an estimator of $\theta$. $MSE(T)$ is a measure of the spread of the
|
Confusion regarding correlation and mse
Correlation: The degree or extent to which variables are linearly related is called the correlation among variables.
MSE: If $T$ be an estimator of $\theta$. $MSE(T)$ is a measure of the spread of the values of $T$ around $\theta$
These two are different so don't be confused
|
Confusion regarding correlation and mse
Correlation: The degree or extent to which variables are linearly related is called the correlation among variables.
MSE: If $T$ be an estimator of $\theta$. $MSE(T)$ is a measure of the spread of the
|
40,132
|
What is the meaning of orthogonal in validation testing?
|
Basically, it would seem that people use orthogonal as a synonym for independent. So, for orthogonal validation read independent validation The validity of equating orthogonality with independence is discussed here such that "if X and Y are independent then they are Orthogonal" but "the converse is not true".
|
What is the meaning of orthogonal in validation testing?
|
Basically, it would seem that people use orthogonal as a synonym for independent. So, for orthogonal validation read independent validation The validity of equating orthogonality with independence is
|
What is the meaning of orthogonal in validation testing?
Basically, it would seem that people use orthogonal as a synonym for independent. So, for orthogonal validation read independent validation The validity of equating orthogonality with independence is discussed here such that "if X and Y are independent then they are Orthogonal" but "the converse is not true".
|
What is the meaning of orthogonal in validation testing?
Basically, it would seem that people use orthogonal as a synonym for independent. So, for orthogonal validation read independent validation The validity of equating orthogonality with independence is
|
40,133
|
What is the meaning of orthogonal in validation testing?
|
An orthogonal method is an additional method that provides very different selectivity to the primary method. The orthogonal method can be used to evaluate the primary method. For example, two methods can be used to investigate protein aggregation 1) size-exclusion chromatograph or an orthogonal method such as 2) analytical ultracentrifugation. Both methods are independent approaches that can answer a question such as "is my protein aggregated?"
|
What is the meaning of orthogonal in validation testing?
|
An orthogonal method is an additional method that provides very different selectivity to the primary method. The orthogonal method can be used to evaluate the primary method. For example, two methods
|
What is the meaning of orthogonal in validation testing?
An orthogonal method is an additional method that provides very different selectivity to the primary method. The orthogonal method can be used to evaluate the primary method. For example, two methods can be used to investigate protein aggregation 1) size-exclusion chromatograph or an orthogonal method such as 2) analytical ultracentrifugation. Both methods are independent approaches that can answer a question such as "is my protein aggregated?"
|
What is the meaning of orthogonal in validation testing?
An orthogonal method is an additional method that provides very different selectivity to the primary method. The orthogonal method can be used to evaluate the primary method. For example, two methods
|
40,134
|
What is the meaning of orthogonal in validation testing?
|
This "orthogonal" word is rather fashionable part of slang in recent EMA/FDA guidelines. Literary means that something crossed at right angle, so more intuitively understood substitute is "cross-over methodology" i.e. two essentially different methods used to measure the same value ("crossing-point"), so the measurement is reliable. Latin rules again :-)
|
What is the meaning of orthogonal in validation testing?
|
This "orthogonal" word is rather fashionable part of slang in recent EMA/FDA guidelines. Literary means that something crossed at right angle, so more intuitively understood substitute is "cross-over
|
What is the meaning of orthogonal in validation testing?
This "orthogonal" word is rather fashionable part of slang in recent EMA/FDA guidelines. Literary means that something crossed at right angle, so more intuitively understood substitute is "cross-over methodology" i.e. two essentially different methods used to measure the same value ("crossing-point"), so the measurement is reliable. Latin rules again :-)
|
What is the meaning of orthogonal in validation testing?
This "orthogonal" word is rather fashionable part of slang in recent EMA/FDA guidelines. Literary means that something crossed at right angle, so more intuitively understood substitute is "cross-over
|
40,135
|
What is the meaning of orthogonal in validation testing?
|
Orthogonal means independent in loose sense. It sounds different in different contexts and technical fields. like in signal processing orthogonal signals means the signals with zero correlation.
But in the contest of testing (validation and verification of embedded software or hardware), preparing and testing more than one functionality at the same time which are independent. say for example we have a system with 3 subsystems in it with set of inputs a1,a2 for subsystem A and out put A1, b1,b2,b3 as inputs to subsystem B with outputs B1 and B2, and c1,c2,and B2 as inputs to Subsystem C with output C1. In this case subsystem A and B are independent and C is dependent on the output of Subsystem B. So, we can test the functionality of the Subsystem A and B in parallel that will save time instead of testing functionality of the subsystem A and then B. Here part of the subsystem C also be tested with the same test sequence done for the B. So very rational part of the subsystem C is has to be tested. With clear understanding of the functionality of the subsystem C, we can test the entire system with minimal number of test cases this is called orthogonal testing in general.
In-case of hardware IO calibration, It is more quite easy, instead of testing the hardware IO's one by one, we can calibrate the independent IOs at the same time. for example if an ECU has 20 sensor inputs, if there is no dependency among these IOs, then all can be calibrated with a single test ( test duration might be different, but sure it will save 90 to 98 of total time required to calibrate independently)
From my understanding this is more efficient for unit testing, system testing with more independent subsystems/functions. As the number of dependent functions in the system increases then the efficiency of time spent to create orthogonal arrays increases than the robustness testing.
|
What is the meaning of orthogonal in validation testing?
|
Orthogonal means independent in loose sense. It sounds different in different contexts and technical fields. like in signal processing orthogonal signals means the signals with zero correlation.
But
|
What is the meaning of orthogonal in validation testing?
Orthogonal means independent in loose sense. It sounds different in different contexts and technical fields. like in signal processing orthogonal signals means the signals with zero correlation.
But in the contest of testing (validation and verification of embedded software or hardware), preparing and testing more than one functionality at the same time which are independent. say for example we have a system with 3 subsystems in it with set of inputs a1,a2 for subsystem A and out put A1, b1,b2,b3 as inputs to subsystem B with outputs B1 and B2, and c1,c2,and B2 as inputs to Subsystem C with output C1. In this case subsystem A and B are independent and C is dependent on the output of Subsystem B. So, we can test the functionality of the Subsystem A and B in parallel that will save time instead of testing functionality of the subsystem A and then B. Here part of the subsystem C also be tested with the same test sequence done for the B. So very rational part of the subsystem C is has to be tested. With clear understanding of the functionality of the subsystem C, we can test the entire system with minimal number of test cases this is called orthogonal testing in general.
In-case of hardware IO calibration, It is more quite easy, instead of testing the hardware IO's one by one, we can calibrate the independent IOs at the same time. for example if an ECU has 20 sensor inputs, if there is no dependency among these IOs, then all can be calibrated with a single test ( test duration might be different, but sure it will save 90 to 98 of total time required to calibrate independently)
From my understanding this is more efficient for unit testing, system testing with more independent subsystems/functions. As the number of dependent functions in the system increases then the efficiency of time spent to create orthogonal arrays increases than the robustness testing.
|
What is the meaning of orthogonal in validation testing?
Orthogonal means independent in loose sense. It sounds different in different contexts and technical fields. like in signal processing orthogonal signals means the signals with zero correlation.
But
|
40,136
|
Confidence interval for the height of a histogram bar
|
Let there be $i \in 1, \dots, I$ histogram bins. The probability of falling into a particular bin is $p_i$. This is just a binomial trial (i.e., you are either in the bin or not, each with a given probability).
If you are calculating the frequency of being in the bin (i.e., histograms with bars giving the set of $p_i$'s), then the variance should be $p_i(1-p_i)/k$.
If you are calculating total counts, then the variance is $p_i(1-p_i) \times k$.
The confidence interval can then be formed in the standard way.
|
Confidence interval for the height of a histogram bar
|
Let there be $i \in 1, \dots, I$ histogram bins. The probability of falling into a particular bin is $p_i$. This is just a binomial trial (i.e., you are either in the bin or not, each with a given pro
|
Confidence interval for the height of a histogram bar
Let there be $i \in 1, \dots, I$ histogram bins. The probability of falling into a particular bin is $p_i$. This is just a binomial trial (i.e., you are either in the bin or not, each with a given probability).
If you are calculating the frequency of being in the bin (i.e., histograms with bars giving the set of $p_i$'s), then the variance should be $p_i(1-p_i)/k$.
If you are calculating total counts, then the variance is $p_i(1-p_i) \times k$.
The confidence interval can then be formed in the standard way.
|
Confidence interval for the height of a histogram bar
Let there be $i \in 1, \dots, I$ histogram bins. The probability of falling into a particular bin is $p_i$. This is just a binomial trial (i.e., you are either in the bin or not, each with a given pro
|
40,137
|
Confidence interval for the height of a histogram bar
|
Using the binomial variance $p (1-p) k$, as proposed in another answer, is only a good idea when the proportion is not near 0 or 1.
For better-behaved confidence intervals, there is extensive statistical literature e.g. Agresti & Coull (1998). Some of the proposed formulae are implemented in the R library PropCIs. Here's an example creating a histogram with error bars using PropCIs: Errorbars on histograms
|
Confidence interval for the height of a histogram bar
|
Using the binomial variance $p (1-p) k$, as proposed in another answer, is only a good idea when the proportion is not near 0 or 1.
For better-behaved confidence intervals, there is extensive statist
|
Confidence interval for the height of a histogram bar
Using the binomial variance $p (1-p) k$, as proposed in another answer, is only a good idea when the proportion is not near 0 or 1.
For better-behaved confidence intervals, there is extensive statistical literature e.g. Agresti & Coull (1998). Some of the proposed formulae are implemented in the R library PropCIs. Here's an example creating a histogram with error bars using PropCIs: Errorbars on histograms
|
Confidence interval for the height of a histogram bar
Using the binomial variance $p (1-p) k$, as proposed in another answer, is only a good idea when the proportion is not near 0 or 1.
For better-behaved confidence intervals, there is extensive statist
|
40,138
|
Calculate number of needed simulations
|
I try to summarize all answers by you in order to have a single place for everything important.
Steps to calculate the needed number of simulations:
Run the simulation with a default number of runs $R_0$. I've seen $R_0 = 1000$ most of the times. Now you should have a vector with the results $x_0$ where $length(x_0) = R_0$.
Calculate the mean value $\overline{x}_0$ and the standard deviation $s_0$.
Specify the allowed level of error $\epsilon$ and the uncertainty $\alpha$ you are willing to accept. Normally you choose $\epsilon = \alpha = 0.05\%$.
Use this equation to get the required number of simulations:
$R \geq (\frac{Z_{1-(\alpha / 2)} \cdot s_0}{\epsilon \cdot \overline{x}_0})^2$, where $Z_{1-(\alpha / 2)}$ is the $1 β (\alpha /2)$ quantile of the standard normal distribution.
[Use the student-t-distribution rather than the normal distribution for small $R_0$]
I hope this will help everybody who will look for an answer.
|
Calculate number of needed simulations
|
I try to summarize all answers by you in order to have a single place for everything important.
Steps to calculate the needed number of simulations:
Run the simulation with a default number of runs $
|
Calculate number of needed simulations
I try to summarize all answers by you in order to have a single place for everything important.
Steps to calculate the needed number of simulations:
Run the simulation with a default number of runs $R_0$. I've seen $R_0 = 1000$ most of the times. Now you should have a vector with the results $x_0$ where $length(x_0) = R_0$.
Calculate the mean value $\overline{x}_0$ and the standard deviation $s_0$.
Specify the allowed level of error $\epsilon$ and the uncertainty $\alpha$ you are willing to accept. Normally you choose $\epsilon = \alpha = 0.05\%$.
Use this equation to get the required number of simulations:
$R \geq (\frac{Z_{1-(\alpha / 2)} \cdot s_0}{\epsilon \cdot \overline{x}_0})^2$, where $Z_{1-(\alpha / 2)}$ is the $1 β (\alpha /2)$ quantile of the standard normal distribution.
[Use the student-t-distribution rather than the normal distribution for small $R_0$]
I hope this will help everybody who will look for an answer.
|
Calculate number of needed simulations
I try to summarize all answers by you in order to have a single place for everything important.
Steps to calculate the needed number of simulations:
Run the simulation with a default number of runs $
|
40,139
|
Calculate number of needed simulations
|
This question is more difficult to answer than you imagine. It depends on the input, the output and degree of precision required on the output. One thing to do is add say $100$ simulations to the current number and if the results seem not to have changed much there could be sufficient convergence. If not keep going until you converge. This assumes that as the input distributions become representative the output distribution will be well represented or if the output is a estimate it will have come close to converging to its expected value. The simplest case is when the output is a single proportion that is a binomial proportion. Then the variance for the output has variance bounded by $\frac{1}{4n}$ where $n$ is the number of simulations. Then you can take n large enough so that the variance of the estimator is as small as you would require. This may seem like an unusual situation. But it comes up a lot when comparing estimation technique. For example I have done simulations to compare bootstrap confidence interval methods. To see if the actual confidence level close to what it is suppose to be we simulate sampling from a particular population distribution and compute the proportion of times the interval includes the true parameter. We might want the standard deviation of the estimate to be less than say $0.001$. This can be achieved since the standard deviation is the square root of the variance and is less than $\frac{1}{2 \sqrt{n}}$ So this will be achieved if we take $n> \frac{4}{(0.001)^2}$.
|
Calculate number of needed simulations
|
This question is more difficult to answer than you imagine. It depends on the input, the output and degree of precision required on the output. One thing to do is add say $100$ simulations to the cu
|
Calculate number of needed simulations
This question is more difficult to answer than you imagine. It depends on the input, the output and degree of precision required on the output. One thing to do is add say $100$ simulations to the current number and if the results seem not to have changed much there could be sufficient convergence. If not keep going until you converge. This assumes that as the input distributions become representative the output distribution will be well represented or if the output is a estimate it will have come close to converging to its expected value. The simplest case is when the output is a single proportion that is a binomial proportion. Then the variance for the output has variance bounded by $\frac{1}{4n}$ where $n$ is the number of simulations. Then you can take n large enough so that the variance of the estimator is as small as you would require. This may seem like an unusual situation. But it comes up a lot when comparing estimation technique. For example I have done simulations to compare bootstrap confidence interval methods. To see if the actual confidence level close to what it is suppose to be we simulate sampling from a particular population distribution and compute the proportion of times the interval includes the true parameter. We might want the standard deviation of the estimate to be less than say $0.001$. This can be achieved since the standard deviation is the square root of the variance and is less than $\frac{1}{2 \sqrt{n}}$ So this will be achieved if we take $n> \frac{4}{(0.001)^2}$.
|
Calculate number of needed simulations
This question is more difficult to answer than you imagine. It depends on the input, the output and degree of precision required on the output. One thing to do is add say $100$ simulations to the cu
|
40,140
|
Calculate number of needed simulations
|
Powerbar, this answer is to address your last comment. Perhaps you can think of your simulation as representing a model for fuel consumption as a function of % minivans on the road plus a random noise component. So every time you run the simulation you get a slightly distorted picture of the curve because of the additive noise component. Each simulation is giving you at various % minivans simulated the value of the function + a random component. If the simulations are independent and the random components are independent (a very reasonable assumption) then averaging the values at each % minivan will improve the estimate of the "actual" fuel consumption value because the average reduces the variance of the noise by a factor of 1/n at each point. In your case choosing 5 reduces it by a factor of 1/5. The standard deviation is reduced by a factor of 1/sqrt(5) or 1/2.236. So the variation from the curve is 2.236 times smaller for the averaged data. Had you used 3 or 4 it would have helped also but not as much. For n larger than 5 would help even more but may not be necessary since your eye saw satisfactory smoothness.
|
Calculate number of needed simulations
|
Powerbar, this answer is to address your last comment. Perhaps you can think of your simulation as representing a model for fuel consumption as a function of % minivans on the road plus a random nois
|
Calculate number of needed simulations
Powerbar, this answer is to address your last comment. Perhaps you can think of your simulation as representing a model for fuel consumption as a function of % minivans on the road plus a random noise component. So every time you run the simulation you get a slightly distorted picture of the curve because of the additive noise component. Each simulation is giving you at various % minivans simulated the value of the function + a random component. If the simulations are independent and the random components are independent (a very reasonable assumption) then averaging the values at each % minivan will improve the estimate of the "actual" fuel consumption value because the average reduces the variance of the noise by a factor of 1/n at each point. In your case choosing 5 reduces it by a factor of 1/5. The standard deviation is reduced by a factor of 1/sqrt(5) or 1/2.236. So the variation from the curve is 2.236 times smaller for the averaged data. Had you used 3 or 4 it would have helped also but not as much. For n larger than 5 would help even more but may not be necessary since your eye saw satisfactory smoothness.
|
Calculate number of needed simulations
Powerbar, this answer is to address your last comment. Perhaps you can think of your simulation as representing a model for fuel consumption as a function of % minivans on the road plus a random nois
|
40,141
|
Differencing an i.i.d. time series
|
If I understand your comments correctly, you've overdifferenced, which is talked about in various guides.
EDIT:
Your original series of numbers (rnorm(5000, 0, 40)) has, by definition and design, no relationship between adjacent numbers or every 2nd number or every 3rd number. It's "random" (pseudo-random, but not distinguishable from truly random by us mere mortals). So the ACF you calculate is random garbage.
But differencing takes that series of numbers and creates a new series which is related in a particular, deterministic way: subtraction of adjacent values. Consider your initial random number series: $(n_1, n_2, n_3, ...)$, then difference it to get $(d_1, d_2, ...)$. Both $d_1$ and $d_2$ are calculated using $n_2$, so you've now introduced autocorrelation at lag 1.
Now look at what happens at that lag 1. $n_2$ is used to calculate $d_1$ and $d_2$, once subtracting from and once being subtracted from. [Begin I'm-way-in-over-my-head part.] In order for $d_1$ and $d_2$ to have the same sign, we'd need to have $n_1 < n_2$ and $n_2 < n_3$ (or vice versa), which is less likely than the alternatives, so we expect that the autocorrelation will be negative. [End I'm-way-in-over-my-head part, gasping for air.]
|
Differencing an i.i.d. time series
|
If I understand your comments correctly, you've overdifferenced, which is talked about in various guides.
EDIT:
Your original series of numbers (rnorm(5000, 0, 40)) has, by definition and design, no
|
Differencing an i.i.d. time series
If I understand your comments correctly, you've overdifferenced, which is talked about in various guides.
EDIT:
Your original series of numbers (rnorm(5000, 0, 40)) has, by definition and design, no relationship between adjacent numbers or every 2nd number or every 3rd number. It's "random" (pseudo-random, but not distinguishable from truly random by us mere mortals). So the ACF you calculate is random garbage.
But differencing takes that series of numbers and creates a new series which is related in a particular, deterministic way: subtraction of adjacent values. Consider your initial random number series: $(n_1, n_2, n_3, ...)$, then difference it to get $(d_1, d_2, ...)$. Both $d_1$ and $d_2$ are calculated using $n_2$, so you've now introduced autocorrelation at lag 1.
Now look at what happens at that lag 1. $n_2$ is used to calculate $d_1$ and $d_2$, once subtracting from and once being subtracted from. [Begin I'm-way-in-over-my-head part.] In order for $d_1$ and $d_2$ to have the same sign, we'd need to have $n_1 < n_2$ and $n_2 < n_3$ (or vice versa), which is less likely than the alternatives, so we expect that the autocorrelation will be negative. [End I'm-way-in-over-my-head part, gasping for air.]
|
Differencing an i.i.d. time series
If I understand your comments correctly, you've overdifferenced, which is talked about in various guides.
EDIT:
Your original series of numbers (rnorm(5000, 0, 40)) has, by definition and design, no
|
40,142
|
Differencing an i.i.d. time series
|
It is a little late ..... but , review the Slutsky Effect where a linear (weighted ) combinations of i.i.d. values leads to a series with auto-correlative structure. This is why assuming any filter picket out of the blue can be dangerous. X11-ARIMA assumes a 16 period equally weighted average ( you can change 16 to another integer ) to smooth the series not knowing the impact of assumed filters. Long live analytics !
|
Differencing an i.i.d. time series
|
It is a little late ..... but , review the Slutsky Effect where a linear (weighted ) combinations of i.i.d. values leads to a series with auto-correlative structure. This is why assuming any filter pi
|
Differencing an i.i.d. time series
It is a little late ..... but , review the Slutsky Effect where a linear (weighted ) combinations of i.i.d. values leads to a series with auto-correlative structure. This is why assuming any filter picket out of the blue can be dangerous. X11-ARIMA assumes a 16 period equally weighted average ( you can change 16 to another integer ) to smooth the series not knowing the impact of assumed filters. Long live analytics !
|
Differencing an i.i.d. time series
It is a little late ..... but , review the Slutsky Effect where a linear (weighted ) combinations of i.i.d. values leads to a series with auto-correlative structure. This is why assuming any filter pi
|
40,143
|
Expectation of an estimator?
|
An estimator is not a parameter, but a random variable. Basically, your estimate depends on the sample which is random, and this makes your estimate a realisation of a random variable called estimator.
|
Expectation of an estimator?
|
An estimator is not a parameter, but a random variable. Basically, your estimate depends on the sample which is random, and this makes your estimate a realisation of a random variable called estimator
|
Expectation of an estimator?
An estimator is not a parameter, but a random variable. Basically, your estimate depends on the sample which is random, and this makes your estimate a realisation of a random variable called estimator.
|
Expectation of an estimator?
An estimator is not a parameter, but a random variable. Basically, your estimate depends on the sample which is random, and this makes your estimate a realisation of a random variable called estimator
|
40,144
|
Understanding Odds Ratios in Logistic Regression
|
If you're using the equation you list below your code, I think you're OK. It's true that the numbers inside that equation are log odds, but once you've solved for $\text{Pr}(Y=1)$, you do have a probability. As far as I can tell, you are not misinterpreting your results.
|
Understanding Odds Ratios in Logistic Regression
|
If you're using the equation you list below your code, I think you're OK. It's true that the numbers inside that equation are log odds, but once you've solved for $\text{Pr}(Y=1)$, you do have a prob
|
Understanding Odds Ratios in Logistic Regression
If you're using the equation you list below your code, I think you're OK. It's true that the numbers inside that equation are log odds, but once you've solved for $\text{Pr}(Y=1)$, you do have a probability. As far as I can tell, you are not misinterpreting your results.
|
Understanding Odds Ratios in Logistic Regression
If you're using the equation you list below your code, I think you're OK. It's true that the numbers inside that equation are log odds, but once you've solved for $\text{Pr}(Y=1)$, you do have a prob
|
40,145
|
Understanding Odds Ratios in Logistic Regression
|
I think it depends on what you mean with interpreting. If you are trying to understand whether the equation for $Pr(Y=1)$ is correct, then I would say yes.
If you want to find an interpretation of the equation itself, then you should consider odds ratios; a unital increase of bid (here you have no problem in fixing all the other covariates!) implies an odds ratio increase of $\exp(0.002)>1$.
I would not try to do the same with the "log-odds" though. The above interpretation is already quite explicit and widely used.
|
Understanding Odds Ratios in Logistic Regression
|
I think it depends on what you mean with interpreting. If you are trying to understand whether the equation for $Pr(Y=1)$ is correct, then I would say yes.
If you want to find an interpretation of the
|
Understanding Odds Ratios in Logistic Regression
I think it depends on what you mean with interpreting. If you are trying to understand whether the equation for $Pr(Y=1)$ is correct, then I would say yes.
If you want to find an interpretation of the equation itself, then you should consider odds ratios; a unital increase of bid (here you have no problem in fixing all the other covariates!) implies an odds ratio increase of $\exp(0.002)>1$.
I would not try to do the same with the "log-odds" though. The above interpretation is already quite explicit and widely used.
|
Understanding Odds Ratios in Logistic Regression
I think it depends on what you mean with interpreting. If you are trying to understand whether the equation for $Pr(Y=1)$ is correct, then I would say yes.
If you want to find an interpretation of the
|
40,146
|
What is the probability of rolling all faces of a die after n number of rolls
|
So you want to know the probability of getting all the faces at least once after rolling the die $n$ times. It is convenient to introduce the number $N_k$ of faces that have been seen after $k$ steps. Obviously, we have $N_1=1$. Also, $N_{k+1}=N_k$ with probability $\frac{N_k}{6}$ and $N_{k+1}=N_k+1$ otherwise -- in other words, the process $\{ N_k \}_{k \geq 1}$ is an Markov chain. One can thus easily compute the vector $V_k=(\mathbb{P}[N_k=1],\mathbb{P}[N_k=2], \ldots, \mathbb{P}[N_k=6])$ for $k=1,2, \ldots$ and solve the problem. One finds $V_{n+1} = V_0 \, A^{n}$ where $V_0=(1,0,\ldots,0)$ and $A$ is the transition matrix of the Markov chain:
$$A = \begin{pmatrix}
1/6 &5/6 &0 &0 &0 &0 \\
0 &2/6 &4/6 &0 &0 &0\\
0 &0 &3/6 &3/6 &0 &0 \\
0 &0 &0 &4/6 &2/6 &0 \\
0 &0 &0 &0 &5/6 &1/6\\
0 &0 &0 &0 &0 &1
\end{pmatrix}$$
To find $V_n$, diagonalize $A$ and then compute the powers. This gives
$$V_{n+1} = \frac{1}{6^{n+1}}\begin{pmatrix}1\\-5\\10\\-10\\5\\1\end{pmatrix}^{tr}
\begin{pmatrix}
6^n &0 &0 &0 &0 &0 \\
0 &5^n &0 &0 &0 &0 \\
0 &0 &4^n &0 &0 &0 \\
0 &0 &0 &3^n &0 &0 \\
0 &0 &0 &0 &2^n &0\\
0 &0 &0 &0 &0 &1
\end{pmatrix}
\begin{pmatrix}
0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 & -1 & 1 \\
0 & 0 & 0 & 1 & -2 & 1 \\
0 & 0 & -1 & 3 & -3 & 1 \\
0 & 1 & -4 & 6 & -4 & 1 \\
-1 & 5 & -10 & 10 & -5 & 1
\end{pmatrix}
$$
For example, after rolling a die 7 times, set $n=6$ in the preceding formula to get
$$V_7 = \begin{pmatrix}6,1890,36120,126000,100800,15120\end{pmatrix} / 6^7$$
From left to right, these are the chances of having observed exactly 1, 2, ..., through 6 faces. The chance of having seen all 6 faces is the last entry, $15120/6^7 = 35/648 \approx 0.054$. In general, the last entry of $V_{n+1}$ equals
$$\Pr[\text{All faces seen after } n+1 \text{ throws}] = 1-5\ 2^{2-n}+5\ 3^{1-n}(1+2^n)-6^{1-n}(1+5^n).$$
|
What is the probability of rolling all faces of a die after n number of rolls
|
So you want to know the probability of getting all the faces at least once after rolling the die $n$ times. It is convenient to introduce the number $N_k$ of faces that have been seen after $k$ steps.
|
What is the probability of rolling all faces of a die after n number of rolls
So you want to know the probability of getting all the faces at least once after rolling the die $n$ times. It is convenient to introduce the number $N_k$ of faces that have been seen after $k$ steps. Obviously, we have $N_1=1$. Also, $N_{k+1}=N_k$ with probability $\frac{N_k}{6}$ and $N_{k+1}=N_k+1$ otherwise -- in other words, the process $\{ N_k \}_{k \geq 1}$ is an Markov chain. One can thus easily compute the vector $V_k=(\mathbb{P}[N_k=1],\mathbb{P}[N_k=2], \ldots, \mathbb{P}[N_k=6])$ for $k=1,2, \ldots$ and solve the problem. One finds $V_{n+1} = V_0 \, A^{n}$ where $V_0=(1,0,\ldots,0)$ and $A$ is the transition matrix of the Markov chain:
$$A = \begin{pmatrix}
1/6 &5/6 &0 &0 &0 &0 \\
0 &2/6 &4/6 &0 &0 &0\\
0 &0 &3/6 &3/6 &0 &0 \\
0 &0 &0 &4/6 &2/6 &0 \\
0 &0 &0 &0 &5/6 &1/6\\
0 &0 &0 &0 &0 &1
\end{pmatrix}$$
To find $V_n$, diagonalize $A$ and then compute the powers. This gives
$$V_{n+1} = \frac{1}{6^{n+1}}\begin{pmatrix}1\\-5\\10\\-10\\5\\1\end{pmatrix}^{tr}
\begin{pmatrix}
6^n &0 &0 &0 &0 &0 \\
0 &5^n &0 &0 &0 &0 \\
0 &0 &4^n &0 &0 &0 \\
0 &0 &0 &3^n &0 &0 \\
0 &0 &0 &0 &2^n &0\\
0 &0 &0 &0 &0 &1
\end{pmatrix}
\begin{pmatrix}
0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 & -1 & 1 \\
0 & 0 & 0 & 1 & -2 & 1 \\
0 & 0 & -1 & 3 & -3 & 1 \\
0 & 1 & -4 & 6 & -4 & 1 \\
-1 & 5 & -10 & 10 & -5 & 1
\end{pmatrix}
$$
For example, after rolling a die 7 times, set $n=6$ in the preceding formula to get
$$V_7 = \begin{pmatrix}6,1890,36120,126000,100800,15120\end{pmatrix} / 6^7$$
From left to right, these are the chances of having observed exactly 1, 2, ..., through 6 faces. The chance of having seen all 6 faces is the last entry, $15120/6^7 = 35/648 \approx 0.054$. In general, the last entry of $V_{n+1}$ equals
$$\Pr[\text{All faces seen after } n+1 \text{ throws}] = 1-5\ 2^{2-n}+5\ 3^{1-n}(1+2^n)-6^{1-n}(1+5^n).$$
|
What is the probability of rolling all faces of a die after n number of rolls
So you want to know the probability of getting all the faces at least once after rolling the die $n$ times. It is convenient to introduce the number $N_k$ of faces that have been seen after $k$ steps.
|
40,147
|
Algorithms for clustering documents by similar words and phrases
|
Right off the bat, you may want to look at various string distances. The only one I'm familiar with is the Levenshtein distance, which is pretty rudimentary. You could apply this on sentences or phrases.
You may want to take a look at some natural language processing techniques, too, such as stemming and tokenizing your data before running any clustering algorithms on it. If you like Python, I highly recommend nltk, which has lots of packages for natural language processing. It may even have a clustering or distance algorithm for you. A quick google gives me this package, but I've never used it.
Edit: Upon reflection, I might have misunderstood your question - are you clustering documents, or words/phrases?
|
Algorithms for clustering documents by similar words and phrases
|
Right off the bat, you may want to look at various string distances. The only one I'm familiar with is the Levenshtein distance, which is pretty rudimentary. You could apply this on sentences or phras
|
Algorithms for clustering documents by similar words and phrases
Right off the bat, you may want to look at various string distances. The only one I'm familiar with is the Levenshtein distance, which is pretty rudimentary. You could apply this on sentences or phrases.
You may want to take a look at some natural language processing techniques, too, such as stemming and tokenizing your data before running any clustering algorithms on it. If you like Python, I highly recommend nltk, which has lots of packages for natural language processing. It may even have a clustering or distance algorithm for you. A quick google gives me this package, but I've never used it.
Edit: Upon reflection, I might have misunderstood your question - are you clustering documents, or words/phrases?
|
Algorithms for clustering documents by similar words and phrases
Right off the bat, you may want to look at various string distances. The only one I'm familiar with is the Levenshtein distance, which is pretty rudimentary. You could apply this on sentences or phras
|
40,148
|
Algorithms for clustering documents by similar words and phrases
|
For pretty much any clustering algorithm that can work with such data, you will need to define a distance or similarity function first. So you might want to browse through the literature on appropriate distance functions for your task.
E.g. cosine distance on a TF-IDF normalized vector representation.
|
Algorithms for clustering documents by similar words and phrases
|
For pretty much any clustering algorithm that can work with such data, you will need to define a distance or similarity function first. So you might want to browse through the literature on appropriat
|
Algorithms for clustering documents by similar words and phrases
For pretty much any clustering algorithm that can work with such data, you will need to define a distance or similarity function first. So you might want to browse through the literature on appropriate distance functions for your task.
E.g. cosine distance on a TF-IDF normalized vector representation.
|
Algorithms for clustering documents by similar words and phrases
For pretty much any clustering algorithm that can work with such data, you will need to define a distance or similarity function first. So you might want to browse through the literature on appropriat
|
40,149
|
Mining search logs to improve autocomplete suggestions?
|
it is a matter of ordering correlations based on statistical significance, and generating enough data over time to define that significance. the noise (random correlations) will be filtered out as more people search for, and correlate, terms and characters.
auto-complete should return the top n results as a user is entering their query. initially, it might display 5 colloquial correlations and 5 random correlations (if n=10). these correlations will probably be weighted the same in the beginning as there may only be one correlation per term in your database (they might display alphabetically or randomly to your users). your correlations will build significance over time as users naturally select the more appropriate suggestions from auto-complete. as this happens, the less significant (read: random) correlations will sink to the bottom thus further reinforcing the significance of those at the top as they become relatively more visible to your users.
keep in mind that there is no shortcut to statistical significance. by nature, it requires a large enough sample set to exist in the first place.
|
Mining search logs to improve autocomplete suggestions?
|
it is a matter of ordering correlations based on statistical significance, and generating enough data over time to define that significance. the noise (random correlations) will be filtered out as mor
|
Mining search logs to improve autocomplete suggestions?
it is a matter of ordering correlations based on statistical significance, and generating enough data over time to define that significance. the noise (random correlations) will be filtered out as more people search for, and correlate, terms and characters.
auto-complete should return the top n results as a user is entering their query. initially, it might display 5 colloquial correlations and 5 random correlations (if n=10). these correlations will probably be weighted the same in the beginning as there may only be one correlation per term in your database (they might display alphabetically or randomly to your users). your correlations will build significance over time as users naturally select the more appropriate suggestions from auto-complete. as this happens, the less significant (read: random) correlations will sink to the bottom thus further reinforcing the significance of those at the top as they become relatively more visible to your users.
keep in mind that there is no shortcut to statistical significance. by nature, it requires a large enough sample set to exist in the first place.
|
Mining search logs to improve autocomplete suggestions?
it is a matter of ordering correlations based on statistical significance, and generating enough data over time to define that significance. the noise (random correlations) will be filtered out as mor
|
40,150
|
Mining search logs to improve autocomplete suggestions?
|
Interesting project. The technique that comes to mind my mind is association mining.
This technique can automatically discover many many patterns in data of this kind. It is often used in retail market research, where the question is "If a shopper bought 10 products, which of them were purchased 'together' and which just happen to be in the same basket?" For example, if everyone is buying bandages and anti-biotic ointment together, then I might want to put those products next to each other in the store.
The drawback is that this technique cannot capture the temporal information in your data, since it only looks at the basket of search queries made by a user, not their order.
I don't know much about mining temporal data, but perhaps someone who does can suggest a temporal form of association mining?
|
Mining search logs to improve autocomplete suggestions?
|
Interesting project. The technique that comes to mind my mind is association mining.
This technique can automatically discover many many patterns in data of this kind. It is often used in retail mark
|
Mining search logs to improve autocomplete suggestions?
Interesting project. The technique that comes to mind my mind is association mining.
This technique can automatically discover many many patterns in data of this kind. It is often used in retail market research, where the question is "If a shopper bought 10 products, which of them were purchased 'together' and which just happen to be in the same basket?" For example, if everyone is buying bandages and anti-biotic ointment together, then I might want to put those products next to each other in the store.
The drawback is that this technique cannot capture the temporal information in your data, since it only looks at the basket of search queries made by a user, not their order.
I don't know much about mining temporal data, but perhaps someone who does can suggest a temporal form of association mining?
|
Mining search logs to improve autocomplete suggestions?
Interesting project. The technique that comes to mind my mind is association mining.
This technique can automatically discover many many patterns in data of this kind. It is often used in retail mark
|
40,151
|
Mining search logs to improve autocomplete suggestions?
|
Is there a similarity measure that you can use for character names? Besides that, I feel that you will need some kind of feedback here: Basically, you need to prove or disprove every correlation (here: equivalence) that you are assuming from the data.
Imagine that a user enters A' to find character A, and then B' to find character B. If you assume that A' = B', you need to prove or disprove this. Why not presenting the next user that is searching for B' the character A first? And, vice versa, present a user looking for A' the B result as option. This, plus some machine-learning/clustering techniques I'm afraid I cannot tell you much about, should help you solve the problem.
|
Mining search logs to improve autocomplete suggestions?
|
Is there a similarity measure that you can use for character names? Besides that, I feel that you will need some kind of feedback here: Basically, you need to prove or disprove every correlation (here
|
Mining search logs to improve autocomplete suggestions?
Is there a similarity measure that you can use for character names? Besides that, I feel that you will need some kind of feedback here: Basically, you need to prove or disprove every correlation (here: equivalence) that you are assuming from the data.
Imagine that a user enters A' to find character A, and then B' to find character B. If you assume that A' = B', you need to prove or disprove this. Why not presenting the next user that is searching for B' the character A first? And, vice versa, present a user looking for A' the B result as option. This, plus some machine-learning/clustering techniques I'm afraid I cannot tell you much about, should help you solve the problem.
|
Mining search logs to improve autocomplete suggestions?
Is there a similarity measure that you can use for character names? Besides that, I feel that you will need some kind of feedback here: Basically, you need to prove or disprove every correlation (here
|
40,152
|
Simulating responses to a test for item-response theory
|
I've included a simdata() function in the mirt package in R for calculating simulated IRT data given a variety of know conditions for several different classes of uni- and multidimensional IRT models. So if you need something a little more flexible that may be a good place to look, and should save you from having to reinvent the wheel.
|
Simulating responses to a test for item-response theory
|
I've included a simdata() function in the mirt package in R for calculating simulated IRT data given a variety of know conditions for several different classes of uni- and multidimensional IRT models.
|
Simulating responses to a test for item-response theory
I've included a simdata() function in the mirt package in R for calculating simulated IRT data given a variety of know conditions for several different classes of uni- and multidimensional IRT models. So if you need something a little more flexible that may be a good place to look, and should save you from having to reinvent the wheel.
|
Simulating responses to a test for item-response theory
I've included a simdata() function in the mirt package in R for calculating simulated IRT data given a variety of know conditions for several different classes of uni- and multidimensional IRT models.
|
40,153
|
Simulating responses to a test for item-response theory
|
Here's a first version of this simulation in R, as an example of what NOT to do. Code untested.
# we're making a table of three columns: person, question, and correct or not
resps <- data.frame(person=integer(), question=integer(), correct=integer())
# do the simulation
for (qu in 1:nQ) { # loop over questions, nQ is number of questions
# how many possible answers does this question have? flip a coin with max_opts sides
opts <- sample.int(max_opts, 1)
for (pe in 1:nP) { # loop over test-takers, nP is number of test-takers
# did this person answer correctly? flip a coin with 1/opts probability of success
resp <- rbinom(1, 1, 1/opts)
resps <- rbind(resps, data.frame(person=pe, question=qu, correct=resp))
}
}
Here are some reasons that this is a bad idea:
it doesn't allow for missing responses
it assumes all people are of the same ability
it assumes all questions are of the same difficulty (given the number of answer options)
You could come up with a few more...
The point is that you want to have a feeling for who you're testing and what you're testing them on, and you want the latent properties of those people and questions to be reflected in your simulated data.
My advice would be to try to get some real humans to take your test for real. It might be pretty cheap and easy on Amazon Mechanical Turk.
|
Simulating responses to a test for item-response theory
|
Here's a first version of this simulation in R, as an example of what NOT to do. Code untested.
# we're making a table of three columns: person, question, and correct or not
resps <- data.frame(person
|
Simulating responses to a test for item-response theory
Here's a first version of this simulation in R, as an example of what NOT to do. Code untested.
# we're making a table of three columns: person, question, and correct or not
resps <- data.frame(person=integer(), question=integer(), correct=integer())
# do the simulation
for (qu in 1:nQ) { # loop over questions, nQ is number of questions
# how many possible answers does this question have? flip a coin with max_opts sides
opts <- sample.int(max_opts, 1)
for (pe in 1:nP) { # loop over test-takers, nP is number of test-takers
# did this person answer correctly? flip a coin with 1/opts probability of success
resp <- rbinom(1, 1, 1/opts)
resps <- rbind(resps, data.frame(person=pe, question=qu, correct=resp))
}
}
Here are some reasons that this is a bad idea:
it doesn't allow for missing responses
it assumes all people are of the same ability
it assumes all questions are of the same difficulty (given the number of answer options)
You could come up with a few more...
The point is that you want to have a feeling for who you're testing and what you're testing them on, and you want the latent properties of those people and questions to be reflected in your simulated data.
My advice would be to try to get some real humans to take your test for real. It might be pretty cheap and easy on Amazon Mechanical Turk.
|
Simulating responses to a test for item-response theory
Here's a first version of this simulation in R, as an example of what NOT to do. Code untested.
# we're making a table of three columns: person, question, and correct or not
resps <- data.frame(person
|
40,154
|
Simulating responses to a test for item-response theory
|
The easiest way to do what you want is probably to use the psych package for R. This includes functions such as sim.rasch and sim.irt which will simulate appropriate data of whatever size for you.
|
Simulating responses to a test for item-response theory
|
The easiest way to do what you want is probably to use the psych package for R. This includes functions such as sim.rasch and sim.irt which will simulate appropriate data of whatever size for you.
|
Simulating responses to a test for item-response theory
The easiest way to do what you want is probably to use the psych package for R. This includes functions such as sim.rasch and sim.irt which will simulate appropriate data of whatever size for you.
|
Simulating responses to a test for item-response theory
The easiest way to do what you want is probably to use the psych package for R. This includes functions such as sim.rasch and sim.irt which will simulate appropriate data of whatever size for you.
|
40,155
|
Simulating responses to a test for item-response theory
|
I know it is a bit too late, but for historical reasons I'd like to answer this question.
Simulating a CAT using an R package
Nowadays, the package catr is able to simulate CATs, which, it seems, is exactly what you want to do. It has a lot of options, like number of starting itens, selection method for the next item, configuration of stopping rule etc.
Here is an old bit of code I have in my computer. All credits go to the catr manual.
# call the catR package, if not installed then install it
if (!require('catR')) install.packages('catR')
require('catR')
# create a bank with 3PL items
Bank <- genDichoMatrix(items = 500, cbControl = NULL, model = "Rasch",
seed = 1)
# list of four parameters that characterize a CAT: start, test, stop, final
# these lists will feed the randomCAT function to generate a response pattern
# one first item selected, ability level starts at 0, criterion for
# selecting first items is maximum Fisher information
Start <- list(nrItems = 1, theta = 0, startSelect = "MFI")
# use weighted likelihood, select items through MFI (see previous comment)
Test <- list(method = "WL", itemSelect = "MFI")
# stopping rule by classication, meaning that the test will stop when the
# CI no longer holds the threshold inside it anymore
Stop <- list(rule = "precision", thr = 0.4, alpha = 0.05)
# how estimates of ability are calculated
Final <- list(method = "WL", alpha = 0.05)
# set true ability at 1, calls lists above
res <- randomCAT(trueTheta = rnorm(n=1,mean=0,sd=1), itemBank = Bank,
start = Start, test = Test,
stop = Stop, final = Final)
# plotting the response pattern
plot(res, ci = TRUE, trueTh = TRUE, classThr = 2)
Extra bit: extracting item parameters from response patterns
From the question, I realized you already had response patterns that you'd like to use to extract the item parameters (discrimination, difficulty, guessing factor etc). In order to do that, I recommend the mirt package, which does just that (and a lot more). You can find examples on how to use this package here and here.
The only extra work I predict you would have to do is convert mirt's output matrix to the input format that catr uses.
|
Simulating responses to a test for item-response theory
|
I know it is a bit too late, but for historical reasons I'd like to answer this question.
Simulating a CAT using an R package
Nowadays, the package catr is able to simulate CATs, which, it seems, is e
|
Simulating responses to a test for item-response theory
I know it is a bit too late, but for historical reasons I'd like to answer this question.
Simulating a CAT using an R package
Nowadays, the package catr is able to simulate CATs, which, it seems, is exactly what you want to do. It has a lot of options, like number of starting itens, selection method for the next item, configuration of stopping rule etc.
Here is an old bit of code I have in my computer. All credits go to the catr manual.
# call the catR package, if not installed then install it
if (!require('catR')) install.packages('catR')
require('catR')
# create a bank with 3PL items
Bank <- genDichoMatrix(items = 500, cbControl = NULL, model = "Rasch",
seed = 1)
# list of four parameters that characterize a CAT: start, test, stop, final
# these lists will feed the randomCAT function to generate a response pattern
# one first item selected, ability level starts at 0, criterion for
# selecting first items is maximum Fisher information
Start <- list(nrItems = 1, theta = 0, startSelect = "MFI")
# use weighted likelihood, select items through MFI (see previous comment)
Test <- list(method = "WL", itemSelect = "MFI")
# stopping rule by classication, meaning that the test will stop when the
# CI no longer holds the threshold inside it anymore
Stop <- list(rule = "precision", thr = 0.4, alpha = 0.05)
# how estimates of ability are calculated
Final <- list(method = "WL", alpha = 0.05)
# set true ability at 1, calls lists above
res <- randomCAT(trueTheta = rnorm(n=1,mean=0,sd=1), itemBank = Bank,
start = Start, test = Test,
stop = Stop, final = Final)
# plotting the response pattern
plot(res, ci = TRUE, trueTh = TRUE, classThr = 2)
Extra bit: extracting item parameters from response patterns
From the question, I realized you already had response patterns that you'd like to use to extract the item parameters (discrimination, difficulty, guessing factor etc). In order to do that, I recommend the mirt package, which does just that (and a lot more). You can find examples on how to use this package here and here.
The only extra work I predict you would have to do is convert mirt's output matrix to the input format that catr uses.
|
Simulating responses to a test for item-response theory
I know it is a bit too late, but for historical reasons I'd like to answer this question.
Simulating a CAT using an R package
Nowadays, the package catr is able to simulate CATs, which, it seems, is e
|
40,156
|
Convergence of a genetic algorithm
|
A simple and common test is to measure improvements in the objective functions: if you no longer improve (by a certain amount) over a set number of iterations, you may as well stop. Other optimisation algorithms use this approach too.
|
Convergence of a genetic algorithm
|
A simple and common test is to measure improvements in the objective functions: if you no longer improve (by a certain amount) over a set number of iterations, you may as well stop. Other optimisation
|
Convergence of a genetic algorithm
A simple and common test is to measure improvements in the objective functions: if you no longer improve (by a certain amount) over a set number of iterations, you may as well stop. Other optimisation algorithms use this approach too.
|
Convergence of a genetic algorithm
A simple and common test is to measure improvements in the objective functions: if you no longer improve (by a certain amount) over a set number of iterations, you may as well stop. Other optimisation
|
40,157
|
Convergence of a genetic algorithm
|
If you don't have any clue on the fitness landscape, i.e. existence of local optima, plateaus, valleys etc, it is hard to understand whether a GA (or other evolutionary algorithms, EAs) have found the global optima. You can use a multi-populations approach, e.g. an island-based GA, and then, with a specific migration strategy, check when all the population converge to the same solution. This is just a possible answer to your question, the problem of avoiding local optima it is a critical problem for EA design, especially in high-dimensionality.
|
Convergence of a genetic algorithm
|
If you don't have any clue on the fitness landscape, i.e. existence of local optima, plateaus, valleys etc, it is hard to understand whether a GA (or other evolutionary algorithms, EAs) have found the
|
Convergence of a genetic algorithm
If you don't have any clue on the fitness landscape, i.e. existence of local optima, plateaus, valleys etc, it is hard to understand whether a GA (or other evolutionary algorithms, EAs) have found the global optima. You can use a multi-populations approach, e.g. an island-based GA, and then, with a specific migration strategy, check when all the population converge to the same solution. This is just a possible answer to your question, the problem of avoiding local optima it is a critical problem for EA design, especially in high-dimensionality.
|
Convergence of a genetic algorithm
If you don't have any clue on the fitness landscape, i.e. existence of local optima, plateaus, valleys etc, it is hard to understand whether a GA (or other evolutionary algorithms, EAs) have found the
|
40,158
|
Convergence of a genetic algorithm
|
The inherent stochasticity of genetic algorithms is what makes them such a powerful tool, however, this property also makes it difficult to know when a global minimum has been found. For example you could sit on a generation at a local minima for a long time before a lucky mutation kicks you out of it and on to a better solution.
Certainly training multiple times (if the search space is reasonably small) to get a feel for what solutions the GA produces would be recommend. Try plotting out the distribution of the solutions obtained. A higher mutation rate may slow training but will also give the algorithm more chance to jump out of local minima.
One possible solution is to look at the standard deviation of the last $n$ predictions, and stop training when it drops below a threshold. If $n$ is large enough this should provide a reasonable method that shows you have come close enough to the global minimum. Note that chasing down that absolute minmum cost value may not always produce a solution that will not generalize well on new data.
|
Convergence of a genetic algorithm
|
The inherent stochasticity of genetic algorithms is what makes them such a powerful tool, however, this property also makes it difficult to know when a global minimum has been found. For example you c
|
Convergence of a genetic algorithm
The inherent stochasticity of genetic algorithms is what makes them such a powerful tool, however, this property also makes it difficult to know when a global minimum has been found. For example you could sit on a generation at a local minima for a long time before a lucky mutation kicks you out of it and on to a better solution.
Certainly training multiple times (if the search space is reasonably small) to get a feel for what solutions the GA produces would be recommend. Try plotting out the distribution of the solutions obtained. A higher mutation rate may slow training but will also give the algorithm more chance to jump out of local minima.
One possible solution is to look at the standard deviation of the last $n$ predictions, and stop training when it drops below a threshold. If $n$ is large enough this should provide a reasonable method that shows you have come close enough to the global minimum. Note that chasing down that absolute minmum cost value may not always produce a solution that will not generalize well on new data.
|
Convergence of a genetic algorithm
The inherent stochasticity of genetic algorithms is what makes them such a powerful tool, however, this property also makes it difficult to know when a global minimum has been found. For example you c
|
40,159
|
Convergence of a genetic algorithm
|
Theoretically (and possibly ironically), it is impossible to determine whether your GA's final solution is either a local optimum, the global optimum or anything else in the case of you don't know the number of optima and where they occur.
But you can reduce all possible outcomes, that is, after performing a GA search if you apply a local search algorithm (Newton's Method etc.) with the GA's final solution is given as a starting point then the produced result is either a local or the global optimum.
Restarting GA with different random populations will help to search different sides of the search space, a local optimizer will perform the 'fine tuning' operations, and if you get lucky you will obtain new local or the global solution as well. After performing many GA search, you can select the best as the global solution.
Finally, you still not sure about that.
|
Convergence of a genetic algorithm
|
Theoretically (and possibly ironically), it is impossible to determine whether your GA's final solution is either a local optimum, the global optimum or anything else in the case of you don't know the
|
Convergence of a genetic algorithm
Theoretically (and possibly ironically), it is impossible to determine whether your GA's final solution is either a local optimum, the global optimum or anything else in the case of you don't know the number of optima and where they occur.
But you can reduce all possible outcomes, that is, after performing a GA search if you apply a local search algorithm (Newton's Method etc.) with the GA's final solution is given as a starting point then the produced result is either a local or the global optimum.
Restarting GA with different random populations will help to search different sides of the search space, a local optimizer will perform the 'fine tuning' operations, and if you get lucky you will obtain new local or the global solution as well. After performing many GA search, you can select the best as the global solution.
Finally, you still not sure about that.
|
Convergence of a genetic algorithm
Theoretically (and possibly ironically), it is impossible to determine whether your GA's final solution is either a local optimum, the global optimum or anything else in the case of you don't know the
|
40,160
|
GLM on unbalanced design
|
Regression models allow you to borrow information explicitly across groups defined by your predictors. Having balanced design only means that all such groups have effects estimated with equal precision (under regression assumptions: correct mean model, homoskedasticity). This is rarely, if ever, necessary for justifying a statistical model. Traditionally, balanced design is considered for two reasons: to assess whether randomization was truly random in clinical trials and to demonstrate differences between certain study designs and simple random samples. In fact, it's frequently the case that unbalanced designs are more valid and more efficient, provided researchers have adhered to their sampling protocol. To clarify on the SSIII point, this is basically the F-test for the main effects which is a sensible test.
Assuming you're using the linear link in your GLM for continuous outcomes, there are alternatives. However, I feel your current methods seems solid, barring any egregious difficulties in the data of which I'm not aware. A sort of traditional consideration with continuous data is whether a transformation is necessary, such as a logarithmic transform. This would be a choice if you're interested in estimating a "ratio" of Y differences for a unit difference in X (i.e. subjects had 2x the 'Y' among those differing by 1 'X') using a base-2 log transform. There are also rank statistics which I find difficult to interpret, but could be a sensitivity analysis for data which is heavily skewed.
An aside: If you're presenting this data in a "Table 1" I would advise against displaying p-values for balance. It's likely to mislead reviewers and/or readers who think your design depends on such characteristics. You need only be explicit about your sampling methodology, and this model otherwise sounds like a valid approach.
|
GLM on unbalanced design
|
Regression models allow you to borrow information explicitly across groups defined by your predictors. Having balanced design only means that all such groups have effects estimated with equal precisio
|
GLM on unbalanced design
Regression models allow you to borrow information explicitly across groups defined by your predictors. Having balanced design only means that all such groups have effects estimated with equal precision (under regression assumptions: correct mean model, homoskedasticity). This is rarely, if ever, necessary for justifying a statistical model. Traditionally, balanced design is considered for two reasons: to assess whether randomization was truly random in clinical trials and to demonstrate differences between certain study designs and simple random samples. In fact, it's frequently the case that unbalanced designs are more valid and more efficient, provided researchers have adhered to their sampling protocol. To clarify on the SSIII point, this is basically the F-test for the main effects which is a sensible test.
Assuming you're using the linear link in your GLM for continuous outcomes, there are alternatives. However, I feel your current methods seems solid, barring any egregious difficulties in the data of which I'm not aware. A sort of traditional consideration with continuous data is whether a transformation is necessary, such as a logarithmic transform. This would be a choice if you're interested in estimating a "ratio" of Y differences for a unit difference in X (i.e. subjects had 2x the 'Y' among those differing by 1 'X') using a base-2 log transform. There are also rank statistics which I find difficult to interpret, but could be a sensitivity analysis for data which is heavily skewed.
An aside: If you're presenting this data in a "Table 1" I would advise against displaying p-values for balance. It's likely to mislead reviewers and/or readers who think your design depends on such characteristics. You need only be explicit about your sampling methodology, and this model otherwise sounds like a valid approach.
|
GLM on unbalanced design
Regression models allow you to borrow information explicitly across groups defined by your predictors. Having balanced design only means that all such groups have effects estimated with equal precisio
|
40,161
|
GLM on unbalanced design
|
The normal GLM methods work just fine on unbalanced designs (provided you aren't using expressions that are simplified for the balanced case --- decent software will work right). Unbalanced designs just have less power than balanced designs, but 250 vs 200 isn't going to have that much of an effect.
|
GLM on unbalanced design
|
The normal GLM methods work just fine on unbalanced designs (provided you aren't using expressions that are simplified for the balanced case --- decent software will work right). Unbalanced designs ju
|
GLM on unbalanced design
The normal GLM methods work just fine on unbalanced designs (provided you aren't using expressions that are simplified for the balanced case --- decent software will work right). Unbalanced designs just have less power than balanced designs, but 250 vs 200 isn't going to have that much of an effect.
|
GLM on unbalanced design
The normal GLM methods work just fine on unbalanced designs (provided you aren't using expressions that are simplified for the balanced case --- decent software will work right). Unbalanced designs ju
|
40,162
|
Are real and imaginary components of frequency element of fft correlated?
|
The ultimate line in the question,
...the default assumption ... that the variables analyzed have a multivariate Gaussian distribution
gives us the information needed to interpret and answer it. To avoid abstractions that might obscure the simplicity of the situation, let us consider a specific example of a time series of four elements, $\mathbf{a}=(a_0, a_1, a_2, a_3) = (a,b,c,d)$, having a multivariate Gaussian (i.e., Normal) distribution. Among other things, this means the $a_j$ are normal random variables. Their discrete Fourier Transform (DFT), according to one definition, is the sequence
$$\widehat{\mathbf{a}} = \frac{1}{2}(a+b+c+d, a+b i -c+d i, a-b + c -d, a - b i - c + d i).$$
The sequence of real parts of the DFT is therefore
$$\Re(\widehat{\mathbf{a}})=\frac{1}{2}(a+b+c+d, a-c, a-b+c-d, a-c)$$
and the sequence of imaginary parts is
$$\Im(\widehat{\mathbf{a}})=\frac{1}{2}(0, b-d, 0, -b+d).$$
These are eight vector-valued random variables, of which two are degenerate (they are always zero). (A) By inspection we can detect two more linear dependencies (as we must: any six linear combinations of four variables must have at least two dependencies), leaving just four combinations
$$\eqalign{
\Re{\widehat{\mathbf{a}}_0} &= \frac{1}{2}(a+b+c+d) \\
\Re{\widehat{\mathbf{a}}}_1 = \Re{\widehat{\mathbf{a}}}_3 &= \frac{1}{2}(a-c) \\
\Re{\widehat{\mathbf{a}}}_2 &= \frac{1}{2}(a-b+c-d) \\
\Im{\widehat{\mathbf{a}}}_1 = -\Im{\widehat{\mathbf{a}}}_3 &= \frac{1}{2}(b-d).\\
}$$
It is routine to check that these are linearly independent (the determinant of the matrix of coefficients equals $1/2$, for instance). From the fact that linear combinations of marginals in a multivariate normal distribution are also multivariate normal, we see immediately that
(B) The real parts of the DFT form a three dimensional multivariate normal distribution. The real parts of both $\widehat{\mathbf{a}}_0$ and $\widehat{\mathbf{a}}_2$, along with any linear combination of $\widehat{\mathbf{a}}_1$ and $\widehat{\mathbf{a}}_3$ not parallel to $(1,-1)$, are needed to span this space.
(C) The imaginary parts of the DFT form a one dimensional multivariate normal distribution. The imaginary part of any linear combination of $\widehat{\mathbf{a}}_1$ and $\widehat{\mathbf{a}}_3$ not parallel to $(1,1)$, is needed to span this space.
(D) The real and imaginary parts of the DFT together can be assembled to form a four dimensional multivariate normal distribution. That this has the same dimension as the length of the original series is obvious when you consider that the DFT is invertible: from the real and imaginary parts of the transform we can reconstruct the original series. (E) By diagonalizing the covariance matrix we can find linear combinations of these DFT coefficients that are uncorrelated and therefore are independent.
The answer to the question is now immediate, but let's be explicit:
I do not know if the imaginary and real parts of the output for a given output element are independent.
They are not independent (statement (A) in the foregoing example). Their real parts are not independent (B). Their imaginary parts are not independent (C). If we select appropriate linear combinations, which (if we wish) can be chosen among only the first half of the terms of $\widehat{\mathbf{a}}$ (having indexes $0$ through $2 = (4/2)$), they can be made independent (E) and form a four-dimensional multivariate Gaussian (D).
Let's make an observation about orthogonality, because that is a concept related to independence. The real and imaginary parts of the DFT are orthogonal in the sense that their inner product is always zero:
$$\eqalign{
&<\Re{\widehat{\mathbf{a}}}, \Im{\widehat{\mathbf{a}}}> \\
&= \frac{1}{4}\left((a+b+c+d)0 + (a-c)(b-d) + (a-b+c-d)0 + (a-c)(-b+d)\right) \\
&= 0.
}$$
Because each of these vectors is a random variable whose components are multivariate normal, we may think of them as spanning a two-dimensional subspace of $\mathbb{R}^4$ and, within that subspace, they determine a two dimensional multivariate normal distribution. The orthogonality implies independence of the real and imaginary parts considered as marginals of this distribution.
Every major conclusion drawn about this particular example holds generally for the DFT of a time series of any length. The demonstrations are identical, but the coefficients will be different (instead of involving $1, i, -1, -i$ and their powers, which are the fourth roots of unity $\exp(2 j\pi i/4), j=0,1,2,3$, they will involve $n^\text{th}$ roots). For even values of $n$, you will find that the imaginary parts of the zeroth and middle ($n/2$) term are always zero and that, neglecting these, the other real and imaginary parts of terms $0$ through $n/2$ can be assembled into an $n$-dimensional multivariate Gaussian.
One last consideration is whether the $n$ terms thus selected among the real and imaginary parts of the DFT are independent. The answer depends on the original distribution of $\mathbf{a}$. The calculations go like this. Consider the real parts of terms $0$ and $1$ in the DFT, equal to $a+b+c+d$ and $a-c$, respectively. Then
$$\eqalign{
\text{Cov}[a+b+c+d, a-c] &= \text{Var}[a] + \text{Cov}[b,a] - \text{Cov}[c,a] \ldots - \text{Cov}[d,c]\\
&=\text{Var}[a] - \text{Var}[c] + \text{Cov}[b+d, a-c].
}$$
If $a$ and $c$ have the same variance (which can be the case for many time series models) and if $b+d$ and $a-c$ are uncorrelated (which likely is not the case for most time series models), then these two DFT coefficients are uncorrelated, whence (because they form part of a multivariate normal distribution) they are independent. In general, though, the result of this calculation is a nonzero value, implying the first two coefficients are not independent.
|
Are real and imaginary components of frequency element of fft correlated?
|
The ultimate line in the question,
...the default assumption ... that the variables analyzed have a multivariate Gaussian distribution
gives us the information needed to interpret and answer it. To
|
Are real and imaginary components of frequency element of fft correlated?
The ultimate line in the question,
...the default assumption ... that the variables analyzed have a multivariate Gaussian distribution
gives us the information needed to interpret and answer it. To avoid abstractions that might obscure the simplicity of the situation, let us consider a specific example of a time series of four elements, $\mathbf{a}=(a_0, a_1, a_2, a_3) = (a,b,c,d)$, having a multivariate Gaussian (i.e., Normal) distribution. Among other things, this means the $a_j$ are normal random variables. Their discrete Fourier Transform (DFT), according to one definition, is the sequence
$$\widehat{\mathbf{a}} = \frac{1}{2}(a+b+c+d, a+b i -c+d i, a-b + c -d, a - b i - c + d i).$$
The sequence of real parts of the DFT is therefore
$$\Re(\widehat{\mathbf{a}})=\frac{1}{2}(a+b+c+d, a-c, a-b+c-d, a-c)$$
and the sequence of imaginary parts is
$$\Im(\widehat{\mathbf{a}})=\frac{1}{2}(0, b-d, 0, -b+d).$$
These are eight vector-valued random variables, of which two are degenerate (they are always zero). (A) By inspection we can detect two more linear dependencies (as we must: any six linear combinations of four variables must have at least two dependencies), leaving just four combinations
$$\eqalign{
\Re{\widehat{\mathbf{a}}_0} &= \frac{1}{2}(a+b+c+d) \\
\Re{\widehat{\mathbf{a}}}_1 = \Re{\widehat{\mathbf{a}}}_3 &= \frac{1}{2}(a-c) \\
\Re{\widehat{\mathbf{a}}}_2 &= \frac{1}{2}(a-b+c-d) \\
\Im{\widehat{\mathbf{a}}}_1 = -\Im{\widehat{\mathbf{a}}}_3 &= \frac{1}{2}(b-d).\\
}$$
It is routine to check that these are linearly independent (the determinant of the matrix of coefficients equals $1/2$, for instance). From the fact that linear combinations of marginals in a multivariate normal distribution are also multivariate normal, we see immediately that
(B) The real parts of the DFT form a three dimensional multivariate normal distribution. The real parts of both $\widehat{\mathbf{a}}_0$ and $\widehat{\mathbf{a}}_2$, along with any linear combination of $\widehat{\mathbf{a}}_1$ and $\widehat{\mathbf{a}}_3$ not parallel to $(1,-1)$, are needed to span this space.
(C) The imaginary parts of the DFT form a one dimensional multivariate normal distribution. The imaginary part of any linear combination of $\widehat{\mathbf{a}}_1$ and $\widehat{\mathbf{a}}_3$ not parallel to $(1,1)$, is needed to span this space.
(D) The real and imaginary parts of the DFT together can be assembled to form a four dimensional multivariate normal distribution. That this has the same dimension as the length of the original series is obvious when you consider that the DFT is invertible: from the real and imaginary parts of the transform we can reconstruct the original series. (E) By diagonalizing the covariance matrix we can find linear combinations of these DFT coefficients that are uncorrelated and therefore are independent.
The answer to the question is now immediate, but let's be explicit:
I do not know if the imaginary and real parts of the output for a given output element are independent.
They are not independent (statement (A) in the foregoing example). Their real parts are not independent (B). Their imaginary parts are not independent (C). If we select appropriate linear combinations, which (if we wish) can be chosen among only the first half of the terms of $\widehat{\mathbf{a}}$ (having indexes $0$ through $2 = (4/2)$), they can be made independent (E) and form a four-dimensional multivariate Gaussian (D).
Let's make an observation about orthogonality, because that is a concept related to independence. The real and imaginary parts of the DFT are orthogonal in the sense that their inner product is always zero:
$$\eqalign{
&<\Re{\widehat{\mathbf{a}}}, \Im{\widehat{\mathbf{a}}}> \\
&= \frac{1}{4}\left((a+b+c+d)0 + (a-c)(b-d) + (a-b+c-d)0 + (a-c)(-b+d)\right) \\
&= 0.
}$$
Because each of these vectors is a random variable whose components are multivariate normal, we may think of them as spanning a two-dimensional subspace of $\mathbb{R}^4$ and, within that subspace, they determine a two dimensional multivariate normal distribution. The orthogonality implies independence of the real and imaginary parts considered as marginals of this distribution.
Every major conclusion drawn about this particular example holds generally for the DFT of a time series of any length. The demonstrations are identical, but the coefficients will be different (instead of involving $1, i, -1, -i$ and their powers, which are the fourth roots of unity $\exp(2 j\pi i/4), j=0,1,2,3$, they will involve $n^\text{th}$ roots). For even values of $n$, you will find that the imaginary parts of the zeroth and middle ($n/2$) term are always zero and that, neglecting these, the other real and imaginary parts of terms $0$ through $n/2$ can be assembled into an $n$-dimensional multivariate Gaussian.
One last consideration is whether the $n$ terms thus selected among the real and imaginary parts of the DFT are independent. The answer depends on the original distribution of $\mathbf{a}$. The calculations go like this. Consider the real parts of terms $0$ and $1$ in the DFT, equal to $a+b+c+d$ and $a-c$, respectively. Then
$$\eqalign{
\text{Cov}[a+b+c+d, a-c] &= \text{Var}[a] + \text{Cov}[b,a] - \text{Cov}[c,a] \ldots - \text{Cov}[d,c]\\
&=\text{Var}[a] - \text{Var}[c] + \text{Cov}[b+d, a-c].
}$$
If $a$ and $c$ have the same variance (which can be the case for many time series models) and if $b+d$ and $a-c$ are uncorrelated (which likely is not the case for most time series models), then these two DFT coefficients are uncorrelated, whence (because they form part of a multivariate normal distribution) they are independent. In general, though, the result of this calculation is a nonzero value, implying the first two coefficients are not independent.
|
Are real and imaginary components of frequency element of fft correlated?
The ultimate line in the question,
...the default assumption ... that the variables analyzed have a multivariate Gaussian distribution
gives us the information needed to interpret and answer it. To
|
40,163
|
Can I pass an "at" parameter for the x-axis locations of bars, to an R barplot?
|
barplot() is just a wrapper for rect(), so you could add the bars yourself. This could be a start:
x <- sort(sample(1:100, 10, replace=FALSE)) # x-coordinates
y <- log(x) # y-coordinates
yD <- c(0, 2*diff(y)) # twice the change between steps
barW <- 1 # width of bars
plot(x, y, ylim=c(0, log(100)), pch=16)
rect(xleft=x-barW, ybottom=0, xright=x+barW, ytop=yD, col=gray(0.5))
Your second idea could be realized by splitting the device region with par(fig).
par(fig=c(0, 1, 0.30, 1)) # upper device region
plot(x, y, ylim=c(0, log(100)), pch=16)
par(fig=c(0, 1, 0, 0.45), bty="n", new=TRUE) # lower device region
plot(x, y, type="n", ylim=c(0, max(yD))) # empty plot to get correct axes
rect(xleft=x-barW, ybottom=0, xright=x+barW, ytop=yD, col=gray(0.5))
|
Can I pass an "at" parameter for the x-axis locations of bars, to an R barplot?
|
barplot() is just a wrapper for rect(), so you could add the bars yourself. This could be a start:
x <- sort(sample(1:100, 10, replace=FALSE)) # x-coordinates
y <- log(x)
|
Can I pass an "at" parameter for the x-axis locations of bars, to an R barplot?
barplot() is just a wrapper for rect(), so you could add the bars yourself. This could be a start:
x <- sort(sample(1:100, 10, replace=FALSE)) # x-coordinates
y <- log(x) # y-coordinates
yD <- c(0, 2*diff(y)) # twice the change between steps
barW <- 1 # width of bars
plot(x, y, ylim=c(0, log(100)), pch=16)
rect(xleft=x-barW, ybottom=0, xright=x+barW, ytop=yD, col=gray(0.5))
Your second idea could be realized by splitting the device region with par(fig).
par(fig=c(0, 1, 0.30, 1)) # upper device region
plot(x, y, ylim=c(0, log(100)), pch=16)
par(fig=c(0, 1, 0, 0.45), bty="n", new=TRUE) # lower device region
plot(x, y, type="n", ylim=c(0, max(yD))) # empty plot to get correct axes
rect(xleft=x-barW, ybottom=0, xright=x+barW, ytop=yD, col=gray(0.5))
|
Can I pass an "at" parameter for the x-axis locations of bars, to an R barplot?
barplot() is just a wrapper for rect(), so you could add the bars yourself. This could be a start:
x <- sort(sample(1:100, 10, replace=FALSE)) # x-coordinates
y <- log(x)
|
40,164
|
libsvm training very slow on 100K rows, suggestions?
|
I've seen liblinear runtimes very sensitive to tol; try tol=.1,
and if possible linear not rbf. How many classes do you have ?
How much memory do you have ? Monitor real / virtual with "top" or the like.
Stochastic gradient descent,
SGDClassifier
in scikits.learn is fast.
For example, on Mnist handwritten digit data, 10k rows x 768 features,
80 % of the raw data 0, -= mean and /= std:
12 sec sgd mnist28 (10000, 784) tol 0.1 C 1 penalty l2 correct 89.6 %
321 sec LinearSVC mnist28 (10000, 784) tol 0.1 C 1 penalty l2 correct 86.6 %
This is with no tuning nor cross-validation; your mileage will vary.
Added: see also Sofia-ml -- comments anyone ?
And please post what worked / what didn't.
|
libsvm training very slow on 100K rows, suggestions?
|
I've seen liblinear runtimes very sensitive to tol; try tol=.1,
and if possible linear not rbf. How many classes do you have ?
How much memory do you have ? Monitor real / virtual with "top" or the li
|
libsvm training very slow on 100K rows, suggestions?
I've seen liblinear runtimes very sensitive to tol; try tol=.1,
and if possible linear not rbf. How many classes do you have ?
How much memory do you have ? Monitor real / virtual with "top" or the like.
Stochastic gradient descent,
SGDClassifier
in scikits.learn is fast.
For example, on Mnist handwritten digit data, 10k rows x 768 features,
80 % of the raw data 0, -= mean and /= std:
12 sec sgd mnist28 (10000, 784) tol 0.1 C 1 penalty l2 correct 89.6 %
321 sec LinearSVC mnist28 (10000, 784) tol 0.1 C 1 penalty l2 correct 86.6 %
This is with no tuning nor cross-validation; your mileage will vary.
Added: see also Sofia-ml -- comments anyone ?
And please post what worked / what didn't.
|
libsvm training very slow on 100K rows, suggestions?
I've seen liblinear runtimes very sensitive to tol; try tol=.1,
and if possible linear not rbf. How many classes do you have ?
How much memory do you have ? Monitor real / virtual with "top" or the li
|
40,165
|
When is the maximum value of chi square achieved for a non-symmetric table?
|
Assume we have an $I \times J$ table of relative frequencies $f_{ij} \; (1 \leq i \leq I, 1 \leq j \leq J)$, where (without loss of generality) $I < J$:
$
\begin{array}{ccccc|l}
f_{11} & \ldots & f_{1j} & \ldots & f_{1J} & f_{1.} \\
\vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
f_{i1} & \ldots & f_{ij} & \ldots & f_{iJ} & f_{i.} \\
\vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
f_{I1} & \ldots & f_{Ij} & \ldots & f_{IJ} & f_{I.} \\\hline
f_{.1} & \ldots & f_{.j} & \ldots & f_{.J} & 1
\end{array}
$
Now define $\varphi^{2} := \chi^{2} / N = \sum_{i}\sum_{j} \frac{(f_{ij} - e_{ij})^{2}}{e_{ij}}$ where $e_{ij} := f_{i.} f_{.j}$. The claim is that $\chi^{2} \leq N \cdot (I-1$), i.e., $\varphi^{2} \leq I-1$. For $\varphi^{2}$ to be defined, we need to assume that all $e_{ij} > 0$, i.e., all $f_{i.} > 0$ and $f_{.j} > 0$. This means that in each row, as well as in each column, at least one $f_{ij} > 0$. Now rewrite $\varphi^{2} = \left(\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}}\right) - 1$. Adding 1, the claim can be restated as $\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}} \leq I$. This follows because
$
\begin{array}{rcl}
\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}} &=& \sum_{i}\sum_{j} \frac{f_{ij}^{2}}{f_{i.} f_{.j}} = \sum_{i}\sum_{j} \frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}}\\
&\leq& \sum_{i}\sum_{j} \frac{f_{ij}}{f_{i.}} = \sum_{i} \left(\frac{1}{f_{i.}} \sum_{j} f_{ij}\right)\\
&=& \sum_{i} \left(\frac{1}{f_{i.}} f_{i.}\right) = \sum_{i} 1 = I
\end{array}
$
The crucial step is from the first to the second line. The inequality holds because $0 \leq \frac{f_{ij}}{f_{.j}} \leq 1$ such that $\frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}} \leq \frac{f_{ij}}{f_{i.}}$ for all $i, j$. If all elements of the sum are smaller than the corresponding elements of a second sum, then the first sum is smaller than the second one.
$\varphi^{2}$ becomes $I-1$ when $\frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}} = \frac{f_{ij}}{f_{i.}}$ for all $i, j$. This happens when $\frac{f_{ij}}{f_{.j}} = 1$ or $\frac{f_{ij}}{f_{i.}} = 0$ for all $i, j$. This in turn happens when $f_{ij}= f_{.j}$ or $f_{ij} = 0$ for all $i, j$. This is the case under complete dependence, i.e., when in each column, only one cell has entries $> 0$.
|
When is the maximum value of chi square achieved for a non-symmetric table?
|
Assume we have an $I \times J$ table of relative frequencies $f_{ij} \; (1 \leq i \leq I, 1 \leq j \leq J)$, where (without loss of generality) $I < J$:
$
\begin{array}{ccccc|l}
f_{11} & \ldots & f_
|
When is the maximum value of chi square achieved for a non-symmetric table?
Assume we have an $I \times J$ table of relative frequencies $f_{ij} \; (1 \leq i \leq I, 1 \leq j \leq J)$, where (without loss of generality) $I < J$:
$
\begin{array}{ccccc|l}
f_{11} & \ldots & f_{1j} & \ldots & f_{1J} & f_{1.} \\
\vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
f_{i1} & \ldots & f_{ij} & \ldots & f_{iJ} & f_{i.} \\
\vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
f_{I1} & \ldots & f_{Ij} & \ldots & f_{IJ} & f_{I.} \\\hline
f_{.1} & \ldots & f_{.j} & \ldots & f_{.J} & 1
\end{array}
$
Now define $\varphi^{2} := \chi^{2} / N = \sum_{i}\sum_{j} \frac{(f_{ij} - e_{ij})^{2}}{e_{ij}}$ where $e_{ij} := f_{i.} f_{.j}$. The claim is that $\chi^{2} \leq N \cdot (I-1$), i.e., $\varphi^{2} \leq I-1$. For $\varphi^{2}$ to be defined, we need to assume that all $e_{ij} > 0$, i.e., all $f_{i.} > 0$ and $f_{.j} > 0$. This means that in each row, as well as in each column, at least one $f_{ij} > 0$. Now rewrite $\varphi^{2} = \left(\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}}\right) - 1$. Adding 1, the claim can be restated as $\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}} \leq I$. This follows because
$
\begin{array}{rcl}
\sum_{i}\sum_{j} \frac{f_{ij}^{2}}{e_{ij}} &=& \sum_{i}\sum_{j} \frac{f_{ij}^{2}}{f_{i.} f_{.j}} = \sum_{i}\sum_{j} \frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}}\\
&\leq& \sum_{i}\sum_{j} \frac{f_{ij}}{f_{i.}} = \sum_{i} \left(\frac{1}{f_{i.}} \sum_{j} f_{ij}\right)\\
&=& \sum_{i} \left(\frac{1}{f_{i.}} f_{i.}\right) = \sum_{i} 1 = I
\end{array}
$
The crucial step is from the first to the second line. The inequality holds because $0 \leq \frac{f_{ij}}{f_{.j}} \leq 1$ such that $\frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}} \leq \frac{f_{ij}}{f_{i.}}$ for all $i, j$. If all elements of the sum are smaller than the corresponding elements of a second sum, then the first sum is smaller than the second one.
$\varphi^{2}$ becomes $I-1$ when $\frac{f_{ij}}{f_{i.}} \frac{f_{ij}}{f_{.j}} = \frac{f_{ij}}{f_{i.}}$ for all $i, j$. This happens when $\frac{f_{ij}}{f_{.j}} = 1$ or $\frac{f_{ij}}{f_{i.}} = 0$ for all $i, j$. This in turn happens when $f_{ij}= f_{.j}$ or $f_{ij} = 0$ for all $i, j$. This is the case under complete dependence, i.e., when in each column, only one cell has entries $> 0$.
|
When is the maximum value of chi square achieved for a non-symmetric table?
Assume we have an $I \times J$ table of relative frequencies $f_{ij} \; (1 \leq i \leq I, 1 \leq j \leq J)$, where (without loss of generality) $I < J$:
$
\begin{array}{ccccc|l}
f_{11} & \ldots & f_
|
40,166
|
Difference between temporal trends
|
Let's start with some considerations:
One usually begins with simple reasonable models, as suggested by theory and restricted by data limitations, and moves to more complex models only if the simpler ones are inadequate. This is how statistical analysis operationalizes the scientific call for parsimony.
Fitting a trend is a form of regression analysis.
Because you have count data, you would naturally first consider binomial regression or Poisson regression. The first is appropriate in any case, while the latter is an excellent approximation for relatively low rates (which is what one hopes with infections!) and is widely available in software. (Ordinary least squares (OLS) is a further approximation that would be valid provided all the annual infection counts are fairly large, say in the tens to hundreds or more, and the infection counts are fairly constant over time.)
When a longish time series of data is available (usually 20-30+ years), you can consider using time series analysis to help account for correlations in rates from year to year. Usually, though, you would first exhaust plausible regression models to account for nonlinear changes over time, perhaps by including quadratic terms, "level shifts," or (more generally) splines. Note that the flexibility to model changes in slope over time is built in to all forms of regression; it is not a special feature of some particular approach.
In any of the regression models you can include separate terms for the male and female trends. This is done by introducing male/female as a covariate by means of "indicator" or "dummy variable" coding and including them as interactions. This has recently been discussed on this site here and here, where you can find the statistical model explicitly stated.
In the extreme case where (a) you contemplate the possibility of all regression coefficients differing between the two groups (the intercept and the slope and the coefficients of any other covariates) and (b) you are using the OLS approximation, this analysis reduces to the Chow Test. The link is to a nice exposition by William Gould, who provides plain-spoken advice ("I blame ... teachers for ... unnecessary jargon") and clear examples. Don't worry that the software is Stata; the output is what matters and it's standard.
|
Difference between temporal trends
|
Let's start with some considerations:
One usually begins with simple reasonable models, as suggested by theory and restricted by data limitations, and moves to more complex models only if the simpler
|
Difference between temporal trends
Let's start with some considerations:
One usually begins with simple reasonable models, as suggested by theory and restricted by data limitations, and moves to more complex models only if the simpler ones are inadequate. This is how statistical analysis operationalizes the scientific call for parsimony.
Fitting a trend is a form of regression analysis.
Because you have count data, you would naturally first consider binomial regression or Poisson regression. The first is appropriate in any case, while the latter is an excellent approximation for relatively low rates (which is what one hopes with infections!) and is widely available in software. (Ordinary least squares (OLS) is a further approximation that would be valid provided all the annual infection counts are fairly large, say in the tens to hundreds or more, and the infection counts are fairly constant over time.)
When a longish time series of data is available (usually 20-30+ years), you can consider using time series analysis to help account for correlations in rates from year to year. Usually, though, you would first exhaust plausible regression models to account for nonlinear changes over time, perhaps by including quadratic terms, "level shifts," or (more generally) splines. Note that the flexibility to model changes in slope over time is built in to all forms of regression; it is not a special feature of some particular approach.
In any of the regression models you can include separate terms for the male and female trends. This is done by introducing male/female as a covariate by means of "indicator" or "dummy variable" coding and including them as interactions. This has recently been discussed on this site here and here, where you can find the statistical model explicitly stated.
In the extreme case where (a) you contemplate the possibility of all regression coefficients differing between the two groups (the intercept and the slope and the coefficients of any other covariates) and (b) you are using the OLS approximation, this analysis reduces to the Chow Test. The link is to a nice exposition by William Gould, who provides plain-spoken advice ("I blame ... teachers for ... unnecessary jargon") and clear examples. Don't worry that the software is Stata; the output is what matters and it's standard.
|
Difference between temporal trends
Let's start with some considerations:
One usually begins with simple reasonable models, as suggested by theory and restricted by data limitations, and moves to more complex models only if the simpler
|
40,167
|
Difference between temporal trends
|
Well John you might be at risk using a single trend model. If your data has a level shift you may be falsely concluding about a persistent change over time. If your data is more representative of y(t)=y(t-1) + constant your trend model doesn't apply. I could go on for days about how trend models of the form y(t)=a+b*t are inadequate but I won't (here !). Now given the huge assumption that y(t)=a+b*t model you are assuming generates a Gaussian Distribution of errors with constant mean (everywhere) , independent (i.e. no provable autocorrelative structure ) , identically distributed with constant variance THEN you could use the CHOW TEST http://en.wikipedia.org/wiki/Chow_test to test the hypothesis that the two sets of a,b were equal or at least didn't differ significantly.
|
Difference between temporal trends
|
Well John you might be at risk using a single trend model. If your data has a level shift you may be falsely concluding about a persistent change over time. If your data is more representative of y(t)
|
Difference between temporal trends
Well John you might be at risk using a single trend model. If your data has a level shift you may be falsely concluding about a persistent change over time. If your data is more representative of y(t)=y(t-1) + constant your trend model doesn't apply. I could go on for days about how trend models of the form y(t)=a+b*t are inadequate but I won't (here !). Now given the huge assumption that y(t)=a+b*t model you are assuming generates a Gaussian Distribution of errors with constant mean (everywhere) , independent (i.e. no provable autocorrelative structure ) , identically distributed with constant variance THEN you could use the CHOW TEST http://en.wikipedia.org/wiki/Chow_test to test the hypothesis that the two sets of a,b were equal or at least didn't differ significantly.
|
Difference between temporal trends
Well John you might be at risk using a single trend model. If your data has a level shift you may be falsely concluding about a persistent change over time. If your data is more representative of y(t)
|
40,168
|
How to intuitively understand formula for estimate of pooled variance when testing differences between group means?
|
There are really 2 questions here, one about pooling and one about degrees of freedom.
Let's look at degrees of freedom first. To get the concept consider if we know that $x+y+z=10$ Then $x$ can be anything we want, and $y$ can be anything we want, but once we set those 2 there is only one value that $z$ can be, so we have 2 degrees of freedom. When we calculate $S^2$ if we subtract the population mean from each $x_i$ then square and sum, then we would divide by $n$ taking the average squared difference. But we generally don't know the population mean so we subtract the sample mean as an estimate of the population mean. But subtracting the sample mean that is estimated from the same data as we are using to find $S^2$ guarentees the lowest possible sum of squares, so it will tend to be too small. But if we divide by $n-1$ instead then it is unbiased because we have taken into account that we already used the same data to compute one piece of information (the mean is just the sum divided by a constant). In regression models the degrees of freedom are equal to $n$ minus the number of parameters we estimate. Each time you estimate a parameter (mean, intercept, slope) you are spending 1 degree of freedom.
For the pooled variance function, $S^2_c$ and $S^2_t$ are already divided by $n_c-1$ and $n_t-1$, so the multiplying just gives the sums of squares, then we add the 2 sums of squares and divide by the total degrees of freedom (we subtract 2 because we estimated 2 sample means to get the sums of squares). The pooled variance is just a weighted average of the 2 variances.
|
How to intuitively understand formula for estimate of pooled variance when testing differences betw
|
There are really 2 questions here, one about pooling and one about degrees of freedom.
Let's look at degrees of freedom first. To get the concept consider if we know that $x+y+z=10$ Then $x$ can be
|
How to intuitively understand formula for estimate of pooled variance when testing differences between group means?
There are really 2 questions here, one about pooling and one about degrees of freedom.
Let's look at degrees of freedom first. To get the concept consider if we know that $x+y+z=10$ Then $x$ can be anything we want, and $y$ can be anything we want, but once we set those 2 there is only one value that $z$ can be, so we have 2 degrees of freedom. When we calculate $S^2$ if we subtract the population mean from each $x_i$ then square and sum, then we would divide by $n$ taking the average squared difference. But we generally don't know the population mean so we subtract the sample mean as an estimate of the population mean. But subtracting the sample mean that is estimated from the same data as we are using to find $S^2$ guarentees the lowest possible sum of squares, so it will tend to be too small. But if we divide by $n-1$ instead then it is unbiased because we have taken into account that we already used the same data to compute one piece of information (the mean is just the sum divided by a constant). In regression models the degrees of freedom are equal to $n$ minus the number of parameters we estimate. Each time you estimate a parameter (mean, intercept, slope) you are spending 1 degree of freedom.
For the pooled variance function, $S^2_c$ and $S^2_t$ are already divided by $n_c-1$ and $n_t-1$, so the multiplying just gives the sums of squares, then we add the 2 sums of squares and divide by the total degrees of freedom (we subtract 2 because we estimated 2 sample means to get the sums of squares). The pooled variance is just a weighted average of the 2 variances.
|
How to intuitively understand formula for estimate of pooled variance when testing differences betw
There are really 2 questions here, one about pooling and one about degrees of freedom.
Let's look at degrees of freedom first. To get the concept consider if we know that $x+y+z=10$ Then $x$ can be
|
40,169
|
How to intuitively understand formula for estimate of pooled variance when testing differences between group means?
|
The pooled variance is a weighted average of the two independent unbiased estimators: $S^2_c$ and $S^2_t$.
Why those weights and what is the relation to the degrees of freedom?
Those weights are such that the weighted average is unbiased.
The degrees of freedom-
Accounting version: since you are summing differences from the mean, which always sum to zero, knowing $n-1$ of them will disclose the last. This suggests that you actually have only $n-1$ independent random variables.
Geometry version: The data can be orthogonally decomposed into two components: the mean and the distance from the mean. The mean vector spans a one dimensional linear space. It's orthogonal complement, should thus be a linear space of dimension $n-1$. So the degrees of freedom can be seen (and should!) as the dimension of $(x_i-\bar x)_{i=1}^n$, i.e., the linear space in which the distances from the mean reside.
|
How to intuitively understand formula for estimate of pooled variance when testing differences betw
|
The pooled variance is a weighted average of the two independent unbiased estimators: $S^2_c$ and $S^2_t$.
Why those weights and what is the relation to the degrees of freedom?
Those weights are such
|
How to intuitively understand formula for estimate of pooled variance when testing differences between group means?
The pooled variance is a weighted average of the two independent unbiased estimators: $S^2_c$ and $S^2_t$.
Why those weights and what is the relation to the degrees of freedom?
Those weights are such that the weighted average is unbiased.
The degrees of freedom-
Accounting version: since you are summing differences from the mean, which always sum to zero, knowing $n-1$ of them will disclose the last. This suggests that you actually have only $n-1$ independent random variables.
Geometry version: The data can be orthogonally decomposed into two components: the mean and the distance from the mean. The mean vector spans a one dimensional linear space. It's orthogonal complement, should thus be a linear space of dimension $n-1$. So the degrees of freedom can be seen (and should!) as the dimension of $(x_i-\bar x)_{i=1}^n$, i.e., the linear space in which the distances from the mean reside.
|
How to intuitively understand formula for estimate of pooled variance when testing differences betw
The pooled variance is a weighted average of the two independent unbiased estimators: $S^2_c$ and $S^2_t$.
Why those weights and what is the relation to the degrees of freedom?
Those weights are such
|
40,170
|
Inner correlation of occurrences (burstiness?) in R
|
This is a widely studied problem in neurosciences, where you need to determine the "burstiness" of action potentials of a neuron. The methods, however, can be obviously applied to any series of events.
Most of them rely on the analysis of the intervals between two following events: in the case of action potentials these are generally called inter-spike interval (ISI), but we can call them inter-event intervals (IEI) to generalize.
We can define them as
$IEI = t_n - t_{n-1} \quad\quad n=2,3,4,...,N$
Where $t_n$ is the time of event $n$ and $N$ is the total number of events.
I will list some of the approaches that have been used. Mind, however, that this list is far from exaustive.
The easiest visual thing to do is starting to plot an histogram of the IEIs or, even better, an histogram of $log_{10}(IEI)$.
In case of high "burstiness" the histogram will have a clear bimodal
distribution, with lots of short intervals between events and some longer ones (the pauses between bursts)
If you have a fairly good number of series of event you can also use a clustering algorithm to divide them in groups (regular, slow bursting, fast bursting etc.). This approach was taken, for instance, in this paper by Nowak et al. where several parameters of the distribution (mean, median, skewness, kurtosis, IQI etc.) are taken as classifiers for hierarchical clustering.
Electrophysiological Classes of Cat Primary Visual Cortical Neurons In Vivo as Revealed by Quantitative Analyses (free article)
Another classic approach is known as the "Poisson surprise method" and was described in 1985 by Charles LegΓ©ndy and Michael Salcman in their paper
Bursts and recurrences of bursts in the spike trains of spontaneously active striate cortex neurons. (not free)
The idea of the method is that:
The measure used here is an evaluation of how improbable it is that the burst is a chance occurrence and is computed, for any given burst that contains n spikes in a time interval T, as
$s = - log P$
where P is the probability that, in a random (Poisson) spike train having the same average spike rate Y as the spike train studied, a given time interval of length T contains y2 or more spikes.
I can provide R code for this if needed
An "updated" version of the Poisson-surprise method, which was developed to solve certain issues with that method is the rank-surprise method described in 2007 by Boris GourΓ©vitch and Jos Eggermont in their paper
A nonparametric approach for detection of bursts in spike trains (not free)
which uses a non parametric approach to define bursts.
We propose to use a more exhaustive search of the maximum of the surprise statistic using the following algorithm dubbed ESM (exhaustive surprise maximization): preliminary to the algorithm, we fix the largest ISI value acceptable in a burst (limit) and a level βlog(Ξ±) of minimum significance for the surprise statistic. We, then identify a first sequence of ISIs whose values are below limit. From this sequence, we perform an exhaustive search of the highest surprise statistic over all possible continuous subsequences of ISI.If the final surprise statistic is above βlog(Ξ±), the associated subsequence is labeled as a burst. Another burst is then searched among the remaining continuous ISI subsequences, obeying the same criterion. The process is repeated until one remaining continuous ISI subsequence is able to provide a significant RS statistic. When the process stops, we proceed to the next sequence of ISIs whose values are below limit and so on.
The authors provide pseudo-code and Matlab code for the algorithm
Other approaches rely on the variability of the distribution.
In particular, one can use the coefficient of variation $C_V$, classically defined as
$C_V = \frac{\sigma_{IEI}}{\langle{IEI}\rangle}$
The higher $C_V$ the burstier the events' distribution
$C_V$, however, is a fairly rough index, so a finer version of it was proposed, called $C_{V2}$, by Gary Holt and colleagues in their paper
Comparison of discharge variability in vitro and in vivo in cat visual cortex neurons (not free)
$C_{V2} = \frac{2*|{IEI}_{n+1}-{IEI}_n|}{{IEI}_{n+1}+{IEI}_n}$
Finally, another approach, proposed by Shigeru Shinomoto and colleagues in 2003 is the local variation coefficient $L_v$ which is defined as
$L_v = \frac{1}{n-1} \sum_{i=1}^{n-1}\frac{3(T_i-T_{i+1})^2}{(T_i+T_{i+1})^2}$
in their paper
Differences in Spiking Patterns Among Cortical Neurons
Also, two classical must-reads:
Neuronal spike trains and stochastic point processes. I. The single spike train
Neuronal spike trains and stochastic point processes. II. Simultaneous spike trains (both free, the second one probably is not too interesting for you, but it's still a good read)
|
Inner correlation of occurrences (burstiness?) in R
|
This is a widely studied problem in neurosciences, where you need to determine the "burstiness" of action potentials of a neuron. The methods, however, can be obviously applied to any series of events
|
Inner correlation of occurrences (burstiness?) in R
This is a widely studied problem in neurosciences, where you need to determine the "burstiness" of action potentials of a neuron. The methods, however, can be obviously applied to any series of events.
Most of them rely on the analysis of the intervals between two following events: in the case of action potentials these are generally called inter-spike interval (ISI), but we can call them inter-event intervals (IEI) to generalize.
We can define them as
$IEI = t_n - t_{n-1} \quad\quad n=2,3,4,...,N$
Where $t_n$ is the time of event $n$ and $N$ is the total number of events.
I will list some of the approaches that have been used. Mind, however, that this list is far from exaustive.
The easiest visual thing to do is starting to plot an histogram of the IEIs or, even better, an histogram of $log_{10}(IEI)$.
In case of high "burstiness" the histogram will have a clear bimodal
distribution, with lots of short intervals between events and some longer ones (the pauses between bursts)
If you have a fairly good number of series of event you can also use a clustering algorithm to divide them in groups (regular, slow bursting, fast bursting etc.). This approach was taken, for instance, in this paper by Nowak et al. where several parameters of the distribution (mean, median, skewness, kurtosis, IQI etc.) are taken as classifiers for hierarchical clustering.
Electrophysiological Classes of Cat Primary Visual Cortical Neurons In Vivo as Revealed by Quantitative Analyses (free article)
Another classic approach is known as the "Poisson surprise method" and was described in 1985 by Charles LegΓ©ndy and Michael Salcman in their paper
Bursts and recurrences of bursts in the spike trains of spontaneously active striate cortex neurons. (not free)
The idea of the method is that:
The measure used here is an evaluation of how improbable it is that the burst is a chance occurrence and is computed, for any given burst that contains n spikes in a time interval T, as
$s = - log P$
where P is the probability that, in a random (Poisson) spike train having the same average spike rate Y as the spike train studied, a given time interval of length T contains y2 or more spikes.
I can provide R code for this if needed
An "updated" version of the Poisson-surprise method, which was developed to solve certain issues with that method is the rank-surprise method described in 2007 by Boris GourΓ©vitch and Jos Eggermont in their paper
A nonparametric approach for detection of bursts in spike trains (not free)
which uses a non parametric approach to define bursts.
We propose to use a more exhaustive search of the maximum of the surprise statistic using the following algorithm dubbed ESM (exhaustive surprise maximization): preliminary to the algorithm, we fix the largest ISI value acceptable in a burst (limit) and a level βlog(Ξ±) of minimum significance for the surprise statistic. We, then identify a first sequence of ISIs whose values are below limit. From this sequence, we perform an exhaustive search of the highest surprise statistic over all possible continuous subsequences of ISI.If the final surprise statistic is above βlog(Ξ±), the associated subsequence is labeled as a burst. Another burst is then searched among the remaining continuous ISI subsequences, obeying the same criterion. The process is repeated until one remaining continuous ISI subsequence is able to provide a significant RS statistic. When the process stops, we proceed to the next sequence of ISIs whose values are below limit and so on.
The authors provide pseudo-code and Matlab code for the algorithm
Other approaches rely on the variability of the distribution.
In particular, one can use the coefficient of variation $C_V$, classically defined as
$C_V = \frac{\sigma_{IEI}}{\langle{IEI}\rangle}$
The higher $C_V$ the burstier the events' distribution
$C_V$, however, is a fairly rough index, so a finer version of it was proposed, called $C_{V2}$, by Gary Holt and colleagues in their paper
Comparison of discharge variability in vitro and in vivo in cat visual cortex neurons (not free)
$C_{V2} = \frac{2*|{IEI}_{n+1}-{IEI}_n|}{{IEI}_{n+1}+{IEI}_n}$
Finally, another approach, proposed by Shigeru Shinomoto and colleagues in 2003 is the local variation coefficient $L_v$ which is defined as
$L_v = \frac{1}{n-1} \sum_{i=1}^{n-1}\frac{3(T_i-T_{i+1})^2}{(T_i+T_{i+1})^2}$
in their paper
Differences in Spiking Patterns Among Cortical Neurons
Also, two classical must-reads:
Neuronal spike trains and stochastic point processes. I. The single spike train
Neuronal spike trains and stochastic point processes. II. Simultaneous spike trains (both free, the second one probably is not too interesting for you, but it's still a good read)
|
Inner correlation of occurrences (burstiness?) in R
This is a widely studied problem in neurosciences, where you need to determine the "burstiness" of action potentials of a neuron. The methods, however, can be obviously applied to any series of events
|
40,171
|
Measuring homogeneity across different spatial aggregations of data
|
There are many ways you can characterize homogeneity, so there could be many answers to your question. One of the most intuitive ways I have seen it displayed is in a book chapter, "Spatial Analysis of Regional Income Inequality" by Sergio Rey in the book Spatially Integrated Social Science (PDF). The approach Rey takes in that chapter is to visualize the change in a metric called Theil's Index. Particularly this is intutitive as the Theil index can be broken down into the "between" unit variation and the "within" unit variation. Subsequently Rey examines the change in the components of Theil's index between different census aggregations across time. (As a note, I find Rey's notation of the Theil index far easier to follow than the Wikipedia page)
This metric is only applicable to continuous variables, so a different approach would be necessary for the categorical variables. A prolific listing of commonly used indices to measure racial segregation are provided in this paper (Massey and Denton, 1988). All of those metrics can be used with categorical variables. Ones I have come across in Criminology/Sociology are the index of qualitative variation and diversity indices.
|
Measuring homogeneity across different spatial aggregations of data
|
There are many ways you can characterize homogeneity, so there could be many answers to your question. One of the most intuitive ways I have seen it displayed is in a book chapter, "Spatial Analysis o
|
Measuring homogeneity across different spatial aggregations of data
There are many ways you can characterize homogeneity, so there could be many answers to your question. One of the most intuitive ways I have seen it displayed is in a book chapter, "Spatial Analysis of Regional Income Inequality" by Sergio Rey in the book Spatially Integrated Social Science (PDF). The approach Rey takes in that chapter is to visualize the change in a metric called Theil's Index. Particularly this is intutitive as the Theil index can be broken down into the "between" unit variation and the "within" unit variation. Subsequently Rey examines the change in the components of Theil's index between different census aggregations across time. (As a note, I find Rey's notation of the Theil index far easier to follow than the Wikipedia page)
This metric is only applicable to continuous variables, so a different approach would be necessary for the categorical variables. A prolific listing of commonly used indices to measure racial segregation are provided in this paper (Massey and Denton, 1988). All of those metrics can be used with categorical variables. Ones I have come across in Criminology/Sociology are the index of qualitative variation and diversity indices.
|
Measuring homogeneity across different spatial aggregations of data
There are many ways you can characterize homogeneity, so there could be many answers to your question. One of the most intuitive ways I have seen it displayed is in a book chapter, "Spatial Analysis o
|
40,172
|
Measuring homogeneity across different spatial aggregations of data
|
Homogeneity Definition: To start, let's define homogeneity as the degree to which households grouped in same area are like one another for some attribute.
MAUP Approach
Paraphrasing the stated problem: We are uncertain how homogeneity changes as we decrease the spatial resolution of the design of how we group households into areas.
For this problem @AndyW answer is solid. In the field of geography, your problem can be classed within the modifiable areal unit problem (MAUP).You can search the index for 'MAUP' at this site.
Alternative Clustering Approach
An alternative problem: Given that we want to maximise areal homogeneity when aggregating households, we are uncertain of the optimal spatial configuration of how we should group the households.
With the p-regions clustering algorithm, you can visually explore different structures of homogeneity within your data by creating different maps of household areas by playing with these 2 parameters:
changing the different attributes
for maximising area homogeneity
changing the number of households
required to build an areal group
|
Measuring homogeneity across different spatial aggregations of data
|
Homogeneity Definition: To start, let's define homogeneity as the degree to which households grouped in same area are like one another for some attribute.
MAUP Approach
Paraphrasing the stated problem
|
Measuring homogeneity across different spatial aggregations of data
Homogeneity Definition: To start, let's define homogeneity as the degree to which households grouped in same area are like one another for some attribute.
MAUP Approach
Paraphrasing the stated problem: We are uncertain how homogeneity changes as we decrease the spatial resolution of the design of how we group households into areas.
For this problem @AndyW answer is solid. In the field of geography, your problem can be classed within the modifiable areal unit problem (MAUP).You can search the index for 'MAUP' at this site.
Alternative Clustering Approach
An alternative problem: Given that we want to maximise areal homogeneity when aggregating households, we are uncertain of the optimal spatial configuration of how we should group the households.
With the p-regions clustering algorithm, you can visually explore different structures of homogeneity within your data by creating different maps of household areas by playing with these 2 parameters:
changing the different attributes
for maximising area homogeneity
changing the number of households
required to build an areal group
|
Measuring homogeneity across different spatial aggregations of data
Homogeneity Definition: To start, let's define homogeneity as the degree to which households grouped in same area are like one another for some attribute.
MAUP Approach
Paraphrasing the stated problem
|
40,173
|
Using R's phyper to get the probability of list overlap
|
Trying to translate this into a statistical question, it seems you have a population with $a$ members and you take two random samples without replacement sized $b$ and $c$, and you want the distribution of $X$, the number appearing in both samples.
As an illustration, suppose $a=5$, $b=2$ and $c=3$. There are 100 ways of taking the samples, of which 10 have none in common, 60 have one in common and 30 have two in common. It the language of black and white balls in an urn, the urn has $b=2$ white balls and $a-b=3$ black balls, and we take $c=3$ balls out to inspect how many white balls come out. In R we can effectively get these values with
> totalpop <- 5
> sample1 <- 2
> sample2 <- 3
> dhyper(0:2, sample1, totalpop-sample1, sample2)
[1] 0.1 0.6 0.3
> phyper(-1:2, sample1, totalpop-sample1, sample2)
[1] 0.0 0.1 0.7 1.0
which confirms the earlier calculations.
If you want to test a number overlap, then the probability of getting that number or smaller from this model is
phyper(overlap, sampleb, totala - sampleb, samplec)
and of getting that number or larger is
1 - phyper(overlap - 1, sampleb, totala - sampleb, samplec)
|
Using R's phyper to get the probability of list overlap
|
Trying to translate this into a statistical question, it seems you have a population with $a$ members and you take two random samples without replacement sized $b$ and $c$, and you want the distributi
|
Using R's phyper to get the probability of list overlap
Trying to translate this into a statistical question, it seems you have a population with $a$ members and you take two random samples without replacement sized $b$ and $c$, and you want the distribution of $X$, the number appearing in both samples.
As an illustration, suppose $a=5$, $b=2$ and $c=3$. There are 100 ways of taking the samples, of which 10 have none in common, 60 have one in common and 30 have two in common. It the language of black and white balls in an urn, the urn has $b=2$ white balls and $a-b=3$ black balls, and we take $c=3$ balls out to inspect how many white balls come out. In R we can effectively get these values with
> totalpop <- 5
> sample1 <- 2
> sample2 <- 3
> dhyper(0:2, sample1, totalpop-sample1, sample2)
[1] 0.1 0.6 0.3
> phyper(-1:2, sample1, totalpop-sample1, sample2)
[1] 0.0 0.1 0.7 1.0
which confirms the earlier calculations.
If you want to test a number overlap, then the probability of getting that number or smaller from this model is
phyper(overlap, sampleb, totala - sampleb, samplec)
and of getting that number or larger is
1 - phyper(overlap - 1, sampleb, totala - sampleb, samplec)
|
Using R's phyper to get the probability of list overlap
Trying to translate this into a statistical question, it seems you have a population with $a$ members and you take two random samples without replacement sized $b$ and $c$, and you want the distributi
|
40,174
|
Most suitable distributions for modeling Monte Carlo Simulations
|
The books "Continuous univariate distributions" Vol 1 + Vol 2 by Johnson, Kotz and Balakrishnan (and there is a multivariate book too, I believe) are classical references, rich on the mathematical properties as well as giving examples of the usages of the different distributions they treat.
If you want details on a specific class of distributions, Wikipedia is always a good place to start, see
http://en.wikipedia.org/wiki/Power_law
The requested list is probably not easy to compile - the "most appropriate use" may be highly dependent upon context, but again the Wikipedia list of distributions
http://en.wikipedia.org/wiki/List_of_probability_distributions
could be a place to start to find distributions appropriate for your project.
|
Most suitable distributions for modeling Monte Carlo Simulations
|
The books "Continuous univariate distributions" Vol 1 + Vol 2 by Johnson, Kotz and Balakrishnan (and there is a multivariate book too, I believe) are classical references, rich on the mathematical pro
|
Most suitable distributions for modeling Monte Carlo Simulations
The books "Continuous univariate distributions" Vol 1 + Vol 2 by Johnson, Kotz and Balakrishnan (and there is a multivariate book too, I believe) are classical references, rich on the mathematical properties as well as giving examples of the usages of the different distributions they treat.
If you want details on a specific class of distributions, Wikipedia is always a good place to start, see
http://en.wikipedia.org/wiki/Power_law
The requested list is probably not easy to compile - the "most appropriate use" may be highly dependent upon context, but again the Wikipedia list of distributions
http://en.wikipedia.org/wiki/List_of_probability_distributions
could be a place to start to find distributions appropriate for your project.
|
Most suitable distributions for modeling Monte Carlo Simulations
The books "Continuous univariate distributions" Vol 1 + Vol 2 by Johnson, Kotz and Balakrishnan (and there is a multivariate book too, I believe) are classical references, rich on the mathematical pro
|
40,175
|
Most suitable distributions for modeling Monte Carlo Simulations
|
I personally worry about the philosophy of deciding on a distribution with certain properties first and then defining the parameters for the distribution.
My advice is normally to get the best data that you can first and then to process that data to find the best distribution and parameters to fit it. If you decide a distribution first to suit the input data then you are deciding on the way the data should behave before you have actually checked that it behaves how you have assumed in reality. A simple example would be a data set where you assume that all of the variations are due to measurement errors, in which case a normal distribution would probably be your chosen distribution. What you can often find though is that the data is not normally distributed and there is something more complex underlying the data you have.
One of the biggest problems in the modern use of Monte-Carlo analysis is the use of assumed distributions based on the best guesses of the users rather than actual data. If you don't actually have the data on which to estimate the input distributions then I would argue that there are better ways of looking at the problem than just going for Monte-Carlo analysis in the first instance.
|
Most suitable distributions for modeling Monte Carlo Simulations
|
I personally worry about the philosophy of deciding on a distribution with certain properties first and then defining the parameters for the distribution.
My advice is normally to get the best data t
|
Most suitable distributions for modeling Monte Carlo Simulations
I personally worry about the philosophy of deciding on a distribution with certain properties first and then defining the parameters for the distribution.
My advice is normally to get the best data that you can first and then to process that data to find the best distribution and parameters to fit it. If you decide a distribution first to suit the input data then you are deciding on the way the data should behave before you have actually checked that it behaves how you have assumed in reality. A simple example would be a data set where you assume that all of the variations are due to measurement errors, in which case a normal distribution would probably be your chosen distribution. What you can often find though is that the data is not normally distributed and there is something more complex underlying the data you have.
One of the biggest problems in the modern use of Monte-Carlo analysis is the use of assumed distributions based on the best guesses of the users rather than actual data. If you don't actually have the data on which to estimate the input distributions then I would argue that there are better ways of looking at the problem than just going for Monte-Carlo analysis in the first instance.
|
Most suitable distributions for modeling Monte Carlo Simulations
I personally worry about the philosophy of deciding on a distribution with certain properties first and then defining the parameters for the distribution.
My advice is normally to get the best data t
|
40,176
|
Most suitable distributions for modeling Monte Carlo Simulations
|
I know I am resurrecting an old thread but I had recently been looking for similar information and was unable to find it on the forum. I eventually managed to implement a solution for my study and I will add my experiences on using Monte Carlo simulation.
Monte Carlo Simulations is a rather broad, all-encompassing term for any statistical simulation method involving random sampling performed a large number of times. An important point to note about this method is that, in general, it will not lead to an improved estimate of the desired statistical property (the mean, for example). What it does provide however, is a means to quantify the uncertainty in that estimate.
Your question could be a little bit misleading since Monte Carlo simulations are not only used to simulate known distributions - in fact one of the strengths (and an oft encountered use-case) of this method is when one does not know the population distribution. While the empirical density distribution of one's data can be approximated by theoretical distributions for some well-known phenomena, more often than not this is not the case. In such situations, it is recommended to instead use the Monte Carlo bootstrap which can be found to be explained well in Michael Chernick's book among others.
The algorithm for implementing this is:
For i = 1 to nsims
Do
Sample = Sampling with replacement ();
Calculate_Mean;
Calculate_Standard_Deviation;
Calculate_Variance;
Calculate_Probability_of_Mean_exceeding_a_threshold;
_etc..._
End Do
End For
I implemented this in R for my study, after having explored the possibility of fitting known distributions and mixture models (my related questions on the same can be found here and here). I was doing a meta-analysis of data values on energy demand obtained from literature. I was working with small sample sizes (between 20 and 50) and wanted to come up with the uncertainty estimates for the mean and the probabilities of the mean exceeding certain thresholds. I cannot yet publish the results here but I can perhaps update this post at a later time.
This does not directly answer the OP's question, but to sum up, in general my advice is to:
1. check if your data matches some known distribution the sources for which have already been listed in other answers
2. Simulate and map the uncertainties and
3. repeat the same with a Monte Carlo bootstrap.
If the results are more or less the same then you have a fairly robust estimate. If they are very different, I would advise to go with the results from the Monte Carlo bootstrap since they do not impose any a-priori assumptions.
|
Most suitable distributions for modeling Monte Carlo Simulations
|
I know I am resurrecting an old thread but I had recently been looking for similar information and was unable to find it on the forum. I eventually managed to implement a solution for my study and I w
|
Most suitable distributions for modeling Monte Carlo Simulations
I know I am resurrecting an old thread but I had recently been looking for similar information and was unable to find it on the forum. I eventually managed to implement a solution for my study and I will add my experiences on using Monte Carlo simulation.
Monte Carlo Simulations is a rather broad, all-encompassing term for any statistical simulation method involving random sampling performed a large number of times. An important point to note about this method is that, in general, it will not lead to an improved estimate of the desired statistical property (the mean, for example). What it does provide however, is a means to quantify the uncertainty in that estimate.
Your question could be a little bit misleading since Monte Carlo simulations are not only used to simulate known distributions - in fact one of the strengths (and an oft encountered use-case) of this method is when one does not know the population distribution. While the empirical density distribution of one's data can be approximated by theoretical distributions for some well-known phenomena, more often than not this is not the case. In such situations, it is recommended to instead use the Monte Carlo bootstrap which can be found to be explained well in Michael Chernick's book among others.
The algorithm for implementing this is:
For i = 1 to nsims
Do
Sample = Sampling with replacement ();
Calculate_Mean;
Calculate_Standard_Deviation;
Calculate_Variance;
Calculate_Probability_of_Mean_exceeding_a_threshold;
_etc..._
End Do
End For
I implemented this in R for my study, after having explored the possibility of fitting known distributions and mixture models (my related questions on the same can be found here and here). I was doing a meta-analysis of data values on energy demand obtained from literature. I was working with small sample sizes (between 20 and 50) and wanted to come up with the uncertainty estimates for the mean and the probabilities of the mean exceeding certain thresholds. I cannot yet publish the results here but I can perhaps update this post at a later time.
This does not directly answer the OP's question, but to sum up, in general my advice is to:
1. check if your data matches some known distribution the sources for which have already been listed in other answers
2. Simulate and map the uncertainties and
3. repeat the same with a Monte Carlo bootstrap.
If the results are more or less the same then you have a fairly robust estimate. If they are very different, I would advise to go with the results from the Monte Carlo bootstrap since they do not impose any a-priori assumptions.
|
Most suitable distributions for modeling Monte Carlo Simulations
I know I am resurrecting an old thread but I had recently been looking for similar information and was unable to find it on the forum. I eventually managed to implement a solution for my study and I w
|
40,177
|
Most suitable distributions for modeling Monte Carlo Simulations
|
If you know the domain of the random variable and maybe have knowledge of some other properties like the mean, variance, etc. but want to be ignorant in a fair way about all other aspects of the distribution, you can find a distribution by applying the principle of maximum entropy. Or put simply
Given a collection of facts,
choose a model which is consistent with all the facts,
but otherwise as uniform as possible.
(Adam Berger)
Even if you don't want to derive these distributions yourself i think it's still good to know that there is such a general principle that may be used.
For many common cases people have already done this and you can just look up the solution, depending on your domain and given statistics: Wikipedia lists some of them.
|
Most suitable distributions for modeling Monte Carlo Simulations
|
If you know the domain of the random variable and maybe have knowledge of some other properties like the mean, variance, etc. but want to be ignorant in a fair way about all other aspects of the distr
|
Most suitable distributions for modeling Monte Carlo Simulations
If you know the domain of the random variable and maybe have knowledge of some other properties like the mean, variance, etc. but want to be ignorant in a fair way about all other aspects of the distribution, you can find a distribution by applying the principle of maximum entropy. Or put simply
Given a collection of facts,
choose a model which is consistent with all the facts,
but otherwise as uniform as possible.
(Adam Berger)
Even if you don't want to derive these distributions yourself i think it's still good to know that there is such a general principle that may be used.
For many common cases people have already done this and you can just look up the solution, depending on your domain and given statistics: Wikipedia lists some of them.
|
Most suitable distributions for modeling Monte Carlo Simulations
If you know the domain of the random variable and maybe have knowledge of some other properties like the mean, variance, etc. but want to be ignorant in a fair way about all other aspects of the distr
|
40,178
|
Number of eigenfunctions for kernel
|
The polynomial kernel $K(x,y) = (x \cdot y + 1)^d$ is easily represented in terms of monomials. The degree $d$ is the maximum degree of the polynomial computed by the kernel and therefore also the maximum degree of any contained monomial.
The problem of determining the number of monomials of degree exactly $d$ in $p$ input variables is the same as the problem of finding the number of combinations to draw $d$ elements from a bin with $p$ different elements. The number of such $d$-combinations is
$$\left(\!\!{d \choose p}\!\!\right) = {d + p - 1 \choose d} = {d + p - 1 \choose p - 1}.$$
However, we need to consider all monomials of degree $k = 0, \ldots, d$. Using $\sum_{j=k}^{n}{j \choose k} = {n+1 \choose k+1}$ we get
$$ \sum_{k=0}^{d}{p - 1 + k \choose p - 1} = \sum_{k=(p-1)}^{(p-1)+d}{k \choose p - 1} = {p + d \choose p} = {p + d \choose d}.$$
Addendum: This formula also nicely showcases the power of kernel functions: Just consider the case where $p = 256$ and $d = 2$. The kernel calculates the scalar product of two vectors (representing the scalar in front of each monomial base function) in a space with dimension ${d + p \choose d} = {256 + 2 \choose 2} = 33153$. An explicit scalar product computation thus involves 33153 multiplications and additions, while the kernel needs $p + d - 1 = 257$ multiplications and $p = 256$ additions.
|
Number of eigenfunctions for kernel
|
The polynomial kernel $K(x,y) = (x \cdot y + 1)^d$ is easily represented in terms of monomials. The degree $d$ is the maximum degree of the polynomial computed by the kernel and therefore also the max
|
Number of eigenfunctions for kernel
The polynomial kernel $K(x,y) = (x \cdot y + 1)^d$ is easily represented in terms of monomials. The degree $d$ is the maximum degree of the polynomial computed by the kernel and therefore also the maximum degree of any contained monomial.
The problem of determining the number of monomials of degree exactly $d$ in $p$ input variables is the same as the problem of finding the number of combinations to draw $d$ elements from a bin with $p$ different elements. The number of such $d$-combinations is
$$\left(\!\!{d \choose p}\!\!\right) = {d + p - 1 \choose d} = {d + p - 1 \choose p - 1}.$$
However, we need to consider all monomials of degree $k = 0, \ldots, d$. Using $\sum_{j=k}^{n}{j \choose k} = {n+1 \choose k+1}$ we get
$$ \sum_{k=0}^{d}{p - 1 + k \choose p - 1} = \sum_{k=(p-1)}^{(p-1)+d}{k \choose p - 1} = {p + d \choose p} = {p + d \choose d}.$$
Addendum: This formula also nicely showcases the power of kernel functions: Just consider the case where $p = 256$ and $d = 2$. The kernel calculates the scalar product of two vectors (representing the scalar in front of each monomial base function) in a space with dimension ${d + p \choose d} = {256 + 2 \choose 2} = 33153$. An explicit scalar product computation thus involves 33153 multiplications and additions, while the kernel needs $p + d - 1 = 257$ multiplications and $p = 256$ additions.
|
Number of eigenfunctions for kernel
The polynomial kernel $K(x,y) = (x \cdot y + 1)^d$ is easily represented in terms of monomials. The degree $d$ is the maximum degree of the polynomial computed by the kernel and therefore also the max
|
40,179
|
Number of eigenfunctions for kernel
|
Take a simple example, if $x,z \in \mathbb{R}^2$, and $d=2$, then,
$$ (\left< x , z \right> + 1)^2 = (x_1z_1 + x_2z_2 + 1)^2 $$
$$ = x_1^2z_1^2 + x_2^2z_2^2 + 2x_1z_1x_2z_2 +x_1z_1 + x_2z_2 + 1$$
$$ = \left< (x_1^2, x_2^2, \sqrt{2}x_1x_2, x_1, x_2, 1), (z_1^2, z_2^2, \sqrt{2}z_1z_2, z_1, z_2, 1) \right> $$
$$ = \left< \phi(\bf{x}), \phi(\bf{z}) \right> $$
where $\phi(\cdot)$ is the feature map, which we can see has 6 eigenfunctions. In this case $p=2$ and $d=2$, so there should be $\left( \begin{array}{c} 4 \\ 2 \end{array} \right) = 6$ eigenfunctions, as predicted. This is trivial but laborious to show for higher dimensions or higher polynomial degree orders.
|
Number of eigenfunctions for kernel
|
Take a simple example, if $x,z \in \mathbb{R}^2$, and $d=2$, then,
$$ (\left< x , z \right> + 1)^2 = (x_1z_1 + x_2z_2 + 1)^2 $$
$$ = x_1^2z_1^2 + x_2^2z_2^2 + 2x_1z_1x_2z_2 +x_1z_1 + x_2z_2 + 1$$
$$ =
|
Number of eigenfunctions for kernel
Take a simple example, if $x,z \in \mathbb{R}^2$, and $d=2$, then,
$$ (\left< x , z \right> + 1)^2 = (x_1z_1 + x_2z_2 + 1)^2 $$
$$ = x_1^2z_1^2 + x_2^2z_2^2 + 2x_1z_1x_2z_2 +x_1z_1 + x_2z_2 + 1$$
$$ = \left< (x_1^2, x_2^2, \sqrt{2}x_1x_2, x_1, x_2, 1), (z_1^2, z_2^2, \sqrt{2}z_1z_2, z_1, z_2, 1) \right> $$
$$ = \left< \phi(\bf{x}), \phi(\bf{z}) \right> $$
where $\phi(\cdot)$ is the feature map, which we can see has 6 eigenfunctions. In this case $p=2$ and $d=2$, so there should be $\left( \begin{array}{c} 4 \\ 2 \end{array} \right) = 6$ eigenfunctions, as predicted. This is trivial but laborious to show for higher dimensions or higher polynomial degree orders.
|
Number of eigenfunctions for kernel
Take a simple example, if $x,z \in \mathbb{R}^2$, and $d=2$, then,
$$ (\left< x , z \right> + 1)^2 = (x_1z_1 + x_2z_2 + 1)^2 $$
$$ = x_1^2z_1^2 + x_2^2z_2^2 + 2x_1z_1x_2z_2 +x_1z_1 + x_2z_2 + 1$$
$$ =
|
40,180
|
Time series factor model with one series more frequent
|
The cannonical way is probably MIDAS regression. There is a Matlab toolbox for estimating, available upon request from the author Eric Ghysels. You might look into user guide of this toolbox, since it has a review of all literature on MIDAS.
The wikipedia page also talks about connection with Kalman filters, so @F. Tussel observation is spot on.
Update There is now also an R package midasr to estimate MIDAS regression.
|
Time series factor model with one series more frequent
|
The cannonical way is probably MIDAS regression. There is a Matlab toolbox for estimating, available upon request from the author Eric Ghysels. You might look into user guide of this toolbox, since it
|
Time series factor model with one series more frequent
The cannonical way is probably MIDAS regression. There is a Matlab toolbox for estimating, available upon request from the author Eric Ghysels. You might look into user guide of this toolbox, since it has a review of all literature on MIDAS.
The wikipedia page also talks about connection with Kalman filters, so @F. Tussel observation is spot on.
Update There is now also an R package midasr to estimate MIDAS regression.
|
Time series factor model with one series more frequent
The cannonical way is probably MIDAS regression. There is a Matlab toolbox for estimating, available upon request from the author Eric Ghysels. You might look into user guide of this toolbox, since it
|
40,181
|
Time series factor model with one series more frequent
|
I would cast the model in state-space form. Then there is no problem if one of the variables is observed more frequently than the other, or the observation times are irregular: the Kalman filter deals with missing and partially observed variables gracefully.
Without details on the exact kind of relationships you aim to model it is difficult to be more specific.
|
Time series factor model with one series more frequent
|
I would cast the model in state-space form. Then there is no problem if one of the variables is observed more frequently than the other, or the observation times are irregular: the Kalman filter deals
|
Time series factor model with one series more frequent
I would cast the model in state-space form. Then there is no problem if one of the variables is observed more frequently than the other, or the observation times are irregular: the Kalman filter deals with missing and partially observed variables gracefully.
Without details on the exact kind of relationships you aim to model it is difficult to be more specific.
|
Time series factor model with one series more frequent
I would cast the model in state-space form. Then there is no problem if one of the variables is observed more frequently than the other, or the observation times are irregular: the Kalman filter deals
|
40,182
|
How to update ARIMA forecast in R? [closed]
|
Update:
It turns out that the Arima function has an argument for supplying old model:
adj_s <- Arima(series,model=arima_s)
The end result might be the same for both approaches, but I would advise using second one, because it clearly is tested more thoroughly.
**Old answer: **
As it happens, I encountered similar problem recently. Here is the function which takes existing arima model and applies it to new data.
adjust.amodel <- function(object,extended) {
km.mod <- makeARIMA(object$model$phi,object$model$theta,object$model$Delta)
km.res <- KalmanRun(extended,km.mod)
object$x <- extended
object$residuals <- ts(km.res$resid,start=start(extended),end=end(extended),frequency=frequency(extended))
object$model <- km.mod
object
}
In your case here is how you should use it:
series[31] <- 65
adj_arima_s <- adjust.amodel(arima_s,series)
simulate(adj_arima_s, nsim=50, future=TRUE)
The usual caveats apply though. You need to have good reasons to do that. If the data changes this means that the model should change, so what you are doing is ignoring the new information and sticking to the old model, which might be the wrong one. You can compare this to producing the model fit by plucking the model coefficients out of the blue air. Although the coefficients have statistical validation, it comes from the old data, so interpretation of the results should take this into consideration.
|
How to update ARIMA forecast in R? [closed]
|
Update:
It turns out that the Arima function has an argument for supplying old model:
adj_s <- Arima(series,model=arima_s)
The end result might be the same for both approaches, but I would advise us
|
How to update ARIMA forecast in R? [closed]
Update:
It turns out that the Arima function has an argument for supplying old model:
adj_s <- Arima(series,model=arima_s)
The end result might be the same for both approaches, but I would advise using second one, because it clearly is tested more thoroughly.
**Old answer: **
As it happens, I encountered similar problem recently. Here is the function which takes existing arima model and applies it to new data.
adjust.amodel <- function(object,extended) {
km.mod <- makeARIMA(object$model$phi,object$model$theta,object$model$Delta)
km.res <- KalmanRun(extended,km.mod)
object$x <- extended
object$residuals <- ts(km.res$resid,start=start(extended),end=end(extended),frequency=frequency(extended))
object$model <- km.mod
object
}
In your case here is how you should use it:
series[31] <- 65
adj_arima_s <- adjust.amodel(arima_s,series)
simulate(adj_arima_s, nsim=50, future=TRUE)
The usual caveats apply though. You need to have good reasons to do that. If the data changes this means that the model should change, so what you are doing is ignoring the new information and sticking to the old model, which might be the wrong one. You can compare this to producing the model fit by plucking the model coefficients out of the blue air. Although the coefficients have statistical validation, it comes from the old data, so interpretation of the results should take this into consideration.
|
How to update ARIMA forecast in R? [closed]
Update:
It turns out that the Arima function has an argument for supplying old model:
adj_s <- Arima(series,model=arima_s)
The end result might be the same for both approaches, but I would advise us
|
40,183
|
R Package GBM - Bernoulli Deviance
|
It is a mathematical trick. We have
\begin{align*}
\log\frac{p_i}{1-p_i}=f(x_i)
\end{align*}
and from this we get
\begin{align*}
\frac{1}{1-p_i}=1+\exp(f(x_i))
\end{align*}
The log likelihood is
\begin{align*}
\sum_{i=1}^n\left[y_i\log(p_i)+(1-y_i)\log(1-p_i)\right]&=\sum_{i=1}^n\left[y_i\log\frac{p_i}{1-p_i}+\log(1-p_i)\right]\\
&=\sum_{i=1}^n\left[y_if(x_i)-\log\frac{1}{1-p_i}\right]\\
&=\sum_{i=1}^n\left[y_if(x_i)-\log(1+\exp(f(x_i)))\right]\\
\end{align*}
Only some terms were rearranged. I hope I made clear how exactly it was done.
|
R Package GBM - Bernoulli Deviance
|
It is a mathematical trick. We have
\begin{align*}
\log\frac{p_i}{1-p_i}=f(x_i)
\end{align*}
and from this we get
\begin{align*}
\frac{1}{1-p_i}=1+\exp(f(x_i))
\end{align*}
The log likelihood is
\beg
|
R Package GBM - Bernoulli Deviance
It is a mathematical trick. We have
\begin{align*}
\log\frac{p_i}{1-p_i}=f(x_i)
\end{align*}
and from this we get
\begin{align*}
\frac{1}{1-p_i}=1+\exp(f(x_i))
\end{align*}
The log likelihood is
\begin{align*}
\sum_{i=1}^n\left[y_i\log(p_i)+(1-y_i)\log(1-p_i)\right]&=\sum_{i=1}^n\left[y_i\log\frac{p_i}{1-p_i}+\log(1-p_i)\right]\\
&=\sum_{i=1}^n\left[y_if(x_i)-\log\frac{1}{1-p_i}\right]\\
&=\sum_{i=1}^n\left[y_if(x_i)-\log(1+\exp(f(x_i)))\right]\\
\end{align*}
Only some terms were rearranged. I hope I made clear how exactly it was done.
|
R Package GBM - Bernoulli Deviance
It is a mathematical trick. We have
\begin{align*}
\log\frac{p_i}{1-p_i}=f(x_i)
\end{align*}
and from this we get
\begin{align*}
\frac{1}{1-p_i}=1+\exp(f(x_i))
\end{align*}
The log likelihood is
\beg
|
40,184
|
R Package GBM - Bernoulli Deviance
|
I'm also studying the GBM package!
mpiktas, i think you forgot a log on the left hand side in the 2nd equation? I assume you substitute p_i with 1/(1+exp(-f(x_i))), but then in the 2nd row above there is log(1/...) = log(1+...), or am i wrong? Anyway, i think then you did it right in the third row...
Can you tell us what is the motivation for choosing p_i = 1/(1+exp(-f(x_i)))? Where does that come form? The p_i should mirror the proportion of success, i.e. class proportions, right?
Thanks!
peter
|
R Package GBM - Bernoulli Deviance
|
I'm also studying the GBM package!
mpiktas, i think you forgot a log on the left hand side in the 2nd equation? I assume you substitute p_i with 1/(1+exp(-f(x_i))), but then in the 2nd row above ther
|
R Package GBM - Bernoulli Deviance
I'm also studying the GBM package!
mpiktas, i think you forgot a log on the left hand side in the 2nd equation? I assume you substitute p_i with 1/(1+exp(-f(x_i))), but then in the 2nd row above there is log(1/...) = log(1+...), or am i wrong? Anyway, i think then you did it right in the third row...
Can you tell us what is the motivation for choosing p_i = 1/(1+exp(-f(x_i)))? Where does that come form? The p_i should mirror the proportion of success, i.e. class proportions, right?
Thanks!
peter
|
R Package GBM - Bernoulli Deviance
I'm also studying the GBM package!
mpiktas, i think you forgot a log on the left hand side in the 2nd equation? I assume you substitute p_i with 1/(1+exp(-f(x_i))), but then in the 2nd row above ther
|
40,185
|
How to increase size of label fonts in barplot
|
According to ?barplot, you need to use cex.names=1.5.
barplot(mx, beside=TRUE, col=c("grey"), names.arg=results$"RUN",
cex.axis=1.5, cex.names=1.5)
|
How to increase size of label fonts in barplot
|
According to ?barplot, you need to use cex.names=1.5.
barplot(mx, beside=TRUE, col=c("grey"), names.arg=results$"RUN",
cex.axis=1.5, cex.names=1.5)
|
How to increase size of label fonts in barplot
According to ?barplot, you need to use cex.names=1.5.
barplot(mx, beside=TRUE, col=c("grey"), names.arg=results$"RUN",
cex.axis=1.5, cex.names=1.5)
|
How to increase size of label fonts in barplot
According to ?barplot, you need to use cex.names=1.5.
barplot(mx, beside=TRUE, col=c("grey"), names.arg=results$"RUN",
cex.axis=1.5, cex.names=1.5)
|
40,186
|
Recreating R's hist function's bin counting
|
Perhaps I've misunderstood what you want, but hist() returns all the details required to produce the histogram that is plotted. But you don't need to plot it and you can capture the returned object for subsequent use. So if the histogram contains the relevant summary you are after, this should be all you need. Here's an example:
> h <- hist(islands, plot = FALSE)
> str(h)
List of 7
$ breaks : num [1:10] 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
$ counts : int [1:9] 41 2 1 1 1 1 0 0 1
$ intensities: num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ density : num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ mids : num [1:9] 1000 3000 5000 7000 9000 11000 13000 15000 17000
$ xname : chr "islands"
$ equidist : logi TRUE
- attr(*, "class")= chr "histogram"
Note the use of plot = FALSE to avoid the superfluous plot side-effect.
|
Recreating R's hist function's bin counting
|
Perhaps I've misunderstood what you want, but hist() returns all the details required to produce the histogram that is plotted. But you don't need to plot it and you can capture the returned object fo
|
Recreating R's hist function's bin counting
Perhaps I've misunderstood what you want, but hist() returns all the details required to produce the histogram that is plotted. But you don't need to plot it and you can capture the returned object for subsequent use. So if the histogram contains the relevant summary you are after, this should be all you need. Here's an example:
> h <- hist(islands, plot = FALSE)
> str(h)
List of 7
$ breaks : num [1:10] 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
$ counts : int [1:9] 41 2 1 1 1 1 0 0 1
$ intensities: num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ density : num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ mids : num [1:9] 1000 3000 5000 7000 9000 11000 13000 15000 17000
$ xname : chr "islands"
$ equidist : logi TRUE
- attr(*, "class")= chr "histogram"
Note the use of plot = FALSE to avoid the superfluous plot side-effect.
|
Recreating R's hist function's bin counting
Perhaps I've misunderstood what you want, but hist() returns all the details required to produce the histogram that is plotted. But you don't need to plot it and you can capture the returned object fo
|
40,187
|
Quantitative methods and statistics conferences in psychology?
|
The European Association of Methodology has a meeting turning around statistics and psychometrics for applied research in social, educational and psychological science every two years. The latest was held in Postdam two months ago.
|
Quantitative methods and statistics conferences in psychology?
|
The European Association of Methodology has a meeting turning around statistics and psychometrics for applied research in social, educational and psychological science every two years. The latest was
|
Quantitative methods and statistics conferences in psychology?
The European Association of Methodology has a meeting turning around statistics and psychometrics for applied research in social, educational and psychological science every two years. The latest was held in Postdam two months ago.
|
Quantitative methods and statistics conferences in psychology?
The European Association of Methodology has a meeting turning around statistics and psychometrics for applied research in social, educational and psychological science every two years. The latest was
|
40,188
|
Quantitative methods and statistics conferences in psychology?
|
You're probably already aware of it, but the Society for Mathematical Psychology has an annual conference, MathPsych, which is attached to CogSci (generally happnens in the same city either before or after) and blends statistical methodology and Psychological modeling.
They do a pretty good job getting big names to come present, it's pretty cutting edge.
2010 conference site: http://www.mathpsych.org/conferences/2010/
|
Quantitative methods and statistics conferences in psychology?
|
You're probably already aware of it, but the Society for Mathematical Psychology has an annual conference, MathPsych, which is attached to CogSci (generally happnens in the same city either before or
|
Quantitative methods and statistics conferences in psychology?
You're probably already aware of it, but the Society for Mathematical Psychology has an annual conference, MathPsych, which is attached to CogSci (generally happnens in the same city either before or after) and blends statistical methodology and Psychological modeling.
They do a pretty good job getting big names to come present, it's pretty cutting edge.
2010 conference site: http://www.mathpsych.org/conferences/2010/
|
Quantitative methods and statistics conferences in psychology?
You're probably already aware of it, but the Society for Mathematical Psychology has an annual conference, MathPsych, which is attached to CogSci (generally happnens in the same city either before or
|
40,189
|
Quantitative methods and statistics conferences in psychology?
|
The annual meeting of the Society for Computers in Psychology often features content on quantitative methods:
http://sites.google.com/site/scipws/
|
Quantitative methods and statistics conferences in psychology?
|
The annual meeting of the Society for Computers in Psychology often features content on quantitative methods:
http://sites.google.com/site/scipws/
|
Quantitative methods and statistics conferences in psychology?
The annual meeting of the Society for Computers in Psychology often features content on quantitative methods:
http://sites.google.com/site/scipws/
|
Quantitative methods and statistics conferences in psychology?
The annual meeting of the Society for Computers in Psychology often features content on quantitative methods:
http://sites.google.com/site/scipws/
|
40,190
|
XGBoost: universal approximator?
|
Yes, it makes sense to characterise GBMs as "universal function approximators" and in particular "greedy" ones, as put forward in Friedman's (2001) (uber-classic) Greedy function approximation: A gradient boosting machine. The greediness here stemming on how we gradually/stage-wise increase the ensemble's capacity by adding units from the same family of known universal approximators (here trees). For that matter, let's remember that Boolean functions (i.e. trees) can be represented as real polynomials; a succinct (and surprisingly readable) intro on that can be found in Nisan & Szegedy (1992) On the degree of boolean functions as real polynomials. I have found Section 12.5 Universal approximation from the online blog version of the book Machine Learning Refined by Watt et al. a nice overview of how universal approximations come into play in ML, that section includes a small sub-section on tree-based universal approximators in particular too.
|
XGBoost: universal approximator?
|
Yes, it makes sense to characterise GBMs as "universal function approximators" and in particular "greedy" ones, as put forward in Friedman's (2001) (uber-classic) Greedy function approximation: A gra
|
XGBoost: universal approximator?
Yes, it makes sense to characterise GBMs as "universal function approximators" and in particular "greedy" ones, as put forward in Friedman's (2001) (uber-classic) Greedy function approximation: A gradient boosting machine. The greediness here stemming on how we gradually/stage-wise increase the ensemble's capacity by adding units from the same family of known universal approximators (here trees). For that matter, let's remember that Boolean functions (i.e. trees) can be represented as real polynomials; a succinct (and surprisingly readable) intro on that can be found in Nisan & Szegedy (1992) On the degree of boolean functions as real polynomials. I have found Section 12.5 Universal approximation from the online blog version of the book Machine Learning Refined by Watt et al. a nice overview of how universal approximations come into play in ML, that section includes a small sub-section on tree-based universal approximators in particular too.
|
XGBoost: universal approximator?
Yes, it makes sense to characterise GBMs as "universal function approximators" and in particular "greedy" ones, as put forward in Friedman's (2001) (uber-classic) Greedy function approximation: A gra
|
40,191
|
Logistic regression with known probabilities for some datapoints
|
I will assume that the objective here is to fit the model subject to the constraint that the predicted probability for one of the observations should have a value of exactly $p_0$ (not just a value "around" $p_0$).
Letting $\mathbf{x}_0$ denote the covariate vector for that observation, this amounts to a linear constraint
$$
\mathbf{x}_0^T\boldsymbol\beta=\eta_0=\operatorname{logit} p_0 \tag{1}
$$
on the parameter vector $\boldsymbol\beta$. This means that one of the elements of $\boldsymbol\beta$ in effect is redundant and can be eliminated from the model by substitution. This in turn leads to a modified design matrix and an offset term as follows.
Partitioning $\boldsymbol\beta$ into subvectors containing the redundant element $\beta_j$ and the remaining elements $\boldsymbol\beta_{-j}$, and partitioning $\mathbf{x}_0$ the same way such that $x_{0,j}\neq 0$, (1) can be written as
$$
\begin{bmatrix} \mathbf{x}_{0,-j}^TΒ & x_{0,j}\end{bmatrix}
\begin{bmatrix} \boldsymbol\beta_{-j}\\ \beta_j \end{bmatrix}
=\eta_0
$$
or
$$
\mathbf{x}_{0,-j}^T \boldsymbol\beta_{-j} + x_{0,j}\beta_j=\eta_0
$$
implying that
$$
\beta_j=x_{0,j}^{-1}(\eta_0 - \mathbf{x}_{0,-j}^T \boldsymbol\beta_{-j}).\tag{2}
$$
For the other observations we have
$$
\boldsymbol\eta=\mathbf{X}\boldsymbol\beta,
$$
or, after partitioning of the design matrix $\mathbf{X}$ the same way into its $j$'th column $\mathbf{x}_j$ and the remaining columns $\mathbf{X}_{-j}$,
$$
\boldsymbol\eta=\begin{bmatrix} \mathbf{X}_{-j}Β & \mathbf{x}_j\end{bmatrix}
\begin{bmatrix} \boldsymbol\beta_{-j}\\ \beta_j \end{bmatrix}=\mathbf{X}_{-j}\boldsymbol\beta_{-j} + \mathbf{x}_j\beta_j. \tag{3}
$$
Substituting (2) into (3) and rearranging terms the model takes the form
$$
\boldsymbol\eta=\underbrace{(\mathbf{X}_{-j}-x_{0,j}^{-1}\mathbf{x}_j\mathbf{x}_{0,-j}^T)}_{\mathbf{X}^*}\boldsymbol\beta_{-j} + \underbrace{x_{0,j}^{-1}\eta_0\mathbf{x}_j }_{\text{offset}}
$$
where $\mathbf{X}^*$ is the appropriate modified design matrix and the second term the offset term needed to fit the model subject to (1).
As a side note, a potentially useful application of the above method is the computation of profile likelihood based confidence intervals for $\eta_0$ and $p_0$ which may have better performance than the current confidence intervals computed by predict.glm in R that relies on asymptotic normality of $\hat{\boldsymbol\beta}$. The above method can also be straightforwardly extended to fit GLMs under general linear hypotheses on the form $\mathbf{C}\boldsymbol\beta=\mathbf{d}$ to facilitate likilihood ratio tests as opposed to sometimes less accurate Wald tests of such hypotheses.
|
Logistic regression with known probabilities for some datapoints
|
I will assume that the objective here is to fit the model subject to the constraint that the predicted probability for one of the observations should have a value of exactly $p_0$ (not just a value "a
|
Logistic regression with known probabilities for some datapoints
I will assume that the objective here is to fit the model subject to the constraint that the predicted probability for one of the observations should have a value of exactly $p_0$ (not just a value "around" $p_0$).
Letting $\mathbf{x}_0$ denote the covariate vector for that observation, this amounts to a linear constraint
$$
\mathbf{x}_0^T\boldsymbol\beta=\eta_0=\operatorname{logit} p_0 \tag{1}
$$
on the parameter vector $\boldsymbol\beta$. This means that one of the elements of $\boldsymbol\beta$ in effect is redundant and can be eliminated from the model by substitution. This in turn leads to a modified design matrix and an offset term as follows.
Partitioning $\boldsymbol\beta$ into subvectors containing the redundant element $\beta_j$ and the remaining elements $\boldsymbol\beta_{-j}$, and partitioning $\mathbf{x}_0$ the same way such that $x_{0,j}\neq 0$, (1) can be written as
$$
\begin{bmatrix} \mathbf{x}_{0,-j}^TΒ & x_{0,j}\end{bmatrix}
\begin{bmatrix} \boldsymbol\beta_{-j}\\ \beta_j \end{bmatrix}
=\eta_0
$$
or
$$
\mathbf{x}_{0,-j}^T \boldsymbol\beta_{-j} + x_{0,j}\beta_j=\eta_0
$$
implying that
$$
\beta_j=x_{0,j}^{-1}(\eta_0 - \mathbf{x}_{0,-j}^T \boldsymbol\beta_{-j}).\tag{2}
$$
For the other observations we have
$$
\boldsymbol\eta=\mathbf{X}\boldsymbol\beta,
$$
or, after partitioning of the design matrix $\mathbf{X}$ the same way into its $j$'th column $\mathbf{x}_j$ and the remaining columns $\mathbf{X}_{-j}$,
$$
\boldsymbol\eta=\begin{bmatrix} \mathbf{X}_{-j}Β & \mathbf{x}_j\end{bmatrix}
\begin{bmatrix} \boldsymbol\beta_{-j}\\ \beta_j \end{bmatrix}=\mathbf{X}_{-j}\boldsymbol\beta_{-j} + \mathbf{x}_j\beta_j. \tag{3}
$$
Substituting (2) into (3) and rearranging terms the model takes the form
$$
\boldsymbol\eta=\underbrace{(\mathbf{X}_{-j}-x_{0,j}^{-1}\mathbf{x}_j\mathbf{x}_{0,-j}^T)}_{\mathbf{X}^*}\boldsymbol\beta_{-j} + \underbrace{x_{0,j}^{-1}\eta_0\mathbf{x}_j }_{\text{offset}}
$$
where $\mathbf{X}^*$ is the appropriate modified design matrix and the second term the offset term needed to fit the model subject to (1).
As a side note, a potentially useful application of the above method is the computation of profile likelihood based confidence intervals for $\eta_0$ and $p_0$ which may have better performance than the current confidence intervals computed by predict.glm in R that relies on asymptotic normality of $\hat{\boldsymbol\beta}$. The above method can also be straightforwardly extended to fit GLMs under general linear hypotheses on the form $\mathbf{C}\boldsymbol\beta=\mathbf{d}$ to facilitate likilihood ratio tests as opposed to sometimes less accurate Wald tests of such hypotheses.
|
Logistic regression with known probabilities for some datapoints
I will assume that the objective here is to fit the model subject to the constraint that the predicted probability for one of the observations should have a value of exactly $p_0$ (not just a value "a
|
40,192
|
Logistic regression with known probabilities for some datapoints
|
One way you can do this that doesn't involve customized loss functions is by augmenting your data with "fake data" that reflects your prior beliefs about the data points. The augmented data consists of some data points with the same values for the features as the data points for which you have prior beliefs and, in this case, 50% "0" values and 50% "1" values for the response variable. The number of augmented data points depends on the strength of your prior beliefs; for example, a prior belief of a probability of 50% with a standard deviation of 0.05 corresponds to the mean and standard deviation of 100 draws from a bernoulli distribution with $p=0.5$. For each such data point, we would replicate the features 100 times and make the corresponding target variable values equal to 50 zeroes and 50 ones.
An example follows:
library(data.table)
x1 <- rnorm(100)
x2 <- rnorm(100)
x3 <- rnorm(100)
p <- exp(x1 + x2 + x3)/(1 + exp(x1+x2+x3))
y <- rbinom(100, 1, p)
df <- data.table(y=y, x1=x1, x2=x2, x3=x3, p=p)
setkey(df, p) # orders the data frame by the variable p
m1 <- glm(y ~ x1 + x2 + x3, family="binomial", data=df)
df$predict <- predict(m1, type="response")
# Assume data points 45 - 55 are believed to have probability = 0.5
# with an sd of 0.05 - corresponding to a Binomial(100, 0.5) dist'n
df2 <- df
for (i in 45:55) {
fake_y <- c(rep(0, 50), rep(1, 50))
fake_data <- data.table(y = fake_y, x1 = df$x1[i],
x2 = df$x2[i], x3=df$x3[i], p=0.5, predict=NA)
df2 <- rbind(df2, fake_data)
}
m2 <- glm(y~x1+x2+x3, family="binomial", data=df2)
df2$augmented_predict <- predict(m2, type="response")
Comparing the model parameters shows us there's been a substantial change:
> summary(m1) # original model
... stuff ...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.3210 0.2711 1.184 0.236499
x1 1.5915 0.4166 3.820 0.000133 ***
x2 1.0751 0.2884 3.728 0.000193 ***
x3 1.1683 0.3407 3.429 0.000606 ***
> summary(m2) # model with augmented data
... stuff ...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.04269 0.06005 0.711 0.477
x1 0.93603 0.19525 4.794 1.64e-06 ***
x2 0.91351 0.19149 4.770 1.84e-06 ***
x3 0.90534 0.19213 4.712 2.45e-06 ***
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
... and the values of the predictions for rows 45 - 55:
> df2[45:55, .(predict, augmented_predict)]
predict augmented_predict
1: 0.3953809 0.4566122
2: 0.4422332 0.4628846
3: 0.5301502 0.4740564
4: 0.5512260 0.4767186
5: 0.5861047 0.4869965
6: 0.7030460 0.5044203
7: 0.5987784 0.5128722
8: 0.6199068 0.5262623
9: 0.6037670 0.5322686
10: 0.4932125 0.5415195
11: 0.6537622 0.5553389
You do have to be careful about this, however. In this case, we have 100 "original" data points and 1,100 "fake" data points, so our results are driven mostly by our (very strong in toto) prior beliefs. Is our prior information really equivalent to observing 1100 data points? In this example it is, but not likely in the real world. A little humility about how much we know goes a long way!
Note that this approach can (not "should") also be taken in other contexts, e.g., ridge regression can be estimated with augmented data and OLS.
|
Logistic regression with known probabilities for some datapoints
|
One way you can do this that doesn't involve customized loss functions is by augmenting your data with "fake data" that reflects your prior beliefs about the data points. The augmented data consists
|
Logistic regression with known probabilities for some datapoints
One way you can do this that doesn't involve customized loss functions is by augmenting your data with "fake data" that reflects your prior beliefs about the data points. The augmented data consists of some data points with the same values for the features as the data points for which you have prior beliefs and, in this case, 50% "0" values and 50% "1" values for the response variable. The number of augmented data points depends on the strength of your prior beliefs; for example, a prior belief of a probability of 50% with a standard deviation of 0.05 corresponds to the mean and standard deviation of 100 draws from a bernoulli distribution with $p=0.5$. For each such data point, we would replicate the features 100 times and make the corresponding target variable values equal to 50 zeroes and 50 ones.
An example follows:
library(data.table)
x1 <- rnorm(100)
x2 <- rnorm(100)
x3 <- rnorm(100)
p <- exp(x1 + x2 + x3)/(1 + exp(x1+x2+x3))
y <- rbinom(100, 1, p)
df <- data.table(y=y, x1=x1, x2=x2, x3=x3, p=p)
setkey(df, p) # orders the data frame by the variable p
m1 <- glm(y ~ x1 + x2 + x3, family="binomial", data=df)
df$predict <- predict(m1, type="response")
# Assume data points 45 - 55 are believed to have probability = 0.5
# with an sd of 0.05 - corresponding to a Binomial(100, 0.5) dist'n
df2 <- df
for (i in 45:55) {
fake_y <- c(rep(0, 50), rep(1, 50))
fake_data <- data.table(y = fake_y, x1 = df$x1[i],
x2 = df$x2[i], x3=df$x3[i], p=0.5, predict=NA)
df2 <- rbind(df2, fake_data)
}
m2 <- glm(y~x1+x2+x3, family="binomial", data=df2)
df2$augmented_predict <- predict(m2, type="response")
Comparing the model parameters shows us there's been a substantial change:
> summary(m1) # original model
... stuff ...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.3210 0.2711 1.184 0.236499
x1 1.5915 0.4166 3.820 0.000133 ***
x2 1.0751 0.2884 3.728 0.000193 ***
x3 1.1683 0.3407 3.429 0.000606 ***
> summary(m2) # model with augmented data
... stuff ...
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.04269 0.06005 0.711 0.477
x1 0.93603 0.19525 4.794 1.64e-06 ***
x2 0.91351 0.19149 4.770 1.84e-06 ***
x3 0.90534 0.19213 4.712 2.45e-06 ***
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
... and the values of the predictions for rows 45 - 55:
> df2[45:55, .(predict, augmented_predict)]
predict augmented_predict
1: 0.3953809 0.4566122
2: 0.4422332 0.4628846
3: 0.5301502 0.4740564
4: 0.5512260 0.4767186
5: 0.5861047 0.4869965
6: 0.7030460 0.5044203
7: 0.5987784 0.5128722
8: 0.6199068 0.5262623
9: 0.6037670 0.5322686
10: 0.4932125 0.5415195
11: 0.6537622 0.5553389
You do have to be careful about this, however. In this case, we have 100 "original" data points and 1,100 "fake" data points, so our results are driven mostly by our (very strong in toto) prior beliefs. Is our prior information really equivalent to observing 1100 data points? In this example it is, but not likely in the real world. A little humility about how much we know goes a long way!
Note that this approach can (not "should") also be taken in other contexts, e.g., ridge regression can be estimated with augmented data and OLS.
|
Logistic regression with known probabilities for some datapoints
One way you can do this that doesn't involve customized loss functions is by augmenting your data with "fake data" that reflects your prior beliefs about the data points. The augmented data consists
|
40,193
|
Hypothesis testing of two dependent samples when pair information is not given
|
If you only have information about each sample separately and nothing about either the pair-differences or say the pair-correlation (nor covariance, nor any other relevant information), you don't have the ability to work out $s_d$. If you assume that the dependence is non-negative (an uncontroversial assumption in most circumstances) you can bound $s_d$ by the usual independent samples pooled standard deviation estimate.
So if all you have is $\bar{x}$, $s$ and $n$ for each sample, and literally nothing more, there's likely nothing to do but treat it as if it were an independent test and work with what should then be an upper bound on the p-value.
It would be good to see the context, because sometimes there's some subtlety that may not be obvious on first glance which, naturally, we won't see in a paraphrased question.
|
Hypothesis testing of two dependent samples when pair information is not given
|
If you only have information about each sample separately and nothing about either the pair-differences or say the pair-correlation (nor covariance, nor any other relevant information), you don't have
|
Hypothesis testing of two dependent samples when pair information is not given
If you only have information about each sample separately and nothing about either the pair-differences or say the pair-correlation (nor covariance, nor any other relevant information), you don't have the ability to work out $s_d$. If you assume that the dependence is non-negative (an uncontroversial assumption in most circumstances) you can bound $s_d$ by the usual independent samples pooled standard deviation estimate.
So if all you have is $\bar{x}$, $s$ and $n$ for each sample, and literally nothing more, there's likely nothing to do but treat it as if it were an independent test and work with what should then be an upper bound on the p-value.
It would be good to see the context, because sometimes there's some subtlety that may not be obvious on first glance which, naturally, we won't see in a paraphrased question.
|
Hypothesis testing of two dependent samples when pair information is not given
If you only have information about each sample separately and nothing about either the pair-differences or say the pair-correlation (nor covariance, nor any other relevant information), you don't have
|
40,194
|
Implementing a VAE in pytorch - extremely negative training loss
|
The problem is return -MSE_loss + KLDiv_Loss. You don't want to minimize -MSE_loss because you can always make $-(x-c)^2$ smaller by choosing $x$ farther from $c$. If $c$ is your target, this means your model is getting further from your goal.
Use return MSE_loss + KLDiv_Loss instead. You can show that this is correct by starting from a Gaussian likelihood for your target tgts and manipulating the algebra to obtain the negative log-likelihood, whence MSE is a rescaling.
|
Implementing a VAE in pytorch - extremely negative training loss
|
The problem is return -MSE_loss + KLDiv_Loss. You don't want to minimize -MSE_loss because you can always make $-(x-c)^2$ smaller by choosing $x$ farther from $c$. If $c$ is your target, this means yo
|
Implementing a VAE in pytorch - extremely negative training loss
The problem is return -MSE_loss + KLDiv_Loss. You don't want to minimize -MSE_loss because you can always make $-(x-c)^2$ smaller by choosing $x$ farther from $c$. If $c$ is your target, this means your model is getting further from your goal.
Use return MSE_loss + KLDiv_Loss instead. You can show that this is correct by starting from a Gaussian likelihood for your target tgts and manipulating the algebra to obtain the negative log-likelihood, whence MSE is a rescaling.
|
Implementing a VAE in pytorch - extremely negative training loss
The problem is return -MSE_loss + KLDiv_Loss. You don't want to minimize -MSE_loss because you can always make $-(x-c)^2$ smaller by choosing $x$ farther from $c$. If $c$ is your target, this means yo
|
40,195
|
How can we know population mean but not variance
|
$\mathbf{\mu}$ is the theorized value under the null hypothesis.
For the situation in general:
$$
H_0:\mu = \mu_0\\
H_a:\mu\ne\mu_0
$$
We do our usual fun of calculating the sample mean $\bar x$ and sample variance $s^2$, and then we calculate the t-statistic.
$$
t = \dfrac{\bar x - \mu_0}{\sqrt{s^2/n}}
$$
Now let's do an example. We have $n = 3$ observations, $3, 4, 5$, and we want to test if $\mu = 3$. (Exercise: The mean of these numbers is, clearly, four. How could the mean possible be three?)
$$
H_0:\mu = 3\\
H_a:\mu\ne 3
$$
Let's calculate $\bar x$ and $s^2$.
$$
\bar x = \dfrac{3 + 4 + 5}{3} = 4 \\
s^2 = \dfrac{(3 - 4)^2 + (4 - 4)^2 + (5 - 4)^2}{3 - 1} = 1
$$
Now calculate the t-stat.
$$
t = \dfrac{\bar x - \mu_0}{\sqrt{s^2/n}} = \dfrac{4 - 3}{\sqrt{1/3}} = \sqrt{3}\approx 1.73
$$
Software agrees.
x <- c(3, 4, 5)
t.test(x, mu = 3)$statistic # I get 1.732051
In summary, you assume $\mu$, rather than know $\mu$.
|
How can we know population mean but not variance
|
$\mathbf{\mu}$ is the theorized value under the null hypothesis.
For the situation in general:
$$
H_0:\mu = \mu_0\\
H_a:\mu\ne\mu_0
$$
We do our usual fun of calculating the sample mean $\bar x$ and s
|
How can we know population mean but not variance
$\mathbf{\mu}$ is the theorized value under the null hypothesis.
For the situation in general:
$$
H_0:\mu = \mu_0\\
H_a:\mu\ne\mu_0
$$
We do our usual fun of calculating the sample mean $\bar x$ and sample variance $s^2$, and then we calculate the t-statistic.
$$
t = \dfrac{\bar x - \mu_0}{\sqrt{s^2/n}}
$$
Now let's do an example. We have $n = 3$ observations, $3, 4, 5$, and we want to test if $\mu = 3$. (Exercise: The mean of these numbers is, clearly, four. How could the mean possible be three?)
$$
H_0:\mu = 3\\
H_a:\mu\ne 3
$$
Let's calculate $\bar x$ and $s^2$.
$$
\bar x = \dfrac{3 + 4 + 5}{3} = 4 \\
s^2 = \dfrac{(3 - 4)^2 + (4 - 4)^2 + (5 - 4)^2}{3 - 1} = 1
$$
Now calculate the t-stat.
$$
t = \dfrac{\bar x - \mu_0}{\sqrt{s^2/n}} = \dfrac{4 - 3}{\sqrt{1/3}} = \sqrt{3}\approx 1.73
$$
Software agrees.
x <- c(3, 4, 5)
t.test(x, mu = 3)$statistic # I get 1.732051
In summary, you assume $\mu$, rather than know $\mu$.
|
How can we know population mean but not variance
$\mathbf{\mu}$ is the theorized value under the null hypothesis.
For the situation in general:
$$
H_0:\mu = \mu_0\\
H_a:\mu\ne\mu_0
$$
We do our usual fun of calculating the sample mean $\bar x$ and s
|
40,196
|
How can we know population mean but not variance
|
This isn't generally applicable, but here's a specific example where the mean is knowable.
Suppose the population is "individuals' net profits in poker games over the last 6 months".
Poker doesn't create or destroy money, so if you add up everybody's winnings and losses the total will be zero. (Let's assume that we are ignoring things like entry fees.)
So the mean profit is zero but the variance is unknown.
|
How can we know population mean but not variance
|
This isn't generally applicable, but here's a specific example where the mean is knowable.
Suppose the population is "individuals' net profits in poker games over the last 6 months".
Poker doesn't cre
|
How can we know population mean but not variance
This isn't generally applicable, but here's a specific example where the mean is knowable.
Suppose the population is "individuals' net profits in poker games over the last 6 months".
Poker doesn't create or destroy money, so if you add up everybody's winnings and losses the total will be zero. (Let's assume that we are ignoring things like entry fees.)
So the mean profit is zero but the variance is unknown.
|
How can we know population mean but not variance
This isn't generally applicable, but here's a specific example where the mean is knowable.
Suppose the population is "individuals' net profits in poker games over the last 6 months".
Poker doesn't cre
|
40,197
|
Problem of computing standard error of higher moments
|
Here is a quick check using the moments of moments functions from the mathStatica package for Mathematica. That uses power sum notation where $s_r = \sum_{i=1}^n X_i^r$. Your problem is to find $E[O_2 O_1^2]$, which denotes the 1st RawMoment of $\frac{s_2}{n} \frac{s_1^2} {n^2}$:
where the solution is expressed in terms of Central Moments $\mu_r$ of the population. In the special case where the mean of the population is 0, this simplifies to:
... as stated in Rao.
|
Problem of computing standard error of higher moments
|
Here is a quick check using the moments of moments functions from the mathStatica package for Mathematica. That uses power sum notation where $s_r = \sum_{i=1}^n X_i^r$. Your problem is to find $E[O_
|
Problem of computing standard error of higher moments
Here is a quick check using the moments of moments functions from the mathStatica package for Mathematica. That uses power sum notation where $s_r = \sum_{i=1}^n X_i^r$. Your problem is to find $E[O_2 O_1^2]$, which denotes the 1st RawMoment of $\frac{s_2}{n} \frac{s_1^2} {n^2}$:
where the solution is expressed in terms of Central Moments $\mu_r$ of the population. In the special case where the mean of the population is 0, this simplifies to:
... as stated in Rao.
|
Problem of computing standard error of higher moments
Here is a quick check using the moments of moments functions from the mathStatica package for Mathematica. That uses power sum notation where $s_r = \sum_{i=1}^n X_i^r$. Your problem is to find $E[O_
|
40,198
|
Estimating the Population Mean with the Sample Mean
|
Let $X_{1},X_{2},\dots ,X_{n}$ are $n$ random samples drawn from a population with overall mean $\mu$ and finite variance $\sigma ^{2}$ and if $\bar {X}_{n}$ is the sample mean, then
We know sample mean (statistic) is an unbiased estimator of the population mean (parameter) i.e., $E[\bar{X_n}]=\mu$
By SLLN we have $\bar{X_n}\overset{a.s.}{\rightarrow}\mu$ and WLLN we have $\bar{X_n}\overset{P}{\rightarrow}\mu$, when $n \to \infty$
By CLT, $\dfrac{\bar{X_n}-\mu}{\sigma/\sqrt{n}}\overset{D}{\rightarrow}N(0,1)$, where a rule of thumb is sample size $n \geq 30$
We can compute the $(1-\alpha)\%$ confidence interval for the population mean by $\bar{X_n}\pm z_{\alpha/2}\frac{\sigma}{\sqrt{n}}$
For example, with the following R code snippet we can construct a $95\%$ confidence interval for the population mean:
sigma <- 5
n <- length(sample_1$pop)
x_bar <- mean(sample_1$pop)
# 95% CI
c(x_bar - qnorm(0.975)*sigma/sqrt(n), x_bar + qnorm(0.975)*sigma/sqrt(n))
# [1] 4.804931 5.424726
The following animation shows how the sampling distribution changes when the sample size gets larger:
The next animation shows how the confidence interval changes for different samples and if you repeat drawing random samples (with replacement) for a long time, there is $(1-\alpha)\%$ chance of the population mean falling inside the $(1-\alpha)\%$ confidence interval.
As can be seen from above, since the population is normally distributed, an observation has low probability to have value far away from the population mean (e.g., there are less than $5\%$ points with more than $2$ standard deviations away from mean), that's why even when the sample size is small, there is a very low probability that an observation in population far away from the population mean will be chosen in the sample, which keeps the sample mean close enough to population mean and the confidence interval constructed around the point estimate (sample mean) almost always contains the population mean. This will not be the case (in general), particularly for the population that has a distribution with fat tails.
The next animation shows how the length of the $95\%$ confidence interval decreases as we have larger sample size:
|
Estimating the Population Mean with the Sample Mean
|
Let $X_{1},X_{2},\dots ,X_{n}$ are $n$ random samples drawn from a population with overall mean $\mu$ and finite variance $\sigma ^{2}$ and if $\bar {X}_{n}$ is the sample mean, then
We know sample
|
Estimating the Population Mean with the Sample Mean
Let $X_{1},X_{2},\dots ,X_{n}$ are $n$ random samples drawn from a population with overall mean $\mu$ and finite variance $\sigma ^{2}$ and if $\bar {X}_{n}$ is the sample mean, then
We know sample mean (statistic) is an unbiased estimator of the population mean (parameter) i.e., $E[\bar{X_n}]=\mu$
By SLLN we have $\bar{X_n}\overset{a.s.}{\rightarrow}\mu$ and WLLN we have $\bar{X_n}\overset{P}{\rightarrow}\mu$, when $n \to \infty$
By CLT, $\dfrac{\bar{X_n}-\mu}{\sigma/\sqrt{n}}\overset{D}{\rightarrow}N(0,1)$, where a rule of thumb is sample size $n \geq 30$
We can compute the $(1-\alpha)\%$ confidence interval for the population mean by $\bar{X_n}\pm z_{\alpha/2}\frac{\sigma}{\sqrt{n}}$
For example, with the following R code snippet we can construct a $95\%$ confidence interval for the population mean:
sigma <- 5
n <- length(sample_1$pop)
x_bar <- mean(sample_1$pop)
# 95% CI
c(x_bar - qnorm(0.975)*sigma/sqrt(n), x_bar + qnorm(0.975)*sigma/sqrt(n))
# [1] 4.804931 5.424726
The following animation shows how the sampling distribution changes when the sample size gets larger:
The next animation shows how the confidence interval changes for different samples and if you repeat drawing random samples (with replacement) for a long time, there is $(1-\alpha)\%$ chance of the population mean falling inside the $(1-\alpha)\%$ confidence interval.
As can be seen from above, since the population is normally distributed, an observation has low probability to have value far away from the population mean (e.g., there are less than $5\%$ points with more than $2$ standard deviations away from mean), that's why even when the sample size is small, there is a very low probability that an observation in population far away from the population mean will be chosen in the sample, which keeps the sample mean close enough to population mean and the confidence interval constructed around the point estimate (sample mean) almost always contains the population mean. This will not be the case (in general), particularly for the population that has a distribution with fat tails.
The next animation shows how the length of the $95\%$ confidence interval decreases as we have larger sample size:
|
Estimating the Population Mean with the Sample Mean
Let $X_{1},X_{2},\dots ,X_{n}$ are $n$ random samples drawn from a population with overall mean $\mu$ and finite variance $\sigma ^{2}$ and if $\bar {X}_{n}$ is the sample mean, then
We know sample
|
40,199
|
Estimating the Population Mean with the Sample Mean
|
If you have a sample $X_1, X_2, \dots, X_n$ from a normal population in vector x, the procedure t.test in R will give you a 95% confidence
interval $(49.19, 50.33)$ for the population mean $\mu,$ for a sample of size $n = 20$ from $\mathsf{Norm}(\mu = 50, \sigma=7),$ as shown below.
(No hand computation is needed.)
set.seed(2021)
x = rnorm(20, 50, 7)
t.test(x)$conf.int
[1] 49.19194 56.32578
attr(,"conf.level")
[1] 0.95
This procedure also does a t test, but you can use $ notation to show just the confidence interval.
This confidence interval is of the form $\bar X\pm t^* s/\sqrt{n},$ where $\bar X$ is the sample mean, $s$ is the
sample standard deviation, and $t^*$ cuts probability $0.025$
from the upper tail of Student's t distribution with $n-1 = 19$ degrees of freedom.
a = mean(x) # sample mean
s = sd(x) # sample standard deviation
t.q = qt(.975, 19) # quantiles .025 and .975 of T(19)
a; s; qt(.975,19)
[1] 52.75886
[1] 7.621391
[1] 2.093024
a + qt(c(.025,.975), 19)*s/sqrt(20)
[1] 49.19194 56.32578
Notice that the appropriate quantiles of the (symmetrical)
t distribution are $\pm 2.09,$ whereas the same quantiles
of the standard normal distribution are $\pm 1.96.$ When $n\ge 30,$ the quantiles of $\mathsf{T}(n-1)$ for a 95% confidence interval are not far from $\pm 1.96;$ both quantiles round to $2.0.$ [But this 'rule of 30' does not work quite so well for confidence levels other than 95%. For a 90% CI the normal quantiles are $\pm 1.645\approx \pm 1.6;$ for $n=30$ the t quantiles are $\pm 1.699 \approx \pm 1.7.]$
qnorm(c(.025,.975))
[1] -1.959964 1.959964
If, for some reason, you wanted a 90% or a 99% confidence
interval for $\mu$ in the above example, you could also get
those by using t.test. Notice that the 99% confidence
interval is the longest of the three CIs given here (90%, 95%, 99%).
t.test(x, conf.level = .90)$conf.int
[1] 49.81208 55.70564
attr(,"conf.level")
[1] 0.9
t.test(x, conf.level = .99)$conf.int
[1] 47.88327 57.63445
attr(,"conf.level")
[1] 0.99
Finally, supposing we did not know that the data x were
sampled from a normal distribution with $\mu = 50,$ we wanted
to test $H_0: \mu = 50$ against $H_a: \mu \ne 50.$
Here are complete results from t.test.
t.test(x, mu = 50)
One Sample t-test
data: x
t = 1.6189, df = 19, p-value = 0.122
alternative hypothesis:
true mean is not equal to 50
95 percent confidence interval:
49.19194 56.32578
sample estimates:
mean of x
52.75886
The null hypothesis is not rejected at the 5% level of significance because the P-value $0.122 > 0.05 = 5\%.$
Accordingly, $\mu_0 = 50$ is contained in the 95% CI.
|
Estimating the Population Mean with the Sample Mean
|
If you have a sample $X_1, X_2, \dots, X_n$ from a normal population in vector x, the procedure t.test in R will give you a 95% confidence
interval $(49.19, 50.33)$ for the population mean $\mu,$ for
|
Estimating the Population Mean with the Sample Mean
If you have a sample $X_1, X_2, \dots, X_n$ from a normal population in vector x, the procedure t.test in R will give you a 95% confidence
interval $(49.19, 50.33)$ for the population mean $\mu,$ for a sample of size $n = 20$ from $\mathsf{Norm}(\mu = 50, \sigma=7),$ as shown below.
(No hand computation is needed.)
set.seed(2021)
x = rnorm(20, 50, 7)
t.test(x)$conf.int
[1] 49.19194 56.32578
attr(,"conf.level")
[1] 0.95
This procedure also does a t test, but you can use $ notation to show just the confidence interval.
This confidence interval is of the form $\bar X\pm t^* s/\sqrt{n},$ where $\bar X$ is the sample mean, $s$ is the
sample standard deviation, and $t^*$ cuts probability $0.025$
from the upper tail of Student's t distribution with $n-1 = 19$ degrees of freedom.
a = mean(x) # sample mean
s = sd(x) # sample standard deviation
t.q = qt(.975, 19) # quantiles .025 and .975 of T(19)
a; s; qt(.975,19)
[1] 52.75886
[1] 7.621391
[1] 2.093024
a + qt(c(.025,.975), 19)*s/sqrt(20)
[1] 49.19194 56.32578
Notice that the appropriate quantiles of the (symmetrical)
t distribution are $\pm 2.09,$ whereas the same quantiles
of the standard normal distribution are $\pm 1.96.$ When $n\ge 30,$ the quantiles of $\mathsf{T}(n-1)$ for a 95% confidence interval are not far from $\pm 1.96;$ both quantiles round to $2.0.$ [But this 'rule of 30' does not work quite so well for confidence levels other than 95%. For a 90% CI the normal quantiles are $\pm 1.645\approx \pm 1.6;$ for $n=30$ the t quantiles are $\pm 1.699 \approx \pm 1.7.]$
qnorm(c(.025,.975))
[1] -1.959964 1.959964
If, for some reason, you wanted a 90% or a 99% confidence
interval for $\mu$ in the above example, you could also get
those by using t.test. Notice that the 99% confidence
interval is the longest of the three CIs given here (90%, 95%, 99%).
t.test(x, conf.level = .90)$conf.int
[1] 49.81208 55.70564
attr(,"conf.level")
[1] 0.9
t.test(x, conf.level = .99)$conf.int
[1] 47.88327 57.63445
attr(,"conf.level")
[1] 0.99
Finally, supposing we did not know that the data x were
sampled from a normal distribution with $\mu = 50,$ we wanted
to test $H_0: \mu = 50$ against $H_a: \mu \ne 50.$
Here are complete results from t.test.
t.test(x, mu = 50)
One Sample t-test
data: x
t = 1.6189, df = 19, p-value = 0.122
alternative hypothesis:
true mean is not equal to 50
95 percent confidence interval:
49.19194 56.32578
sample estimates:
mean of x
52.75886
The null hypothesis is not rejected at the 5% level of significance because the P-value $0.122 > 0.05 = 5\%.$
Accordingly, $\mu_0 = 50$ is contained in the 95% CI.
|
Estimating the Population Mean with the Sample Mean
If you have a sample $X_1, X_2, \dots, X_n$ from a normal population in vector x, the procedure t.test in R will give you a 95% confidence
interval $(49.19, 50.33)$ for the population mean $\mu,$ for
|
40,200
|
What are the simplest examples of nonlinear statistical functionals?
|
Variances. Per the Wikipedia page on mixture distributions, expectations are linear, but variances are not. (When you think about it, this is kind of obvious, because expectations involve integrating over a function, which is linear, but variances involve integrating over the square of a function, which isn't.)
Specifically, for $n$ mixture components with means $\mu_i$, variances $\sigma_i^2$ and mixture weights $w_i$ summing to one, we have a mixture mean and variance of
$$ \begin{align*}
\mu =& \sum_{i=1}^n w_i\mu_i \\
\sigma^2 =& \sum_{i=1}^n w_i(\sigma_i^2+\mu_i^2-\mu^2).
\end{align*}$$
The expression for $\sigma^2$ is quite different from $\sum w_i\sigma_i^2$ because of the squared means. For instance, consider two normals $N(0,1)$ and $N(1,2)$ with weights $(0.3,0.7)$, then
$$ \begin{align*}
\mu =& w_1\mu_1+w_2\mu_2 = 0.7 \\
\sigma^2 =& w_1(\sigma_1^2+\mu_1^2-\mu^2)+w_2(\sigma_2^2+\mu_2^2-\mu^2) = 1.91
\neq 1.7 = w_1\sigma_1^2+w_2\sigma_2^2.
\end{align*}$$
Here is a quick R simulation for people who (like me) don't trust my math-fu:
weights <- c(0.3,0.7)
means <- c(0,1)
vars <- c(1,2)
index <- 2-(runif(1e7)<weights[1])
sims <- rnorm(length(which_one),mean=means[index],sd=sqrt(vars[index]))
mean(sims)
sum(weights*means)
var(sims)
sum(weights*vars)
Quantiles. For instance, your CDFs could be normal distributions with different means and variances, so $aF+bG$ would be a Gaussian mixture, and $T$ could extract any quantile. Quantiles of mixtures are not simply the weighted averages of the quantiles of the components. (See here for an argument why the median is not a linear functional for mixtures of normal distributions.)
The maximum or minimum of distributions with bounded support. If your two CDFs are for a $U[0,1]$ and a $U[0,2]$ distribution and $a,b>0$, then the mixture will have minimum $0$ and maximum $2$, regardless of the specific values of $a$ and $b$. Yes, this is not all that different from quantiles.
The (-1)-median, which is the functional that minimizes the expected mean absolute percentage error, and is not very well known.
|
What are the simplest examples of nonlinear statistical functionals?
|
Variances. Per the Wikipedia page on mixture distributions, expectations are linear, but variances are not. (When you think about it, this is kind of obvious, because expectations involve integrating
|
What are the simplest examples of nonlinear statistical functionals?
Variances. Per the Wikipedia page on mixture distributions, expectations are linear, but variances are not. (When you think about it, this is kind of obvious, because expectations involve integrating over a function, which is linear, but variances involve integrating over the square of a function, which isn't.)
Specifically, for $n$ mixture components with means $\mu_i$, variances $\sigma_i^2$ and mixture weights $w_i$ summing to one, we have a mixture mean and variance of
$$ \begin{align*}
\mu =& \sum_{i=1}^n w_i\mu_i \\
\sigma^2 =& \sum_{i=1}^n w_i(\sigma_i^2+\mu_i^2-\mu^2).
\end{align*}$$
The expression for $\sigma^2$ is quite different from $\sum w_i\sigma_i^2$ because of the squared means. For instance, consider two normals $N(0,1)$ and $N(1,2)$ with weights $(0.3,0.7)$, then
$$ \begin{align*}
\mu =& w_1\mu_1+w_2\mu_2 = 0.7 \\
\sigma^2 =& w_1(\sigma_1^2+\mu_1^2-\mu^2)+w_2(\sigma_2^2+\mu_2^2-\mu^2) = 1.91
\neq 1.7 = w_1\sigma_1^2+w_2\sigma_2^2.
\end{align*}$$
Here is a quick R simulation for people who (like me) don't trust my math-fu:
weights <- c(0.3,0.7)
means <- c(0,1)
vars <- c(1,2)
index <- 2-(runif(1e7)<weights[1])
sims <- rnorm(length(which_one),mean=means[index],sd=sqrt(vars[index]))
mean(sims)
sum(weights*means)
var(sims)
sum(weights*vars)
Quantiles. For instance, your CDFs could be normal distributions with different means and variances, so $aF+bG$ would be a Gaussian mixture, and $T$ could extract any quantile. Quantiles of mixtures are not simply the weighted averages of the quantiles of the components. (See here for an argument why the median is not a linear functional for mixtures of normal distributions.)
The maximum or minimum of distributions with bounded support. If your two CDFs are for a $U[0,1]$ and a $U[0,2]$ distribution and $a,b>0$, then the mixture will have minimum $0$ and maximum $2$, regardless of the specific values of $a$ and $b$. Yes, this is not all that different from quantiles.
The (-1)-median, which is the functional that minimizes the expected mean absolute percentage error, and is not very well known.
|
What are the simplest examples of nonlinear statistical functionals?
Variances. Per the Wikipedia page on mixture distributions, expectations are linear, but variances are not. (When you think about it, this is kind of obvious, because expectations involve integrating
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.