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
|
|---|---|---|---|---|---|---|
7,001
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
|
If I understand your problem, you're looking for the convex hull of health and of unemployment. There are probably several packages to do this in R, one of which is package geometry. I'd imagine that the points are sorted in order around the perimeter, but you'd have to check that.
EDIT: Here's an example, which doesn't use ggplot, but I hope it's useful. The example in the chull documentation seems to be wrong, which might be throwing you off:
X <- matrix(rnorm(2000), ncol = 2)
X.chull <- chull (X)
X.chull <- c(X.chull, X.chull[1])
plot (X)
lines (X[X.chull,])
EDIT 2: OK, here is something using ggplot2. We turn X into a data.frame with variables x and y. Then:
library(ggplot2)
X <- as.data.frame(X)
hull <- chull(X)
hull <- c(hull, hull[1])
ggplot(X, aes(x=x, y=y)) + geom_polygon(data=X[hull,], fill="red") + geom_point()
Note that the geom_point is using the data (X) and aes from the ggplot, while I'm overriding it in the geom_polygon.
To get it fully, you'd need to put the x and y for the hull for both issues into bar, using a third column issue to differentiate them.
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
|
If I understand your problem, you're looking for the convex hull of health and of unemployment. There are probably several packages to do this in R, one of which is package geometry. I'd imagine that
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
If I understand your problem, you're looking for the convex hull of health and of unemployment. There are probably several packages to do this in R, one of which is package geometry. I'd imagine that the points are sorted in order around the perimeter, but you'd have to check that.
EDIT: Here's an example, which doesn't use ggplot, but I hope it's useful. The example in the chull documentation seems to be wrong, which might be throwing you off:
X <- matrix(rnorm(2000), ncol = 2)
X.chull <- chull (X)
X.chull <- c(X.chull, X.chull[1])
plot (X)
lines (X[X.chull,])
EDIT 2: OK, here is something using ggplot2. We turn X into a data.frame with variables x and y. Then:
library(ggplot2)
X <- as.data.frame(X)
hull <- chull(X)
hull <- c(hull, hull[1])
ggplot(X, aes(x=x, y=y)) + geom_polygon(data=X[hull,], fill="red") + geom_point()
Note that the geom_point is using the data (X) and aes from the ggplot, while I'm overriding it in the geom_polygon.
To get it fully, you'd need to put the x and y for the hull for both issues into bar, using a third column issue to differentiate them.
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
If I understand your problem, you're looking for the convex hull of health and of unemployment. There are probably several packages to do this in R, one of which is package geometry. I'd imagine that
|
7,002
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
|
As of this afternoon, I've wrapped the chull function inside an R package as a geom_convexhull function.
Once the package is loaded, it can be used as any other geom, in your case it should be something like :
ggplot(d, aes(man, eff, colour=issue, fill=issue)) +
geom_convexhull(alpha=.5) +
geom_point() +
labs(x = "Efficiency", y = "Mandate"))
The package is available on github : https://github.com/cmartin/ggConvexHull
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
|
As of this afternoon, I've wrapped the chull function inside an R package as a geom_convexhull function.
Once the package is loaded, it can be used as any other geom, in your case it should be somethi
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
As of this afternoon, I've wrapped the chull function inside an R package as a geom_convexhull function.
Once the package is loaded, it can be used as any other geom, in your case it should be something like :
ggplot(d, aes(man, eff, colour=issue, fill=issue)) +
geom_convexhull(alpha=.5) +
geom_point() +
labs(x = "Efficiency", y = "Mandate"))
The package is available on github : https://github.com/cmartin/ggConvexHull
|
How to draw neat polygons around scatterplot regions in ggplot2 [closed]
As of this afternoon, I've wrapped the chull function inside an R package as a geom_convexhull function.
Once the package is loaded, it can be used as any other geom, in your case it should be somethi
|
7,003
|
Why is max pooling necessary in convolutional neural networks?
|
You can indeed do that, see Striving for Simplicity: The All Convolutional Net. Pooling gives you some amount of translation invariance, which may or may not be helpful. Also, pooling is faster to compute than convolutions. Still, you can always try replacing pooling by convolution with stride and see what works better.
Some current works use average pooling (Wide Residual Networks, DenseNets), others use convolution with stride (DelugeNets)
|
Why is max pooling necessary in convolutional neural networks?
|
You can indeed do that, see Striving for Simplicity: The All Convolutional Net. Pooling gives you some amount of translation invariance, which may or may not be helpful. Also, pooling is faster to com
|
Why is max pooling necessary in convolutional neural networks?
You can indeed do that, see Striving for Simplicity: The All Convolutional Net. Pooling gives you some amount of translation invariance, which may or may not be helpful. Also, pooling is faster to compute than convolutions. Still, you can always try replacing pooling by convolution with stride and see what works better.
Some current works use average pooling (Wide Residual Networks, DenseNets), others use convolution with stride (DelugeNets)
|
Why is max pooling necessary in convolutional neural networks?
You can indeed do that, see Striving for Simplicity: The All Convolutional Net. Pooling gives you some amount of translation invariance, which may or may not be helpful. Also, pooling is faster to com
|
7,004
|
Why is max pooling necessary in convolutional neural networks?
|
Apparently max pooling helps because it extracts the sharpest features of an image. So given an image, the sharpest features are the best lower-level representation of an image. https://www.quora.com/What-is-the-benefit-of-using-average-pooling-rather-than-max-pooling
But according to Andrew Ng's Deep Learning lecture, max pooling works well but no one knows why. Quote -> "But I have to admit, I think the main reason people use max pooling is because it's been found in a lot of experiments to work well, ... I don't know of anyone fully knows if that is the real underlying reason."
|
Why is max pooling necessary in convolutional neural networks?
|
Apparently max pooling helps because it extracts the sharpest features of an image. So given an image, the sharpest features are the best lower-level representation of an image. https://www.quora.com/
|
Why is max pooling necessary in convolutional neural networks?
Apparently max pooling helps because it extracts the sharpest features of an image. So given an image, the sharpest features are the best lower-level representation of an image. https://www.quora.com/What-is-the-benefit-of-using-average-pooling-rather-than-max-pooling
But according to Andrew Ng's Deep Learning lecture, max pooling works well but no one knows why. Quote -> "But I have to admit, I think the main reason people use max pooling is because it's been found in a lot of experiments to work well, ... I don't know of anyone fully knows if that is the real underlying reason."
|
Why is max pooling necessary in convolutional neural networks?
Apparently max pooling helps because it extracts the sharpest features of an image. So given an image, the sharpest features are the best lower-level representation of an image. https://www.quora.com/
|
7,005
|
Why is max pooling necessary in convolutional neural networks?
|
Pooling mainly helps in extracting sharp and smooth features. It is also done to reduce variance and computations. Max-pooling helps in extracting low-level features like edges, points, etc. While Avg-pooling goes for smooth features.
If time constraint is not a problem, then one can skip the pooling layer and use a convolutional layer to do the same.
Refer this.
|
Why is max pooling necessary in convolutional neural networks?
|
Pooling mainly helps in extracting sharp and smooth features. It is also done to reduce variance and computations. Max-pooling helps in extracting low-level features like edges, points, etc. While Avg
|
Why is max pooling necessary in convolutional neural networks?
Pooling mainly helps in extracting sharp and smooth features. It is also done to reduce variance and computations. Max-pooling helps in extracting low-level features like edges, points, etc. While Avg-pooling goes for smooth features.
If time constraint is not a problem, then one can skip the pooling layer and use a convolutional layer to do the same.
Refer this.
|
Why is max pooling necessary in convolutional neural networks?
Pooling mainly helps in extracting sharp and smooth features. It is also done to reduce variance and computations. Max-pooling helps in extracting low-level features like edges, points, etc. While Avg
|
7,006
|
Why is max pooling necessary in convolutional neural networks?
|
It really depends on the images. In some scenarios, Max pooling can take away too much info, resulting in worst performance that a CNN without max pooling. See this video for a surprising comparison using the MNIST Fashion dataset: https://www.youtube.com/watch?v=0ixAwVAfejY
|
Why is max pooling necessary in convolutional neural networks?
|
It really depends on the images. In some scenarios, Max pooling can take away too much info, resulting in worst performance that a CNN without max pooling. See this video for a surprising comparison u
|
Why is max pooling necessary in convolutional neural networks?
It really depends on the images. In some scenarios, Max pooling can take away too much info, resulting in worst performance that a CNN without max pooling. See this video for a surprising comparison using the MNIST Fashion dataset: https://www.youtube.com/watch?v=0ixAwVAfejY
|
Why is max pooling necessary in convolutional neural networks?
It really depends on the images. In some scenarios, Max pooling can take away too much info, resulting in worst performance that a CNN without max pooling. See this video for a surprising comparison u
|
7,007
|
Is a strong background in maths a total requisite for ML?
|
Stanford (Ng) and Caltech (Abu-Mostafa) have put machine learning classes on YouTube. You don't get to see the assignments, but the lectures don't rely on those. I recommend trying to watch those first, as those will help you to find out what math you need to learn. I believe a very similar class with assignments is taught by Andrew Ng on Coursera, which Ng helped to create.
One exception: If I recall correctly, early in the Stanford lectures, Ng does some calculations involving derivatives of traces of products of matrices. Those are rather isolated, so don't worry if you don't follow those calculations. I don't even know what course would cover those.
You do want to have some familiarity with probability, linear algebra, linear programming, and multivariable calculus. However, you need a lot less than what is contained in many complete college classes on those subjects.
|
Is a strong background in maths a total requisite for ML?
|
Stanford (Ng) and Caltech (Abu-Mostafa) have put machine learning classes on YouTube. You don't get to see the assignments, but the lectures don't rely on those. I recommend trying to watch those firs
|
Is a strong background in maths a total requisite for ML?
Stanford (Ng) and Caltech (Abu-Mostafa) have put machine learning classes on YouTube. You don't get to see the assignments, but the lectures don't rely on those. I recommend trying to watch those first, as those will help you to find out what math you need to learn. I believe a very similar class with assignments is taught by Andrew Ng on Coursera, which Ng helped to create.
One exception: If I recall correctly, early in the Stanford lectures, Ng does some calculations involving derivatives of traces of products of matrices. Those are rather isolated, so don't worry if you don't follow those calculations. I don't even know what course would cover those.
You do want to have some familiarity with probability, linear algebra, linear programming, and multivariable calculus. However, you need a lot less than what is contained in many complete college classes on those subjects.
|
Is a strong background in maths a total requisite for ML?
Stanford (Ng) and Caltech (Abu-Mostafa) have put machine learning classes on YouTube. You don't get to see the assignments, but the lectures don't rely on those. I recommend trying to watch those firs
|
7,008
|
Is a strong background in maths a total requisite for ML?
|
Depending on the kind of application, you don't necessarily need a lot of math as a ML practitioner.
As a self-taught programmer (~15 years) and frequent college dropout without much background in math (Calculus III) or statistics, I started with machine learning / data mining with a few resources:
The book "Mastering Data Mining: The Art and Science of Customer
Relationship Management" by Berry and Linoff
The book "Data Mining Techniques" by the same authors
R, in particular and the packages party and nnet
I work at a non-profit supporting marketing and operations. Especially in the beginning, I used data mining primarily for direct mail appeals.
Later I took Linear Algebra, Andrew Ng's Machine Learning, Introduction to Statistical Methods (STAT 301) at CSU, etc.
For you I recommend starting with the two books, Andrew Ng's course, and, depending on your application, decision trees (the party package in R).
|
Is a strong background in maths a total requisite for ML?
|
Depending on the kind of application, you don't necessarily need a lot of math as a ML practitioner.
As a self-taught programmer (~15 years) and frequent college dropout without much background in m
|
Is a strong background in maths a total requisite for ML?
Depending on the kind of application, you don't necessarily need a lot of math as a ML practitioner.
As a self-taught programmer (~15 years) and frequent college dropout without much background in math (Calculus III) or statistics, I started with machine learning / data mining with a few resources:
The book "Mastering Data Mining: The Art and Science of Customer
Relationship Management" by Berry and Linoff
The book "Data Mining Techniques" by the same authors
R, in particular and the packages party and nnet
I work at a non-profit supporting marketing and operations. Especially in the beginning, I used data mining primarily for direct mail appeals.
Later I took Linear Algebra, Andrew Ng's Machine Learning, Introduction to Statistical Methods (STAT 301) at CSU, etc.
For you I recommend starting with the two books, Andrew Ng's course, and, depending on your application, decision trees (the party package in R).
|
Is a strong background in maths a total requisite for ML?
Depending on the kind of application, you don't necessarily need a lot of math as a ML practitioner.
As a self-taught programmer (~15 years) and frequent college dropout without much background in m
|
7,009
|
Is a strong background in maths a total requisite for ML?
|
I think this is a good question actually, and highly topical; I'm not sure if there is an answer however. A recent article stirred a deal of controversy (see here) by suggesting that data science was easy to learn online. One notable thing about most of the case studies mentioned in that article however is that they come from actuarial or mathematical backgrounds.
This is an interesting point, because it indicates that while online courses like Coursera, Stanford and edX are helpful in teaching the specific computer science skills required, it is likely that some mathematical background is essential to understand what the models you're applying are doing. On the other hand, an equally strong argument could be made that these guys were all analytically minded to start with, and this is both why they work in quantitative disciplines as well as why they picked up machine learning easily and won competitions.
I think fundamentally that there is a levels of analysis problem going on here. While mathematical skills are sometimes helpful in understanding the probabilistic roots of the algorithms you're applying, there's an equal argument to be made that good software engineering skills can add just as much by allowing you to do high level analysis and put together parts of algorithms to accomplish your goal even if you don't entirely understand why they are doing that. Generally, data science (and machine learning by association) is an exciting field precisely because of this breadth - you can be a database guy and use brute force to solve problems, or a mathematician who uses simulation, or a computer scientist who leverages well engineered code to put together different algorithms and approaches in an optimal way.
All approaches that add to the prediction are good, so I'd say that learning some mathematics may be a good idea to give you the best chance of success in the field. If you want some good starting points, MIT has a great linear algebra course , with some nice computational applications, that I found easy to understand. They also have other courses on stochastic processes and multivariable calculus that may also be of interest in building up your knowledge.
|
Is a strong background in maths a total requisite for ML?
|
I think this is a good question actually, and highly topical; I'm not sure if there is an answer however. A recent article stirred a deal of controversy (see here) by suggesting that data science was
|
Is a strong background in maths a total requisite for ML?
I think this is a good question actually, and highly topical; I'm not sure if there is an answer however. A recent article stirred a deal of controversy (see here) by suggesting that data science was easy to learn online. One notable thing about most of the case studies mentioned in that article however is that they come from actuarial or mathematical backgrounds.
This is an interesting point, because it indicates that while online courses like Coursera, Stanford and edX are helpful in teaching the specific computer science skills required, it is likely that some mathematical background is essential to understand what the models you're applying are doing. On the other hand, an equally strong argument could be made that these guys were all analytically minded to start with, and this is both why they work in quantitative disciplines as well as why they picked up machine learning easily and won competitions.
I think fundamentally that there is a levels of analysis problem going on here. While mathematical skills are sometimes helpful in understanding the probabilistic roots of the algorithms you're applying, there's an equal argument to be made that good software engineering skills can add just as much by allowing you to do high level analysis and put together parts of algorithms to accomplish your goal even if you don't entirely understand why they are doing that. Generally, data science (and machine learning by association) is an exciting field precisely because of this breadth - you can be a database guy and use brute force to solve problems, or a mathematician who uses simulation, or a computer scientist who leverages well engineered code to put together different algorithms and approaches in an optimal way.
All approaches that add to the prediction are good, so I'd say that learning some mathematics may be a good idea to give you the best chance of success in the field. If you want some good starting points, MIT has a great linear algebra course , with some nice computational applications, that I found easy to understand. They also have other courses on stochastic processes and multivariable calculus that may also be of interest in building up your knowledge.
|
Is a strong background in maths a total requisite for ML?
I think this is a good question actually, and highly topical; I'm not sure if there is an answer however. A recent article stirred a deal of controversy (see here) by suggesting that data science was
|
7,010
|
Is a strong background in maths a total requisite for ML?
|
Is a strong background in maths a total requisite for ML? – an answer and some speculation for ML conceptualized as being statistics ;-)
Around 1990 I had hopes for computer algebra being of assistance, I think it is but it is fairly limited. But it certainly helps with speeding up the learning of math (less need to develope manipulatory skills by practice or try to get by with just being able to do the simple exercises). I found Fred Szabo's Linear Algebra with Mathematica an excellent example of this (but I had already taken an advanced theory level linear algebra course.)
I have been working since 1988 (Utilizing Computer Intensive Methods to "Concretize" Theorems and Principles from Statistics – Precisely) to make the answer no or at least not necessary (for statistics). One will always be able to understand more quickly and more generally with additional mathematical skill and understanding. I think I am starting to get close, but one needs a manipulate-able representation of probability generating models and inference that is valid and useful for more than just toy problems.
Should I try and fill in the blanks of my maths before continuing with ML?
That’s a hard endeavour – in MHO almost everyone who understands statistics got there by being very comfortable manipulating the standard and especially not so standard mathematical representations of probability generating models and mathematical characterizations of inference (the top x% of mathematical statistics Phds). So it’s not just getting the basics but being real comfortable with the math. (As an aside, for me Fourier Theory was essential.)
Why are these representations hard (even with lots of math)?
Gerd Gigerenzer has pretty much established that there is no challenge with the simple disease positive/negative given test positive/negative problem using _natural frequencies”. A reference from the linked question seems to make good use of that http://www.autonlab.org/tutorials/prob18.pdf
Why is this hard to generalize?
For k tests (repeated and or different ) – 2^k
For tests that take v values – v^k
So for binary unknown – 2 * v^k sample path probabilities
For p multiple binary unknowns 2^p * v^k
For p multiple rational unknowns Q^p * v^k
One quickly moves to math with countable and uncountable infinities to cope with this, which even with mathematical expertise leads to many misunderstandings and seeming paradoxes (e.g. Borel’s paradox?)
Additionally there is linear to non-linear hazardous misunderstandings (e.g. Hidden Dangers of Specifying Noninformative Priors Winbugs and other MCMC without information for prior distribution ) and interactions and random effects, etc.
|
Is a strong background in maths a total requisite for ML?
|
Is a strong background in maths a total requisite for ML? – an answer and some speculation for ML conceptualized as being statistics ;-)
Around 1990 I had hopes for computer algebra being of assistanc
|
Is a strong background in maths a total requisite for ML?
Is a strong background in maths a total requisite for ML? – an answer and some speculation for ML conceptualized as being statistics ;-)
Around 1990 I had hopes for computer algebra being of assistance, I think it is but it is fairly limited. But it certainly helps with speeding up the learning of math (less need to develope manipulatory skills by practice or try to get by with just being able to do the simple exercises). I found Fred Szabo's Linear Algebra with Mathematica an excellent example of this (but I had already taken an advanced theory level linear algebra course.)
I have been working since 1988 (Utilizing Computer Intensive Methods to "Concretize" Theorems and Principles from Statistics – Precisely) to make the answer no or at least not necessary (for statistics). One will always be able to understand more quickly and more generally with additional mathematical skill and understanding. I think I am starting to get close, but one needs a manipulate-able representation of probability generating models and inference that is valid and useful for more than just toy problems.
Should I try and fill in the blanks of my maths before continuing with ML?
That’s a hard endeavour – in MHO almost everyone who understands statistics got there by being very comfortable manipulating the standard and especially not so standard mathematical representations of probability generating models and mathematical characterizations of inference (the top x% of mathematical statistics Phds). So it’s not just getting the basics but being real comfortable with the math. (As an aside, for me Fourier Theory was essential.)
Why are these representations hard (even with lots of math)?
Gerd Gigerenzer has pretty much established that there is no challenge with the simple disease positive/negative given test positive/negative problem using _natural frequencies”. A reference from the linked question seems to make good use of that http://www.autonlab.org/tutorials/prob18.pdf
Why is this hard to generalize?
For k tests (repeated and or different ) – 2^k
For tests that take v values – v^k
So for binary unknown – 2 * v^k sample path probabilities
For p multiple binary unknowns 2^p * v^k
For p multiple rational unknowns Q^p * v^k
One quickly moves to math with countable and uncountable infinities to cope with this, which even with mathematical expertise leads to many misunderstandings and seeming paradoxes (e.g. Borel’s paradox?)
Additionally there is linear to non-linear hazardous misunderstandings (e.g. Hidden Dangers of Specifying Noninformative Priors Winbugs and other MCMC without information for prior distribution ) and interactions and random effects, etc.
|
Is a strong background in maths a total requisite for ML?
Is a strong background in maths a total requisite for ML? – an answer and some speculation for ML conceptualized as being statistics ;-)
Around 1990 I had hopes for computer algebra being of assistanc
|
7,011
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
The function cv.glmnet from the R package glmnet does automatic cross-validation on a grid of $\lambda$ values used for $\ell_1$-penalized regression problems. In particular, for the lasso. The glmnet package also supports the more general elastic net penalty, which is a combination of $\ell_1$ and $\ell_2$ penalization. As of version 1.7.3. of the package taking the $\alpha$ parameter equal to 0 gives ridge regression (at least, this functionality was not documented until recently).
Cross-validation is an estimate of the expected generalization error for each $\lambda$ and $\lambda$ can sensibly be chosen as the minimizer of this estimate. The cv.glmnet function returns two values of $\lambda$. The minimizer, lambda.min, and the always larger lambda.1se, which is a heuristic choice of $\lambda$ producing a less complex model, for which the performance in terms of estimated expected generalization error is within one standard error of the minimum. Different choices of loss functions for measuring the generalization error are possible in the glmnet package. The argument type.measure specifies the loss function.
Alternatively, the R package mgcv contains extensive possibilities for estimation with quadratic penalization including automatic selection of the penalty parameters. Methods implemented include generalized cross-validation and REML, as mentioned in a comment. More details can be found in the package authors book: Wood, S.N. (2006) Generalized Additive Models: an introduction with R, CRC.
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
The function cv.glmnet from the R package glmnet does automatic cross-validation on a grid of $\lambda$ values used for $\ell_1$-penalized regression problems. In particular, for the lasso. The glmnet
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
The function cv.glmnet from the R package glmnet does automatic cross-validation on a grid of $\lambda$ values used for $\ell_1$-penalized regression problems. In particular, for the lasso. The glmnet package also supports the more general elastic net penalty, which is a combination of $\ell_1$ and $\ell_2$ penalization. As of version 1.7.3. of the package taking the $\alpha$ parameter equal to 0 gives ridge regression (at least, this functionality was not documented until recently).
Cross-validation is an estimate of the expected generalization error for each $\lambda$ and $\lambda$ can sensibly be chosen as the minimizer of this estimate. The cv.glmnet function returns two values of $\lambda$. The minimizer, lambda.min, and the always larger lambda.1se, which is a heuristic choice of $\lambda$ producing a less complex model, for which the performance in terms of estimated expected generalization error is within one standard error of the minimum. Different choices of loss functions for measuring the generalization error are possible in the glmnet package. The argument type.measure specifies the loss function.
Alternatively, the R package mgcv contains extensive possibilities for estimation with quadratic penalization including automatic selection of the penalty parameters. Methods implemented include generalized cross-validation and REML, as mentioned in a comment. More details can be found in the package authors book: Wood, S.N. (2006) Generalized Additive Models: an introduction with R, CRC.
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
The function cv.glmnet from the R package glmnet does automatic cross-validation on a grid of $\lambda$ values used for $\ell_1$-penalized regression problems. In particular, for the lasso. The glmnet
|
7,012
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
This answer is MATLAB specific, however, the basic concepts should be quite similar to what you're used to with R...
In the case of MATLAB, you have the option to run lasso with cross validation enabled.
If you do so, the lasso function will report two critical parameter values
The lambda value that minimizes the cross validated mean squared error
The lambda value with the greatest amount of shrinkage whose CVMSE is within one standard error of the minimum.
You also get a nice little chart that you can use to inspect the relationship between lambda and CVMSE
In general, you'll chose a value of lambda that falls between the blue line and the green line.
The following blog posting includes some demo code based on some examples in
Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. J. Royal. Statist. Soc B., Vol. 58, No. 1, pages 267-288).
http://blogs.mathworks.com/loren/2011/11/29/subset-selection-and-regularization-part-2/
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
This answer is MATLAB specific, however, the basic concepts should be quite similar to what you're used to with R...
In the case of MATLAB, you have the option to run lasso with cross validation enabl
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
This answer is MATLAB specific, however, the basic concepts should be quite similar to what you're used to with R...
In the case of MATLAB, you have the option to run lasso with cross validation enabled.
If you do so, the lasso function will report two critical parameter values
The lambda value that minimizes the cross validated mean squared error
The lambda value with the greatest amount of shrinkage whose CVMSE is within one standard error of the minimum.
You also get a nice little chart that you can use to inspect the relationship between lambda and CVMSE
In general, you'll chose a value of lambda that falls between the blue line and the green line.
The following blog posting includes some demo code based on some examples in
Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. J. Royal. Statist. Soc B., Vol. 58, No. 1, pages 267-288).
http://blogs.mathworks.com/loren/2011/11/29/subset-selection-and-regularization-part-2/
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
This answer is MATLAB specific, however, the basic concepts should be quite similar to what you're used to with R...
In the case of MATLAB, you have the option to run lasso with cross validation enabl
|
7,013
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
I have had good success using effective AIC, that is using AIC with the effective degrees of freedom - see Gray JASA 87:942 1992 for effective d.f. This is implemented for $L_{2}$ penalty in the R rms package for linear and logistic models, and the rms pentrace function can be used to solve for the shrinkage coefficient that optimizes effective AIC. A case study that shows how to do differential shrinkage (e.g. more shrinkage for interactions) is Harrell et al Stat in Med 17:909, 1998.
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
|
I have had good success using effective AIC, that is using AIC with the effective degrees of freedom - see Gray JASA 87:942 1992 for effective d.f. This is implemented for $L_{2}$ penalty in the R rm
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
I have had good success using effective AIC, that is using AIC with the effective degrees of freedom - see Gray JASA 87:942 1992 for effective d.f. This is implemented for $L_{2}$ penalty in the R rms package for linear and logistic models, and the rms pentrace function can be used to solve for the shrinkage coefficient that optimizes effective AIC. A case study that shows how to do differential shrinkage (e.g. more shrinkage for interactions) is Harrell et al Stat in Med 17:909, 1998.
|
How to estimate shrinkage parameter in Lasso or ridge regression with >50K variables?
I have had good success using effective AIC, that is using AIC with the effective degrees of freedom - see Gray JASA 87:942 1992 for effective d.f. This is implemented for $L_{2}$ penalty in the R rm
|
7,014
|
What are the differences between sparse coding and autoencoder?
|
Finding the differences can be done by looking at the models. Let's look at sparse coding first.
Sparse coding
Sparse coding minimizes the objective
$$
\mathcal{L}_{\text{sc}} = \underbrace{||WH - X||_2^2}_{\text{reconstruction term}} + \underbrace{\lambda ||H||_1}_{\text{sparsity term}}
$$
where $W$ is a matrix of bases, H is a matrix of codes and $X$ is a matrix of the data we wish to represent. $\lambda$ implements a trade of between sparsity and reconstruction. Note that if we are given $H$, estimation of $W$ is easy via least squares.
In the beginning, we do not have $H$ however. Yet, many algorithms exist that can solve the objective above with respect to $H$. Actually, this is how we do inference: we need to solve an optimisation problem if we want to know the $h$ belonging to an unseen $x$.
Auto encoders
Auto encoders are a family of unsupervised neural networks. There are quite a lot of them, e.g. deep auto encoders or those having different regularisation tricks attached--e.g. denoising, contractive, sparse. There even exist probabilistic ones, such as generative stochastic networks or the variational auto encoder. Their most abstract form is
$$
D(d(e(x;\theta^r); \theta^d), x)
$$
but we will go along with a much simpler one for now:
$$
\mathcal{L}_{\text{ae}} = ||W\sigma(W^TX) - X||^2
$$
where $\sigma$ is a nonlinear function such as the logistic sigmoid $\sigma(x) = {1 \over 1 + \exp(-x)}$.
Similarities
Note that $\mathcal{L}_{sc}$ looks almost like $\mathcal{L}_{ae}$ once we set $H = \sigma(W^TX)$. The difference of both is that i) auto encoders do not encourage sparsity in their general form ii) an autoencoder uses a model for finding the codes, while sparse coding does so by means of optimisation.
For natural image data, regularized auto encoders and sparse coding tend to yield very similar $W$. However, auto encoders are much more efficient and are easily generalized to much more complicated models. E.g. the decoder can be highly nonlinear, e.g. a deep neural network. Furthermore, one is not tied to the squared loss (on which the estimation of $W$ for $\mathcal{L}_{sc}$ depends.)
Also, the different methods of regularisation yield representations with different characteristica. Denoising auto encoders have also been shown to be equivalent to a certain form of RBMs etc.
But why?
If you want to solve a prediction problem, you will not need auto encoders unless you have only little labeled data and a lot of unlabeled data. Then you will generally be better of to train a deep auto encoder and put a linear SVM on top instead of training a deep neural net.
However, they are very powerful models for capturing characteristica of distributions. This is vague, but research turning this into hard statistical facts is currently conducted. Deep latent Gaussian models aka Variational Auto encoders or generative stochastic networks are pretty interesting ways of obtaining auto encoders which provably estimate the underlying data distribution.
|
What are the differences between sparse coding and autoencoder?
|
Finding the differences can be done by looking at the models. Let's look at sparse coding first.
Sparse coding
Sparse coding minimizes the objective
$$
\mathcal{L}_{\text{sc}} = \underbrace{||WH - X|
|
What are the differences between sparse coding and autoencoder?
Finding the differences can be done by looking at the models. Let's look at sparse coding first.
Sparse coding
Sparse coding minimizes the objective
$$
\mathcal{L}_{\text{sc}} = \underbrace{||WH - X||_2^2}_{\text{reconstruction term}} + \underbrace{\lambda ||H||_1}_{\text{sparsity term}}
$$
where $W$ is a matrix of bases, H is a matrix of codes and $X$ is a matrix of the data we wish to represent. $\lambda$ implements a trade of between sparsity and reconstruction. Note that if we are given $H$, estimation of $W$ is easy via least squares.
In the beginning, we do not have $H$ however. Yet, many algorithms exist that can solve the objective above with respect to $H$. Actually, this is how we do inference: we need to solve an optimisation problem if we want to know the $h$ belonging to an unseen $x$.
Auto encoders
Auto encoders are a family of unsupervised neural networks. There are quite a lot of them, e.g. deep auto encoders or those having different regularisation tricks attached--e.g. denoising, contractive, sparse. There even exist probabilistic ones, such as generative stochastic networks or the variational auto encoder. Their most abstract form is
$$
D(d(e(x;\theta^r); \theta^d), x)
$$
but we will go along with a much simpler one for now:
$$
\mathcal{L}_{\text{ae}} = ||W\sigma(W^TX) - X||^2
$$
where $\sigma$ is a nonlinear function such as the logistic sigmoid $\sigma(x) = {1 \over 1 + \exp(-x)}$.
Similarities
Note that $\mathcal{L}_{sc}$ looks almost like $\mathcal{L}_{ae}$ once we set $H = \sigma(W^TX)$. The difference of both is that i) auto encoders do not encourage sparsity in their general form ii) an autoencoder uses a model for finding the codes, while sparse coding does so by means of optimisation.
For natural image data, regularized auto encoders and sparse coding tend to yield very similar $W$. However, auto encoders are much more efficient and are easily generalized to much more complicated models. E.g. the decoder can be highly nonlinear, e.g. a deep neural network. Furthermore, one is not tied to the squared loss (on which the estimation of $W$ for $\mathcal{L}_{sc}$ depends.)
Also, the different methods of regularisation yield representations with different characteristica. Denoising auto encoders have also been shown to be equivalent to a certain form of RBMs etc.
But why?
If you want to solve a prediction problem, you will not need auto encoders unless you have only little labeled data and a lot of unlabeled data. Then you will generally be better of to train a deep auto encoder and put a linear SVM on top instead of training a deep neural net.
However, they are very powerful models for capturing characteristica of distributions. This is vague, but research turning this into hard statistical facts is currently conducted. Deep latent Gaussian models aka Variational Auto encoders or generative stochastic networks are pretty interesting ways of obtaining auto encoders which provably estimate the underlying data distribution.
|
What are the differences between sparse coding and autoencoder?
Finding the differences can be done by looking at the models. Let's look at sparse coding first.
Sparse coding
Sparse coding minimizes the objective
$$
\mathcal{L}_{\text{sc}} = \underbrace{||WH - X|
|
7,015
|
What are the differences between sparse coding and autoencoder?
|
In neuroscience the term Neural Coding is used to refer to the patterns of electrical activity of neurons induced by a stimulus. Sparse Coding by its turn is one kind of pattern. A code is said to be sparse when a stimulus (like an image) provokes the activation of just a relatively small number of neurons, that combined represent it in a sparse way. In machine learning the same optimization constraint used to create a sparse code model can be used to implement Sparse Autoencoders, which are regular autoencoders trained with a sparsity constraint. Bellow more detailed explanations for each of your questions are given.
Sparse coding is defined as learning an over-complete set of basis vectors to represent input vectors (<-- why do we want this)
First, at least since (Hubel & Wiesel, 1968) it's known that in the V1 region there are specific cells which respond maximally to edge-like stimulus (besides having others "useful" properties). Sparse Coding is a model which explains well many of the observed characteristics of this system. See (Olshausen & Field, 1996) for more details.
Second, it's being shown that the model which describes sparse coding is a useful technique for feature extraction in Machine Learning and yields good results in transfer learning tasks. Raina et al. (2007) showed that a set of "basis vectors" (features, as pen-strokes and edges) learned with a training set composed of hand-written characters improves classification in a hand-written digits recognition task. Later Sparse Coding based models has been used to train "deep" networks, stacking layers of sparse feature detectors to create a "sparse deep belief net" (Lee et al., 2007). More recently astonishing results in image recognition was achieved using sparse coding based models to construct a network with several layers (the famous "Google Brain"), which was capable of distinguish a image of a cat in a purely unsupervised manner (Le et al., 2013).
Third, it's probably possible to use the learned basis to perform compression. A haven't seen anyone really doing it though.
What are the difference between sparse coding and autoencoder?
An autoencoder is a model which tries to reconstruct its input, usually using some sort of constraint. Accordingly to Wikipedia it "is an artificial neural network used for learning efficient codings". There's nothing in autoencoder's definition requiring sparsity. Sparse coding based contraints is one of the available techniques, but there are others, for example Denoising Autoencoders, Contractive Autoencoders and RBMs. All makes the network learn good representations of the input (that are also commonly "sparse").
When will we use sparse coding and autoencoder?
You're probably interested in using an auto-encoder for feature extraction and/or pre-training of deep networks. If you implement an autoencoder with the sparsity constraint, you'll be using both.
|
What are the differences between sparse coding and autoencoder?
|
In neuroscience the term Neural Coding is used to refer to the patterns of electrical activity of neurons induced by a stimulus. Sparse Coding by its turn is one kind of pattern. A code is said to be
|
What are the differences between sparse coding and autoencoder?
In neuroscience the term Neural Coding is used to refer to the patterns of electrical activity of neurons induced by a stimulus. Sparse Coding by its turn is one kind of pattern. A code is said to be sparse when a stimulus (like an image) provokes the activation of just a relatively small number of neurons, that combined represent it in a sparse way. In machine learning the same optimization constraint used to create a sparse code model can be used to implement Sparse Autoencoders, which are regular autoencoders trained with a sparsity constraint. Bellow more detailed explanations for each of your questions are given.
Sparse coding is defined as learning an over-complete set of basis vectors to represent input vectors (<-- why do we want this)
First, at least since (Hubel & Wiesel, 1968) it's known that in the V1 region there are specific cells which respond maximally to edge-like stimulus (besides having others "useful" properties). Sparse Coding is a model which explains well many of the observed characteristics of this system. See (Olshausen & Field, 1996) for more details.
Second, it's being shown that the model which describes sparse coding is a useful technique for feature extraction in Machine Learning and yields good results in transfer learning tasks. Raina et al. (2007) showed that a set of "basis vectors" (features, as pen-strokes and edges) learned with a training set composed of hand-written characters improves classification in a hand-written digits recognition task. Later Sparse Coding based models has been used to train "deep" networks, stacking layers of sparse feature detectors to create a "sparse deep belief net" (Lee et al., 2007). More recently astonishing results in image recognition was achieved using sparse coding based models to construct a network with several layers (the famous "Google Brain"), which was capable of distinguish a image of a cat in a purely unsupervised manner (Le et al., 2013).
Third, it's probably possible to use the learned basis to perform compression. A haven't seen anyone really doing it though.
What are the difference between sparse coding and autoencoder?
An autoencoder is a model which tries to reconstruct its input, usually using some sort of constraint. Accordingly to Wikipedia it "is an artificial neural network used for learning efficient codings". There's nothing in autoencoder's definition requiring sparsity. Sparse coding based contraints is one of the available techniques, but there are others, for example Denoising Autoencoders, Contractive Autoencoders and RBMs. All makes the network learn good representations of the input (that are also commonly "sparse").
When will we use sparse coding and autoencoder?
You're probably interested in using an auto-encoder for feature extraction and/or pre-training of deep networks. If you implement an autoencoder with the sparsity constraint, you'll be using both.
|
What are the differences between sparse coding and autoencoder?
In neuroscience the term Neural Coding is used to refer to the patterns of electrical activity of neurons induced by a stimulus. Sparse Coding by its turn is one kind of pattern. A code is said to be
|
7,016
|
What are the differences between sparse coding and autoencoder?
|
A sparse coder is kind of like half an auto-encoder. An auto-encoder works like:
input => neural net layer => hidden outputs => neural net layer => output
For back-propagation, the error signal, the loss, is: input - output
If we apply a sparsity constraint on the hidden outputs, then most will be zeros, and a few will be 1s. Then the second layer is essentially a set of linear basis functions, that are added together, according to which of the hidden outputs are 1s.
In sparse coding, we only have the second half of this:
codes => neural net layer => output
The 'codes' is a bunch of real numbers, selecting for the basis functions represented by the weights in the neural net layer. Since in Olshausen's paper, they are applying a sparsity constraint to the codes, the codes are, just as in the sparse auto-encoder, sparse: mostly zeros with a few ones.
The difference we can see now clearly: for the sparse coding, there is no first half of the neural network: the codes are not provided for us automatically by a neural net.
How do we get the codes in sparse coding? We have to optimize ourselves, which we do by using gradient descent or similar, to find the set of codes that best provides output matching the input image. We have to do this for every image, including for every test image, each time.
|
What are the differences between sparse coding and autoencoder?
|
A sparse coder is kind of like half an auto-encoder. An auto-encoder works like:
input => neural net layer => hidden outputs => neural net layer => output
For back-propagation, the error signal,
|
What are the differences between sparse coding and autoencoder?
A sparse coder is kind of like half an auto-encoder. An auto-encoder works like:
input => neural net layer => hidden outputs => neural net layer => output
For back-propagation, the error signal, the loss, is: input - output
If we apply a sparsity constraint on the hidden outputs, then most will be zeros, and a few will be 1s. Then the second layer is essentially a set of linear basis functions, that are added together, according to which of the hidden outputs are 1s.
In sparse coding, we only have the second half of this:
codes => neural net layer => output
The 'codes' is a bunch of real numbers, selecting for the basis functions represented by the weights in the neural net layer. Since in Olshausen's paper, they are applying a sparsity constraint to the codes, the codes are, just as in the sparse auto-encoder, sparse: mostly zeros with a few ones.
The difference we can see now clearly: for the sparse coding, there is no first half of the neural network: the codes are not provided for us automatically by a neural net.
How do we get the codes in sparse coding? We have to optimize ourselves, which we do by using gradient descent or similar, to find the set of codes that best provides output matching the input image. We have to do this for every image, including for every test image, each time.
|
What are the differences between sparse coding and autoencoder?
A sparse coder is kind of like half an auto-encoder. An auto-encoder works like:
input => neural net layer => hidden outputs => neural net layer => output
For back-propagation, the error signal,
|
7,017
|
What are the differences between sparse coding and autoencoder?
|
You might want to read this recent paper, https://arxiv.org/abs/1708.03735v2 on precisely this same topic. In this paper the authors show that indeed one can set up an autoencoder such that the ground truth dictionary is a critical point of that autoencoder's squared loss function.
|
What are the differences between sparse coding and autoencoder?
|
You might want to read this recent paper, https://arxiv.org/abs/1708.03735v2 on precisely this same topic. In this paper the authors show that indeed one can set up an autoencoder such that the ground
|
What are the differences between sparse coding and autoencoder?
You might want to read this recent paper, https://arxiv.org/abs/1708.03735v2 on precisely this same topic. In this paper the authors show that indeed one can set up an autoencoder such that the ground truth dictionary is a critical point of that autoencoder's squared loss function.
|
What are the differences between sparse coding and autoencoder?
You might want to read this recent paper, https://arxiv.org/abs/1708.03735v2 on precisely this same topic. In this paper the authors show that indeed one can set up an autoencoder such that the ground
|
7,018
|
Can SVM do stream learning one example at a time?
|
The streaming setting in machine learning is called "online learning". There is no exact support vector machine in the online setting (since the definition of the objective function is inherently for the batch setting). Probably the most straightforward generalization of the SVM to the online setting are passive-aggressive algorithms. Code is here http://webee.technion.ac.il/people/koby/code-index.html and an associated paper is here http://eprints.pascal-network.org/archive/00002147/01/CrammerDeKeShSi06.pdf
The basic idea is that one recieves data as $(\mathbf{x},y)\in\mathbb{R}^d\times [k]$ pairs with query points $\mathbf{x}\in \mathbb{R}$ where $k$ is the number of labels. The algorithm maintains a weight matrix $W_t\in \mathbb{R}^{k\times d}$ at iteration $t$ the algorithms recieves a data point $\mathbf{x}_t$ and then gives predicted scores $\hat{\mathbf{y}}_t=W\mathbf{x}_t$ for each of the labels and it predicts the highest scoring label as the true label. If the prediction is wrong then the algorithm makes the smallest change to $W_t$ such that it will avoid that mistake in the future. Smallest change is here defined in terms of the Frobenius norm.
|
Can SVM do stream learning one example at a time?
|
The streaming setting in machine learning is called "online learning". There is no exact support vector machine in the online setting (since the definition of the objective function is inherently for
|
Can SVM do stream learning one example at a time?
The streaming setting in machine learning is called "online learning". There is no exact support vector machine in the online setting (since the definition of the objective function is inherently for the batch setting). Probably the most straightforward generalization of the SVM to the online setting are passive-aggressive algorithms. Code is here http://webee.technion.ac.il/people/koby/code-index.html and an associated paper is here http://eprints.pascal-network.org/archive/00002147/01/CrammerDeKeShSi06.pdf
The basic idea is that one recieves data as $(\mathbf{x},y)\in\mathbb{R}^d\times [k]$ pairs with query points $\mathbf{x}\in \mathbb{R}$ where $k$ is the number of labels. The algorithm maintains a weight matrix $W_t\in \mathbb{R}^{k\times d}$ at iteration $t$ the algorithms recieves a data point $\mathbf{x}_t$ and then gives predicted scores $\hat{\mathbf{y}}_t=W\mathbf{x}_t$ for each of the labels and it predicts the highest scoring label as the true label. If the prediction is wrong then the algorithm makes the smallest change to $W_t$ such that it will avoid that mistake in the future. Smallest change is here defined in terms of the Frobenius norm.
|
Can SVM do stream learning one example at a time?
The streaming setting in machine learning is called "online learning". There is no exact support vector machine in the online setting (since the definition of the objective function is inherently for
|
7,019
|
Can SVM do stream learning one example at a time?
|
I've always found the implicit updates framework (that includes the passive-aggressive algorithms mentioned in another answer here) to be unnecessarily more complex than the explicit updates framework (not to mention that implicit updates can be much slower than the explicit ones unless a closed-form solution for implicit update is available).
Online Importance Weight Aware Updates is an example of a state-of-the-art explicit update algorithm which is simpler, faster, and more flexible (supporting multiple loss functions, multiple penalties, cost-sensitive learning etc.) than its implicit counterparts. The paper deals with linear models only though (linear svm corresponds to the case of hinge loss function with quadratic penalty)
Since you need multi-class classification, one approach is to use the "reductions" functionality of vowpal wabbit (built on the top of the approach from the paper) which is not documented well unfortunately.
|
Can SVM do stream learning one example at a time?
|
I've always found the implicit updates framework (that includes the passive-aggressive algorithms mentioned in another answer here) to be unnecessarily more complex than the explicit updates framework
|
Can SVM do stream learning one example at a time?
I've always found the implicit updates framework (that includes the passive-aggressive algorithms mentioned in another answer here) to be unnecessarily more complex than the explicit updates framework (not to mention that implicit updates can be much slower than the explicit ones unless a closed-form solution for implicit update is available).
Online Importance Weight Aware Updates is an example of a state-of-the-art explicit update algorithm which is simpler, faster, and more flexible (supporting multiple loss functions, multiple penalties, cost-sensitive learning etc.) than its implicit counterparts. The paper deals with linear models only though (linear svm corresponds to the case of hinge loss function with quadratic penalty)
Since you need multi-class classification, one approach is to use the "reductions" functionality of vowpal wabbit (built on the top of the approach from the paper) which is not documented well unfortunately.
|
Can SVM do stream learning one example at a time?
I've always found the implicit updates framework (that includes the passive-aggressive algorithms mentioned in another answer here) to be unnecessarily more complex than the explicit updates framework
|
7,020
|
Can SVM do stream learning one example at a time?
|
LASVM is one of the most popular online learning variants of the SVM.
Linear SVMs can also be trained using stochastic gradient descent, just like any linear model.
|
Can SVM do stream learning one example at a time?
|
LASVM is one of the most popular online learning variants of the SVM.
Linear SVMs can also be trained using stochastic gradient descent, just like any linear model.
|
Can SVM do stream learning one example at a time?
LASVM is one of the most popular online learning variants of the SVM.
Linear SVMs can also be trained using stochastic gradient descent, just like any linear model.
|
Can SVM do stream learning one example at a time?
LASVM is one of the most popular online learning variants of the SVM.
Linear SVMs can also be trained using stochastic gradient descent, just like any linear model.
|
7,021
|
Can SVM do stream learning one example at a time?
|
Please refer to paper SVM Incremental Learning, Adaptation, and Optimization, which proposed an online SVM for binary classification.
The code of above paper can be found here. In the code, two ways of online training are introduced:
train the SVM incrementally on one example at a time by calling svmtrain(), and
perform batch training, incrementing all the training examples into the solution simultaneously by calling svmtrain2().
Back to your question, the answer is obviously YES for stream learning one example at a time. And the code can also handle unlearn (discard) a example, i.e. exact and approximate leave-one-out (LOO) error estimation - the exact LOO error estimate can be efficiently computed by exactly unlearning one example at a time and testing the classifier on the example.
|
Can SVM do stream learning one example at a time?
|
Please refer to paper SVM Incremental Learning, Adaptation, and Optimization, which proposed an online SVM for binary classification.
The code of above paper can be found here. In the code, two ways o
|
Can SVM do stream learning one example at a time?
Please refer to paper SVM Incremental Learning, Adaptation, and Optimization, which proposed an online SVM for binary classification.
The code of above paper can be found here. In the code, two ways of online training are introduced:
train the SVM incrementally on one example at a time by calling svmtrain(), and
perform batch training, incrementing all the training examples into the solution simultaneously by calling svmtrain2().
Back to your question, the answer is obviously YES for stream learning one example at a time. And the code can also handle unlearn (discard) a example, i.e. exact and approximate leave-one-out (LOO) error estimation - the exact LOO error estimate can be efficiently computed by exactly unlearning one example at a time and testing the classifier on the example.
|
Can SVM do stream learning one example at a time?
Please refer to paper SVM Incremental Learning, Adaptation, and Optimization, which proposed an online SVM for binary classification.
The code of above paper can be found here. In the code, two ways o
|
7,022
|
Can SVM do stream learning one example at a time?
|
Online Learning with Kernels discusses online learning in general kernel settings.
Excerpt from the abstract -
"Kernel based algorithms such as support vector machines have achieved considerable success in various problems in the batch setting where all of the training data is available in advance. Support vector machines combine the so-called kernel trick with the large margin idea. There has been little use of these methods in an online setting suitable for real-time applications. In this paper we consider online learning in a Reproducing Kernel Hilbert Space. By considering classical stochastic gradient descent within a feature space, and the use of some straight-forward tricks, we develop simple and computationally efficient algorithms for a wide range of problems such as classification, regression, and novelty detection."
|
Can SVM do stream learning one example at a time?
|
Online Learning with Kernels discusses online learning in general kernel settings.
Excerpt from the abstract -
"Kernel based algorithms such as support vector machines have achieved considerable suc
|
Can SVM do stream learning one example at a time?
Online Learning with Kernels discusses online learning in general kernel settings.
Excerpt from the abstract -
"Kernel based algorithms such as support vector machines have achieved considerable success in various problems in the batch setting where all of the training data is available in advance. Support vector machines combine the so-called kernel trick with the large margin idea. There has been little use of these methods in an online setting suitable for real-time applications. In this paper we consider online learning in a Reproducing Kernel Hilbert Space. By considering classical stochastic gradient descent within a feature space, and the use of some straight-forward tricks, we develop simple and computationally efficient algorithms for a wide range of problems such as classification, regression, and novelty detection."
|
Can SVM do stream learning one example at a time?
Online Learning with Kernels discusses online learning in general kernel settings.
Excerpt from the abstract -
"Kernel based algorithms such as support vector machines have achieved considerable suc
|
7,023
|
What is the "capacity" of a machine learning model?
|
Capacity is an informal term. It's very close (if not a synonym) for model complexity. It's a way to talk about how complicated a pattern or relationship a model can express. You could expect a model with higher capacity to be able to model more relationships between more variables than a model with a lower capacity.
Drawing an analogy from the colloquial definition of capacity, you can think of it as the ability of a model to learn from more and more data, until it's been completely "filled up" with information.
There are various ways to formalize capacity and compute a numerical value for it, but importantly these are just some possible "operationalizations" of capacity (in much the same way that, if someone came up with a formula to compute beauty, you would realize that the formula is just one fallible interpretation of beauty).
VC dimension is a mathematically rigorous formulation of capacity. However, there can be a large gap between the VC dimension of a model and the model's actual ability to fit the data. Even though knowing the VC dim gives a bound on the generalization error of the model, this is usually too loose to be useful with neural networks.
Another line of research see here is to use the spectral norm of the weight matrices in a neural network as a measure of capacity. One way to understand this is that the spectral norm bounds the Lipschitz constant of the network.
The most common way to estimate the capacity of a model is to count the number of parameters. The more parameters, the higher the capacity in general. Of course, often a smaller network learns to model more complex data better than a larger network, so this measure is also far from perfect.
Another way to measure capacity might be to train your model with random labels (Neyshabur et. al) -- if your network can correctly remember a bunch of inputs along with random labels, it essentially shows that the model has the ability to remember all those data points individually. The more input/output pairs which can be "learned", the higher the capacity.
Adapting this to an auto-encoder, you might
generate random inputs, train the network to reconstruct them, and then count how many random inputs you can successfully reconstruct with less than $\epsilon$ error.
|
What is the "capacity" of a machine learning model?
|
Capacity is an informal term. It's very close (if not a synonym) for model complexity. It's a way to talk about how complicated a pattern or relationship a model can express. You could expect a model
|
What is the "capacity" of a machine learning model?
Capacity is an informal term. It's very close (if not a synonym) for model complexity. It's a way to talk about how complicated a pattern or relationship a model can express. You could expect a model with higher capacity to be able to model more relationships between more variables than a model with a lower capacity.
Drawing an analogy from the colloquial definition of capacity, you can think of it as the ability of a model to learn from more and more data, until it's been completely "filled up" with information.
There are various ways to formalize capacity and compute a numerical value for it, but importantly these are just some possible "operationalizations" of capacity (in much the same way that, if someone came up with a formula to compute beauty, you would realize that the formula is just one fallible interpretation of beauty).
VC dimension is a mathematically rigorous formulation of capacity. However, there can be a large gap between the VC dimension of a model and the model's actual ability to fit the data. Even though knowing the VC dim gives a bound on the generalization error of the model, this is usually too loose to be useful with neural networks.
Another line of research see here is to use the spectral norm of the weight matrices in a neural network as a measure of capacity. One way to understand this is that the spectral norm bounds the Lipschitz constant of the network.
The most common way to estimate the capacity of a model is to count the number of parameters. The more parameters, the higher the capacity in general. Of course, often a smaller network learns to model more complex data better than a larger network, so this measure is also far from perfect.
Another way to measure capacity might be to train your model with random labels (Neyshabur et. al) -- if your network can correctly remember a bunch of inputs along with random labels, it essentially shows that the model has the ability to remember all those data points individually. The more input/output pairs which can be "learned", the higher the capacity.
Adapting this to an auto-encoder, you might
generate random inputs, train the network to reconstruct them, and then count how many random inputs you can successfully reconstruct with less than $\epsilon$ error.
|
What is the "capacity" of a machine learning model?
Capacity is an informal term. It's very close (if not a synonym) for model complexity. It's a way to talk about how complicated a pattern or relationship a model can express. You could expect a model
|
7,024
|
What is the "capacity" of a machine learning model?
|
In the fundamental challenge of Machine Learning: Does the model I built truly generalize? one way to approach it is by using model capacity.
Higher the model capacity, the more expressive the model (i.e., it can accommodate more variation).
Capacity needs to be tuned with respect to the amount of data at hand. If a dataset is small we are better off training models with lower capacity.
Yes you can measure the capacity of a model if you first agree what a good metric has to be used. Usually variation is used for that.
|
What is the "capacity" of a machine learning model?
|
In the fundamental challenge of Machine Learning: Does the model I built truly generalize? one way to approach it is by using model capacity.
Higher the model capacity, the more expressive the model (
|
What is the "capacity" of a machine learning model?
In the fundamental challenge of Machine Learning: Does the model I built truly generalize? one way to approach it is by using model capacity.
Higher the model capacity, the more expressive the model (i.e., it can accommodate more variation).
Capacity needs to be tuned with respect to the amount of data at hand. If a dataset is small we are better off training models with lower capacity.
Yes you can measure the capacity of a model if you first agree what a good metric has to be used. Usually variation is used for that.
|
What is the "capacity" of a machine learning model?
In the fundamental challenge of Machine Learning: Does the model I built truly generalize? one way to approach it is by using model capacity.
Higher the model capacity, the more expressive the model (
|
7,025
|
When is it appropriate to use an improper scoring rule?
|
It is appropriate to use an improper scoring rule when the purpose is actually forecasting, but not inference. I don't really care whether another forecaster is cheating or not when I am the one who is going to be doing the forecast.
Proper scoring rules ensure that during estimation process the model approaches the true data generating process (DGP). This sounds promising because as we approach the true DGP we will be also doing good in terms of forecasting under any loss function. The catch is that most of the time (actually in reality almost always) our model search space doesn't contain the true DGP. We end up approximating the true DGP with some functional form that we propose.
In this more realistic setting, if our forecasting task is easier than to figure out the entire density of the true DGP we may actually do better. This is especially true for classification. For example the true DGP can be very complex but the classification task can be very easy.
Yaroslav Bulatov provided the following example in his blog:
http://yaroslavvb.blogspot.ro/2007/06/log-loss-or-hinge-loss.html
As you can see below the true density is wiggly but it is very easy to build a classifier to separate data generated by this into two classes. Simply if $x \ge 0$ output class 1, and if $x < 0$ output class 2.
Instead of matching the exact density above we propose the below crude model, which is quite far from the true DGP. However it does perfect classification. This is found by using hinge loss, which is not proper.
On the other hand if you decide to find the true DGP with log-loss (which is proper) then you start fitting some functionals, as you don't know what the exact functional form you need a priori. But as you try harder and harder to match it, you start misclassifying things.
Note that in both cases we used the same functional forms. In the improper loss case it degenerated into a step function which in turn did perfect classification. In the proper case it went berserk trying to satisfy every region of the density.
Basically we don't always need to achieve the true model to have accurate forecasts. Or sometimes we don't really need to do good on the entire domain of the density, but be very good only on certain parts of it.
|
When is it appropriate to use an improper scoring rule?
|
It is appropriate to use an improper scoring rule when the purpose is actually forecasting, but not inference. I don't really care whether another forecaster is cheating or not when I am the one who i
|
When is it appropriate to use an improper scoring rule?
It is appropriate to use an improper scoring rule when the purpose is actually forecasting, but not inference. I don't really care whether another forecaster is cheating or not when I am the one who is going to be doing the forecast.
Proper scoring rules ensure that during estimation process the model approaches the true data generating process (DGP). This sounds promising because as we approach the true DGP we will be also doing good in terms of forecasting under any loss function. The catch is that most of the time (actually in reality almost always) our model search space doesn't contain the true DGP. We end up approximating the true DGP with some functional form that we propose.
In this more realistic setting, if our forecasting task is easier than to figure out the entire density of the true DGP we may actually do better. This is especially true for classification. For example the true DGP can be very complex but the classification task can be very easy.
Yaroslav Bulatov provided the following example in his blog:
http://yaroslavvb.blogspot.ro/2007/06/log-loss-or-hinge-loss.html
As you can see below the true density is wiggly but it is very easy to build a classifier to separate data generated by this into two classes. Simply if $x \ge 0$ output class 1, and if $x < 0$ output class 2.
Instead of matching the exact density above we propose the below crude model, which is quite far from the true DGP. However it does perfect classification. This is found by using hinge loss, which is not proper.
On the other hand if you decide to find the true DGP with log-loss (which is proper) then you start fitting some functionals, as you don't know what the exact functional form you need a priori. But as you try harder and harder to match it, you start misclassifying things.
Note that in both cases we used the same functional forms. In the improper loss case it degenerated into a step function which in turn did perfect classification. In the proper case it went berserk trying to satisfy every region of the density.
Basically we don't always need to achieve the true model to have accurate forecasts. Or sometimes we don't really need to do good on the entire domain of the density, but be very good only on certain parts of it.
|
When is it appropriate to use an improper scoring rule?
It is appropriate to use an improper scoring rule when the purpose is actually forecasting, but not inference. I don't really care whether another forecaster is cheating or not when I am the one who i
|
7,026
|
When is it appropriate to use an improper scoring rule?
|
Accuracy (i.e., percent correctly classified) is an improper scoring rule, so in some sense people do it all the time.
More generally, any scoring rule that forces predictions into a pre-defined category is going to be improper. Classification is an extreme case of this (the only allowable forecasts are 0% and 100%), but the weather forecast is probably also slightly improper--my local stations seems to report the chance of rain in 10 or 20% intervals, though I'd bet the underlying model is much more precise.
Proper scoring rules also assume that the forecaster is risk neutral. This is often not the case for actual human forecasters, who are typically risk-adverse, and some applications might benefit from a scoring rule that reproduces that bias. For example, you might give a little extra weight to P(rain) since carrying an umbrella but not needing it is far better than being caught in a downpour.
|
When is it appropriate to use an improper scoring rule?
|
Accuracy (i.e., percent correctly classified) is an improper scoring rule, so in some sense people do it all the time.
More generally, any scoring rule that forces predictions into a pre-defined categ
|
When is it appropriate to use an improper scoring rule?
Accuracy (i.e., percent correctly classified) is an improper scoring rule, so in some sense people do it all the time.
More generally, any scoring rule that forces predictions into a pre-defined category is going to be improper. Classification is an extreme case of this (the only allowable forecasts are 0% and 100%), but the weather forecast is probably also slightly improper--my local stations seems to report the chance of rain in 10 or 20% intervals, though I'd bet the underlying model is much more precise.
Proper scoring rules also assume that the forecaster is risk neutral. This is often not the case for actual human forecasters, who are typically risk-adverse, and some applications might benefit from a scoring rule that reproduces that bias. For example, you might give a little extra weight to P(rain) since carrying an umbrella but not needing it is far better than being caught in a downpour.
|
When is it appropriate to use an improper scoring rule?
Accuracy (i.e., percent correctly classified) is an improper scoring rule, so in some sense people do it all the time.
More generally, any scoring rule that forces predictions into a pre-defined categ
|
7,027
|
When is it appropriate to use an improper scoring rule?
|
A simplified answer, as indicated by Cagdas Ozgenc, might be: whenever you do not aim for the true predictive distribution.
A second aspect is the difference between fitting/estimation, inference, and forecast comparison. When you fit by minimizing a proper scoring rule and then add a penalty to deal with overfitting, your objective is usually no longer a proper scoring rule.
Thirdly, I'm not aware of use cases where you want a predictive distribution but not the true one, or as close as possible. Often in practice, however, you are content with predicting a certain functional of the predictive distribution, i.e. a point forecast like the expected value or a quantile. In those cases, the usage of proper scoring functions is advisable, unless there is a clear (business) objective that you want to optimize directly. Also note that the notions of scoring rule and scoring function for the expectation coincide for binary targets.
This is the general direction of Cagdas Ozgenc's answer, on which I'd like to comment (as I can't comment directly...yet):
The same parametric model should have been used for log-loss and hinge loss. I'm sure, a logistic regression with intercept plus feature $I_{x>0}$ would not be worse than the hinge example.
"However it does perfect classification." It does not. BTW, by which notion of "good classification"?
I guess by "classification", a concrete decision based on a (probabilistic) forecast is meant, have a look at https://stats.stackexchange.com/q/312787 for more details on that distinction.
|
When is it appropriate to use an improper scoring rule?
|
A simplified answer, as indicated by Cagdas Ozgenc, might be: whenever you do not aim for the true predictive distribution.
A second aspect is the difference between fitting/estimation, inference, and
|
When is it appropriate to use an improper scoring rule?
A simplified answer, as indicated by Cagdas Ozgenc, might be: whenever you do not aim for the true predictive distribution.
A second aspect is the difference between fitting/estimation, inference, and forecast comparison. When you fit by minimizing a proper scoring rule and then add a penalty to deal with overfitting, your objective is usually no longer a proper scoring rule.
Thirdly, I'm not aware of use cases where you want a predictive distribution but not the true one, or as close as possible. Often in practice, however, you are content with predicting a certain functional of the predictive distribution, i.e. a point forecast like the expected value or a quantile. In those cases, the usage of proper scoring functions is advisable, unless there is a clear (business) objective that you want to optimize directly. Also note that the notions of scoring rule and scoring function for the expectation coincide for binary targets.
This is the general direction of Cagdas Ozgenc's answer, on which I'd like to comment (as I can't comment directly...yet):
The same parametric model should have been used for log-loss and hinge loss. I'm sure, a logistic regression with intercept plus feature $I_{x>0}$ would not be worse than the hinge example.
"However it does perfect classification." It does not. BTW, by which notion of "good classification"?
I guess by "classification", a concrete decision based on a (probabilistic) forecast is meant, have a look at https://stats.stackexchange.com/q/312787 for more details on that distinction.
|
When is it appropriate to use an improper scoring rule?
A simplified answer, as indicated by Cagdas Ozgenc, might be: whenever you do not aim for the true predictive distribution.
A second aspect is the difference between fitting/estimation, inference, and
|
7,028
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
|
1) Making some assumptions about the population size (namely that it is large enough that a binomial model is appropriate), the prevalence of a disease in a population at a particular time can be obtained by sampling simple random sampling of people and finding who is sick. That is a binomial random variable and the Wald confidence interval for a proportion $p$ is
$$ p \pm 1.96\dfrac{\sqrt{p(1-p)}}{\sqrt{n}}$$
The variance portion is bounded above by 0.5, so we can make the simplifying assumption that the width of the confidence interval is $\sim 2/\sqrt{n}$. So, the answer to this part is that the confidence interval for $p$ decreases like $1/\sqrt{n}$. Quadruple your sample, halve your interval. Now, this was based on using a Wald interval, which is known to be problematic when $p$ is near 0 or 1, but the spirit remains the same for other intervals.
2) You need to look at metrics like specificity and sensitivity.
Sensitivity is the probability that a diseased person will be identified as diseased (i.e. tests positive). Specificity is the probability that a person without the disease is identified as not having the disease (i.e. tests negative). There are lots of other metrics for diagnostic tests found here which should answer your question.
3) I guess this is still up in the air. There are several attempts to model the infection over time. SIR models and their variants can make a simplifying assumption that the population is closed (i.e. S(t) + I(t) + R(t) = 1) and then I(t) can be interpreted as the prevalence. This isn't a very good assumption IMO because clearly the population is not closed (people die from the disease). As for modelling the diagnostic properties of a test, those are also a function of the prevalence. From Bayes rule
$$ p(T+ \vert D+) = \dfrac{P(D+\vert T+)p(T+)}{p(D+)}$$
Here, $P(D+)$ is the prevalence of the disease, so as this changes then the sensitivity should change as well.
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
|
1) Making some assumptions about the population size (namely that it is large enough that a binomial model is appropriate), the prevalence of a disease in a population at a particular time can be obt
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
1) Making some assumptions about the population size (namely that it is large enough that a binomial model is appropriate), the prevalence of a disease in a population at a particular time can be obtained by sampling simple random sampling of people and finding who is sick. That is a binomial random variable and the Wald confidence interval for a proportion $p$ is
$$ p \pm 1.96\dfrac{\sqrt{p(1-p)}}{\sqrt{n}}$$
The variance portion is bounded above by 0.5, so we can make the simplifying assumption that the width of the confidence interval is $\sim 2/\sqrt{n}$. So, the answer to this part is that the confidence interval for $p$ decreases like $1/\sqrt{n}$. Quadruple your sample, halve your interval. Now, this was based on using a Wald interval, which is known to be problematic when $p$ is near 0 or 1, but the spirit remains the same for other intervals.
2) You need to look at metrics like specificity and sensitivity.
Sensitivity is the probability that a diseased person will be identified as diseased (i.e. tests positive). Specificity is the probability that a person without the disease is identified as not having the disease (i.e. tests negative). There are lots of other metrics for diagnostic tests found here which should answer your question.
3) I guess this is still up in the air. There are several attempts to model the infection over time. SIR models and their variants can make a simplifying assumption that the population is closed (i.e. S(t) + I(t) + R(t) = 1) and then I(t) can be interpreted as the prevalence. This isn't a very good assumption IMO because clearly the population is not closed (people die from the disease). As for modelling the diagnostic properties of a test, those are also a function of the prevalence. From Bayes rule
$$ p(T+ \vert D+) = \dfrac{P(D+\vert T+)p(T+)}{p(D+)}$$
Here, $P(D+)$ is the prevalence of the disease, so as this changes then the sensitivity should change as well.
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
1) Making some assumptions about the population size (namely that it is large enough that a binomial model is appropriate), the prevalence of a disease in a population at a particular time can be obt
|
7,029
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
|
It has been answered by Dimitri Pananos, I will only add that in order to estimate the prevalence with pre-set precision you need an absolute sample size which is pretty much invariant with the population size (only when the sample is a substantial part of the target population you have a non-negligible finite population correction factor). So there is not a percentage of the population that needs to be tested: 50% of a small population may not be sufficient, 0.5% of a large population may be far enough for the same precision.
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
|
It has been answered by Dimitri Pananos, I will only add that in order to estimate the prevalence with pre-set precision you need an absolute sample size which is pretty much invariant with the popula
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
It has been answered by Dimitri Pananos, I will only add that in order to estimate the prevalence with pre-set precision you need an absolute sample size which is pretty much invariant with the population size (only when the sample is a substantial part of the target population you have a non-negligible finite population correction factor). So there is not a percentage of the population that needs to be tested: 50% of a small population may not be sufficient, 0.5% of a large population may be far enough for the same precision.
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
It has been answered by Dimitri Pananos, I will only add that in order to estimate the prevalence with pre-set precision you need an absolute sample size which is pretty much invariant with the popula
|
7,030
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
|
I'll go in a somewhat different direction and say that it depends...
Of course any sampling is based on the notion that the sampling is truly random. Trying to account for non-randomness in the sample tremendously complicates the situation.
This type of yes/no measurement is non-parametric. Such tests need a larger sample size than if the measurement was parametric.
Presumably you're ignoring the problem of false positives and false negatives in the testing. False positives could be a real problem is the disease fraction is low.
What is the actual fraction of the diseased? If only 0.1% of the population is diseased then on average one 1 in a 1000 tests would be positive. So the lower the infection rate, the larger the sample would need to be.
How precise an estimate do you want? In other words do you want to know the infection rate +/- 20%, or to say +/- 1%. The more precise you want to know the value of the infection rate the larger the sample would need to be.
There is a type of statistical testing called Acceptance Testing which can be used. Basically the important decision is how precise do you want the measurement to be? Then you keep sampling until that level of precision is achieved. So if 50% of the population is infected then a relatively small sample is needed to get to +/- 10% error in the measurement itself (e.g 50% +/- 5%). However if only 0.5% of the population is infected then a much larger sample is needed to determine that the disease level (e.g. 0.5% +/- 0.05%).
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
|
I'll go in a somewhat different direction and say that it depends...
Of course any sampling is based on the notion that the sampling is truly random. Trying to account for non-randomness in the sampl
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVID-19
I'll go in a somewhat different direction and say that it depends...
Of course any sampling is based on the notion that the sampling is truly random. Trying to account for non-randomness in the sample tremendously complicates the situation.
This type of yes/no measurement is non-parametric. Such tests need a larger sample size than if the measurement was parametric.
Presumably you're ignoring the problem of false positives and false negatives in the testing. False positives could be a real problem is the disease fraction is low.
What is the actual fraction of the diseased? If only 0.1% of the population is diseased then on average one 1 in a 1000 tests would be positive. So the lower the infection rate, the larger the sample would need to be.
How precise an estimate do you want? In other words do you want to know the infection rate +/- 20%, or to say +/- 1%. The more precise you want to know the value of the infection rate the larger the sample would need to be.
There is a type of statistical testing called Acceptance Testing which can be used. Basically the important decision is how precise do you want the measurement to be? Then you keep sampling until that level of precision is achieved. So if 50% of the population is infected then a relatively small sample is needed to get to +/- 10% error in the measurement itself (e.g 50% +/- 5%). However if only 0.5% of the population is infected then a much larger sample is needed to determine that the disease level (e.g. 0.5% +/- 0.05%).
|
What percentage of a population needs a test in order to estimate prevalence of a disease? Say, COVI
I'll go in a somewhat different direction and say that it depends...
Of course any sampling is based on the notion that the sampling is truly random. Trying to account for non-randomness in the sampl
|
7,031
|
Error metrics for cross-validating Poisson models
|
There are a couple of proper and strictly proper scoring rules for count data you can use. Scoring rules are penalties $s(y,P)$ introduced with $P$ being the predictive distribution and $y$ the observed value. They have a number of desirable properties, first and foremost that a forecast that is closer to the true probability will always receive less penalty and there is a (unique) best forecast and that one is when the predicted probability coincides with the true probability. Thus minimizing the expectation of $s(y,P)$ means reporting the true probabilities. See also Wikipedia.
Often one takes an average of those over all predicted values as
$S=\frac{1}{n}\sum_{i=1}^n s(y^{(i)},P^{(i)})$
Which rule to take depends on your objective but I'll give a rough characterization when each is good to be used.
In what follows I use $f(y)$ for the predictive probability mass function $\Pr(Y=y)$ and $F(y)$ the predictive cumulative distribution function. A $\sum_k$ runs over the whole support of the count distribution (i.e, $0,1,\dots, \infty$). $I$ denotes an indicator function. $\mu$ and $\sigma$ are the mean and standard deviation of the predictive distribution (which are usually directly estimated quantities in count data models).
Strictly proper scoring rules
Brier Score: $s(y,P)=-2 f(y) + \sum_k f^2(k)$ (stable for size imbalance in categorical predictors)
Dawid-Sebastiani score: $s(y,P)=(\frac{y-\mu}{\sigma})^2+2\log\sigma$ (good for general predictive model choice; stable for size imbalance in categorical predictors)
Deviance score: $s(y,P)=-2\log f(y) + g_y$ ($g_y$ is a normalization
term that only depends on $y$, in Poisson models it is usually taken
as the saturated deviance; good for use with estimates from an ML framework)
Logarithmic score: $s(y,P)=-\log f(y)$ (very easily calculated; stable for size imbalance in categorical predictors)
Ranked probability score: $s(y,P)=\sum_k \{F(k)-I(y\leq k)\}^2$ (good for contrasting different predictions of very high counts; susceptible to size imbalance in categorical predictors)
Spherical score: $s(y,P)=\frac{f(y)}{\sqrt{\sum_k f^2(k)}}$ (stable for size imbalance in categorical predictors)
Other scoring rules (not so proper but often used)
Absolute error score: $s(y,P)=|y-\mu|$ (not proper)
Squared error score: $s(y,P)=(y-\mu)^2$ (not strictly proper; susceptible to outliers; susceptible to size imbalance in categorical predictors)
Pearson normalized squared error score: $s(y,P)=(\frac{y-\mu}{\sigma})^2$ (not strictly proper; susceptible to outliers; can be used for checking if model checking if the averaged score is very different from 1; stable for size imbalance in categorical predictors)
Example R code for the strictly proper rules:
library(vcdExtra)
m1 <- glm(Freq ~ mental, family=poisson, data=Mental)
# scores for the first observation
mu <- predict(m1, type="response")[1]
x <- Mental$Freq[1]
# logarithmic (equivalent to deviance score up to a constant)
-log(dpois(x, lambda=mu))
# quadratic (brier)
-2*dpois(x,lambda=mu) + sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) })
# spherical
- dpois(x,mu) / sqrt(sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) }))
# ranked probability score
sum(ppois((-1):(x-1), mu)^2) + sum((ppois(x:10000,mu)-1)^2)
# Dawid Sebastiani
(x-mu)^2/mu + log(mu)
|
Error metrics for cross-validating Poisson models
|
There are a couple of proper and strictly proper scoring rules for count data you can use. Scoring rules are penalties $s(y,P)$ introduced with $P$ being the predictive distribution and $y$ the observ
|
Error metrics for cross-validating Poisson models
There are a couple of proper and strictly proper scoring rules for count data you can use. Scoring rules are penalties $s(y,P)$ introduced with $P$ being the predictive distribution and $y$ the observed value. They have a number of desirable properties, first and foremost that a forecast that is closer to the true probability will always receive less penalty and there is a (unique) best forecast and that one is when the predicted probability coincides with the true probability. Thus minimizing the expectation of $s(y,P)$ means reporting the true probabilities. See also Wikipedia.
Often one takes an average of those over all predicted values as
$S=\frac{1}{n}\sum_{i=1}^n s(y^{(i)},P^{(i)})$
Which rule to take depends on your objective but I'll give a rough characterization when each is good to be used.
In what follows I use $f(y)$ for the predictive probability mass function $\Pr(Y=y)$ and $F(y)$ the predictive cumulative distribution function. A $\sum_k$ runs over the whole support of the count distribution (i.e, $0,1,\dots, \infty$). $I$ denotes an indicator function. $\mu$ and $\sigma$ are the mean and standard deviation of the predictive distribution (which are usually directly estimated quantities in count data models).
Strictly proper scoring rules
Brier Score: $s(y,P)=-2 f(y) + \sum_k f^2(k)$ (stable for size imbalance in categorical predictors)
Dawid-Sebastiani score: $s(y,P)=(\frac{y-\mu}{\sigma})^2+2\log\sigma$ (good for general predictive model choice; stable for size imbalance in categorical predictors)
Deviance score: $s(y,P)=-2\log f(y) + g_y$ ($g_y$ is a normalization
term that only depends on $y$, in Poisson models it is usually taken
as the saturated deviance; good for use with estimates from an ML framework)
Logarithmic score: $s(y,P)=-\log f(y)$ (very easily calculated; stable for size imbalance in categorical predictors)
Ranked probability score: $s(y,P)=\sum_k \{F(k)-I(y\leq k)\}^2$ (good for contrasting different predictions of very high counts; susceptible to size imbalance in categorical predictors)
Spherical score: $s(y,P)=\frac{f(y)}{\sqrt{\sum_k f^2(k)}}$ (stable for size imbalance in categorical predictors)
Other scoring rules (not so proper but often used)
Absolute error score: $s(y,P)=|y-\mu|$ (not proper)
Squared error score: $s(y,P)=(y-\mu)^2$ (not strictly proper; susceptible to outliers; susceptible to size imbalance in categorical predictors)
Pearson normalized squared error score: $s(y,P)=(\frac{y-\mu}{\sigma})^2$ (not strictly proper; susceptible to outliers; can be used for checking if model checking if the averaged score is very different from 1; stable for size imbalance in categorical predictors)
Example R code for the strictly proper rules:
library(vcdExtra)
m1 <- glm(Freq ~ mental, family=poisson, data=Mental)
# scores for the first observation
mu <- predict(m1, type="response")[1]
x <- Mental$Freq[1]
# logarithmic (equivalent to deviance score up to a constant)
-log(dpois(x, lambda=mu))
# quadratic (brier)
-2*dpois(x,lambda=mu) + sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) })
# spherical
- dpois(x,mu) / sqrt(sapply(mu, function(x){ sum(dpois(1:1000,lambda=x)^2) }))
# ranked probability score
sum(ppois((-1):(x-1), mu)^2) + sum((ppois(x:10000,mu)-1)^2)
# Dawid Sebastiani
(x-mu)^2/mu + log(mu)
|
Error metrics for cross-validating Poisson models
There are a couple of proper and strictly proper scoring rules for count data you can use. Scoring rules are penalties $s(y,P)$ introduced with $P$ being the predictive distribution and $y$ the observ
|
7,032
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
I managed to come up with an example where a connection exists. It seems to depend heavily on my choice of loss function and the use of composite hypotheses though.
I start with a general example, which is then followed by a simple special case involving the normal distribution.
General example
For an unknown parameter $\theta $, let $\Theta$ be the parameter space and consider the hypothesis $\theta\in\Theta_0$ versus the alternative $\theta\in\Theta_1=\Theta\backslash\Theta_0$.
Let $\varphi$ be a test function, using the notation in Xi'an's The Bayesian Choice (which is sort of backwards to what I at least am used to), so that we reject $\Theta_0$ if $\varphi=0$ and accept $\Theta_0$ if $\varphi=1$. Consider the loss function
$$
L(\theta,\varphi) = \begin{cases} 0, & \mbox{if } \varphi=\mathbb{I}_{\Theta_0}(\theta) \\
a_0, & \mbox{if } \theta\in\Theta_0 \mbox{ and }\varphi=0\\
a_1, & \mbox{if } \theta\in\Theta_1 \mbox{ and }\varphi=1. \end{cases}
$$
The Bayes test is then $$\varphi^\pi(x)=1\quad \rm if\quad P(\theta\in\Theta_0|x)\geq a_1(a_0+a_1)^{-1}.$$
Take $a_0=\alpha\leq 0.5$ and $a_1=1-\alpha$. The null hypothesis $\Theta_0$ is accepted if $\rm P(\theta\in\Theta_0|x)\geq 1-\alpha$.
Now, a credible region $\Theta_c$ is a region such that $\rm P(\Theta_c|x)\geq 1-\alpha$. Thus, by definition, if $\Theta_0$ is such that $\rm P(\theta\in\Theta_0|x)\geq 1-\alpha$, $\Theta_c$ can be a credible region only if $\rm P(\Theta_0\cap\Theta_c|x)>0$.
We accept the null hypothesis if an only if each $1-\alpha$-credible region contains a non-null subset of $\Theta_0$.
A simpler special case
To better illustrate what kind of test we have in the above example, consider the following special case.
Let $x\sim \rm N(\theta,1)$ with $\theta\sim \rm N(0,1)$. Set $\Theta=\mathbb{R}$, $\Theta_0=(-\infty,0]$ and $\Theta_1=(0,\infty)$, so that we wish to test whether $\theta\leq 0$.
Standard calculations give $$\rm P(\theta\leq 0|x)=\Phi(-x/\sqrt{2}),$$ where $\Phi(\cdot)$ is the standard normal cdf.
Let $z_{1-\alpha}$ be such that $\Phi(z_{1-\alpha})=1-\alpha$. $\Theta_0$ is accepted when $-x/\sqrt{2}>z_{1-\alpha}$.
This is equivalent to accepting when $x\leq \sqrt{2}z_{\alpha}.$ For $\alpha=0.05$, $\Theta_0$ is therefore rejected when $x>-2.33$.
If instead we use the prior $\theta\sim \rm N(\nu,1)$, $\Theta_0$ is rejected when $x>-2.33-\nu$.
Comments
The above loss function, where we think that falsely accepting the null hypothesis is worse than falsely rejecting it, may at first glance seem like a slightly artifical one. It can however be of considerable use in situations where "false negatives" can be costly, for instance when screening for dangerous contagious diseases or terrorists.
The condition that all credible regions must contain a part of $\Theta_0$ is actually a bit stronger than what I was hoping for: in the frequentist case the correspondence is between a single test and a single $1-\alpha$ confidence interval and not between a single test and all $1-\alpha$ intervals.
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
I managed to come up with an example where a connection exists. It seems to depend heavily on my choice of loss function and the use of composite hypotheses though.
I start with a general example, whi
|
What is the connection between credible regions and Bayesian hypothesis tests?
I managed to come up with an example where a connection exists. It seems to depend heavily on my choice of loss function and the use of composite hypotheses though.
I start with a general example, which is then followed by a simple special case involving the normal distribution.
General example
For an unknown parameter $\theta $, let $\Theta$ be the parameter space and consider the hypothesis $\theta\in\Theta_0$ versus the alternative $\theta\in\Theta_1=\Theta\backslash\Theta_0$.
Let $\varphi$ be a test function, using the notation in Xi'an's The Bayesian Choice (which is sort of backwards to what I at least am used to), so that we reject $\Theta_0$ if $\varphi=0$ and accept $\Theta_0$ if $\varphi=1$. Consider the loss function
$$
L(\theta,\varphi) = \begin{cases} 0, & \mbox{if } \varphi=\mathbb{I}_{\Theta_0}(\theta) \\
a_0, & \mbox{if } \theta\in\Theta_0 \mbox{ and }\varphi=0\\
a_1, & \mbox{if } \theta\in\Theta_1 \mbox{ and }\varphi=1. \end{cases}
$$
The Bayes test is then $$\varphi^\pi(x)=1\quad \rm if\quad P(\theta\in\Theta_0|x)\geq a_1(a_0+a_1)^{-1}.$$
Take $a_0=\alpha\leq 0.5$ and $a_1=1-\alpha$. The null hypothesis $\Theta_0$ is accepted if $\rm P(\theta\in\Theta_0|x)\geq 1-\alpha$.
Now, a credible region $\Theta_c$ is a region such that $\rm P(\Theta_c|x)\geq 1-\alpha$. Thus, by definition, if $\Theta_0$ is such that $\rm P(\theta\in\Theta_0|x)\geq 1-\alpha$, $\Theta_c$ can be a credible region only if $\rm P(\Theta_0\cap\Theta_c|x)>0$.
We accept the null hypothesis if an only if each $1-\alpha$-credible region contains a non-null subset of $\Theta_0$.
A simpler special case
To better illustrate what kind of test we have in the above example, consider the following special case.
Let $x\sim \rm N(\theta,1)$ with $\theta\sim \rm N(0,1)$. Set $\Theta=\mathbb{R}$, $\Theta_0=(-\infty,0]$ and $\Theta_1=(0,\infty)$, so that we wish to test whether $\theta\leq 0$.
Standard calculations give $$\rm P(\theta\leq 0|x)=\Phi(-x/\sqrt{2}),$$ where $\Phi(\cdot)$ is the standard normal cdf.
Let $z_{1-\alpha}$ be such that $\Phi(z_{1-\alpha})=1-\alpha$. $\Theta_0$ is accepted when $-x/\sqrt{2}>z_{1-\alpha}$.
This is equivalent to accepting when $x\leq \sqrt{2}z_{\alpha}.$ For $\alpha=0.05$, $\Theta_0$ is therefore rejected when $x>-2.33$.
If instead we use the prior $\theta\sim \rm N(\nu,1)$, $\Theta_0$ is rejected when $x>-2.33-\nu$.
Comments
The above loss function, where we think that falsely accepting the null hypothesis is worse than falsely rejecting it, may at first glance seem like a slightly artifical one. It can however be of considerable use in situations where "false negatives" can be costly, for instance when screening for dangerous contagious diseases or terrorists.
The condition that all credible regions must contain a part of $\Theta_0$ is actually a bit stronger than what I was hoping for: in the frequentist case the correspondence is between a single test and a single $1-\alpha$ confidence interval and not between a single test and all $1-\alpha$ intervals.
|
What is the connection between credible regions and Bayesian hypothesis tests?
I managed to come up with an example where a connection exists. It seems to depend heavily on my choice of loss function and the use of composite hypotheses though.
I start with a general example, whi
|
7,033
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
Michael and Fraijo suggested that simply checking whether the parameter value of interested was contained in some credible region was the Bayesian equivalent of inverting confidence intervals. I was a bit skeptical about this at first, since it wasn't obvious to me that this procedure really resulted in a Bayesian test (in the usual sense).
As it turns out, it does - at least if you're willing to accept a certain type of loss functions. Many thanks to Zen, who provided references to two papers that establish a connection between HPD regions and hypothesis testing:
Pereira & Stern (1999), Evidence and credibility: full Bayesian significance test for precise hypotheses, Entropy
Madruga, Esteves & Wechsler (2001), On the Bayesianity of Pereira-Stern tests, Test
I'll try to summarize them here, for future reference. In analogue with the example in the original question, I'll treat the special case where the hypotheses are $$H_0: \theta\in\Theta_0=\{\theta_0\}\qquad \mbox{and}\qquad H_1: \theta\in\Theta_1=\Theta\backslash \Theta_0,$$ where $\Theta$ is the parameter space.
Pereira & Stern proposed a method for testing said hypotheses without having to put prior probabilities on $\Theta_0$ and $\Theta_1$.
Let $\pi(\cdot)$ denote the density function of $\theta$ and define $$T(x)=\{ \theta:\pi(\theta|x)>\pi(\theta_0|x)\}.$$
This means that $T(x)$ is a HPD region, with credibility $P(\theta\in T(x)|x)$.
The Pereira-Stern test rejects $\Theta_0$ when $P(\theta\notin T(x)|x)$ is "small" ($<0.05$, say). For a unimodal posterior, this means that $\theta_0$ is far out in the tails of the posterior, making this criterion somewhat similar to using p-values. In other words, $\Theta_0$ is rejected at the $5~\%$ level if and only if it is not contained the in $95~\%$ HPD region.
Let the test function $\varphi$ be $1$ if $\Theta_0$ is accepted and $0$ if $\Theta_0$ is rejected. Madruga et al. proposed the loss function
$$
L(\theta,\varphi,x) = \begin{cases} a(1-\mathbb{I}(\theta\in T(x)), & \mbox{if } \varphi(x)=0 \\
b+c\mathbb{I}(\theta\in(T(x)), & \mbox{if } \varphi(x)=1, \end{cases}
$$
with $a,b,c>0$.
Minimization of the expected loss leads to the Pereira-Stern test where $\Theta_0$ is rejected if $P(\theta\notin T(x)|x)<(b+c)/(a+c).$
So far, all is well. The Pereira-Stern test is equivalent to checking whether $\theta_0$ is in an HPD region and there is a loss function that generates this test, meaning that it is founded in decision theory.
The controversial part though is that the loss function depends on $x$. While such loss functions have appeared in the literature a few times, they don't seem to be generally accepted as being very reasonable.
For further reading on this topic, see a list of papers that cite the Madruga et al. article.
Update October 2012:
I wasn't completely satisfied with the above loss function, as its dependence on $x$ makes the decision-making more subjective than I would like. I spent some more time thinking about this problem and ended up writing a short note about it, posted on arXiv earlier today.
Let $q_{\alpha}(\theta|x)$ denote the posterior quantile function of $\theta$, such that $P(\theta\leq q_{\alpha}(\theta|x))=\alpha$. Instead of HPD sets we consider the central (equal-tailed) interval $(q_{\alpha/2}(\theta|x),q_{1-\alpha/2}(\theta|x))$. To test $\Theta_0$ using this interval can be justified in the decision-theoretic framework without a loss function that depends on $x$.
The trick is to reformulate the problem of testing the point-null hypothesis $\Theta_0=\{\theta_0\}$ as a three-decision problem with directional conclusions. $\Theta_0$ is then tested against both $\Theta_{-1}=\{\theta:\theta<\theta_0\}$ and $\Theta_{1}=\{\theta:\theta>\theta_0\}$.
Let the test function $\varphi=i$ if we accept $\Theta_i$ (note that this notation is the opposite of that used above!). It turns out that under the weighted $0-1$ loss function
$$L_2(\theta,\varphi) = \begin{cases} 0, & \mbox{if } \theta\in\Theta_i\mbox{ and }\varphi=i, \quad i\in \{-1,0,1\}, \\
\alpha/2, & \mbox{if } \theta\notin\Theta_0 \mbox{ and }\varphi=0,\\
1, & \mbox{if } \theta\in\Theta_{i}\cup\Theta_0 \mbox{ and }\varphi=-i,\quad i\in\{-1,1\},\end{cases}$$
the Bayes test is to reject $\Theta_0$ if $\theta_0$ is not in the central interval.
This seems like a quite reasonable loss function to me. I discuss this loss, the Madruga-Esteves-Wechsler loss and testing using credible sets further in the manuscript on arXiv.
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
Michael and Fraijo suggested that simply checking whether the parameter value of interested was contained in some credible region was the Bayesian equivalent of inverting confidence intervals. I was a
|
What is the connection between credible regions and Bayesian hypothesis tests?
Michael and Fraijo suggested that simply checking whether the parameter value of interested was contained in some credible region was the Bayesian equivalent of inverting confidence intervals. I was a bit skeptical about this at first, since it wasn't obvious to me that this procedure really resulted in a Bayesian test (in the usual sense).
As it turns out, it does - at least if you're willing to accept a certain type of loss functions. Many thanks to Zen, who provided references to two papers that establish a connection between HPD regions and hypothesis testing:
Pereira & Stern (1999), Evidence and credibility: full Bayesian significance test for precise hypotheses, Entropy
Madruga, Esteves & Wechsler (2001), On the Bayesianity of Pereira-Stern tests, Test
I'll try to summarize them here, for future reference. In analogue with the example in the original question, I'll treat the special case where the hypotheses are $$H_0: \theta\in\Theta_0=\{\theta_0\}\qquad \mbox{and}\qquad H_1: \theta\in\Theta_1=\Theta\backslash \Theta_0,$$ where $\Theta$ is the parameter space.
Pereira & Stern proposed a method for testing said hypotheses without having to put prior probabilities on $\Theta_0$ and $\Theta_1$.
Let $\pi(\cdot)$ denote the density function of $\theta$ and define $$T(x)=\{ \theta:\pi(\theta|x)>\pi(\theta_0|x)\}.$$
This means that $T(x)$ is a HPD region, with credibility $P(\theta\in T(x)|x)$.
The Pereira-Stern test rejects $\Theta_0$ when $P(\theta\notin T(x)|x)$ is "small" ($<0.05$, say). For a unimodal posterior, this means that $\theta_0$ is far out in the tails of the posterior, making this criterion somewhat similar to using p-values. In other words, $\Theta_0$ is rejected at the $5~\%$ level if and only if it is not contained the in $95~\%$ HPD region.
Let the test function $\varphi$ be $1$ if $\Theta_0$ is accepted and $0$ if $\Theta_0$ is rejected. Madruga et al. proposed the loss function
$$
L(\theta,\varphi,x) = \begin{cases} a(1-\mathbb{I}(\theta\in T(x)), & \mbox{if } \varphi(x)=0 \\
b+c\mathbb{I}(\theta\in(T(x)), & \mbox{if } \varphi(x)=1, \end{cases}
$$
with $a,b,c>0$.
Minimization of the expected loss leads to the Pereira-Stern test where $\Theta_0$ is rejected if $P(\theta\notin T(x)|x)<(b+c)/(a+c).$
So far, all is well. The Pereira-Stern test is equivalent to checking whether $\theta_0$ is in an HPD region and there is a loss function that generates this test, meaning that it is founded in decision theory.
The controversial part though is that the loss function depends on $x$. While such loss functions have appeared in the literature a few times, they don't seem to be generally accepted as being very reasonable.
For further reading on this topic, see a list of papers that cite the Madruga et al. article.
Update October 2012:
I wasn't completely satisfied with the above loss function, as its dependence on $x$ makes the decision-making more subjective than I would like. I spent some more time thinking about this problem and ended up writing a short note about it, posted on arXiv earlier today.
Let $q_{\alpha}(\theta|x)$ denote the posterior quantile function of $\theta$, such that $P(\theta\leq q_{\alpha}(\theta|x))=\alpha$. Instead of HPD sets we consider the central (equal-tailed) interval $(q_{\alpha/2}(\theta|x),q_{1-\alpha/2}(\theta|x))$. To test $\Theta_0$ using this interval can be justified in the decision-theoretic framework without a loss function that depends on $x$.
The trick is to reformulate the problem of testing the point-null hypothesis $\Theta_0=\{\theta_0\}$ as a three-decision problem with directional conclusions. $\Theta_0$ is then tested against both $\Theta_{-1}=\{\theta:\theta<\theta_0\}$ and $\Theta_{1}=\{\theta:\theta>\theta_0\}$.
Let the test function $\varphi=i$ if we accept $\Theta_i$ (note that this notation is the opposite of that used above!). It turns out that under the weighted $0-1$ loss function
$$L_2(\theta,\varphi) = \begin{cases} 0, & \mbox{if } \theta\in\Theta_i\mbox{ and }\varphi=i, \quad i\in \{-1,0,1\}, \\
\alpha/2, & \mbox{if } \theta\notin\Theta_0 \mbox{ and }\varphi=0,\\
1, & \mbox{if } \theta\in\Theta_{i}\cup\Theta_0 \mbox{ and }\varphi=-i,\quad i\in\{-1,1\},\end{cases}$$
the Bayes test is to reject $\Theta_0$ if $\theta_0$ is not in the central interval.
This seems like a quite reasonable loss function to me. I discuss this loss, the Madruga-Esteves-Wechsler loss and testing using credible sets further in the manuscript on arXiv.
|
What is the connection between credible regions and Bayesian hypothesis tests?
Michael and Fraijo suggested that simply checking whether the parameter value of interested was contained in some credible region was the Bayesian equivalent of inverting confidence intervals. I was a
|
7,034
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
I coincidentally read your arXiv paper prior to coming to this question and already wrote a blog entry on it (scheduled to appear on October, 08). To sum up, I find your construction of theoretical interest, but also think it is too contrived to be recommended, esp. as it does not seem to solve the point-null hypothesis Bayesian testing problem, which traditionally requires to put some prior mass on the point-null parameter value.
To wit, the solution you propose above (in the October update) and as Theorem 2 in your arXiv paper is not a valid test procedure in that $\varphi$ takes three values, rather than the two values that correspond to accept/reject. Similarly, the loss function you use in Theorem 3 (not reproduced here) amounts to testing a one-sided hypothesis, $H_0: \theta\le\theta_0$, rather than a point-null hypothesis $H_0: \theta= \theta_0$.
My major issue however is that it seems to me that both Theorem 3 and Theorem 4 in your arXiv paper are not valid when $H_0$ is a point-null hypothesis, i.e. when $\Theta_0=\{\theta_0\}$, with no prior mass.
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
I coincidentally read your arXiv paper prior to coming to this question and already wrote a blog entry on it (scheduled to appear on October, 08). To sum up, I find your construction of theoretical in
|
What is the connection between credible regions and Bayesian hypothesis tests?
I coincidentally read your arXiv paper prior to coming to this question and already wrote a blog entry on it (scheduled to appear on October, 08). To sum up, I find your construction of theoretical interest, but also think it is too contrived to be recommended, esp. as it does not seem to solve the point-null hypothesis Bayesian testing problem, which traditionally requires to put some prior mass on the point-null parameter value.
To wit, the solution you propose above (in the October update) and as Theorem 2 in your arXiv paper is not a valid test procedure in that $\varphi$ takes three values, rather than the two values that correspond to accept/reject. Similarly, the loss function you use in Theorem 3 (not reproduced here) amounts to testing a one-sided hypothesis, $H_0: \theta\le\theta_0$, rather than a point-null hypothesis $H_0: \theta= \theta_0$.
My major issue however is that it seems to me that both Theorem 3 and Theorem 4 in your arXiv paper are not valid when $H_0$ is a point-null hypothesis, i.e. when $\Theta_0=\{\theta_0\}$, with no prior mass.
|
What is the connection between credible regions and Bayesian hypothesis tests?
I coincidentally read your arXiv paper prior to coming to this question and already wrote a blog entry on it (scheduled to appear on October, 08). To sum up, I find your construction of theoretical in
|
7,035
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
You can use a credible interval (or HPD region) for Bayesian hypothesis testing. I don't think it is common; though, to be fair I do not see much nor do I use formal Bayesian Hypothesis testing in practice. Bayes factors are occasionally used (and in Robert's "Bayesian Core" somewhat lauded) in hypothesis testing set up.
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
You can use a credible interval (or HPD region) for Bayesian hypothesis testing. I don't think it is common; though, to be fair I do not see much nor do I use formal Bayesian Hypothesis testing in pr
|
What is the connection between credible regions and Bayesian hypothesis tests?
You can use a credible interval (or HPD region) for Bayesian hypothesis testing. I don't think it is common; though, to be fair I do not see much nor do I use formal Bayesian Hypothesis testing in practice. Bayes factors are occasionally used (and in Robert's "Bayesian Core" somewhat lauded) in hypothesis testing set up.
|
What is the connection between credible regions and Bayesian hypothesis tests?
You can use a credible interval (or HPD region) for Bayesian hypothesis testing. I don't think it is common; though, to be fair I do not see much nor do I use formal Bayesian Hypothesis testing in pr
|
7,036
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
A credible region is just a region where the integral of the posterior density over the region is a specified probability e.g. 0.95. One way to form a Bayesian hypothesis test is to see whether or not the null hypothesized value(s) of the parameter(s) fall in the credible region. In this way we can have a similar 1-1 correspondence between hypothesis tests and credible regions just like the frequentists do with confidence intervals and hypothesis tests. But this is not the only way to do hypothesis testing.
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
A credible region is just a region where the integral of the posterior density over the region is a specified probability e.g. 0.95. One way to form a Bayesian hypothesis test is to see whether or not
|
What is the connection between credible regions and Bayesian hypothesis tests?
A credible region is just a region where the integral of the posterior density over the region is a specified probability e.g. 0.95. One way to form a Bayesian hypothesis test is to see whether or not the null hypothesized value(s) of the parameter(s) fall in the credible region. In this way we can have a similar 1-1 correspondence between hypothesis tests and credible regions just like the frequentists do with confidence intervals and hypothesis tests. But this is not the only way to do hypothesis testing.
|
What is the connection between credible regions and Bayesian hypothesis tests?
A credible region is just a region where the integral of the posterior density over the region is a specified probability e.g. 0.95. One way to form a Bayesian hypothesis test is to see whether or not
|
7,037
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
Let me give it how I got it reading Tim's answer.
It is based on the table views with hypothesis (estimated parameter) in columns and observations in the rows.
In the first table, you have col probabilities sum to 1, i.e. they are conditional probabilities, whose condition, getting into the column event is supplied in the bottom row, called 'prior'. In the last table, rows similarly sum to 1 and in the middle you have joint probabilities, i.e. conditional probabilities you find in the first and last table times the probability of the condition, the priors.
The tables basically perform the Bayesian transform: in the first table, you give p.d.f of the observations (rows) in every column, set the prior for this hypothesis (yes, hypothesis column is a pdf of observations under that hypothesis), you do that for every column and table takes it first into the joint probabilites table and, then into the probabilities of your hypothesis, conditioned by observations.
As I have got from Tim's answer (correct me if I am wrong), the Critical Interval approach looks at the first table. That is, once experiment is complete, we know the row of the table (either heads or tails in my example but you may make more complex experiments, like 100 coin flips and get a table with 2^100 rows). Frequentialist scans through its columns, which, as I have said, is a distribution of possible outcomes under condition that hypothesis colds true (e.g. coin is fair in my example), and rejects those hypothesis (columns) that has give very low probability value at the observed row.
Bayesianist first adjust the probabilities, converting cols into rows and looks at table 3, finds the row of the observed outcome. Since it is also a p.d.f, he goes through the experiment outcome row and picks the highest-prob hypethesis until his 95% credibility pocket is full. The rest of hypothesis is rejected.
How do you like it? I am still in the process of learning and graphic seems helpful to me. I belive that I am on the right track since a reputable user gives the same picture, when analyzes the difference of two approaches. I have proposed a graphical view of the mechanics of hypothesis selection.
I encourage everybody to read that Keith last answer but my picture of hypothesis test mechanics can immediately say that frequentist does not look at the other hypothesis when verifies the current one whereas consideration of high credibile hypothesis highly impacts the reception/rejection of other hypotheses in bayesian analisys because if you have a single hypothesis which occurs 95% of times under observed data, you throw all other hypothesis immediately, regardless how well is data fit within them. Let's put the statistical power analysis, which contrast two hypotheses based on their confidence intervals overlap, aside.
But, I seem have spotted the similarity between two approaches: they seem to be connected through P(A | B) > P(A) <=> P(B|A) > P(B) property. Basically, if there is a dependence between A and B then it will show up as correlation in both freq and bayesian tables. So, doing one hypothesis test correlates with the other, they sorta must give the same results. Studying the roots of the correlation, will likely give you the connection between the two. In my question there I actually ask why is the difference instead of absolute correlation?
|
What is the connection between credible regions and Bayesian hypothesis tests?
|
Let me give it how I got it reading Tim's answer.
It is based on the table views with hypothesis (estimated parameter) in columns and observations in the rows.
In the first table, you have col proba
|
What is the connection between credible regions and Bayesian hypothesis tests?
Let me give it how I got it reading Tim's answer.
It is based on the table views with hypothesis (estimated parameter) in columns and observations in the rows.
In the first table, you have col probabilities sum to 1, i.e. they are conditional probabilities, whose condition, getting into the column event is supplied in the bottom row, called 'prior'. In the last table, rows similarly sum to 1 and in the middle you have joint probabilities, i.e. conditional probabilities you find in the first and last table times the probability of the condition, the priors.
The tables basically perform the Bayesian transform: in the first table, you give p.d.f of the observations (rows) in every column, set the prior for this hypothesis (yes, hypothesis column is a pdf of observations under that hypothesis), you do that for every column and table takes it first into the joint probabilites table and, then into the probabilities of your hypothesis, conditioned by observations.
As I have got from Tim's answer (correct me if I am wrong), the Critical Interval approach looks at the first table. That is, once experiment is complete, we know the row of the table (either heads or tails in my example but you may make more complex experiments, like 100 coin flips and get a table with 2^100 rows). Frequentialist scans through its columns, which, as I have said, is a distribution of possible outcomes under condition that hypothesis colds true (e.g. coin is fair in my example), and rejects those hypothesis (columns) that has give very low probability value at the observed row.
Bayesianist first adjust the probabilities, converting cols into rows and looks at table 3, finds the row of the observed outcome. Since it is also a p.d.f, he goes through the experiment outcome row and picks the highest-prob hypethesis until his 95% credibility pocket is full. The rest of hypothesis is rejected.
How do you like it? I am still in the process of learning and graphic seems helpful to me. I belive that I am on the right track since a reputable user gives the same picture, when analyzes the difference of two approaches. I have proposed a graphical view of the mechanics of hypothesis selection.
I encourage everybody to read that Keith last answer but my picture of hypothesis test mechanics can immediately say that frequentist does not look at the other hypothesis when verifies the current one whereas consideration of high credibile hypothesis highly impacts the reception/rejection of other hypotheses in bayesian analisys because if you have a single hypothesis which occurs 95% of times under observed data, you throw all other hypothesis immediately, regardless how well is data fit within them. Let's put the statistical power analysis, which contrast two hypotheses based on their confidence intervals overlap, aside.
But, I seem have spotted the similarity between two approaches: they seem to be connected through P(A | B) > P(A) <=> P(B|A) > P(B) property. Basically, if there is a dependence between A and B then it will show up as correlation in both freq and bayesian tables. So, doing one hypothesis test correlates with the other, they sorta must give the same results. Studying the roots of the correlation, will likely give you the connection between the two. In my question there I actually ask why is the difference instead of absolute correlation?
|
What is the connection between credible regions and Bayesian hypothesis tests?
Let me give it how I got it reading Tim's answer.
It is based on the table views with hypothesis (estimated parameter) in columns and observations in the rows.
In the first table, you have col proba
|
7,038
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
|
A Bayesian network is a type of graphical model. The other "big" type of graphical model is a Markov Random Field (MRF). Graphical models are used for inference, estimation and in general, to model the world.
The term hierarchical model is used to mean many things in different areas.
While neural networks come with "graphs" they generally don't encode dependence information, and the nodes don't represent random variables. NNs are different because they are discriminative. Popular neural networks are used for classification and regression.
Kevin Murphy has an excellent introduction to these topics available here.
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
|
A Bayesian network is a type of graphical model. The other "big" type of graphical model is a Markov Random Field (MRF). Graphical models are used for inference, estimation and in general, to model t
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
A Bayesian network is a type of graphical model. The other "big" type of graphical model is a Markov Random Field (MRF). Graphical models are used for inference, estimation and in general, to model the world.
The term hierarchical model is used to mean many things in different areas.
While neural networks come with "graphs" they generally don't encode dependence information, and the nodes don't represent random variables. NNs are different because they are discriminative. Popular neural networks are used for classification and regression.
Kevin Murphy has an excellent introduction to these topics available here.
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
A Bayesian network is a type of graphical model. The other "big" type of graphical model is a Markov Random Field (MRF). Graphical models are used for inference, estimation and in general, to model t
|
7,039
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
|
As @carlosdc said, a bayesian network is a type of Graphical Model (i.e., a directed acyclic graph (DAG) whose structure defines a set of conditional independence properties). Hierarchical Bayes Models can also be represented as DAGs; Hierarchical Naive Bayes Classifiers for uncertain data, by Bellazzi et al., provides a good introduction to classification with such models. About hierarchical models, I think many articles can be retrieved by googling with appropriate keywords; for example, I found this one:
C. H. Jackson, N. G. Best and S.
Richardson. Bayesian graphical models
for regression on multiple data sets
with different variables.
Biostatistics (2008) 10(2): 335-351.
Michael I. Jordan has a nice tutorial on Graphical Models, with various applications based on the factorial Hidden Markov model in bioinformatics or natural language processing. His book, Learning in Graphical Models (MIT Press, 1998), is also worth reading (there's an application of GMs to structural modeling with BUGS code, pp. 575-598)
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
|
As @carlosdc said, a bayesian network is a type of Graphical Model (i.e., a directed acyclic graph (DAG) whose structure defines a set of conditional independence properties). Hierarchical Bayes Model
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
As @carlosdc said, a bayesian network is a type of Graphical Model (i.e., a directed acyclic graph (DAG) whose structure defines a set of conditional independence properties). Hierarchical Bayes Models can also be represented as DAGs; Hierarchical Naive Bayes Classifiers for uncertain data, by Bellazzi et al., provides a good introduction to classification with such models. About hierarchical models, I think many articles can be retrieved by googling with appropriate keywords; for example, I found this one:
C. H. Jackson, N. G. Best and S.
Richardson. Bayesian graphical models
for regression on multiple data sets
with different variables.
Biostatistics (2008) 10(2): 335-351.
Michael I. Jordan has a nice tutorial on Graphical Models, with various applications based on the factorial Hidden Markov model in bioinformatics or natural language processing. His book, Learning in Graphical Models (MIT Press, 1998), is also worth reading (there's an application of GMs to structural modeling with BUGS code, pp. 575-598)
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
As @carlosdc said, a bayesian network is a type of Graphical Model (i.e., a directed acyclic graph (DAG) whose structure defines a set of conditional independence properties). Hierarchical Bayes Model
|
7,040
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
|
Neural networks does not require priors, but each hidden node (neurons) of a neural network can be considered as CPD
- Noisy OR/AND CPD for a linear node
- Sigmoid CPD for a logistic node
So, neural networks could be viewed as multiple layers of hidden nodes, each with linear/sigmoidal CPDs
Koller's class on Coursera OR her textbook should be a good reference for types of CPDs.
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
|
Neural networks does not require priors, but each hidden node (neurons) of a neural network can be considered as CPD
- Noisy OR/AND CPD for a linear node
- Sigmoid CPD for a logistic node
So, neural n
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian networks?
Neural networks does not require priors, but each hidden node (neurons) of a neural network can be considered as CPD
- Noisy OR/AND CPD for a linear node
- Sigmoid CPD for a logistic node
So, neural networks could be viewed as multiple layers of hidden nodes, each with linear/sigmoidal CPDs
Koller's class on Coursera OR her textbook should be a good reference for types of CPDs.
|
What's the relation between hierarchical models, neural networks, graphical models, bayesian network
Neural networks does not require priors, but each hidden node (neurons) of a neural network can be considered as CPD
- Noisy OR/AND CPD for a linear node
- Sigmoid CPD for a logistic node
So, neural n
|
7,041
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
You may also find the following papers to be of interest:
R. J. Tibshirani and J. Taylor (2011), Degrees of freedom in lasso problems, arXiv preprint:1111.0653.
H. Zou, T. Hastie and R. Tibshirani (2007), On the degrees of freedom of the lasso, Annals of Statistics 35 (5), 2173–2192.
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
You may also find the following papers to be of interest:
R. J. Tibshirani and J. Taylor (2011), Degrees of freedom in lasso problems, arXiv preprint:1111.0653.
H. Zou, T. Hastie and R. Tibshirani (
|
Is it possible to calculate AIC and BIC for lasso regression models?
You may also find the following papers to be of interest:
R. J. Tibshirani and J. Taylor (2011), Degrees of freedom in lasso problems, arXiv preprint:1111.0653.
H. Zou, T. Hastie and R. Tibshirani (2007), On the degrees of freedom of the lasso, Annals of Statistics 35 (5), 2173–2192.
|
Is it possible to calculate AIC and BIC for lasso regression models?
You may also find the following papers to be of interest:
R. J. Tibshirani and J. Taylor (2011), Degrees of freedom in lasso problems, arXiv preprint:1111.0653.
H. Zou, T. Hastie and R. Tibshirani (
|
7,042
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
I was struggling a lot with a way how to calculate AIC and BIC for glmnet models. However, after quite a lot of searching, I found on the third page of google results the answer. It can be found here. I am posting it here for future readers as I believe I cannot be the only one.
In the end, I implemented the AIC and BIC in the following way:
fit <- glmnet(x, y, family = "multinomial")
tLL <- fit$nulldev - deviance(fit)
k <- fit$df
n <- fit$nobs
AICc <- -tLL+2*k+2*k*(k+1)/(n-k-1)
AICc
BIC<-log(n)*k - tLL
BIC
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
I was struggling a lot with a way how to calculate AIC and BIC for glmnet models. However, after quite a lot of searching, I found on the third page of google results the answer. It can be found here.
|
Is it possible to calculate AIC and BIC for lasso regression models?
I was struggling a lot with a way how to calculate AIC and BIC for glmnet models. However, after quite a lot of searching, I found on the third page of google results the answer. It can be found here. I am posting it here for future readers as I believe I cannot be the only one.
In the end, I implemented the AIC and BIC in the following way:
fit <- glmnet(x, y, family = "multinomial")
tLL <- fit$nulldev - deviance(fit)
k <- fit$df
n <- fit$nobs
AICc <- -tLL+2*k+2*k*(k+1)/(n-k-1)
AICc
BIC<-log(n)*k - tLL
BIC
|
Is it possible to calculate AIC and BIC for lasso regression models?
I was struggling a lot with a way how to calculate AIC and BIC for glmnet models. However, after quite a lot of searching, I found on the third page of google results the answer. It can be found here.
|
7,043
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
In the link referenced by johnnyheineken, the author states:
I'm afraid that the two quantities available from the glmnet object(dev.ratio, nulldev) are not enough to obtain the likelihood for the model, which you need to compute AICc. You have two equations in three unknowns: likelihood(null), likelihood(model), and likelihood(saturated). I can't get the likelihood(model) free from the likelihood(null).
It seems to me, that if you're comparing the AIC between two models, the fact that you can't separate the null deviance shouldn't matter. Since it exists on both "sides" of the inequality, it would show which model must have the lower AIC. This is dependent on two things:
The data is the same in both models (necessary for AIC comparison anyway)
I am neither forgetting something from Stat101 nor high school algebra (a strong assumption given my current caffeine intake)
|
Is it possible to calculate AIC and BIC for lasso regression models?
|
In the link referenced by johnnyheineken, the author states:
I'm afraid that the two quantities available from the glmnet object(dev.ratio, nulldev) are not enough to obtain the likelihood for the mo
|
Is it possible to calculate AIC and BIC for lasso regression models?
In the link referenced by johnnyheineken, the author states:
I'm afraid that the two quantities available from the glmnet object(dev.ratio, nulldev) are not enough to obtain the likelihood for the model, which you need to compute AICc. You have two equations in three unknowns: likelihood(null), likelihood(model), and likelihood(saturated). I can't get the likelihood(model) free from the likelihood(null).
It seems to me, that if you're comparing the AIC between two models, the fact that you can't separate the null deviance shouldn't matter. Since it exists on both "sides" of the inequality, it would show which model must have the lower AIC. This is dependent on two things:
The data is the same in both models (necessary for AIC comparison anyway)
I am neither forgetting something from Stat101 nor high school algebra (a strong assumption given my current caffeine intake)
|
Is it possible to calculate AIC and BIC for lasso regression models?
In the link referenced by johnnyheineken, the author states:
I'm afraid that the two quantities available from the glmnet object(dev.ratio, nulldev) are not enough to obtain the likelihood for the mo
|
7,044
|
Do we need a test set when using k-fold cross-validation?
|
In the K-Fold method, do we still hold out a test set for the very end, and only use the remaining data for training and hyperparameter tuning (ie. we split the remaining data into k folds, and then use the average accuracy after training with each fold (or whatever performance metric we choose) to tune our hyperparameters)?
Yes. As a rule, the test set should never be used to change your model (e.g., its hyperparameters).
However, cross-validation can sometimes be used for purposes other than hyperparameter tuning, e.g. determining to what extent the train/test split impacts the results.
|
Do we need a test set when using k-fold cross-validation?
|
In the K-Fold method, do we still hold out a test set for the very end, and only use the remaining data for training and hyperparameter tuning (ie. we split the remaining data into k folds, and then u
|
Do we need a test set when using k-fold cross-validation?
In the K-Fold method, do we still hold out a test set for the very end, and only use the remaining data for training and hyperparameter tuning (ie. we split the remaining data into k folds, and then use the average accuracy after training with each fold (or whatever performance metric we choose) to tune our hyperparameters)?
Yes. As a rule, the test set should never be used to change your model (e.g., its hyperparameters).
However, cross-validation can sometimes be used for purposes other than hyperparameter tuning, e.g. determining to what extent the train/test split impacts the results.
|
Do we need a test set when using k-fold cross-validation?
In the K-Fold method, do we still hold out a test set for the very end, and only use the remaining data for training and hyperparameter tuning (ie. we split the remaining data into k folds, and then u
|
7,045
|
Do we need a test set when using k-fold cross-validation?
|
Generally, yes.
Basically you we are talking about the bias-variance tradeoff. If you use data to build up your model (training and validation data) and you iterate over different hyperparameters and you try to maximize an averaged performence metric your model might not be as good as indicated.
However, especially in small datasets the additional split might lead to an even smaller training set and result in a bad model.
|
Do we need a test set when using k-fold cross-validation?
|
Generally, yes.
Basically you we are talking about the bias-variance tradeoff. If you use data to build up your model (training and validation data) and you iterate over different hyperparameters and
|
Do we need a test set when using k-fold cross-validation?
Generally, yes.
Basically you we are talking about the bias-variance tradeoff. If you use data to build up your model (training and validation data) and you iterate over different hyperparameters and you try to maximize an averaged performence metric your model might not be as good as indicated.
However, especially in small datasets the additional split might lead to an even smaller training set and result in a bad model.
|
Do we need a test set when using k-fold cross-validation?
Generally, yes.
Basically you we are talking about the bias-variance tradeoff. If you use data to build up your model (training and validation data) and you iterate over different hyperparameters and
|
7,046
|
Do we need a test set when using k-fold cross-validation?
|
Ideally, validation (for model selection) and final test should not be mixed. However, if your k value is high, or it is leave-one-out, using test result to guide your model selection is less harmful. In this scenario, if you are writing an academic paper, do not do it (unless you bother to explain)-- meaning always have a separate test set. If you are building a practical project, it is OK to do so.
|
Do we need a test set when using k-fold cross-validation?
|
Ideally, validation (for model selection) and final test should not be mixed. However, if your k value is high, or it is leave-one-out, using test result to guide your model selection is less harmful.
|
Do we need a test set when using k-fold cross-validation?
Ideally, validation (for model selection) and final test should not be mixed. However, if your k value is high, or it is leave-one-out, using test result to guide your model selection is less harmful. In this scenario, if you are writing an academic paper, do not do it (unless you bother to explain)-- meaning always have a separate test set. If you are building a practical project, it is OK to do so.
|
Do we need a test set when using k-fold cross-validation?
Ideally, validation (for model selection) and final test should not be mixed. However, if your k value is high, or it is leave-one-out, using test result to guide your model selection is less harmful.
|
7,047
|
Clustering a dataset with both discrete and continuous variables
|
So you've been told you need an appropriate distance measure. Here are some leads:
Clustering mixed data
A generalized Mahalanobis distance for mixed data
Estimating the Mahalanobis distance from mixed continuous and discrete data
Generalization of the Mahalanobis distance in the mixed case
Distance functions for categorical and mixed variables
Informational distances and related statistics in mixed continuous and categorical variables
and, of course: Mahalanobis distance.
|
Clustering a dataset with both discrete and continuous variables
|
So you've been told you need an appropriate distance measure. Here are some leads:
Clustering mixed data
A generalized Mahalanobis distance for mixed data
Estimating the Mahalanobis distance from mix
|
Clustering a dataset with both discrete and continuous variables
So you've been told you need an appropriate distance measure. Here are some leads:
Clustering mixed data
A generalized Mahalanobis distance for mixed data
Estimating the Mahalanobis distance from mixed continuous and discrete data
Generalization of the Mahalanobis distance in the mixed case
Distance functions for categorical and mixed variables
Informational distances and related statistics in mixed continuous and categorical variables
and, of course: Mahalanobis distance.
|
Clustering a dataset with both discrete and continuous variables
So you've been told you need an appropriate distance measure. Here are some leads:
Clustering mixed data
A generalized Mahalanobis distance for mixed data
Estimating the Mahalanobis distance from mix
|
7,048
|
Clustering a dataset with both discrete and continuous variables
|
I've had to deal with this kind of problem in the past, and I think there could be 2 interesting approaches:
Continuousification: transform symbolic attributes with a sequence of integers. There are several ways to do this, all of which described in this paper. You can try NBF, VDM and MDV algorithms.
Discretization: transform continuous attributes into symbolic values. Again, many algorithms, and a good lecture on this would be this article. I believe the most commonly used method is Holte's 1R, but the best way to know for sure is to look at the ROC curves against algorithms like EWD, EFD, ID, LD or NDD.
Once you have all your features in the same space, it becomes an usual clustering problem.
Choosing between continuousification or discretization depends on your dataset and what your features look like, so it's a bit hard to say, but I advise you to read the articles I gave you on that topic.
|
Clustering a dataset with both discrete and continuous variables
|
I've had to deal with this kind of problem in the past, and I think there could be 2 interesting approaches:
Continuousification: transform symbolic attributes with a sequence of integers. There are
|
Clustering a dataset with both discrete and continuous variables
I've had to deal with this kind of problem in the past, and I think there could be 2 interesting approaches:
Continuousification: transform symbolic attributes with a sequence of integers. There are several ways to do this, all of which described in this paper. You can try NBF, VDM and MDV algorithms.
Discretization: transform continuous attributes into symbolic values. Again, many algorithms, and a good lecture on this would be this article. I believe the most commonly used method is Holte's 1R, but the best way to know for sure is to look at the ROC curves against algorithms like EWD, EFD, ID, LD or NDD.
Once you have all your features in the same space, it becomes an usual clustering problem.
Choosing between continuousification or discretization depends on your dataset and what your features look like, so it's a bit hard to say, but I advise you to read the articles I gave you on that topic.
|
Clustering a dataset with both discrete and continuous variables
I've had to deal with this kind of problem in the past, and I think there could be 2 interesting approaches:
Continuousification: transform symbolic attributes with a sequence of integers. There are
|
7,049
|
Clustering a dataset with both discrete and continuous variables
|
K-means obviously doesn't make any sense, as it computes means (which are nonsensical). Same goes for GMM.
You might want to try distance-based clustering algorithms with appropriate distance functions, for example DBSCAN.
The main challenge is to find a distance function!
While you could put a different distance function into k-means, it will still compute the mean which probably doesn't make much sense (and probably messes with a distance function for discrete values).
Anyway, first focus on define what "similar" is. Then cluster using this definition of similar!
|
Clustering a dataset with both discrete and continuous variables
|
K-means obviously doesn't make any sense, as it computes means (which are nonsensical). Same goes for GMM.
You might want to try distance-based clustering algorithms with appropriate distance function
|
Clustering a dataset with both discrete and continuous variables
K-means obviously doesn't make any sense, as it computes means (which are nonsensical). Same goes for GMM.
You might want to try distance-based clustering algorithms with appropriate distance functions, for example DBSCAN.
The main challenge is to find a distance function!
While you could put a different distance function into k-means, it will still compute the mean which probably doesn't make much sense (and probably messes with a distance function for discrete values).
Anyway, first focus on define what "similar" is. Then cluster using this definition of similar!
|
Clustering a dataset with both discrete and continuous variables
K-means obviously doesn't make any sense, as it computes means (which are nonsensical). Same goes for GMM.
You might want to try distance-based clustering algorithms with appropriate distance function
|
7,050
|
Clustering a dataset with both discrete and continuous variables
|
If you are comfortable working with a distance matrix of size num_of_samples x num_of_samples, you could use random forests, as well.
Click here for a reference paper titled Unsupervised learning with random forest predictors.
The idea is creating a synthetic dataset by shuffling values in the original dataset and training a classifier for separating both. During classification you will get an inter-sample distance matrix, on which you could test your favorite clustering algorithm.
|
Clustering a dataset with both discrete and continuous variables
|
If you are comfortable working with a distance matrix of size num_of_samples x num_of_samples, you could use random forests, as well.
Click here for a reference paper titled Unsupervised learning with
|
Clustering a dataset with both discrete and continuous variables
If you are comfortable working with a distance matrix of size num_of_samples x num_of_samples, you could use random forests, as well.
Click here for a reference paper titled Unsupervised learning with random forest predictors.
The idea is creating a synthetic dataset by shuffling values in the original dataset and training a classifier for separating both. During classification you will get an inter-sample distance matrix, on which you could test your favorite clustering algorithm.
|
Clustering a dataset with both discrete and continuous variables
If you are comfortable working with a distance matrix of size num_of_samples x num_of_samples, you could use random forests, as well.
Click here for a reference paper titled Unsupervised learning with
|
7,051
|
Clustering a dataset with both discrete and continuous variables
|
Mixed approach to be adopted:
1) Use classification technique (C4.5 decision tree) to classify the data set into 2 classes.
2) Once it is done, leave categorical variables and proceed with continuous variables for clustering.
|
Clustering a dataset with both discrete and continuous variables
|
Mixed approach to be adopted:
1) Use classification technique (C4.5 decision tree) to classify the data set into 2 classes.
2) Once it is done, leave categorical variables and proceed with continuous
|
Clustering a dataset with both discrete and continuous variables
Mixed approach to be adopted:
1) Use classification technique (C4.5 decision tree) to classify the data set into 2 classes.
2) Once it is done, leave categorical variables and proceed with continuous variables for clustering.
|
Clustering a dataset with both discrete and continuous variables
Mixed approach to be adopted:
1) Use classification technique (C4.5 decision tree) to classify the data set into 2 classes.
2) Once it is done, leave categorical variables and proceed with continuous
|
7,052
|
Sampling for Imbalanced Data in Regression
|
Imbalance is not necessarily a problem, but how you get there can be. It is unsound to base your sampling strategy on the target variable. Because this variable incorporates the randomness in your regression model, if you sample based on this you will have big problems doing any kind of inference. I doubt it is possible to "undo" those problems.
You can legitimately over- or under-sample based on the predictor variables. In this case, provided you carefully check that the model assumptions seem valid (eg homoscedasticity one that springs to mind as important in this situation, if you have an "ordinary" regression with the usuals assumptions), I don't think you need to undo the oversampling when predicting. Your case would now be similar to an analyst who has designed an experiment explicitly to have a balanced range of the predictor variables.
Edit - addition - expansion on why it is bad to sample based on Y
In fitting the standard regression model $y=Xb+e$ the $e$ is expected to be normally distributed, have a mean of zero, and be independent and identically distributed. If you choose your sample based on the value of the y (which includes a contribution of $e$ as well as of $Xb$) the e will no longer have a mean of zero or be identically distributed. For example, low values of y which might include very low values of e might be less likely to be selected. This ruins any inference based on the usual means of fitting such models. Corrections can be made similar to those made in econometrics for fitting truncated models, but they are a pain and require additional assumptions, and should only be employed whenm there is no alternative.
Consider the extreme illustration below. If you truncate your data at an arbitrary value for the response variable, you introduce very significant biases. If you truncate it for an explanatory variable, there is not necessarily a problem. You see that the green line, based on a subset chosen because of their predictor values, is very close to the true fitted line; this cannot be said of the blue line, based only on the blue points.
This extends to the less severe case of under or oversampling (because truncation can be seen as undersampling taken to its logical extreme).
# generate data
x <- rnorm(100)
y <- 3 + 2*x + rnorm(100)
# demonstrate
plot(x,y, bty="l")
abline(v=0, col="grey70")
abline(h=4, col="grey70")
abline(3,2, col=1)
abline(lm(y~x), col=2)
abline(lm(y[x>0] ~ x[x>0]), col=3)
abline(lm(y[y>4] ~ x[y>4]), col=4)
points(x[y>4], y[y>4], pch=19, col=4)
points(x[x>0], y[x>0], pch=1, cex=1.5, col=3)
legend(-2.5,8, legend=c("True line", "Fitted - all data", "Fitted - subset based on x",
"Fitted - subset based on y"), lty=1, col=1:4, bty="n")
|
Sampling for Imbalanced Data in Regression
|
Imbalance is not necessarily a problem, but how you get there can be. It is unsound to base your sampling strategy on the target variable. Because this variable incorporates the randomness in your r
|
Sampling for Imbalanced Data in Regression
Imbalance is not necessarily a problem, but how you get there can be. It is unsound to base your sampling strategy on the target variable. Because this variable incorporates the randomness in your regression model, if you sample based on this you will have big problems doing any kind of inference. I doubt it is possible to "undo" those problems.
You can legitimately over- or under-sample based on the predictor variables. In this case, provided you carefully check that the model assumptions seem valid (eg homoscedasticity one that springs to mind as important in this situation, if you have an "ordinary" regression with the usuals assumptions), I don't think you need to undo the oversampling when predicting. Your case would now be similar to an analyst who has designed an experiment explicitly to have a balanced range of the predictor variables.
Edit - addition - expansion on why it is bad to sample based on Y
In fitting the standard regression model $y=Xb+e$ the $e$ is expected to be normally distributed, have a mean of zero, and be independent and identically distributed. If you choose your sample based on the value of the y (which includes a contribution of $e$ as well as of $Xb$) the e will no longer have a mean of zero or be identically distributed. For example, low values of y which might include very low values of e might be less likely to be selected. This ruins any inference based on the usual means of fitting such models. Corrections can be made similar to those made in econometrics for fitting truncated models, but they are a pain and require additional assumptions, and should only be employed whenm there is no alternative.
Consider the extreme illustration below. If you truncate your data at an arbitrary value for the response variable, you introduce very significant biases. If you truncate it for an explanatory variable, there is not necessarily a problem. You see that the green line, based on a subset chosen because of their predictor values, is very close to the true fitted line; this cannot be said of the blue line, based only on the blue points.
This extends to the less severe case of under or oversampling (because truncation can be seen as undersampling taken to its logical extreme).
# generate data
x <- rnorm(100)
y <- 3 + 2*x + rnorm(100)
# demonstrate
plot(x,y, bty="l")
abline(v=0, col="grey70")
abline(h=4, col="grey70")
abline(3,2, col=1)
abline(lm(y~x), col=2)
abline(lm(y[x>0] ~ x[x>0]), col=3)
abline(lm(y[y>4] ~ x[y>4]), col=4)
points(x[y>4], y[y>4], pch=19, col=4)
points(x[x>0], y[x>0], pch=1, cex=1.5, col=3)
legend(-2.5,8, legend=c("True line", "Fitted - all data", "Fitted - subset based on x",
"Fitted - subset based on y"), lty=1, col=1:4, bty="n")
|
Sampling for Imbalanced Data in Regression
Imbalance is not necessarily a problem, but how you get there can be. It is unsound to base your sampling strategy on the target variable. Because this variable incorporates the randomness in your r
|
7,053
|
Sampling for Imbalanced Data in Regression
|
Updated answer, May 2020:
There is actually a field of research that deals particularly with this question and has developed practically feasible solutions. It is called Covariate Shift Adaptation and has been popularized by a series of highly cited papers by Sugiyama et al., starting around 2007 (I believe). There is also a whole book devoted to this subject by Sugiyama / Kawanabe from 2012, called "Machine Learning in Non-Stationary Environments".
I will try to give a very brief summary of the main idea. Suppose your training data are drawn from a distribution $p_{\text{train}}(x)$, but you would like the model to perform well on data drawn from another distribution $p_{\text{target}}(x)$. This is what's called "covariate shift". Then, instead of minimizing the expected loss over the training distribution
$$ \theta^* = \arg \min_\theta E[\ell(x, \theta)]_{p_{\text{train}}} = \arg \min_\theta \frac{1}{N}\sum_{i=1}^N \ell(x_i, \theta)$$
as one would usually do, one minimizes the expected loss over the target distribution:
$$ \theta^* = \arg \min_\theta E[\ell(x, \theta)]_{p_{\text{target}}} \\
= \arg \min_\theta E\left[\frac{p_{\text{target}}(x)}{p_{\text{train}}(x)}\ell(x, \theta)\right]_{p_{\text{train}}} \\
= \arg \min_\theta \frac{1}{N}\sum_{i=1}^N \underbrace{\frac{p_{\text{target}}(x_i)}{p_{\text{train}}(x_i)}}_{=w_i} \ell(x_i, \theta)$$
In practice, this amounts to simply weighting individual samples by their importance $w_i$. The key to practically implementing this is an efficient method for estimating the importance, which is generally nontrivial. This is one of the main topic of papers on this subject, and many methods can be found in the literature (keyword "Direct importance estimation").
So, finally getting back to the original question, this method consists not of resampling or creating artificial samples, but of simply weighting the existing samples in an appropriate manner.
Interestingly, none of the papers I cited below cites this branch of research. Possibly, because the authors are/were unaware of it?
Old answer
This is not an attempt at providing a practical solution to your problem, but I just did a bit of research on dealing with imbalanced datasets in regression problems and wanted to share my results:
Essentially, this seems to be a more or less open problem, with very few solution attempts published (see Krawczyk 2016, "Learning from imbalanced data: open challenges and future directions").
Sampling strategies seem to be the most popular (only?) pursued solution approach, that is, oversampling of the under-represented class or undersampling of the over-represented class. See e.g. "SMOTE for Regression" by Torgo, Ribeiro et al., 2013.
All of the described methods appear to work by performing a classification of the (continuously distributed) data into discrete classes by some method, and using a standard class balancing method.
|
Sampling for Imbalanced Data in Regression
|
Updated answer, May 2020:
There is actually a field of research that deals particularly with this question and has developed practically feasible solutions. It is called Covariate Shift Adaptation and
|
Sampling for Imbalanced Data in Regression
Updated answer, May 2020:
There is actually a field of research that deals particularly with this question and has developed practically feasible solutions. It is called Covariate Shift Adaptation and has been popularized by a series of highly cited papers by Sugiyama et al., starting around 2007 (I believe). There is also a whole book devoted to this subject by Sugiyama / Kawanabe from 2012, called "Machine Learning in Non-Stationary Environments".
I will try to give a very brief summary of the main idea. Suppose your training data are drawn from a distribution $p_{\text{train}}(x)$, but you would like the model to perform well on data drawn from another distribution $p_{\text{target}}(x)$. This is what's called "covariate shift". Then, instead of minimizing the expected loss over the training distribution
$$ \theta^* = \arg \min_\theta E[\ell(x, \theta)]_{p_{\text{train}}} = \arg \min_\theta \frac{1}{N}\sum_{i=1}^N \ell(x_i, \theta)$$
as one would usually do, one minimizes the expected loss over the target distribution:
$$ \theta^* = \arg \min_\theta E[\ell(x, \theta)]_{p_{\text{target}}} \\
= \arg \min_\theta E\left[\frac{p_{\text{target}}(x)}{p_{\text{train}}(x)}\ell(x, \theta)\right]_{p_{\text{train}}} \\
= \arg \min_\theta \frac{1}{N}\sum_{i=1}^N \underbrace{\frac{p_{\text{target}}(x_i)}{p_{\text{train}}(x_i)}}_{=w_i} \ell(x_i, \theta)$$
In practice, this amounts to simply weighting individual samples by their importance $w_i$. The key to practically implementing this is an efficient method for estimating the importance, which is generally nontrivial. This is one of the main topic of papers on this subject, and many methods can be found in the literature (keyword "Direct importance estimation").
So, finally getting back to the original question, this method consists not of resampling or creating artificial samples, but of simply weighting the existing samples in an appropriate manner.
Interestingly, none of the papers I cited below cites this branch of research. Possibly, because the authors are/were unaware of it?
Old answer
This is not an attempt at providing a practical solution to your problem, but I just did a bit of research on dealing with imbalanced datasets in regression problems and wanted to share my results:
Essentially, this seems to be a more or less open problem, with very few solution attempts published (see Krawczyk 2016, "Learning from imbalanced data: open challenges and future directions").
Sampling strategies seem to be the most popular (only?) pursued solution approach, that is, oversampling of the under-represented class or undersampling of the over-represented class. See e.g. "SMOTE for Regression" by Torgo, Ribeiro et al., 2013.
All of the described methods appear to work by performing a classification of the (continuously distributed) data into discrete classes by some method, and using a standard class balancing method.
|
Sampling for Imbalanced Data in Regression
Updated answer, May 2020:
There is actually a field of research that deals particularly with this question and has developed practically feasible solutions. It is called Covariate Shift Adaptation and
|
7,054
|
Sampling for Imbalanced Data in Regression
|
It is a question of whether you are doing causal analysis or prediction.
Resampling on the target variable for training for the purposes of prediction works as long as one tests on an non-resampled hold out sample. The final performance chart must be based solely on the hold out. For most accuracy in the determination of the predictability of the model, cross validation techniques should be employed.
You "undo" by the final analysis of the regression model and on the imbalanced data set.
|
Sampling for Imbalanced Data in Regression
|
It is a question of whether you are doing causal analysis or prediction.
Resampling on the target variable for training for the purposes of prediction works as long as one tests on an non-resampled ho
|
Sampling for Imbalanced Data in Regression
It is a question of whether you are doing causal analysis or prediction.
Resampling on the target variable for training for the purposes of prediction works as long as one tests on an non-resampled hold out sample. The final performance chart must be based solely on the hold out. For most accuracy in the determination of the predictability of the model, cross validation techniques should be employed.
You "undo" by the final analysis of the regression model and on the imbalanced data set.
|
Sampling for Imbalanced Data in Regression
It is a question of whether you are doing causal analysis or prediction.
Resampling on the target variable for training for the purposes of prediction works as long as one tests on an non-resampled ho
|
7,055
|
Sampling for Imbalanced Data in Regression
|
first of all, 1:10 ration is not bad at all. there are simple way of undoing sampling-
1) for classification problem, If you have sub-sampled any negative class by 10. the resulting probability is 10 times more what is should be. you can simple divide resulting probability by 10.(known as model re calibration)
2) Facebook also sub-samples(for click prediction in logistic regression) and do a negative down sampling. recalibartion is done by simple formula p/(p+(1-p)/w); where p is prediction in downsampling,n w is negative down sampling rate.
|
Sampling for Imbalanced Data in Regression
|
first of all, 1:10 ration is not bad at all. there are simple way of undoing sampling-
1) for classification problem, If you have sub-sampled any negative class by 10. the resulting probability is 10
|
Sampling for Imbalanced Data in Regression
first of all, 1:10 ration is not bad at all. there are simple way of undoing sampling-
1) for classification problem, If you have sub-sampled any negative class by 10. the resulting probability is 10 times more what is should be. you can simple divide resulting probability by 10.(known as model re calibration)
2) Facebook also sub-samples(for click prediction in logistic regression) and do a negative down sampling. recalibartion is done by simple formula p/(p+(1-p)/w); where p is prediction in downsampling,n w is negative down sampling rate.
|
Sampling for Imbalanced Data in Regression
first of all, 1:10 ration is not bad at all. there are simple way of undoing sampling-
1) for classification problem, If you have sub-sampled any negative class by 10. the resulting probability is 10
|
7,056
|
Sampling for Imbalanced Data in Regression
|
A recent technique proposed for dealing with imbalanced distribution in regression is the Weighted Relevance-based Combination Strategy (WERCS). Branco et al. (2019) https://doi.org/10.1016/j.neucom.2018.11.100.
The author has reproducible R implementation of the method at GitHub here: https://github.com/paobranco/Pre-processingApproachesImbalanceRegression.
The authors note this WERCS method does not involve the generation of synthetic samples and yet show it often outperforms popular methods such as random over/under-sampling, Gaussian Noise, and SMOTER.
|
Sampling for Imbalanced Data in Regression
|
A recent technique proposed for dealing with imbalanced distribution in regression is the Weighted Relevance-based Combination Strategy (WERCS). Branco et al. (2019) https://doi.org/10.1016/j.neucom.2
|
Sampling for Imbalanced Data in Regression
A recent technique proposed for dealing with imbalanced distribution in regression is the Weighted Relevance-based Combination Strategy (WERCS). Branco et al. (2019) https://doi.org/10.1016/j.neucom.2018.11.100.
The author has reproducible R implementation of the method at GitHub here: https://github.com/paobranco/Pre-processingApproachesImbalanceRegression.
The authors note this WERCS method does not involve the generation of synthetic samples and yet show it often outperforms popular methods such as random over/under-sampling, Gaussian Noise, and SMOTER.
|
Sampling for Imbalanced Data in Regression
A recent technique proposed for dealing with imbalanced distribution in regression is the Weighted Relevance-based Combination Strategy (WERCS). Branco et al. (2019) https://doi.org/10.1016/j.neucom.2
|
7,057
|
Mode, Class and Type of R objects
|
The class() is used to define/identify what "type" an object is from the point of view of object-oriented programming in R. So for
> x <- 1:3
> class(x)
[1] "integer"
any generic function that has an "integer" method will be used.
typeof() gives the "type" of object from R's point of view, whilst mode() gives the "type" of object from the point of view of Becker, Chambers & Wilks (1988). The latter may be more compatible with other S implementations according to the R Language Definition manual.
I'd probably err on the side of using typeof() in most cases unless it was for passing R objects to compiled code, where storage.mode() will be useful.
This is usefully discussed in the R Language Definition as linked to above.
|
Mode, Class and Type of R objects
|
The class() is used to define/identify what "type" an object is from the point of view of object-oriented programming in R. So for
> x <- 1:3
> class(x)
[1] "integer"
any generic function that has an
|
Mode, Class and Type of R objects
The class() is used to define/identify what "type" an object is from the point of view of object-oriented programming in R. So for
> x <- 1:3
> class(x)
[1] "integer"
any generic function that has an "integer" method will be used.
typeof() gives the "type" of object from R's point of view, whilst mode() gives the "type" of object from the point of view of Becker, Chambers & Wilks (1988). The latter may be more compatible with other S implementations according to the R Language Definition manual.
I'd probably err on the side of using typeof() in most cases unless it was for passing R objects to compiled code, where storage.mode() will be useful.
This is usefully discussed in the R Language Definition as linked to above.
|
Mode, Class and Type of R objects
The class() is used to define/identify what "type" an object is from the point of view of object-oriented programming in R. So for
> x <- 1:3
> class(x)
[1] "integer"
any generic function that has an
|
7,058
|
Mode, Class and Type of R objects
|
From: https://www.mail-archive.com/r-help@r-project.org/msg17169.html :
'mode' is a mutually exclusive classification of objects according to
their basic structure. The 'atomic' modes are numeric, complex,
character and logical. Recursive objects have modes such as 'list' or
'function' or a few others. An object has one and only one mode.
'class' is a property assigned to an object that determines how generic
functions operate with it. It is not a mutually exclusive
classification. If an object has no specific class assigned to it, such
as a simple numeric vector, it's class is usually the same as its mode,
by convention.
Changing the mode of an object is often called 'coercion'. The mode of
an object can change without necessarily changing the class.
|
Mode, Class and Type of R objects
|
From: https://www.mail-archive.com/r-help@r-project.org/msg17169.html :
'mode' is a mutually exclusive classification of objects according to
their basic structure. The 'atomic' modes are numeric, co
|
Mode, Class and Type of R objects
From: https://www.mail-archive.com/r-help@r-project.org/msg17169.html :
'mode' is a mutually exclusive classification of objects according to
their basic structure. The 'atomic' modes are numeric, complex,
character and logical. Recursive objects have modes such as 'list' or
'function' or a few others. An object has one and only one mode.
'class' is a property assigned to an object that determines how generic
functions operate with it. It is not a mutually exclusive
classification. If an object has no specific class assigned to it, such
as a simple numeric vector, it's class is usually the same as its mode,
by convention.
Changing the mode of an object is often called 'coercion'. The mode of
an object can change without necessarily changing the class.
|
Mode, Class and Type of R objects
From: https://www.mail-archive.com/r-help@r-project.org/msg17169.html :
'mode' is a mutually exclusive classification of objects according to
their basic structure. The 'atomic' modes are numeric, co
|
7,059
|
Mode, Class and Type of R objects
|
The main difference between class and typeof is that the first can be defined by the user, but the type cannot. For example, define a list
> x<-list("a",c(1,2))
> # x is a list
> class(x)
[1] "list"
> # class can be user defined
> class(x)<-"newclass"
> class(x)
[1] "newclass"
> typeof(x)
[1] "list"
# you cannot assign a different type using typeof()
> typeof(x)<-"newclass"
Error in typeof(x) <- "newclass" : could not find function "typeof<-"
To give a certain class name to a user defined object is very useful to write programs. It allows to tag user defined objects in a similar way to what happens in object-oriented programming languages.
|
Mode, Class and Type of R objects
|
The main difference between class and typeof is that the first can be defined by the user, but the type cannot. For example, define a list
> x<-list("a",c(1,2))
> # x is a list
> class(x)
[1] "list"
|
Mode, Class and Type of R objects
The main difference between class and typeof is that the first can be defined by the user, but the type cannot. For example, define a list
> x<-list("a",c(1,2))
> # x is a list
> class(x)
[1] "list"
> # class can be user defined
> class(x)<-"newclass"
> class(x)
[1] "newclass"
> typeof(x)
[1] "list"
# you cannot assign a different type using typeof()
> typeof(x)<-"newclass"
Error in typeof(x) <- "newclass" : could not find function "typeof<-"
To give a certain class name to a user defined object is very useful to write programs. It allows to tag user defined objects in a similar way to what happens in object-oriented programming languages.
|
Mode, Class and Type of R objects
The main difference between class and typeof is that the first can be defined by the user, but the type cannot. For example, define a list
> x<-list("a",c(1,2))
> # x is a list
> class(x)
[1] "list"
|
7,060
|
How to visualize/understand what a neural network is doing?
|
Neural networks are sometimes called "differentiable function approximators". So what you can do is to differentiate any unit with respect to any other unit to see what their relationshsip is.
You can check how sensitive the error of the network is wrt to a specific input as well with this.
Then, there is something called "receptive fields", which is just the visualization of the connections going into a hidden unit. This makes it easy to understand what particular units do for image data, for example. This can be done for higher levels as well. See Visualizing Higher-Level Features of a Deep Network.
|
How to visualize/understand what a neural network is doing?
|
Neural networks are sometimes called "differentiable function approximators". So what you can do is to differentiate any unit with respect to any other unit to see what their relationshsip is.
You can
|
How to visualize/understand what a neural network is doing?
Neural networks are sometimes called "differentiable function approximators". So what you can do is to differentiate any unit with respect to any other unit to see what their relationshsip is.
You can check how sensitive the error of the network is wrt to a specific input as well with this.
Then, there is something called "receptive fields", which is just the visualization of the connections going into a hidden unit. This makes it easy to understand what particular units do for image data, for example. This can be done for higher levels as well. See Visualizing Higher-Level Features of a Deep Network.
|
How to visualize/understand what a neural network is doing?
Neural networks are sometimes called "differentiable function approximators". So what you can do is to differentiate any unit with respect to any other unit to see what their relationshsip is.
You can
|
7,061
|
How to visualize/understand what a neural network is doing?
|
Estimate feature importance by randomly bumping every value of a single feature, and recording how your overall fitness function degrades.
So if your first feature $x_{1,i}$ is continuously-valued and scaled to $[0,1]$, then you might add $rand(0,1)-0.5$ to each training example's value for the first feature. Then look for how much your $R^2$ decreases. This effectively excludes a feature from your training data, but deals with cross-interactions better than literally deleting the feature.
Then rank your features by fitness function degradation, and make a pretty bar chart. At least some of the most important features should pass a gut-check, given your knowledge of the problem domain. And this also lets you be nicely surprised by informative features that you may not have expected.
This sort of feature importance test works for all black-box models, including neural networks and large CART ensembles. In my experience, feature importance is the first step in understanding what a model is really doing.
|
How to visualize/understand what a neural network is doing?
|
Estimate feature importance by randomly bumping every value of a single feature, and recording how your overall fitness function degrades.
So if your first feature $x_{1,i}$ is continuously-valued and
|
How to visualize/understand what a neural network is doing?
Estimate feature importance by randomly bumping every value of a single feature, and recording how your overall fitness function degrades.
So if your first feature $x_{1,i}$ is continuously-valued and scaled to $[0,1]$, then you might add $rand(0,1)-0.5$ to each training example's value for the first feature. Then look for how much your $R^2$ decreases. This effectively excludes a feature from your training data, but deals with cross-interactions better than literally deleting the feature.
Then rank your features by fitness function degradation, and make a pretty bar chart. At least some of the most important features should pass a gut-check, given your knowledge of the problem domain. And this also lets you be nicely surprised by informative features that you may not have expected.
This sort of feature importance test works for all black-box models, including neural networks and large CART ensembles. In my experience, feature importance is the first step in understanding what a model is really doing.
|
How to visualize/understand what a neural network is doing?
Estimate feature importance by randomly bumping every value of a single feature, and recording how your overall fitness function degrades.
So if your first feature $x_{1,i}$ is continuously-valued and
|
7,062
|
How to visualize/understand what a neural network is doing?
|
Here's a graphical intuition for a particular kind of neural networks. At the end of that post, there's a link to R code that shows a visualization for a particular problem. Here's what that looks like:
|
How to visualize/understand what a neural network is doing?
|
Here's a graphical intuition for a particular kind of neural networks. At the end of that post, there's a link to R code that shows a visualization for a particular problem. Here's what that looks lik
|
How to visualize/understand what a neural network is doing?
Here's a graphical intuition for a particular kind of neural networks. At the end of that post, there's a link to R code that shows a visualization for a particular problem. Here's what that looks like:
|
How to visualize/understand what a neural network is doing?
Here's a graphical intuition for a particular kind of neural networks. At the end of that post, there's a link to R code that shows a visualization for a particular problem. Here's what that looks lik
|
7,063
|
How to visualize/understand what a neural network is doing?
|
Fall 2011 I took the free online Machine Learning course from Standford taught by Andrew Ng, and we visualized a neural network which was a face detector. The output was a generic face. I want to mention this for completeness, but you didn't mention this kind of application, so I am not going to dig up the details. :)
|
How to visualize/understand what a neural network is doing?
|
Fall 2011 I took the free online Machine Learning course from Standford taught by Andrew Ng, and we visualized a neural network which was a face detector. The output was a generic face. I want to me
|
How to visualize/understand what a neural network is doing?
Fall 2011 I took the free online Machine Learning course from Standford taught by Andrew Ng, and we visualized a neural network which was a face detector. The output was a generic face. I want to mention this for completeness, but you didn't mention this kind of application, so I am not going to dig up the details. :)
|
How to visualize/understand what a neural network is doing?
Fall 2011 I took the free online Machine Learning course from Standford taught by Andrew Ng, and we visualized a neural network which was a face detector. The output was a generic face. I want to me
|
7,064
|
How to visualize/understand what a neural network is doing?
|
The below mentioned method is taken from this link, visit the site for more details.
Start with a random image, i.e., arbitrarily provide values to the pixels. "Next, we do a forward pass using this image x as input to the network to compute the activation a_i(x) caused by x at some neuron i somewhere in the middle of the network. Then we do a backward pass (performing backprop) to compute the gradient of a_i(x) with respect to earlier activations in the network. At the end of the backward pass we are left with the gradient ∂a_i(x)/∂x, or how to change the color of each pixel to increase the activation of neuron i. We do exactly that by adding a little fraction αα of that gradient to the image:
x ← x + α⋅∂a_i(x)/∂x
We keep doing that repeatedly until we have an image x' that causes high activation of the neuron in question."
|
How to visualize/understand what a neural network is doing?
|
The below mentioned method is taken from this link, visit the site for more details.
Start with a random image, i.e., arbitrarily provide values to the pixels. "Next, we do a forward pass using this i
|
How to visualize/understand what a neural network is doing?
The below mentioned method is taken from this link, visit the site for more details.
Start with a random image, i.e., arbitrarily provide values to the pixels. "Next, we do a forward pass using this image x as input to the network to compute the activation a_i(x) caused by x at some neuron i somewhere in the middle of the network. Then we do a backward pass (performing backprop) to compute the gradient of a_i(x) with respect to earlier activations in the network. At the end of the backward pass we are left with the gradient ∂a_i(x)/∂x, or how to change the color of each pixel to increase the activation of neuron i. We do exactly that by adding a little fraction αα of that gradient to the image:
x ← x + α⋅∂a_i(x)/∂x
We keep doing that repeatedly until we have an image x' that causes high activation of the neuron in question."
|
How to visualize/understand what a neural network is doing?
The below mentioned method is taken from this link, visit the site for more details.
Start with a random image, i.e., arbitrarily provide values to the pixels. "Next, we do a forward pass using this i
|
7,065
|
Can AIC compare across different types of model?
|
It depends. AIC is a function of the log likelihood. If both types of model compute the log likelihood the same way (i.e. include the same constant) then yes you can, if the models are nested.
I'm reasonably certain that glm() and lmer() don't use comparable log likelihoods.
The point about nested models is also up for discussion. Some say AIC is only valid for nested models as that is how the theory is presented/worked through. Others use it for all sorts of comparisons.
|
Can AIC compare across different types of model?
|
It depends. AIC is a function of the log likelihood. If both types of model compute the log likelihood the same way (i.e. include the same constant) then yes you can, if the models are nested.
I'm rea
|
Can AIC compare across different types of model?
It depends. AIC is a function of the log likelihood. If both types of model compute the log likelihood the same way (i.e. include the same constant) then yes you can, if the models are nested.
I'm reasonably certain that glm() and lmer() don't use comparable log likelihoods.
The point about nested models is also up for discussion. Some say AIC is only valid for nested models as that is how the theory is presented/worked through. Others use it for all sorts of comparisons.
|
Can AIC compare across different types of model?
It depends. AIC is a function of the log likelihood. If both types of model compute the log likelihood the same way (i.e. include the same constant) then yes you can, if the models are nested.
I'm rea
|
7,066
|
Can AIC compare across different types of model?
|
This is a great question that I've been curious about for a while.
For models in the same family (ie. auto-regressive models of order k or polynomials) AIC/BIC makes a lot of sense. In other cases it's less clear. Computing the log-likelihood exactly (with the constant terms) should work, but using more complicated model comparison such as Bayes Factors is probably better (http://www.jstor.org/stable/2291091).
If the models have the same loss/error-function one alternative is to just compare the cross-validated log-likelihoods. That's usually what I try to do when I'm not sure AIC/BIC makes sense in a certain situation.
|
Can AIC compare across different types of model?
|
This is a great question that I've been curious about for a while.
For models in the same family (ie. auto-regressive models of order k or polynomials) AIC/BIC makes a lot of sense. In other cases it'
|
Can AIC compare across different types of model?
This is a great question that I've been curious about for a while.
For models in the same family (ie. auto-regressive models of order k or polynomials) AIC/BIC makes a lot of sense. In other cases it's less clear. Computing the log-likelihood exactly (with the constant terms) should work, but using more complicated model comparison such as Bayes Factors is probably better (http://www.jstor.org/stable/2291091).
If the models have the same loss/error-function one alternative is to just compare the cross-validated log-likelihoods. That's usually what I try to do when I'm not sure AIC/BIC makes sense in a certain situation.
|
Can AIC compare across different types of model?
This is a great question that I've been curious about for a while.
For models in the same family (ie. auto-regressive models of order k or polynomials) AIC/BIC makes a lot of sense. In other cases it'
|
7,067
|
Can AIC compare across different types of model?
|
Note that in some cases AIC cannot even compare models of the same type, like ARIMA models with a different order of differencing. Quoting Forecasting: Principles and Practice by Rob J Hyndman and George Athanasopoulos:
It is important to note that these information criteria tend not to be good guides to selecting the appropriate order of differencing ($d$) of a model, but only for selecting the values of $p$ and $q$. This is because the differencing changes the data on which the likelihood is computed, making the AIC values between models with different orders of differencing not comparable. So we need to use some other approach to choose $d$, and then we can use the AICc to select $p$ and $q$.
|
Can AIC compare across different types of model?
|
Note that in some cases AIC cannot even compare models of the same type, like ARIMA models with a different order of differencing. Quoting Forecasting: Principles and Practice by Rob J Hyndman and Geo
|
Can AIC compare across different types of model?
Note that in some cases AIC cannot even compare models of the same type, like ARIMA models with a different order of differencing. Quoting Forecasting: Principles and Practice by Rob J Hyndman and George Athanasopoulos:
It is important to note that these information criteria tend not to be good guides to selecting the appropriate order of differencing ($d$) of a model, but only for selecting the values of $p$ and $q$. This is because the differencing changes the data on which the likelihood is computed, making the AIC values between models with different orders of differencing not comparable. So we need to use some other approach to choose $d$, and then we can use the AICc to select $p$ and $q$.
|
Can AIC compare across different types of model?
Note that in some cases AIC cannot even compare models of the same type, like ARIMA models with a different order of differencing. Quoting Forecasting: Principles and Practice by Rob J Hyndman and Geo
|
7,068
|
Model selection and cross-validation: The right way
|
My paper in JMLR addresses this exact question, and demonstrates why the procedure suggested in the question (or at least one very like it) results in optimistically biased performance estimates:
Gavin C. Cawley, Nicola L. C. Talbot, "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", Journal of Machine Learning Research, 11(Jul):2079−2107, 2010. (www)
The key thing to remember is that cross-validation is a technique for estimating the generalisation performance for a method of generating a model, rather than of the model itself. So if choosing kernel parameters is part of the process of generating the model, you need to cross-validate the model selection process as well, otherwise you will end up with an optimistically biased performance estimate (as will happen with the procedure you propose).
Assume you have a function fit_model, which takes in a dataset consisting of attributes X and desired responses Y, and which returns the fitted model for that dataset, including the tuning of hyper-parameters (in this case kernel and regularisation parameters). This tuning of hyper-parameters can be performed in many ways, for example minimising the cross-validation error over X and Y.
Step 1 - Fit the model to all available data, using the function fit_model. This gives you the model that you will use in operation or deployment.
Step 2 - Performance evaluation. Perform repeated cross-validation using all available data. In each fold, the data are partitioned into a training set and a test set. Fit the model using the training set (record hyper-parameter values for the fitted model) and evaluate performance on the test set. Use the mean over all of the test sets as a performance estimate (and perhaps look at the spread of values as well).
Step 3 - Variability of hyper-parameter settings - perform analysis of hyper-parameter values collected in step 3. However I should point out that there is nothing special about hyper-parameters, they are just parameters of the model that have been estimated (indirectly) from the data. They are treated as hyper-parameters rather than parameters for computational/mathematical convenience, but this doesn't have to be the case.
The problem with using cross-validation here is that the training and test data are not independent samples (as they share data) which means that the estimate of the variance of the performance estimate and of the hyper-parameters is likely to be biased (i.e. smaller than it would be for genuinely independent samples of data in each fold). Rather than repeated cross-validation, I would probably use bootstrapping instead and bag the resulting models if this was computationally feasible.
The key point is that to get an unbiased performance estimate, whatever procedure you use to generate the final model (fit_model) must be repeated in its entirety independently in each fold of the cross-validation procedure.
|
Model selection and cross-validation: The right way
|
My paper in JMLR addresses this exact question, and demonstrates why the procedure suggested in the question (or at least one very like it) results in optimistically biased performance estimates:
Gavi
|
Model selection and cross-validation: The right way
My paper in JMLR addresses this exact question, and demonstrates why the procedure suggested in the question (or at least one very like it) results in optimistically biased performance estimates:
Gavin C. Cawley, Nicola L. C. Talbot, "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", Journal of Machine Learning Research, 11(Jul):2079−2107, 2010. (www)
The key thing to remember is that cross-validation is a technique for estimating the generalisation performance for a method of generating a model, rather than of the model itself. So if choosing kernel parameters is part of the process of generating the model, you need to cross-validate the model selection process as well, otherwise you will end up with an optimistically biased performance estimate (as will happen with the procedure you propose).
Assume you have a function fit_model, which takes in a dataset consisting of attributes X and desired responses Y, and which returns the fitted model for that dataset, including the tuning of hyper-parameters (in this case kernel and regularisation parameters). This tuning of hyper-parameters can be performed in many ways, for example minimising the cross-validation error over X and Y.
Step 1 - Fit the model to all available data, using the function fit_model. This gives you the model that you will use in operation or deployment.
Step 2 - Performance evaluation. Perform repeated cross-validation using all available data. In each fold, the data are partitioned into a training set and a test set. Fit the model using the training set (record hyper-parameter values for the fitted model) and evaluate performance on the test set. Use the mean over all of the test sets as a performance estimate (and perhaps look at the spread of values as well).
Step 3 - Variability of hyper-parameter settings - perform analysis of hyper-parameter values collected in step 3. However I should point out that there is nothing special about hyper-parameters, they are just parameters of the model that have been estimated (indirectly) from the data. They are treated as hyper-parameters rather than parameters for computational/mathematical convenience, but this doesn't have to be the case.
The problem with using cross-validation here is that the training and test data are not independent samples (as they share data) which means that the estimate of the variance of the performance estimate and of the hyper-parameters is likely to be biased (i.e. smaller than it would be for genuinely independent samples of data in each fold). Rather than repeated cross-validation, I would probably use bootstrapping instead and bag the resulting models if this was computationally feasible.
The key point is that to get an unbiased performance estimate, whatever procedure you use to generate the final model (fit_model) must be repeated in its entirety independently in each fold of the cross-validation procedure.
|
Model selection and cross-validation: The right way
My paper in JMLR addresses this exact question, and demonstrates why the procedure suggested in the question (or at least one very like it) results in optimistically biased performance estimates:
Gavi
|
7,069
|
Model selection and cross-validation: The right way
|
Using a SVM with fixed hyperparameters ($\gamma$ and $C$) is a machine learning algorithm.
A procedure that optimizes these hyperparameters and trains a SVM with these is also just a machine learning algorithm.
Instead of only optimizing the internal parameters of the SVM (the support vectors) it also optimizes the hyperparameters.
Now you have two problems [that can be solved independently]:
How to perform hyperparameter
optimization/model selection?
How to estimate generalization error of a machine learning algorithm?
Read Cross-validation misuse (reporting performance for the best hyperparameter value) to make sure that you don't mix them up.
A specific (probably not optimal) solution to the concrete problem of your question:
k = 5
loss_CV = zeros(k)
for i in 1:k
Xi_train, Xi_test = folds(X,k)[i]
loss = zeros((3,3))
for lambda in {0.1,0.2,0.5,1.0}
for C in {10,100,1000}
for j in 1:k
Xj_train, Xj_test = folds(Xi_train,k)[j]
model = SVM(Xj_train,lambda, C)
loss[lambda,C] += test_error(model,Xj_test)
lambda, C = argmax(loss)
model = SVM(Xi_train,lambda, C)
loss_CV += test_error(model,Xi_test)
loss = zeros((3,3))
for lambda in {0.1,0.2,0.5,1.0}
for C in {10,100,1000}
for j in 1:k
Xj_train, Xj_test = folds(Xi_train,k)[j]
model = SVM(Xj_train,lambda, C)
loss[lambda,C] += test_error(model,Xj_test)
lambda, C = argmax(loss)
model = SVM(Xi_train,lambda, C)
Here, model would be your "best model" and loss_CV a "proper estimate of its generalization error" (although biased upward, but you cannot have the cake and eat it too).
|
Model selection and cross-validation: The right way
|
Using a SVM with fixed hyperparameters ($\gamma$ and $C$) is a machine learning algorithm.
A procedure that optimizes these hyperparameters and trains a SVM with these is also just a machine learning
|
Model selection and cross-validation: The right way
Using a SVM with fixed hyperparameters ($\gamma$ and $C$) is a machine learning algorithm.
A procedure that optimizes these hyperparameters and trains a SVM with these is also just a machine learning algorithm.
Instead of only optimizing the internal parameters of the SVM (the support vectors) it also optimizes the hyperparameters.
Now you have two problems [that can be solved independently]:
How to perform hyperparameter
optimization/model selection?
How to estimate generalization error of a machine learning algorithm?
Read Cross-validation misuse (reporting performance for the best hyperparameter value) to make sure that you don't mix them up.
A specific (probably not optimal) solution to the concrete problem of your question:
k = 5
loss_CV = zeros(k)
for i in 1:k
Xi_train, Xi_test = folds(X,k)[i]
loss = zeros((3,3))
for lambda in {0.1,0.2,0.5,1.0}
for C in {10,100,1000}
for j in 1:k
Xj_train, Xj_test = folds(Xi_train,k)[j]
model = SVM(Xj_train,lambda, C)
loss[lambda,C] += test_error(model,Xj_test)
lambda, C = argmax(loss)
model = SVM(Xi_train,lambda, C)
loss_CV += test_error(model,Xi_test)
loss = zeros((3,3))
for lambda in {0.1,0.2,0.5,1.0}
for C in {10,100,1000}
for j in 1:k
Xj_train, Xj_test = folds(Xi_train,k)[j]
model = SVM(Xj_train,lambda, C)
loss[lambda,C] += test_error(model,Xj_test)
lambda, C = argmax(loss)
model = SVM(Xi_train,lambda, C)
Here, model would be your "best model" and loss_CV a "proper estimate of its generalization error" (although biased upward, but you cannot have the cake and eat it too).
|
Model selection and cross-validation: The right way
Using a SVM with fixed hyperparameters ($\gamma$ and $C$) is a machine learning algorithm.
A procedure that optimizes these hyperparameters and trains a SVM with these is also just a machine learning
|
7,070
|
What are the benefits of using ReLU over softplus as activation functions?
|
I found an answer to your question in the Section 6.3.3 of the Deep Learning book. (Goodfellow et. al, 2016):
The use of softplus is generally discouraged. ... one might expect it to have advantage over the rectifier due to being differentiable everywhere or due to saturating less completely, but empirically it does not.
As a reference to support this claim they cite the paper Deep Sparse Rectifier Neural Networks (Glorot et. al, 2011).
|
What are the benefits of using ReLU over softplus as activation functions?
|
I found an answer to your question in the Section 6.3.3 of the Deep Learning book. (Goodfellow et. al, 2016):
The use of softplus is generally discouraged. ... one might expect it to have advantage o
|
What are the benefits of using ReLU over softplus as activation functions?
I found an answer to your question in the Section 6.3.3 of the Deep Learning book. (Goodfellow et. al, 2016):
The use of softplus is generally discouraged. ... one might expect it to have advantage over the rectifier due to being differentiable everywhere or due to saturating less completely, but empirically it does not.
As a reference to support this claim they cite the paper Deep Sparse Rectifier Neural Networks (Glorot et. al, 2011).
|
What are the benefits of using ReLU over softplus as activation functions?
I found an answer to your question in the Section 6.3.3 of the Deep Learning book. (Goodfellow et. al, 2016):
The use of softplus is generally discouraged. ... one might expect it to have advantage o
|
7,071
|
What are the benefits of using ReLU over softplus as activation functions?
|
ReLUs can indeed be permanently switched off, particularly under high learning rates. This is a motivation behind leaky ReLU, and ELU activations, both of which have non-zero gradient almost everywhere.
Leaky ReLU is a piecewise linear function, just as for ReLU, so quick to compute. ELU has the advantage over softplus and ReLU that its mean output is closer to zero, which improves learning.
|
What are the benefits of using ReLU over softplus as activation functions?
|
ReLUs can indeed be permanently switched off, particularly under high learning rates. This is a motivation behind leaky ReLU, and ELU activations, both of which have non-zero gradient almost everywher
|
What are the benefits of using ReLU over softplus as activation functions?
ReLUs can indeed be permanently switched off, particularly under high learning rates. This is a motivation behind leaky ReLU, and ELU activations, both of which have non-zero gradient almost everywhere.
Leaky ReLU is a piecewise linear function, just as for ReLU, so quick to compute. ELU has the advantage over softplus and ReLU that its mean output is closer to zero, which improves learning.
|
What are the benefits of using ReLU over softplus as activation functions?
ReLUs can indeed be permanently switched off, particularly under high learning rates. This is a motivation behind leaky ReLU, and ELU activations, both of which have non-zero gradient almost everywher
|
7,072
|
What are the benefits of using ReLU over softplus as activation functions?
|
The main reason ReLU works better than Softplus is that for ReLU we have the idea of sparsity in the model. This means that some of the neurons of the model output zero which does not have any effect for the next layers. this idea is something like Dropout. Neurons in hidden layers learn hidden concepts. If the input does not contain the corresponding concept, some neurons will output zero and they will not be engaged in the calculations of the next layers. This idea cannot be in Softplus, because the output cannot be zero like ReLU.
|
What are the benefits of using ReLU over softplus as activation functions?
|
The main reason ReLU works better than Softplus is that for ReLU we have the idea of sparsity in the model. This means that some of the neurons of the model output zero which does not have any effect
|
What are the benefits of using ReLU over softplus as activation functions?
The main reason ReLU works better than Softplus is that for ReLU we have the idea of sparsity in the model. This means that some of the neurons of the model output zero which does not have any effect for the next layers. this idea is something like Dropout. Neurons in hidden layers learn hidden concepts. If the input does not contain the corresponding concept, some neurons will output zero and they will not be engaged in the calculations of the next layers. This idea cannot be in Softplus, because the output cannot be zero like ReLU.
|
What are the benefits of using ReLU over softplus as activation functions?
The main reason ReLU works better than Softplus is that for ReLU we have the idea of sparsity in the model. This means that some of the neurons of the model output zero which does not have any effect
|
7,073
|
Reference: who introduced the tilde "~" notation to mean "has probability distribution..."?
|
Early uses
There are some earlier uses since 1961 by Ingram Olkin with others.
Olkin, Ingram, and Robert F. Tate. "Multivariate correlation models with mixed discrete and continuous variables." The Annals of Mathematical Statistics (1961): 448-465.
$X \sim F(x)$ means that $x$ is distributed according to the d.f. $F(x)$, and $x(n) \to F(x)$ means
that the asymptotic d.f. of $x(n)$ is $F(x)$.
Olkin, Ingram, and Herman Rubin. "A characterization of the Wishart distribution." The Annals of Mathematical Statistics (1962): 1272-1280.
We write $X \sim \mathcal{W}(\Lambda,p,n), (n > p-1, \Lambda: p \times p, \Lambda > 0 )$, to mean that $X$ is a $p \times p$ symmetric matrix with the density function $$p(X) = c \vert \Lambda \vert ^{n/2} \vert X \vert^{(n-p-1)/2} e^{-(\frac{1}{2}) \text{tr} \Lambda X} $$
digging further you come across the notation in the dissertation "Multivariate Tests of Hypotheses with Incomplete Data" by Raghunandan Prasad Bhargava (student of Olkin) in 1963
We use the notation $Y \sim p(z)$ to mean that the probability density of $Z$ is $p(z)$, and $Y \underset{H}{\sim} p(z)$ to denote that the probability density of $Z$ under the hypothesis $H$ is $p(z)$.
Srivastava is also an alumnus of Stanford university (and used the notation in a paper of 1965).
Before 1961
Before this time Olkin uses the more verbose descriptions of the form 'Let ... be independent and each distributed as ...'. So it seems like he either started it around 1961 or picked it up from others.
For Rubin there is neither earlier use of $\sim$ in this way. In one paper he seems to use it to indicate asymptotic equality. (analogous to Bachmann–Landau notations)
Rubin, Herman. "The estimation of discontinuities in multivariate densities, and related problems in stochastic processes." Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Contributions to the Theory of Statistics. University of California Press, 1961.
Other uses of the symbol $\sim$ are by Kolmogorov in
Колмогоров, Андрей Николаевич. "Об аналитических методах в теории вероятностей." Успехи математических наук 5 (1938): 5-41.
I do not know Russian but based on google translate I guess that equation 67 $$P^p_k \sim \frac{A^kp^k}{k!}e^{-Ap}$$ is supposed to mean is approximately distributed as
A similar use is in
Колмогоров, Андрей Николаевич. "Обобщение формулы Пуассона на случай выборки из конечной совокупности." Успехи математических наук 6.3 (43 (1951): 133-134.
In which we have an equation $$P_n(m \vert N,M) \sim P_n^\star(m\vert N , M)$$ and $P^\star$ is a simpler expression that is supposed to approximate to $P$ (in this case the hypergeometric distribution is being approximated)
Another use by Kolmogorov is in
Колмогоров, Андрей Николаевич. "Об операциях над множествами." Математический сборник 35.3-4 (1928): 415-422.
In which the following equation occurs $$\overline{\overline{X}} \sim X$$ Again, I do not know Russian and have to decipher it. To me it seems that it means that the operation denoted by $\overline{\overline{X}}$ will give the same result as the operation denoted by $X$. (this is not anymore about probability).
Paul Lévy uses the tilde symbol also as 'approximation' or 'asymptotic formula'. For instance in
Lévy, Paul. "Sur le développement en fraction continue d'un nombre choisi au hasard." Compositio mathematica 3 (1936): 286-303.
La probabilité de l’existence de $p$ valeurs supérieures à $n$ dans
la suite $y_1, y_2, ..., y_n$ est d’autre part $$C_{n}^p \left( \frac{1}{n}\right)^p\left( 1-\frac{1}{n}\right)^{n-p} \sim \frac{1}{ep!} \quad (n \to \infty)$$
But, here both sides of the binary relation are mathematical expressions. It is not a 'statistical variable' on the left side.
Lévy uses $\sim$ in stochastic expressions in
Lévy, Paul. "Wiener's random function, and other Laplacian random functions." Proceedings of the Second Berkeley Symposium on Mathematical Statistics and Probability. University of California Press, 1951.
Now it is an asymptotic relation for the case of infinitesimally small steps. For instance Lévy's fundamental stochastic infinitesimal equation (equation 2.1.1) is written as $$\delta X(t) \sim dt \int_{t_0}^t F(t,u) dX(u) + \zeta \sigma(t) \sqrt{dt}$$ and the symbol is explained as
The symbol $\sim$ means that, as $dt \to 0$, the two first moments of the difference of the two sides are $o(dt)$ or $o\left[d\omega(t) \right]$ [if $\sigma^2(t)dt$ is replaced by $d\omega(t)$].
(in Jeffreys "$∼$" denotes the logical not)
The tilde notation for negation dates at least back to use by Giuseppe Peano in 1987. See Jeff Miller's webpage: https://jeff560.tripod.com/set.html
|
Reference: who introduced the tilde "~" notation to mean "has probability distribution..."?
|
Early uses
There are some earlier uses since 1961 by Ingram Olkin with others.
Olkin, Ingram, and Robert F. Tate. "Multivariate correlation models with mixed discrete and continuous variables." The A
|
Reference: who introduced the tilde "~" notation to mean "has probability distribution..."?
Early uses
There are some earlier uses since 1961 by Ingram Olkin with others.
Olkin, Ingram, and Robert F. Tate. "Multivariate correlation models with mixed discrete and continuous variables." The Annals of Mathematical Statistics (1961): 448-465.
$X \sim F(x)$ means that $x$ is distributed according to the d.f. $F(x)$, and $x(n) \to F(x)$ means
that the asymptotic d.f. of $x(n)$ is $F(x)$.
Olkin, Ingram, and Herman Rubin. "A characterization of the Wishart distribution." The Annals of Mathematical Statistics (1962): 1272-1280.
We write $X \sim \mathcal{W}(\Lambda,p,n), (n > p-1, \Lambda: p \times p, \Lambda > 0 )$, to mean that $X$ is a $p \times p$ symmetric matrix with the density function $$p(X) = c \vert \Lambda \vert ^{n/2} \vert X \vert^{(n-p-1)/2} e^{-(\frac{1}{2}) \text{tr} \Lambda X} $$
digging further you come across the notation in the dissertation "Multivariate Tests of Hypotheses with Incomplete Data" by Raghunandan Prasad Bhargava (student of Olkin) in 1963
We use the notation $Y \sim p(z)$ to mean that the probability density of $Z$ is $p(z)$, and $Y \underset{H}{\sim} p(z)$ to denote that the probability density of $Z$ under the hypothesis $H$ is $p(z)$.
Srivastava is also an alumnus of Stanford university (and used the notation in a paper of 1965).
Before 1961
Before this time Olkin uses the more verbose descriptions of the form 'Let ... be independent and each distributed as ...'. So it seems like he either started it around 1961 or picked it up from others.
For Rubin there is neither earlier use of $\sim$ in this way. In one paper he seems to use it to indicate asymptotic equality. (analogous to Bachmann–Landau notations)
Rubin, Herman. "The estimation of discontinuities in multivariate densities, and related problems in stochastic processes." Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Contributions to the Theory of Statistics. University of California Press, 1961.
Other uses of the symbol $\sim$ are by Kolmogorov in
Колмогоров, Андрей Николаевич. "Об аналитических методах в теории вероятностей." Успехи математических наук 5 (1938): 5-41.
I do not know Russian but based on google translate I guess that equation 67 $$P^p_k \sim \frac{A^kp^k}{k!}e^{-Ap}$$ is supposed to mean is approximately distributed as
A similar use is in
Колмогоров, Андрей Николаевич. "Обобщение формулы Пуассона на случай выборки из конечной совокупности." Успехи математических наук 6.3 (43 (1951): 133-134.
In which we have an equation $$P_n(m \vert N,M) \sim P_n^\star(m\vert N , M)$$ and $P^\star$ is a simpler expression that is supposed to approximate to $P$ (in this case the hypergeometric distribution is being approximated)
Another use by Kolmogorov is in
Колмогоров, Андрей Николаевич. "Об операциях над множествами." Математический сборник 35.3-4 (1928): 415-422.
In which the following equation occurs $$\overline{\overline{X}} \sim X$$ Again, I do not know Russian and have to decipher it. To me it seems that it means that the operation denoted by $\overline{\overline{X}}$ will give the same result as the operation denoted by $X$. (this is not anymore about probability).
Paul Lévy uses the tilde symbol also as 'approximation' or 'asymptotic formula'. For instance in
Lévy, Paul. "Sur le développement en fraction continue d'un nombre choisi au hasard." Compositio mathematica 3 (1936): 286-303.
La probabilité de l’existence de $p$ valeurs supérieures à $n$ dans
la suite $y_1, y_2, ..., y_n$ est d’autre part $$C_{n}^p \left( \frac{1}{n}\right)^p\left( 1-\frac{1}{n}\right)^{n-p} \sim \frac{1}{ep!} \quad (n \to \infty)$$
But, here both sides of the binary relation are mathematical expressions. It is not a 'statistical variable' on the left side.
Lévy uses $\sim$ in stochastic expressions in
Lévy, Paul. "Wiener's random function, and other Laplacian random functions." Proceedings of the Second Berkeley Symposium on Mathematical Statistics and Probability. University of California Press, 1951.
Now it is an asymptotic relation for the case of infinitesimally small steps. For instance Lévy's fundamental stochastic infinitesimal equation (equation 2.1.1) is written as $$\delta X(t) \sim dt \int_{t_0}^t F(t,u) dX(u) + \zeta \sigma(t) \sqrt{dt}$$ and the symbol is explained as
The symbol $\sim$ means that, as $dt \to 0$, the two first moments of the difference of the two sides are $o(dt)$ or $o\left[d\omega(t) \right]$ [if $\sigma^2(t)dt$ is replaced by $d\omega(t)$].
(in Jeffreys "$∼$" denotes the logical not)
The tilde notation for negation dates at least back to use by Giuseppe Peano in 1987. See Jeff Miller's webpage: https://jeff560.tripod.com/set.html
|
Reference: who introduced the tilde "~" notation to mean "has probability distribution..."?
Early uses
There are some earlier uses since 1961 by Ingram Olkin with others.
Olkin, Ingram, and Robert F. Tate. "Multivariate correlation models with mixed discrete and continuous variables." The A
|
7,074
|
How would PCA help with a k-means clustering analysis?
|
PCA is not a clustering method. But sometimes it helps to reveal clusters.
Let's assume you have 10-dimensional Normal distributions with mean $0_{10}$ (vector of zeros) and some covariance matrix with 3 directions having bigger variance than others. Applying principal component analysis with 3 components will give you these directions in decreasing order and 'elbow' approach will say to you that this amount of chosen components is right. However, it will be still a cloud of points (1 cluster).
Let's assume you have 10 10-dimensional Normal distributions with means $1_{10}$, $2_{10}$, ... $10_{10}$ (means are staying almost on the line) and similar covariance matrices. Applying PCA with only 1 component (after standardization) will give you the direction where you will observe all 10 clusters. Analyzing explained variance ('elbow' approach), you will see that 1 component is enough to describe this data.
In the link you show PCA is used only to build some hypotheses regarding the data. The amount of clusters is determined by 'elbow' approach according to the value of within groups sum of squares (not by explained variance). Basically, you repeat K-means algorithm for different amount of clusters and calculate this sum of squares. If the number of clusters equal to the number of data points, then sum of squares equal $0$.
|
How would PCA help with a k-means clustering analysis?
|
PCA is not a clustering method. But sometimes it helps to reveal clusters.
Let's assume you have 10-dimensional Normal distributions with mean $0_{10}$ (vector of zeros) and some covariance matrix wit
|
How would PCA help with a k-means clustering analysis?
PCA is not a clustering method. But sometimes it helps to reveal clusters.
Let's assume you have 10-dimensional Normal distributions with mean $0_{10}$ (vector of zeros) and some covariance matrix with 3 directions having bigger variance than others. Applying principal component analysis with 3 components will give you these directions in decreasing order and 'elbow' approach will say to you that this amount of chosen components is right. However, it will be still a cloud of points (1 cluster).
Let's assume you have 10 10-dimensional Normal distributions with means $1_{10}$, $2_{10}$, ... $10_{10}$ (means are staying almost on the line) and similar covariance matrices. Applying PCA with only 1 component (after standardization) will give you the direction where you will observe all 10 clusters. Analyzing explained variance ('elbow' approach), you will see that 1 component is enough to describe this data.
In the link you show PCA is used only to build some hypotheses regarding the data. The amount of clusters is determined by 'elbow' approach according to the value of within groups sum of squares (not by explained variance). Basically, you repeat K-means algorithm for different amount of clusters and calculate this sum of squares. If the number of clusters equal to the number of data points, then sum of squares equal $0$.
|
How would PCA help with a k-means clustering analysis?
PCA is not a clustering method. But sometimes it helps to reveal clusters.
Let's assume you have 10-dimensional Normal distributions with mean $0_{10}$ (vector of zeros) and some covariance matrix wit
|
7,075
|
How would PCA help with a k-means clustering analysis?
|
to my opinion:
PCA extracts main non-correlated features (x) that explains most of the variety in y=f(x).
Cluster analysis mostly extracts groups of samples & their labels (or y results in y=f(x) )
|
How would PCA help with a k-means clustering analysis?
|
to my opinion:
PCA extracts main non-correlated features (x) that explains most of the variety in y=f(x).
Cluster analysis mostly extracts groups of samples & their labels (or y results in y=f(x) )
|
How would PCA help with a k-means clustering analysis?
to my opinion:
PCA extracts main non-correlated features (x) that explains most of the variety in y=f(x).
Cluster analysis mostly extracts groups of samples & their labels (or y results in y=f(x) )
|
How would PCA help with a k-means clustering analysis?
to my opinion:
PCA extracts main non-correlated features (x) that explains most of the variety in y=f(x).
Cluster analysis mostly extracts groups of samples & their labels (or y results in y=f(x) )
|
7,076
|
Why does glmer not achieve the maximum likelihood (as verified by applying further generic optimization)?
|
Setting a high value of nAGQ in the glmer call made the MLEs from the two methods equivalent. The default precision of glmer was not very good. This settles the issue.
glmer(cbind(y,N-y)~1+(1|id),family=binomial,nAGQ=20)
See @SteveWalker's answer here Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorithm? for more details.
|
Why does glmer not achieve the maximum likelihood (as verified by applying further generic optimizat
|
Setting a high value of nAGQ in the glmer call made the MLEs from the two methods equivalent. The default precision of glmer was not very good. This settles the issue.
glmer(cbind(y,N-y)~1+(1|id),fami
|
Why does glmer not achieve the maximum likelihood (as verified by applying further generic optimization)?
Setting a high value of nAGQ in the glmer call made the MLEs from the two methods equivalent. The default precision of glmer was not very good. This settles the issue.
glmer(cbind(y,N-y)~1+(1|id),family=binomial,nAGQ=20)
See @SteveWalker's answer here Why can't I match glmer (family=binomial) output with manual implementation of Gauss-Newton algorithm? for more details.
|
Why does glmer not achieve the maximum likelihood (as verified by applying further generic optimizat
Setting a high value of nAGQ in the glmer call made the MLEs from the two methods equivalent. The default precision of glmer was not very good. This settles the issue.
glmer(cbind(y,N-y)~1+(1|id),fami
|
7,077
|
What is your favorite layman's explanation for a difficult statistical concept?
|
A p value is a measure of how embarrassing the data are to the null hypothesis
Nicholas Maxwell, Data Matters: Conceptual Statistics for a Random World Emeryville CA: Key College Publishing, 2004.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
A p value is a measure of how embarrassing the data are to the null hypothesis
Nicholas Maxwell, Data Matters: Conceptual Statistics for a Random World Emeryville CA: Key College Publishing, 2004.
|
What is your favorite layman's explanation for a difficult statistical concept?
A p value is a measure of how embarrassing the data are to the null hypothesis
Nicholas Maxwell, Data Matters: Conceptual Statistics for a Random World Emeryville CA: Key College Publishing, 2004.
|
What is your favorite layman's explanation for a difficult statistical concept?
A p value is a measure of how embarrassing the data are to the null hypothesis
Nicholas Maxwell, Data Matters: Conceptual Statistics for a Random World Emeryville CA: Key College Publishing, 2004.
|
7,078
|
What is your favorite layman's explanation for a difficult statistical concept?
|
If you carved your distribution (histogram) out
of wood, and tried to balance it on
your finger, the balance point would
be the mean, no matter the shape of the distribution.
If you put a stick in the middle of
your scatter plot, and attached the
stick to each data point with a
spring, the resting point of the
stick would be your regression line. [1]
[1] this would technically be principal components regression. you would have to force the springs to move only "vertically" to be least squares, but the example is illustrative either way.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
If you carved your distribution (histogram) out
of wood, and tried to balance it on
your finger, the balance point would
be the mean, no matter the shape of the distribution.
If you put a stick in the
|
What is your favorite layman's explanation for a difficult statistical concept?
If you carved your distribution (histogram) out
of wood, and tried to balance it on
your finger, the balance point would
be the mean, no matter the shape of the distribution.
If you put a stick in the middle of
your scatter plot, and attached the
stick to each data point with a
spring, the resting point of the
stick would be your regression line. [1]
[1] this would technically be principal components regression. you would have to force the springs to move only "vertically" to be least squares, but the example is illustrative either way.
|
What is your favorite layman's explanation for a difficult statistical concept?
If you carved your distribution (histogram) out
of wood, and tried to balance it on
your finger, the balance point would
be the mean, no matter the shape of the distribution.
If you put a stick in the
|
7,079
|
What is your favorite layman's explanation for a difficult statistical concept?
|
I like to demonstrate sampling variation and essentially the Central Limit Theorem through an "in-class" exercise. Everybody in the class of say 100 students writes their age on a piece of paper. All pieces of paper are the same size and folded in the same fashion after I've calculated the average. This is the population and I calculate the average age. Then each student randomly selects 10 pieces of paper, writes down the ages and returns them to the bag. (S)he calculates the mean and passes the bag along to the next student. Eventually we have 100 samples of 10 students each estimating the population mean which we can describe through a histogram and some descriptive statistics.
We then repeat the demonstration this time using a set of 100 "opinions" that replicate some Yes/No question from recent polls e.g. If the (British General) election were called tomorrow would you consider voting for the British National Party. Students them sample 10 of these opinions.
At the end we've demonstrated sampling variation, the Central Limit Theorem, etc with both continuous and binary data.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
I like to demonstrate sampling variation and essentially the Central Limit Theorem through an "in-class" exercise. Everybody in the class of say 100 students writes their age on a piece of paper. All
|
What is your favorite layman's explanation for a difficult statistical concept?
I like to demonstrate sampling variation and essentially the Central Limit Theorem through an "in-class" exercise. Everybody in the class of say 100 students writes their age on a piece of paper. All pieces of paper are the same size and folded in the same fashion after I've calculated the average. This is the population and I calculate the average age. Then each student randomly selects 10 pieces of paper, writes down the ages and returns them to the bag. (S)he calculates the mean and passes the bag along to the next student. Eventually we have 100 samples of 10 students each estimating the population mean which we can describe through a histogram and some descriptive statistics.
We then repeat the demonstration this time using a set of 100 "opinions" that replicate some Yes/No question from recent polls e.g. If the (British General) election were called tomorrow would you consider voting for the British National Party. Students them sample 10 of these opinions.
At the end we've demonstrated sampling variation, the Central Limit Theorem, etc with both continuous and binary data.
|
What is your favorite layman's explanation for a difficult statistical concept?
I like to demonstrate sampling variation and essentially the Central Limit Theorem through an "in-class" exercise. Everybody in the class of say 100 students writes their age on a piece of paper. All
|
7,080
|
What is your favorite layman's explanation for a difficult statistical concept?
|
I have used the drunkard's walk before for random walk, and the drunk and her dog for cointegration; they're very helpful (partially because they're amusing).
One of my favorite common examples is the Birthday Paradox (wikipedia entry), which illustrates some important concepts of probability. You can simulate this with a room full of people.
Incidentally, I strongly recommend Andrew Gelman's "Teaching Statistics: A Bag of Tricks" for some examples of creative ways to teach statistical concepts (see the table of contents). Also look at his paper about the course that he teaches on teaching statistics: "A Course on Teaching Statistics at the University Level". And on "Teaching Bayes to Graduate Students in Political Science, Sociology,
Public Health, Education, Economics, ...".
For describing Bayesian methods, using an unfair coin and flipping it multiple times is a pretty common/effective approach.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
I have used the drunkard's walk before for random walk, and the drunk and her dog for cointegration; they're very helpful (partially because they're amusing).
One of my favorite common examples is the
|
What is your favorite layman's explanation for a difficult statistical concept?
I have used the drunkard's walk before for random walk, and the drunk and her dog for cointegration; they're very helpful (partially because they're amusing).
One of my favorite common examples is the Birthday Paradox (wikipedia entry), which illustrates some important concepts of probability. You can simulate this with a room full of people.
Incidentally, I strongly recommend Andrew Gelman's "Teaching Statistics: A Bag of Tricks" for some examples of creative ways to teach statistical concepts (see the table of contents). Also look at his paper about the course that he teaches on teaching statistics: "A Course on Teaching Statistics at the University Level". And on "Teaching Bayes to Graduate Students in Political Science, Sociology,
Public Health, Education, Economics, ...".
For describing Bayesian methods, using an unfair coin and flipping it multiple times is a pretty common/effective approach.
|
What is your favorite layman's explanation for a difficult statistical concept?
I have used the drunkard's walk before for random walk, and the drunk and her dog for cointegration; they're very helpful (partially because they're amusing).
One of my favorite common examples is the
|
7,081
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Definitely the Monty Hall Problem. http://en.wikipedia.org/wiki/Monty_Hall_problem
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Definitely the Monty Hall Problem. http://en.wikipedia.org/wiki/Monty_Hall_problem
|
What is your favorite layman's explanation for a difficult statistical concept?
Definitely the Monty Hall Problem. http://en.wikipedia.org/wiki/Monty_Hall_problem
|
What is your favorite layman's explanation for a difficult statistical concept?
Definitely the Monty Hall Problem. http://en.wikipedia.org/wiki/Monty_Hall_problem
|
7,082
|
What is your favorite layman's explanation for a difficult statistical concept?
|
1) A good demonstration of how "random" needs to be defined in order to work out probability of certain events:
What is the chance that a random line drawn across a circle will be longer than the radius?
The question totally depends how you draw your line. Possibilities which you can describe in a real-world way for a circle drawn on the ground might include:
Draw two random points inside the circle and draw a line through those. (See where two flies / stones fall...)
Choose a fixed point on the circumference, then a random one elsewhere in the circle and join those. (In effect this is laying a stick across the circle at a variable angle through a given point and a random one e.g. where a stone falls.)
Draw a diameter. Randomly choose a point along it and draw a perpendicular through that. (Roll a stick along in a straight line so it rests across the circle.)
It is relatively easy to show someone who can do some geometry (but not necessarily stats) the answer to the question can vary quite widely (from about 2/3 to about 0.866 or so).
2) A reverse-engineered coin-toss: toss it (say) ten times and write down the result. Work out the probability of this exact sequence $\left(\frac{1}{2^{10}}\right)$. A tiny chance, but you just saw it happen with your own eyes!... Every sequence might come up, including ten heads in a row, but it is hard for lay people to get their head round it. As an encore, try to convince them they have just as good a chance of winning the lottery with the numbers 1 through 6 as any other combination.
3) Explaining why medical diagnosis may seem really flawed. A test for disease foo which is 99.9% accurate at identifying those who have it but .1% false-positively diagnoses those who don't really have it may seem to be wrong really so often when the prevalence of the disease is really low (e.g. 1 in 1000) but many patients are tested for it.
This is one that is best explained with real numbers - imagine 1 million people are tested, so 1000 have the disease, 999 are correctly identified, but 0.1% of 999,000 is 999 who are told they have it but don't. So half those who are told they have it actually do not, despite the high level of accuracy (99.9%) and low level of false positives (0.1%). A second (ideally different) test will then separate these groups out.
[Incidentally, I chose the numbers because they are easy to work with, of course they do not have to add up to 100% as the accuracy / false positive rates are independent factors in the test.]
|
What is your favorite layman's explanation for a difficult statistical concept?
|
1) A good demonstration of how "random" needs to be defined in order to work out probability of certain events:
What is the chance that a random line drawn across a circle will be longer than the radi
|
What is your favorite layman's explanation for a difficult statistical concept?
1) A good demonstration of how "random" needs to be defined in order to work out probability of certain events:
What is the chance that a random line drawn across a circle will be longer than the radius?
The question totally depends how you draw your line. Possibilities which you can describe in a real-world way for a circle drawn on the ground might include:
Draw two random points inside the circle and draw a line through those. (See where two flies / stones fall...)
Choose a fixed point on the circumference, then a random one elsewhere in the circle and join those. (In effect this is laying a stick across the circle at a variable angle through a given point and a random one e.g. where a stone falls.)
Draw a diameter. Randomly choose a point along it and draw a perpendicular through that. (Roll a stick along in a straight line so it rests across the circle.)
It is relatively easy to show someone who can do some geometry (but not necessarily stats) the answer to the question can vary quite widely (from about 2/3 to about 0.866 or so).
2) A reverse-engineered coin-toss: toss it (say) ten times and write down the result. Work out the probability of this exact sequence $\left(\frac{1}{2^{10}}\right)$. A tiny chance, but you just saw it happen with your own eyes!... Every sequence might come up, including ten heads in a row, but it is hard for lay people to get their head round it. As an encore, try to convince them they have just as good a chance of winning the lottery with the numbers 1 through 6 as any other combination.
3) Explaining why medical diagnosis may seem really flawed. A test for disease foo which is 99.9% accurate at identifying those who have it but .1% false-positively diagnoses those who don't really have it may seem to be wrong really so often when the prevalence of the disease is really low (e.g. 1 in 1000) but many patients are tested for it.
This is one that is best explained with real numbers - imagine 1 million people are tested, so 1000 have the disease, 999 are correctly identified, but 0.1% of 999,000 is 999 who are told they have it but don't. So half those who are told they have it actually do not, despite the high level of accuracy (99.9%) and low level of false positives (0.1%). A second (ideally different) test will then separate these groups out.
[Incidentally, I chose the numbers because they are easy to work with, of course they do not have to add up to 100% as the accuracy / false positive rates are independent factors in the test.]
|
What is your favorite layman's explanation for a difficult statistical concept?
1) A good demonstration of how "random" needs to be defined in order to work out probability of certain events:
What is the chance that a random line drawn across a circle will be longer than the radi
|
7,083
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Sam Savage's book Flaw of Averages is filled with good layman explanations of statistical concepts. In particular, he has a good explanation of Jensen's inequality. If the graph of your return on an investment is convex, i.e. it "smiles at you", then randomness is in your favor: your average return is greater than your return at the average.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Sam Savage's book Flaw of Averages is filled with good layman explanations of statistical concepts. In particular, he has a good explanation of Jensen's inequality. If the graph of your return on an
|
What is your favorite layman's explanation for a difficult statistical concept?
Sam Savage's book Flaw of Averages is filled with good layman explanations of statistical concepts. In particular, he has a good explanation of Jensen's inequality. If the graph of your return on an investment is convex, i.e. it "smiles at you", then randomness is in your favor: your average return is greater than your return at the average.
|
What is your favorite layman's explanation for a difficult statistical concept?
Sam Savage's book Flaw of Averages is filled with good layman explanations of statistical concepts. In particular, he has a good explanation of Jensen's inequality. If the graph of your return on an
|
7,084
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Along the lines of the mean as balance point, I like this view of the median as a balance point:
A Pearl: a Balanced Median Necklace
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Along the lines of the mean as balance point, I like this view of the median as a balance point:
A Pearl: a Balanced Median Necklace
|
What is your favorite layman's explanation for a difficult statistical concept?
Along the lines of the mean as balance point, I like this view of the median as a balance point:
A Pearl: a Balanced Median Necklace
|
What is your favorite layman's explanation for a difficult statistical concept?
Along the lines of the mean as balance point, I like this view of the median as a balance point:
A Pearl: a Balanced Median Necklace
|
7,085
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Behar et al have a collection of 25 analogies for teaching statistics.
Here are two examples:
2.9 All Models are Theoretical:
There Are No Perfect Spheres in the Universe It appears that the most common geometric form in the
universe is the sphere. But how many mathematically perfect spheres
are there in the universe? The answer is none. Neither the Earth, nor
the Sun, nor a billiard ball is a perfect sphere. So, if there are no
true spheres, what good are the formulas for ascertaining the area or
volume of a sphere? So it is with statistical models in general and,
in particular, with a normal distribution. Although one of the most
commonplace examples is height distribution, if we were to have at our
disposal the height of every adult on the planet, the histogram profile
would not correspond to a Gaussian bell curve, not even if the data
were stratified by gender, race, or any other characteristic. But the
normal distribution model still provides approximate results that are
good enough for practical purposes.
2.25 Residuals Should Not Contain Information: A Trash Bag Residuals are what remain after removing all the information from the data.
Since they should carry no information, we consider them as “trash.”
It is necessary to make sure that we do not throw out any trash that
has value (information) and that can be exploited to better explain
the behavior of the dependent variable.
Other examples include
"Effect of Sample Size on the Comparison of Treatments: Magnification of Binoculars"
"The Sample Size Versus the Size of the Population: A Spoon for Tasting the Soup"
References
Behar, R., Grima, P., & Marco-Almagro, L. (2012). Twenty Five Analogies for Explaining Statistical Concepts. The American Statistician, (just-accepted).
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Behar et al have a collection of 25 analogies for teaching statistics.
Here are two examples:
2.9 All Models are Theoretical:
There Are No Perfect Spheres in the Universe It appears that the most c
|
What is your favorite layman's explanation for a difficult statistical concept?
Behar et al have a collection of 25 analogies for teaching statistics.
Here are two examples:
2.9 All Models are Theoretical:
There Are No Perfect Spheres in the Universe It appears that the most common geometric form in the
universe is the sphere. But how many mathematically perfect spheres
are there in the universe? The answer is none. Neither the Earth, nor
the Sun, nor a billiard ball is a perfect sphere. So, if there are no
true spheres, what good are the formulas for ascertaining the area or
volume of a sphere? So it is with statistical models in general and,
in particular, with a normal distribution. Although one of the most
commonplace examples is height distribution, if we were to have at our
disposal the height of every adult on the planet, the histogram profile
would not correspond to a Gaussian bell curve, not even if the data
were stratified by gender, race, or any other characteristic. But the
normal distribution model still provides approximate results that are
good enough for practical purposes.
2.25 Residuals Should Not Contain Information: A Trash Bag Residuals are what remain after removing all the information from the data.
Since they should carry no information, we consider them as “trash.”
It is necessary to make sure that we do not throw out any trash that
has value (information) and that can be exploited to better explain
the behavior of the dependent variable.
Other examples include
"Effect of Sample Size on the Comparison of Treatments: Magnification of Binoculars"
"The Sample Size Versus the Size of the Population: A Spoon for Tasting the Soup"
References
Behar, R., Grima, P., & Marco-Almagro, L. (2012). Twenty Five Analogies for Explaining Statistical Concepts. The American Statistician, (just-accepted).
|
What is your favorite layman's explanation for a difficult statistical concept?
Behar et al have a collection of 25 analogies for teaching statistics.
Here are two examples:
2.9 All Models are Theoretical:
There Are No Perfect Spheres in the Universe It appears that the most c
|
7,086
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Fun question.
Someone found out I work in biostatistics, and they asked me (basically) "Isn't statistics just a way of lying?"
(Which brings back the Mark Twain quote about Lies, Damn Lies, and Statistics.)
I tried to explain that statistics allows us to say with 100 percent precision that, given assumptions, and given data, that the probability of such-and-so was exactly such-and-such.
She wasn't impressed.
|
What is your favorite layman's explanation for a difficult statistical concept?
|
Fun question.
Someone found out I work in biostatistics, and they asked me (basically) "Isn't statistics just a way of lying?"
(Which brings back the Mark Twain quote about Lies, Damn Lies, and Statis
|
What is your favorite layman's explanation for a difficult statistical concept?
Fun question.
Someone found out I work in biostatistics, and they asked me (basically) "Isn't statistics just a way of lying?"
(Which brings back the Mark Twain quote about Lies, Damn Lies, and Statistics.)
I tried to explain that statistics allows us to say with 100 percent precision that, given assumptions, and given data, that the probability of such-and-so was exactly such-and-such.
She wasn't impressed.
|
What is your favorite layman's explanation for a difficult statistical concept?
Fun question.
Someone found out I work in biostatistics, and they asked me (basically) "Isn't statistics just a way of lying?"
(Which brings back the Mark Twain quote about Lies, Damn Lies, and Statis
|
7,087
|
Why are log probabilities useful?
|
The log of $1$ is just $0$ and the limit as $x$ approaches $0$ (from the positive side) of $\log x$ is $-\infty$. So the range of values for log probabilities is $(-\infty, 0]$.
The real advantage is in the arithmetic. Log probabilities are not as easy to understand as probabilities (for most people), but every time you multiply together two probabilities (other than $1 \times 1 = 1$), you will end up with a value closer to $0$. Dealing with numbers very close to $0$ can become unstable with finite precision approximations, so working with logs makes things much more stable and in some cases quicker and easier. Why do you need any more justification than that?
|
Why are log probabilities useful?
|
The log of $1$ is just $0$ and the limit as $x$ approaches $0$ (from the positive side) of $\log x$ is $-\infty$. So the range of values for log probabilities is $(-\infty, 0]$.
The real advantage is
|
Why are log probabilities useful?
The log of $1$ is just $0$ and the limit as $x$ approaches $0$ (from the positive side) of $\log x$ is $-\infty$. So the range of values for log probabilities is $(-\infty, 0]$.
The real advantage is in the arithmetic. Log probabilities are not as easy to understand as probabilities (for most people), but every time you multiply together two probabilities (other than $1 \times 1 = 1$), you will end up with a value closer to $0$. Dealing with numbers very close to $0$ can become unstable with finite precision approximations, so working with logs makes things much more stable and in some cases quicker and easier. Why do you need any more justification than that?
|
Why are log probabilities useful?
The log of $1$ is just $0$ and the limit as $x$ approaches $0$ (from the positive side) of $\log x$ is $-\infty$. So the range of values for log probabilities is $(-\infty, 0]$.
The real advantage is
|
7,088
|
Why are log probabilities useful?
|
I would like to add that taking the log of a probability or probability density can often simplify certain computations, such as calculating the gradient of the density given some of its parameters. This is in particular when the density belongs to the exponential family, which often contain fewer special function calls after being logged than before. This makes taking the derivative by hand simpler (as product rules become simpler sum rules), and also can lead to more stable numerical derivative calculations such as finite differencing.
As an illustration, let's take the Poisson with probability function $e^{-\lambda}\frac{\lambda^{x}}{x!}$. Even though $x$ is discrete, this function is smooth with respect to $\lambda$, and becomes $\log f_x= -\lambda + x*\log(\lambda) - \log(x!)$, for a derivative with respect to $\lambda$ of simply $\frac{\partial \log f_x}{\partial \lambda} = -1 + \frac{x}{\lambda}$, which involves two simple operations. Contrast that with $\frac{\partial f_x}{\partial \lambda} = \frac{e^{-\lambda } (x-\lambda
) \lambda ^{x-1}}{x!}$, which involves natural exponentiation, real exponentiation, computation of a factorial, and, worst of all, division by a factorial. This both involves more computation time and less computation stability, even in this simple example. The result is compounded for more complex probability functions, as well as when observing an i.i.d sample of random variables, since these are added in log space while multiplied in probability space (again, complicating derivative calculation, as well as introducing more of the floating point error mentioned in the other answer).
These gradient expressions are used in both analytic and numerical computation of Maximum a Posteriori ($\ell_0$ Bayes) and Maximum Likelihood Estimators. It's also used in the numerical solution of Method of Moments estimating equations, often via Newton's method, which involves Hessian computations, or second derivatives. Here the difference between logged and unlogged complexity can be huge. And finally, it is used to show the equivalence between least squares and maximum likelihood with a Gaussian error structure.
|
Why are log probabilities useful?
|
I would like to add that taking the log of a probability or probability density can often simplify certain computations, such as calculating the gradient of the density given some of its parameters. T
|
Why are log probabilities useful?
I would like to add that taking the log of a probability or probability density can often simplify certain computations, such as calculating the gradient of the density given some of its parameters. This is in particular when the density belongs to the exponential family, which often contain fewer special function calls after being logged than before. This makes taking the derivative by hand simpler (as product rules become simpler sum rules), and also can lead to more stable numerical derivative calculations such as finite differencing.
As an illustration, let's take the Poisson with probability function $e^{-\lambda}\frac{\lambda^{x}}{x!}$. Even though $x$ is discrete, this function is smooth with respect to $\lambda$, and becomes $\log f_x= -\lambda + x*\log(\lambda) - \log(x!)$, for a derivative with respect to $\lambda$ of simply $\frac{\partial \log f_x}{\partial \lambda} = -1 + \frac{x}{\lambda}$, which involves two simple operations. Contrast that with $\frac{\partial f_x}{\partial \lambda} = \frac{e^{-\lambda } (x-\lambda
) \lambda ^{x-1}}{x!}$, which involves natural exponentiation, real exponentiation, computation of a factorial, and, worst of all, division by a factorial. This both involves more computation time and less computation stability, even in this simple example. The result is compounded for more complex probability functions, as well as when observing an i.i.d sample of random variables, since these are added in log space while multiplied in probability space (again, complicating derivative calculation, as well as introducing more of the floating point error mentioned in the other answer).
These gradient expressions are used in both analytic and numerical computation of Maximum a Posteriori ($\ell_0$ Bayes) and Maximum Likelihood Estimators. It's also used in the numerical solution of Method of Moments estimating equations, often via Newton's method, which involves Hessian computations, or second derivatives. Here the difference between logged and unlogged complexity can be huge. And finally, it is used to show the equivalence between least squares and maximum likelihood with a Gaussian error structure.
|
Why are log probabilities useful?
I would like to add that taking the log of a probability or probability density can often simplify certain computations, such as calculating the gradient of the density given some of its parameters. T
|
7,089
|
Why are log probabilities useful?
|
As an example of the process mentioned in Greg Snow's answer: I quite often use high-level programming languages (Octave, Maxima[*], Gnuplot, Perl,...) to compute ratios between marginal likelihoods for Bayesian model comparison. If one tries to compute the ratio of marginal likelihoods directly, intermediate steps in the calculation (and sometimes the final result too) very frequently go beyond the capabilities of the floating-point number implementation in the interpreter/compiler, producing numbers so small that the computer can't tell them apart from zero, when all the important information is in the fact that those numbers are actually not quite zero. If, on the other hand, one works in log probabilities throughout, and takes the difference between the logarithms of the marginal likelihoods at the end, this problem is much less likely to occur.
[*] Sometimes, Maxima evades the problem by using rational-number arithmetic instead of floating-point arithmetic, but one can't necessarily rely on this.
|
Why are log probabilities useful?
|
As an example of the process mentioned in Greg Snow's answer: I quite often use high-level programming languages (Octave, Maxima[*], Gnuplot, Perl,...) to compute ratios between marginal likelihoods f
|
Why are log probabilities useful?
As an example of the process mentioned in Greg Snow's answer: I quite often use high-level programming languages (Octave, Maxima[*], Gnuplot, Perl,...) to compute ratios between marginal likelihoods for Bayesian model comparison. If one tries to compute the ratio of marginal likelihoods directly, intermediate steps in the calculation (and sometimes the final result too) very frequently go beyond the capabilities of the floating-point number implementation in the interpreter/compiler, producing numbers so small that the computer can't tell them apart from zero, when all the important information is in the fact that those numbers are actually not quite zero. If, on the other hand, one works in log probabilities throughout, and takes the difference between the logarithms of the marginal likelihoods at the end, this problem is much less likely to occur.
[*] Sometimes, Maxima evades the problem by using rational-number arithmetic instead of floating-point arithmetic, but one can't necessarily rely on this.
|
Why are log probabilities useful?
As an example of the process mentioned in Greg Snow's answer: I quite often use high-level programming languages (Octave, Maxima[*], Gnuplot, Perl,...) to compute ratios between marginal likelihoods f
|
7,090
|
Why are log probabilities useful?
|
This might not be what you are interested in, but log probabilities in statistical physics are closely related to the concepts of energy and entropy. For a physical system in equilibrium at temperature $T$ (in kelvin), the difference in energy between two microstates A and B is related to the logarithm of the probabilities that the system is in state A or state B:
$$E_\mathrm{A} - E_\mathrm{B} =-k_\mathrm{B}T \left[ \ln(P_\mathrm{A}) - \ln( P_\mathrm{B}) \right]$$
So, statistical physicists often work with log probabilities (or scaled versions of them), because they are physically meaningful. For example, the potential energy of a gas molecule in an atmosphere at a fixed temperature under a uniform gravitation field (a good approximation near the surface of the Earth) is $mgh$, where $m$ is the mass of the gas molecule, $g$ is the acceleration of gravity, and $h$ is the height of the molecule above the surface. The probability of finding a gas molecule in the top floor of the building versus in the bottom floor (assuming the floors have the same volume and the floor-to-ceiling height is small) is given by:
$$mg (h_\mathrm{top} - h_\mathrm{bottom}) \approx -k_\mathrm{B} T \left[ \ln (P_\mathrm{top}) - \ln(P_\mathrm{bottom}) \right]$$
This probability is trivially related to the concentration of the gas on the two floors. Higher floors have a lower concentration and the concentration of heavier molecules decays more quickly with height.
In statistical physics, it is often useful to switch back and forth between quantities proportional to log probabilities (energy, entropy, enthalpy, free energy) and quantities proportional to probability (number of microstates, partition function, density of states).
|
Why are log probabilities useful?
|
This might not be what you are interested in, but log probabilities in statistical physics are closely related to the concepts of energy and entropy. For a physical system in equilibrium at temperatur
|
Why are log probabilities useful?
This might not be what you are interested in, but log probabilities in statistical physics are closely related to the concepts of energy and entropy. For a physical system in equilibrium at temperature $T$ (in kelvin), the difference in energy between two microstates A and B is related to the logarithm of the probabilities that the system is in state A or state B:
$$E_\mathrm{A} - E_\mathrm{B} =-k_\mathrm{B}T \left[ \ln(P_\mathrm{A}) - \ln( P_\mathrm{B}) \right]$$
So, statistical physicists often work with log probabilities (or scaled versions of them), because they are physically meaningful. For example, the potential energy of a gas molecule in an atmosphere at a fixed temperature under a uniform gravitation field (a good approximation near the surface of the Earth) is $mgh$, where $m$ is the mass of the gas molecule, $g$ is the acceleration of gravity, and $h$ is the height of the molecule above the surface. The probability of finding a gas molecule in the top floor of the building versus in the bottom floor (assuming the floors have the same volume and the floor-to-ceiling height is small) is given by:
$$mg (h_\mathrm{top} - h_\mathrm{bottom}) \approx -k_\mathrm{B} T \left[ \ln (P_\mathrm{top}) - \ln(P_\mathrm{bottom}) \right]$$
This probability is trivially related to the concentration of the gas on the two floors. Higher floors have a lower concentration and the concentration of heavier molecules decays more quickly with height.
In statistical physics, it is often useful to switch back and forth between quantities proportional to log probabilities (energy, entropy, enthalpy, free energy) and quantities proportional to probability (number of microstates, partition function, density of states).
|
Why are log probabilities useful?
This might not be what you are interested in, but log probabilities in statistical physics are closely related to the concepts of energy and entropy. For a physical system in equilibrium at temperatur
|
7,091
|
Why does logistic regression become unstable when classes are well-separated?
|
It isn't correct that logistic regression in itself becomes unstable when there are separation. Separation means that there are some variables which are very good predictors, which is good, or, separation may be an artifact of too few observations/too many variables. If that is the case, the solution might be to get more data. But separation itself, then, is only a symptom, and not a problem in itself.
So there are really different cases to be treated. First, what is the goal of the analysis? If the final result of the analysis is some classification of cases, separation is no problem at all, it really means that there are very good variables giving very good classification. But if the goal is risk estimation, we need the parameter estimates, and with separation the usual mle (maximum likelihood) estimates do not exist. So we must change estimation method, maybe. There are several proposals in the literature, I will come back to that.
Then there are (as said above) two different possible causes for separation. There might be separation in the full population, or separation might be caused by to few observed cases/too many variables.
What breaks down with separation, is the maximum likelihood estimation procedure. The mle parameter estimates (or at least some of them) becomes infinite. I said in the first version of this answer that that can be solved easily, maybe with bootstrapping, but that does not work, since there will be separation in each bootstrap resample, at least with the usual cases bootstrapping procedure. But logistic regression is still a valid model, but we need some other estimation procedure. Some proposals have been:
regularization, like ridge or lasso, maybe combined with bootstrap.
exact conditional logistic regression
permutation tests, see https://www.ncbi.nlm.nih.gov/pubmed/15515134
Firths bias-reduced estimation procedure, see Logistic regression model does not converge
surely others ...
If you use R, there is a package on CRAN, SafeBinaryRegression, which help with diagnosing problems with separation, using mathematical optimization methods to check for sure if there is separation or quasiseparation! In the following I will be giving a simulated example using this package, and the elrm package for approximate conditional logistic regression.
First, a simple example with the safeBinaryRegression package. This package just redefines the glm function, overloading it with a test of separation, using linear programming methods. If it detects separation, it exits with an error condition, declaring that the mle does not exist. Otherwise it just runs the ordinary glm function from stats. The example is from its help pages:
library(safeBinaryRegression) # Some testing of that
# package,
# based on its examples
# complete separation:
x <- c(-2, -1, 1, 2)
y <- c(0, 0, 1, 1)
glm(y ~ x, family=binomial)
glm(y ~ x, family=binomial, separation="test")
stats::glm(y ~ x, family=binomial)
# Quasicomplete separation:
x <- c(-2, 0, 0, 2)
y <- c(0, 0, 1, 1)
glm(y ~ x, family=binomial)
glm(y ~ x, family=binomial, separation="test")
stats::glm(y ~ x, family=binomial)
The output from running it:
> # complete separation:
> x <- c(-2, -1, 1, 2)
> y <- c(0, 0, 1, 1)
> glm(y ~ x, family=binomial)
Error in glm(y ~ x, family = binomial) :
The following terms are causing separation among the sample points: (Intercept), x
> glm(y ~ x, family=binomial, separation="test")
Error in glm(y ~ x, family = binomial, separation = "test") :
Separation exists among the sample points.
This model cannot be fit by maximum likelihood.
> stats::glm(y ~ x, family=binomial)
Call: stats::glm(formula = y ~ x, family = binomial)
Coefficients:
(Intercept) x
-9.031e-08 2.314e+01
Degrees of Freedom: 3 Total (i.e. Null); 2 Residual
Null Deviance: 5.545
Residual Deviance: 3.567e-10 AIC: 4
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
> # Quasicomplete separation:
> x <- c(-2, 0, 0, 2)
> y <- c(0, 0, 1, 1)
> glm(y ~ x, family=binomial)
Error in glm(y ~ x, family = binomial) :
The following terms are causing separation among the sample points: x
> glm(y ~ x, family=binomial, separation="test")
Error in glm(y ~ x, family = binomial, separation = "test") :
Separation exists among the sample points.
This model cannot be fit by maximum likelihood.
> stats::glm(y ~ x, family=binomial)
Call: stats::glm(formula = y ~ x, family = binomial)
Coefficients:
(Intercept) x
5.009e-17 9.783e+00
Degrees of Freedom: 3 Total (i.e. Null); 2 Residual
Null Deviance: 5.545
Residual Deviance: 2.773 AIC: 6.773
Now we simulate from a model which can be closely approximated by a logistic model, except that above a certain cutoff the event probability is exactly 1.0. Think about a bioassay problem, but above the cutoff the poison always kills:
pl <- function(a, b, x) 1/(1+exp(-a-b*x))
a <- 0
b <- 1.5
x_cutoff <- uniroot(function(x) pl(0,1.5,x) -
0.98,lower=1,upper=3.5)$root
### circa 2.6
pltrue <- function(a, b, x) ifelse(x < x_cutoff, pl(a, b,
x), 1.0)
x <- -3:3
### Let us simulate many times from this model, and try to
# estimate it
### with safeBinaryRegression::glm That way we can estimate
#the probability
### of separation from this model
set.seed(31415926) ### May I have a large container of
# coffee
replications <- 1000
p <- pltrue(a, b, x)
err <- 0
good <- 0
for (i in 1:replications) {
y <- rbinom(length(x), 1, p)
res <- try(glm(y~x, family=binomial), silent=TRUE)
if (inherits(res,"try-error")) err <- err+1 else
good <- good+1
}
P_separation <- err/replications
P_separation
When running this code, we estimate the probability of separation as
0.759. Run the code yourself, it is fast!
Then we extend this code to try different estimations procedures, mle and approximate conditional logistic regression from elrm. Running this simulation take around 40 minutes on my computer.
library(elrm) # from CRAN
set.seed(31415926) ### May I have a large container of
# coffee
replications <- 1000
GOOD <- numeric(length=replications) ### will be set to one
# when MLE exists!
COEFS <- matrix(as.numeric(NA), replications, 2)
COEFS.elrm <- matrix(as.numeric(NA), replications, 2) # But
# we'll only use second col for x
p <- pltrue(a, b, x)
err <- 0
good <- 0
for (i in 1:replications) {
y <- rbinom(length(x), 1, p)
res <- try(glm(y~x, family=binomial), silent=TRUE)
if (inherits(res,"try-error")) err <- err+1 else{
good <- good+1
GOOD[i] <- 1 }
# Using stats::glm
mod <- stats::glm(y~x, family=binomial)
COEFS[i, ] <- coef(mod)
# Using elrm:
DATASET <- data.frame(x=x, y=y, n=1)
mod.elrm <- elrm(y/n ~ x, interest= ~ x -1, r=4,
iter=10000, burnIn=1000,
dataset=DATASET)
COEFS.elrm[i, 2 ] <- mod.erlm$coeffs
}
### Now we can compare coefficient estimates of x,
### when there are separation, and when not:
non <- which(GOOD==1)
cof.mle.non <- COEFS[non, 2, drop=TRUE]
cof.mle.sep <- COEFS[-non, 2, drop=TRUE]
cof.elrm.non <- COEFS.elrm[non, 2, drop=TRUE]
cof.elrm.sep <- COEFS.elrm[-non, 2, drop=TRUE]
Now we want to plot the results, but before that, note that ALL the conditional estimates are equal! That is really strange and should need an explanation ... The common value is 0.9523975. But at least we obtained finite estimates, with confidence intervals which contains the true value (not shown here). So I will only show a histogram of the mle estimates in the cases without separation:
hist(cof.mle.non, prob=TRUE)
[
What is remarkable is that all the estimates is lesser than the true value 1.5. That can have to do with the fact that we simulated from a modified model, needs investigation.
|
Why does logistic regression become unstable when classes are well-separated?
|
It isn't correct that logistic regression in itself becomes unstable when there are separation. Separation means that there are some variables which are very good predictors, which is good, or, separ
|
Why does logistic regression become unstable when classes are well-separated?
It isn't correct that logistic regression in itself becomes unstable when there are separation. Separation means that there are some variables which are very good predictors, which is good, or, separation may be an artifact of too few observations/too many variables. If that is the case, the solution might be to get more data. But separation itself, then, is only a symptom, and not a problem in itself.
So there are really different cases to be treated. First, what is the goal of the analysis? If the final result of the analysis is some classification of cases, separation is no problem at all, it really means that there are very good variables giving very good classification. But if the goal is risk estimation, we need the parameter estimates, and with separation the usual mle (maximum likelihood) estimates do not exist. So we must change estimation method, maybe. There are several proposals in the literature, I will come back to that.
Then there are (as said above) two different possible causes for separation. There might be separation in the full population, or separation might be caused by to few observed cases/too many variables.
What breaks down with separation, is the maximum likelihood estimation procedure. The mle parameter estimates (or at least some of them) becomes infinite. I said in the first version of this answer that that can be solved easily, maybe with bootstrapping, but that does not work, since there will be separation in each bootstrap resample, at least with the usual cases bootstrapping procedure. But logistic regression is still a valid model, but we need some other estimation procedure. Some proposals have been:
regularization, like ridge or lasso, maybe combined with bootstrap.
exact conditional logistic regression
permutation tests, see https://www.ncbi.nlm.nih.gov/pubmed/15515134
Firths bias-reduced estimation procedure, see Logistic regression model does not converge
surely others ...
If you use R, there is a package on CRAN, SafeBinaryRegression, which help with diagnosing problems with separation, using mathematical optimization methods to check for sure if there is separation or quasiseparation! In the following I will be giving a simulated example using this package, and the elrm package for approximate conditional logistic regression.
First, a simple example with the safeBinaryRegression package. This package just redefines the glm function, overloading it with a test of separation, using linear programming methods. If it detects separation, it exits with an error condition, declaring that the mle does not exist. Otherwise it just runs the ordinary glm function from stats. The example is from its help pages:
library(safeBinaryRegression) # Some testing of that
# package,
# based on its examples
# complete separation:
x <- c(-2, -1, 1, 2)
y <- c(0, 0, 1, 1)
glm(y ~ x, family=binomial)
glm(y ~ x, family=binomial, separation="test")
stats::glm(y ~ x, family=binomial)
# Quasicomplete separation:
x <- c(-2, 0, 0, 2)
y <- c(0, 0, 1, 1)
glm(y ~ x, family=binomial)
glm(y ~ x, family=binomial, separation="test")
stats::glm(y ~ x, family=binomial)
The output from running it:
> # complete separation:
> x <- c(-2, -1, 1, 2)
> y <- c(0, 0, 1, 1)
> glm(y ~ x, family=binomial)
Error in glm(y ~ x, family = binomial) :
The following terms are causing separation among the sample points: (Intercept), x
> glm(y ~ x, family=binomial, separation="test")
Error in glm(y ~ x, family = binomial, separation = "test") :
Separation exists among the sample points.
This model cannot be fit by maximum likelihood.
> stats::glm(y ~ x, family=binomial)
Call: stats::glm(formula = y ~ x, family = binomial)
Coefficients:
(Intercept) x
-9.031e-08 2.314e+01
Degrees of Freedom: 3 Total (i.e. Null); 2 Residual
Null Deviance: 5.545
Residual Deviance: 3.567e-10 AIC: 4
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
> # Quasicomplete separation:
> x <- c(-2, 0, 0, 2)
> y <- c(0, 0, 1, 1)
> glm(y ~ x, family=binomial)
Error in glm(y ~ x, family = binomial) :
The following terms are causing separation among the sample points: x
> glm(y ~ x, family=binomial, separation="test")
Error in glm(y ~ x, family = binomial, separation = "test") :
Separation exists among the sample points.
This model cannot be fit by maximum likelihood.
> stats::glm(y ~ x, family=binomial)
Call: stats::glm(formula = y ~ x, family = binomial)
Coefficients:
(Intercept) x
5.009e-17 9.783e+00
Degrees of Freedom: 3 Total (i.e. Null); 2 Residual
Null Deviance: 5.545
Residual Deviance: 2.773 AIC: 6.773
Now we simulate from a model which can be closely approximated by a logistic model, except that above a certain cutoff the event probability is exactly 1.0. Think about a bioassay problem, but above the cutoff the poison always kills:
pl <- function(a, b, x) 1/(1+exp(-a-b*x))
a <- 0
b <- 1.5
x_cutoff <- uniroot(function(x) pl(0,1.5,x) -
0.98,lower=1,upper=3.5)$root
### circa 2.6
pltrue <- function(a, b, x) ifelse(x < x_cutoff, pl(a, b,
x), 1.0)
x <- -3:3
### Let us simulate many times from this model, and try to
# estimate it
### with safeBinaryRegression::glm That way we can estimate
#the probability
### of separation from this model
set.seed(31415926) ### May I have a large container of
# coffee
replications <- 1000
p <- pltrue(a, b, x)
err <- 0
good <- 0
for (i in 1:replications) {
y <- rbinom(length(x), 1, p)
res <- try(glm(y~x, family=binomial), silent=TRUE)
if (inherits(res,"try-error")) err <- err+1 else
good <- good+1
}
P_separation <- err/replications
P_separation
When running this code, we estimate the probability of separation as
0.759. Run the code yourself, it is fast!
Then we extend this code to try different estimations procedures, mle and approximate conditional logistic regression from elrm. Running this simulation take around 40 minutes on my computer.
library(elrm) # from CRAN
set.seed(31415926) ### May I have a large container of
# coffee
replications <- 1000
GOOD <- numeric(length=replications) ### will be set to one
# when MLE exists!
COEFS <- matrix(as.numeric(NA), replications, 2)
COEFS.elrm <- matrix(as.numeric(NA), replications, 2) # But
# we'll only use second col for x
p <- pltrue(a, b, x)
err <- 0
good <- 0
for (i in 1:replications) {
y <- rbinom(length(x), 1, p)
res <- try(glm(y~x, family=binomial), silent=TRUE)
if (inherits(res,"try-error")) err <- err+1 else{
good <- good+1
GOOD[i] <- 1 }
# Using stats::glm
mod <- stats::glm(y~x, family=binomial)
COEFS[i, ] <- coef(mod)
# Using elrm:
DATASET <- data.frame(x=x, y=y, n=1)
mod.elrm <- elrm(y/n ~ x, interest= ~ x -1, r=4,
iter=10000, burnIn=1000,
dataset=DATASET)
COEFS.elrm[i, 2 ] <- mod.erlm$coeffs
}
### Now we can compare coefficient estimates of x,
### when there are separation, and when not:
non <- which(GOOD==1)
cof.mle.non <- COEFS[non, 2, drop=TRUE]
cof.mle.sep <- COEFS[-non, 2, drop=TRUE]
cof.elrm.non <- COEFS.elrm[non, 2, drop=TRUE]
cof.elrm.sep <- COEFS.elrm[-non, 2, drop=TRUE]
Now we want to plot the results, but before that, note that ALL the conditional estimates are equal! That is really strange and should need an explanation ... The common value is 0.9523975. But at least we obtained finite estimates, with confidence intervals which contains the true value (not shown here). So I will only show a histogram of the mle estimates in the cases without separation:
hist(cof.mle.non, prob=TRUE)
[
What is remarkable is that all the estimates is lesser than the true value 1.5. That can have to do with the fact that we simulated from a modified model, needs investigation.
|
Why does logistic regression become unstable when classes are well-separated?
It isn't correct that logistic regression in itself becomes unstable when there are separation. Separation means that there are some variables which are very good predictors, which is good, or, separ
|
7,092
|
Why does logistic regression become unstable when classes are well-separated?
|
There are good answers here from @sean501 and @kjetilbhalvorsen. You asked for an example. Consider the figure below. You might come across some situation in which the data generating process is like that depicted in panel A. If so, it is quite possible that the data you actually gather look like those in panel B. Now, when you use data to build a statistical model, the idea is to recover the true data generating process or at least come up with an approximation that is reasonably close. Thus, the question is, will fitting a logistic regression to the data in B yield a model that approximates the blue line in A? If you look at panel C, you can see that the gray line better approximates the data than the true function does, so in seeking the best fit, the logistic regression will 'prefer' to return the gray line rather than the blue one. It doesn't stop there, however. Looking at panel D, the black line approximates the data better than the gray one—in fact, it is the best fit that could possibly occur. So that is the line the logistic regression model is pursuing. It corresponds to an intercept of negative infinity and a slope of infinity. That is, of course, very far from the truth that you are hoping to recover. Complete separation can also cause problems with the calculation of the p-values for your variables that come standard with logistic regression output (the explanation there is slightly different and more complicated). Moreover, trying to combine the fit here with other attempts, for example with a meta-analysis, will just make the other findings less accurate.
|
Why does logistic regression become unstable when classes are well-separated?
|
There are good answers here from @sean501 and @kjetilbhalvorsen. You asked for an example. Consider the figure below. You might come across some situation in which the data generating process is li
|
Why does logistic regression become unstable when classes are well-separated?
There are good answers here from @sean501 and @kjetilbhalvorsen. You asked for an example. Consider the figure below. You might come across some situation in which the data generating process is like that depicted in panel A. If so, it is quite possible that the data you actually gather look like those in panel B. Now, when you use data to build a statistical model, the idea is to recover the true data generating process or at least come up with an approximation that is reasonably close. Thus, the question is, will fitting a logistic regression to the data in B yield a model that approximates the blue line in A? If you look at panel C, you can see that the gray line better approximates the data than the true function does, so in seeking the best fit, the logistic regression will 'prefer' to return the gray line rather than the blue one. It doesn't stop there, however. Looking at panel D, the black line approximates the data better than the gray one—in fact, it is the best fit that could possibly occur. So that is the line the logistic regression model is pursuing. It corresponds to an intercept of negative infinity and a slope of infinity. That is, of course, very far from the truth that you are hoping to recover. Complete separation can also cause problems with the calculation of the p-values for your variables that come standard with logistic regression output (the explanation there is slightly different and more complicated). Moreover, trying to combine the fit here with other attempts, for example with a meta-analysis, will just make the other findings less accurate.
|
Why does logistic regression become unstable when classes are well-separated?
There are good answers here from @sean501 and @kjetilbhalvorsen. You asked for an example. Consider the figure below. You might come across some situation in which the data generating process is li
|
7,093
|
Why does logistic regression become unstable when classes are well-separated?
|
It means that there is a hyperplane such that on one side there are all the positive points and on the other side all the negative. The maximum likelihood solution is then flat 1 on one side and flat 0 on other side, which is 'achieved' with the logistic function by having the coefficients at infinity.
|
Why does logistic regression become unstable when classes are well-separated?
|
It means that there is a hyperplane such that on one side there are all the positive points and on the other side all the negative. The maximum likelihood solution is then flat 1 on one side and flat
|
Why does logistic regression become unstable when classes are well-separated?
It means that there is a hyperplane such that on one side there are all the positive points and on the other side all the negative. The maximum likelihood solution is then flat 1 on one side and flat 0 on other side, which is 'achieved' with the logistic function by having the coefficients at infinity.
|
Why does logistic regression become unstable when classes are well-separated?
It means that there is a hyperplane such that on one side there are all the positive points and on the other side all the negative. The maximum likelihood solution is then flat 1 on one side and flat
|
7,094
|
Why does logistic regression become unstable when classes are well-separated?
|
What you are calling "separation" (not 'seperation') covers two different situations that end up causing the same issue – which I would not call, however, an issue of "instability" as you do.
An illustration: Survival on the Titanic
Let $DV \in (0, 1)$ be a binary dependent variable, and $SV$ a separating, independent variable.
Let's suppose that $SV$ is the class of the passengers on the Titanic, and that $DV$ indicates whether they survived the wreckage, with $0$ indicating death and $1$ indicating survival.
Complete separation is the situation where $SV$ predicts all values of $DV$.
That would be the case if all first-class passengers on the Titanic had survived the wreckage, and none of the second-class passengers had survived.
Quasi-complete separation is the situation where $SV$ predicts either all cases where $DV = 0$, or all cases where $DV = 1$, but not both.
That would be the case if some first-class passengers on the Titanic had survived the wreckage, and none of the second-class passengers had survived. In that case, passenger class $SV$ predicts all cases where $DV = 1$, but not all cases where $DV = 0$.
Reversely, if only some second-class passengers on the Titanic had died in the wreckage, then passenger class $SV$ predicts all cases where $DV = 0$, but not all cases where $DV = 1$, which includes both first-class and second-class passengers.
What you are calling "well-separated classes" is the situation where a binary outcome variable $DV$ (e.g. survival on the Titanic) can be completely or quasi-completely mapped to a predictor $SV$ (e.g. passenger class membership; $SV$ need not be binary as it is in my example).
Why is logistic regression "unstable" in these cases?
This is well explained in Rainey 2016 and Zorn 2005.
Under complete separation, your logistic model is going to look for a logistic curve that assigns, for example, all probabilities of $DV$ to $1$ when $SV = 1$, and all probabilities to $DV$ to $0$ when $SV = 0$.
This corresponds to the aforementioned situation where only and all first-class passengers of the Titanic survive, with $SV = 1$ indicating first-class passenger membership.
This is problematic because the logistic curve lies strictly between $0$ and $1$, which means that, to model the observed data, the maximisation is going to push some of its terms towards infinity, in order, if you like, to make $SV$ "infinitely" predictive of $DV$.
The same problem arises under quasi-complete separation, as the logistic curve will still need to assign only values of either $0$ or $1$ to $DV$ in one of two cases, $SV = 0$ or $SV = 1$.
In both cases, the likelihood function of your model will be unable to find a maximum likelihood estimate: it will only find an approximation of that value by approaching it asymptotically.
What you are calling "instability" is the fact that, in cases of complete or quasi-complete separation, there is no finite likelihood for the logistic model to reach. I would not use that term, however: the likelihood function is, in fact, being pretty "stable" (monotonic) in its assignment of coefficient values towards infinity.
Note: my example is fictional. Survival on the Titanic did not boil down just to passenger class membership. See Hall (1986).
|
Why does logistic regression become unstable when classes are well-separated?
|
What you are calling "separation" (not 'seperation') covers two different situations that end up causing the same issue – which I would not call, however, an issue of "instability" as you do.
An illus
|
Why does logistic regression become unstable when classes are well-separated?
What you are calling "separation" (not 'seperation') covers two different situations that end up causing the same issue – which I would not call, however, an issue of "instability" as you do.
An illustration: Survival on the Titanic
Let $DV \in (0, 1)$ be a binary dependent variable, and $SV$ a separating, independent variable.
Let's suppose that $SV$ is the class of the passengers on the Titanic, and that $DV$ indicates whether they survived the wreckage, with $0$ indicating death and $1$ indicating survival.
Complete separation is the situation where $SV$ predicts all values of $DV$.
That would be the case if all first-class passengers on the Titanic had survived the wreckage, and none of the second-class passengers had survived.
Quasi-complete separation is the situation where $SV$ predicts either all cases where $DV = 0$, or all cases where $DV = 1$, but not both.
That would be the case if some first-class passengers on the Titanic had survived the wreckage, and none of the second-class passengers had survived. In that case, passenger class $SV$ predicts all cases where $DV = 1$, but not all cases where $DV = 0$.
Reversely, if only some second-class passengers on the Titanic had died in the wreckage, then passenger class $SV$ predicts all cases where $DV = 0$, but not all cases where $DV = 1$, which includes both first-class and second-class passengers.
What you are calling "well-separated classes" is the situation where a binary outcome variable $DV$ (e.g. survival on the Titanic) can be completely or quasi-completely mapped to a predictor $SV$ (e.g. passenger class membership; $SV$ need not be binary as it is in my example).
Why is logistic regression "unstable" in these cases?
This is well explained in Rainey 2016 and Zorn 2005.
Under complete separation, your logistic model is going to look for a logistic curve that assigns, for example, all probabilities of $DV$ to $1$ when $SV = 1$, and all probabilities to $DV$ to $0$ when $SV = 0$.
This corresponds to the aforementioned situation where only and all first-class passengers of the Titanic survive, with $SV = 1$ indicating first-class passenger membership.
This is problematic because the logistic curve lies strictly between $0$ and $1$, which means that, to model the observed data, the maximisation is going to push some of its terms towards infinity, in order, if you like, to make $SV$ "infinitely" predictive of $DV$.
The same problem arises under quasi-complete separation, as the logistic curve will still need to assign only values of either $0$ or $1$ to $DV$ in one of two cases, $SV = 0$ or $SV = 1$.
In both cases, the likelihood function of your model will be unable to find a maximum likelihood estimate: it will only find an approximation of that value by approaching it asymptotically.
What you are calling "instability" is the fact that, in cases of complete or quasi-complete separation, there is no finite likelihood for the logistic model to reach. I would not use that term, however: the likelihood function is, in fact, being pretty "stable" (monotonic) in its assignment of coefficient values towards infinity.
Note: my example is fictional. Survival on the Titanic did not boil down just to passenger class membership. See Hall (1986).
|
Why does logistic regression become unstable when classes are well-separated?
What you are calling "separation" (not 'seperation') covers two different situations that end up causing the same issue – which I would not call, however, an issue of "instability" as you do.
An illus
|
7,095
|
Are all simulation methods some form of Monte Carlo?
|
There are simulations that are not Monte Carlo. Basically, all Monte Carlo methods use the (weak) law of large numbers: The mean converges to its expectation.
Then there are Quasi Monte Carlo methods. These are simulated with a compromise of random numbers and equally spaced grids to yield faster convergece.
Simulations that are not Monte Carlo are e.g. used in computational fluid dynamics. It is easy to model fluid dynamics on a "micro scale" of single portions of the fluid. These portions have an initial speed, pressure and size and are affected by forces from the neighbouring portions or by solid bodies. Simulations compute the whole behaviour of the fluid by calculating all the portions and their interaction. Doing this efficiently makes this a science. No random numbers are needed there.
In meteorology or climate research, things are done similarly. But now, the initial values are not exactly known: You only have the meteorological data at some points where they have been measured. A lot of data has to be guessed.
As these complicated problems are often not continuous in their input data, you run the simulations with different guesses. The final result will be chosen among the most frequent outcomes. This is actually how some weather forecasts are simulated in principle.
|
Are all simulation methods some form of Monte Carlo?
|
There are simulations that are not Monte Carlo. Basically, all Monte Carlo methods use the (weak) law of large numbers: The mean converges to its expectation.
Then there are Quasi Monte Carlo methods
|
Are all simulation methods some form of Monte Carlo?
There are simulations that are not Monte Carlo. Basically, all Monte Carlo methods use the (weak) law of large numbers: The mean converges to its expectation.
Then there are Quasi Monte Carlo methods. These are simulated with a compromise of random numbers and equally spaced grids to yield faster convergece.
Simulations that are not Monte Carlo are e.g. used in computational fluid dynamics. It is easy to model fluid dynamics on a "micro scale" of single portions of the fluid. These portions have an initial speed, pressure and size and are affected by forces from the neighbouring portions or by solid bodies. Simulations compute the whole behaviour of the fluid by calculating all the portions and their interaction. Doing this efficiently makes this a science. No random numbers are needed there.
In meteorology or climate research, things are done similarly. But now, the initial values are not exactly known: You only have the meteorological data at some points where they have been measured. A lot of data has to be guessed.
As these complicated problems are often not continuous in their input data, you run the simulations with different guesses. The final result will be chosen among the most frequent outcomes. This is actually how some weather forecasts are simulated in principle.
|
Are all simulation methods some form of Monte Carlo?
There are simulations that are not Monte Carlo. Basically, all Monte Carlo methods use the (weak) law of large numbers: The mean converges to its expectation.
Then there are Quasi Monte Carlo methods
|
7,096
|
Are all simulation methods some form of Monte Carlo?
|
Monte Carlo method was the first approach to use computer simulation for statistical problems. It was developed by the John von Neumann, Stanisław Ulam, & Nicholas Metropolis team from Los Alamos laboratories that was working on the Manhattan project during the World War II. It was first described in 1949 by Metropolis & Ulam, and it was the first time the name appeared in print. It was possible because the scientists that discovered it were also able to use one of the first computers, that they were working on. In their work they used Monte Carlo methods for simulation physical problems, and the idea was that you could simulate a complicated problem with sampling some number of examples of this process. There are multiple interesting articles on history of Monte Carlo e.g. by Metropolis himself or some more recent, e.g. by Robert & Casella.
So "Monte Carlo" was a name of the first method described for a purpose of computer simulation to solve statistical problems. Then the name became a general name for a whole family of simulation methods and is commonly used in this fashion.
There are simulation methods considered non-Monte Carlo, however while Monte Carlo was the first use of computer simulation it is common that "computer simulation" and "Monte Carlo" are used interchangeably.
There are different definition of what "simulation" is, i.e.
Merriam-Webster dictionary:
3 a : the imitative representation of the functioning of one system
or process by means of the functioning of another b : examination of a problem
often not subject to direct experimentation by means of a simulating
device
Cambridge dictionary:
to do or make something which behaves or looks like something real but
which is not real
Wikipedia:
imitation of the operation of a real-world process or system over time
What simulation needs to work is an ability to imitate some system or process. This does not need any randomness involved (as with Monte Carlo), however if all the possibilities are tried, then the procedure is rather an exhaustive search or generally and optimization problem. If the random element is involved and a computer is used to run a simulation of some model, then this simulation resembles the spirit of the initial Monte Carlo method (e.g. Metropolis & Ulam, 1949). The random element as a crucial part of simulation is mentioned, for example, by Ross (2006, Simulation. Elsevier). However, the answer to the question depends heavily on the definition of simulation you assume. For example, if you assume that deterministic algorithms that use optimization or exhaustive search, are in fact simulations, then we need to consider a wide variety of algorithms to be simulations and this makes the definition of simulation per se very blurry.
Literally every statistical procedure employs some model or approximation of the reality, that is "tried" and assessed. This is consistent with dictionary definitions of simulation. We do not however consider all the statistics to be simulation based. The question and the discussion seems to emerge from the lack of the precise definition of "simulation". Monte Carlo seems to be archetypical (and first) example of simulation, however if we consider very general definition of simulation then many non-Monte Carlo methods fall into the definition. So there are non-Monte Carlo simulations, but all the clearly simulation-based methods resemble the spirit of Monte Carlo, relate to it in some way, or were inspired by it. That is the reason why "Monte Carlo" is often used as a synonym for "simulation".
|
Are all simulation methods some form of Monte Carlo?
|
Monte Carlo method was the first approach to use computer simulation for statistical problems. It was developed by the John von Neumann, Stanisław Ulam, & Nicholas Metropolis team from Los Alamos labo
|
Are all simulation methods some form of Monte Carlo?
Monte Carlo method was the first approach to use computer simulation for statistical problems. It was developed by the John von Neumann, Stanisław Ulam, & Nicholas Metropolis team from Los Alamos laboratories that was working on the Manhattan project during the World War II. It was first described in 1949 by Metropolis & Ulam, and it was the first time the name appeared in print. It was possible because the scientists that discovered it were also able to use one of the first computers, that they were working on. In their work they used Monte Carlo methods for simulation physical problems, and the idea was that you could simulate a complicated problem with sampling some number of examples of this process. There are multiple interesting articles on history of Monte Carlo e.g. by Metropolis himself or some more recent, e.g. by Robert & Casella.
So "Monte Carlo" was a name of the first method described for a purpose of computer simulation to solve statistical problems. Then the name became a general name for a whole family of simulation methods and is commonly used in this fashion.
There are simulation methods considered non-Monte Carlo, however while Monte Carlo was the first use of computer simulation it is common that "computer simulation" and "Monte Carlo" are used interchangeably.
There are different definition of what "simulation" is, i.e.
Merriam-Webster dictionary:
3 a : the imitative representation of the functioning of one system
or process by means of the functioning of another b : examination of a problem
often not subject to direct experimentation by means of a simulating
device
Cambridge dictionary:
to do or make something which behaves or looks like something real but
which is not real
Wikipedia:
imitation of the operation of a real-world process or system over time
What simulation needs to work is an ability to imitate some system or process. This does not need any randomness involved (as with Monte Carlo), however if all the possibilities are tried, then the procedure is rather an exhaustive search or generally and optimization problem. If the random element is involved and a computer is used to run a simulation of some model, then this simulation resembles the spirit of the initial Monte Carlo method (e.g. Metropolis & Ulam, 1949). The random element as a crucial part of simulation is mentioned, for example, by Ross (2006, Simulation. Elsevier). However, the answer to the question depends heavily on the definition of simulation you assume. For example, if you assume that deterministic algorithms that use optimization or exhaustive search, are in fact simulations, then we need to consider a wide variety of algorithms to be simulations and this makes the definition of simulation per se very blurry.
Literally every statistical procedure employs some model or approximation of the reality, that is "tried" and assessed. This is consistent with dictionary definitions of simulation. We do not however consider all the statistics to be simulation based. The question and the discussion seems to emerge from the lack of the precise definition of "simulation". Monte Carlo seems to be archetypical (and first) example of simulation, however if we consider very general definition of simulation then many non-Monte Carlo methods fall into the definition. So there are non-Monte Carlo simulations, but all the clearly simulation-based methods resemble the spirit of Monte Carlo, relate to it in some way, or were inspired by it. That is the reason why "Monte Carlo" is often used as a synonym for "simulation".
|
Are all simulation methods some form of Monte Carlo?
Monte Carlo method was the first approach to use computer simulation for statistical problems. It was developed by the John von Neumann, Stanisław Ulam, & Nicholas Metropolis team from Los Alamos labo
|
7,097
|
Are all simulation methods some form of Monte Carlo?
|
All simulation methods involve substituting random numbers into the function to find a range of values for the function.
I have never heard of that definition of simulation. For example, Wikipedia’s articles on simulation and computer simulations mention terms like random and stochastic only briefly.
A simple example of a simulation that does not involve any randomness and thus clearly is not a Monte Carlo simulation would be the following:
I want to simulate the behaviour of a simple pendulum and make some simplifying assumptions (massless cord, punctual mass, no friction, no external forces like the Coriolis force). Then I obtain a mathematical pendulum and can write down differential equations describing its motion. I can then use some solver for differential equations like a Runge–Kutta method to simulate its trajectory for given initial conditions. (I can also theoretically argue that I do not need to regard further initial conditions.)
This way I obtain a rather good simulation of a real pendulum without ever using a random number. Therefore, this is not a Monte–Carlo simulation.
In another example, consider the logistic map, which is a simple population model without any randomness.
|
Are all simulation methods some form of Monte Carlo?
|
All simulation methods involve substituting random numbers into the function to find a range of values for the function.
I have never heard of that definition of simulation. For example, Wikipedia’s
|
Are all simulation methods some form of Monte Carlo?
All simulation methods involve substituting random numbers into the function to find a range of values for the function.
I have never heard of that definition of simulation. For example, Wikipedia’s articles on simulation and computer simulations mention terms like random and stochastic only briefly.
A simple example of a simulation that does not involve any randomness and thus clearly is not a Monte Carlo simulation would be the following:
I want to simulate the behaviour of a simple pendulum and make some simplifying assumptions (massless cord, punctual mass, no friction, no external forces like the Coriolis force). Then I obtain a mathematical pendulum and can write down differential equations describing its motion. I can then use some solver for differential equations like a Runge–Kutta method to simulate its trajectory for given initial conditions. (I can also theoretically argue that I do not need to regard further initial conditions.)
This way I obtain a rather good simulation of a real pendulum without ever using a random number. Therefore, this is not a Monte–Carlo simulation.
In another example, consider the logistic map, which is a simple population model without any randomness.
|
Are all simulation methods some form of Monte Carlo?
All simulation methods involve substituting random numbers into the function to find a range of values for the function.
I have never heard of that definition of simulation. For example, Wikipedia’s
|
7,098
|
Are all simulation methods some form of Monte Carlo?
|
No. The simulation of a particle under a force can be done using Runge-Kutta or other deterministic algorithm, which is not Monte Carlo.
Monte Carlo is used to compute integrals (you can call it a simulation, but in the end it just computes a numerical approximation of an estimator). Again, you could use a deterministic method to do that (e.g. trapezoidal rule).
Broadly speaking, you can separate algorithms to compute integrals in deterministic and non-deterministic. Monte Carlo is a non-deterministic method. Quasi-Monte Carlo is another. Trapezoidal rule is a deterministic algorithm.
|
Are all simulation methods some form of Monte Carlo?
|
No. The simulation of a particle under a force can be done using Runge-Kutta or other deterministic algorithm, which is not Monte Carlo.
Monte Carlo is used to compute integrals (you can call it a sim
|
Are all simulation methods some form of Monte Carlo?
No. The simulation of a particle under a force can be done using Runge-Kutta or other deterministic algorithm, which is not Monte Carlo.
Monte Carlo is used to compute integrals (you can call it a simulation, but in the end it just computes a numerical approximation of an estimator). Again, you could use a deterministic method to do that (e.g. trapezoidal rule).
Broadly speaking, you can separate algorithms to compute integrals in deterministic and non-deterministic. Monte Carlo is a non-deterministic method. Quasi-Monte Carlo is another. Trapezoidal rule is a deterministic algorithm.
|
Are all simulation methods some form of Monte Carlo?
No. The simulation of a particle under a force can be done using Runge-Kutta or other deterministic algorithm, which is not Monte Carlo.
Monte Carlo is used to compute integrals (you can call it a sim
|
7,099
|
Are all simulation methods some form of Monte Carlo?
|
Let me take a stab at a simplified explanation. A "what-if" model is a (deterministic) simulation. Say you have a complex system, like a widget processing plant. You want to be able to estimate some performance parameter, say cost. You build a mathematical model of the plant and then select various assumptions for specific factors in the model, like how fast widgets move through different operations, or what percentages flow in various directions, or how many widgets you will process. The model is a simulation of the plant and each set of assumptions gives you an estimate of that performance parameter.
Now introduce uncertainty. You don't know what the demand for widgets will be next month but you need to estimate cost. So instead of saying demand will be 1,000 widgets, you estimate a probability distribution for demand. Then you randomly sample demand values from that distribution and use those for your assumption. While you're at it, you can use probability distributions for other assumptions, also. You use the model over and over, plugging in assumptions sampled from the various probability distributions. The result will be a distribution of cost estimates. That's the Monte Carlo aspect.
Monte Carlo is a "feature" or "engine" that is layered on top of a simulation model. Instead of simulating with a single set of assumptions for a single estimate, it performs a collection of simulations using randomly selected assumptions.
|
Are all simulation methods some form of Monte Carlo?
|
Let me take a stab at a simplified explanation. A "what-if" model is a (deterministic) simulation. Say you have a complex system, like a widget processing plant. You want to be able to estimate som
|
Are all simulation methods some form of Monte Carlo?
Let me take a stab at a simplified explanation. A "what-if" model is a (deterministic) simulation. Say you have a complex system, like a widget processing plant. You want to be able to estimate some performance parameter, say cost. You build a mathematical model of the plant and then select various assumptions for specific factors in the model, like how fast widgets move through different operations, or what percentages flow in various directions, or how many widgets you will process. The model is a simulation of the plant and each set of assumptions gives you an estimate of that performance parameter.
Now introduce uncertainty. You don't know what the demand for widgets will be next month but you need to estimate cost. So instead of saying demand will be 1,000 widgets, you estimate a probability distribution for demand. Then you randomly sample demand values from that distribution and use those for your assumption. While you're at it, you can use probability distributions for other assumptions, also. You use the model over and over, plugging in assumptions sampled from the various probability distributions. The result will be a distribution of cost estimates. That's the Monte Carlo aspect.
Monte Carlo is a "feature" or "engine" that is layered on top of a simulation model. Instead of simulating with a single set of assumptions for a single estimate, it performs a collection of simulations using randomly selected assumptions.
|
Are all simulation methods some form of Monte Carlo?
Let me take a stab at a simplified explanation. A "what-if" model is a (deterministic) simulation. Say you have a complex system, like a widget processing plant. You want to be able to estimate som
|
7,100
|
Are all simulation methods some form of Monte Carlo?
|
In game theory, especially, approaches that use randomness in the simulations are called monte carlo techniques. It is typically used as part of Monte Carlo Tree Search (MCTS) in modern programs.
(The original question did not make a distinction between "monte carlo algorithm" and "monte carlo method", which may explain disagreement over some of the answers here.)
For instance in the game of go (and all other games I am aware of that use MCTS), the simulations are called playouts. Random playouts use the barest set of rules. Light playouts are either a synonym for random playouts or filter out a few easily detected bad moves. Heavy playouts use more heuristics to filter out a lot more moves. (By the way the playout always goes to the end of the game, so each playout takes roughly the same amount of time.) But all are referred to as being "monte carlo" simulations.
|
Are all simulation methods some form of Monte Carlo?
|
In game theory, especially, approaches that use randomness in the simulations are called monte carlo techniques. It is typically used as part of Monte Carlo Tree Search (MCTS) in modern programs.
(The
|
Are all simulation methods some form of Monte Carlo?
In game theory, especially, approaches that use randomness in the simulations are called monte carlo techniques. It is typically used as part of Monte Carlo Tree Search (MCTS) in modern programs.
(The original question did not make a distinction between "monte carlo algorithm" and "monte carlo method", which may explain disagreement over some of the answers here.)
For instance in the game of go (and all other games I am aware of that use MCTS), the simulations are called playouts. Random playouts use the barest set of rules. Light playouts are either a synonym for random playouts or filter out a few easily detected bad moves. Heavy playouts use more heuristics to filter out a lot more moves. (By the way the playout always goes to the end of the game, so each playout takes roughly the same amount of time.) But all are referred to as being "monte carlo" simulations.
|
Are all simulation methods some form of Monte Carlo?
In game theory, especially, approaches that use randomness in the simulations are called monte carlo techniques. It is typically used as part of Monte Carlo Tree Search (MCTS) in modern programs.
(The
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.