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
16,501
Predicting count data with random forest?
I see a few possibilities. You could bin the response into a few arbitrary categories and use a classification tree If the counts are typically very low, 0, 0, 0, 1, 0, 3, 0, 2, you could treat each integer count as a class and again use a classification tree (probably not your case). In these cases, it's going to be harder to get a high variance explained type metric as opposed to continuous regression. If the counts are not typically low and there is a lot of variation, I'd just go for it with a regression tree. Using poisson regression over linear regression, for instance, is only gravy when it comes to getting a good linear predictor. If you're not seeing good predictive power with the random forest, then I doubt a fancier model that specifically accommodates count data is going to do a lot for you. Update (2020-12-11) Since writing this answer, a Kaggle contest (the M5 competition) showed me a situation where using Poisson loss in a LightGBM framework did really well for retail sales data with low counts. I don't know how much better it did than mean squared error but many of the public notebooks were using it, and it was an easy switch. I don't think my second bullet is a very good idea but I'll leave it up.
Predicting count data with random forest?
I see a few possibilities. You could bin the response into a few arbitrary categories and use a classification tree If the counts are typically very low, 0, 0, 0, 1, 0, 3, 0, 2, you could treat each
Predicting count data with random forest? I see a few possibilities. You could bin the response into a few arbitrary categories and use a classification tree If the counts are typically very low, 0, 0, 0, 1, 0, 3, 0, 2, you could treat each integer count as a class and again use a classification tree (probably not your case). In these cases, it's going to be harder to get a high variance explained type metric as opposed to continuous regression. If the counts are not typically low and there is a lot of variation, I'd just go for it with a regression tree. Using poisson regression over linear regression, for instance, is only gravy when it comes to getting a good linear predictor. If you're not seeing good predictive power with the random forest, then I doubt a fancier model that specifically accommodates count data is going to do a lot for you. Update (2020-12-11) Since writing this answer, a Kaggle contest (the M5 competition) showed me a situation where using Poisson loss in a LightGBM framework did really well for retail sales data with low counts. I don't know how much better it did than mean squared error but many of the public notebooks were using it, and it was an easy switch. I don't think my second bullet is a very good idea but I'll leave it up.
Predicting count data with random forest? I see a few possibilities. You could bin the response into a few arbitrary categories and use a classification tree If the counts are typically very low, 0, 0, 0, 1, 0, 3, 0, 2, you could treat each
16,502
Predicting count data with random forest?
Well, its not random forest, but CatBoost supports a poisson loss function that could be used for count regression with boosted trees: https://tech.yandex.com/catboost/doc/dg/concepts/loss-functions-docpage/
Predicting count data with random forest?
Well, its not random forest, but CatBoost supports a poisson loss function that could be used for count regression with boosted trees: https://tech.yandex.com/catboost/doc/dg/concepts/loss-functions-d
Predicting count data with random forest? Well, its not random forest, but CatBoost supports a poisson loss function that could be used for count regression with boosted trees: https://tech.yandex.com/catboost/doc/dg/concepts/loss-functions-docpage/
Predicting count data with random forest? Well, its not random forest, but CatBoost supports a poisson loss function that could be used for count regression with boosted trees: https://tech.yandex.com/catboost/doc/dg/concepts/loss-functions-d
16,503
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
This is a long answer. So, let's give a short-story version of it here. There's no nice algebraic solution to this root-finding problem, so we need a numerical algorithm. The function $\mathrm{df}(\lambda)$ has lots of nice properties. We can harness these to create a specialized version of Newton's method for this problem with guaranteed monotonic convergence to each root. Even brain-dead R code absent any attempts at optimization can compute a grid of size 100 with $p = 100\,000$ in a few of seconds. Carefully written C code would reduce this by at least 2–3 orders of magnitude. There are two schemes given below to guarantee monotonic convergence. One uses bounds shown below, which seem to help save a Newton step or two on occasion. Example: $p = 100\,000$ and a uniform grid for the degrees of freedom of size 100. The eigenvalues are Pareto-distributed, hence highly skewed. Below are tables of the number of Newton steps to find each root. # Table of Newton iterations per root. # Without using lower-bound check. 1 3 4 5 6 1 28 65 5 1 # Table with lower-bound check. 1 2 3 1 14 85 There won't be a closed-form solution for this, in general, but there is a lot of structure present which can be used to produce very effective and safe solutions using standard root-finding methods. Before digging too deeply into things, let's collect some properties and consequences of the function $$\newcommand{\df}{\mathrm{df}} \df(\lambda) = \sum_{i=1}^p \frac{d_i^2}{d_i^2 + \lambda} \>. $$ Property 0: $\df$ is a rational function of $\lambda$. (This is apparent from the definition.) Consequence 0: No general algebraic solution will exist for finding the root $\df(\lambda) - y = 0$. This is because there is an equivalent polynomial root-finding problem of degree $p$ and so if $p$ is not extremely small (i.e., less than five), no general solution will exist. So, we'll need a numerical method. Property 1: The function $\df$ is convex and decreasing on $\lambda \geq 0$. (Take derivatives.) Consequence 1(a): Newton's root-finding algorithm will behave very nicely in this situation. Let $y$ be the desired degrees of freedom and $\lambda_0$ the corresponding root, i.e., $y = \df(\lambda_0)$. In particular, if we start out with any initial value $\lambda_1 < \lambda_0$ (so, $\df(\lambda_1) > y$), then the sequence of Newton-step iterations $\lambda_1,\lambda_2,\ldots$ will converge monotonically to the unique solution $\lambda_0$. Consequence 1(b): Furthermore, if we were to start out with $\lambda_1 > \lambda_0$, then the first step would yield $\lambda_2 \leq \lambda_0$, from whence it will monotonically increase to the solution by the previous consequence (see caveat below). Intuitively, this last fact follows because if we start to the right of the root, the derivative is "too" shallow due to the convexity of $\df$ and so the first Newton step will take us somewhere to the left of the root. NB Since $\df$ is not in general convex for negative $\lambda$, this provides a strong reason to prefer starting to the left of the desired root. Otherwise, we need to double check that the Newton step hasn't resulted in a negative value for the estimated root, which may place us somewhere in a nonconvex portion of $\df$. Consequence 1(c): Once we've found the root for some $y_1$ and are then searching for the root from some $y_2 < y_1$, using $\lambda_1$ such that $\df(\lambda_1) = y_1$ as our initial guess guarantees we start to the left of the second root. So, our convergence is guaranteed to be monotonic from there. Property 2: Reasonable bounds exist to give "safe" starting points. Using convexity arguments and Jensen's inequality, we have the following bounds $$ \frac{p}{1+ \frac{\lambda}{p}\sum d_i^{-2}} \leq \df(\lambda) \leq \frac{p \sum_i d_i^2}{\sum_i d_i^2 + p \lambda} \>. $$ Consequence 2: This tells us that the root $\lambda_0$ satisfying $\df(\lambda_0) = y$ obeys $$ \frac{1}{\frac{1}{p}\sum_i d_i^{-2}}\left(\frac{p - y}{y}\right) \leq \lambda_0 \leq \left(\frac{1}{p}\sum_i d_i^2\right) \left(\frac{p - y}{y}\right) \>. \tag{$\star$} $$ So, up to a common constant, we've sandwiched the root in between the harmonic and arithmetic means of the $d_i^2$. This assumes that $d_i > 0$ for all $i$. If this is not the case, then the same bound holds by considering only the positive $d_i$ and replacing $p$ by the number of positive $d_i$. NB: Since $\df(0) = p$ assuming all $d_i > 0$, then $y \in (0,p]$, whence the bounds are always nontrivial (e.g., the lower bound is always nonnegative). Here is a plot of a "typical" example of $\df(\lambda)$ with $p = 400$. We've superimposed a grid of size 10 for the degrees of freedom. These are the horizontal lines in the plot. The vertical green lines correspond to the lower bound in $(\star)$. An algorithm and some example R code A very efficient algorithm given a grid of desired degrees of freedom $y_1, \ldots y_n$ in $(0,p]$ is to sort them in decreasing order and then sequentially find the root of each, using the previous root as the starting point for the following one. We can refine this further by checking if each root is greater than the lower bound for the next root, and, if not, we can start the next iteration at the lower bound instead. Here is some example code in R, with no attempts made to optimize it. As seen below, it is still quite fast even though R is—to put it politely—horrifingly, awfully, terribly slow at loops. # Newton's step for finding solutions to regularization dof. dof <- function(lambda, d) { sum(1/(1+lambda / (d[d>0])^2)) } dof.prime <- function(lambda, d) { -sum(1/(d[d>0]+lambda / d[d>0])^2) } newton.step <- function(lambda, y, d) { lambda - (dof(lambda,d)-y)/dof.prime(lambda,d) } # Full Newton step; Finds the root of y = dof(lambda, d). newton <- function(y, d, lambda = NA, tol=1e-10, smart.start=T) { if( is.na(lambda) || smart.start ) lambda <- max(ifelse(is.na(lambda),0,lambda), (sum(d>0)/y-1)/mean(1/(d[d>0])^2)) iter <- 0 yn <- Inf while( abs(y-yn) > tol ) { lambda <- max(0, newton.step(lambda, y, d)) # max = pedantically safe yn <- dof(lambda,d) iter = iter + 1 } return(list(lambda=lambda, dof=y, iter=iter, err=abs(y-yn))) } Below is the final full algorithm which takes a grid of points, and a vector of the $d_i$ (not $d_i^2$!). newton.grid <- function(ygrid, d, lambda=NA, tol=1e-10, smart.start=TRUE) { p <- sum(d>0) if( any(d < 0) || all(d==0) || any(ygrid > p) || any(ygrid <= 0) || (!is.na(lambda) && lambda < 0) ) stop("Don't try to fool me. That's not nice. Give me valid inputs, please.") ygrid <- sort(ygrid, decreasing=TRUE) out <- data.frame() lambda <- NA for(y in ygrid) { out <- rbind(out, newton(y,d,lambda, smart.start=smart.start)) lambda <- out$lambda[nrow(out)] } out } Sample function call set.seed(17) p <- 100000 d <- sqrt(sort(exp(rexp(p, 10)),decr=T)) ygrid <- p*(1:100)/100 # Should take ten seconds or so. out <- newton.grid(ygrid,d)
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
This is a long answer. So, let's give a short-story version of it here. There's no nice algebraic solution to this root-finding problem, so we need a numerical algorithm. The function $\mathrm{df}(\l
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? This is a long answer. So, let's give a short-story version of it here. There's no nice algebraic solution to this root-finding problem, so we need a numerical algorithm. The function $\mathrm{df}(\lambda)$ has lots of nice properties. We can harness these to create a specialized version of Newton's method for this problem with guaranteed monotonic convergence to each root. Even brain-dead R code absent any attempts at optimization can compute a grid of size 100 with $p = 100\,000$ in a few of seconds. Carefully written C code would reduce this by at least 2–3 orders of magnitude. There are two schemes given below to guarantee monotonic convergence. One uses bounds shown below, which seem to help save a Newton step or two on occasion. Example: $p = 100\,000$ and a uniform grid for the degrees of freedom of size 100. The eigenvalues are Pareto-distributed, hence highly skewed. Below are tables of the number of Newton steps to find each root. # Table of Newton iterations per root. # Without using lower-bound check. 1 3 4 5 6 1 28 65 5 1 # Table with lower-bound check. 1 2 3 1 14 85 There won't be a closed-form solution for this, in general, but there is a lot of structure present which can be used to produce very effective and safe solutions using standard root-finding methods. Before digging too deeply into things, let's collect some properties and consequences of the function $$\newcommand{\df}{\mathrm{df}} \df(\lambda) = \sum_{i=1}^p \frac{d_i^2}{d_i^2 + \lambda} \>. $$ Property 0: $\df$ is a rational function of $\lambda$. (This is apparent from the definition.) Consequence 0: No general algebraic solution will exist for finding the root $\df(\lambda) - y = 0$. This is because there is an equivalent polynomial root-finding problem of degree $p$ and so if $p$ is not extremely small (i.e., less than five), no general solution will exist. So, we'll need a numerical method. Property 1: The function $\df$ is convex and decreasing on $\lambda \geq 0$. (Take derivatives.) Consequence 1(a): Newton's root-finding algorithm will behave very nicely in this situation. Let $y$ be the desired degrees of freedom and $\lambda_0$ the corresponding root, i.e., $y = \df(\lambda_0)$. In particular, if we start out with any initial value $\lambda_1 < \lambda_0$ (so, $\df(\lambda_1) > y$), then the sequence of Newton-step iterations $\lambda_1,\lambda_2,\ldots$ will converge monotonically to the unique solution $\lambda_0$. Consequence 1(b): Furthermore, if we were to start out with $\lambda_1 > \lambda_0$, then the first step would yield $\lambda_2 \leq \lambda_0$, from whence it will monotonically increase to the solution by the previous consequence (see caveat below). Intuitively, this last fact follows because if we start to the right of the root, the derivative is "too" shallow due to the convexity of $\df$ and so the first Newton step will take us somewhere to the left of the root. NB Since $\df$ is not in general convex for negative $\lambda$, this provides a strong reason to prefer starting to the left of the desired root. Otherwise, we need to double check that the Newton step hasn't resulted in a negative value for the estimated root, which may place us somewhere in a nonconvex portion of $\df$. Consequence 1(c): Once we've found the root for some $y_1$ and are then searching for the root from some $y_2 < y_1$, using $\lambda_1$ such that $\df(\lambda_1) = y_1$ as our initial guess guarantees we start to the left of the second root. So, our convergence is guaranteed to be monotonic from there. Property 2: Reasonable bounds exist to give "safe" starting points. Using convexity arguments and Jensen's inequality, we have the following bounds $$ \frac{p}{1+ \frac{\lambda}{p}\sum d_i^{-2}} \leq \df(\lambda) \leq \frac{p \sum_i d_i^2}{\sum_i d_i^2 + p \lambda} \>. $$ Consequence 2: This tells us that the root $\lambda_0$ satisfying $\df(\lambda_0) = y$ obeys $$ \frac{1}{\frac{1}{p}\sum_i d_i^{-2}}\left(\frac{p - y}{y}\right) \leq \lambda_0 \leq \left(\frac{1}{p}\sum_i d_i^2\right) \left(\frac{p - y}{y}\right) \>. \tag{$\star$} $$ So, up to a common constant, we've sandwiched the root in between the harmonic and arithmetic means of the $d_i^2$. This assumes that $d_i > 0$ for all $i$. If this is not the case, then the same bound holds by considering only the positive $d_i$ and replacing $p$ by the number of positive $d_i$. NB: Since $\df(0) = p$ assuming all $d_i > 0$, then $y \in (0,p]$, whence the bounds are always nontrivial (e.g., the lower bound is always nonnegative). Here is a plot of a "typical" example of $\df(\lambda)$ with $p = 400$. We've superimposed a grid of size 10 for the degrees of freedom. These are the horizontal lines in the plot. The vertical green lines correspond to the lower bound in $(\star)$. An algorithm and some example R code A very efficient algorithm given a grid of desired degrees of freedom $y_1, \ldots y_n$ in $(0,p]$ is to sort them in decreasing order and then sequentially find the root of each, using the previous root as the starting point for the following one. We can refine this further by checking if each root is greater than the lower bound for the next root, and, if not, we can start the next iteration at the lower bound instead. Here is some example code in R, with no attempts made to optimize it. As seen below, it is still quite fast even though R is—to put it politely—horrifingly, awfully, terribly slow at loops. # Newton's step for finding solutions to regularization dof. dof <- function(lambda, d) { sum(1/(1+lambda / (d[d>0])^2)) } dof.prime <- function(lambda, d) { -sum(1/(d[d>0]+lambda / d[d>0])^2) } newton.step <- function(lambda, y, d) { lambda - (dof(lambda,d)-y)/dof.prime(lambda,d) } # Full Newton step; Finds the root of y = dof(lambda, d). newton <- function(y, d, lambda = NA, tol=1e-10, smart.start=T) { if( is.na(lambda) || smart.start ) lambda <- max(ifelse(is.na(lambda),0,lambda), (sum(d>0)/y-1)/mean(1/(d[d>0])^2)) iter <- 0 yn <- Inf while( abs(y-yn) > tol ) { lambda <- max(0, newton.step(lambda, y, d)) # max = pedantically safe yn <- dof(lambda,d) iter = iter + 1 } return(list(lambda=lambda, dof=y, iter=iter, err=abs(y-yn))) } Below is the final full algorithm which takes a grid of points, and a vector of the $d_i$ (not $d_i^2$!). newton.grid <- function(ygrid, d, lambda=NA, tol=1e-10, smart.start=TRUE) { p <- sum(d>0) if( any(d < 0) || all(d==0) || any(ygrid > p) || any(ygrid <= 0) || (!is.na(lambda) && lambda < 0) ) stop("Don't try to fool me. That's not nice. Give me valid inputs, please.") ygrid <- sort(ygrid, decreasing=TRUE) out <- data.frame() lambda <- NA for(y in ygrid) { out <- rbind(out, newton(y,d,lambda, smart.start=smart.start)) lambda <- out$lambda[nrow(out)] } out } Sample function call set.seed(17) p <- 100000 d <- sqrt(sort(exp(rexp(p, 10)),decr=T)) ygrid <- p*(1:100)/100 # Should take ten seconds or so. out <- newton.grid(ygrid,d)
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? This is a long answer. So, let's give a short-story version of it here. There's no nice algebraic solution to this root-finding problem, so we need a numerical algorithm. The function $\mathrm{df}(\l
16,504
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
In addition, a couple of methods exist that will calculate the complete regularization path efficiently: GPS glmnet gcdnet The above are all R packages, as you are using Python, scikit-learn contains implementations for ridge, lasso and elastic net.
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
In addition, a couple of methods exist that will calculate the complete regularization path efficiently: GPS glmnet gcdnet The above are all R packages, as you are using Python, scikit-learn contain
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? In addition, a couple of methods exist that will calculate the complete regularization path efficiently: GPS glmnet gcdnet The above are all R packages, as you are using Python, scikit-learn contains implementations for ridge, lasso and elastic net.
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? In addition, a couple of methods exist that will calculate the complete regularization path efficiently: GPS glmnet gcdnet The above are all R packages, as you are using Python, scikit-learn contain
16,505
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
A possible alternative according to the source below seems to be: The closed form solution: $df(\lambda) = \operatorname{tr}(X(X^{\top} X + \lambda I_{p})^{-1}X^{\top})$ Should you be using the normal equation as the solver or computing the variance-covariance estimate, you should already have computed $(X^{\top}X + \lambda I_{p})^{-1}$. This approach works best if you are estimating the coefficients at the various $\lambda$. Source
Implementing ridge regression: Selecting an intelligent grid for $\lambda$?
A possible alternative according to the source below seems to be: The closed form solution: $df(\lambda) = \operatorname{tr}(X(X^{\top} X + \lambda I_{p})^{-1}X^{\top})$ Should you be using the normal
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? A possible alternative according to the source below seems to be: The closed form solution: $df(\lambda) = \operatorname{tr}(X(X^{\top} X + \lambda I_{p})^{-1}X^{\top})$ Should you be using the normal equation as the solver or computing the variance-covariance estimate, you should already have computed $(X^{\top}X + \lambda I_{p})^{-1}$. This approach works best if you are estimating the coefficients at the various $\lambda$. Source
Implementing ridge regression: Selecting an intelligent grid for $\lambda$? A possible alternative according to the source below seems to be: The closed form solution: $df(\lambda) = \operatorname{tr}(X(X^{\top} X + \lambda I_{p})^{-1}X^{\top})$ Should you be using the normal
16,506
The input parameters for using latent Dirichlet allocation
As far as I know you just need to supply a number of topics and the corpus. No need to specify a candidate topic set, though one can be used, as you can see in the example starting at the bottom of page 15 of Grun and Hornik (2011). Updated 28 Jan 14. I now do things a bit differently to the method below. See here for my current approach: https://stackoverflow.com/a/21394092/1036500 A relatively simple way to find the optimum number of topics without training data is by looping through models with different numbers of topics to find the number of topics with the maximum log likelihood, given the data. Consider this example with R # download and install one of the two R packages for LDA, see a discussion # of them here: http://stats.stackexchange.com/questions/24441 # install.packages("topicmodels") library(topicmodels) # # get some of the example data that's bundled with the package # data("AssociatedPress", package = "topicmodels") Before going right into generating the topic model and analysing the output, we need to decide on the number of topics that the model should use. Here’s a function to loop over different topic numbers, get the log liklihood of the model for each topic number and plot it so we can pick the best one. The best number of topics is the one with the highest log likelihood value to get the example data built into the package. Here I've chosen to evaluate every model starting with 2 topics though to 100 topics (this will take some time!). best.model <- lapply(seq(2,100, by=1), function(k){LDA(AssociatedPress[21:30,], k)}) Now we can extract the log liklihood values for each model that was generated and prepare to plot it: best.model.logLik <- as.data.frame(as.matrix(lapply(best.model, logLik))) best.model.logLik.df <- data.frame(topics=c(2:100), LL=as.numeric(as.matrix(best.model.logLik))) And now make a plot to see at what number of topics the highest log likelihood appears: library(ggplot2) ggplot(best.model.logLik.df, aes(x=topics, y=LL)) + xlab("Number of topics") + ylab("Log likelihood of the model") + geom_line() + theme_bw() + opts(axis.title.x = theme_text(vjust = -0.25, size = 14)) + opts(axis.title.y = theme_text(size = 14, angle=90)) Looks like it's somewhere between 10 and 20 topics. We can inspect the data to find the exact number of topics with the highest log liklihood like so: best.model.logLik.df[which.max(best.model.logLik.df$LL),] # which returns topics LL 12 13 -8525.234 So the result is that 13 topics give the best fit for these data. Now we can go ahead with creating the LDA model with 13 topics and investigating the model: lda_AP <- LDA(AssociatedPress[21:30,], 13) # generate the model with 13 topics get_terms(lda_AP, 5) # gets 5 keywords for each topic, just for a quick look get_topics(lda_AP, 5) # gets 5 topic numbers per document And so on to determine the attributes of the model. This approach is based on: Griffiths, T.L., and M. Steyvers 2004. Finding scientific topics. Proceedings of the National Academy of Sciences of the United States of America 101(Suppl 1):5228 –5235.
The input parameters for using latent Dirichlet allocation
As far as I know you just need to supply a number of topics and the corpus. No need to specify a candidate topic set, though one can be used, as you can see in the example starting at the bottom of pa
The input parameters for using latent Dirichlet allocation As far as I know you just need to supply a number of topics and the corpus. No need to specify a candidate topic set, though one can be used, as you can see in the example starting at the bottom of page 15 of Grun and Hornik (2011). Updated 28 Jan 14. I now do things a bit differently to the method below. See here for my current approach: https://stackoverflow.com/a/21394092/1036500 A relatively simple way to find the optimum number of topics without training data is by looping through models with different numbers of topics to find the number of topics with the maximum log likelihood, given the data. Consider this example with R # download and install one of the two R packages for LDA, see a discussion # of them here: http://stats.stackexchange.com/questions/24441 # install.packages("topicmodels") library(topicmodels) # # get some of the example data that's bundled with the package # data("AssociatedPress", package = "topicmodels") Before going right into generating the topic model and analysing the output, we need to decide on the number of topics that the model should use. Here’s a function to loop over different topic numbers, get the log liklihood of the model for each topic number and plot it so we can pick the best one. The best number of topics is the one with the highest log likelihood value to get the example data built into the package. Here I've chosen to evaluate every model starting with 2 topics though to 100 topics (this will take some time!). best.model <- lapply(seq(2,100, by=1), function(k){LDA(AssociatedPress[21:30,], k)}) Now we can extract the log liklihood values for each model that was generated and prepare to plot it: best.model.logLik <- as.data.frame(as.matrix(lapply(best.model, logLik))) best.model.logLik.df <- data.frame(topics=c(2:100), LL=as.numeric(as.matrix(best.model.logLik))) And now make a plot to see at what number of topics the highest log likelihood appears: library(ggplot2) ggplot(best.model.logLik.df, aes(x=topics, y=LL)) + xlab("Number of topics") + ylab("Log likelihood of the model") + geom_line() + theme_bw() + opts(axis.title.x = theme_text(vjust = -0.25, size = 14)) + opts(axis.title.y = theme_text(size = 14, angle=90)) Looks like it's somewhere between 10 and 20 topics. We can inspect the data to find the exact number of topics with the highest log liklihood like so: best.model.logLik.df[which.max(best.model.logLik.df$LL),] # which returns topics LL 12 13 -8525.234 So the result is that 13 topics give the best fit for these data. Now we can go ahead with creating the LDA model with 13 topics and investigating the model: lda_AP <- LDA(AssociatedPress[21:30,], 13) # generate the model with 13 topics get_terms(lda_AP, 5) # gets 5 keywords for each topic, just for a quick look get_topics(lda_AP, 5) # gets 5 topic numbers per document And so on to determine the attributes of the model. This approach is based on: Griffiths, T.L., and M. Steyvers 2004. Finding scientific topics. Proceedings of the National Academy of Sciences of the United States of America 101(Suppl 1):5228 –5235.
The input parameters for using latent Dirichlet allocation As far as I know you just need to supply a number of topics and the corpus. No need to specify a candidate topic set, though one can be used, as you can see in the example starting at the bottom of pa
16,507
Nonparametric Bayesian analysis in R
Here are some online ressources I found interesting without going into detail (and I'm not a specialist of this topic): Hierarchical Dirichlet Processes, by Teh et al. (2005) Dirichlet Processes A gentle tutorial, by El-Arini (2008) Bayesian Nonparametrics, by Rosasco (2010) Non-parametric Bayesian Methods, by Ghahramani (2005) The definitive reference seems to be N. Hjort, C. Holmes, P. Müller, and S. Walker, editors. Bayesian Nonparametrics. Number 28 in Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press, 2010. About R, there seems to be some other packages worth to explore if the DPpackage does not suit your needs, e.g. dpmixsim, BHC, or mbsc found on Rseek.org.
Nonparametric Bayesian analysis in R
Here are some online ressources I found interesting without going into detail (and I'm not a specialist of this topic): Hierarchical Dirichlet Processes, by Teh et al. (2005) Dirichlet Processes A ge
Nonparametric Bayesian analysis in R Here are some online ressources I found interesting without going into detail (and I'm not a specialist of this topic): Hierarchical Dirichlet Processes, by Teh et al. (2005) Dirichlet Processes A gentle tutorial, by El-Arini (2008) Bayesian Nonparametrics, by Rosasco (2010) Non-parametric Bayesian Methods, by Ghahramani (2005) The definitive reference seems to be N. Hjort, C. Holmes, P. Müller, and S. Walker, editors. Bayesian Nonparametrics. Number 28 in Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press, 2010. About R, there seems to be some other packages worth to explore if the DPpackage does not suit your needs, e.g. dpmixsim, BHC, or mbsc found on Rseek.org.
Nonparametric Bayesian analysis in R Here are some online ressources I found interesting without going into detail (and I'm not a specialist of this topic): Hierarchical Dirichlet Processes, by Teh et al. (2005) Dirichlet Processes A ge
16,508
Nonparametric Bayesian analysis in R
These two links provide some R (and C) code examples of implementing a DP normal mixture: http://ice.uchicago.edu/2008_presentations/Rossi/density_estimation_with_DP_priors.ppt http://www.duke.edu/~neelo003/r/DP02.r Found another reference. Chapter 15 has DP winbugs code: http://www.ics.uci.edu/~wjohnson/BIDA/BIDABook.html
Nonparametric Bayesian analysis in R
These two links provide some R (and C) code examples of implementing a DP normal mixture: http://ice.uchicago.edu/2008_presentations/Rossi/density_estimation_with_DP_priors.ppt http://www.duke.edu/~n
Nonparametric Bayesian analysis in R These two links provide some R (and C) code examples of implementing a DP normal mixture: http://ice.uchicago.edu/2008_presentations/Rossi/density_estimation_with_DP_priors.ppt http://www.duke.edu/~neelo003/r/DP02.r Found another reference. Chapter 15 has DP winbugs code: http://www.ics.uci.edu/~wjohnson/BIDA/BIDABook.html
Nonparametric Bayesian analysis in R These two links provide some R (and C) code examples of implementing a DP normal mixture: http://ice.uchicago.edu/2008_presentations/Rossi/density_estimation_with_DP_priors.ppt http://www.duke.edu/~n
16,509
Why not use evaluation metrics as the loss function?
Maximizing accuracy (percent of correctly examples) is the same as minimizing error rate (percent of incorrectly classified examples). For a single observation, the loss function for the error rate is always 1 (if the predicted class does not match the label) or 0 (if the predicted class matches the label). Accordingly, the derivative of this function is always 0 except at a negligible set of points where the derivative is infinite. This excludes any gradient-based optimizer from training a model, because the model parameters almost always have an update step size of 0, except for the countable number of times when the step size is infinite. Giving up gradient information is not a good trade, because gradient descent, Newton-Raphson and similar are very effective at finding solutions which also have high accuracies, even though accuracy was not optimized directly. Examples include neural-networks and logistic regression. Not all models are trained with gradient information. One prominent example is tree-induction methods such as random forest (however, not all trees are free of gradients; gradient-boosted trees use gradient information). These tree-based models search for good splits by optimizing some criterion, usually gini impurity, or information gain. While these models aren't optimized using gradient information, they also aren't optimized using accuracy. I suppose hypothetically you could use accuracy as a the split criterion.
Why not use evaluation metrics as the loss function?
Maximizing accuracy (percent of correctly examples) is the same as minimizing error rate (percent of incorrectly classified examples). For a single observation, the loss function for the error rate is
Why not use evaluation metrics as the loss function? Maximizing accuracy (percent of correctly examples) is the same as minimizing error rate (percent of incorrectly classified examples). For a single observation, the loss function for the error rate is always 1 (if the predicted class does not match the label) or 0 (if the predicted class matches the label). Accordingly, the derivative of this function is always 0 except at a negligible set of points where the derivative is infinite. This excludes any gradient-based optimizer from training a model, because the model parameters almost always have an update step size of 0, except for the countable number of times when the step size is infinite. Giving up gradient information is not a good trade, because gradient descent, Newton-Raphson and similar are very effective at finding solutions which also have high accuracies, even though accuracy was not optimized directly. Examples include neural-networks and logistic regression. Not all models are trained with gradient information. One prominent example is tree-induction methods such as random forest (however, not all trees are free of gradients; gradient-boosted trees use gradient information). These tree-based models search for good splits by optimizing some criterion, usually gini impurity, or information gain. While these models aren't optimized using gradient information, they also aren't optimized using accuracy. I suppose hypothetically you could use accuracy as a the split criterion.
Why not use evaluation metrics as the loss function? Maximizing accuracy (percent of correctly examples) is the same as minimizing error rate (percent of incorrectly classified examples). For a single observation, the loss function for the error rate is
16,510
Why not use evaluation metrics as the loss function?
It's because accuracy is not a proper scoring rule. You will want to consider the cost of misclassification. Here are some more useful links: Example when using accuracy as an outcome measure will lead to a wrong conclusion. Use of proper scoring rule when classification is required. The statistical part of prediction ends with outputting a distribution. And here the excellent posts by Frank Harrel: Classification vs. Prediction. Damage Caused by Classification Accuracy and Other Discontinuous Improper Accuracy Scoring Rules Here's a counter-example where using accuracy as loss function was actually better than using the Brier-score. You'll find that this answer is not definitive, and it depends on your actual problem if using evaluation metrics is a valid choice. I suppose it depends on the answer to the question "Does using a surrogate loss that also is a proper scoring rule reflect the learning goal of the problem well?"
Why not use evaluation metrics as the loss function?
It's because accuracy is not a proper scoring rule. You will want to consider the cost of misclassification. Here are some more useful links: Example when using accuracy as an outcome measure will le
Why not use evaluation metrics as the loss function? It's because accuracy is not a proper scoring rule. You will want to consider the cost of misclassification. Here are some more useful links: Example when using accuracy as an outcome measure will lead to a wrong conclusion. Use of proper scoring rule when classification is required. The statistical part of prediction ends with outputting a distribution. And here the excellent posts by Frank Harrel: Classification vs. Prediction. Damage Caused by Classification Accuracy and Other Discontinuous Improper Accuracy Scoring Rules Here's a counter-example where using accuracy as loss function was actually better than using the Brier-score. You'll find that this answer is not definitive, and it depends on your actual problem if using evaluation metrics is a valid choice. I suppose it depends on the answer to the question "Does using a surrogate loss that also is a proper scoring rule reflect the learning goal of the problem well?"
Why not use evaluation metrics as the loss function? It's because accuracy is not a proper scoring rule. You will want to consider the cost of misclassification. Here are some more useful links: Example when using accuracy as an outcome measure will le
16,511
Why is the limit of a Chi squared distribution a normal distribution?
This property follows from the central limit theorem, using the fact that the chi-squared distribution is obtained as the distribution of a sum of squares of independent standard normal random variables. If you have a sequence of random variables $Z_1,Z_2,Z_3, ... \sim \text{IID N}(0,1)$ then you have:$^\dagger$ $$\chi_p^2 \equiv \sum_{i=1}^p Z_i^2 \sim \text{ChiSq}(p).$$ Now, the random variables $Z_1^2,Z_2^2,Z_3^2, ... $ are IID with mean $\mathbb{E}(Z_i^2) = 1$ and variance $\mathbb{V}(Z_i^2) = 2 < \infty$, so we have $\mathbb{E}(\chi_p^2) = p$ and $\mathbb{V}(\chi_p^2) = 2p$. Applying the classical central limit theorem you get: $$\lim_{p \rightarrow \infty} \mathbb{P} \Bigg( \frac{\chi_p^2 - p}{\sqrt{2p}} \leqslant z \Bigg) = \Phi(z).$$ Another way of writing this formal limiting result is that: $$\frac{\chi_p^2 - p}{\sqrt{2p}} \overset{\text{Dist}}{\rightarrow} \text{N}(0, 1).$$ That is the formal convergence result that holds for the chi-squared distribution. Informally, for large $p \in \mathbb{N}$ we have the approximate distribution: $$\chi_p^2 \overset{\text{Approx}}{\rightarrow} \text{N}(p, 2p).$$ Though not strictly correct, sometimes this informal approximation is asserted as a kind of convergence result, informally referring to convergence where $p$ appears on both sides. (Or sometimes it is made strictly correct by adding an appropriate order term.) This is presumably what your professor was referring to. In regard to this property, it is worth noting that the gamma distribution converges to the normal as the scale parameter tends to infinity; the convergence of the chi-squared distribution to the normal is a special case of this broader convergence result. $^\dagger$ As a sidenote, one often proceeds more generally by writing: $$\chi_{p}^{2} = \sum_{i = 1}^{p} \bigg( \frac{X_i - \mu_{i}}{\sigma_{i}} \bigg)^2,$$ where the $X_{i} \sim \text{N}(\mu_i, \sigma_i)$ are independent Gaussian random variables with arbitrary mean and variance. By setting $Z_i \equiv (X_i - \mu_{i})/\sigma_{i}$, we can write the above formula using standardised versions of any independent normal random variables instead.
Why is the limit of a Chi squared distribution a normal distribution?
This property follows from the central limit theorem, using the fact that the chi-squared distribution is obtained as the distribution of a sum of squares of independent standard normal random variabl
Why is the limit of a Chi squared distribution a normal distribution? This property follows from the central limit theorem, using the fact that the chi-squared distribution is obtained as the distribution of a sum of squares of independent standard normal random variables. If you have a sequence of random variables $Z_1,Z_2,Z_3, ... \sim \text{IID N}(0,1)$ then you have:$^\dagger$ $$\chi_p^2 \equiv \sum_{i=1}^p Z_i^2 \sim \text{ChiSq}(p).$$ Now, the random variables $Z_1^2,Z_2^2,Z_3^2, ... $ are IID with mean $\mathbb{E}(Z_i^2) = 1$ and variance $\mathbb{V}(Z_i^2) = 2 < \infty$, so we have $\mathbb{E}(\chi_p^2) = p$ and $\mathbb{V}(\chi_p^2) = 2p$. Applying the classical central limit theorem you get: $$\lim_{p \rightarrow \infty} \mathbb{P} \Bigg( \frac{\chi_p^2 - p}{\sqrt{2p}} \leqslant z \Bigg) = \Phi(z).$$ Another way of writing this formal limiting result is that: $$\frac{\chi_p^2 - p}{\sqrt{2p}} \overset{\text{Dist}}{\rightarrow} \text{N}(0, 1).$$ That is the formal convergence result that holds for the chi-squared distribution. Informally, for large $p \in \mathbb{N}$ we have the approximate distribution: $$\chi_p^2 \overset{\text{Approx}}{\rightarrow} \text{N}(p, 2p).$$ Though not strictly correct, sometimes this informal approximation is asserted as a kind of convergence result, informally referring to convergence where $p$ appears on both sides. (Or sometimes it is made strictly correct by adding an appropriate order term.) This is presumably what your professor was referring to. In regard to this property, it is worth noting that the gamma distribution converges to the normal as the scale parameter tends to infinity; the convergence of the chi-squared distribution to the normal is a special case of this broader convergence result. $^\dagger$ As a sidenote, one often proceeds more generally by writing: $$\chi_{p}^{2} = \sum_{i = 1}^{p} \bigg( \frac{X_i - \mu_{i}}{\sigma_{i}} \bigg)^2,$$ where the $X_{i} \sim \text{N}(\mu_i, \sigma_i)$ are independent Gaussian random variables with arbitrary mean and variance. By setting $Z_i \equiv (X_i - \mu_{i})/\sigma_{i}$, we can write the above formula using standardised versions of any independent normal random variables instead.
Why is the limit of a Chi squared distribution a normal distribution? This property follows from the central limit theorem, using the fact that the chi-squared distribution is obtained as the distribution of a sum of squares of independent standard normal random variabl
16,512
Why is the limit of a Chi squared distribution a normal distribution?
I think I'm too late to the party, but I'm writing this answer only to find a way around the confusion caused by the appearance of $p$ on the left and the right sides, namely: in the terms of the chi-square distribution $\chi^2_p$ and the normal one $\mathcal{N}(p,2p),$ as pointed out in Ben's answer above. This point was raised in the OP and also commented upon by Dilip Sarwate in the comment section to the OP. Now here, one can still be interested in the difference of the two distributions$\chi^2_p$ and $\mathcal{N}(p,2p).$ Along this line, one can indeed guarantee here that: $$ lim_{p \to \infty}\| \Phi_{\chi^2_p} - \Phi_{\mathcal{N}(p,2p)} \|_{L^{\infty}(\mathbb{R})}=0 .....(0)$$ where $\Phi_X$ denotes the CDF of the random variable $X.$ Note the uniform convergence of the difference above to zero, which is really the key point I'm making. The proof is a one-step application of Berry-Eseén theorem, which translates to in our case as follows (check here that the hypothesis of this theorem is really true in our case!) $$ | \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(x) - \Phi_{\mathcal{N}(0,1)}(x) | \le \frac{C}{\sqrt{p}} \forall x \in \mathbb{R}.....(1) $$ where $C$ is independent of $p.$ Note that this is stronger than CLT in this case, as the bound on the right hand side is independent of $x \in \mathbb{R},$ meaning the convergence of the difference between the two CDF's is uniform,which is not necessarily the case for convergence in distribution, as it's a pointwise convergence of the CDF's at the point of continuity of the limit CDF. Note that, the uniformity w.r.t. $x$ also implies: $$ | \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(\frac{x-p}{\sqrt{2p}}) - \Phi_{\mathcal{N}(0,1)}(\frac{x-p}{\sqrt{2p}}) | \le \frac{C}{\sqrt{p}} \forall x \in \mathbb{R}.....(2) $$ Next, if we use the fact that $\forall a > 0,$ $$\Phi_{aX + b}(x) = \Phi_X(\frac{x-a}{b}) $$ $$\implies \Phi_{\chi^2_p}(x) = \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(\frac{x-p}{\sqrt{2p}}) , .....(3)$$ and similarly: $$\Phi_{\mathcal{N}(p,2p)} = \Phi_{\mathcal{N}(0,1)}(\frac{x-p}{\sqrt{2p}}) .....(4)$$ Now the equations (1), (3) and (4) collectively implies the equation (0). This proves that even if the d.f. $p \to \infty,$ the difference between the CDF's of $\chi^2_p$ and $\mathcal{N}(p,2p)$ indeed goes to zero. N.B. to answer your question, we only used the fact the pointwise difference between the two CDF's in (1) is independent of the point $x$ and goes to zero as $p\to \infty,$ i.e. the convergence of the CDF's is uniform; we didn't really use the fact that the rate of convergence is $O(\frac{1}{\sqrt{p}}).$ I hope this helps!
Why is the limit of a Chi squared distribution a normal distribution?
I think I'm too late to the party, but I'm writing this answer only to find a way around the confusion caused by the appearance of $p$ on the left and the right sides, namely: in the terms of the chi-
Why is the limit of a Chi squared distribution a normal distribution? I think I'm too late to the party, but I'm writing this answer only to find a way around the confusion caused by the appearance of $p$ on the left and the right sides, namely: in the terms of the chi-square distribution $\chi^2_p$ and the normal one $\mathcal{N}(p,2p),$ as pointed out in Ben's answer above. This point was raised in the OP and also commented upon by Dilip Sarwate in the comment section to the OP. Now here, one can still be interested in the difference of the two distributions$\chi^2_p$ and $\mathcal{N}(p,2p).$ Along this line, one can indeed guarantee here that: $$ lim_{p \to \infty}\| \Phi_{\chi^2_p} - \Phi_{\mathcal{N}(p,2p)} \|_{L^{\infty}(\mathbb{R})}=0 .....(0)$$ where $\Phi_X$ denotes the CDF of the random variable $X.$ Note the uniform convergence of the difference above to zero, which is really the key point I'm making. The proof is a one-step application of Berry-Eseén theorem, which translates to in our case as follows (check here that the hypothesis of this theorem is really true in our case!) $$ | \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(x) - \Phi_{\mathcal{N}(0,1)}(x) | \le \frac{C}{\sqrt{p}} \forall x \in \mathbb{R}.....(1) $$ where $C$ is independent of $p.$ Note that this is stronger than CLT in this case, as the bound on the right hand side is independent of $x \in \mathbb{R},$ meaning the convergence of the difference between the two CDF's is uniform,which is not necessarily the case for convergence in distribution, as it's a pointwise convergence of the CDF's at the point of continuity of the limit CDF. Note that, the uniformity w.r.t. $x$ also implies: $$ | \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(\frac{x-p}{\sqrt{2p}}) - \Phi_{\mathcal{N}(0,1)}(\frac{x-p}{\sqrt{2p}}) | \le \frac{C}{\sqrt{p}} \forall x \in \mathbb{R}.....(2) $$ Next, if we use the fact that $\forall a > 0,$ $$\Phi_{aX + b}(x) = \Phi_X(\frac{x-a}{b}) $$ $$\implies \Phi_{\chi^2_p}(x) = \Phi_{\frac{\chi^2_p - p}{\sqrt{2p}}}(\frac{x-p}{\sqrt{2p}}) , .....(3)$$ and similarly: $$\Phi_{\mathcal{N}(p,2p)} = \Phi_{\mathcal{N}(0,1)}(\frac{x-p}{\sqrt{2p}}) .....(4)$$ Now the equations (1), (3) and (4) collectively implies the equation (0). This proves that even if the d.f. $p \to \infty,$ the difference between the CDF's of $\chi^2_p$ and $\mathcal{N}(p,2p)$ indeed goes to zero. N.B. to answer your question, we only used the fact the pointwise difference between the two CDF's in (1) is independent of the point $x$ and goes to zero as $p\to \infty,$ i.e. the convergence of the CDF's is uniform; we didn't really use the fact that the rate of convergence is $O(\frac{1}{\sqrt{p}}).$ I hope this helps!
Why is the limit of a Chi squared distribution a normal distribution? I think I'm too late to the party, but I'm writing this answer only to find a way around the confusion caused by the appearance of $p$ on the left and the right sides, namely: in the terms of the chi-
16,513
the relationship between maximizing the likelihood and minimizing the cross-entropy
Here's a worked example in the case of iid binary data, each with a success/failure recorded as $y_i \in \{0,1\}$. For labels $y_i\in \{0,1\}$, the likelihood of some binary data under the Bernoulli model with parameters $\theta$ is $$ \mathcal{L}(\theta) = \prod_{i=1}^n p(y_i=1|\theta)^{y_i}p(y_i=0|\theta)^{1-y_i}\\ $$ whereas the log-likelihood is $$ \log\mathcal{L}(\theta) = \sum_{i=1}^n y_i\log p(y=1|\theta) + (1-y_i)\log p(y=0|\theta) $$ And the binary cross-entropy is $$ L(\theta) = -\frac{1}{n}\sum_{i=1}^n y_i\log p(y=1|\theta) + (1-y_i)\log p(y=0|\theta) $$ Clearly, $ \log \mathcal{L}(\theta) = -nL(\theta) $. We know that an optimal parameter vector $\theta^*$ is the same for both because we can observe that for any $\theta$ which is not optimal, we have $\frac{1}{n} L(\theta) > \frac{1}{n} L(\theta^*)$, which holds for any $\frac{1}{n} > 0$. (Remember, we want to minimize cross-entropy, so the optimal $\theta^*$ has the least $L(\theta^*)$.) Likewise, we know that the optimal value $\theta^*$ is the same for $\log \mathcal{L}(\theta)$ and $ \mathcal{L}(\theta)$ because $\log(x)$ is a monotonic increasing function for $x \in \mathbb{R}^+$, so we can write $\log \mathcal{L}(\theta) < \log\mathcal{L}(\theta^*)$. (Remember, we want to maximize the likelihood, so the optimal $\theta^*$ has the most $\mathcal{L}(\theta^*)$.) Some sources omit the $\frac{1}{n}$ from the cross-entropy. Clearly, this only changes the value of $L(\theta)$, but not the location of the optima, so from an optimization perspective the distinction is not important. The negative sign, however, is obviously important since it is the difference between maximizing and minimizing! Some more additional examples and more general result can be found in this related thread: How to construct a cross-entropy loss for general regression targets?
the relationship between maximizing the likelihood and minimizing the cross-entropy
Here's a worked example in the case of iid binary data, each with a success/failure recorded as $y_i \in \{0,1\}$. For labels $y_i\in \{0,1\}$, the likelihood of some binary data under the Bernoulli
the relationship between maximizing the likelihood and minimizing the cross-entropy Here's a worked example in the case of iid binary data, each with a success/failure recorded as $y_i \in \{0,1\}$. For labels $y_i\in \{0,1\}$, the likelihood of some binary data under the Bernoulli model with parameters $\theta$ is $$ \mathcal{L}(\theta) = \prod_{i=1}^n p(y_i=1|\theta)^{y_i}p(y_i=0|\theta)^{1-y_i}\\ $$ whereas the log-likelihood is $$ \log\mathcal{L}(\theta) = \sum_{i=1}^n y_i\log p(y=1|\theta) + (1-y_i)\log p(y=0|\theta) $$ And the binary cross-entropy is $$ L(\theta) = -\frac{1}{n}\sum_{i=1}^n y_i\log p(y=1|\theta) + (1-y_i)\log p(y=0|\theta) $$ Clearly, $ \log \mathcal{L}(\theta) = -nL(\theta) $. We know that an optimal parameter vector $\theta^*$ is the same for both because we can observe that for any $\theta$ which is not optimal, we have $\frac{1}{n} L(\theta) > \frac{1}{n} L(\theta^*)$, which holds for any $\frac{1}{n} > 0$. (Remember, we want to minimize cross-entropy, so the optimal $\theta^*$ has the least $L(\theta^*)$.) Likewise, we know that the optimal value $\theta^*$ is the same for $\log \mathcal{L}(\theta)$ and $ \mathcal{L}(\theta)$ because $\log(x)$ is a monotonic increasing function for $x \in \mathbb{R}^+$, so we can write $\log \mathcal{L}(\theta) < \log\mathcal{L}(\theta^*)$. (Remember, we want to maximize the likelihood, so the optimal $\theta^*$ has the most $\mathcal{L}(\theta^*)$.) Some sources omit the $\frac{1}{n}$ from the cross-entropy. Clearly, this only changes the value of $L(\theta)$, but not the location of the optima, so from an optimization perspective the distinction is not important. The negative sign, however, is obviously important since it is the difference between maximizing and minimizing! Some more additional examples and more general result can be found in this related thread: How to construct a cross-entropy loss for general regression targets?
the relationship between maximizing the likelihood and minimizing the cross-entropy Here's a worked example in the case of iid binary data, each with a success/failure recorded as $y_i \in \{0,1\}$. For labels $y_i\in \{0,1\}$, the likelihood of some binary data under the Bernoulli
16,514
High-dimensional regression: why is $\log p/n$ special?
(Moved from comments to an answer as requested by @Greenparker) Part 1) The $\sqrt{\log p}$ term comes from (Gaussian) concentration of measure. In particular, if you have $p$ IID Gaussian random variables[F1], their maximum is on the order of $\sigma\sqrt{\log p}$ with high probability. The $n^{-1}$ factor just comes fact you are looking at average prediction error - i.e., it matches the $n^{-1}$ on the other side - if you looked at total error, it wouldn't be there. Part 2) Essentially, you have two forces you need to control: i) the good properties of having more data (so we want $n$ to be big); ii) the difficulties have having more (irrelevant) features (so we want $p$ to be small). In classical statistics, we typically fix $p$ and let $n$ go to infinity: this regime is not super useful for high-dimensional theory because it is (asymptotically) in the low-dimensional regime by construction. Alternatively, we could let $p$ go to infinity and $n$ stay fixed, but then our error just blows up as the problem becomes essentially impossible. Depending on the problem, the error may go to infinity or stop at some natural upper bound (e.g., 100% misclassification error). Since both of these cases are a bit useless, we instead consider $n, p$ both going to infinity so that our theory is both relevant (stays high-dimensional) without being apocalyptic (infinite features, finite data). Having two "knobs" is generally harder than having a single knob, so we fix $p=f(n)$ for some fixed $f$ and let $n$ go to infinity (and hence $p$ goes to infinity indirectly).[F2] The choice of $f$ determines the behavior of the problem. For reasons in my answer to part 1, it turns out that the "badness" from the extra features only grows as $\log p$ while the "goodness" from the extra data grows as $n$. If $\frac{\log p}{n}$ stays constant (equivalently, $p=f(n)=Θ(C^n)$ for some $C$), we tread water and the problem is a wash (error stays fixed asymptotically); if $\frac{\log p}{n} \to 0$ ($p=o(C^n)$) we asymptotically achieve zero error; and if $\frac{\log p}{n}→\infty$ ($p=\omega(C^n)$), the error eventually goes to infinity. This last regime is sometimes called "ultra-high-dimensional" in the literature. The term "ultra-high-dimensional" doesn't have a rigorous definition as far as I know, but it's informally just "the regime that breaks the lasso and similar estimators." We can demonstrate this with a small simulation study under fairly idealized conditions. Here we take theoretical guidance on the optimal choice of $\lambda$ from [BRT09] and pick $\lambda = 3 \sqrt{\log(p)/n}$. First consider a case where $p = f(n) = 3n$. This is in the 'tractable' high-dimensional regime described above and, as theory predicts, we see the prediction error converge to zero: Code to reproduce: library(glmnet) library(ggplot2) # Standard High-Dimensional Asymptotics: log(p) / n -> 0 N <- c(50, 100, 200, 400, 600, 800, 1000, 1100, 1200, 1300) P <- 3 * N ERROR_HD <- data.frame() for(ix in seq_along(N)){ n <- N[ix] p <- P[ix] PMSE <- replicate(20, { X <- matrix(rnorm(n * p), ncol=p) beta <- rep(0, p) beta[1:10] <- runif(10, 2, 3) y <- X %*% beta + rnorm(n) g <- glmnet(X, y) ## Cf. Theorem 7.2 of Bickel et al. AOS 37(4), p.1705-1732, 2009. ## lambda ~ 2*\sqrt{2} * \sqrt{\log(p)/n} ## is good scaling for controlling prediction error of the lasso err <- X %*% beta - predict(g, newx=X, s=3 * sqrt(log(p)/n)) mean(err^2) }) ERROR_HD <- rbind(ERROR_HD, data.frame(PMSE=PMSE, n=n, p=p)) } ggplot(ERROR_HD, aes(x=n, y=PMSE)) + geom_point() + theme_bw() + xlab("Number of Samples (n)") + ylab("Mean Prediction Error (at observed design points)") + ggtitle("Prediction Error Converging to 0 under High-Dim Asymptotics") + scale_x_continuous(sec.axis = sec_axis(~ 3 * ., name="Number of Features (p)")) + scale_y_log10() We can compare this to the case where $\frac{\log p}{n}$ stays approximately constant: I call this the "borderline" ultra-high-dimensional regime, but that's not a standard term: P <- 10 + ceiling(exp(N/120)) Here we see that the prediction error (using the same design as above) levels off instead of continuing to zero. If we set $P$ to grow faster than $e^n$, (e.g., $e^{n^2}$), the prediction error increases without bound. These $e^{n^2}$ is ludicrously fast and leads to enormous problems / numerical problems, so here's a slightly slower, but still UHD example: P <- 10 + ceiling(exp(N^(1.03)/120)) (I used a sparse random $X$ for speed, so don't try to compare the numbers with the other plots directly) It's hard to see any uptick in this graph, perhaps because we kept the UHD growth from being too "ultra" in the name of computational time. Using a larger exponent (like $e^{n^1.5}$) would make the asymptotic growth a bit clearer. Despite what I said above and how it may appear, the ultra-high-dimensional regime is not actually completely hopeless (though it's close), but it requires much more sophisticated techniques than just a simple max of Gaussian random variables to control the error. The need to use these complex techniques is the ultimate source of the complexity you note. There's no particular reason to think that $p, n$ should grow "together" in any way (i.e., there's not an obvious "real-world" reason to fix $p = f(n)$), but math generally lacks language and tools for discussing limits with two "degrees of freedom" so it's the best we can do (for now!). Part 3) I'm afraid I don't know any books in the statistical literature that really focus on the growth of $\log p$ vs $n$ explicitly. (There may be something in the compressive sensing literature) My current favorite reference for this kind of theory is Chapters 10 and 11 of Statistical Learning with Sparsity [F3] but it generally takes the approach of considering $n, p$ fixed and giving finite-sample (non-asymptotic) properties of getting a "good" result. This is actually a more powerful approach - once you have the result for any $n, p$, it's easy to consider the asymptotics - but these results are generally harder to derive, so we currently only have them for lasso-type estimators as far as I know. If you're comfortable and willing to delve into research literature, I'd look at works by Jianqing Fan and Jinchi Lv, who have done most of the foundational work on ultra-high-dimensional problems. ("Screening" is a good term to search on) [F1] Actually, any subgaussian random variable, but this doesn't add that much to this discussion. [F2] We might also set the "true" sparsity $s$ to depend on $n$ ($s = g(n)$) but that doesn't change things too much. [F3] T. Hastie, R. Tibshirani, and M. Wainwright. Statistical Learning with Sparsity. Monographs on Statistics and Applied Probability 143. CRC Press, 2015. Available at for free download at https://web.stanford.edu/~hastie/StatLearnSparsity_files/SLS.pdf [BRT] Peter J. Bickel, Ya'acov Ritov, and Alexandre B. Tsybakov. "Simultaneous Analysis of Lasso and Dantzig Selector." Annals of Statistics 37(4), p. 1705-1732, 2009. http://dx.doi.org/10.1214/08-AOS620
High-dimensional regression: why is $\log p/n$ special?
(Moved from comments to an answer as requested by @Greenparker) Part 1) The $\sqrt{\log p}$ term comes from (Gaussian) concentration of measure. In particular, if you have $p$ IID Gaussian random var
High-dimensional regression: why is $\log p/n$ special? (Moved from comments to an answer as requested by @Greenparker) Part 1) The $\sqrt{\log p}$ term comes from (Gaussian) concentration of measure. In particular, if you have $p$ IID Gaussian random variables[F1], their maximum is on the order of $\sigma\sqrt{\log p}$ with high probability. The $n^{-1}$ factor just comes fact you are looking at average prediction error - i.e., it matches the $n^{-1}$ on the other side - if you looked at total error, it wouldn't be there. Part 2) Essentially, you have two forces you need to control: i) the good properties of having more data (so we want $n$ to be big); ii) the difficulties have having more (irrelevant) features (so we want $p$ to be small). In classical statistics, we typically fix $p$ and let $n$ go to infinity: this regime is not super useful for high-dimensional theory because it is (asymptotically) in the low-dimensional regime by construction. Alternatively, we could let $p$ go to infinity and $n$ stay fixed, but then our error just blows up as the problem becomes essentially impossible. Depending on the problem, the error may go to infinity or stop at some natural upper bound (e.g., 100% misclassification error). Since both of these cases are a bit useless, we instead consider $n, p$ both going to infinity so that our theory is both relevant (stays high-dimensional) without being apocalyptic (infinite features, finite data). Having two "knobs" is generally harder than having a single knob, so we fix $p=f(n)$ for some fixed $f$ and let $n$ go to infinity (and hence $p$ goes to infinity indirectly).[F2] The choice of $f$ determines the behavior of the problem. For reasons in my answer to part 1, it turns out that the "badness" from the extra features only grows as $\log p$ while the "goodness" from the extra data grows as $n$. If $\frac{\log p}{n}$ stays constant (equivalently, $p=f(n)=Θ(C^n)$ for some $C$), we tread water and the problem is a wash (error stays fixed asymptotically); if $\frac{\log p}{n} \to 0$ ($p=o(C^n)$) we asymptotically achieve zero error; and if $\frac{\log p}{n}→\infty$ ($p=\omega(C^n)$), the error eventually goes to infinity. This last regime is sometimes called "ultra-high-dimensional" in the literature. The term "ultra-high-dimensional" doesn't have a rigorous definition as far as I know, but it's informally just "the regime that breaks the lasso and similar estimators." We can demonstrate this with a small simulation study under fairly idealized conditions. Here we take theoretical guidance on the optimal choice of $\lambda$ from [BRT09] and pick $\lambda = 3 \sqrt{\log(p)/n}$. First consider a case where $p = f(n) = 3n$. This is in the 'tractable' high-dimensional regime described above and, as theory predicts, we see the prediction error converge to zero: Code to reproduce: library(glmnet) library(ggplot2) # Standard High-Dimensional Asymptotics: log(p) / n -> 0 N <- c(50, 100, 200, 400, 600, 800, 1000, 1100, 1200, 1300) P <- 3 * N ERROR_HD <- data.frame() for(ix in seq_along(N)){ n <- N[ix] p <- P[ix] PMSE <- replicate(20, { X <- matrix(rnorm(n * p), ncol=p) beta <- rep(0, p) beta[1:10] <- runif(10, 2, 3) y <- X %*% beta + rnorm(n) g <- glmnet(X, y) ## Cf. Theorem 7.2 of Bickel et al. AOS 37(4), p.1705-1732, 2009. ## lambda ~ 2*\sqrt{2} * \sqrt{\log(p)/n} ## is good scaling for controlling prediction error of the lasso err <- X %*% beta - predict(g, newx=X, s=3 * sqrt(log(p)/n)) mean(err^2) }) ERROR_HD <- rbind(ERROR_HD, data.frame(PMSE=PMSE, n=n, p=p)) } ggplot(ERROR_HD, aes(x=n, y=PMSE)) + geom_point() + theme_bw() + xlab("Number of Samples (n)") + ylab("Mean Prediction Error (at observed design points)") + ggtitle("Prediction Error Converging to 0 under High-Dim Asymptotics") + scale_x_continuous(sec.axis = sec_axis(~ 3 * ., name="Number of Features (p)")) + scale_y_log10() We can compare this to the case where $\frac{\log p}{n}$ stays approximately constant: I call this the "borderline" ultra-high-dimensional regime, but that's not a standard term: P <- 10 + ceiling(exp(N/120)) Here we see that the prediction error (using the same design as above) levels off instead of continuing to zero. If we set $P$ to grow faster than $e^n$, (e.g., $e^{n^2}$), the prediction error increases without bound. These $e^{n^2}$ is ludicrously fast and leads to enormous problems / numerical problems, so here's a slightly slower, but still UHD example: P <- 10 + ceiling(exp(N^(1.03)/120)) (I used a sparse random $X$ for speed, so don't try to compare the numbers with the other plots directly) It's hard to see any uptick in this graph, perhaps because we kept the UHD growth from being too "ultra" in the name of computational time. Using a larger exponent (like $e^{n^1.5}$) would make the asymptotic growth a bit clearer. Despite what I said above and how it may appear, the ultra-high-dimensional regime is not actually completely hopeless (though it's close), but it requires much more sophisticated techniques than just a simple max of Gaussian random variables to control the error. The need to use these complex techniques is the ultimate source of the complexity you note. There's no particular reason to think that $p, n$ should grow "together" in any way (i.e., there's not an obvious "real-world" reason to fix $p = f(n)$), but math generally lacks language and tools for discussing limits with two "degrees of freedom" so it's the best we can do (for now!). Part 3) I'm afraid I don't know any books in the statistical literature that really focus on the growth of $\log p$ vs $n$ explicitly. (There may be something in the compressive sensing literature) My current favorite reference for this kind of theory is Chapters 10 and 11 of Statistical Learning with Sparsity [F3] but it generally takes the approach of considering $n, p$ fixed and giving finite-sample (non-asymptotic) properties of getting a "good" result. This is actually a more powerful approach - once you have the result for any $n, p$, it's easy to consider the asymptotics - but these results are generally harder to derive, so we currently only have them for lasso-type estimators as far as I know. If you're comfortable and willing to delve into research literature, I'd look at works by Jianqing Fan and Jinchi Lv, who have done most of the foundational work on ultra-high-dimensional problems. ("Screening" is a good term to search on) [F1] Actually, any subgaussian random variable, but this doesn't add that much to this discussion. [F2] We might also set the "true" sparsity $s$ to depend on $n$ ($s = g(n)$) but that doesn't change things too much. [F3] T. Hastie, R. Tibshirani, and M. Wainwright. Statistical Learning with Sparsity. Monographs on Statistics and Applied Probability 143. CRC Press, 2015. Available at for free download at https://web.stanford.edu/~hastie/StatLearnSparsity_files/SLS.pdf [BRT] Peter J. Bickel, Ya'acov Ritov, and Alexandre B. Tsybakov. "Simultaneous Analysis of Lasso and Dantzig Selector." Annals of Statistics 37(4), p. 1705-1732, 2009. http://dx.doi.org/10.1214/08-AOS620
High-dimensional regression: why is $\log p/n$ special? (Moved from comments to an answer as requested by @Greenparker) Part 1) The $\sqrt{\log p}$ term comes from (Gaussian) concentration of measure. In particular, if you have $p$ IID Gaussian random var
16,515
When is it inappropriate to control for a variable?
Conditioning (i.e. adjusting) the probabilities of some outcome given some predictor on third variables is widely practiced, but as you rightly point out, may actually introduce bias into the resulting estimate as a representation of causal effects. This can even happen with "classical" definitions of a potential causal confounder, because both the confounder itself, and the predictor of interest may each have further causal confounders upstream. In the DAG below, for example, $L$ is a classic confounder of the causal effect of $E$ on $D$, because (1) it causes and is therefore associated with $E$, and (2) is associated with $D$ since it is associated with $U_{2}$ which is associated with $D$. However, either conditioning or stratifying $P(D|E)$ on $L$ (a "collider") will produce biased causal estimates of the effect of $E$ on $D$ because $L$ is confounded with $D$ by the unmeasured variable $U_{2}$, and $L$ is confounded with $E$ by the unmeasured variable $U_{1}$. Understanding which variables to condition or stratify one's analysis on to provide an unbiased causal estimate requires careful consideration of the possible DAGs using the criteria for causal effect identifiability—no common causes that are not blocked by backdoor paths—described by Pearl, Robins, and others. There are no shortcuts. Learn common confounding patterns. Learn common selection bias patterns. Practice. References Greenland, S., Pearl, J., and Robins, J. M. (1999). Causal diagrams for epidemiologic research. Epidemiology, 10(1):37–48. Hernán, M. A. and Robins, J. M. (2018). Causal Inference. Chapman & Hall/CRC, Boca Raton, FL Maldonado, G. and Greenland, S. (2002). Estimating causal effects. International Journal of Epidemiology, 31(2):422–438. Pearl, J. (2000). Causality: Models, Reasoning, and Inference. Cambridge University Press.
When is it inappropriate to control for a variable?
Conditioning (i.e. adjusting) the probabilities of some outcome given some predictor on third variables is widely practiced, but as you rightly point out, may actually introduce bias into the resultin
When is it inappropriate to control for a variable? Conditioning (i.e. adjusting) the probabilities of some outcome given some predictor on third variables is widely practiced, but as you rightly point out, may actually introduce bias into the resulting estimate as a representation of causal effects. This can even happen with "classical" definitions of a potential causal confounder, because both the confounder itself, and the predictor of interest may each have further causal confounders upstream. In the DAG below, for example, $L$ is a classic confounder of the causal effect of $E$ on $D$, because (1) it causes and is therefore associated with $E$, and (2) is associated with $D$ since it is associated with $U_{2}$ which is associated with $D$. However, either conditioning or stratifying $P(D|E)$ on $L$ (a "collider") will produce biased causal estimates of the effect of $E$ on $D$ because $L$ is confounded with $D$ by the unmeasured variable $U_{2}$, and $L$ is confounded with $E$ by the unmeasured variable $U_{1}$. Understanding which variables to condition or stratify one's analysis on to provide an unbiased causal estimate requires careful consideration of the possible DAGs using the criteria for causal effect identifiability—no common causes that are not blocked by backdoor paths—described by Pearl, Robins, and others. There are no shortcuts. Learn common confounding patterns. Learn common selection bias patterns. Practice. References Greenland, S., Pearl, J., and Robins, J. M. (1999). Causal diagrams for epidemiologic research. Epidemiology, 10(1):37–48. Hernán, M. A. and Robins, J. M. (2018). Causal Inference. Chapman & Hall/CRC, Boca Raton, FL Maldonado, G. and Greenland, S. (2002). Estimating causal effects. International Journal of Epidemiology, 31(2):422–438. Pearl, J. (2000). Causality: Models, Reasoning, and Inference. Cambridge University Press.
When is it inappropriate to control for a variable? Conditioning (i.e. adjusting) the probabilities of some outcome given some predictor on third variables is widely practiced, but as you rightly point out, may actually introduce bias into the resultin
16,516
When is it inappropriate to control for a variable?
I believe the quick one-sentence answer to your question, When is it appropriate to control for variable Y and when not? is the "back-door criterion". Judea Pearl's Structural Causal Model can tell you definitively which variables are sufficient (and when it's necessary) for conditioning, to infer the causal impact of one variable on another. Namely, this is answered using the back-door criterion, which is described in page 19 of this review paper by Pearl. The major caveat is that it requires you to know the causal relationship between the variables (in the form of directional arrows in a graph). There's no way around that. This is where the difficulty and possible subjectivity can come into play. Pearl's structural causal model only allows you to know how to answer the right questions given a causal model (i.e. directed graph), which set of causal models are possible given a data distribution, or how to look for causal structure by performing the right experiment. It doesn't tell you how to find the right causal structure given only the data distribution. In fact, it claims that this is impossible without using external knowledge/intuition about the meaning of the variables. The back-door criteria can be stated as follows: To find the causal impact of $X$ on $Y,$ a set of variable nodes $S$ is sufficient to be conditioned on as long as it satisfies both of the following criteria: 1) No elements in $S$ is a descendant of $X$ 2) $S$ blocks all "back-door" paths between $X$ and $Y$ Here, a "back-door" path is simply a path of arrows that begin at $Y$ and end with an arrow pointing at $X.$ (The direction that all other arrows point is not important.) And "blocking" is, itself, a criterion that has a specific meaning, which is given in page 11 of the above link. This is the same criterion that you would read when learning about "D-separation". I personally found that chapter 8 of Bishop's Pattern Recognition and Machine Learning describes the concept of blocking in D-separation far better than the Pearl source I linked above. But it goes like this: A set of nodes, $S,$ blocks a path between $X$ and $Y$ if it satisfies at least one of the following criteria: 1) One of the nodes in the path, that is also in $S,$ emits at least one arrow on the path (i.e. the arrow is pointing away from the node) 2) A node that is neither in $S$ nor an ancestor of a node in $S$ has two arrows in the path "colliding" towards it (i.e. meeting it head-to-head) This is an or criterion, unlike the general back-door criterion which is an and criterion. To be clear about the back-door criterion, what it tells you is that, for a given causal model, when conditioning on a sufficient variable, you can learn the causal impact from the probability distribution of the data. (As we know, the joint distribution alone isn't sufficient for finding causal behavior because multiple causal structures can be responsible for the same distribution. This is why the causal model is required as well.) The distribution can be estimated using ordinary statistical/machine learning methods on the observational data. So as long as you know that the causal structure allows for conditioning on a variable (or set of variables), your estimate of the causal impact of one variable on another is as good as your estimate of the distribution of the data, which you obtain through statistical methods. Here is what we find when we apply the back-door criterion to your two diagrams: In neither case does there exist a back-door path from $Z$ to $X.$ So it's true that $Y$ blocks "all" back-door paths, because there aren't any. However, in the left diagram, $Y$ is a direct descendant of $X,$ while in the right diagram it is not. Therefore $Y$ follows the back-door criterion in the right diagram, but not the left. These are unsurprising results. What is surprising, however, is that in the right diagram, as long as it is the complete picture, you need not condition on $Y$ to get the full causal impact of $X$ on $Z$. (Said another way, the null set satisfies the back-door criteria, and is thus, sufficient for conditioning.) Intuitively this is true because the value of $X$ is not associated with that of $Y$ so for sufficient data you can simply average over the values of $Y$ to marginalize the effect of $Y$ on $Z.$ One objection to this point can be that the data is limited, so you don't have a representative distribution of $Y$ values. But recall that the back-door criterion assumes you have the probability distribution of the data. In that case you can analytically marginalize $Y.$ Marginalization over a finite data set is just an estimation. Also, note that it's highly unlikely that this is the complete picture. There are likely external factors that impact $X.$ If those factors are also associated with $Y$ in any way, then more work must be done to see if $Y$ must be conditioned on, or if it's even sufficient. If you draw another arrow pointing from $Y$ to $X$ then $Y$ becomes necessary to control. Those are, of course, very simple examples where intuition is enough to know when $Y$ can or cannot be controlled for. But here's a couple more examples where it's not obvious by looking at the diagram, and you can use the back-door criteria. For the following diagram we ask if it is sufficient to control for $Y$ when determining the causal impact of $X$ on $Z.$ The first thing to note is that, in both cases, $Y$ is not a descendant of $X.$ So it passes that criterion. The next thing to note is that, in both cases, there are several backdoor paths from $Z$ to $X.$ Two in the left diagram and three in the right. In the left diagram the backdoor paths are $Z \leftarrow Y \rightarrow X$ and $Z \leftarrow W \rightarrow B \leftarrow A \rightarrow X. \hspace{1mm}$ $Y$ blocks the first path because it is an arrow-emitting node that is directly in the path. $Y$ also blocks the second path because it is neither $B,$ nor is it a descendant of $B,$ which is the only arrow colliding node in the path. Therefore $Y$ is a sufficient set for conditioning. (Note, unlike in your right diagram, the null set is not sufficient for conditioning, because it does not block the path $Z \leftarrow Y \rightarrow X$.) In the right diagram the backdoor paths are the same two as in the left, plus the path $Z \leftarrow W \rightarrow B \rightarrow Y \rightarrow X. \hspace{1mm}$ $Y$ does block this path, because it is an arrow emitting node in the path. It also blocks the path $Z \leftarrow Y \rightarrow X$ for the same reason as the left diagram. However, it does not block the path $Z \leftarrow W \rightarrow B \leftarrow A \rightarrow X,$ because it is a direct descendant of the collider node $B.$ Therefore it is not sufficient for conditioning. It is pretty unintuitive to see why $Y$ is sufficient for conditioning on the left diagram, because of the exogenous variables $A$ and $W$ that affect $X$ and $Z$ respectively. However, suppose there was no $B.$ In that case, there would be no spurious relationship between $X$ and $Z$ due to these exogenous variables so they're not of concern. The existence of $B,$ however, puts that in question. If $B$ is allowed to take whatever value it naturally takes given $A$ and $W$, it would not be a problem because it does not have any impact on the important variables, or the exogenous variables determining them. However, if $B$ (or any of its descendants) is controlled then it actually renders $A$ and $W$ dependent, which creates the spurious relationship beteween $X$ and $Z$ that we don't want. As mentioned in the linked source, this is an example of Berkson's paradox, where an observation of a variable caused by two independent sources makes those sources dependent (e.g. the result of two independent coin flips is rendered dependent upon the observation of the number of total heads flipped). As I mentioned before the use of the back-door criterion requires that you know the causal model (i.e. the "correct" diagram of arrows between the variables). But the Structural Causal Model, in my opinion, also gives the best and most formal way to search for such a model, or to know when the search is futile. It also has the wonderful side effect of rendering terms like "confounding", "mediation", and "spurious" (all of which confuse me) obsolete. Just show me the picture and I'll tell you which circles ought to be controlled.
When is it inappropriate to control for a variable?
I believe the quick one-sentence answer to your question, When is it appropriate to control for variable Y and when not? is the "back-door criterion". Judea Pearl's Structural Causal Model can tell
When is it inappropriate to control for a variable? I believe the quick one-sentence answer to your question, When is it appropriate to control for variable Y and when not? is the "back-door criterion". Judea Pearl's Structural Causal Model can tell you definitively which variables are sufficient (and when it's necessary) for conditioning, to infer the causal impact of one variable on another. Namely, this is answered using the back-door criterion, which is described in page 19 of this review paper by Pearl. The major caveat is that it requires you to know the causal relationship between the variables (in the form of directional arrows in a graph). There's no way around that. This is where the difficulty and possible subjectivity can come into play. Pearl's structural causal model only allows you to know how to answer the right questions given a causal model (i.e. directed graph), which set of causal models are possible given a data distribution, or how to look for causal structure by performing the right experiment. It doesn't tell you how to find the right causal structure given only the data distribution. In fact, it claims that this is impossible without using external knowledge/intuition about the meaning of the variables. The back-door criteria can be stated as follows: To find the causal impact of $X$ on $Y,$ a set of variable nodes $S$ is sufficient to be conditioned on as long as it satisfies both of the following criteria: 1) No elements in $S$ is a descendant of $X$ 2) $S$ blocks all "back-door" paths between $X$ and $Y$ Here, a "back-door" path is simply a path of arrows that begin at $Y$ and end with an arrow pointing at $X.$ (The direction that all other arrows point is not important.) And "blocking" is, itself, a criterion that has a specific meaning, which is given in page 11 of the above link. This is the same criterion that you would read when learning about "D-separation". I personally found that chapter 8 of Bishop's Pattern Recognition and Machine Learning describes the concept of blocking in D-separation far better than the Pearl source I linked above. But it goes like this: A set of nodes, $S,$ blocks a path between $X$ and $Y$ if it satisfies at least one of the following criteria: 1) One of the nodes in the path, that is also in $S,$ emits at least one arrow on the path (i.e. the arrow is pointing away from the node) 2) A node that is neither in $S$ nor an ancestor of a node in $S$ has two arrows in the path "colliding" towards it (i.e. meeting it head-to-head) This is an or criterion, unlike the general back-door criterion which is an and criterion. To be clear about the back-door criterion, what it tells you is that, for a given causal model, when conditioning on a sufficient variable, you can learn the causal impact from the probability distribution of the data. (As we know, the joint distribution alone isn't sufficient for finding causal behavior because multiple causal structures can be responsible for the same distribution. This is why the causal model is required as well.) The distribution can be estimated using ordinary statistical/machine learning methods on the observational data. So as long as you know that the causal structure allows for conditioning on a variable (or set of variables), your estimate of the causal impact of one variable on another is as good as your estimate of the distribution of the data, which you obtain through statistical methods. Here is what we find when we apply the back-door criterion to your two diagrams: In neither case does there exist a back-door path from $Z$ to $X.$ So it's true that $Y$ blocks "all" back-door paths, because there aren't any. However, in the left diagram, $Y$ is a direct descendant of $X,$ while in the right diagram it is not. Therefore $Y$ follows the back-door criterion in the right diagram, but not the left. These are unsurprising results. What is surprising, however, is that in the right diagram, as long as it is the complete picture, you need not condition on $Y$ to get the full causal impact of $X$ on $Z$. (Said another way, the null set satisfies the back-door criteria, and is thus, sufficient for conditioning.) Intuitively this is true because the value of $X$ is not associated with that of $Y$ so for sufficient data you can simply average over the values of $Y$ to marginalize the effect of $Y$ on $Z.$ One objection to this point can be that the data is limited, so you don't have a representative distribution of $Y$ values. But recall that the back-door criterion assumes you have the probability distribution of the data. In that case you can analytically marginalize $Y.$ Marginalization over a finite data set is just an estimation. Also, note that it's highly unlikely that this is the complete picture. There are likely external factors that impact $X.$ If those factors are also associated with $Y$ in any way, then more work must be done to see if $Y$ must be conditioned on, or if it's even sufficient. If you draw another arrow pointing from $Y$ to $X$ then $Y$ becomes necessary to control. Those are, of course, very simple examples where intuition is enough to know when $Y$ can or cannot be controlled for. But here's a couple more examples where it's not obvious by looking at the diagram, and you can use the back-door criteria. For the following diagram we ask if it is sufficient to control for $Y$ when determining the causal impact of $X$ on $Z.$ The first thing to note is that, in both cases, $Y$ is not a descendant of $X.$ So it passes that criterion. The next thing to note is that, in both cases, there are several backdoor paths from $Z$ to $X.$ Two in the left diagram and three in the right. In the left diagram the backdoor paths are $Z \leftarrow Y \rightarrow X$ and $Z \leftarrow W \rightarrow B \leftarrow A \rightarrow X. \hspace{1mm}$ $Y$ blocks the first path because it is an arrow-emitting node that is directly in the path. $Y$ also blocks the second path because it is neither $B,$ nor is it a descendant of $B,$ which is the only arrow colliding node in the path. Therefore $Y$ is a sufficient set for conditioning. (Note, unlike in your right diagram, the null set is not sufficient for conditioning, because it does not block the path $Z \leftarrow Y \rightarrow X$.) In the right diagram the backdoor paths are the same two as in the left, plus the path $Z \leftarrow W \rightarrow B \rightarrow Y \rightarrow X. \hspace{1mm}$ $Y$ does block this path, because it is an arrow emitting node in the path. It also blocks the path $Z \leftarrow Y \rightarrow X$ for the same reason as the left diagram. However, it does not block the path $Z \leftarrow W \rightarrow B \leftarrow A \rightarrow X,$ because it is a direct descendant of the collider node $B.$ Therefore it is not sufficient for conditioning. It is pretty unintuitive to see why $Y$ is sufficient for conditioning on the left diagram, because of the exogenous variables $A$ and $W$ that affect $X$ and $Z$ respectively. However, suppose there was no $B.$ In that case, there would be no spurious relationship between $X$ and $Z$ due to these exogenous variables so they're not of concern. The existence of $B,$ however, puts that in question. If $B$ is allowed to take whatever value it naturally takes given $A$ and $W$, it would not be a problem because it does not have any impact on the important variables, or the exogenous variables determining them. However, if $B$ (or any of its descendants) is controlled then it actually renders $A$ and $W$ dependent, which creates the spurious relationship beteween $X$ and $Z$ that we don't want. As mentioned in the linked source, this is an example of Berkson's paradox, where an observation of a variable caused by two independent sources makes those sources dependent (e.g. the result of two independent coin flips is rendered dependent upon the observation of the number of total heads flipped). As I mentioned before the use of the back-door criterion requires that you know the causal model (i.e. the "correct" diagram of arrows between the variables). But the Structural Causal Model, in my opinion, also gives the best and most formal way to search for such a model, or to know when the search is futile. It also has the wonderful side effect of rendering terms like "confounding", "mediation", and "spurious" (all of which confuse me) obsolete. Just show me the picture and I'll tell you which circles ought to be controlled.
When is it inappropriate to control for a variable? I believe the quick one-sentence answer to your question, When is it appropriate to control for variable Y and when not? is the "back-door criterion". Judea Pearl's Structural Causal Model can tell
16,517
When is it inappropriate to control for a variable?
The following might or might not be appropriate to your case: if X is a treatment, then you might be able to go around your problem by using propensity score matching in which you would still keep the variable Y when you do the matching. In other words, you balance the covariates (Y is one of such covariates) that predict receiving the treatment X. Note how there is no reference to the outcome variable Z in the above. You can also check how balanced your observations are (by generating a before and after matching balance table), which might give you insights into how much of X is determined by Y.
When is it inappropriate to control for a variable?
The following might or might not be appropriate to your case: if X is a treatment, then you might be able to go around your problem by using propensity score matching in which you would still keep the
When is it inappropriate to control for a variable? The following might or might not be appropriate to your case: if X is a treatment, then you might be able to go around your problem by using propensity score matching in which you would still keep the variable Y when you do the matching. In other words, you balance the covariates (Y is one of such covariates) that predict receiving the treatment X. Note how there is no reference to the outcome variable Z in the above. You can also check how balanced your observations are (by generating a before and after matching balance table), which might give you insights into how much of X is determined by Y.
When is it inappropriate to control for a variable? The following might or might not be appropriate to your case: if X is a treatment, then you might be able to go around your problem by using propensity score matching in which you would still keep the
16,518
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by Freedman
They're quite different. (A) is explicitly introductory (but in many ways not elementary). That may seem contradictory: perhaps it's fair to say that (A) assumes intelligent readers willing to think hard, but not previous knowledge of statistics. There are no gimmicks such as colour photographs of happy people, boxes of various kinds with extra materials, or rude stories based on the author's wilder experiences or over-fertile imagination. (I allude without references to some of the more appalling alternatives in the market.) A smart high school student or anyone who remembered most of their high school mathematics would find it rewarding, as well as the more obvious undergraduate market. (B) is more a second text and would be tough going for anybody who didn't find the content of (A) familiar. I'd say (B) depends on readers having encountered most of the material at least once before, because many of the explanations are cleverly concise but equally rather condensed. I'd say it's really for researchers, minimally final-year undergraduates preparing a dissertation or research paper. It's also more opinionated, which you'll love or loathe according to whether you agree with Freedman, whose high standards often excluded almost anybody else's work. I re-read (A) with profit and pleasure every few years and have done so since the first edition (with skimming and skipping). Disclosure: I am not a statistician either; nor I have ever taken courses taught by statisticians. Gossip: A biography of John Tukey (see here for details and a review) twice includes an undocumented story that David Freedman as a graduate student at Princeton really couldn't get on with Tukey's sometimes elliptical and elusive teaching style. It is tempting to speculate that this may have been an underlying reason why (A) avoids box plots and Tukeyish exploratory methods generally.
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by F
They're quite different. (A) is explicitly introductory (but in many ways not elementary). That may seem contradictory: perhaps it's fair to say that (A) assumes intelligent readers willing to think
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by Freedman They're quite different. (A) is explicitly introductory (but in many ways not elementary). That may seem contradictory: perhaps it's fair to say that (A) assumes intelligent readers willing to think hard, but not previous knowledge of statistics. There are no gimmicks such as colour photographs of happy people, boxes of various kinds with extra materials, or rude stories based on the author's wilder experiences or over-fertile imagination. (I allude without references to some of the more appalling alternatives in the market.) A smart high school student or anyone who remembered most of their high school mathematics would find it rewarding, as well as the more obvious undergraduate market. (B) is more a second text and would be tough going for anybody who didn't find the content of (A) familiar. I'd say (B) depends on readers having encountered most of the material at least once before, because many of the explanations are cleverly concise but equally rather condensed. I'd say it's really for researchers, minimally final-year undergraduates preparing a dissertation or research paper. It's also more opinionated, which you'll love or loathe according to whether you agree with Freedman, whose high standards often excluded almost anybody else's work. I re-read (A) with profit and pleasure every few years and have done so since the first edition (with skimming and skipping). Disclosure: I am not a statistician either; nor I have ever taken courses taught by statisticians. Gossip: A biography of John Tukey (see here for details and a review) twice includes an undocumented story that David Freedman as a graduate student at Princeton really couldn't get on with Tukey's sometimes elliptical and elusive teaching style. It is tempting to speculate that this may have been an underlying reason why (A) avoids box plots and Tukeyish exploratory methods generally.
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by F They're quite different. (A) is explicitly introductory (but in many ways not elementary). That may seem contradictory: perhaps it's fair to say that (A) assumes intelligent readers willing to think
16,519
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by Freedman
I am a statistician, taught it for 40 years, mainly to biologists. The Nick Cox answer above is dead on. In my opinion, "FPP" is still by far the best intro book on statistics. Strong emphasis on concepts, great examples (though I wish more were from biology!), and counter-examples (showing how 'the obvious' can sometimes be wrong), and exercises. It is easy reading, but this can be deceptive: you have to think. "Statistical Models" (Freedman) is a second or third course book. It's also very conceptual. You'd probably want a more standard book for learning the basics of least squares methods (regression, anova, etc.). Freedman is more concerned about when the models are justified (usually as good approximations to "truth") and when not. Very important now, when you can run very complex models at little more than the push of a button, but not have much idea of what you assumed or what the results mean. Davison's book is also excellent, but more technical and practical: it describes the most important standard models (and some less standard) in a variety of areas and shows ways to analyze them.
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by F
I am a statistician, taught it for 40 years, mainly to biologists. The Nick Cox answer above is dead on. In my opinion, "FPP" is still by far the best intro book on statistics. Strong emphasis on c
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by Freedman I am a statistician, taught it for 40 years, mainly to biologists. The Nick Cox answer above is dead on. In my opinion, "FPP" is still by far the best intro book on statistics. Strong emphasis on concepts, great examples (though I wish more were from biology!), and counter-examples (showing how 'the obvious' can sometimes be wrong), and exercises. It is easy reading, but this can be deceptive: you have to think. "Statistical Models" (Freedman) is a second or third course book. It's also very conceptual. You'd probably want a more standard book for learning the basics of least squares methods (regression, anova, etc.). Freedman is more concerned about when the models are justified (usually as good approximations to "truth") and when not. Very important now, when you can run very complex models at little more than the push of a button, but not have much idea of what you assumed or what the results mean. Davison's book is also excellent, but more technical and practical: it describes the most important standard models (and some less standard) in a variety of areas and shows ways to analyze them.
Choosing between "Statistics" by Freedman et al., and "Statistical Models: Theory and Practice" by F I am a statistician, taught it for 40 years, mainly to biologists. The Nick Cox answer above is dead on. In my opinion, "FPP" is still by far the best intro book on statistics. Strong emphasis on c
16,520
Caret glmnet vs cv.glmnet
I see two issue here. First, your training set is too small relative to your testing set. Normally, we would want a training set that is at least comparable in size to the testing set. Another note is that for Cross Validation, you're not using the testing set at all, because the algorithm basically creates testing sets for you using the "training set". So you'd be better off using more of the data as your initial training set. Second, 3 folds is too small for your CV to be reliable. Typically, 5-10 folds is recommended (nfolds = 5 for cv.glmnet and number=5 for caret). With these changes, I got the same lambda values across the two methods and almost identical estimates: set.seed(849) training <- twoClassSim(500, linearVars = 2) set.seed(849) testing <- twoClassSim(50, linearVars = 2) trainX <- training[, -ncol(training)] testX <- testing[, -ncol(testing)] trainY <- training$Class # Using glmnet to directly perform CV set.seed(849) cvob1=cv.glmnet(x=as.matrix(trainX), y=trainY,family="binomial",alpha=1, type.measure="auc", nfolds = 5, lambda = seq(0.001,0.1,by = 0.001), standardize=FALSE) cbind(cvob1$lambda,cvob1$cvm) # best parameter cvob1$lambda.min # best coefficient coef(cvob1, s = "lambda.min") # Using caret to perform CV cctrl1 <- trainControl(method="cv", number=5, returnResamp="all", classProbs=TRUE, summaryFunction=twoClassSummary) set.seed(849) test_class_cv_model <- train(trainX, trainY, method = "glmnet", trControl = cctrl1,metric = "ROC", tuneGrid = expand.grid(alpha = 1, lambda = seq(0.001,0.1,by = 0.001))) test_class_cv_model # best parameter test_class_cv_model$bestTune # best coefficient coef(test_class_cv_model$finalModel, test_class_cv_model$bestTune$lambda) Result: > cvob1$lambda.min [1] 0.001 > coef(cvob1, s = "lambda.min") 8 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) -0.781015706 TwoFactor1 -1.793387005 TwoFactor2 1.850588656 Linear1 0.009341356 Linear2 -1.213777391 Nonlinear1 1.158009360 Nonlinear2 0.609911748 Nonlinear3 0.246029667 > test_class_cv_model$bestTune alpha lambda 1 1 0.001 > coef(test_class_cv_model$finalModel, test_class_cv_model$bestTune$lambda) 8 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) -0.845792624 TwoFactor1 -1.786976586 TwoFactor2 1.844767690 Linear1 0.008308165 Linear2 -1.212285068 Nonlinear1 1.159933335 Nonlinear2 0.676803555 Nonlinear3 0.309947442
Caret glmnet vs cv.glmnet
I see two issue here. First, your training set is too small relative to your testing set. Normally, we would want a training set that is at least comparable in size to the testing set. Another note is
Caret glmnet vs cv.glmnet I see two issue here. First, your training set is too small relative to your testing set. Normally, we would want a training set that is at least comparable in size to the testing set. Another note is that for Cross Validation, you're not using the testing set at all, because the algorithm basically creates testing sets for you using the "training set". So you'd be better off using more of the data as your initial training set. Second, 3 folds is too small for your CV to be reliable. Typically, 5-10 folds is recommended (nfolds = 5 for cv.glmnet and number=5 for caret). With these changes, I got the same lambda values across the two methods and almost identical estimates: set.seed(849) training <- twoClassSim(500, linearVars = 2) set.seed(849) testing <- twoClassSim(50, linearVars = 2) trainX <- training[, -ncol(training)] testX <- testing[, -ncol(testing)] trainY <- training$Class # Using glmnet to directly perform CV set.seed(849) cvob1=cv.glmnet(x=as.matrix(trainX), y=trainY,family="binomial",alpha=1, type.measure="auc", nfolds = 5, lambda = seq(0.001,0.1,by = 0.001), standardize=FALSE) cbind(cvob1$lambda,cvob1$cvm) # best parameter cvob1$lambda.min # best coefficient coef(cvob1, s = "lambda.min") # Using caret to perform CV cctrl1 <- trainControl(method="cv", number=5, returnResamp="all", classProbs=TRUE, summaryFunction=twoClassSummary) set.seed(849) test_class_cv_model <- train(trainX, trainY, method = "glmnet", trControl = cctrl1,metric = "ROC", tuneGrid = expand.grid(alpha = 1, lambda = seq(0.001,0.1,by = 0.001))) test_class_cv_model # best parameter test_class_cv_model$bestTune # best coefficient coef(test_class_cv_model$finalModel, test_class_cv_model$bestTune$lambda) Result: > cvob1$lambda.min [1] 0.001 > coef(cvob1, s = "lambda.min") 8 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) -0.781015706 TwoFactor1 -1.793387005 TwoFactor2 1.850588656 Linear1 0.009341356 Linear2 -1.213777391 Nonlinear1 1.158009360 Nonlinear2 0.609911748 Nonlinear3 0.246029667 > test_class_cv_model$bestTune alpha lambda 1 1 0.001 > coef(test_class_cv_model$finalModel, test_class_cv_model$bestTune$lambda) 8 x 1 sparse Matrix of class "dgCMatrix" 1 (Intercept) -0.845792624 TwoFactor1 -1.786976586 TwoFactor2 1.844767690 Linear1 0.008308165 Linear2 -1.212285068 Nonlinear1 1.159933335 Nonlinear2 0.676803555 Nonlinear3 0.309947442
Caret glmnet vs cv.glmnet I see two issue here. First, your training set is too small relative to your testing set. Normally, we would want a training set that is at least comparable in size to the testing set. Another note is
16,521
R/mgcv: Why do te() and ti() tensor products produce different surfaces?
These are superficially the same model but in practice when fitting there are some subtle differences. One important difference is that the model with ti() terms is estimating more smoothness parameters compared with the te() model: > b2$sp te(x,z)1 te(x,z)2 3.479997 5.884272 > b3$sp ti(x) ti(z) ti(x,z)1 ti(x,z)2 8.168742 60.456559 2.370604 2.761823 and this is because there are more penalty matrices associated with the two models; in the ti() model we have one per "term" compared with just two in the te() model, one per marginal smooth. I see models with ti() as being used to decide whether I want $\hat{y} = \beta_0 + s(x, y)$ or $\hat{y} = \beta_0 + s(x) + s(y)$. I can't compare those models if I use te() terms so I use ti(). Once I've determined if I need $s(x,y)$ I can refit the model with te() if I need it or with separate s() for each marginal effect if I don't need $s(x,y)$. Note that you can get the models somewhat closer to each other by fitting using method = "ML" (or "REML", but you shouldn't be comparing "fixed" effects with "REML" unless all the terms are fully penalized, which by default they aren't, but would be say with select = TRUE).
R/mgcv: Why do te() and ti() tensor products produce different surfaces?
These are superficially the same model but in practice when fitting there are some subtle differences. One important difference is that the model with ti() terms is estimating more smoothness paramete
R/mgcv: Why do te() and ti() tensor products produce different surfaces? These are superficially the same model but in practice when fitting there are some subtle differences. One important difference is that the model with ti() terms is estimating more smoothness parameters compared with the te() model: > b2$sp te(x,z)1 te(x,z)2 3.479997 5.884272 > b3$sp ti(x) ti(z) ti(x,z)1 ti(x,z)2 8.168742 60.456559 2.370604 2.761823 and this is because there are more penalty matrices associated with the two models; in the ti() model we have one per "term" compared with just two in the te() model, one per marginal smooth. I see models with ti() as being used to decide whether I want $\hat{y} = \beta_0 + s(x, y)$ or $\hat{y} = \beta_0 + s(x) + s(y)$. I can't compare those models if I use te() terms so I use ti(). Once I've determined if I need $s(x,y)$ I can refit the model with te() if I need it or with separate s() for each marginal effect if I don't need $s(x,y)$. Note that you can get the models somewhat closer to each other by fitting using method = "ML" (or "REML", but you shouldn't be comparing "fixed" effects with "REML" unless all the terms are fully penalized, which by default they aren't, but would be say with select = TRUE).
R/mgcv: Why do te() and ti() tensor products produce different surfaces? These are superficially the same model but in practice when fitting there are some subtle differences. One important difference is that the model with ti() terms is estimating more smoothness paramete
16,522
Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis
The result that $p$ values have a uniform distribution under $H_0$ holds for continuously distributed test statistics - at least for point nulls, as you have here. As James Stanley mentions in comments the distribution of the test statistic is discrete, so that result doesn't apply. You may have no errors at all in your code (though I wouldn't display a discrete distribution with a histogram, I'd lean toward displaying the cdf or the pmf, or better, both). While not actually uniform, each jump in the cdf of the p-value takes it to the line $F(x)=x$ (I don't know a name for this, but it ought to have a name, perhaps something like 'quasi-uniform' - edit - some authors seem to call this 'sub-uniform'): It's quite possible to compute this distribution exactly, rather than simulate - but I've followed your lead and done a simulation (though a larger one than you have). Such a distribution needn't have mean 0.5, though as the $n$ in the binomial increases the step cdf will approach the line more closely, and the mean will approach 0.5. One implication of the discreteness of the p-values is that only certain significance levels are achievable -- the ones corresponding to the step-heights in the actual population cdf of p-values under the null. So for example you can have an $\alpha$ near 0.056 or one near 0.04, but not anything closer to 0.05.
Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis
The result that $p$ values have a uniform distribution under $H_0$ holds for continuously distributed test statistics - at least for point nulls, as you have here. As James Stanley mentions in comment
Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis The result that $p$ values have a uniform distribution under $H_0$ holds for continuously distributed test statistics - at least for point nulls, as you have here. As James Stanley mentions in comments the distribution of the test statistic is discrete, so that result doesn't apply. You may have no errors at all in your code (though I wouldn't display a discrete distribution with a histogram, I'd lean toward displaying the cdf or the pmf, or better, both). While not actually uniform, each jump in the cdf of the p-value takes it to the line $F(x)=x$ (I don't know a name for this, but it ought to have a name, perhaps something like 'quasi-uniform' - edit - some authors seem to call this 'sub-uniform'): It's quite possible to compute this distribution exactly, rather than simulate - but I've followed your lead and done a simulation (though a larger one than you have). Such a distribution needn't have mean 0.5, though as the $n$ in the binomial increases the step cdf will approach the line more closely, and the mean will approach 0.5. One implication of the discreteness of the p-values is that only certain significance levels are achievable -- the ones corresponding to the step-heights in the actual population cdf of p-values under the null. So for example you can have an $\alpha$ near 0.056 or one near 0.04, but not anything closer to 0.05.
Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis The result that $p$ values have a uniform distribution under $H_0$ holds for continuously distributed test statistics - at least for point nulls, as you have here. As James Stanley mentions in comment
16,523
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant
Your computation seems to be verifying that, when we have a particular prior distribution $p(\theta)$ the following two procedures Compute the posterior $p_{\theta \mid D}(\theta \mid D)$ Transform the aforementioned posterior into the other parametrization to obtain $p_{\psi \mid D}(\psi \mid D)$ and Transform the prior $p_\theta(\theta)$ into the other parametrization to obtain $p_\psi(\psi)$ Using the prior $p_\psi(\psi)$, compute the posterior $p_{\psi \mid D}(\psi \mid D)$ lead to the same posterior for $\psi$. This will indeed always occur (caveat; as long as the transformation is such that a distribution over $\psi$ is determined by a distribution over $\theta$). However, this is not the point of the invariance in question. Instead, the question is whether, when we have a particular Method For Deciding The Prior, the following two procedures: Use the Method For Deciding The Prior to decide $p_\theta(\theta)$ Convert that distribution into $p_\psi(\psi)$ and Use the Method For Deciding The Prior to decide $p_\psi(\psi)$ result in the same prior distribution for $\psi$. If they result in the same prior, they will indeed result in the same posterior, too (as you have verified for a couple of cases). As mentioned in @NeilG's answer, if your Method For Deciding The Prior is 'set uniform prior for the parameter', you will not get the same prior in the probability/odds case, as the uniform prior for $\theta$ over $[0,1]$ is not uniform for $\psi$ over $[0,\infty)$. Instead, if your Method For Deciding The Prior is 'use Jeffrey's prior for the parameter', it will not matter whether you use it for $\theta$ and convert into the $\psi$-parametrization, or use it for $\psi$ directly. This is the claimed invariance.
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant
Your computation seems to be verifying that, when we have a particular prior distribution $p(\theta)$ the following two procedures Compute the posterior $p_{\theta \mid D}(\theta \mid D)$ Transform t
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant Your computation seems to be verifying that, when we have a particular prior distribution $p(\theta)$ the following two procedures Compute the posterior $p_{\theta \mid D}(\theta \mid D)$ Transform the aforementioned posterior into the other parametrization to obtain $p_{\psi \mid D}(\psi \mid D)$ and Transform the prior $p_\theta(\theta)$ into the other parametrization to obtain $p_\psi(\psi)$ Using the prior $p_\psi(\psi)$, compute the posterior $p_{\psi \mid D}(\psi \mid D)$ lead to the same posterior for $\psi$. This will indeed always occur (caveat; as long as the transformation is such that a distribution over $\psi$ is determined by a distribution over $\theta$). However, this is not the point of the invariance in question. Instead, the question is whether, when we have a particular Method For Deciding The Prior, the following two procedures: Use the Method For Deciding The Prior to decide $p_\theta(\theta)$ Convert that distribution into $p_\psi(\psi)$ and Use the Method For Deciding The Prior to decide $p_\psi(\psi)$ result in the same prior distribution for $\psi$. If they result in the same prior, they will indeed result in the same posterior, too (as you have verified for a couple of cases). As mentioned in @NeilG's answer, if your Method For Deciding The Prior is 'set uniform prior for the parameter', you will not get the same prior in the probability/odds case, as the uniform prior for $\theta$ over $[0,1]$ is not uniform for $\psi$ over $[0,\infty)$. Instead, if your Method For Deciding The Prior is 'use Jeffrey's prior for the parameter', it will not matter whether you use it for $\theta$ and convert into the $\psi$-parametrization, or use it for $\psi$ directly. This is the claimed invariance.
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant Your computation seems to be verifying that, when we have a particular prior distribution $p(\theta)$ the following two procedures Compute the posterior $p_{\theta \mid D}(\theta \mid D)$ Transform t
16,524
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant
It looks like you're verifying the likelihoods induced by the data are unaffected by parametrization, which has nothing to do with the prior. If your way of choosing priors is to, e.g., "choose the uniform prior", then what is uniform under one parametrization (say Beta, i.e. Beta(1,1)) is not uniform under another, say, BetaPrime(1,1) (which is skewed) — it's BetaPrime(1,-1) is uniform if such a thing exists. The Jeffreys prior is the only "way to choose priors" that is invariant under reparametrization. So it is less assumptive than any other way of choosing priors.
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant
It looks like you're verifying the likelihoods induced by the data are unaffected by parametrization, which has nothing to do with the prior. If your way of choosing priors is to, e.g., "choose the un
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant It looks like you're verifying the likelihoods induced by the data are unaffected by parametrization, which has nothing to do with the prior. If your way of choosing priors is to, e.g., "choose the uniform prior", then what is uniform under one parametrization (say Beta, i.e. Beta(1,1)) is not uniform under another, say, BetaPrime(1,1) (which is skewed) — it's BetaPrime(1,-1) is uniform if such a thing exists. The Jeffreys prior is the only "way to choose priors" that is invariant under reparametrization. So it is less assumptive than any other way of choosing priors.
Example for a prior, that unlike Jeffreys, leads to a posterior that is not invariant It looks like you're verifying the likelihoods induced by the data are unaffected by parametrization, which has nothing to do with the prior. If your way of choosing priors is to, e.g., "choose the un
16,525
For which distributions is there a closed-form unbiased estimator for the standard deviation?
Although this is not directly connected to the question, there is a 1968 paper by Peter Bickel and Erich Lehmann that states that, for a convex family of distributions $F$, there exists an unbiased estimator of a functional $q(F)$ (for a sample size $n$ large enough) if and only if $q(\alpha F+(1-\alpha)G)$ is a polynomial in $0\le \alpha\le 1$. This theorem does not apply to the problem here because the collection of Gaussian distributions is not convex (a mixture of Gaussians is not a Gaussian). An extension of the result in the question is that any power $\sigma^\alpha$ of the standard deviation can be unbiasedly estimated, provided there are enough observations when $\alpha<0$. This follows from the result $$\frac{1}{\sigma^2} \sum_{k=1}^n(x_i-\bar{x})^2 \sim \chi^{2}_{n-1}$$ that $\sigma$ is the scale (and unique) parameter for $\sum_{k=1}^n(x_i-\bar{x})^2$. This normal setting can then be extended to any location-scale family $$X_1,\ldots,X_n\stackrel{\text{iid}}{\sim} \tau^{-1}f(\tau^{-1}\{x-\mu\})$$ with a finite variance $\sigma^2$. Indeed, the variance $$\text{var}_{\mu,\tau}(X)=\mathbb{E}_{\mu,\tau}[(X-\mu)^2]=\tau^2\mathbb{E}_{0,1}[X^2]$$ is only a function of $\tau$; the sum of squares \begin{align*}\mathbb{E}_{\mu,\tau}\left[\sum_{k=1}^n(X_i-\bar{X})^2\right]&=\tau^2\mathbb{E}_{\mu,\tau}\left[\sum_{k=1}^n\tau^{-2}(X_i-\mu-\bar{X}+\mu)^2\right]\\ &=\tau^2\mathbb{E}_{0,1}\left[\sum_{k=1}^n(X_i-\bar{X})^2\right]\end{align*} has an expectation of the form $\tau^2\psi(n)$; and similarly for any power $$\mathbb{E}_{\mu,\tau}\left[\left\{\sum_{k=1}^n(X_i-\bar{X})^2\right\}^\alpha\right]=\tau^{2\alpha}\mathbb{E}_{0,1}\left[\left\{\sum_{k=1}^n(X_i-\bar{X})^2\right\}^\alpha\right]$$ such that the expectation is finite.
For which distributions is there a closed-form unbiased estimator for the standard deviation?
Although this is not directly connected to the question, there is a 1968 paper by Peter Bickel and Erich Lehmann that states that, for a convex family of distributions $F$, there exists an unbiased es
For which distributions is there a closed-form unbiased estimator for the standard deviation? Although this is not directly connected to the question, there is a 1968 paper by Peter Bickel and Erich Lehmann that states that, for a convex family of distributions $F$, there exists an unbiased estimator of a functional $q(F)$ (for a sample size $n$ large enough) if and only if $q(\alpha F+(1-\alpha)G)$ is a polynomial in $0\le \alpha\le 1$. This theorem does not apply to the problem here because the collection of Gaussian distributions is not convex (a mixture of Gaussians is not a Gaussian). An extension of the result in the question is that any power $\sigma^\alpha$ of the standard deviation can be unbiasedly estimated, provided there are enough observations when $\alpha<0$. This follows from the result $$\frac{1}{\sigma^2} \sum_{k=1}^n(x_i-\bar{x})^2 \sim \chi^{2}_{n-1}$$ that $\sigma$ is the scale (and unique) parameter for $\sum_{k=1}^n(x_i-\bar{x})^2$. This normal setting can then be extended to any location-scale family $$X_1,\ldots,X_n\stackrel{\text{iid}}{\sim} \tau^{-1}f(\tau^{-1}\{x-\mu\})$$ with a finite variance $\sigma^2$. Indeed, the variance $$\text{var}_{\mu,\tau}(X)=\mathbb{E}_{\mu,\tau}[(X-\mu)^2]=\tau^2\mathbb{E}_{0,1}[X^2]$$ is only a function of $\tau$; the sum of squares \begin{align*}\mathbb{E}_{\mu,\tau}\left[\sum_{k=1}^n(X_i-\bar{X})^2\right]&=\tau^2\mathbb{E}_{\mu,\tau}\left[\sum_{k=1}^n\tau^{-2}(X_i-\mu-\bar{X}+\mu)^2\right]\\ &=\tau^2\mathbb{E}_{0,1}\left[\sum_{k=1}^n(X_i-\bar{X})^2\right]\end{align*} has an expectation of the form $\tau^2\psi(n)$; and similarly for any power $$\mathbb{E}_{\mu,\tau}\left[\left\{\sum_{k=1}^n(X_i-\bar{X})^2\right\}^\alpha\right]=\tau^{2\alpha}\mathbb{E}_{0,1}\left[\left\{\sum_{k=1}^n(X_i-\bar{X})^2\right\}^\alpha\right]$$ such that the expectation is finite.
For which distributions is there a closed-form unbiased estimator for the standard deviation? Although this is not directly connected to the question, there is a 1968 paper by Peter Bickel and Erich Lehmann that states that, for a convex family of distributions $F$, there exists an unbiased es
16,526
For which distributions is there a closed-form unbiased estimator for the standard deviation?
A probably well known case, but a case nevertheless. Consider a continuous uniform distribution $U(0,\theta)$. Given an i.i.d. sample, the maximum order statistic, $X_{(n)}$ has expected value $$E(X_{(n)}) = \frac {n}{n+1}\theta $$ The standard deviation of the distribution is $$\sigma = \frac {\theta}{2\sqrt 3}$$ So the estimator $$\hat \sigma = \frac 1{2\sqrt 3}\frac {n+1}{n}X_{(n)}$$ is evidently unbiased for $\sigma$. This generalizes to the case where the lower bound of the distribution is also unknown, since we can have an unbiased estimator for the Range, and then the standard deviation is again a linear function of the Range (as is essentially above also). This exemplifies @whuber's comment, that "the amount of bias is a function of $n$ alone" (plus possibly any known constants) -so it can be deterministically corrected. And this is the case here.
For which distributions is there a closed-form unbiased estimator for the standard deviation?
A probably well known case, but a case nevertheless. Consider a continuous uniform distribution $U(0,\theta)$. Given an i.i.d. sample, the maximum order statistic, $X_{(n)}$ has expected value $$E(X_{
For which distributions is there a closed-form unbiased estimator for the standard deviation? A probably well known case, but a case nevertheless. Consider a continuous uniform distribution $U(0,\theta)$. Given an i.i.d. sample, the maximum order statistic, $X_{(n)}$ has expected value $$E(X_{(n)}) = \frac {n}{n+1}\theta $$ The standard deviation of the distribution is $$\sigma = \frac {\theta}{2\sqrt 3}$$ So the estimator $$\hat \sigma = \frac 1{2\sqrt 3}\frac {n+1}{n}X_{(n)}$$ is evidently unbiased for $\sigma$. This generalizes to the case where the lower bound of the distribution is also unknown, since we can have an unbiased estimator for the Range, and then the standard deviation is again a linear function of the Range (as is essentially above also). This exemplifies @whuber's comment, that "the amount of bias is a function of $n$ alone" (plus possibly any known constants) -so it can be deterministically corrected. And this is the case here.
For which distributions is there a closed-form unbiased estimator for the standard deviation? A probably well known case, but a case nevertheless. Consider a continuous uniform distribution $U(0,\theta)$. Given an i.i.d. sample, the maximum order statistic, $X_{(n)}$ has expected value $$E(X_{
16,527
Confidence interval for the product of two parameters
You can use the Delta method to calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$. The delta method states that an approximation of the variance of a function $g(t)$ is given by: $$ \mathrm{Var}(g(t))\approx \sum_{i=1}^{k}g'_{i}(\theta)^{2}\,\mathrm{Var}(t_{i})+2\sum_{i>j}g'_{i}(\theta)g'_{j}(\theta)\,\mathrm{Cov}(t_{i},t_{j}). $$ The approximation of the expectation of $g(t)$ on the other hand is given by: $$ \mathrm{\mathbf{E}}(g(t))\approx g(\theta) $$ So the expectation is simply the function. Your function $g(t)$ is: $g(p_{1}, p_{2})=p_{1}p_{2}$. The expectation of $g(p_{1}, p_{2})=p_{1}p_{2}$ would simply be: $p_{1}p_{2}$. For the variance, we need the partial derivatives of $g(p_{1}, p_{2})$: $$ \begin{align} \frac{\partial}{\partial p_{1}}g(p_{1}p_{2}) & = p_{2} \\ \frac{\partial}{\partial p_{2}}g(p_{1}p_{2}) &= p_{1} \\ \end{align} $$ Using the function for the variance above, we get: $$ \mathrm{Var}(\hat{p}_{1}\hat{p}_{2})=\hat{p}_{2}^{2}\,\mathrm{Var}(\hat{p}_{1}) + \hat{p}_{1}^{2}\,\mathrm{Var}(\hat{p}_{2})+2\cdot \hat{p}_{1}\hat{p}_{2}\,\mathrm{Cov}(\hat{p}_{1},\hat{p}_{2}). $$ The standard error would then simply be the square root of the above expression. Once you've got the standard error, it is straight-forward to calculate a $95\%$ confidence interval for $\hat{p}_{1}\hat{p}_{2}$: $\hat{p}_{1}\hat{p}_{2}\pm 1.96\cdot \widehat{\mathrm{SE}}(\hat{p}_{1}\hat{p}_{2})$ To calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$, you need the variance of $\hat{p}_{1}$ and $\hat{p}_{2}$ which you usually can get by the variance-covariance matrix $\Sigma$ which would be a $2\times 2$-matrix in your case because you have two estimates. The diagonal elements in the variance-covariance matrix are the variances of $\hat{p}_{1}$ and $\hat{p}_{2}$ while the off-diagonal elements are the covariance of $\hat{p}_{1}$ and $\hat{p}_{2}$ (the matrix is symmetric). As @gung mentions in the comments, the variance-covariance matrix can be extracted by most statistical software packages. Sometimes, estimation algorithms provide the Hessian matrix (I won't go into details about that here), and the variance-covariance matrix can be estimated by the inverse of the negative Hessian (but only if you maximized the log-likelihood!; see this post). Again, consult the documentation of your statistical software and/or the web on how to extract the Hessian and on how to calculate the inverse of a matrix. Alternatively, you can get the variances of $\hat{p}_{1}$ and $\hat{p}_{2}$ from the confidence intervals in the following way (this is valid for a $95\%$-CI): $\mathrm{SE}(\hat{p}_{1})=(\text{upper limit} - \text{lower limit})/3.92$. For an $100(1-\alpha)\%$-CI, the estimated standard error is: $\mathrm{SE}(\hat{p}_{1})=(\text{upper limit} - \text{lower limit})/(2\cdot z_{1-\alpha/2})$, where $z_{1-\alpha/2}$ is the $(1-\alpha/2)$ quantile of the standard normal distribution (for $\alpha=0.05$, $z_{0.975}\approx 1.96$). Then, $\mathrm{Var}(\hat{p}_{1}) = \mathrm{SE}(\hat{p}_{1})^{2}$. The same is true for the variance of $\hat{p}_{2}$. We need the covariance of $\hat{p}_{1}$ and $\hat{p}_{2},$ too (see paragraph above). If $\hat{p}_{1}$ and $\hat{p}_{2}$ are independent, the covariance is zero and we can drop the term. This paper might provide additional information.
Confidence interval for the product of two parameters
You can use the Delta method to calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$. The delta method states that an approximation of the variance of a function $g(t)$ is given by: $$ \mathrm{Var
Confidence interval for the product of two parameters You can use the Delta method to calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$. The delta method states that an approximation of the variance of a function $g(t)$ is given by: $$ \mathrm{Var}(g(t))\approx \sum_{i=1}^{k}g'_{i}(\theta)^{2}\,\mathrm{Var}(t_{i})+2\sum_{i>j}g'_{i}(\theta)g'_{j}(\theta)\,\mathrm{Cov}(t_{i},t_{j}). $$ The approximation of the expectation of $g(t)$ on the other hand is given by: $$ \mathrm{\mathbf{E}}(g(t))\approx g(\theta) $$ So the expectation is simply the function. Your function $g(t)$ is: $g(p_{1}, p_{2})=p_{1}p_{2}$. The expectation of $g(p_{1}, p_{2})=p_{1}p_{2}$ would simply be: $p_{1}p_{2}$. For the variance, we need the partial derivatives of $g(p_{1}, p_{2})$: $$ \begin{align} \frac{\partial}{\partial p_{1}}g(p_{1}p_{2}) & = p_{2} \\ \frac{\partial}{\partial p_{2}}g(p_{1}p_{2}) &= p_{1} \\ \end{align} $$ Using the function for the variance above, we get: $$ \mathrm{Var}(\hat{p}_{1}\hat{p}_{2})=\hat{p}_{2}^{2}\,\mathrm{Var}(\hat{p}_{1}) + \hat{p}_{1}^{2}\,\mathrm{Var}(\hat{p}_{2})+2\cdot \hat{p}_{1}\hat{p}_{2}\,\mathrm{Cov}(\hat{p}_{1},\hat{p}_{2}). $$ The standard error would then simply be the square root of the above expression. Once you've got the standard error, it is straight-forward to calculate a $95\%$ confidence interval for $\hat{p}_{1}\hat{p}_{2}$: $\hat{p}_{1}\hat{p}_{2}\pm 1.96\cdot \widehat{\mathrm{SE}}(\hat{p}_{1}\hat{p}_{2})$ To calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$, you need the variance of $\hat{p}_{1}$ and $\hat{p}_{2}$ which you usually can get by the variance-covariance matrix $\Sigma$ which would be a $2\times 2$-matrix in your case because you have two estimates. The diagonal elements in the variance-covariance matrix are the variances of $\hat{p}_{1}$ and $\hat{p}_{2}$ while the off-diagonal elements are the covariance of $\hat{p}_{1}$ and $\hat{p}_{2}$ (the matrix is symmetric). As @gung mentions in the comments, the variance-covariance matrix can be extracted by most statistical software packages. Sometimes, estimation algorithms provide the Hessian matrix (I won't go into details about that here), and the variance-covariance matrix can be estimated by the inverse of the negative Hessian (but only if you maximized the log-likelihood!; see this post). Again, consult the documentation of your statistical software and/or the web on how to extract the Hessian and on how to calculate the inverse of a matrix. Alternatively, you can get the variances of $\hat{p}_{1}$ and $\hat{p}_{2}$ from the confidence intervals in the following way (this is valid for a $95\%$-CI): $\mathrm{SE}(\hat{p}_{1})=(\text{upper limit} - \text{lower limit})/3.92$. For an $100(1-\alpha)\%$-CI, the estimated standard error is: $\mathrm{SE}(\hat{p}_{1})=(\text{upper limit} - \text{lower limit})/(2\cdot z_{1-\alpha/2})$, where $z_{1-\alpha/2}$ is the $(1-\alpha/2)$ quantile of the standard normal distribution (for $\alpha=0.05$, $z_{0.975}\approx 1.96$). Then, $\mathrm{Var}(\hat{p}_{1}) = \mathrm{SE}(\hat{p}_{1})^{2}$. The same is true for the variance of $\hat{p}_{2}$. We need the covariance of $\hat{p}_{1}$ and $\hat{p}_{2},$ too (see paragraph above). If $\hat{p}_{1}$ and $\hat{p}_{2}$ are independent, the covariance is zero and we can drop the term. This paper might provide additional information.
Confidence interval for the product of two parameters You can use the Delta method to calculate the standard error of $\hat{p}_{1}\hat{p}_{2}$. The delta method states that an approximation of the variance of a function $g(t)$ is given by: $$ \mathrm{Var
16,528
Confidence interval for the product of two parameters
I found a different equation for calculation of variance of product. If x and y are independently distributed, the variance of the product is relatively straightforward: V(x*y)= V(y)*E(x)^2 + V(x)*E(y)^2 + V(x)*V(y) These results also generalize to cases involving three or more variables (Goodman 1960). Source: Regulating Pesticides (1980), appendix F Coolserdash: The last component V(x)*V(y) is missing in your equation. Is the referenced book (Regulating Pesticides) wrong? Also, both equations might not be perfect. "... we show that the distribution of the product of three independent normal variables is not normal." (source). I would expect some positive skew even in the product of two normally distributed variables.
Confidence interval for the product of two parameters
I found a different equation for calculation of variance of product. If x and y are independently distributed, the variance of the product is relatively straightforward: V(x*y)= V(y)*E(x)^2 + V
Confidence interval for the product of two parameters I found a different equation for calculation of variance of product. If x and y are independently distributed, the variance of the product is relatively straightforward: V(x*y)= V(y)*E(x)^2 + V(x)*E(y)^2 + V(x)*V(y) These results also generalize to cases involving three or more variables (Goodman 1960). Source: Regulating Pesticides (1980), appendix F Coolserdash: The last component V(x)*V(y) is missing in your equation. Is the referenced book (Regulating Pesticides) wrong? Also, both equations might not be perfect. "... we show that the distribution of the product of three independent normal variables is not normal." (source). I would expect some positive skew even in the product of two normally distributed variables.
Confidence interval for the product of two parameters I found a different equation for calculation of variance of product. If x and y are independently distributed, the variance of the product is relatively straightforward: V(x*y)= V(y)*E(x)^2 + V
16,529
Confidence interval for the product of two parameters
The length of the CI / 2 / 1.96 = se, i.e. the standard error of A or B se^2 = var, i.e. the variance of the estimate A or B Use the estimated A or B as the means of A or B, i.e. E(A) or E(B) Follow this page http://falkenblog.blogspot.se/2008/07/formula-for-varxy.html to get var(A*B), i.e. var(C) Square-root of var(C) is the se of C (C - 1.96*se(C), C + 1.96*se(C)) is the 95% CI of C Note that if your A and B are correlated, you need to consider their covariance as well.
Confidence interval for the product of two parameters
The length of the CI / 2 / 1.96 = se, i.e. the standard error of A or B se^2 = var, i.e. the variance of the estimate A or B Use the estimated A or B as the means of A or B, i.e. E(A) or E(B) Follow t
Confidence interval for the product of two parameters The length of the CI / 2 / 1.96 = se, i.e. the standard error of A or B se^2 = var, i.e. the variance of the estimate A or B Use the estimated A or B as the means of A or B, i.e. E(A) or E(B) Follow this page http://falkenblog.blogspot.se/2008/07/formula-for-varxy.html to get var(A*B), i.e. var(C) Square-root of var(C) is the se of C (C - 1.96*se(C), C + 1.96*se(C)) is the 95% CI of C Note that if your A and B are correlated, you need to consider their covariance as well.
Confidence interval for the product of two parameters The length of the CI / 2 / 1.96 = se, i.e. the standard error of A or B se^2 = var, i.e. the variance of the estimate A or B Use the estimated A or B as the means of A or B, i.e. E(A) or E(B) Follow t
16,530
What are R-structure G-structure in a glmm?
I would prefer to post my comments below as a comment but this would not be enough. These are questions rather than an answer (simlarly to @gung I don't feel strong enough on the topic). I am under the impression that MCMCglmm does not implement a "true" Bayesian glmm. The true Bayesian model is described in section 2 of this paper. Similarly to the frequentist model, one has $g(E(y \mid u)) = X\beta + Zu$ and there is a prior required on the dispersion parameter $\phi_1$ in addition to the fixed parameters $\beta$ and the "G" variance of the random effect $u$. But according to this MCMCglmm vignette, the model implemented in MCMCglmm is given by $g(E(y \mid u,e)) = X\beta + Zu + e$ , and it does not involve the dispersion parameter $\phi_1$. It is not similar to the classical frequentist model. Therefore I would be not surprised that there is no analogue of $\sigma_e$ with glmer. Please apologize for these rough comments, I just took a quick look about that.
What are R-structure G-structure in a glmm?
I would prefer to post my comments below as a comment but this would not be enough. These are questions rather than an answer (simlarly to @gung I don't feel strong enough on the topic). I am under th
What are R-structure G-structure in a glmm? I would prefer to post my comments below as a comment but this would not be enough. These are questions rather than an answer (simlarly to @gung I don't feel strong enough on the topic). I am under the impression that MCMCglmm does not implement a "true" Bayesian glmm. The true Bayesian model is described in section 2 of this paper. Similarly to the frequentist model, one has $g(E(y \mid u)) = X\beta + Zu$ and there is a prior required on the dispersion parameter $\phi_1$ in addition to the fixed parameters $\beta$ and the "G" variance of the random effect $u$. But according to this MCMCglmm vignette, the model implemented in MCMCglmm is given by $g(E(y \mid u,e)) = X\beta + Zu + e$ , and it does not involve the dispersion parameter $\phi_1$. It is not similar to the classical frequentist model. Therefore I would be not surprised that there is no analogue of $\sigma_e$ with glmer. Please apologize for these rough comments, I just took a quick look about that.
What are R-structure G-structure in a glmm? I would prefer to post my comments below as a comment but this would not be enough. These are questions rather than an answer (simlarly to @gung I don't feel strong enough on the topic). I am under th
16,531
What are R-structure G-structure in a glmm?
I am late to the game, but a few notes. The $\mathbf{R}$ structure is the residual structure. In your case, the "structure" only has a single element (but this need not be the case). For Gaussian response variable, the residual variance, $\sigma^{2}_{e}$ is typically estimated. For binary outcomes, it is held constant. Because of how MCMCglmm is setup, you cannot fix it at zero, but it is relatively standard to fix it at $1$ (also true for a probit model). For count data (e.g., with a poisson distribution), you do not fix it and this automatically estimates an overdispersion parameter essentially. The $\mathbf{G}$ structure is the random effects structure. Again in your case, just a random intercept, but if you had multiple random effects, they would form a variance-covariance matrix, $\mathbf{G}$. A final note, because the residual variance is not fixed at zero, the estimates will not match those from glmer. You need to rescale them. Here is a little example (not using random effects, but it generalizes). Note how the R structure variance is fixed at 1. # example showing how close the match is to ML without separation m2 <- MCMCglmm(vs ~ mpg, data = mtcars, family = "categorical", prior = list( B = list(mu = c(0, 0), V = diag(2) * 1e10), R = list(V = 1, fix = 1)), nitt = 1e6, thin = 500, burnin = 10000) summary(m2) Here is the rescaling constant for the binomial family: k <- ((16*sqrt(3))/(15*pi))^2 Now divide the solution by it, and get the posterior modes posterior.mode(m2$Sol/(sqrt(1 + k))) Which should be fairly close to what we get from glm summary(glm(vs ~mpg, data = mtcars, family = binomial))
What are R-structure G-structure in a glmm?
I am late to the game, but a few notes. The $\mathbf{R}$ structure is the residual structure. In your case, the "structure" only has a single element (but this need not be the case). For Gaussian r
What are R-structure G-structure in a glmm? I am late to the game, but a few notes. The $\mathbf{R}$ structure is the residual structure. In your case, the "structure" only has a single element (but this need not be the case). For Gaussian response variable, the residual variance, $\sigma^{2}_{e}$ is typically estimated. For binary outcomes, it is held constant. Because of how MCMCglmm is setup, you cannot fix it at zero, but it is relatively standard to fix it at $1$ (also true for a probit model). For count data (e.g., with a poisson distribution), you do not fix it and this automatically estimates an overdispersion parameter essentially. The $\mathbf{G}$ structure is the random effects structure. Again in your case, just a random intercept, but if you had multiple random effects, they would form a variance-covariance matrix, $\mathbf{G}$. A final note, because the residual variance is not fixed at zero, the estimates will not match those from glmer. You need to rescale them. Here is a little example (not using random effects, but it generalizes). Note how the R structure variance is fixed at 1. # example showing how close the match is to ML without separation m2 <- MCMCglmm(vs ~ mpg, data = mtcars, family = "categorical", prior = list( B = list(mu = c(0, 0), V = diag(2) * 1e10), R = list(V = 1, fix = 1)), nitt = 1e6, thin = 500, burnin = 10000) summary(m2) Here is the rescaling constant for the binomial family: k <- ((16*sqrt(3))/(15*pi))^2 Now divide the solution by it, and get the posterior modes posterior.mode(m2$Sol/(sqrt(1 + k))) Which should be fairly close to what we get from glm summary(glm(vs ~mpg, data = mtcars, family = binomial))
What are R-structure G-structure in a glmm? I am late to the game, but a few notes. The $\mathbf{R}$ structure is the residual structure. In your case, the "structure" only has a single element (but this need not be the case). For Gaussian r
16,532
Quantiles from the combination of normal distributions
Unfortunately, the standard normal (from which all others can be determined, since the normal is a location-scale family) quantile function does not admit a closed form (i.e. a 'pretty formula'). The closest thing to a closed form is that the standard normal quantile function is the function, $w$, that satisfies the differential equation $$ \frac{d^2 w}{d p^2} = w \left(\frac{d w}{d p}\right)^2 $$ and the initial conditions $w(1/2) = 0$ and $w'(1/2) = \sqrt{2 \pi}$. In most computing environments there is a function that numerically calculates the normal quantile function. In R, you would type qnorm(p, mean=mu, sd=sigma) to get the $p$'th quantile of the $N(\mu, \sigma^2)$ distribution. Edit: With a modified understanding of the problem, the data is generated from a mixture of normals, so that the density of the observed data is: $$ p(x) = \sum_{i} w_{i} p_{i}(x) $$ where $\sum_{i} w_{i} = 1$ and each $p_{i}(x)$ is some normal density with mean $\mu_{i}$ and standard deviation $\sigma_{i}$. It follows that the CDF of the observed data is $$ F(y) = \int_{-\infty}^{y} \sum_{i} w_{i} p_{i}(x) dx = \sum_{i} w_{i} \int_{-\infty}^{y} p_{i}(x) = \sum_{i} w_{i} F_{i}(y) $$ where $F_{i}(x)$ is the normal CDF with mean $\mu_{i}$ and standard deviation $\sigma_{i}$. Integration and summation can be interchanged because these integrals are finite. This CDF is continuous and easy enough to calculate on a computer, so the inverse CDF, $F^{-1}$, also known as the quantile function, can be calculated by doing a line search. I default to this option because no simple formula for the quantile function of a mixture of normals, as a function of the quantiles of the constituent distributions, comes to mind. The following R code numerically calculates $F^{-1}$ using bisection for the line search. The function F_inv() is the quantile function, you need to supply the vector containing each $w_{i}, \mu_{i}, \sigma_{i}$ and the quantile to be solved for, $p$. # evaluate the function at the point x, where the components # of the mixture have weights w, means stored in u, and std deviations # stored in s - all must have the same length. F = function(x,w,u,s) sum( w*pnorm(x,mean=u,sd=s) ) # provide an initial bracket for the quantile. default is c(-1000,1000). F_inv = function(p,w,u,s,br=c(-1000,1000)) { G = function(x) F(x,w,u,s) - p return( uniroot(G,br)$root ) } #test # data is 50% N(0,1), 25% N(2,1), 20% N(5,1), 5% N(10,1) X = c(rnorm(5000), rnorm(2500,mean=2,sd=1),rnorm(2000,mean=5,sd=1),rnorm(500,mean=10,sd=1)) quantile(X,.95) 95% 7.69205 F_inv(.95,c(.5,.25,.2,.05),c(0,2,5,10),c(1,1,1,1)) [1] 7.745526 # data is 20% N(-5,1), 45% N(5,1), 30% N(10,1), 5% N(15,1) X = c(rnorm(5000,mean=-5,sd=1), rnorm(2500,mean=5,sd=1), rnorm(2000,mean=10,sd=1), rnorm(500, mean=15,sd=1)) quantile(X,.95) 95% 12.69563 F_inv(.95,c(.2,.45,.3,.05),c(-5,5,10,15),c(1,1,1,1)) [1] 12.81730
Quantiles from the combination of normal distributions
Unfortunately, the standard normal (from which all others can be determined, since the normal is a location-scale family) quantile function does not admit a closed form (i.e. a 'pretty formula'). The
Quantiles from the combination of normal distributions Unfortunately, the standard normal (from which all others can be determined, since the normal is a location-scale family) quantile function does not admit a closed form (i.e. a 'pretty formula'). The closest thing to a closed form is that the standard normal quantile function is the function, $w$, that satisfies the differential equation $$ \frac{d^2 w}{d p^2} = w \left(\frac{d w}{d p}\right)^2 $$ and the initial conditions $w(1/2) = 0$ and $w'(1/2) = \sqrt{2 \pi}$. In most computing environments there is a function that numerically calculates the normal quantile function. In R, you would type qnorm(p, mean=mu, sd=sigma) to get the $p$'th quantile of the $N(\mu, \sigma^2)$ distribution. Edit: With a modified understanding of the problem, the data is generated from a mixture of normals, so that the density of the observed data is: $$ p(x) = \sum_{i} w_{i} p_{i}(x) $$ where $\sum_{i} w_{i} = 1$ and each $p_{i}(x)$ is some normal density with mean $\mu_{i}$ and standard deviation $\sigma_{i}$. It follows that the CDF of the observed data is $$ F(y) = \int_{-\infty}^{y} \sum_{i} w_{i} p_{i}(x) dx = \sum_{i} w_{i} \int_{-\infty}^{y} p_{i}(x) = \sum_{i} w_{i} F_{i}(y) $$ where $F_{i}(x)$ is the normal CDF with mean $\mu_{i}$ and standard deviation $\sigma_{i}$. Integration and summation can be interchanged because these integrals are finite. This CDF is continuous and easy enough to calculate on a computer, so the inverse CDF, $F^{-1}$, also known as the quantile function, can be calculated by doing a line search. I default to this option because no simple formula for the quantile function of a mixture of normals, as a function of the quantiles of the constituent distributions, comes to mind. The following R code numerically calculates $F^{-1}$ using bisection for the line search. The function F_inv() is the quantile function, you need to supply the vector containing each $w_{i}, \mu_{i}, \sigma_{i}$ and the quantile to be solved for, $p$. # evaluate the function at the point x, where the components # of the mixture have weights w, means stored in u, and std deviations # stored in s - all must have the same length. F = function(x,w,u,s) sum( w*pnorm(x,mean=u,sd=s) ) # provide an initial bracket for the quantile. default is c(-1000,1000). F_inv = function(p,w,u,s,br=c(-1000,1000)) { G = function(x) F(x,w,u,s) - p return( uniroot(G,br)$root ) } #test # data is 50% N(0,1), 25% N(2,1), 20% N(5,1), 5% N(10,1) X = c(rnorm(5000), rnorm(2500,mean=2,sd=1),rnorm(2000,mean=5,sd=1),rnorm(500,mean=10,sd=1)) quantile(X,.95) 95% 7.69205 F_inv(.95,c(.5,.25,.2,.05),c(0,2,5,10),c(1,1,1,1)) [1] 7.745526 # data is 20% N(-5,1), 45% N(5,1), 30% N(10,1), 5% N(15,1) X = c(rnorm(5000,mean=-5,sd=1), rnorm(2500,mean=5,sd=1), rnorm(2000,mean=10,sd=1), rnorm(500, mean=15,sd=1)) quantile(X,.95) 95% 12.69563 F_inv(.95,c(.2,.45,.3,.05),c(-5,5,10,15),c(1,1,1,1)) [1] 12.81730
Quantiles from the combination of normal distributions Unfortunately, the standard normal (from which all others can be determined, since the normal is a location-scale family) quantile function does not admit a closed form (i.e. a 'pretty formula'). The
16,533
How to create coloured tables with Sweave and xtable? [closed]
Although I didn't try this explicitly from with R (I usually post-process the Tables in Latex directly with \rowcolor, \rowcolors, or the colortbl package), I think it would be easy to do this by playing with the add.to.row arguments in print.xtable(). It basically expect two components (passed as list): (1) row number, and (2) $\LaTeX$ command. Please note that command are added at the end of the specified row(s). It seems to work, with the colortbl package. So, something like this <<result=tex>> library(xtable) m <- matrix(sample(1:10,10), nr=2) print(xtable(m), add.to.row=list(list(1),"\\rowcolor[gray]{.8} ")) @ gives me (This is a customized Beamer template, but this should work with a standard document. With Beamer, you'll probably want to add the table option when loading the package.) Update: Following @Conjugate's suggestion, you can also rely on Hmisc facilities for handling $\TeX$ output, see the many options of the latex() function. Here is an example of use: library(Hmisc) ## print the second row in bold (including row label) form.mat <- matrix(c(rep("", 5), rep("bfseries", 5)), nr=2, byrow=TRUE) w1 <- latex(m, rownamesTexCmd=c("","bfseries"), cellTexCmds=form.mat, numeric.dollar=FALSE, file='/tmp/out1.tex') w1 # call latex on /tmp/out1.tex ## highlight the second row in gray (as above) w2 <- latex(m, rownamesTexCmd=c("","rowcolor[gray]{.8}"), numeric.dollar=FALSE, file='/tmp/out2.tex') w2
How to create coloured tables with Sweave and xtable? [closed]
Although I didn't try this explicitly from with R (I usually post-process the Tables in Latex directly with \rowcolor, \rowcolors, or the colortbl package), I think it would be easy to do this by play
How to create coloured tables with Sweave and xtable? [closed] Although I didn't try this explicitly from with R (I usually post-process the Tables in Latex directly with \rowcolor, \rowcolors, or the colortbl package), I think it would be easy to do this by playing with the add.to.row arguments in print.xtable(). It basically expect two components (passed as list): (1) row number, and (2) $\LaTeX$ command. Please note that command are added at the end of the specified row(s). It seems to work, with the colortbl package. So, something like this <<result=tex>> library(xtable) m <- matrix(sample(1:10,10), nr=2) print(xtable(m), add.to.row=list(list(1),"\\rowcolor[gray]{.8} ")) @ gives me (This is a customized Beamer template, but this should work with a standard document. With Beamer, you'll probably want to add the table option when loading the package.) Update: Following @Conjugate's suggestion, you can also rely on Hmisc facilities for handling $\TeX$ output, see the many options of the latex() function. Here is an example of use: library(Hmisc) ## print the second row in bold (including row label) form.mat <- matrix(c(rep("", 5), rep("bfseries", 5)), nr=2, byrow=TRUE) w1 <- latex(m, rownamesTexCmd=c("","bfseries"), cellTexCmds=form.mat, numeric.dollar=FALSE, file='/tmp/out1.tex') w1 # call latex on /tmp/out1.tex ## highlight the second row in gray (as above) w2 <- latex(m, rownamesTexCmd=c("","rowcolor[gray]{.8}"), numeric.dollar=FALSE, file='/tmp/out2.tex') w2
How to create coloured tables with Sweave and xtable? [closed] Although I didn't try this explicitly from with R (I usually post-process the Tables in Latex directly with \rowcolor, \rowcolors, or the colortbl package), I think it would be easy to do this by play
16,534
Application of machine learning techniques in small sample clinical studies
I haven't seen this used in outside of bioinformatics/machine learning either, but maybe you can be the first one :) As a good representative of small sample method method from bioinformatics, logistic regression with L1 regularization can give a good fit when number of parameters is exponential in the number of observations, non-asymptotic confidence intervals can be crafted using Chernoff-type inequalities (ie, Dudik, (2004) for example). Trevor Hastie has done some work applying these methods to identifying gene interactions. In the paper below, he uses it to identify significant effects from a model with 310,637 adjustable parameters fit to a sample of 2200 observations "Genome-wide association analysis by lasso penalized logistic regression." Authors: Hastie, T; Sobel, E; Wu, T. T; Chen, Y. F; Lange, K Bioinformatics Vol: 25 Issue: 6 ISSN: 1367-4803 Date: 03/2009 Pages: 714 - 721 Related presentation by Victoria Stodden (Model Selection with Many More Variables than Observations )
Application of machine learning techniques in small sample clinical studies
I haven't seen this used in outside of bioinformatics/machine learning either, but maybe you can be the first one :) As a good representative of small sample method method from bioinformatics, logisti
Application of machine learning techniques in small sample clinical studies I haven't seen this used in outside of bioinformatics/machine learning either, but maybe you can be the first one :) As a good representative of small sample method method from bioinformatics, logistic regression with L1 regularization can give a good fit when number of parameters is exponential in the number of observations, non-asymptotic confidence intervals can be crafted using Chernoff-type inequalities (ie, Dudik, (2004) for example). Trevor Hastie has done some work applying these methods to identifying gene interactions. In the paper below, he uses it to identify significant effects from a model with 310,637 adjustable parameters fit to a sample of 2200 observations "Genome-wide association analysis by lasso penalized logistic regression." Authors: Hastie, T; Sobel, E; Wu, T. T; Chen, Y. F; Lange, K Bioinformatics Vol: 25 Issue: 6 ISSN: 1367-4803 Date: 03/2009 Pages: 714 - 721 Related presentation by Victoria Stodden (Model Selection with Many More Variables than Observations )
Application of machine learning techniques in small sample clinical studies I haven't seen this used in outside of bioinformatics/machine learning either, but maybe you can be the first one :) As a good representative of small sample method method from bioinformatics, logisti
16,535
Application of machine learning techniques in small sample clinical studies
I would have very little confidence in the generalisability of results of an exploratory analysis with 15 predictors and a sample size of 20. The confidence intervals of parameter estimates would be large. E.g., the 95% confidence interval on r = .30 with n = 20 is -0.17 to 0.66 . Issues tend to be compounded when you have multiple predictors used in an exploratory and data driven way. In such circumstances, my advice would generally be to limit analyses to bivariate relationships. If you take a bayesian perspective, then I'd say that your prior expectations are equally if not more important than the data.
Application of machine learning techniques in small sample clinical studies
I would have very little confidence in the generalisability of results of an exploratory analysis with 15 predictors and a sample size of 20. The confidence intervals of parameter estimates would be
Application of machine learning techniques in small sample clinical studies I would have very little confidence in the generalisability of results of an exploratory analysis with 15 predictors and a sample size of 20. The confidence intervals of parameter estimates would be large. E.g., the 95% confidence interval on r = .30 with n = 20 is -0.17 to 0.66 . Issues tend to be compounded when you have multiple predictors used in an exploratory and data driven way. In such circumstances, my advice would generally be to limit analyses to bivariate relationships. If you take a bayesian perspective, then I'd say that your prior expectations are equally if not more important than the data.
Application of machine learning techniques in small sample clinical studies I would have very little confidence in the generalisability of results of an exploratory analysis with 15 predictors and a sample size of 20. The confidence intervals of parameter estimates would be
16,536
Application of machine learning techniques in small sample clinical studies
One common rule of thumb is to have at least 10 times the number of training data instances (not to speak of any test/validation data, etc.) as there are adjustable parameters in the classifier. Keep in mind that you have a problem wherein you need to not only have adequate data but also representative data. In the end, there is no systematic rule because there are so many variables when making this decision. As Hastie, Tibshirani, and Friedman say in The Elements of Statistical Learning (see Chapter 7): it is too difficult to give a general rule on how much training data is enough; among other things, this depends on the signal-to-noise ratio of the underlying function, and the complexity of the models being fit to the data. If you are new to this field, I recommend reading this short "Pattern Recognition" paper from the Encyclopedia of Biomedical Engineering which gives a brief summary of some of the data issues.
Application of machine learning techniques in small sample clinical studies
One common rule of thumb is to have at least 10 times the number of training data instances (not to speak of any test/validation data, etc.) as there are adjustable parameters in the classifier. Keep
Application of machine learning techniques in small sample clinical studies One common rule of thumb is to have at least 10 times the number of training data instances (not to speak of any test/validation data, etc.) as there are adjustable parameters in the classifier. Keep in mind that you have a problem wherein you need to not only have adequate data but also representative data. In the end, there is no systematic rule because there are so many variables when making this decision. As Hastie, Tibshirani, and Friedman say in The Elements of Statistical Learning (see Chapter 7): it is too difficult to give a general rule on how much training data is enough; among other things, this depends on the signal-to-noise ratio of the underlying function, and the complexity of the models being fit to the data. If you are new to this field, I recommend reading this short "Pattern Recognition" paper from the Encyclopedia of Biomedical Engineering which gives a brief summary of some of the data issues.
Application of machine learning techniques in small sample clinical studies One common rule of thumb is to have at least 10 times the number of training data instances (not to speak of any test/validation data, etc.) as there are adjustable parameters in the classifier. Keep
16,537
Application of machine learning techniques in small sample clinical studies
I can assure you that RF would work in that case and its importance measure would be pretty insightful (because there will be no large tail of misleading unimportant attributes like in standard (n << p)s). I can't recall now any paper dealing with similar problem, but I'll look for it.
Application of machine learning techniques in small sample clinical studies
I can assure you that RF would work in that case and its importance measure would be pretty insightful (because there will be no large tail of misleading unimportant attributes like in standard (n <<
Application of machine learning techniques in small sample clinical studies I can assure you that RF would work in that case and its importance measure would be pretty insightful (because there will be no large tail of misleading unimportant attributes like in standard (n << p)s). I can't recall now any paper dealing with similar problem, but I'll look for it.
Application of machine learning techniques in small sample clinical studies I can assure you that RF would work in that case and its importance measure would be pretty insightful (because there will be no large tail of misleading unimportant attributes like in standard (n <<
16,538
Application of machine learning techniques in small sample clinical studies
If you have discrete inputs, I'm writing a program to predict missing values of a binary input, given previous inputs. Any categories, e.g. "1 of 6", can be converted into binary bits, and it will work just fine; it won't effect it. The purpose of the algorithm I'm writing is to learn as fast as mathematically possible. Consequently it has very poor time and space complexity (space complexity about O(4^N)!. But for that you get essentially 1-off learning, for any system whose state can be expressed as a bit vector. For instance, a full-adder has 8 distinct input states. The algorithm will learn a full adder perfectly after only 8 distinct training samples. Not only that, but you can then give it the answer and have it predict the question, or give it part of the answer and part of the question and have it fill in the remaining. If the input data has a lot of bits, it'll be pretty computation and memory intensive. But if you've got very few samples, - or so the design goal is - it will give you near the best predictions possible. You just train it with bit vectors, including a bit vector of which bits are unknown. To get a prediction, you likewise just feed it a bit vector, which bits are unknown, and which bits you want it to predict. Source code available here: https://sourceforge.net/p/aithroughlogiccompression/code/HEAD/tree/BayesianInferenceEngine/src/_version2/
Application of machine learning techniques in small sample clinical studies
If you have discrete inputs, I'm writing a program to predict missing values of a binary input, given previous inputs. Any categories, e.g. "1 of 6", can be converted into binary bits, and it will wo
Application of machine learning techniques in small sample clinical studies If you have discrete inputs, I'm writing a program to predict missing values of a binary input, given previous inputs. Any categories, e.g. "1 of 6", can be converted into binary bits, and it will work just fine; it won't effect it. The purpose of the algorithm I'm writing is to learn as fast as mathematically possible. Consequently it has very poor time and space complexity (space complexity about O(4^N)!. But for that you get essentially 1-off learning, for any system whose state can be expressed as a bit vector. For instance, a full-adder has 8 distinct input states. The algorithm will learn a full adder perfectly after only 8 distinct training samples. Not only that, but you can then give it the answer and have it predict the question, or give it part of the answer and part of the question and have it fill in the remaining. If the input data has a lot of bits, it'll be pretty computation and memory intensive. But if you've got very few samples, - or so the design goal is - it will give you near the best predictions possible. You just train it with bit vectors, including a bit vector of which bits are unknown. To get a prediction, you likewise just feed it a bit vector, which bits are unknown, and which bits you want it to predict. Source code available here: https://sourceforge.net/p/aithroughlogiccompression/code/HEAD/tree/BayesianInferenceEngine/src/_version2/
Application of machine learning techniques in small sample clinical studies If you have discrete inputs, I'm writing a program to predict missing values of a binary input, given previous inputs. Any categories, e.g. "1 of 6", can be converted into binary bits, and it will wo
16,539
How to handle Simpson's paradox
For the case in which all patient descriptors are in the correct part of a causal diagram, a necessary but not sufficient condition for which is that the descriptors are assessed at "time zero" or before, Simpson's "paradox" is nothing more than a failure to ask a specific enough question. Stay away from marginal treatment effects and instead condition on all available information that is consistent with causal pathways. In the case of age and sex it is seldom inappropriate to condition on them. Treatment effects should be conditional and respect information flow. Focus on making the best treatment decision for the one patient being treated.
How to handle Simpson's paradox
For the case in which all patient descriptors are in the correct part of a causal diagram, a necessary but not sufficient condition for which is that the descriptors are assessed at "time zero" or bef
How to handle Simpson's paradox For the case in which all patient descriptors are in the correct part of a causal diagram, a necessary but not sufficient condition for which is that the descriptors are assessed at "time zero" or before, Simpson's "paradox" is nothing more than a failure to ask a specific enough question. Stay away from marginal treatment effects and instead condition on all available information that is consistent with causal pathways. In the case of age and sex it is seldom inappropriate to condition on them. Treatment effects should be conditional and respect information flow. Focus on making the best treatment decision for the one patient being treated.
How to handle Simpson's paradox For the case in which all patient descriptors are in the correct part of a causal diagram, a necessary but not sufficient condition for which is that the descriptors are assessed at "time zero" or bef
16,540
How to handle Simpson's paradox
"What do practitioners do in such cases?" The key thing is to understand why, in the specific situation, Simpson's paradox arises. This depends on the situation. Let's imagine a medical trial example in which there are men, and women, treatment and placebo, "improvement" or "no improvement/harm". It may be that women are generally far more likely to show improvements, and also for some reason women received much placebo and little treatment. In this situation placebo may look inferior to treatment for both men and women, but better after aggregation. It is very important now why it happened that relatively more women were in the placebo group. If this was a randomised trial and it's just because of random variation of assignment, whereas the difference between men and women is meaningful, surely one should go by the men and women results individually (because the aggregation difference is not meaningful whereas the men/women difference is). However, one could also imagine a situation in which in fact for ethical reasons (probably not a valid thing to do in a clinical trial but anyway) there are a number of severe cases and it was decided that those are all given treatment, and almost all of these were men, and that among the non-severe cases there are no meaningful differences between men and women. Then one cannot say the treatment is better for both men and women, therefore better overall (despite the aggregate) - however one would need to take into account severity and couldn't make a conclusion by just looking at the aggregate either (because once more things are aggregated that are essentially different). One can also imagine a situation in which the differences between the groups involved in the paradox are not meaningful, and therefore the aggregate is more relevant, although that's more difficult (as there need to be systematic differences between the groups in order for the paradox to work - the situation needs to be constructed in such a way that these systematic differences are irrelevant to the study aim - unlikely in clinical trials, more likely maybe in social sciences where randomisation cannot be done and administrative decisions peripheral to the study aim may play a role). In any case the baseline is that the occurrence of Simpson's paradox needs to be explained from background information, and what to do depends crucially on that explanation. "Or is the Simpson's phenomenon ipso facto indicative of insufficient sample size/significance level, and hence renders the trial inconclusive?" No, in principle it can occur at any sample size, increasing it will not necessarily make it go away. One exception is if it occurs in a randomised trial due to an imbalance in groups caused by freak random numbers - this may be balanced out with a larger sample (once more it is important to understand what caused it).
How to handle Simpson's paradox
"What do practitioners do in such cases?" The key thing is to understand why, in the specific situation, Simpson's paradox arises. This depends on the situation. Let's imagine a medical trial example
How to handle Simpson's paradox "What do practitioners do in such cases?" The key thing is to understand why, in the specific situation, Simpson's paradox arises. This depends on the situation. Let's imagine a medical trial example in which there are men, and women, treatment and placebo, "improvement" or "no improvement/harm". It may be that women are generally far more likely to show improvements, and also for some reason women received much placebo and little treatment. In this situation placebo may look inferior to treatment for both men and women, but better after aggregation. It is very important now why it happened that relatively more women were in the placebo group. If this was a randomised trial and it's just because of random variation of assignment, whereas the difference between men and women is meaningful, surely one should go by the men and women results individually (because the aggregation difference is not meaningful whereas the men/women difference is). However, one could also imagine a situation in which in fact for ethical reasons (probably not a valid thing to do in a clinical trial but anyway) there are a number of severe cases and it was decided that those are all given treatment, and almost all of these were men, and that among the non-severe cases there are no meaningful differences between men and women. Then one cannot say the treatment is better for both men and women, therefore better overall (despite the aggregate) - however one would need to take into account severity and couldn't make a conclusion by just looking at the aggregate either (because once more things are aggregated that are essentially different). One can also imagine a situation in which the differences between the groups involved in the paradox are not meaningful, and therefore the aggregate is more relevant, although that's more difficult (as there need to be systematic differences between the groups in order for the paradox to work - the situation needs to be constructed in such a way that these systematic differences are irrelevant to the study aim - unlikely in clinical trials, more likely maybe in social sciences where randomisation cannot be done and administrative decisions peripheral to the study aim may play a role). In any case the baseline is that the occurrence of Simpson's paradox needs to be explained from background information, and what to do depends crucially on that explanation. "Or is the Simpson's phenomenon ipso facto indicative of insufficient sample size/significance level, and hence renders the trial inconclusive?" No, in principle it can occur at any sample size, increasing it will not necessarily make it go away. One exception is if it occurs in a randomised trial due to an imbalance in groups caused by freak random numbers - this may be balanced out with a larger sample (once more it is important to understand what caused it).
How to handle Simpson's paradox "What do practitioners do in such cases?" The key thing is to understand why, in the specific situation, Simpson's paradox arises. This depends on the situation. Let's imagine a medical trial example
16,541
How to handle Simpson's paradox
tl;dr– Simpson's paradox isn't problematic unless correlations are inappropriately assumed to be causative. Background: Simpson's paradox only happens when causation was fallaciously assumed. Let's suppose these premises: Healthcare can help apparently-healthy people. Healthcare can help apparently-not-healthy people. People receiving healthcare are more likely to be apparently-not-healthy. Here we have an opportunity for Simpson's paradox: the bulk population has a negative association between apparent-health and receiving healthcare, despite each of the two sub-populations having a positive association. But it's not really paradoxical (confusing), right? I mean, obviously, the negative association is due to people seeking medical attention when they're apparently-not-healthy. The missing component is assuming causation. For example, if someone does a study on the correlation between apparent-health and receiving-healthcare, then assumes it causative, then they'd perceive a paradoxical situation in which: Healthcare helps healthy people. Healthcare helps not-healthy people. Healthcare hurts (healthy OR not-healthy) people. Absent false presumptions of causation, Simpson's paradox isn't a paradox. How to handle Simpson's paradox? Same thing you do when you discover that $1 = 2 :$ realize that someone messed up along the way. To be clear, a legitimate analysis can find correlations in which the total population has a different correlation than its component sub-populations, such as in the example above. But a legitimate analysis shouldn't be able to arrive at a situation where causative behavior is reversed.
How to handle Simpson's paradox
tl;dr– Simpson's paradox isn't problematic unless correlations are inappropriately assumed to be causative. Background: Simpson's paradox only happens when causation was fallaciously assumed. Let's
How to handle Simpson's paradox tl;dr– Simpson's paradox isn't problematic unless correlations are inappropriately assumed to be causative. Background: Simpson's paradox only happens when causation was fallaciously assumed. Let's suppose these premises: Healthcare can help apparently-healthy people. Healthcare can help apparently-not-healthy people. People receiving healthcare are more likely to be apparently-not-healthy. Here we have an opportunity for Simpson's paradox: the bulk population has a negative association between apparent-health and receiving healthcare, despite each of the two sub-populations having a positive association. But it's not really paradoxical (confusing), right? I mean, obviously, the negative association is due to people seeking medical attention when they're apparently-not-healthy. The missing component is assuming causation. For example, if someone does a study on the correlation between apparent-health and receiving-healthcare, then assumes it causative, then they'd perceive a paradoxical situation in which: Healthcare helps healthy people. Healthcare helps not-healthy people. Healthcare hurts (healthy OR not-healthy) people. Absent false presumptions of causation, Simpson's paradox isn't a paradox. How to handle Simpson's paradox? Same thing you do when you discover that $1 = 2 :$ realize that someone messed up along the way. To be clear, a legitimate analysis can find correlations in which the total population has a different correlation than its component sub-populations, such as in the example above. But a legitimate analysis shouldn't be able to arrive at a situation where causative behavior is reversed.
How to handle Simpson's paradox tl;dr– Simpson's paradox isn't problematic unless correlations are inappropriately assumed to be causative. Background: Simpson's paradox only happens when causation was fallaciously assumed. Let's
16,542
What is use of Tweedie or poisson loss/objective function in XGboost and Deep learning models
I used to develop these models professionally for a major casualty insurer, and probably had a part in developing the data for one of the Kaggle competition's you're referencing. So I'm relatively well positioned for this question. Can someone please explain the use/need for using Tweedie or poisson instead of the regular mean squared loss as objective. The goal of these models is to price insurance contracts. I.e., we want to know, for a customer who as purchased an insurance contract, how much our company will pay out in total claim costs for the customer. So let's let $X$ denote all the measurements we have for a single customer we've insured. There are two possibilities for what happens over the life of the contract: The insured files no claims. In this case the company pays out nothing. Let's call $F$ the random variable counting the number of claims filed by the insured over the contract period. This is often assumed to be poisson distributed, as a decent approximation. In the jargon of the industry, this random variable is called the frequency. The insured files at least one claim. Then, for each claim, a random amount is payed out by our company. Let's denote the amount payed out for the $i$'th claim $S_i$. This is a continuous random variable with a heavy right tail. It is often assumed these are gamma distributed, because the shape is intuitively reasonable. In the jargon of the industry, these are called the severity. Putting that all together, the amount payed out over the insurance contract is a random variable: $$Y \mid X = \sum_{i \sim F} S_i $$ This is a funny little equation, but basically there is a random number of summands, according the the frequency $F$, and each summand $S_i$ is a random claim amount (for a single claim). If $F$ is poisson, and each $S_i$ is a gamma distribution, this is the Tweedie distribution. Reasonable assumptions lead to a parametric assumption that $Y \mid X$ is Tweedie distributed. Is it because of the distribution of the response variable ? As noted above, sort of. It's actually the conditional distribution of the response variable (so $Y \mid X$, not the marginal $Y$), which we never really observe. Some features of the conditional distributions manifest in the marginal, like the large point mass at zero. If the response is variable is positive and right skewed, should we always use Tweedie or poisson instead of mean squared loss ? Nope. It's the conditional distribution $Y \mid X$ that guides the choice of loss function, which often comes from thought and imagination like the above. The (marginal) distribution of $Y$ can be skew even if the conditional distributions $Y \mid X$ is symmetric. For example: $$ X \sim \text{Poisson}(\lambda = 1.0) $$ $$ Y \mid X \sim \text{Normal}(\mu = X, \sigma = 1.0) $$ Will lead to a right skew marginal distribution of $Y$, but the least squares loss is exactly correct to use. Is the sales forecasting same as the claims example - where each sale is poisson and sale amount is gamma distributed? I haven't done any projects in this area, but that sounds like a reasonable approach. Can you please explain, how/why claim amount follows gamma distribution. There's no magic here, there's no principled theory about claims distributions. Roughly, it has the correct shape: it's positively supported (i.e. $P(G \leq 0) = 0$), it's unimodal, and it has a positive skew; and it leads to mathematically tractable models. That's about it, it's just a reasonable choice which has worked well for a long time.
What is use of Tweedie or poisson loss/objective function in XGboost and Deep learning models
I used to develop these models professionally for a major casualty insurer, and probably had a part in developing the data for one of the Kaggle competition's you're referencing. So I'm relatively wel
What is use of Tweedie or poisson loss/objective function in XGboost and Deep learning models I used to develop these models professionally for a major casualty insurer, and probably had a part in developing the data for one of the Kaggle competition's you're referencing. So I'm relatively well positioned for this question. Can someone please explain the use/need for using Tweedie or poisson instead of the regular mean squared loss as objective. The goal of these models is to price insurance contracts. I.e., we want to know, for a customer who as purchased an insurance contract, how much our company will pay out in total claim costs for the customer. So let's let $X$ denote all the measurements we have for a single customer we've insured. There are two possibilities for what happens over the life of the contract: The insured files no claims. In this case the company pays out nothing. Let's call $F$ the random variable counting the number of claims filed by the insured over the contract period. This is often assumed to be poisson distributed, as a decent approximation. In the jargon of the industry, this random variable is called the frequency. The insured files at least one claim. Then, for each claim, a random amount is payed out by our company. Let's denote the amount payed out for the $i$'th claim $S_i$. This is a continuous random variable with a heavy right tail. It is often assumed these are gamma distributed, because the shape is intuitively reasonable. In the jargon of the industry, these are called the severity. Putting that all together, the amount payed out over the insurance contract is a random variable: $$Y \mid X = \sum_{i \sim F} S_i $$ This is a funny little equation, but basically there is a random number of summands, according the the frequency $F$, and each summand $S_i$ is a random claim amount (for a single claim). If $F$ is poisson, and each $S_i$ is a gamma distribution, this is the Tweedie distribution. Reasonable assumptions lead to a parametric assumption that $Y \mid X$ is Tweedie distributed. Is it because of the distribution of the response variable ? As noted above, sort of. It's actually the conditional distribution of the response variable (so $Y \mid X$, not the marginal $Y$), which we never really observe. Some features of the conditional distributions manifest in the marginal, like the large point mass at zero. If the response is variable is positive and right skewed, should we always use Tweedie or poisson instead of mean squared loss ? Nope. It's the conditional distribution $Y \mid X$ that guides the choice of loss function, which often comes from thought and imagination like the above. The (marginal) distribution of $Y$ can be skew even if the conditional distributions $Y \mid X$ is symmetric. For example: $$ X \sim \text{Poisson}(\lambda = 1.0) $$ $$ Y \mid X \sim \text{Normal}(\mu = X, \sigma = 1.0) $$ Will lead to a right skew marginal distribution of $Y$, but the least squares loss is exactly correct to use. Is the sales forecasting same as the claims example - where each sale is poisson and sale amount is gamma distributed? I haven't done any projects in this area, but that sounds like a reasonable approach. Can you please explain, how/why claim amount follows gamma distribution. There's no magic here, there's no principled theory about claims distributions. Roughly, it has the correct shape: it's positively supported (i.e. $P(G \leq 0) = 0$), it's unimodal, and it has a positive skew; and it leads to mathematically tractable models. That's about it, it's just a reasonable choice which has worked well for a long time.
What is use of Tweedie or poisson loss/objective function in XGboost and Deep learning models I used to develop these models professionally for a major casualty insurer, and probably had a part in developing the data for one of the Kaggle competition's you're referencing. So I'm relatively wel
16,543
Why does thinning work in Bayesian inference?
Thinning has nothing to do with Bayesian inference, but everything to do with computer-based pseudo-random simulation. The whole point in generating a Markov chain $(\theta_t)$ via MCMC algorithms is to achieve more easily simulations from the posterior distribution, $\pi(\cdot)$. However, the penalty for doing so is creating correlation between the simulations. (With respect to the question, this correlation persists even asymptotically in $t$.) By subsampling or thinning out the Markov chain $(\theta_t)$, this correlation is usually (but not always) reduced as the thinning interval grows. Thinning has however nothing to do with convergence of the Markov chain to the stationary distribution $\pi(\cdot)$ since it is a post-processing of the simulated Markov chain $(\theta_t)$. Thinning only makes sense once the chain is (approximately) stationary. Removing early values of the Markov chain to eliminate the impact of the starting value is called burning or warmup. Note furthermore that thinning is rarely helpful when considering approximations of posterior expectations (by the Ergodic Theorem) $$\frac{1}{T}\sum_{t=}^T h(\theta_t) \longrightarrow \int h(\theta(\pi(\theta)\text{d}\theta$$ since using the entire (unthinned) chain most often reduces the variance of the approximation. If specific needs call for an almost iid sample from $\pi(\cdot)$, thinning may appeal, but except for specific situations where renewal can be implemented, there is no guarantee that the sample will be either "i" or "id"... The alternative solution of running several chains independently in parallel produces independent samples but again with rarely a guarantee that the points are exactly distributed from $\pi(\cdot)$.
Why does thinning work in Bayesian inference?
Thinning has nothing to do with Bayesian inference, but everything to do with computer-based pseudo-random simulation. The whole point in generating a Markov chain $(\theta_t)$ via MCMC algorithms is
Why does thinning work in Bayesian inference? Thinning has nothing to do with Bayesian inference, but everything to do with computer-based pseudo-random simulation. The whole point in generating a Markov chain $(\theta_t)$ via MCMC algorithms is to achieve more easily simulations from the posterior distribution, $\pi(\cdot)$. However, the penalty for doing so is creating correlation between the simulations. (With respect to the question, this correlation persists even asymptotically in $t$.) By subsampling or thinning out the Markov chain $(\theta_t)$, this correlation is usually (but not always) reduced as the thinning interval grows. Thinning has however nothing to do with convergence of the Markov chain to the stationary distribution $\pi(\cdot)$ since it is a post-processing of the simulated Markov chain $(\theta_t)$. Thinning only makes sense once the chain is (approximately) stationary. Removing early values of the Markov chain to eliminate the impact of the starting value is called burning or warmup. Note furthermore that thinning is rarely helpful when considering approximations of posterior expectations (by the Ergodic Theorem) $$\frac{1}{T}\sum_{t=}^T h(\theta_t) \longrightarrow \int h(\theta(\pi(\theta)\text{d}\theta$$ since using the entire (unthinned) chain most often reduces the variance of the approximation. If specific needs call for an almost iid sample from $\pi(\cdot)$, thinning may appeal, but except for specific situations where renewal can be implemented, there is no guarantee that the sample will be either "i" or "id"... The alternative solution of running several chains independently in parallel produces independent samples but again with rarely a guarantee that the points are exactly distributed from $\pi(\cdot)$.
Why does thinning work in Bayesian inference? Thinning has nothing to do with Bayesian inference, but everything to do with computer-based pseudo-random simulation. The whole point in generating a Markov chain $(\theta_t)$ via MCMC algorithms is
16,544
Why does thinning work in Bayesian inference?
Thinning does not really work. On the contrary, without thinning you end up with more samples, and so, more precise estimates (Link and Eaton, 2012). Adding to great answer by Xi'an, nowadays thinning is rarely recommend as it doesn't help that much. You could use thinning if you want to reduce disk, or memory, usage by storing less samples, but that seems to be the greatest advantage. Link, W. A., & Eaton, M. J. (2012). On thinning of chains in MCMC. Methods in ecology and evolution, 3(1), 112-115.
Why does thinning work in Bayesian inference?
Thinning does not really work. On the contrary, without thinning you end up with more samples, and so, more precise estimates (Link and Eaton, 2012). Adding to great answer by Xi'an, nowadays thinning
Why does thinning work in Bayesian inference? Thinning does not really work. On the contrary, without thinning you end up with more samples, and so, more precise estimates (Link and Eaton, 2012). Adding to great answer by Xi'an, nowadays thinning is rarely recommend as it doesn't help that much. You could use thinning if you want to reduce disk, or memory, usage by storing less samples, but that seems to be the greatest advantage. Link, W. A., & Eaton, M. J. (2012). On thinning of chains in MCMC. Methods in ecology and evolution, 3(1), 112-115.
Why does thinning work in Bayesian inference? Thinning does not really work. On the contrary, without thinning you end up with more samples, and so, more precise estimates (Link and Eaton, 2012). Adding to great answer by Xi'an, nowadays thinning
16,545
Why can RNNs with LSTM units also suffer from "exploding gradients"?
A very short answer: LSTM decouples cell state (typically denoted by c) and hidden layer/output (typically denoted by h), and only do additive updates to c, which makes memories in c more stable. Thus the gradient flows through c is kept and hard to vanish (therefore the overall gradient is hard to vanish). However, other paths may cause gradient explosion. A more detailed answer with mathematical explanation: Let's review CEC (Constant Error Carousel) mechanism first. CEC says, from time step t to t+1, if the forget gate is 1 (There's no forget gate in the original LSTM paper, thus this is always the case), the gradient $dl/dc^{t}$ can flow without change. Following to the BPTT formulae in paper LSTM: A Search Space Odyssey Appendix A.2 (y in the paper is h in other literature), the CEC flow actually corresponds to the equation $\delta c^t = \dots + \delta c^{t+1} \odot f^{t+1}$. When $f^{t+1}$ is close to 1, $\delta c^{t+1}$ accumulates to $\delta c^t$ losslessly. However, LSTM is more than CEC. Apart from the CEC path from $c^{t}$ to $c^{t+1}$, other paths do exist between two adjacent time steps. For example, $y^t \rightarrow o^{t+1} \rightarrow y^{t+1}$. Walking through the back propagation process over 2 steps, we have: $\delta y^t \leftarrow R^T_o \delta o^{t+1} \leftarrow \delta y^{t+1} \leftarrow R^T_o \delta o^{t+2}$, we see $R^T_o$ is multiplied twice on this path just like vanilla RNNs, which may cause gradient explosion. Similarly, paths through input and forget gate are also capable of causing gradient explosion due to self-multiplication of matrices $R^T_i, R^T_f, R^T_z$. Reference: K. Greff, R. K. Srivastava, J. Koutn´ık, B. R. Steunebrink, and J.Schmidhuber. LSTM: A search space odyssey. CoRR, abs/1503.04069, 2015.
Why can RNNs with LSTM units also suffer from "exploding gradients"?
A very short answer: LSTM decouples cell state (typically denoted by c) and hidden layer/output (typically denoted by h), and only do additive updates to c, which makes memories in c more stable. Thus
Why can RNNs with LSTM units also suffer from "exploding gradients"? A very short answer: LSTM decouples cell state (typically denoted by c) and hidden layer/output (typically denoted by h), and only do additive updates to c, which makes memories in c more stable. Thus the gradient flows through c is kept and hard to vanish (therefore the overall gradient is hard to vanish). However, other paths may cause gradient explosion. A more detailed answer with mathematical explanation: Let's review CEC (Constant Error Carousel) mechanism first. CEC says, from time step t to t+1, if the forget gate is 1 (There's no forget gate in the original LSTM paper, thus this is always the case), the gradient $dl/dc^{t}$ can flow without change. Following to the BPTT formulae in paper LSTM: A Search Space Odyssey Appendix A.2 (y in the paper is h in other literature), the CEC flow actually corresponds to the equation $\delta c^t = \dots + \delta c^{t+1} \odot f^{t+1}$. When $f^{t+1}$ is close to 1, $\delta c^{t+1}$ accumulates to $\delta c^t$ losslessly. However, LSTM is more than CEC. Apart from the CEC path from $c^{t}$ to $c^{t+1}$, other paths do exist between two adjacent time steps. For example, $y^t \rightarrow o^{t+1} \rightarrow y^{t+1}$. Walking through the back propagation process over 2 steps, we have: $\delta y^t \leftarrow R^T_o \delta o^{t+1} \leftarrow \delta y^{t+1} \leftarrow R^T_o \delta o^{t+2}$, we see $R^T_o$ is multiplied twice on this path just like vanilla RNNs, which may cause gradient explosion. Similarly, paths through input and forget gate are also capable of causing gradient explosion due to self-multiplication of matrices $R^T_i, R^T_f, R^T_z$. Reference: K. Greff, R. K. Srivastava, J. Koutn´ık, B. R. Steunebrink, and J.Schmidhuber. LSTM: A search space odyssey. CoRR, abs/1503.04069, 2015.
Why can RNNs with LSTM units also suffer from "exploding gradients"? A very short answer: LSTM decouples cell state (typically denoted by c) and hidden layer/output (typically denoted by h), and only do additive updates to c, which makes memories in c more stable. Thus
16,546
Why can RNNs with LSTM units also suffer from "exploding gradients"?
RNNs before LSTM/GRU used to be unstable because what they were doing through was essentially multiplication of hidden state with some weights for every timestep, which means it's an exponential operation. And as we know, exponentiation is very unstable: $$0.99^{200} \approx 0.134$$ $$1^{200} = 1$$ $$1.01^{200} \approx 13$$ LSTM/GRU cells solve this problem by turning multiplication into addition. You have a cell state, and instead of multiplying you either add or subtract from it. However there's still some paths through which the gradient might become unstable, and the bigger the net is, the more probable it is that you're gonna run into this problem.
Why can RNNs with LSTM units also suffer from "exploding gradients"?
RNNs before LSTM/GRU used to be unstable because what they were doing through was essentially multiplication of hidden state with some weights for every timestep, which means it's an exponential opera
Why can RNNs with LSTM units also suffer from "exploding gradients"? RNNs before LSTM/GRU used to be unstable because what they were doing through was essentially multiplication of hidden state with some weights for every timestep, which means it's an exponential operation. And as we know, exponentiation is very unstable: $$0.99^{200} \approx 0.134$$ $$1^{200} = 1$$ $$1.01^{200} \approx 13$$ LSTM/GRU cells solve this problem by turning multiplication into addition. You have a cell state, and instead of multiplying you either add or subtract from it. However there's still some paths through which the gradient might become unstable, and the bigger the net is, the more probable it is that you're gonna run into this problem.
Why can RNNs with LSTM units also suffer from "exploding gradients"? RNNs before LSTM/GRU used to be unstable because what they were doing through was essentially multiplication of hidden state with some weights for every timestep, which means it's an exponential opera
16,547
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA?
You might experience some issues with vanilla PCA on CLR coordinates. There are two major problems with compositional data: they are strictly non-negative they have a sum constraint Various compositional transforms address one or both of these issues. In particular, CLR transforms your data by taking the log of the ratio between observed frequencies ${\bf x}$ and their geometric mean $G({\bf x})$, i.e. $$ \hat{\bf{x}} = \left \{ \log \left (\frac{{x}_{1}}{G({\bf x})} \right), \dots, \log \left (\frac{{x}_{n}}{G({\bf x})} \right) \right \} = \left\{ \log ({x}_{1}) - \log( G({\bf x}) ) , \dots ,\log({x}_{n}) - \log( G({\bf x})) \right\} $$ Now, consider that $$ \log (G({\bf x} ))=\log \left( \exp \left[ \frac { 1 }{ n } \sum _{ i=1 }^{ n }{ \log ({ x }_{ i }) } \right] \right) = \mathop{\mathbb{E}}\left[ \log({\bf x}) \right] $$ This effectively means that $$ \sum{\hat{{\bf x}}} = \sum{ \left [ \log({\bf x}) - \mathop{\mathbb{E}}\left[ \log({\bf x}) \right] \right ]} = 0 $$ In other words CLR removes the value-range restriction (which is good for some applications), but does not remove the sum constraint, resulting in a singular covariance matrix, which effectively breaks (M)ANOVA/linear regression/... and makes PCA sensitive to outliers (because robust covariance estimation requires a full-rank matrix). As far as I know, of all compositional transforms only ILR addresses both issues without any major underlying assumptions. The situation is a bit more complicated, though. SVD of CLR coordinates gives you an orthogonal basis in the ILR space (ILR coordinates span a hyperplane in CLR), so your variance estimations will not differ between ILR and CLR (that is of course obvious, because both ILR and CLR are isometries on the simplex). There are, however, methods for robust covariance estimation on ILR coordinates [2]. Update I Just to illustrate that CLR is not valid for correlation and location-dependant methods. Let's assume we sample a community of three linearly independent normally distributed components 100 times. For the sake of simplicity, let all components have equal expectations (100) and variances (100): In [1]: import numpy as np In [2]: from scipy.stats import linregress In [3]: from scipy.stats.mstats import gmean In [4]: def clr(x): ...: return np.log(x) - np.log(gmean(x)) ...: In [5]: nsamples = 100 In [6]: samples = np.random.multivariate_normal( ...: mean=[100]*3, cov=np.eye(3)*100, size=nsamples ...: ).T In [7]: transformed = clr(samples) In [8]: np.corrcoef(transformed) Out[8]: array([[ 1. , -0.59365113, -0.49087714], [-0.59365113, 1. , -0.40968767], [-0.49087714, -0.40968767, 1. ]]) In [9]: linregress(transformed[0], transformed[1]) Out[9]: LinregressResult( ...: slope=-0.5670, intercept=-0.0027, rvalue=-0.5936, ...: pvalue=7.5398e-11, stderr=0.0776 ...: ) Update II Considering the responses I've received, I find it necessary to point out that at no point in my answer I've said that PCA doesn't work on CLR-transformed data. I've stated that CLR can break PCA in subtle ways, which might not be important for dimensionality reduction, but is important for exploratory data analysis. The paper cited by @Archie covers microbial ecology. In that field of computational biology PCA or PCoA on various distance matrices are used to explore sources of variation in the data. My answer should only be considered in this context. Moreover, this is highlighted in the paper itself: ... The compositional biplot [note: referring to PCA] has several advantages over the principal co-ordinate (PCoA) plots for β-diversity analysis. The results obtained are very stable when the data are subset (Bian et al., 2017), meaning that exploratory analysis is not driven simply by the presence absence relationships in the data nor by excessive sparsity (Wong et al., 2016; Morton et al., 2017). Gloor et al., 2017 Update III Additional references to published research (I thank @Nick Cox for the recommendation to add more references): Arguments against using CLR for PCA Arguments against using CLR for correlation-based methods Introduction to ILR
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA?
You might experience some issues with vanilla PCA on CLR coordinates. There are two major problems with compositional data: they are strictly non-negative they have a sum constraint Various composi
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA? You might experience some issues with vanilla PCA on CLR coordinates. There are two major problems with compositional data: they are strictly non-negative they have a sum constraint Various compositional transforms address one or both of these issues. In particular, CLR transforms your data by taking the log of the ratio between observed frequencies ${\bf x}$ and their geometric mean $G({\bf x})$, i.e. $$ \hat{\bf{x}} = \left \{ \log \left (\frac{{x}_{1}}{G({\bf x})} \right), \dots, \log \left (\frac{{x}_{n}}{G({\bf x})} \right) \right \} = \left\{ \log ({x}_{1}) - \log( G({\bf x}) ) , \dots ,\log({x}_{n}) - \log( G({\bf x})) \right\} $$ Now, consider that $$ \log (G({\bf x} ))=\log \left( \exp \left[ \frac { 1 }{ n } \sum _{ i=1 }^{ n }{ \log ({ x }_{ i }) } \right] \right) = \mathop{\mathbb{E}}\left[ \log({\bf x}) \right] $$ This effectively means that $$ \sum{\hat{{\bf x}}} = \sum{ \left [ \log({\bf x}) - \mathop{\mathbb{E}}\left[ \log({\bf x}) \right] \right ]} = 0 $$ In other words CLR removes the value-range restriction (which is good for some applications), but does not remove the sum constraint, resulting in a singular covariance matrix, which effectively breaks (M)ANOVA/linear regression/... and makes PCA sensitive to outliers (because robust covariance estimation requires a full-rank matrix). As far as I know, of all compositional transforms only ILR addresses both issues without any major underlying assumptions. The situation is a bit more complicated, though. SVD of CLR coordinates gives you an orthogonal basis in the ILR space (ILR coordinates span a hyperplane in CLR), so your variance estimations will not differ between ILR and CLR (that is of course obvious, because both ILR and CLR are isometries on the simplex). There are, however, methods for robust covariance estimation on ILR coordinates [2]. Update I Just to illustrate that CLR is not valid for correlation and location-dependant methods. Let's assume we sample a community of three linearly independent normally distributed components 100 times. For the sake of simplicity, let all components have equal expectations (100) and variances (100): In [1]: import numpy as np In [2]: from scipy.stats import linregress In [3]: from scipy.stats.mstats import gmean In [4]: def clr(x): ...: return np.log(x) - np.log(gmean(x)) ...: In [5]: nsamples = 100 In [6]: samples = np.random.multivariate_normal( ...: mean=[100]*3, cov=np.eye(3)*100, size=nsamples ...: ).T In [7]: transformed = clr(samples) In [8]: np.corrcoef(transformed) Out[8]: array([[ 1. , -0.59365113, -0.49087714], [-0.59365113, 1. , -0.40968767], [-0.49087714, -0.40968767, 1. ]]) In [9]: linregress(transformed[0], transformed[1]) Out[9]: LinregressResult( ...: slope=-0.5670, intercept=-0.0027, rvalue=-0.5936, ...: pvalue=7.5398e-11, stderr=0.0776 ...: ) Update II Considering the responses I've received, I find it necessary to point out that at no point in my answer I've said that PCA doesn't work on CLR-transformed data. I've stated that CLR can break PCA in subtle ways, which might not be important for dimensionality reduction, but is important for exploratory data analysis. The paper cited by @Archie covers microbial ecology. In that field of computational biology PCA or PCoA on various distance matrices are used to explore sources of variation in the data. My answer should only be considered in this context. Moreover, this is highlighted in the paper itself: ... The compositional biplot [note: referring to PCA] has several advantages over the principal co-ordinate (PCoA) plots for β-diversity analysis. The results obtained are very stable when the data are subset (Bian et al., 2017), meaning that exploratory analysis is not driven simply by the presence absence relationships in the data nor by excessive sparsity (Wong et al., 2016; Morton et al., 2017). Gloor et al., 2017 Update III Additional references to published research (I thank @Nick Cox for the recommendation to add more references): Arguments against using CLR for PCA Arguments against using CLR for correlation-based methods Introduction to ILR
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA? You might experience some issues with vanilla PCA on CLR coordinates. There are two major problems with compositional data: they are strictly non-negative they have a sum constraint Various composi
16,548
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA?
Yes you can, and in fact you should, when your data is compositional. A review from the field of microbiology can be found here, which motivates to use the CLR-transformation followed by PCA to analyze microbiome datasets (which are per definition compositional): https://www.frontiersin.org/articles/10.3389/fmicb.2017.02224/full.
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA?
Yes you can, and in fact you should, when your data is compositional. A review from the field of microbiology can be found here, which motivates to use the CLR-transformation followed by PCA to analy
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA? Yes you can, and in fact you should, when your data is compositional. A review from the field of microbiology can be found here, which motivates to use the CLR-transformation followed by PCA to analyze microbiome datasets (which are per definition compositional): https://www.frontiersin.org/articles/10.3389/fmicb.2017.02224/full.
Can I use the CLR (centered log-ratio transformation) to prepare data for PCA? Yes you can, and in fact you should, when your data is compositional. A review from the field of microbiology can be found here, which motivates to use the CLR-transformation followed by PCA to analy
16,549
When do maximum likelihood and method of moments produce the same estimators?
A general answer is that an estimator based on a method of moments is not invariant by a bijective change of parameterisation, while a maximum likelihood estimator is invariant. Therefore, they almost never coincide. (Almost never across all possible transforms.) Furthermore, as stated in the question, there are many MoM estimators. An infinity of them, actually. But they are all based on the empirical distribution, $\hat{F}$, which may be seen as a non-parametric MLE of $F$, although this does not relate to the question. Actually, a more appropriate way to frame the question would be to ask when a moment estimator is sufficient, but this forces the distribution of the data to be from an exponential family, by the Pitman-Koopman lemma, a case when the answer is already known. Note: In the Laplace distribution, when the mean is known, the problem is equivalent to observing the absolute values, which are then exponential variates and part of an exponential family.
When do maximum likelihood and method of moments produce the same estimators?
A general answer is that an estimator based on a method of moments is not invariant by a bijective change of parameterisation, while a maximum likelihood estimator is invariant. Therefore, they almost
When do maximum likelihood and method of moments produce the same estimators? A general answer is that an estimator based on a method of moments is not invariant by a bijective change of parameterisation, while a maximum likelihood estimator is invariant. Therefore, they almost never coincide. (Almost never across all possible transforms.) Furthermore, as stated in the question, there are many MoM estimators. An infinity of them, actually. But they are all based on the empirical distribution, $\hat{F}$, which may be seen as a non-parametric MLE of $F$, although this does not relate to the question. Actually, a more appropriate way to frame the question would be to ask when a moment estimator is sufficient, but this forces the distribution of the data to be from an exponential family, by the Pitman-Koopman lemma, a case when the answer is already known. Note: In the Laplace distribution, when the mean is known, the problem is equivalent to observing the absolute values, which are then exponential variates and part of an exponential family.
When do maximum likelihood and method of moments produce the same estimators? A general answer is that an estimator based on a method of moments is not invariant by a bijective change of parameterisation, while a maximum likelihood estimator is invariant. Therefore, they almost
16,550
Fine Tuning vs Joint Training vs Feature Extraction
As shown in figure 2 of {1}, in the fine-tuning strategy all weights are changed when training on the new task (except for the weights of the last layers for the original task), whereas in the feature extraction strategy only the weights of the newly added last layers change during the training phase: References: {1} Li, Zhizhong, and Derek Hoiem. "Learning without forgetting." In European Conference on Computer Vision, pp. 614-629. Springer International Publishing, 2016. https://arxiv.org/abs/1606.09282 ; https://doi.org/10.1007/978-3-319-46493-0_37
Fine Tuning vs Joint Training vs Feature Extraction
As shown in figure 2 of {1}, in the fine-tuning strategy all weights are changed when training on the new task (except for the weights of the last layers for the original task), whereas in the feature
Fine Tuning vs Joint Training vs Feature Extraction As shown in figure 2 of {1}, in the fine-tuning strategy all weights are changed when training on the new task (except for the weights of the last layers for the original task), whereas in the feature extraction strategy only the weights of the newly added last layers change during the training phase: References: {1} Li, Zhizhong, and Derek Hoiem. "Learning without forgetting." In European Conference on Computer Vision, pp. 614-629. Springer International Publishing, 2016. https://arxiv.org/abs/1606.09282 ; https://doi.org/10.1007/978-3-319-46493-0_37
Fine Tuning vs Joint Training vs Feature Extraction As shown in figure 2 of {1}, in the fine-tuning strategy all weights are changed when training on the new task (except for the weights of the last layers for the original task), whereas in the feature
16,551
Fine Tuning vs Joint Training vs Feature Extraction
I agree it's a wording error. Feature extraction in this context should mean participation of outputs from model a) in the inputs to some other model (not necessarily of the same type). For example, we could run textual inputs through transformer model like Bert, and use resulting vector as features along with simple text stats as words count, avg length etc to predict sentiment of the text using, let's say, xgboost model.
Fine Tuning vs Joint Training vs Feature Extraction
I agree it's a wording error. Feature extraction in this context should mean participation of outputs from model a) in the inputs to some other model (not necessarily of the same type). For example, w
Fine Tuning vs Joint Training vs Feature Extraction I agree it's a wording error. Feature extraction in this context should mean participation of outputs from model a) in the inputs to some other model (not necessarily of the same type). For example, we could run textual inputs through transformer model like Bert, and use resulting vector as features along with simple text stats as words count, avg length etc to predict sentiment of the text using, let's say, xgboost model.
Fine Tuning vs Joint Training vs Feature Extraction I agree it's a wording error. Feature extraction in this context should mean participation of outputs from model a) in the inputs to some other model (not necessarily of the same type). For example, w
16,552
An impossible estimation problem?
Basically, for your sample, the estimate of the size parameter is on the boundary of the parameter space. One could also consider a reparameterization such as d = size / (size+1); when size=0, d=0, when size tends to infinity, d approaches 1. It turns out that, for the parameter settings you have given, size estimates of infinity (d close to 1) happen about 13% of the time for Cox-Reid adjusted profile likelihood (APL) estimates, which is an alternative to MLE estimates for NB (example shown here). The estimates of the mean parameter (or 'prob') seem to be ok (see figure, blue lines are the true values, red dot is the estimate for your seed=167 sample). More details on the APL theory are here. So, I would say to 1.: Decent parameter estimates can be had .. size=infinity or dispersion=0 is a reasonable estimate given the sample. Consider a different parameter space and the estimates will be finite.
An impossible estimation problem?
Basically, for your sample, the estimate of the size parameter is on the boundary of the parameter space. One could also consider a reparameterization such as d = size / (size+1); when size=0, d=0, wh
An impossible estimation problem? Basically, for your sample, the estimate of the size parameter is on the boundary of the parameter space. One could also consider a reparameterization such as d = size / (size+1); when size=0, d=0, when size tends to infinity, d approaches 1. It turns out that, for the parameter settings you have given, size estimates of infinity (d close to 1) happen about 13% of the time for Cox-Reid adjusted profile likelihood (APL) estimates, which is an alternative to MLE estimates for NB (example shown here). The estimates of the mean parameter (or 'prob') seem to be ok (see figure, blue lines are the true values, red dot is the estimate for your seed=167 sample). More details on the APL theory are here. So, I would say to 1.: Decent parameter estimates can be had .. size=infinity or dispersion=0 is a reasonable estimate given the sample. Consider a different parameter space and the estimates will be finite.
An impossible estimation problem? Basically, for your sample, the estimate of the size parameter is on the boundary of the parameter space. One could also consider a reparameterization such as d = size / (size+1); when size=0, d=0, wh
16,553
An impossible estimation problem?
In the Negative Binomial (NB) example, the likelihood may have its maximum at an infinite distance for $p \to 0$ and $r \to \infty$, on the boundary of the domain $\Theta := (0,\,1)\times(0,\,\infty)$. If it turns out that the Poisson distribution leads for some mean $\lambda >0$ to a likelihood which is greater than the NB, then the likelihood can increase when $[p,\,r] \in \Theta$ moves along a path with $p \to 0$, $r \to \infty$ and $rp/(1-p) \to \lambda$. The probability that the maximum likelihood is found on the boundary is not zero. A similar problem but with simpler diagnostic is for the Lomax distribution: it is known that the ML estimate of the shape is infinite when the sample has coefficient of variation $\text{CV} < 1$. Yet the probability of this event is positive for any sample size, and is for example $>0.3$ for $\alpha = 20$ and $n = 200$. ML properties are for a large sample size: under regularity conditions, a ML estimate is shown to exist, to be unique and to tend to the true parameter. Yet for a given finite sample size, the ML estimate can fail to exist in the domain, e.g. because the maximum is reached on the boundary. It can also exist in a domain which is larger than the one used for maximisation. In the Lomax example, some people would chose to use the exponential distribution, which is the limit for $\alpha \to \infty$ and $\lambda / \alpha \to \theta >0$. This boils down to accepting an infinite ML estimate. Since the Lomax is a special re-parameterisation of the two-parameter Generalised Pareto Distribution $\text{GPD}(\sigma,\,\xi)$ with shape $\xi >0$, we could as well fit a GPD, then finding $\widehat{\xi} < 0$ instead of the exponential $\widehat{\xi} = 0$. For the NB example, we can chose to fit a Poisson distribution thus accepting a boundary value of the NB parameter. For the sake of invariance by re-parameterization, I believe that infinite parameters can make sense in some cases.
An impossible estimation problem?
In the Negative Binomial (NB) example, the likelihood may have its maximum at an infinite distance for $p \to 0$ and $r \to \infty$, on the boundary of the domain $\Theta := (0,\,1)\times(0,\,\infty)$
An impossible estimation problem? In the Negative Binomial (NB) example, the likelihood may have its maximum at an infinite distance for $p \to 0$ and $r \to \infty$, on the boundary of the domain $\Theta := (0,\,1)\times(0,\,\infty)$. If it turns out that the Poisson distribution leads for some mean $\lambda >0$ to a likelihood which is greater than the NB, then the likelihood can increase when $[p,\,r] \in \Theta$ moves along a path with $p \to 0$, $r \to \infty$ and $rp/(1-p) \to \lambda$. The probability that the maximum likelihood is found on the boundary is not zero. A similar problem but with simpler diagnostic is for the Lomax distribution: it is known that the ML estimate of the shape is infinite when the sample has coefficient of variation $\text{CV} < 1$. Yet the probability of this event is positive for any sample size, and is for example $>0.3$ for $\alpha = 20$ and $n = 200$. ML properties are for a large sample size: under regularity conditions, a ML estimate is shown to exist, to be unique and to tend to the true parameter. Yet for a given finite sample size, the ML estimate can fail to exist in the domain, e.g. because the maximum is reached on the boundary. It can also exist in a domain which is larger than the one used for maximisation. In the Lomax example, some people would chose to use the exponential distribution, which is the limit for $\alpha \to \infty$ and $\lambda / \alpha \to \theta >0$. This boils down to accepting an infinite ML estimate. Since the Lomax is a special re-parameterisation of the two-parameter Generalised Pareto Distribution $\text{GPD}(\sigma,\,\xi)$ with shape $\xi >0$, we could as well fit a GPD, then finding $\widehat{\xi} < 0$ instead of the exponential $\widehat{\xi} = 0$. For the NB example, we can chose to fit a Poisson distribution thus accepting a boundary value of the NB parameter. For the sake of invariance by re-parameterization, I believe that infinite parameters can make sense in some cases.
An impossible estimation problem? In the Negative Binomial (NB) example, the likelihood may have its maximum at an infinite distance for $p \to 0$ and $r \to \infty$, on the boundary of the domain $\Theta := (0,\,1)\times(0,\,\infty)$
16,554
Gini decrease and Gini impurity of children nodes
You simply did not used the target class variable at all. Gini impurity as all other impurity functions, measures impurity of the outputs after a split. What you have done is to measure something using only sample size. I try to derive formula for your case. Suppose for simplicity you have have a binary classifier. Denote with $A$ the test attribute, with $C$ the class attribute which have $c_+, c_-$ values. The initial gini index before split is given by $$I(A) = 1 - P(A_+)^2 - P(A_-)^2$$ where $P(A_+)$ is the proportion of data points which have $c_+$ value for class variable. Now, impurity for left node would be $$I(Al) = 1 - P(Al_+)^2-P(Al_-)^2$$ $$I(Ar) = 1 - P(Ar_+)^2-P(Ar_-)^2$$ where $P(Al_+)$ is proportion of data points from left subset of $A$ which have value $c_+$ in the class variable, etc. Now the final formula for GiniGain would be $$GiniGain(A) = I(A) - p_{left}I(Al) - p_{right}I(Ar)$$ where $p_{left}$ is the proportion of instances for the left subset, or $\frac{\#|Al|}{\#|Al|+\#|Ar|}$ (how many instances are in left subset divided by the total number of instances from $A$. I feel my notation could be improved, I will watch later when I will have more time. Conclusion Using only number of data points is not enough, impurity mean how well one feature (test feature) is able to reproduce the distribution of another feature (class feature). Test feature distribution produces the number you used (how to left, how to right), but distribution of the class feature is not used in your formulas. Later edit - proove why it decrease Now I noticed that I missed the part which proves why it always the gini index on child node is less than on parent node. I do not have a complete proove or a verified one, but I am thinking is a valid proof. For other interenting thing related with the topic you might check Technical Note: Some Properties of Splitting Criteria - Leo Breiman. Now it will follow my proof. Suppose that we are in the binary case, and all the values in a node could be completely described by a pair $(a,b)$ with the meaning of $a$ instances of the first class, and $b$ instances of the second class. We can state than that in the parent node we have $(a,b)$ instances. In order to find the best split we sort the instances according with a test feature and we try all the binary possible splits. Sorted by a given feature is actually a permutation of instances, in which classes starts with an instance of the first class or of the second class. Without loosing the generality, we will suppose that it starts with an instance of the first class (if this is not the case we have a mirror proof with the same calculation). The first split to try is in the left $(1,0)$ and in the right $(a-1,b)$ instances. How the gini index for those possible candidates for left and right child nodes are compared with the parent node? Obviously in the left we have $h(left) = 1 - (1/1)^2 - (0/1)^2 = 0$. So on the left side we have a smaller gini index value. How about the right node? $$h(parent) = 1 - (\frac{a}{a+b})^2 - (\frac{b}{a+b})^2$$ $$h(right) = 1 - (\frac{a-1}{(a-1)+b})^2 - (\frac{b}{(a-1)+b})^2$$ Considering that $a$ is greater or equal than $0$ (since otherwise how could we separate an instance of the first class in the left node?) and after simplification it's simple to see that the gini index for the right node has a smaller value than for the parent node. Now the final stage of the proof is to node that while considering all the possible split points dictated by the data we have, we keep the one which has the smallest aggregated gini index, which means that the optimum we choose is less or equal than the trivial one which I prooved that is smaller. Which concludes that in the end the gini index will decrease. As a final conclusion we have to note even if various splits can give values bigger that parent node, the one that we choose will be the smallest among them and also smaller that the parent gini index value. Hope it helps.
Gini decrease and Gini impurity of children nodes
You simply did not used the target class variable at all. Gini impurity as all other impurity functions, measures impurity of the outputs after a split. What you have done is to measure something usin
Gini decrease and Gini impurity of children nodes You simply did not used the target class variable at all. Gini impurity as all other impurity functions, measures impurity of the outputs after a split. What you have done is to measure something using only sample size. I try to derive formula for your case. Suppose for simplicity you have have a binary classifier. Denote with $A$ the test attribute, with $C$ the class attribute which have $c_+, c_-$ values. The initial gini index before split is given by $$I(A) = 1 - P(A_+)^2 - P(A_-)^2$$ where $P(A_+)$ is the proportion of data points which have $c_+$ value for class variable. Now, impurity for left node would be $$I(Al) = 1 - P(Al_+)^2-P(Al_-)^2$$ $$I(Ar) = 1 - P(Ar_+)^2-P(Ar_-)^2$$ where $P(Al_+)$ is proportion of data points from left subset of $A$ which have value $c_+$ in the class variable, etc. Now the final formula for GiniGain would be $$GiniGain(A) = I(A) - p_{left}I(Al) - p_{right}I(Ar)$$ where $p_{left}$ is the proportion of instances for the left subset, or $\frac{\#|Al|}{\#|Al|+\#|Ar|}$ (how many instances are in left subset divided by the total number of instances from $A$. I feel my notation could be improved, I will watch later when I will have more time. Conclusion Using only number of data points is not enough, impurity mean how well one feature (test feature) is able to reproduce the distribution of another feature (class feature). Test feature distribution produces the number you used (how to left, how to right), but distribution of the class feature is not used in your formulas. Later edit - proove why it decrease Now I noticed that I missed the part which proves why it always the gini index on child node is less than on parent node. I do not have a complete proove or a verified one, but I am thinking is a valid proof. For other interenting thing related with the topic you might check Technical Note: Some Properties of Splitting Criteria - Leo Breiman. Now it will follow my proof. Suppose that we are in the binary case, and all the values in a node could be completely described by a pair $(a,b)$ with the meaning of $a$ instances of the first class, and $b$ instances of the second class. We can state than that in the parent node we have $(a,b)$ instances. In order to find the best split we sort the instances according with a test feature and we try all the binary possible splits. Sorted by a given feature is actually a permutation of instances, in which classes starts with an instance of the first class or of the second class. Without loosing the generality, we will suppose that it starts with an instance of the first class (if this is not the case we have a mirror proof with the same calculation). The first split to try is in the left $(1,0)$ and in the right $(a-1,b)$ instances. How the gini index for those possible candidates for left and right child nodes are compared with the parent node? Obviously in the left we have $h(left) = 1 - (1/1)^2 - (0/1)^2 = 0$. So on the left side we have a smaller gini index value. How about the right node? $$h(parent) = 1 - (\frac{a}{a+b})^2 - (\frac{b}{a+b})^2$$ $$h(right) = 1 - (\frac{a-1}{(a-1)+b})^2 - (\frac{b}{(a-1)+b})^2$$ Considering that $a$ is greater or equal than $0$ (since otherwise how could we separate an instance of the first class in the left node?) and after simplification it's simple to see that the gini index for the right node has a smaller value than for the parent node. Now the final stage of the proof is to node that while considering all the possible split points dictated by the data we have, we keep the one which has the smallest aggregated gini index, which means that the optimum we choose is less or equal than the trivial one which I prooved that is smaller. Which concludes that in the end the gini index will decrease. As a final conclusion we have to note even if various splits can give values bigger that parent node, the one that we choose will be the smallest among them and also smaller that the parent gini index value. Hope it helps.
Gini decrease and Gini impurity of children nodes You simply did not used the target class variable at all. Gini impurity as all other impurity functions, measures impurity of the outputs after a split. What you have done is to measure something usin
16,555
How to fit a discrete distribution to count data?
Methods of fitting discrete distributions There are three main methods* used to fit (estimate the parameters of) discrete distributions. 1) Maximum Likelihood This finds the parameter values that give the best chance of supplying your sample (given the other assumptions, like independence, constant parameters, etc) 2) Method of moments This finds the parameter values that make the first few population moments match your sample moments. It’s often fairly easy to do, and in many cases yields fairly reasonable estimators. It’s also sometimes used to supply starting values to ML routines. 3) Minimum chi-square This minimizes the chi-square goodness of fit statistic over the discrete distribution, though sometimes with larger data sets, the end-categories might be combined for convenience. It often works fairly well, and it even arguably has some advantages over ML in particular situations, but generally it must be iterated to convergence, in which case most people tend to prefer ML. The first two methods are also used for continuous distributions; the third is usually not used in that case. These by no means comprise an exhaustive list, and it would be quite possible to estimate parameters by minimizing the KS-statistic for example – and even (if you adjust for the discreteness), to get a joint consonance region from it, if you were so inclined. Since you’re working in R, ML estimation is quite easy to achieve for the negative binomial. If your sample were in x, it’s as simple as library(MASS);fitdistr (x,"negative binomial"): > library(MASS) > x <- rnegbin(100,7,3) > fitdistr (x,"negative binomial") size mu 3.6200839 6.3701156 (0.8033929) (0.4192836) Those are the parameter estimates and their (asymptotic) standard errors. In the case of the Poisson distribution, MLE and MoM both estimate the Poisson parameter at the sample mean. If you'd like to see examples, you should post some actual counts. Note that your histogram has been done with bins chosen so that the 0 and 1 categories are combined and we don't have the raw counts. As near as I can guess, your data are roughly as follows: Count: 0&1 2 3 4 5 6 >6 Frequency: 311 197 74 15 3 1 0 But the big numbers will be uncertain (it depends heavily on how accurately the low-counts are represented by the pixel-counts of their bar-heights) and it could be some multiple of those numbers, like twice those numbers (the raw counts affect the standard errors, so it matters whether they're about those values or twice as big) The combining of the first two groups makes it a little bit awkward (it's possible to do, but less straightforward if you combine some categories. A lot of information is in those first two groups so it's best not to just let the default histogram lump them). * Other methods of fitting discrete distributions are possible of course (one might match quantiles or minimise other goodness of fit statistics for example). The ones I mention appear to be the most common.
How to fit a discrete distribution to count data?
Methods of fitting discrete distributions There are three main methods* used to fit (estimate the parameters of) discrete distributions. 1) Maximum Likelihood This finds the parameter values that giv
How to fit a discrete distribution to count data? Methods of fitting discrete distributions There are three main methods* used to fit (estimate the parameters of) discrete distributions. 1) Maximum Likelihood This finds the parameter values that give the best chance of supplying your sample (given the other assumptions, like independence, constant parameters, etc) 2) Method of moments This finds the parameter values that make the first few population moments match your sample moments. It’s often fairly easy to do, and in many cases yields fairly reasonable estimators. It’s also sometimes used to supply starting values to ML routines. 3) Minimum chi-square This minimizes the chi-square goodness of fit statistic over the discrete distribution, though sometimes with larger data sets, the end-categories might be combined for convenience. It often works fairly well, and it even arguably has some advantages over ML in particular situations, but generally it must be iterated to convergence, in which case most people tend to prefer ML. The first two methods are also used for continuous distributions; the third is usually not used in that case. These by no means comprise an exhaustive list, and it would be quite possible to estimate parameters by minimizing the KS-statistic for example – and even (if you adjust for the discreteness), to get a joint consonance region from it, if you were so inclined. Since you’re working in R, ML estimation is quite easy to achieve for the negative binomial. If your sample were in x, it’s as simple as library(MASS);fitdistr (x,"negative binomial"): > library(MASS) > x <- rnegbin(100,7,3) > fitdistr (x,"negative binomial") size mu 3.6200839 6.3701156 (0.8033929) (0.4192836) Those are the parameter estimates and their (asymptotic) standard errors. In the case of the Poisson distribution, MLE and MoM both estimate the Poisson parameter at the sample mean. If you'd like to see examples, you should post some actual counts. Note that your histogram has been done with bins chosen so that the 0 and 1 categories are combined and we don't have the raw counts. As near as I can guess, your data are roughly as follows: Count: 0&1 2 3 4 5 6 >6 Frequency: 311 197 74 15 3 1 0 But the big numbers will be uncertain (it depends heavily on how accurately the low-counts are represented by the pixel-counts of their bar-heights) and it could be some multiple of those numbers, like twice those numbers (the raw counts affect the standard errors, so it matters whether they're about those values or twice as big) The combining of the first two groups makes it a little bit awkward (it's possible to do, but less straightforward if you combine some categories. A lot of information is in those first two groups so it's best not to just let the default histogram lump them). * Other methods of fitting discrete distributions are possible of course (one might match quantiles or minimise other goodness of fit statistics for example). The ones I mention appear to be the most common.
How to fit a discrete distribution to count data? Methods of fitting discrete distributions There are three main methods* used to fit (estimate the parameters of) discrete distributions. 1) Maximum Likelihood This finds the parameter values that giv
16,556
How to fit a discrete distribution to count data?
In an edit, you gave some data, and added a new question: "This is a frequency table of the count data. In my problem, I am only focusing on non-zero counts. Counts: 1 2 3 4 5 6 7 9 10 Frequency: 3875 2454 921 192 37 11 1 1 2 Can someone give me an example of how you would carry out the chi-squared goodness of fit test here?" This leads to further comments: Having zeros but wanting to ignore them can make sense, but generally statistical and subject-matter people would want to see a good reason for why. If you choose to ignore zeros, you are placing yourself in difficult territory, as you can't just fire up routines for e.g. Poisson or negative binomial if you leave out the zeros. Well, you can, but the answers would be wrong. You need special purpose functions or commands for distributions such as the zero-truncated Poisson or zero-truncated negative binomial. That's challenging stuff and needs dedicated reading to be clear on what you are doing. Asking how to do a chi-square test suggests to me that you have not really understood what I said very briefly and @Glen_b said in much more detail (and, to my mind, very clearly). Splitting that in two: There can be no chi-square test without expected frequencies and there can be no expected frequencies without parameter estimates. It may be that you are most familiar with chi-square test routines in which independence of rows and columns in a two-way table is tested. Although that is the chi-square test most met in introductory courses, it is actually very unusual among chi-square tests in general in that the usual software in effect does the parameter estimation for you and thereby gets the expected frequencies. Beyond that, in most more complicated problems, such as yours, you have to get the parameter estimates first. A chi-square test isn't wrong, but if you estimate parameters by maximum likelihood it's irrelevant as the fitting routine gives you estimates and standard errors and allows tests in their wake. @Glen_b gave an example already in his answer. A side-issue is that it would be clearer to tweak your histograms to respect the discreteness of the variable and show probabilities, not densities. The apparent gaps are just artefacts of default bin choice not respecting the discreteness of the variable. UPDATE: The supplementary question about a chi-square test has now been deleted. For the moment I am letting #3 above stand, in case someone else follows the same path of wanting a chi-square test.
How to fit a discrete distribution to count data?
In an edit, you gave some data, and added a new question: "This is a frequency table of the count data. In my problem, I am only focusing on non-zero counts. Counts: 1 2 3 4 5 6
How to fit a discrete distribution to count data? In an edit, you gave some data, and added a new question: "This is a frequency table of the count data. In my problem, I am only focusing on non-zero counts. Counts: 1 2 3 4 5 6 7 9 10 Frequency: 3875 2454 921 192 37 11 1 1 2 Can someone give me an example of how you would carry out the chi-squared goodness of fit test here?" This leads to further comments: Having zeros but wanting to ignore them can make sense, but generally statistical and subject-matter people would want to see a good reason for why. If you choose to ignore zeros, you are placing yourself in difficult territory, as you can't just fire up routines for e.g. Poisson or negative binomial if you leave out the zeros. Well, you can, but the answers would be wrong. You need special purpose functions or commands for distributions such as the zero-truncated Poisson or zero-truncated negative binomial. That's challenging stuff and needs dedicated reading to be clear on what you are doing. Asking how to do a chi-square test suggests to me that you have not really understood what I said very briefly and @Glen_b said in much more detail (and, to my mind, very clearly). Splitting that in two: There can be no chi-square test without expected frequencies and there can be no expected frequencies without parameter estimates. It may be that you are most familiar with chi-square test routines in which independence of rows and columns in a two-way table is tested. Although that is the chi-square test most met in introductory courses, it is actually very unusual among chi-square tests in general in that the usual software in effect does the parameter estimation for you and thereby gets the expected frequencies. Beyond that, in most more complicated problems, such as yours, you have to get the parameter estimates first. A chi-square test isn't wrong, but if you estimate parameters by maximum likelihood it's irrelevant as the fitting routine gives you estimates and standard errors and allows tests in their wake. @Glen_b gave an example already in his answer. A side-issue is that it would be clearer to tweak your histograms to respect the discreteness of the variable and show probabilities, not densities. The apparent gaps are just artefacts of default bin choice not respecting the discreteness of the variable. UPDATE: The supplementary question about a chi-square test has now been deleted. For the moment I am letting #3 above stand, in case someone else follows the same path of wanting a chi-square test.
How to fit a discrete distribution to count data? In an edit, you gave some data, and added a new question: "This is a frequency table of the count data. In my problem, I am only focusing on non-zero counts. Counts: 1 2 3 4 5 6
16,557
Coin flipping, decision processes and value of information
Multi-armed Bandit This is a particular case of a Multi-Armed bandit problem. I say a particular case because generally we don't know any of the probabilities of heads (in this case we know one of the coins has probability 0.5). The issue you raise is known as the exploration vs exploitation dilemma: do you explore the other options, or do you stick with what you think is the best. There is an immediate optimal solution assuming you knew all probabilities: simply choose the coin with the highest probability of winning. The problem, as you have alluded to, is that we are unsure about what the true probabilities are. There is lots of literature on the subject, and there are many deterministic algorithms, but since you tagged this Bayesian, I'd like to tell you about my personal favourite solution: the Bayesian Bandit! The Baysian Bandit Solution The Bayesian approach to this problem is very natural. We are interested in answering "What is the probability that coin X is the better of the two?". A priori, assuming we have observed no coin flips yet, we have no idea what the probability of coin B's Heads might be, denote this unknown $p_B$. So we should assign a prior uniform distribution to this unknown probability. Alternatively, our prior (and posterior) for coin A is trivially concentrated entirely at 1/2. As you have stated, we observe 2 tails and 1 heads from coin B, we need to update our posterior distribution. Assuming a uniform prior, and flips are Bernoulli coin-flips, our posterior is a $Beta( 1 + 1, 1 + 2)$. Comparing the posterior distributions or A and B now: Finding an approximately optimal strategy Now that we have the posteriors, what to do? We are interested in answering "What is the probability coin B is the better of the two" (Remember from our Bayesian perspective, although there is a definite answer to which one is better, we can only speak in probabilities): $$w_B = P( p_b > 0.5 )$$ The approximately optimal solution is to choose B with probability $w_B$ and A with probability $1 - w_B$. This scheme maximizes out expected gains. $w_B$ can be computed in calculated numerically, as we know the posterior distribution, but an interesting way is the following: 1. Sample P_B from the posterior of coin B 2. If P_B > 0.5, choose coin B, else choose coin A. This scheme is also self-updating. When we observe the outcome of choosing coin B, we update our posterior with this new information, and select again. This way, if coin B is really bad we will choose it less, and it coin B is in fact really good, we will choose it more often. Of course, we are Bayesians, hence we can never be absolutely sure coin B is better. Choosing probabilistically like this is the most natural solution to the exploration-exploitation dilemma. This is a particular example of Thompson Sampling. More information, and cool applications to online advertising, can be found in Google's research paper and Yahoo's research paper. I love this stuff!
Coin flipping, decision processes and value of information
Multi-armed Bandit This is a particular case of a Multi-Armed bandit problem. I say a particular case because generally we don't know any of the probabilities of heads (in this case we know one of the
Coin flipping, decision processes and value of information Multi-armed Bandit This is a particular case of a Multi-Armed bandit problem. I say a particular case because generally we don't know any of the probabilities of heads (in this case we know one of the coins has probability 0.5). The issue you raise is known as the exploration vs exploitation dilemma: do you explore the other options, or do you stick with what you think is the best. There is an immediate optimal solution assuming you knew all probabilities: simply choose the coin with the highest probability of winning. The problem, as you have alluded to, is that we are unsure about what the true probabilities are. There is lots of literature on the subject, and there are many deterministic algorithms, but since you tagged this Bayesian, I'd like to tell you about my personal favourite solution: the Bayesian Bandit! The Baysian Bandit Solution The Bayesian approach to this problem is very natural. We are interested in answering "What is the probability that coin X is the better of the two?". A priori, assuming we have observed no coin flips yet, we have no idea what the probability of coin B's Heads might be, denote this unknown $p_B$. So we should assign a prior uniform distribution to this unknown probability. Alternatively, our prior (and posterior) for coin A is trivially concentrated entirely at 1/2. As you have stated, we observe 2 tails and 1 heads from coin B, we need to update our posterior distribution. Assuming a uniform prior, and flips are Bernoulli coin-flips, our posterior is a $Beta( 1 + 1, 1 + 2)$. Comparing the posterior distributions or A and B now: Finding an approximately optimal strategy Now that we have the posteriors, what to do? We are interested in answering "What is the probability coin B is the better of the two" (Remember from our Bayesian perspective, although there is a definite answer to which one is better, we can only speak in probabilities): $$w_B = P( p_b > 0.5 )$$ The approximately optimal solution is to choose B with probability $w_B$ and A with probability $1 - w_B$. This scheme maximizes out expected gains. $w_B$ can be computed in calculated numerically, as we know the posterior distribution, but an interesting way is the following: 1. Sample P_B from the posterior of coin B 2. If P_B > 0.5, choose coin B, else choose coin A. This scheme is also self-updating. When we observe the outcome of choosing coin B, we update our posterior with this new information, and select again. This way, if coin B is really bad we will choose it less, and it coin B is in fact really good, we will choose it more often. Of course, we are Bayesians, hence we can never be absolutely sure coin B is better. Choosing probabilistically like this is the most natural solution to the exploration-exploitation dilemma. This is a particular example of Thompson Sampling. More information, and cool applications to online advertising, can be found in Google's research paper and Yahoo's research paper. I love this stuff!
Coin flipping, decision processes and value of information Multi-armed Bandit This is a particular case of a Multi-Armed bandit problem. I say a particular case because generally we don't know any of the probabilities of heads (in this case we know one of the
16,558
Coin flipping, decision processes and value of information
This is a simple case of a multi-armed bandit problem. As you note, you want to balance the information you collect by trying the unknown coin when you think is suboptimal in the short run against exploiting the knowledge you have. In the classical multi-armed bandit problem, you would not be certain of the probability for either coin. However, here you are given that you know the value of coin A, so when you flip A, you get no information. In fact, you might as well ignore the stochastic nature of A, and assume you get a flat $1/2$ per choice of A. This means if it is ever right to flip coin A, then you should keep flipping A. So, you just want to find the optimal stopping rule for when you should give up on B. This depends on the prior distribution for the parameter for B and the number of trials. With a greater number of trials, exploring has more value, so you would test B more. In general, I think you can't get away from a dynamic programming problem, although there might be special cases where the optimal strategy can be found and checked more simply. With a uniform prior, here is where you should stop: $(0 ~ \text{heads}, 3 ~\text{tails}), (1 ~\text{head}, 5 ~\text{tails}), (2 ~\text{heads}, 6 ~\text{tails}), (3,7), (4,8),...(31,35), (32,35), (33,36), (34,37), ... (41,44), (42,44), ... (46,48), (47,48), (48,49), (49,50)$. Under this strategy, you expect to collect $61.3299$ heads. I used the following Mathematica code to compute the equities: Clear[Equity]; Equity[n_, heads_, tails_] := Equity[n, heads, tails] = If[n == 0, heads, Max[1/2 + Equity[n - 1, heads, tails], (heads + 1)/(heads + tails + 2) Equity[n - 1, heads + 1, tails] + (tails + 1)/(heads + tails + 2) Equity[n - 1, heads, tails + 1] ] ] For comparison, the Thompson sampling heuristic (which Cam Davidson Pilon claimed is optimal) gives an average of 60.2907 heads, lower by 1.03915. Thompson sampling has the problem that it sometimes samples B when you have enough information to know that it is not a good bet, and it often wastes chances to sample B early, when information is worth the most. In this type of problem, you are almost never indifferent between your options, and there is a pure optimal strategy. tp[heads_, tails_] := tp[heads, tails] = Integrate[x^heads (1 - x)^tails / Beta[heads + 1, tails + 1], {x, 0, 1/2}] Clear[Thompson]; Thompson[flipsLeft_, heads_, tails_] := Thompson[flipsLeft, heads, tails] =  If[flipsLeft == 0, heads,  Module[{p = tp[heads, tails]},  p (1/2 + Thompson[flipsLeft-1,heads,tails]) + (1-p)((heads+1)/(heads+tails+2)Thompson[flipsLeft-1,heads+1,tails] + ((tails+1)/(heads+tails+2)) Thompson[flipsLeft-1,heads,tails+1])]]
Coin flipping, decision processes and value of information
This is a simple case of a multi-armed bandit problem. As you note, you want to balance the information you collect by trying the unknown coin when you think is suboptimal in the short run against exp
Coin flipping, decision processes and value of information This is a simple case of a multi-armed bandit problem. As you note, you want to balance the information you collect by trying the unknown coin when you think is suboptimal in the short run against exploiting the knowledge you have. In the classical multi-armed bandit problem, you would not be certain of the probability for either coin. However, here you are given that you know the value of coin A, so when you flip A, you get no information. In fact, you might as well ignore the stochastic nature of A, and assume you get a flat $1/2$ per choice of A. This means if it is ever right to flip coin A, then you should keep flipping A. So, you just want to find the optimal stopping rule for when you should give up on B. This depends on the prior distribution for the parameter for B and the number of trials. With a greater number of trials, exploring has more value, so you would test B more. In general, I think you can't get away from a dynamic programming problem, although there might be special cases where the optimal strategy can be found and checked more simply. With a uniform prior, here is where you should stop: $(0 ~ \text{heads}, 3 ~\text{tails}), (1 ~\text{head}, 5 ~\text{tails}), (2 ~\text{heads}, 6 ~\text{tails}), (3,7), (4,8),...(31,35), (32,35), (33,36), (34,37), ... (41,44), (42,44), ... (46,48), (47,48), (48,49), (49,50)$. Under this strategy, you expect to collect $61.3299$ heads. I used the following Mathematica code to compute the equities: Clear[Equity]; Equity[n_, heads_, tails_] := Equity[n, heads, tails] = If[n == 0, heads, Max[1/2 + Equity[n - 1, heads, tails], (heads + 1)/(heads + tails + 2) Equity[n - 1, heads + 1, tails] + (tails + 1)/(heads + tails + 2) Equity[n - 1, heads, tails + 1] ] ] For comparison, the Thompson sampling heuristic (which Cam Davidson Pilon claimed is optimal) gives an average of 60.2907 heads, lower by 1.03915. Thompson sampling has the problem that it sometimes samples B when you have enough information to know that it is not a good bet, and it often wastes chances to sample B early, when information is worth the most. In this type of problem, you are almost never indifferent between your options, and there is a pure optimal strategy. tp[heads_, tails_] := tp[heads, tails] = Integrate[x^heads (1 - x)^tails / Beta[heads + 1, tails + 1], {x, 0, 1/2}] Clear[Thompson]; Thompson[flipsLeft_, heads_, tails_] := Thompson[flipsLeft, heads, tails] =  If[flipsLeft == 0, heads,  Module[{p = tp[heads, tails]},  p (1/2 + Thompson[flipsLeft-1,heads,tails]) + (1-p)((heads+1)/(heads+tails+2)Thompson[flipsLeft-1,heads+1,tails] + ((tails+1)/(heads+tails+2)) Thompson[flipsLeft-1,heads,tails+1])]]
Coin flipping, decision processes and value of information This is a simple case of a multi-armed bandit problem. As you note, you want to balance the information you collect by trying the unknown coin when you think is suboptimal in the short run against exp
16,559
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
Yes the Handbook of MCMC is a very up-to-date collection of papers on MCMC, Also the book by Robert and Casella is a more current account than Markov Chain Monte Carlo in Practice. But I think MCMC in Practice is really a good place to start learning the subject. Here are amazon links to descriptions of the books I mentioned above. Introducing Monte Carlo Methods with R Handbook of Markov Chain Monte Carlo
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
Yes the Handbook of MCMC is a very up-to-date collection of papers on MCMC, Also the book by Robert and Casella is a more current account than Markov Chain Monte Carlo in Practice. But I think MCMC i
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? Yes the Handbook of MCMC is a very up-to-date collection of papers on MCMC, Also the book by Robert and Casella is a more current account than Markov Chain Monte Carlo in Practice. But I think MCMC in Practice is really a good place to start learning the subject. Here are amazon links to descriptions of the books I mentioned above. Introducing Monte Carlo Methods with R Handbook of Markov Chain Monte Carlo
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? Yes the Handbook of MCMC is a very up-to-date collection of papers on MCMC, Also the book by Robert and Casella is a more current account than Markov Chain Monte Carlo in Practice. But I think MCMC i
16,560
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
I found this article to be a good review/primer on MCMC for machine learning: An Introduction to MCMC for Machine Learning - Andrieu, de Freitas, Doucet & Jordan (2003).
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
I found this article to be a good review/primer on MCMC for machine learning: An Introduction to MCMC for Machine Learning - Andrieu, de Freitas, Doucet & Jordan (2003).
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? I found this article to be a good review/primer on MCMC for machine learning: An Introduction to MCMC for Machine Learning - Andrieu, de Freitas, Doucet & Jordan (2003).
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? I found this article to be a good review/primer on MCMC for machine learning: An Introduction to MCMC for Machine Learning - Andrieu, de Freitas, Doucet & Jordan (2003).
16,561
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
SAS 9.3 now provides proc mcmc with a detailed documentation (as usual!). No fewer than 19 examples illustrate that new bayesian procedure. Simple linear regression models, linear and non-linear mixed models, but also Cox models and many other types of analysis are covered. Strictly speaking, this is not a book... but it is definitively a gold mine of applications ;-)
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?
SAS 9.3 now provides proc mcmc with a detailed documentation (as usual!). No fewer than 19 examples illustrate that new bayesian procedure. Simple linear regression models, linear and non-linear mixed
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? SAS 9.3 now provides proc mcmc with a detailed documentation (as usual!). No fewer than 19 examples illustrate that new bayesian procedure. Simple linear regression models, linear and non-linear mixed models, but also Cox models and many other types of analysis are covered. Strictly speaking, this is not a book... but it is definitively a gold mine of applications ;-)
Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? SAS 9.3 now provides proc mcmc with a detailed documentation (as usual!). No fewer than 19 examples illustrate that new bayesian procedure. Simple linear regression models, linear and non-linear mixed
16,562
Does Bayesian statistics bypass the need for the sampling distribution?
We need to be precise about the terms "frequentist" and "Bayesian", because they are ambiguous. "Frequentism" can be understood as adhering to a specific interpretation of the meaning of probability, which doesn't necessarily imply that any specific methodology needs to be applied. In this sense one can be a frequentist without ever computing confidence intervals, and as a frequentist one can do Bayesian statistics (particularly if the prior has a frequentist interpretation). However more people use "frequentist" as referring to what is known as standard frequentist approaches to inference, estimation, tests and confidence regions. These rely crucially on the sampling distribution. "Bayesian" on the other hand is often meant refer to a particular interpretation of the meaning of probability, usually understood as "epistemic" probabilities, although this is not the only possible meaning "Bayesian" can have. A frequentist probability would be defined by a data generating process in reality, whereas an epistemic probability refers to a state of knowledge of an individual (or science as a whole) about something rather than the real process that generates this "something". The concept of a "sampling distribution" is understood by frequentists as referring to a distribution of a statistic given that data are distributed according to the underlying real process. As there is no such thing in epistemic probability as an underlying real process defining probabilities, they don't have a sampling distribution in this sense. They don't "bypass" it, it is a concept that isn't meaningful for them. However a Bayesian still can think of a real process as a sampling process for choosing and processing their epistemic probabilities, in which case something can occur in the Bayesian computations that looks and acts like a sampling distribution. Note: Following a remark by Sextus Empiricus I add that when writing about "frequentists" and "Bayesians" I don't intend to imply that anybody has to be either a frequentist or a Bayesian as a person. What I do think is that whenever we do data analysis involving probabilities, we should be clear what we think these probabilities mean, and this can be frequentist, or epistemic (various versions), or other. This shouldn't stop us from adopting a different interpretation in a different situation if it seems fit. So where I write "as a frequentist", I mean "as somebody who locally, in a given situation, takes a frequentist hat", etc.
Does Bayesian statistics bypass the need for the sampling distribution?
We need to be precise about the terms "frequentist" and "Bayesian", because they are ambiguous. "Frequentism" can be understood as adhering to a specific interpretation of the meaning of probability,
Does Bayesian statistics bypass the need for the sampling distribution? We need to be precise about the terms "frequentist" and "Bayesian", because they are ambiguous. "Frequentism" can be understood as adhering to a specific interpretation of the meaning of probability, which doesn't necessarily imply that any specific methodology needs to be applied. In this sense one can be a frequentist without ever computing confidence intervals, and as a frequentist one can do Bayesian statistics (particularly if the prior has a frequentist interpretation). However more people use "frequentist" as referring to what is known as standard frequentist approaches to inference, estimation, tests and confidence regions. These rely crucially on the sampling distribution. "Bayesian" on the other hand is often meant refer to a particular interpretation of the meaning of probability, usually understood as "epistemic" probabilities, although this is not the only possible meaning "Bayesian" can have. A frequentist probability would be defined by a data generating process in reality, whereas an epistemic probability refers to a state of knowledge of an individual (or science as a whole) about something rather than the real process that generates this "something". The concept of a "sampling distribution" is understood by frequentists as referring to a distribution of a statistic given that data are distributed according to the underlying real process. As there is no such thing in epistemic probability as an underlying real process defining probabilities, they don't have a sampling distribution in this sense. They don't "bypass" it, it is a concept that isn't meaningful for them. However a Bayesian still can think of a real process as a sampling process for choosing and processing their epistemic probabilities, in which case something can occur in the Bayesian computations that looks and acts like a sampling distribution. Note: Following a remark by Sextus Empiricus I add that when writing about "frequentists" and "Bayesians" I don't intend to imply that anybody has to be either a frequentist or a Bayesian as a person. What I do think is that whenever we do data analysis involving probabilities, we should be clear what we think these probabilities mean, and this can be frequentist, or epistemic (various versions), or other. This shouldn't stop us from adopting a different interpretation in a different situation if it seems fit. So where I write "as a frequentist", I mean "as somebody who locally, in a given situation, takes a frequentist hat", etc.
Does Bayesian statistics bypass the need for the sampling distribution? We need to be precise about the terms "frequentist" and "Bayesian", because they are ambiguous. "Frequentism" can be understood as adhering to a specific interpretation of the meaning of probability,
16,563
Does Bayesian statistics bypass the need for the sampling distribution?
As Pohoua commented, your understanding is correct (but I would say not entirely*). Concepts like confidence intervals, p-values, and hypothesis tests are not calculated from the likelihood $f(\theta|x)$ with $x$ fixed, but instead with the pdf $f(x|\theta)$, where $\theta$ is fixed, which is a different slice of the joint distribution $f(x,\theta)$.Confidence intervals, p-value, and hypothesis tests, are different things than just the information from likelihood ratios. So in that sense frequentist statistics 'needs'/'uses' the sampling distribution of the entire sample $f(x\vert \theta)$ (and as Tim Maks answer argues it does not need the sample distribution in many other ways). But in your example you speak about the sampling distribution of a statistic** as in a sample distribution of values like the sample mean and sample variance (an interpretation that you repeat in a question about the CLT). This more narrow sense of sampling distribution is not necessary/needed for frequentists statistics. The sampling distribution (of a statistic) is not being used by frequentist statistics but it is the subject of many frequentist statistics. Frequentist statistics is a lot about sampling distributions of an estimate/statistic, and in Bayesian statistics the sampling distribution hardly occurs. But, for several reasons, it would be wrong to say that Bayesian statistics is 'bypassing the use of the sampling distribution'. A 'bypass' is not really the right word. Bayesian statistics is answering a different question than frequentist statistics (or at least takes a different point of view), and Bayesian statistics is no more bypassing the use of the sampling distribution than frequentist statistics is bypassing the use of the prior distribution. In a similar way a soccer/football player is not bypassing the use of a backhand and a tennis player is not bypassing the use of slidings, or a carpenter is not bypassing the use of paint and a painter is not bypassing the use of wood. *Your understanding is incorrect in the sense that it relates to the role of the difference between population distribution and sample distribution of a statistic. This misunderstanding relates to something that you expressed in an earlier question, where you end up concluding that in a Bayesian analysis one can not use the CLT because we are not supposed to think of sample distributions when using a Bayesian analysis. The likelihood function is not always so easy to compute and in that case one needs to use approximations instead of a direct analytical solution, like computational approximations by sampling. One may also use more analytical approximations, for instance like employing the CLT and a synthetic likelihood. The bypass occurs at a different level. A difference between Bayesian/frequentists statistics is that with a frequentist method you analyse the joint distribution $f(\boldsymbol{\theta},\mathbf{x})$ by considering the whole space of possible observations $x_1, x_2, \dots, x_n$, whereas with Bayesian methods you condition on the observation and only consider the values of the function $f(\boldsymbol{\theta},\mathbf{x})$ for a fixed single particular observation. This difference makes that something like using a statistic (and the related sample distribution) is useful for a frequentist method because it greatly simplifies the computations and visualisation of the whole sample space for $\mathbf{x}$, by replacing it with the sample space for a statistic. The Bayesian method does not bypass this sampling distribution. By this I do not mean that the Bayesian method needs the sampling distribution (it doesn't), but I mean that it is not a bypass. What the Bayesian method is 'bypassing' is a need to make calculations with the joint distribution of parameters and observations $f(\boldsymbol{\theta},\mathbf{x})$ for values other than the actual observation, since the method conditions on the observation. And maybe the question is indirectly about that (but it is not so clear). The sampling distribution is in fact a shortcut (and not something cumbersome that is to be bypassed). With a frequentist method you can just as well work with the likelihood function and for instance do maximum likelihood estimation or confidence intervals. But the sample distribution of an estimate/statistic is the best language to do this. Frequentist/Bayesian is not a dichotomy There is no clear border what frequentist and Bayesian statistics means. One can do empirical Bayesian analysis or use Jeffreys prior in which case one is loosening the conditioning on the observation. And one can make an analysis that is frequentist-like but is not using an estimate/statistic and it's sample distribution. Many people are just fitting curves with models by using some linear or non-linear fitting package and use something like an estimate of the inverse of the Fisher information matrix to express the variance/error of the estimate and there is no direct computation of the sample distribution. Or one can do something else like using AIC/BIC to express goodness of fit, or use a Bayes factor or fiduciary or likelihood intervals. When a sample distribution is used, then it is not really a tool that is something that can be 'bypassed'. The sample distribution is the goal itselve. And if you like you could apply it to a Bayesian estimate (although it makes less sense in such a setting). In frequentist statistics you don't have to compute a sampling distribution of an estimate. In frequentist statistics, or whatever it is, you don't have to calculate these statistics and their sample distribution. You can also work only with the likelihood function in order to make point or interval estimates. The method in the example of the question, with the sampling distribution of the mean is derived from maximum likelihood estimation and effectively equivalent. You do not need a sample distribution of a statistic or estimate (but it does make the analysis simpler) to compute it. For instance to make a maximum likelihood estimate for a population mean $\mu$ of a normal distributed population we use the likelihood function: $$\mathcal{L}(\mu \vert x_1,x_2,\dots,x_n ,\sigma) = \prod_{1\leq i \leq n} \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x_i-\mu}{\sigma}\right)^2} $$ and the $\mu$ that maximizes this function is the MLE estimate. This is very similar to Bayesian maximum a posteriori estimate, which is just maximizing $$ f_{posterior}(\mu \vert x_1,x_2,\dots,x_n ) \propto \mathcal{L}(\mu \vert x_1,x_2,\dots,x_n ,\sigma) \cdot f_{prior}(\mu)$$ The only difference is that the likelihood function is multiplied with the prior probability. Similarly for confidence intervals, one could use z or t-statistics, but effectively those statistics are shortcuts for the more difficult geometrical shape of the density distribution in all coordinates of the observation $\mathbf{x}$. We can derive p-values, statistical tests (and related confidence intervals) by only considering whether an observation is 'extreme' or not. And this can be defined by the likelihood function without considering a statistic/estimate and it's sample distribution (e.g. likelihood ratio test, if the likelihood is below a certain value than the value is not inside the confidence region). This view is also illustrated here where a test is not viewed by considering the sampling distribution of a statistic, but by considering the PDF of the whole data (in that case the data is two variables X and Y). The sample distribution occurs particularly in the method of moments. We can use the moments of a sample to estimate the moments of a distribution and in that case we may wish to express the sample distribution of the moments of a sample. But the method of moments is different from maximum likelihood estimation (but maybe this is already not frequentist?), and we do not use this sample distribution in every type of analysis. **This question is not entirely clear about what is meant with 'sampling distribution' (an ambiguity which causes two diverging type of answers). For this answer I interpret sampling distribution as the distribution of a statistic or the distribution of an estimate. And I interpret a statistic in the sense of R.A. Fisher "statistic may be defined as a function of the observations designed as an estimate of the parameters". In this answer I argue that you do not need such sampling distributions (e.g. you do not need to work as you describe, compute sample mean and sample variance. Instead, you can use the likelihood/probability function directly. But the sampling distribution, and related sufficient statistics, does make it easier.). I do not interpret sample distribution more generally as the distribution of observations/samples.
Does Bayesian statistics bypass the need for the sampling distribution?
As Pohoua commented, your understanding is correct (but I would say not entirely*). Concepts like confidence intervals, p-values, and hypothesis tests are not calculated from the likelihood $f(\theta|
Does Bayesian statistics bypass the need for the sampling distribution? As Pohoua commented, your understanding is correct (but I would say not entirely*). Concepts like confidence intervals, p-values, and hypothesis tests are not calculated from the likelihood $f(\theta|x)$ with $x$ fixed, but instead with the pdf $f(x|\theta)$, where $\theta$ is fixed, which is a different slice of the joint distribution $f(x,\theta)$.Confidence intervals, p-value, and hypothesis tests, are different things than just the information from likelihood ratios. So in that sense frequentist statistics 'needs'/'uses' the sampling distribution of the entire sample $f(x\vert \theta)$ (and as Tim Maks answer argues it does not need the sample distribution in many other ways). But in your example you speak about the sampling distribution of a statistic** as in a sample distribution of values like the sample mean and sample variance (an interpretation that you repeat in a question about the CLT). This more narrow sense of sampling distribution is not necessary/needed for frequentists statistics. The sampling distribution (of a statistic) is not being used by frequentist statistics but it is the subject of many frequentist statistics. Frequentist statistics is a lot about sampling distributions of an estimate/statistic, and in Bayesian statistics the sampling distribution hardly occurs. But, for several reasons, it would be wrong to say that Bayesian statistics is 'bypassing the use of the sampling distribution'. A 'bypass' is not really the right word. Bayesian statistics is answering a different question than frequentist statistics (or at least takes a different point of view), and Bayesian statistics is no more bypassing the use of the sampling distribution than frequentist statistics is bypassing the use of the prior distribution. In a similar way a soccer/football player is not bypassing the use of a backhand and a tennis player is not bypassing the use of slidings, or a carpenter is not bypassing the use of paint and a painter is not bypassing the use of wood. *Your understanding is incorrect in the sense that it relates to the role of the difference between population distribution and sample distribution of a statistic. This misunderstanding relates to something that you expressed in an earlier question, where you end up concluding that in a Bayesian analysis one can not use the CLT because we are not supposed to think of sample distributions when using a Bayesian analysis. The likelihood function is not always so easy to compute and in that case one needs to use approximations instead of a direct analytical solution, like computational approximations by sampling. One may also use more analytical approximations, for instance like employing the CLT and a synthetic likelihood. The bypass occurs at a different level. A difference between Bayesian/frequentists statistics is that with a frequentist method you analyse the joint distribution $f(\boldsymbol{\theta},\mathbf{x})$ by considering the whole space of possible observations $x_1, x_2, \dots, x_n$, whereas with Bayesian methods you condition on the observation and only consider the values of the function $f(\boldsymbol{\theta},\mathbf{x})$ for a fixed single particular observation. This difference makes that something like using a statistic (and the related sample distribution) is useful for a frequentist method because it greatly simplifies the computations and visualisation of the whole sample space for $\mathbf{x}$, by replacing it with the sample space for a statistic. The Bayesian method does not bypass this sampling distribution. By this I do not mean that the Bayesian method needs the sampling distribution (it doesn't), but I mean that it is not a bypass. What the Bayesian method is 'bypassing' is a need to make calculations with the joint distribution of parameters and observations $f(\boldsymbol{\theta},\mathbf{x})$ for values other than the actual observation, since the method conditions on the observation. And maybe the question is indirectly about that (but it is not so clear). The sampling distribution is in fact a shortcut (and not something cumbersome that is to be bypassed). With a frequentist method you can just as well work with the likelihood function and for instance do maximum likelihood estimation or confidence intervals. But the sample distribution of an estimate/statistic is the best language to do this. Frequentist/Bayesian is not a dichotomy There is no clear border what frequentist and Bayesian statistics means. One can do empirical Bayesian analysis or use Jeffreys prior in which case one is loosening the conditioning on the observation. And one can make an analysis that is frequentist-like but is not using an estimate/statistic and it's sample distribution. Many people are just fitting curves with models by using some linear or non-linear fitting package and use something like an estimate of the inverse of the Fisher information matrix to express the variance/error of the estimate and there is no direct computation of the sample distribution. Or one can do something else like using AIC/BIC to express goodness of fit, or use a Bayes factor or fiduciary or likelihood intervals. When a sample distribution is used, then it is not really a tool that is something that can be 'bypassed'. The sample distribution is the goal itselve. And if you like you could apply it to a Bayesian estimate (although it makes less sense in such a setting). In frequentist statistics you don't have to compute a sampling distribution of an estimate. In frequentist statistics, or whatever it is, you don't have to calculate these statistics and their sample distribution. You can also work only with the likelihood function in order to make point or interval estimates. The method in the example of the question, with the sampling distribution of the mean is derived from maximum likelihood estimation and effectively equivalent. You do not need a sample distribution of a statistic or estimate (but it does make the analysis simpler) to compute it. For instance to make a maximum likelihood estimate for a population mean $\mu$ of a normal distributed population we use the likelihood function: $$\mathcal{L}(\mu \vert x_1,x_2,\dots,x_n ,\sigma) = \prod_{1\leq i \leq n} \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x_i-\mu}{\sigma}\right)^2} $$ and the $\mu$ that maximizes this function is the MLE estimate. This is very similar to Bayesian maximum a posteriori estimate, which is just maximizing $$ f_{posterior}(\mu \vert x_1,x_2,\dots,x_n ) \propto \mathcal{L}(\mu \vert x_1,x_2,\dots,x_n ,\sigma) \cdot f_{prior}(\mu)$$ The only difference is that the likelihood function is multiplied with the prior probability. Similarly for confidence intervals, one could use z or t-statistics, but effectively those statistics are shortcuts for the more difficult geometrical shape of the density distribution in all coordinates of the observation $\mathbf{x}$. We can derive p-values, statistical tests (and related confidence intervals) by only considering whether an observation is 'extreme' or not. And this can be defined by the likelihood function without considering a statistic/estimate and it's sample distribution (e.g. likelihood ratio test, if the likelihood is below a certain value than the value is not inside the confidence region). This view is also illustrated here where a test is not viewed by considering the sampling distribution of a statistic, but by considering the PDF of the whole data (in that case the data is two variables X and Y). The sample distribution occurs particularly in the method of moments. We can use the moments of a sample to estimate the moments of a distribution and in that case we may wish to express the sample distribution of the moments of a sample. But the method of moments is different from maximum likelihood estimation (but maybe this is already not frequentist?), and we do not use this sample distribution in every type of analysis. **This question is not entirely clear about what is meant with 'sampling distribution' (an ambiguity which causes two diverging type of answers). For this answer I interpret sampling distribution as the distribution of a statistic or the distribution of an estimate. And I interpret a statistic in the sense of R.A. Fisher "statistic may be defined as a function of the observations designed as an estimate of the parameters". In this answer I argue that you do not need such sampling distributions (e.g. you do not need to work as you describe, compute sample mean and sample variance. Instead, you can use the likelihood/probability function directly. But the sampling distribution, and related sufficient statistics, does make it easier.). I do not interpret sample distribution more generally as the distribution of observations/samples.
Does Bayesian statistics bypass the need for the sampling distribution? As Pohoua commented, your understanding is correct (but I would say not entirely*). Concepts like confidence intervals, p-values, and hypothesis tests are not calculated from the likelihood $f(\theta|
16,564
Does Bayesian statistics bypass the need for the sampling distribution?
Broadly speaking, Bayesian analyses satisfy the so-called likelihood principle, which means that all the information about parameters $\theta$ from an experiment that observed $X^\star$ is contained in the likelihood $$ L(\theta) \equiv p(X^\star | \theta), $$ which is crucially only evaluated at the observed $X^\star$. Contrast this with the sampling distribution, $p(X|\theta)$ as a distribution in $X$. Crucially the data isn’t fixed to the observed value, and we instead consider this as a distribution in $X$. Take for example the posterior, $$ p(\theta|X^\star) \propto p(X^\star | \theta) \pi(\theta). $$ It doesn’t depend on $p(X|\theta)$ anywhere other than at $X=X^\star$. So we would find the same posterior distribution for any sampling distribution $f$ so long as $f(X^\star|\theta) =p(X^\star|\theta)$. The posterior depends on the likelihood function, but not the entire sampling distribution. Whilst the fundamental rules of Bayesian inference satisfy the likelihood principle, a few ideas violate it. For example, a few formal rules for constructing priors, e.g., so called reference priors and Jeffreys priors, use the likelihood function evaluated at all possible experimental outcomes (i.e., they use the sampling distribution). A few hybrid ideas, like the posterior and prior $p$-value, also violate it. I suppose ABC methods require the sampling distribution, but only as a means to ultimately approximate the likelihood at the observed data. So, with a few exceptions, yes Bayesian statistics bypasses the need for the sampling distribution.
Does Bayesian statistics bypass the need for the sampling distribution?
Broadly speaking, Bayesian analyses satisfy the so-called likelihood principle, which means that all the information about parameters $\theta$ from an experiment that observed $X^\star$ is contained i
Does Bayesian statistics bypass the need for the sampling distribution? Broadly speaking, Bayesian analyses satisfy the so-called likelihood principle, which means that all the information about parameters $\theta$ from an experiment that observed $X^\star$ is contained in the likelihood $$ L(\theta) \equiv p(X^\star | \theta), $$ which is crucially only evaluated at the observed $X^\star$. Contrast this with the sampling distribution, $p(X|\theta)$ as a distribution in $X$. Crucially the data isn’t fixed to the observed value, and we instead consider this as a distribution in $X$. Take for example the posterior, $$ p(\theta|X^\star) \propto p(X^\star | \theta) \pi(\theta). $$ It doesn’t depend on $p(X|\theta)$ anywhere other than at $X=X^\star$. So we would find the same posterior distribution for any sampling distribution $f$ so long as $f(X^\star|\theta) =p(X^\star|\theta)$. The posterior depends on the likelihood function, but not the entire sampling distribution. Whilst the fundamental rules of Bayesian inference satisfy the likelihood principle, a few ideas violate it. For example, a few formal rules for constructing priors, e.g., so called reference priors and Jeffreys priors, use the likelihood function evaluated at all possible experimental outcomes (i.e., they use the sampling distribution). A few hybrid ideas, like the posterior and prior $p$-value, also violate it. I suppose ABC methods require the sampling distribution, but only as a means to ultimately approximate the likelihood at the observed data. So, with a few exceptions, yes Bayesian statistics bypasses the need for the sampling distribution.
Does Bayesian statistics bypass the need for the sampling distribution? Broadly speaking, Bayesian analyses satisfy the so-called likelihood principle, which means that all the information about parameters $\theta$ from an experiment that observed $X^\star$ is contained i
16,565
Does Bayesian statistics bypass the need for the sampling distribution?
No, your understanding is not correct. First, frequentist statistics does not allow us to "test to see what is the % chance the population mean falls within some range, using the sampling distribution". More precisely, frequentist statistics do not make probability statements on the population mean --- they only make probability statements on the estimates of the population mean. This is a well-known limitation of frequentist statisics that has caused much confusion and spawned many related questions on cross validated. (See, e.g., this thread.) Secondly, in Bayesian stats, we do have the sampling distribution of the sample mean. We may not specifically refer to it, though. As others have mentioned though, Bayesian inference is a type of likelihood inference. Once you have defined your likelihood, you have, by deduction, the sampling distribution of the sample mean. Whether you use that distribution is another matter though. In fact, there are variants of frequentist inference that bypass the likelihood, in that they only work with the moments of the sampling distribution and not the full distribution. See, e.g. the literature on method of moments. However, a "pure" Bayesian analysis will always involve the likelihood even if it is intractable, and therefore a sampling distribution is always implied. Just for completeness, there are also variants of Bayesian inference that do not involve a full definition of the likelihood, and hence I specifically refered to "pure" Bayesian inference earlier. An example for illustration \begin{align} X_i &\overset{iid}{\sim} N(\mu, 1) \tag{1} \\ \mu &\sim N(0, \sigma^2) \tag{2} \end{align} Here, equation (1) implies \begin{equation} \bar{X} = \sum_i^n X_i \sim N(\mu, 1/n) \tag{3} \end{equation} which is the sampling distribution of $\bar{X}$. Of course, in Bayesian inference, we typically don't care about (3), since our interest will usually be in \begin{equation} p(\mu|X) = \frac{p(X|\mu)p(\mu)}{p(X)} \end{equation} However, it happens in this case, since $\bar{X}$ is a sufficient statistic, that \begin{equation} p(\mu|X) = p(\mu|\bar{X}) = \frac{p(\bar{X}|\mu)p(\mu)}{p(\bar{X})} \end{equation} Thus, you can also use the sampling distribution (3) to derive your posterior distribution, if you like.
Does Bayesian statistics bypass the need for the sampling distribution?
No, your understanding is not correct. First, frequentist statistics does not allow us to "test to see what is the % chance the population mean falls within some range, using the sampling distributio
Does Bayesian statistics bypass the need for the sampling distribution? No, your understanding is not correct. First, frequentist statistics does not allow us to "test to see what is the % chance the population mean falls within some range, using the sampling distribution". More precisely, frequentist statistics do not make probability statements on the population mean --- they only make probability statements on the estimates of the population mean. This is a well-known limitation of frequentist statisics that has caused much confusion and spawned many related questions on cross validated. (See, e.g., this thread.) Secondly, in Bayesian stats, we do have the sampling distribution of the sample mean. We may not specifically refer to it, though. As others have mentioned though, Bayesian inference is a type of likelihood inference. Once you have defined your likelihood, you have, by deduction, the sampling distribution of the sample mean. Whether you use that distribution is another matter though. In fact, there are variants of frequentist inference that bypass the likelihood, in that they only work with the moments of the sampling distribution and not the full distribution. See, e.g. the literature on method of moments. However, a "pure" Bayesian analysis will always involve the likelihood even if it is intractable, and therefore a sampling distribution is always implied. Just for completeness, there are also variants of Bayesian inference that do not involve a full definition of the likelihood, and hence I specifically refered to "pure" Bayesian inference earlier. An example for illustration \begin{align} X_i &\overset{iid}{\sim} N(\mu, 1) \tag{1} \\ \mu &\sim N(0, \sigma^2) \tag{2} \end{align} Here, equation (1) implies \begin{equation} \bar{X} = \sum_i^n X_i \sim N(\mu, 1/n) \tag{3} \end{equation} which is the sampling distribution of $\bar{X}$. Of course, in Bayesian inference, we typically don't care about (3), since our interest will usually be in \begin{equation} p(\mu|X) = \frac{p(X|\mu)p(\mu)}{p(X)} \end{equation} However, it happens in this case, since $\bar{X}$ is a sufficient statistic, that \begin{equation} p(\mu|X) = p(\mu|\bar{X}) = \frac{p(\bar{X}|\mu)p(\mu)}{p(\bar{X})} \end{equation} Thus, you can also use the sampling distribution (3) to derive your posterior distribution, if you like.
Does Bayesian statistics bypass the need for the sampling distribution? No, your understanding is not correct. First, frequentist statistics does not allow us to "test to see what is the % chance the population mean falls within some range, using the sampling distributio
16,566
Recursively updating the MLE as new observations stream in
See the concept of sufficiency and in particular, minimal sufficient statistics. In many cases you need the whole sample to compute the estimate at a given sample size, with no trivial way to update from a sample one size smaller (i.e. there's no convenient general result). If the distribution is exponential family (and in some other cases besides; the uniform is a neat example) there's a nice sufficient statistic that can in many cases be updated in the manner you seek (i.e. with a number of commonly used distributions there would be a fast update). One example I'm not aware of any direct way to either calculate or update is the estimate for the location of the Cauchy distribution (e.g. with unit scale, to make the problem a simple one-parameter problem). There may be a faster update, however, that I simply haven't noticed - I can't say I've really done more than glance at it for considering the updating case. On the other hand, with MLEs that are obtained via numerical optimization methods, the previous estimate would in many cases be a great starting point, since typically the previous estimate would be very close to the updated estimate; in that sense at least, rapid updating should often be possible. Even this isn't the general case, though -- with multimodal likelihood functions (again, see the Cauchy for an example), a new observation might lead to the highest mode being some distance from the previous one (even if the locations of each of the biggest few modes didn't shift much, which one is highest could well change).
Recursively updating the MLE as new observations stream in
See the concept of sufficiency and in particular, minimal sufficient statistics. In many cases you need the whole sample to compute the estimate at a given sample size, with no trivial way to update f
Recursively updating the MLE as new observations stream in See the concept of sufficiency and in particular, minimal sufficient statistics. In many cases you need the whole sample to compute the estimate at a given sample size, with no trivial way to update from a sample one size smaller (i.e. there's no convenient general result). If the distribution is exponential family (and in some other cases besides; the uniform is a neat example) there's a nice sufficient statistic that can in many cases be updated in the manner you seek (i.e. with a number of commonly used distributions there would be a fast update). One example I'm not aware of any direct way to either calculate or update is the estimate for the location of the Cauchy distribution (e.g. with unit scale, to make the problem a simple one-parameter problem). There may be a faster update, however, that I simply haven't noticed - I can't say I've really done more than glance at it for considering the updating case. On the other hand, with MLEs that are obtained via numerical optimization methods, the previous estimate would in many cases be a great starting point, since typically the previous estimate would be very close to the updated estimate; in that sense at least, rapid updating should often be possible. Even this isn't the general case, though -- with multimodal likelihood functions (again, see the Cauchy for an example), a new observation might lead to the highest mode being some distance from the previous one (even if the locations of each of the biggest few modes didn't shift much, which one is highest could well change).
Recursively updating the MLE as new observations stream in See the concept of sufficiency and in particular, minimal sufficient statistics. In many cases you need the whole sample to compute the estimate at a given sample size, with no trivial way to update f
16,567
Recursively updating the MLE as new observations stream in
In machine learning, this is referred to as online learning. As @Glen_b pointed out, there are special cases in which the MLE can be updated without needing to access all the previous data. As he also points out, I don't believe there's a generic solution for finding the MLE. A fairly generic approach for finding the approximate solution is to use something like stochastic gradient descent. In this case, as each observation comes in, we compute the gradient with respect to this individual observation and move the parameter values a very small amount in this direction. Under certain conditions, we can show that this will converge to a neighborhood of the MLE with high probability; the neighborhood is tighter and tighter as we reduce the step size, but more data is required for convergence. However, these stochastic methods in general require much more fiddling to obtain good performance than, say, closed form updates.
Recursively updating the MLE as new observations stream in
In machine learning, this is referred to as online learning. As @Glen_b pointed out, there are special cases in which the MLE can be updated without needing to access all the previous data. As he als
Recursively updating the MLE as new observations stream in In machine learning, this is referred to as online learning. As @Glen_b pointed out, there are special cases in which the MLE can be updated without needing to access all the previous data. As he also points out, I don't believe there's a generic solution for finding the MLE. A fairly generic approach for finding the approximate solution is to use something like stochastic gradient descent. In this case, as each observation comes in, we compute the gradient with respect to this individual observation and move the parameter values a very small amount in this direction. Under certain conditions, we can show that this will converge to a neighborhood of the MLE with high probability; the neighborhood is tighter and tighter as we reduce the step size, but more data is required for convergence. However, these stochastic methods in general require much more fiddling to obtain good performance than, say, closed form updates.
Recursively updating the MLE as new observations stream in In machine learning, this is referred to as online learning. As @Glen_b pointed out, there are special cases in which the MLE can be updated without needing to access all the previous data. As he als
16,568
Objective vs. subjective Bayesian paradigms
This is a very confusing topic, mostly owing to the fact that there are two different ways in which the concept of “subjectivism” is commonly used in these discussions.$^\dagger$ It is made even more confusing by the fact that there is a class of “subjectivism” that is rooted in prior elicitation from experts, and this particular variation has to be fit into the philosophical categorisation of paradigms carefully. I will try to bring some clarity to this issue by setting out some different ways in which “subjectivism” is often interpreted, and then setting out broad areas of agreement among Bayesians, and areas where there is a divergence in philosophical and practical approaches. I expect there will be others who will disagree with my own views on this, but I hope this gives a good starting point for clear discussion. Weak subjectivism: In this interpretation, the term "subjective" is used in its weaker sense, meaning merely that probability encapsulates the rational beliefs of a subject. (Some people, such as myself, prefer to use the term "epistemic" for this concept, since it does not actually require subjectivity in the stronger sense.) Strong subjectivism: In this interpretation, the term "subjective" is used in its stronger sense, meaning that weak subjectivism holds, and furthermore, the subject's belief lacks any outside "objective" justification (i.e., two or more different subjects could all hold different beliefs, and none would be considered more or less wrong than the others). In Bayesian analysis it is generally the case that the chosen sampling distribution has an objective justification rooted in some understanding of the sampling mechanism. However, there is rarely any available information pertaining to the parameter, other than in the sample data. This gives rise to three broad paradigms in Bayesian statistics, which correspond to different ways of determining the prior distribution. Subjective Bayesian paradigm: This paradigm agrees with weak subjectivism, and further holds that any set of probabilistic beliefs is equally valid. So long as subjects use Bayesian updating for new data, it is legitimate to use any prior. Under this paradigm, the prior does not require any objective justification. In this paradigm there is a focus on disclosing the prior used, and then showing how this updates with new data. It is common in this method to include sensitivity analysis showing posterior beliefs under a range of prior beliefs. Objective Bayesian paradigm: This paradigm also agrees with weak subjectivism, but prefers to additionally constrain prior beliefs (before inclusion of any data) so that they are objectively “non-informative” about the parameter. In this paradigm the prior is supposed to accurately reflect the lack of available information pertaining to the parameter, outside of the data. This usually entails adopting some theory for how to set the prior (e.g., Jeffrey’s, Jaynes, Bernardo reference priors, etc.) This paradigm holds that a set of probabilistic beliefs is to be preferred if it is based on a prior belief that is objectively determined and uninformative about the parameters in the problem of interest. It agrees that any set of probabilistic beliefs is consistent with the rationality criteria underlying Bayesian analysis, but views beliefs based on “bad” priors (too informative about the unknown parameter) as being worse than those based on “good” priors. In this paradigm the prior is chosen from some uninformative class, and then updated with new data to yield an objective answer to the problem. Expert-prior Bayesian paradigm: This method is often viewed as part of the subjective paradigm, and is not usually identified separately, but I consider it a separate paradigm because it has elements of each view. This paradigm agrees with weak subjectivism, but like the objective Bayesian paradigm, it does not view all priors as equally valid. This paradigm treats present “priors” as posteriors from previous life experience, and so regards the prior beliefs of subject-matter experts as being superior to the prior beliefs of non-experts. It also recognises that those beliefs are probably based on data that has not been systematically recorded, and is not based on systematic use of probability theory, so it is not possible to decompose these existing expert priors into an original non-informative prior and the data that this expert observed. (And indeed, in the absence of systematic use of probability theory, the present expert “prior” is probably not even consistent with Bayesian updating.) In this paradigm the expert’s present “subjective” opinion is treated as being a valuable encapsulation of subject-matter knowledge, which is treated as a primitive prior. In this paradigm the analyst seeks to elicit the expert prior through some tests of prior belief, and then the prior is formulated as the best fit to that expert belief (taking care to ensure that the expert belief has not been polluted by knowledge of the present data). The “subjective” belief of the expert is thus treated as an “objective” encapsulation of subject-matter knowledge from previous data. Differences in method: In terms of method, the objective Bayesian paradigm differs from the subjective paradigm insofar as the former constrains the allowable priors (either to a unique prior or a very small class of similar priors), whereas the latter does not constraint the allowable priors. In the objective Bayesian approach the prior is constrained by theories of representing a “non-informative” prior. The expert-prior paradigm takes a different approach and instead identifies one or more people that are experts, and elicits their prior beliefs. Once we understand these different sense of the different paradigms in Bayesian statistics, we can set out some areas of broad agreement, and areas where there is disagreement. Actually, despite differences in method, there is more agreement on the underlying theories than is usually apprectiated. Broad agreement on weak subjectivism: There exists a large literature in Bayesian statistics showing that the “axioms” of probability can be derived from preliminary desiderata relating to rational decision-making. This includes arguments pertaining to dynamic belief consistency (see e.g., Epstein and Le Breton 1993), arguments appealing to the Dutch book theorem (see e.g., Lehmann 1955, Hajek 2009). Bayesians of all these paradigms broadly agree that probability should be interpreted epistemically, as referring to the beliefs of a subject, constrained by the rationality constraints inherent in the axioms of probability. We agree that one should use the rules of probability to constrain one’s beliefs about uncertainty to be rational. This implies that beliefs about uncertainty require Bayesian updating in the face of new data, but it does not impose any further constraint (i.e., without more, it does not say that any prior is better than any other prior). All three of the above paradigms agree on this. There is agreement that posteriors tend to converge with more data: There are a number of consistency theorems in Bayesian statistics which show that if you have two people with the same likelihood function, but different priors, then their posterior beliefs will converge as you get more and more data.$^{\dagger \dagger}$ This means that with a large amount of data, the prior does not matter very much. These are undeniable theorems of probability, and all three of the above paradigms agree on this. For this reason, it is generally recognised that with large amounts of data, any of the three paradigms is likely to give similar results. Consequently, the differences in the paradigms are most important when we only have a small amount of data. There is broad agreement that there are roughly “objective” rules for priors that are available if you want to use them: There exists a large body of literature in Bayesian statistics showing how you can develop “non-informative” priors which are roughly determined by the sampling problem, and roughly encapsulate the absence of much knowledge about the parameter in question. I say “roughly” because there are several competing theories here that sometimes correspond but sometimes differ slightly (e.g., Jeffrey’s, Jaynes, reference priors, Walley classes of imprecise priors, etc.), and there are also some tricky paradoxes that can occur. The most difficult issue here is that it is difficult to make an “uninformative” prior for a continuous parameter that can be subjected to nonlinear transformations (since “uninformativity” should ideally be invariant to transformations). Again, these are theorems of probability, and all the paradigms agree with their content. Objective Bayesians tend to view this theory as being sufficiently good that it gives superior priors, whereas subjective Bayesians and expert-prior Bayesians tend to view the theory as being insufficient to establish superiority of these priors. In other words, there is broad agreement that these objective rules exist, and can be used, but there is disagreement over how good they are. There is disagreement over the importance of having a single answer: Objective Bayesians are motivated by the preference that a statistical problem with fixed data and a fixed likelihood function should lead to a uniquely determined posterior belief (or at least a small number of allowable posterior beliefs that vary very little). This preference is generally part of a broader preference for having scientific procedures that yield a unique answer when applied to fixed sets of objective conditions. Contrarily, both subjective Bayesians and expert-prior Bayesians believe that this is not especially important, and they generally believe that this focus on a uniquely determined posterior is actually misleading. There is broad agreement that the public are not well-acquainted with Bayesian posteriors: All paradigms agree that the general public are not well-acquainted with the basic mechanics of how Bayesian analysis transitions from a prior to a posterior. Objective Bayesians sometimes worry that giving more than one allowable answer for the posterior will be confusing to people. Subjective Bayesians worry that failing to give more than one allowable answer for the posterior is misleading to people. $^\dagger$ It is worth noting that the confusion over "subjectivism" here stems from a particular instance of the general false dichotomy in epistemology between "subjectivism" and "intrinsicism" (see e.g., Piekoff). In attempts to interpret probability many users have made the error of believing that any rejection of aleatory theories of probability necessarily lead to interpretations that are "subjective" in the stronger sense specified here. To understand probability interpretations correctly, it is a good idea to understand the general problems with the subjectivism-intrinsicism dichotomy, and therefore recognise that objective epistemic interpretations exist. $^{\dagger \dagger}$ There are some broad regularity conditions required for this result (e.g., both subjects have a prior with support including the true parameter value) but it applies very broadly.
Objective vs. subjective Bayesian paradigms
This is a very confusing topic, mostly owing to the fact that there are two different ways in which the concept of “subjectivism” is commonly used in these discussions.$^\dagger$ It is made even more
Objective vs. subjective Bayesian paradigms This is a very confusing topic, mostly owing to the fact that there are two different ways in which the concept of “subjectivism” is commonly used in these discussions.$^\dagger$ It is made even more confusing by the fact that there is a class of “subjectivism” that is rooted in prior elicitation from experts, and this particular variation has to be fit into the philosophical categorisation of paradigms carefully. I will try to bring some clarity to this issue by setting out some different ways in which “subjectivism” is often interpreted, and then setting out broad areas of agreement among Bayesians, and areas where there is a divergence in philosophical and practical approaches. I expect there will be others who will disagree with my own views on this, but I hope this gives a good starting point for clear discussion. Weak subjectivism: In this interpretation, the term "subjective" is used in its weaker sense, meaning merely that probability encapsulates the rational beliefs of a subject. (Some people, such as myself, prefer to use the term "epistemic" for this concept, since it does not actually require subjectivity in the stronger sense.) Strong subjectivism: In this interpretation, the term "subjective" is used in its stronger sense, meaning that weak subjectivism holds, and furthermore, the subject's belief lacks any outside "objective" justification (i.e., two or more different subjects could all hold different beliefs, and none would be considered more or less wrong than the others). In Bayesian analysis it is generally the case that the chosen sampling distribution has an objective justification rooted in some understanding of the sampling mechanism. However, there is rarely any available information pertaining to the parameter, other than in the sample data. This gives rise to three broad paradigms in Bayesian statistics, which correspond to different ways of determining the prior distribution. Subjective Bayesian paradigm: This paradigm agrees with weak subjectivism, and further holds that any set of probabilistic beliefs is equally valid. So long as subjects use Bayesian updating for new data, it is legitimate to use any prior. Under this paradigm, the prior does not require any objective justification. In this paradigm there is a focus on disclosing the prior used, and then showing how this updates with new data. It is common in this method to include sensitivity analysis showing posterior beliefs under a range of prior beliefs. Objective Bayesian paradigm: This paradigm also agrees with weak subjectivism, but prefers to additionally constrain prior beliefs (before inclusion of any data) so that they are objectively “non-informative” about the parameter. In this paradigm the prior is supposed to accurately reflect the lack of available information pertaining to the parameter, outside of the data. This usually entails adopting some theory for how to set the prior (e.g., Jeffrey’s, Jaynes, Bernardo reference priors, etc.) This paradigm holds that a set of probabilistic beliefs is to be preferred if it is based on a prior belief that is objectively determined and uninformative about the parameters in the problem of interest. It agrees that any set of probabilistic beliefs is consistent with the rationality criteria underlying Bayesian analysis, but views beliefs based on “bad” priors (too informative about the unknown parameter) as being worse than those based on “good” priors. In this paradigm the prior is chosen from some uninformative class, and then updated with new data to yield an objective answer to the problem. Expert-prior Bayesian paradigm: This method is often viewed as part of the subjective paradigm, and is not usually identified separately, but I consider it a separate paradigm because it has elements of each view. This paradigm agrees with weak subjectivism, but like the objective Bayesian paradigm, it does not view all priors as equally valid. This paradigm treats present “priors” as posteriors from previous life experience, and so regards the prior beliefs of subject-matter experts as being superior to the prior beliefs of non-experts. It also recognises that those beliefs are probably based on data that has not been systematically recorded, and is not based on systematic use of probability theory, so it is not possible to decompose these existing expert priors into an original non-informative prior and the data that this expert observed. (And indeed, in the absence of systematic use of probability theory, the present expert “prior” is probably not even consistent with Bayesian updating.) In this paradigm the expert’s present “subjective” opinion is treated as being a valuable encapsulation of subject-matter knowledge, which is treated as a primitive prior. In this paradigm the analyst seeks to elicit the expert prior through some tests of prior belief, and then the prior is formulated as the best fit to that expert belief (taking care to ensure that the expert belief has not been polluted by knowledge of the present data). The “subjective” belief of the expert is thus treated as an “objective” encapsulation of subject-matter knowledge from previous data. Differences in method: In terms of method, the objective Bayesian paradigm differs from the subjective paradigm insofar as the former constrains the allowable priors (either to a unique prior or a very small class of similar priors), whereas the latter does not constraint the allowable priors. In the objective Bayesian approach the prior is constrained by theories of representing a “non-informative” prior. The expert-prior paradigm takes a different approach and instead identifies one or more people that are experts, and elicits their prior beliefs. Once we understand these different sense of the different paradigms in Bayesian statistics, we can set out some areas of broad agreement, and areas where there is disagreement. Actually, despite differences in method, there is more agreement on the underlying theories than is usually apprectiated. Broad agreement on weak subjectivism: There exists a large literature in Bayesian statistics showing that the “axioms” of probability can be derived from preliminary desiderata relating to rational decision-making. This includes arguments pertaining to dynamic belief consistency (see e.g., Epstein and Le Breton 1993), arguments appealing to the Dutch book theorem (see e.g., Lehmann 1955, Hajek 2009). Bayesians of all these paradigms broadly agree that probability should be interpreted epistemically, as referring to the beliefs of a subject, constrained by the rationality constraints inherent in the axioms of probability. We agree that one should use the rules of probability to constrain one’s beliefs about uncertainty to be rational. This implies that beliefs about uncertainty require Bayesian updating in the face of new data, but it does not impose any further constraint (i.e., without more, it does not say that any prior is better than any other prior). All three of the above paradigms agree on this. There is agreement that posteriors tend to converge with more data: There are a number of consistency theorems in Bayesian statistics which show that if you have two people with the same likelihood function, but different priors, then their posterior beliefs will converge as you get more and more data.$^{\dagger \dagger}$ This means that with a large amount of data, the prior does not matter very much. These are undeniable theorems of probability, and all three of the above paradigms agree on this. For this reason, it is generally recognised that with large amounts of data, any of the three paradigms is likely to give similar results. Consequently, the differences in the paradigms are most important when we only have a small amount of data. There is broad agreement that there are roughly “objective” rules for priors that are available if you want to use them: There exists a large body of literature in Bayesian statistics showing how you can develop “non-informative” priors which are roughly determined by the sampling problem, and roughly encapsulate the absence of much knowledge about the parameter in question. I say “roughly” because there are several competing theories here that sometimes correspond but sometimes differ slightly (e.g., Jeffrey’s, Jaynes, reference priors, Walley classes of imprecise priors, etc.), and there are also some tricky paradoxes that can occur. The most difficult issue here is that it is difficult to make an “uninformative” prior for a continuous parameter that can be subjected to nonlinear transformations (since “uninformativity” should ideally be invariant to transformations). Again, these are theorems of probability, and all the paradigms agree with their content. Objective Bayesians tend to view this theory as being sufficiently good that it gives superior priors, whereas subjective Bayesians and expert-prior Bayesians tend to view the theory as being insufficient to establish superiority of these priors. In other words, there is broad agreement that these objective rules exist, and can be used, but there is disagreement over how good they are. There is disagreement over the importance of having a single answer: Objective Bayesians are motivated by the preference that a statistical problem with fixed data and a fixed likelihood function should lead to a uniquely determined posterior belief (or at least a small number of allowable posterior beliefs that vary very little). This preference is generally part of a broader preference for having scientific procedures that yield a unique answer when applied to fixed sets of objective conditions. Contrarily, both subjective Bayesians and expert-prior Bayesians believe that this is not especially important, and they generally believe that this focus on a uniquely determined posterior is actually misleading. There is broad agreement that the public are not well-acquainted with Bayesian posteriors: All paradigms agree that the general public are not well-acquainted with the basic mechanics of how Bayesian analysis transitions from a prior to a posterior. Objective Bayesians sometimes worry that giving more than one allowable answer for the posterior will be confusing to people. Subjective Bayesians worry that failing to give more than one allowable answer for the posterior is misleading to people. $^\dagger$ It is worth noting that the confusion over "subjectivism" here stems from a particular instance of the general false dichotomy in epistemology between "subjectivism" and "intrinsicism" (see e.g., Piekoff). In attempts to interpret probability many users have made the error of believing that any rejection of aleatory theories of probability necessarily lead to interpretations that are "subjective" in the stronger sense specified here. To understand probability interpretations correctly, it is a good idea to understand the general problems with the subjectivism-intrinsicism dichotomy, and therefore recognise that objective epistemic interpretations exist. $^{\dagger \dagger}$ There are some broad regularity conditions required for this result (e.g., both subjects have a prior with support including the true parameter value) but it applies very broadly.
Objective vs. subjective Bayesian paradigms This is a very confusing topic, mostly owing to the fact that there are two different ways in which the concept of “subjectivism” is commonly used in these discussions.$^\dagger$ It is made even more
16,569
How could I have discovered the normal distribution?
I would guess the first derivations must have come as a byproduct from trying to find fast ways to compute basic discrete probability distributions, such as binomials. Is that correct? Yes. The normal curve was developed mathematically in 1733 by DeMoivre as an approximation to the binomial distribution. His paper was not discovered until 1924 by Karl Pearson. Laplace used the normal curve in 1783 to describe the distribution of errors. Subsequently, Gauss used the normal curve to analyze astronomical data in 1809. Source : NORMAL DISTRIBUTION Other sources with historical context: The Evolution of the Normal Distribution Wikipedia history section Nowadays the fact that the Normal distribution is an approximation for Binomials for large $n$ is considered as a special case of the Central Limit Theorem. It can be found in most text books and is considered as elementary. You can find a proof on Wikipedia. The exponential just shows up as $e^x=\lim(1+\frac{x}{n})^n$ after some Taylor expansion of the characteristic function that yield $-\frac{t^2}{2}$. Sometimes you still find special proofs for Binomials in textbooks and this is known as DeMoivre-Laplace theorem.
How could I have discovered the normal distribution?
I would guess the first derivations must have come as a byproduct from trying to find fast ways to compute basic discrete probability distributions, such as binomials. Is that correct? Yes. The norma
How could I have discovered the normal distribution? I would guess the first derivations must have come as a byproduct from trying to find fast ways to compute basic discrete probability distributions, such as binomials. Is that correct? Yes. The normal curve was developed mathematically in 1733 by DeMoivre as an approximation to the binomial distribution. His paper was not discovered until 1924 by Karl Pearson. Laplace used the normal curve in 1783 to describe the distribution of errors. Subsequently, Gauss used the normal curve to analyze astronomical data in 1809. Source : NORMAL DISTRIBUTION Other sources with historical context: The Evolution of the Normal Distribution Wikipedia history section Nowadays the fact that the Normal distribution is an approximation for Binomials for large $n$ is considered as a special case of the Central Limit Theorem. It can be found in most text books and is considered as elementary. You can find a proof on Wikipedia. The exponential just shows up as $e^x=\lim(1+\frac{x}{n})^n$ after some Taylor expansion of the characteristic function that yield $-\frac{t^2}{2}$. Sometimes you still find special proofs for Binomials in textbooks and this is known as DeMoivre-Laplace theorem.
How could I have discovered the normal distribution? I would guess the first derivations must have come as a byproduct from trying to find fast ways to compute basic discrete probability distributions, such as binomials. Is that correct? Yes. The norma
16,570
How could I have discovered the normal distribution?
Stahl ("The Evolution of the Normal Distribution", Mathematics Magazine, 2006) argues that the first historical traces of the normal came from gambling, approximations to the binomial distributions (for demographics) and error analysis in astronomy.
How could I have discovered the normal distribution?
Stahl ("The Evolution of the Normal Distribution", Mathematics Magazine, 2006) argues that the first historical traces of the normal came from gambling, approximations to the binomial distributions (f
How could I have discovered the normal distribution? Stahl ("The Evolution of the Normal Distribution", Mathematics Magazine, 2006) argues that the first historical traces of the normal came from gambling, approximations to the binomial distributions (for demographics) and error analysis in astronomy.
How could I have discovered the normal distribution? Stahl ("The Evolution of the Normal Distribution", Mathematics Magazine, 2006) argues that the first historical traces of the normal came from gambling, approximations to the binomial distributions (f
16,571
How could I have discovered the normal distribution?
The question's historical part was answered already, possibly, multiple times on this forum, e.g. see the accepted answer to a similar question. No, it was not discovered as an approximation to discrete distributions. I doubt there was even a notion of probability distribution at the time. It was discovered by guys who's be called physicists or mathematicians these days, I guess nature philosophers at the time. How would another civilization discover the normal distribution is an interesting question. Anyone who studies errors and disturbances of any kind would have found it. It happened so that our civilization found it while studying celestial bodies. I doubt that it is likely that other humans would develop statistics before physics or mathematics.
How could I have discovered the normal distribution?
The question's historical part was answered already, possibly, multiple times on this forum, e.g. see the accepted answer to a similar question. No, it was not discovered as an approximation to discre
How could I have discovered the normal distribution? The question's historical part was answered already, possibly, multiple times on this forum, e.g. see the accepted answer to a similar question. No, it was not discovered as an approximation to discrete distributions. I doubt there was even a notion of probability distribution at the time. It was discovered by guys who's be called physicists or mathematicians these days, I guess nature philosophers at the time. How would another civilization discover the normal distribution is an interesting question. Anyone who studies errors and disturbances of any kind would have found it. It happened so that our civilization found it while studying celestial bodies. I doubt that it is likely that other humans would develop statistics before physics or mathematics.
How could I have discovered the normal distribution? The question's historical part was answered already, possibly, multiple times on this forum, e.g. see the accepted answer to a similar question. No, it was not discovered as an approximation to discre
16,572
How could I have discovered the normal distribution?
What' special about the normal distribution is the Central Limit Theory. For details and derivation/proof see: https://en.wikipedia.org/wiki/Central_limit_theorem
How could I have discovered the normal distribution?
What' special about the normal distribution is the Central Limit Theory. For details and derivation/proof see: https://en.wikipedia.org/wiki/Central_limit_theorem
How could I have discovered the normal distribution? What' special about the normal distribution is the Central Limit Theory. For details and derivation/proof see: https://en.wikipedia.org/wiki/Central_limit_theorem
How could I have discovered the normal distribution? What' special about the normal distribution is the Central Limit Theory. For details and derivation/proof see: https://en.wikipedia.org/wiki/Central_limit_theorem
16,573
How could I have discovered the normal distribution?
I also asked myself that question and this youtube video is the best answer I have found https://www.youtube.com/watch?v=cTyPuZ9-JZ0 I don`t think that it is the original derivation but the description of the video says "This argument is adapted from the work of the astronomer John Herschel in 1850 and the physicist James Clerk Maxwell in 1860. "
How could I have discovered the normal distribution?
I also asked myself that question and this youtube video is the best answer I have found https://www.youtube.com/watch?v=cTyPuZ9-JZ0 I don`t think that it is the original derivation but the descriptio
How could I have discovered the normal distribution? I also asked myself that question and this youtube video is the best answer I have found https://www.youtube.com/watch?v=cTyPuZ9-JZ0 I don`t think that it is the original derivation but the description of the video says "This argument is adapted from the work of the astronomer John Herschel in 1850 and the physicist James Clerk Maxwell in 1860. "
How could I have discovered the normal distribution? I also asked myself that question and this youtube video is the best answer I have found https://www.youtube.com/watch?v=cTyPuZ9-JZ0 I don`t think that it is the original derivation but the descriptio
16,574
How could I have discovered the normal distribution?
It's hard to parse this question. Who is the "I" in this question? And when is the time in question? An almost trivial answer is finding a location/scale family that is $\propto \exp(-x^2)$. The OP then goes on to ask "If humanity forgot about the normal distribution, in what manner would it be rediscovered"? This is an altogether different question. I think a relevant answer here is one that 1) borrows the perspective of modern science 2) provides an answer that is different from the most frequently encountered historical answer, aka the Central Limit Theorym. In quantum mechanics, information theory, and thermodynamics, the entropy quantifies the state of a system. In these fields, the quantum state is in fact, wholly random or stochastic. Contrast this with classical mechanics. In classical mechanics, states are fixed but our observation is imperfect due to the contribution of hundreds or millions of unobserved influencing factors: this kind of result gives rise to the CLT. In quantum mechanics, we use Bayesian probability to quantify our belief about the state of the system. Along those lines, proofs have been presented, and tweaked, that the Gaussian or normal random variable has maximum entropy among all random variables with finite mean or standard deviation. https://www.dsprelated.com/freebooks/sasp/Maximum_Entropy_Property_Gaussian.html https://en.wikipedia.org/wiki/Differential_entropy http://bayes.wustl.edu/etj/articles/brandeis.pdf
How could I have discovered the normal distribution?
It's hard to parse this question. Who is the "I" in this question? And when is the time in question? An almost trivial answer is finding a location/scale family that is $\propto \exp(-x^2)$. The OP th
How could I have discovered the normal distribution? It's hard to parse this question. Who is the "I" in this question? And when is the time in question? An almost trivial answer is finding a location/scale family that is $\propto \exp(-x^2)$. The OP then goes on to ask "If humanity forgot about the normal distribution, in what manner would it be rediscovered"? This is an altogether different question. I think a relevant answer here is one that 1) borrows the perspective of modern science 2) provides an answer that is different from the most frequently encountered historical answer, aka the Central Limit Theorym. In quantum mechanics, information theory, and thermodynamics, the entropy quantifies the state of a system. In these fields, the quantum state is in fact, wholly random or stochastic. Contrast this with classical mechanics. In classical mechanics, states are fixed but our observation is imperfect due to the contribution of hundreds or millions of unobserved influencing factors: this kind of result gives rise to the CLT. In quantum mechanics, we use Bayesian probability to quantify our belief about the state of the system. Along those lines, proofs have been presented, and tweaked, that the Gaussian or normal random variable has maximum entropy among all random variables with finite mean or standard deviation. https://www.dsprelated.com/freebooks/sasp/Maximum_Entropy_Property_Gaussian.html https://en.wikipedia.org/wiki/Differential_entropy http://bayes.wustl.edu/etj/articles/brandeis.pdf
How could I have discovered the normal distribution? It's hard to parse this question. Who is the "I" in this question? And when is the time in question? An almost trivial answer is finding a location/scale family that is $\propto \exp(-x^2)$. The OP th
16,575
Multi-label classification - Brier Score or Log Loss?
Since the log likelihood function (combined with the prior if Bayesian modeling is being used) is the gold standard optimality criterion, it is best to use the log likelihood (a linear translation of the logarithmic accuracy scoring rule). This automatically extends to ordinal and multinomial (polytomous) $Y$. There are only three reasons I can think of for not using the log likelihood in summarizing the model's predictive value: you seek to describe model performance using a measure the model was not optimizing (not a bad idea; often why we use the Brier score) you have a single predicted probability of one or zero that was "wrong", rendering an infinite value for the logarithmic score it's often hard to know "how good" a value of the index is (same for Brier score, not so much for $c$-index, i.e., concordance probability or AUROC)
Multi-label classification - Brier Score or Log Loss?
Since the log likelihood function (combined with the prior if Bayesian modeling is being used) is the gold standard optimality criterion, it is best to use the log likelihood (a linear translation of
Multi-label classification - Brier Score or Log Loss? Since the log likelihood function (combined with the prior if Bayesian modeling is being used) is the gold standard optimality criterion, it is best to use the log likelihood (a linear translation of the logarithmic accuracy scoring rule). This automatically extends to ordinal and multinomial (polytomous) $Y$. There are only three reasons I can think of for not using the log likelihood in summarizing the model's predictive value: you seek to describe model performance using a measure the model was not optimizing (not a bad idea; often why we use the Brier score) you have a single predicted probability of one or zero that was "wrong", rendering an infinite value for the logarithmic score it's often hard to know "how good" a value of the index is (same for Brier score, not so much for $c$-index, i.e., concordance probability or AUROC)
Multi-label classification - Brier Score or Log Loss? Since the log likelihood function (combined with the prior if Bayesian modeling is being used) is the gold standard optimality criterion, it is best to use the log likelihood (a linear translation of
16,576
Multi-label classification - Brier Score or Log Loss?
Either of these measures may be appropriate, depending on what you want to concentrate on. The Brier score is basically the sum of squared errors of the classwise probability estimates. It will inform you as to both how accurate the model is and how "confidently" accurate the model is. You would not want to use the Brier score for scoring an ordinal classification problem. If missing a class 1 by predicting class 2 is better than predicting class 3, for example. The Brier score weights all misses equally. Cross entropy (log loss) will, basically, measure the relative uncertainty between classes your model produces relative to the true classes. Over the past decade or so, it's become one of the very standard model scoring statistics for multiclass (and binary) classification problems.
Multi-label classification - Brier Score or Log Loss?
Either of these measures may be appropriate, depending on what you want to concentrate on. The Brier score is basically the sum of squared errors of the classwise probability estimates. It will inform
Multi-label classification - Brier Score or Log Loss? Either of these measures may be appropriate, depending on what you want to concentrate on. The Brier score is basically the sum of squared errors of the classwise probability estimates. It will inform you as to both how accurate the model is and how "confidently" accurate the model is. You would not want to use the Brier score for scoring an ordinal classification problem. If missing a class 1 by predicting class 2 is better than predicting class 3, for example. The Brier score weights all misses equally. Cross entropy (log loss) will, basically, measure the relative uncertainty between classes your model produces relative to the true classes. Over the past decade or so, it's become one of the very standard model scoring statistics for multiclass (and binary) classification problems.
Multi-label classification - Brier Score or Log Loss? Either of these measures may be appropriate, depending on what you want to concentrate on. The Brier score is basically the sum of squared errors of the classwise probability estimates. It will inform
16,577
Multi-label classification - Brier Score or Log Loss?
This paper seems to talk a bit: http://faculty.engr.utexas.edu/bickel/Papers/QSL_Comparison.pdf And I got it from this answer: Justifying and choosing a proper scoring rule
Multi-label classification - Brier Score or Log Loss?
This paper seems to talk a bit: http://faculty.engr.utexas.edu/bickel/Papers/QSL_Comparison.pdf And I got it from this answer: Justifying and choosing a proper scoring rule
Multi-label classification - Brier Score or Log Loss? This paper seems to talk a bit: http://faculty.engr.utexas.edu/bickel/Papers/QSL_Comparison.pdf And I got it from this answer: Justifying and choosing a proper scoring rule
Multi-label classification - Brier Score or Log Loss? This paper seems to talk a bit: http://faculty.engr.utexas.edu/bickel/Papers/QSL_Comparison.pdf And I got it from this answer: Justifying and choosing a proper scoring rule
16,578
Logistic Regression: Scikit Learn vs glmnet
Dougal's answer is correct, you regularize the intercept in sklearn but not in R. Make sure you use solver='newton-cg' since default solver ('liblinear') always regularizes the intercept. cf https://github.com/scikit-learn/scikit-learn/issues/6595
Logistic Regression: Scikit Learn vs glmnet
Dougal's answer is correct, you regularize the intercept in sklearn but not in R. Make sure you use solver='newton-cg' since default solver ('liblinear') always regularizes the intercept. cf https://g
Logistic Regression: Scikit Learn vs glmnet Dougal's answer is correct, you regularize the intercept in sklearn but not in R. Make sure you use solver='newton-cg' since default solver ('liblinear') always regularizes the intercept. cf https://github.com/scikit-learn/scikit-learn/issues/6595
Logistic Regression: Scikit Learn vs glmnet Dougal's answer is correct, you regularize the intercept in sklearn but not in R. Make sure you use solver='newton-cg' since default solver ('liblinear') always regularizes the intercept. cf https://g
16,579
Logistic Regression: Scikit Learn vs glmnet
sklearn's logistic regression doesn't standardize the inputs by default, which changes the meaning of the $L_2$ regularization term; probably glmnet does. Especially since your gre term is on such a larger scale than the other variables, this will change the relative costs of using the different variables for weights. Note also that by including an explicit intercept term in the features, you're regularizing the intercept of the model. This is generally not done, since it means that your model is no longer covariant to shifting all the labels by a constant.
Logistic Regression: Scikit Learn vs glmnet
sklearn's logistic regression doesn't standardize the inputs by default, which changes the meaning of the $L_2$ regularization term; probably glmnet does. Especially since your gre term is on such a
Logistic Regression: Scikit Learn vs glmnet sklearn's logistic regression doesn't standardize the inputs by default, which changes the meaning of the $L_2$ regularization term; probably glmnet does. Especially since your gre term is on such a larger scale than the other variables, this will change the relative costs of using the different variables for weights. Note also that by including an explicit intercept term in the features, you're regularizing the intercept of the model. This is generally not done, since it means that your model is no longer covariant to shifting all the labels by a constant.
Logistic Regression: Scikit Learn vs glmnet sklearn's logistic regression doesn't standardize the inputs by default, which changes the meaning of the $L_2$ regularization term; probably glmnet does. Especially since your gre term is on such a
16,580
Logistic Regression: Scikit Learn vs glmnet
You should also use L1_wt=0 argument along with alpha in fit_regularized() call. This code in statsmodels: import statsmodels.api as sm res = sm.GLM(y, X, family=sm.families.Binomial()).fit_regularized(alpha=1/(y.shape[0]*C), L1_wt=0) is equivalent to the following code from sklearn: from sklearn import linear_model clf = linear_model.LogisticRegression(C = C) clf.fit(X, y) Hope it helps!
Logistic Regression: Scikit Learn vs glmnet
You should also use L1_wt=0 argument along with alpha in fit_regularized() call. This code in statsmodels: import statsmodels.api as sm res = sm.GLM(y, X, family=sm.families.Binomial()).fit_regulariz
Logistic Regression: Scikit Learn vs glmnet You should also use L1_wt=0 argument along with alpha in fit_regularized() call. This code in statsmodels: import statsmodels.api as sm res = sm.GLM(y, X, family=sm.families.Binomial()).fit_regularized(alpha=1/(y.shape[0]*C), L1_wt=0) is equivalent to the following code from sklearn: from sklearn import linear_model clf = linear_model.LogisticRegression(C = C) clf.fit(X, y) Hope it helps!
Logistic Regression: Scikit Learn vs glmnet You should also use L1_wt=0 argument along with alpha in fit_regularized() call. This code in statsmodels: import statsmodels.api as sm res = sm.GLM(y, X, family=sm.families.Binomial()).fit_regulariz
16,581
Which test for cross table analysis: Boschloo or Barnard?
There may be some confusion about term "Barnard"s test or "Boschloo"s test. Barnard's exact test is an unconditional test in the sense that it does not condition on both margins. Therefore, both the second and third bullets are Barnard's test. We should instead write: Both margins fixed (Hypergeometric Dist'n)→Fisher's exact test One margin fixed (Double Binomial Dist'n)→Barnard's exact test No margins fixed (Multinomial Dist'n)→Barnard's exact test Barnard's exact test encompasses two types of tables, so we distinguish the two by saying "binomial" or "multinomial" model as appropriate. Typically, Barnard's exact test either uses a Z-pooled (aka Score) statistic to determine the 'as or more extreme' tables. Note the original Barnard paper (1947) uses a more complicated approach to determine the more extreme tables (referred as "CSM"). Boschloo's exact test uses Fisher's p-value to determine the 'as or more extreme' tables. Boschloo's test is uniformly more powerful than Fisher's exact test. For your dataset, it sounds like neither margins were fixed, so would recommend using Boschloo's exact test with a multinomial model. I found Boschloo's test slightly better for unbalanced margin ratios (although typically very similar to Barnard's exact test with Z-pooled statistic). However, since both Boschloo's test and multinomial models are much more computationally intensive, you can also use the binomial model (the reasoning for why this would still be appropriate is a little complicated; to briefly summarize, the margins are an approximately ancillary statistic, so it's alright to condition on margin). For more details on the exact tests and information on implementation, please use the Exact R package (https://cran.r-project.org/web/packages/Exact/Exact.pdf). I am the author of the package and it's a more updated version of the code on the blog.
Which test for cross table analysis: Boschloo or Barnard?
There may be some confusion about term "Barnard"s test or "Boschloo"s test. Barnard's exact test is an unconditional test in the sense that it does not condition on both margins. Therefore, both the
Which test for cross table analysis: Boschloo or Barnard? There may be some confusion about term "Barnard"s test or "Boschloo"s test. Barnard's exact test is an unconditional test in the sense that it does not condition on both margins. Therefore, both the second and third bullets are Barnard's test. We should instead write: Both margins fixed (Hypergeometric Dist'n)→Fisher's exact test One margin fixed (Double Binomial Dist'n)→Barnard's exact test No margins fixed (Multinomial Dist'n)→Barnard's exact test Barnard's exact test encompasses two types of tables, so we distinguish the two by saying "binomial" or "multinomial" model as appropriate. Typically, Barnard's exact test either uses a Z-pooled (aka Score) statistic to determine the 'as or more extreme' tables. Note the original Barnard paper (1947) uses a more complicated approach to determine the more extreme tables (referred as "CSM"). Boschloo's exact test uses Fisher's p-value to determine the 'as or more extreme' tables. Boschloo's test is uniformly more powerful than Fisher's exact test. For your dataset, it sounds like neither margins were fixed, so would recommend using Boschloo's exact test with a multinomial model. I found Boschloo's test slightly better for unbalanced margin ratios (although typically very similar to Barnard's exact test with Z-pooled statistic). However, since both Boschloo's test and multinomial models are much more computationally intensive, you can also use the binomial model (the reasoning for why this would still be appropriate is a little complicated; to briefly summarize, the margins are an approximately ancillary statistic, so it's alright to condition on margin). For more details on the exact tests and information on implementation, please use the Exact R package (https://cran.r-project.org/web/packages/Exact/Exact.pdf). I am the author of the package and it's a more updated version of the code on the blog.
Which test for cross table analysis: Boschloo or Barnard? There may be some confusion about term "Barnard"s test or "Boschloo"s test. Barnard's exact test is an unconditional test in the sense that it does not condition on both margins. Therefore, both the
16,582
Jeffreys Prior for normal distribution with unknown mean and variance
I think the discrepancy is explained by whether the authors consider the density over $\sigma$ or the density over $\sigma^2$. Supporting this interpretation, the exact thing that Kass and Wassermann write is $$ \pi(\mu, \sigma) = 1 / \sigma^2, $$ while Yang and Berger write $$ \pi(\mu, \sigma^2) = 1 / \sigma^4. $$
Jeffreys Prior for normal distribution with unknown mean and variance
I think the discrepancy is explained by whether the authors consider the density over $\sigma$ or the density over $\sigma^2$. Supporting this interpretation, the exact thing that Kass and Wassermann
Jeffreys Prior for normal distribution with unknown mean and variance I think the discrepancy is explained by whether the authors consider the density over $\sigma$ or the density over $\sigma^2$. Supporting this interpretation, the exact thing that Kass and Wassermann write is $$ \pi(\mu, \sigma) = 1 / \sigma^2, $$ while Yang and Berger write $$ \pi(\mu, \sigma^2) = 1 / \sigma^4. $$
Jeffreys Prior for normal distribution with unknown mean and variance I think the discrepancy is explained by whether the authors consider the density over $\sigma$ or the density over $\sigma^2$. Supporting this interpretation, the exact thing that Kass and Wassermann
16,583
Jeffreys Prior for normal distribution with unknown mean and variance
The existing answers already well answer the original question. As a physicist, I would just like to add to this discussion a dimensionality argument. If you consider $\mu$ and $\sigma^2$ to describe a distribution of a random variable in a real 1D space and measured in meters, they have the dimensions $[\mu] \sim m$ and $[\sigma^2] \sim m^2$. To have a physically correct prior, you need it to have the right dimensions, i.e. the only powers of $\sigma$ physically possible in a non-parametric prior are: $$ \pi(\mu, \sigma) \sim 1/\sigma^{2} $$ and $$ \pi(\mu, \sigma^2) \sim 1/\sigma^{3} $$.
Jeffreys Prior for normal distribution with unknown mean and variance
The existing answers already well answer the original question. As a physicist, I would just like to add to this discussion a dimensionality argument. If you consider $\mu$ and $\sigma^2$ to describe
Jeffreys Prior for normal distribution with unknown mean and variance The existing answers already well answer the original question. As a physicist, I would just like to add to this discussion a dimensionality argument. If you consider $\mu$ and $\sigma^2$ to describe a distribution of a random variable in a real 1D space and measured in meters, they have the dimensions $[\mu] \sim m$ and $[\sigma^2] \sim m^2$. To have a physically correct prior, you need it to have the right dimensions, i.e. the only powers of $\sigma$ physically possible in a non-parametric prior are: $$ \pi(\mu, \sigma) \sim 1/\sigma^{2} $$ and $$ \pi(\mu, \sigma^2) \sim 1/\sigma^{3} $$.
Jeffreys Prior for normal distribution with unknown mean and variance The existing answers already well answer the original question. As a physicist, I would just like to add to this discussion a dimensionality argument. If you consider $\mu$ and $\sigma^2$ to describe
16,584
Jeffreys Prior for normal distribution with unknown mean and variance
$\frac{1}{\sigma^3}$ is the Jeffreys prior. However in practice $\frac{1}{\sigma^2}$ is quite often used cause it leads to a relatively simple posterior, the "intuition" of this prior is that it corresponds with a flat prior on $\log(\sigma)$.
Jeffreys Prior for normal distribution with unknown mean and variance
$\frac{1}{\sigma^3}$ is the Jeffreys prior. However in practice $\frac{1}{\sigma^2}$ is quite often used cause it leads to a relatively simple posterior, the "intuition" of this prior is that it corre
Jeffreys Prior for normal distribution with unknown mean and variance $\frac{1}{\sigma^3}$ is the Jeffreys prior. However in practice $\frac{1}{\sigma^2}$ is quite often used cause it leads to a relatively simple posterior, the "intuition" of this prior is that it corresponds with a flat prior on $\log(\sigma)$.
Jeffreys Prior for normal distribution with unknown mean and variance $\frac{1}{\sigma^3}$ is the Jeffreys prior. However in practice $\frac{1}{\sigma^2}$ is quite often used cause it leads to a relatively simple posterior, the "intuition" of this prior is that it corre
16,585
Advantages of Box-Muller over inverse CDF method for simulating Normal distribution?
From a purely probabilistic perspective, both approaches are correct and hence equivalent. From an algorithmic perspective, the comparison must consider both the precision and the computing cost. Box-Muller relies on a uniform generator and costs about the same as this uniform generator. As mentioned in my comment, you can get away without sine or cosine calls, if not without the logarithm: generate $$U_1,U_2\stackrel{\text{iid}}{\sim}\mathcal{U}(-1,1)$$ until $S=U_1^2+U_2^2\le 1$ take $Z=\sqrt{-2\log(S)/S}$ and define $$X_1=ZU_1\,,\ X_2=Z U_2$$ The generic inversion algorithm requires the call to the inverse normal cdf, for instance qnorm(runif(N)) in R, which may be more costly than the above and more importantly may fail in the tails in terms of precision, unless the quantile function is well-coded. To follow on comments made by whuber, the comparison of rnorm(N)and qnorm(runif(N))is at the advantage of the inverse cdf, both in execution time: > system.time(qnorm(runif(10^8))) sutilisateur système écoulé 10.137 0.120 10.251 > system.time(rnorm(10^8)) utilisateur système écoulé 13.417 0.060 13.472` ` using the more accurate R benchmark test replications elapsed relative user.self sys.self 3 box-muller 100 0.103 1.839 0.103 0 2 inverse 100 0.056 1.000 0.056 0 1 R rnorm 100 0.064 1.143 0.064 0 and in terms of fit in the tail: Following a comment of Radford Neal on my blog, I want to point out that the default rnorm in R makes use of the inversion method, hence that the above comparison is reflecting on the interface and not on the simulation method itself! To quote the R documentation on RNG: ‘normal.kind’ can be ‘"Kinderman-Ramage"’, ‘"Buggy Kinderman-Ramage"’ (not for ‘set.seed’), ‘"Ahrens-Dieter"’, ‘"Box-Muller"’, ‘"Inversion"’ (the default), or ‘"user-supplied"’. (For inversion, see the reference in ‘qnorm’.) The Kinderman-Ramage generator used in versions prior to 1.7.1 (now called ‘"Buggy"’) had several approximation errors and should only be used for reproduction of old results. The ‘"Box-Muller"’ generator is stateful as pairs of normals are generated and returned sequentially. The state is reset whenever it is selected (even if it is the current normal generator) and when ‘kind’ is changed.
Advantages of Box-Muller over inverse CDF method for simulating Normal distribution?
From a purely probabilistic perspective, both approaches are correct and hence equivalent. From an algorithmic perspective, the comparison must consider both the precision and the computing cost. Box-
Advantages of Box-Muller over inverse CDF method for simulating Normal distribution? From a purely probabilistic perspective, both approaches are correct and hence equivalent. From an algorithmic perspective, the comparison must consider both the precision and the computing cost. Box-Muller relies on a uniform generator and costs about the same as this uniform generator. As mentioned in my comment, you can get away without sine or cosine calls, if not without the logarithm: generate $$U_1,U_2\stackrel{\text{iid}}{\sim}\mathcal{U}(-1,1)$$ until $S=U_1^2+U_2^2\le 1$ take $Z=\sqrt{-2\log(S)/S}$ and define $$X_1=ZU_1\,,\ X_2=Z U_2$$ The generic inversion algorithm requires the call to the inverse normal cdf, for instance qnorm(runif(N)) in R, which may be more costly than the above and more importantly may fail in the tails in terms of precision, unless the quantile function is well-coded. To follow on comments made by whuber, the comparison of rnorm(N)and qnorm(runif(N))is at the advantage of the inverse cdf, both in execution time: > system.time(qnorm(runif(10^8))) sutilisateur système écoulé 10.137 0.120 10.251 > system.time(rnorm(10^8)) utilisateur système écoulé 13.417 0.060 13.472` ` using the more accurate R benchmark test replications elapsed relative user.self sys.self 3 box-muller 100 0.103 1.839 0.103 0 2 inverse 100 0.056 1.000 0.056 0 1 R rnorm 100 0.064 1.143 0.064 0 and in terms of fit in the tail: Following a comment of Radford Neal on my blog, I want to point out that the default rnorm in R makes use of the inversion method, hence that the above comparison is reflecting on the interface and not on the simulation method itself! To quote the R documentation on RNG: ‘normal.kind’ can be ‘"Kinderman-Ramage"’, ‘"Buggy Kinderman-Ramage"’ (not for ‘set.seed’), ‘"Ahrens-Dieter"’, ‘"Box-Muller"’, ‘"Inversion"’ (the default), or ‘"user-supplied"’. (For inversion, see the reference in ‘qnorm’.) The Kinderman-Ramage generator used in versions prior to 1.7.1 (now called ‘"Buggy"’) had several approximation errors and should only be used for reproduction of old results. The ‘"Box-Muller"’ generator is stateful as pairs of normals are generated and returned sequentially. The state is reset whenever it is selected (even if it is the current normal generator) and when ‘kind’ is changed.
Advantages of Box-Muller over inverse CDF method for simulating Normal distribution? From a purely probabilistic perspective, both approaches are correct and hence equivalent. From an algorithmic perspective, the comparison must consider both the precision and the computing cost. Box-
16,586
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares over N?
There are at least three basic problems which can readily be explained to beginners: The "new" SD is not even defined for infinite populations. (One could declare it always to equal zero in such cases, but that would not make it any more useful.) The new SD does not behave the way an average should do under random sampling. Although the new SD can be used with all mathematical rigor to assess deviations from a mean (in samples and finite populations), its interpretation is unnecessarily complicated. 1. The applicability of the new SD is limited Point (1) could be brought home, even to those not versed in integration, by pointing out that because the variance clearly is an arithmetic mean (of squared deviations), it has a useful extension to models of "infinite" populations for which the intuition of the existence of an arithmetic mean still holds. Therefore its square root--the usual SD--is perfectly well defined in such cases, too, and just as useful in its role as a (nonlinear reexpression of) a variance. However, the new SD divides that average by the arbitrarily large $\sqrt{N}$, rendering problematic its generalization beyond finite populations and finite samples: what should $1/\sqrt{N}$ be taken to equal in such cases? 2. The new SD is not an average Any statistic worthy of the name "average" should have the property that it converges to the population value as the size of a random sample from the population increases. Any fixed multiple of the SD would have this property, because the multiplier would apply both to computing the sample SD and the population SD. (Although not directly contradicting the argument offered by Alecos Papadopoulos, this observation suggests that argument is only tangential to the real issues.) However, the "new" SD, being equal to $1/\sqrt{N}$ times the usual one, obviously converges to $0$ in all circumstances as the sample size $N$ grows large. Therefore, although for any fixed sample size $N$ the new SD (suitably interpreted) is a perfectly adequate measure of variation around the mean, it cannot justifiably be considered a universal measure applicable, with the same interpretation, for all sample sizes, nor can it correctly be called an "average" in any useful sense. 3. The new SD is complicated to interpret and use Consider taking samples of (say) size $N=4$. The new SD in these cases is $1/\sqrt{N}=1/2$ times the usual SD. It therefore enjoys comparable interpretations, such as an analog of the 68-95-99 rule (about 68% of the data should lie within two new SDs of the mean, 95% of them within four new SDs of the mean, etc.; and versions of classical inequalities such as Chebychev's will hold (no more than $1/k^2$ of the data can lie more than $2k$ new SDs away from their mean); and the Central Limit Theorem can be analogously restated in terms of the new SD (one divides by $\sqrt{N}$ times the new SD in order to standardize the variable). Thus, in this specific and clearly constrained sense, there is nothing wrong with the student's proposal. The difficulty, though, is that these statements all contain--quite explicitly--factors of $\sqrt{N}=2$. Although there is no inherent mathematical problem with this, it certainly complicates the statements and interpretation of the most fundamental laws of statistics. It is of note that Gauss and others originally parameterized the Gaussian distribution by $\sqrt{2}\sigma$, effectively using $\sqrt{2}$ times the SD to quantify the spread of a Normal random variable. This historical use demonstrates the propriety and effectiveness of using other fixed multiples of the SD in its stead.
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares
There are at least three basic problems which can readily be explained to beginners: The "new" SD is not even defined for infinite populations. (One could declare it always to equal zero in such cas
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares over N? There are at least three basic problems which can readily be explained to beginners: The "new" SD is not even defined for infinite populations. (One could declare it always to equal zero in such cases, but that would not make it any more useful.) The new SD does not behave the way an average should do under random sampling. Although the new SD can be used with all mathematical rigor to assess deviations from a mean (in samples and finite populations), its interpretation is unnecessarily complicated. 1. The applicability of the new SD is limited Point (1) could be brought home, even to those not versed in integration, by pointing out that because the variance clearly is an arithmetic mean (of squared deviations), it has a useful extension to models of "infinite" populations for which the intuition of the existence of an arithmetic mean still holds. Therefore its square root--the usual SD--is perfectly well defined in such cases, too, and just as useful in its role as a (nonlinear reexpression of) a variance. However, the new SD divides that average by the arbitrarily large $\sqrt{N}$, rendering problematic its generalization beyond finite populations and finite samples: what should $1/\sqrt{N}$ be taken to equal in such cases? 2. The new SD is not an average Any statistic worthy of the name "average" should have the property that it converges to the population value as the size of a random sample from the population increases. Any fixed multiple of the SD would have this property, because the multiplier would apply both to computing the sample SD and the population SD. (Although not directly contradicting the argument offered by Alecos Papadopoulos, this observation suggests that argument is only tangential to the real issues.) However, the "new" SD, being equal to $1/\sqrt{N}$ times the usual one, obviously converges to $0$ in all circumstances as the sample size $N$ grows large. Therefore, although for any fixed sample size $N$ the new SD (suitably interpreted) is a perfectly adequate measure of variation around the mean, it cannot justifiably be considered a universal measure applicable, with the same interpretation, for all sample sizes, nor can it correctly be called an "average" in any useful sense. 3. The new SD is complicated to interpret and use Consider taking samples of (say) size $N=4$. The new SD in these cases is $1/\sqrt{N}=1/2$ times the usual SD. It therefore enjoys comparable interpretations, such as an analog of the 68-95-99 rule (about 68% of the data should lie within two new SDs of the mean, 95% of them within four new SDs of the mean, etc.; and versions of classical inequalities such as Chebychev's will hold (no more than $1/k^2$ of the data can lie more than $2k$ new SDs away from their mean); and the Central Limit Theorem can be analogously restated in terms of the new SD (one divides by $\sqrt{N}$ times the new SD in order to standardize the variable). Thus, in this specific and clearly constrained sense, there is nothing wrong with the student's proposal. The difficulty, though, is that these statements all contain--quite explicitly--factors of $\sqrt{N}=2$. Although there is no inherent mathematical problem with this, it certainly complicates the statements and interpretation of the most fundamental laws of statistics. It is of note that Gauss and others originally parameterized the Gaussian distribution by $\sqrt{2}\sigma$, effectively using $\sqrt{2}$ times the SD to quantify the spread of a Normal random variable. This historical use demonstrates the propriety and effectiveness of using other fixed multiples of the SD in its stead.
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares There are at least three basic problems which can readily be explained to beginners: The "new" SD is not even defined for infinite populations. (One could declare it always to equal zero in such cas
16,587
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares over N?
Assume that your sample contains only two realizations. I guess an intuitive measure of dispersion would be the average absolute deviation (AAD) $$AAD = \frac 12 (|x_1-\bar x| + |x_2-\bar x|) = ...= \frac {|x_1-x_2|}{2}$$ So we would want other measures of dispersion at the same level of units of measurement to be "close" to the above. The sample variance is defined as $$\sigma^2=\frac{1}{2}[(x_1-\bar x)^2 + (x_2-\bar x)^2] = \frac 12 \left[\left(\frac {x_1-x_2}{2}\right)^2 + \left(\frac {x_2-x_1}{2}\right)^2\right]$$ $$=\frac 12 \left[\frac {(x_1-x_2)^2}{4} + \frac {(x_1-x_2)^2}{4}\right]=\frac 12 \frac {(x_1-x_2)^2}{2}$$ $$=\frac 12\cdot \frac {|x_1-x_2|^2}{2}$$ To return to the original units of measurement, if we did as the student wondered/suggested,we would obtain the measure, call it $q$ $$ q \equiv \frac 12\cdot \sqrt {\frac {|x_1-x_2|^2}{2}} = \frac 12 \frac {|x_1-x_2|}{\sqrt 2} = \frac 1{\sqrt 2} AAD < AAD$$ i.e. we would have "downplayed" the "intuitive" measure of dispersion, while if we have considered the standard deviation as defined, $$SD \equiv \sqrt {\sigma^2} = \frac {|x_1-x_2|}{2} =AAD$$ Since we want to "stay as close as possible" to the intuitive measure, we should use $SD$. ADDENDUM Let's consider now a sample of size $n$ We have $$n\cdot AAD = \sum_{i=1}^n |x_i-\bar x|$$ and $$n \cdot \text{Var}(X) = \sum_{i=1}^n (x_i-\bar x)^2 = \sum_{i=1}^n |x_i-\bar x|^2$$ we can write the right-hand side of the variance expression as $$\sum_{i=1}^n |x_i-\bar x|^2 = \left(\sum_{i=1}^n |x_i-\bar x|\right)^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$$ $$ = \left (n\cdot AAD\right)^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$$ Then the dispersion measure $q_n$ will be $$q_n \equiv \frac 1n \left[n^2\cdot AAD^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ $$= \left[AAD^2 - \frac 1{n^2} \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ Now think informally: note that $\sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$ contains $n^2-n$ terms, and so divided by $n^2$ will left us with "one term in the second power". But also "one term in the 2nd power" is what we have in $AAD^2$: this is a primitive way to "sense" why $q_n$ will tend to zero as $n$ grows large. On the other hand the Standard Deviation as defined would be $$SD \equiv \frac 1{\sqrt n} \left[n^2\cdot AAD^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ $$= \left[n\cdot AAD^2 - \frac 1{n} \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ Continuing are informal thinking, the first term gives us $n$ "terms in the 2nd power", while the second term gives us $n-1$ "terms in the second power" . So we will be left eventually with one such term, as $n$ grows large, and then we will take its square root. This does not mean that the Standard Deviation as defined will equal the Average Absolute Deviation in general (it doesn't), but it does show that it is suitably defined so as to be "on a par" with it for any $n$, as well as for the case when $n\rightarrow \infty$.
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares
Assume that your sample contains only two realizations. I guess an intuitive measure of dispersion would be the average absolute deviation (AAD) $$AAD = \frac 12 (|x_1-\bar x| + |x_2-\bar x|) = ...= \
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares over N? Assume that your sample contains only two realizations. I guess an intuitive measure of dispersion would be the average absolute deviation (AAD) $$AAD = \frac 12 (|x_1-\bar x| + |x_2-\bar x|) = ...= \frac {|x_1-x_2|}{2}$$ So we would want other measures of dispersion at the same level of units of measurement to be "close" to the above. The sample variance is defined as $$\sigma^2=\frac{1}{2}[(x_1-\bar x)^2 + (x_2-\bar x)^2] = \frac 12 \left[\left(\frac {x_1-x_2}{2}\right)^2 + \left(\frac {x_2-x_1}{2}\right)^2\right]$$ $$=\frac 12 \left[\frac {(x_1-x_2)^2}{4} + \frac {(x_1-x_2)^2}{4}\right]=\frac 12 \frac {(x_1-x_2)^2}{2}$$ $$=\frac 12\cdot \frac {|x_1-x_2|^2}{2}$$ To return to the original units of measurement, if we did as the student wondered/suggested,we would obtain the measure, call it $q$ $$ q \equiv \frac 12\cdot \sqrt {\frac {|x_1-x_2|^2}{2}} = \frac 12 \frac {|x_1-x_2|}{\sqrt 2} = \frac 1{\sqrt 2} AAD < AAD$$ i.e. we would have "downplayed" the "intuitive" measure of dispersion, while if we have considered the standard deviation as defined, $$SD \equiv \sqrt {\sigma^2} = \frac {|x_1-x_2|}{2} =AAD$$ Since we want to "stay as close as possible" to the intuitive measure, we should use $SD$. ADDENDUM Let's consider now a sample of size $n$ We have $$n\cdot AAD = \sum_{i=1}^n |x_i-\bar x|$$ and $$n \cdot \text{Var}(X) = \sum_{i=1}^n (x_i-\bar x)^2 = \sum_{i=1}^n |x_i-\bar x|^2$$ we can write the right-hand side of the variance expression as $$\sum_{i=1}^n |x_i-\bar x|^2 = \left(\sum_{i=1}^n |x_i-\bar x|\right)^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$$ $$ = \left (n\cdot AAD\right)^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$$ Then the dispersion measure $q_n$ will be $$q_n \equiv \frac 1n \left[n^2\cdot AAD^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ $$= \left[AAD^2 - \frac 1{n^2} \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ Now think informally: note that $\sum_{j\neq i} |x_i-\bar x||x_j-\bar x|$ contains $n^2-n$ terms, and so divided by $n^2$ will left us with "one term in the second power". But also "one term in the 2nd power" is what we have in $AAD^2$: this is a primitive way to "sense" why $q_n$ will tend to zero as $n$ grows large. On the other hand the Standard Deviation as defined would be $$SD \equiv \frac 1{\sqrt n} \left[n^2\cdot AAD^2 - \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ $$= \left[n\cdot AAD^2 - \frac 1{n} \sum_{j\neq i} |x_i-\bar x||x_j-\bar x|\right]^{1/2}$$ Continuing are informal thinking, the first term gives us $n$ "terms in the 2nd power", while the second term gives us $n-1$ "terms in the second power" . So we will be left eventually with one such term, as $n$ grows large, and then we will take its square root. This does not mean that the Standard Deviation as defined will equal the Average Absolute Deviation in general (it doesn't), but it does show that it is suitably defined so as to be "on a par" with it for any $n$, as well as for the case when $n\rightarrow \infty$.
Why is the standard deviation defined as sqrt of the variance and not as the sqrt of sum of squares Assume that your sample contains only two realizations. I guess an intuitive measure of dispersion would be the average absolute deviation (AAD) $$AAD = \frac 12 (|x_1-\bar x| + |x_2-\bar x|) = ...= \
16,588
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values?
Here's a little info that might point you in the right direction. Regarding your data, what you have is a response with multiple categories, and anytime you are trying to model a response which is categorical you are right to try and use some type of generalized linear model (GLM). In your case you have additional information which you must take into account regarding your response and that is that your response levels have a natural ordering good > middle > bad, notice how this is different from trying to model a response such as what color balloon someone is likely to buy (red/blue/green), these values have no natural ordering. When doing this type of model with an ordered response you may want to consider using a proportional odds model. http://en.wikipedia.org/wiki/Ordered_logit I haven't used it myself, but the polr() function in the MASS package is likely to be of some use, alternatively I have used the lrm() function in the rms package to do similar types of analysis, and have found it quite useful. If you load these packages just use ?polr or ?lrm for the function information. Alright enough background, on to your questions: This should be covered above, check out these packages/functions and read up on ordinal logistic regression and proportional odds models Any time you have a covariate which is categorical (Race/Sex/Hair color) you want to treat these as 'factors' in your R coding in order to model them appropriately. It's important to know what a factor is and how they are treated, but essentially you treat each category as a separate level and then model them in an appropriate way. Just read up on factors in models and you should be able to tease out whats going on. Keep in mind that treating categorical variables as factors is not unique to glm models or proportional odds models, but is typically how all models deal with categorical variables. http://www.stat.berkeley.edu/classes/s133/factors.html Missing values can sometimes be a hassle to deal with but if you're doing a fairly basic analysis its probably safe to just remove data rows which contain missing values (this isn't always true, but based on your current experience level I'm guessing you need not be concerned with the specifics of when and how to deal with missing values). In fact this is pretty much what R does. If you have a data which you are using to model, if you are missing information in a row for your response or any covariate in the model R is just going to exclude this data (this is the warning your seeing). Obviously if you're excluding a large proportion of your data due to missingness, your results could be biased and its probably good to try and get some more info on why there are so many missing values, but if you're missing 162 observations in 10,000 rows of data I wouldn't sweat it too much. You can google up on methods for handling missing data if you're interested in some more specifics. Almost all R model objects (lm, glm, lrm,...) will have an associated predict() function which will allow you to calculate the predicted values for your current modeling dataset and additionally for another dataset which you wish to predict an outcome for. Just search ?predict.glm or ?predict.lm to try and get some more info for whatever model type you want to work with. This is a very typical thing people wish to do with models so rest assured that there are some built in functions and methods that should make doing this relatively straightforward. Best of luck!
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values?
Here's a little info that might point you in the right direction. Regarding your data, what you have is a response with multiple categories, and anytime you are trying to model a response which is cat
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values? Here's a little info that might point you in the right direction. Regarding your data, what you have is a response with multiple categories, and anytime you are trying to model a response which is categorical you are right to try and use some type of generalized linear model (GLM). In your case you have additional information which you must take into account regarding your response and that is that your response levels have a natural ordering good > middle > bad, notice how this is different from trying to model a response such as what color balloon someone is likely to buy (red/blue/green), these values have no natural ordering. When doing this type of model with an ordered response you may want to consider using a proportional odds model. http://en.wikipedia.org/wiki/Ordered_logit I haven't used it myself, but the polr() function in the MASS package is likely to be of some use, alternatively I have used the lrm() function in the rms package to do similar types of analysis, and have found it quite useful. If you load these packages just use ?polr or ?lrm for the function information. Alright enough background, on to your questions: This should be covered above, check out these packages/functions and read up on ordinal logistic regression and proportional odds models Any time you have a covariate which is categorical (Race/Sex/Hair color) you want to treat these as 'factors' in your R coding in order to model them appropriately. It's important to know what a factor is and how they are treated, but essentially you treat each category as a separate level and then model them in an appropriate way. Just read up on factors in models and you should be able to tease out whats going on. Keep in mind that treating categorical variables as factors is not unique to glm models or proportional odds models, but is typically how all models deal with categorical variables. http://www.stat.berkeley.edu/classes/s133/factors.html Missing values can sometimes be a hassle to deal with but if you're doing a fairly basic analysis its probably safe to just remove data rows which contain missing values (this isn't always true, but based on your current experience level I'm guessing you need not be concerned with the specifics of when and how to deal with missing values). In fact this is pretty much what R does. If you have a data which you are using to model, if you are missing information in a row for your response or any covariate in the model R is just going to exclude this data (this is the warning your seeing). Obviously if you're excluding a large proportion of your data due to missingness, your results could be biased and its probably good to try and get some more info on why there are so many missing values, but if you're missing 162 observations in 10,000 rows of data I wouldn't sweat it too much. You can google up on methods for handling missing data if you're interested in some more specifics. Almost all R model objects (lm, glm, lrm,...) will have an associated predict() function which will allow you to calculate the predicted values for your current modeling dataset and additionally for another dataset which you wish to predict an outcome for. Just search ?predict.glm or ?predict.lm to try and get some more info for whatever model type you want to work with. This is a very typical thing people wish to do with models so rest assured that there are some built in functions and methods that should make doing this relatively straightforward. Best of luck!
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values? Here's a little info that might point you in the right direction. Regarding your data, what you have is a response with multiple categories, and anytime you are trying to model a response which is cat
16,589
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values?
Yes, ordered logit or probit would be where to start. Here's a tutorial on ordered logit that uses R. Other CV questions can probably help you with any snags you run into—try the tags 'logit,' 'probit,' and 'ordinal.' A standard approach to dealing with a categorical independent variable with $k$ values is to dummy code it as $k-1$ binary values. This is more fully explained here, but in short: The effect of one category is subsumed into the intercept, and coefficients are fitted to the remaining categories. In your example, there would be a dummy variable caucasian that would be coded to 1 for a Caucasian respondent, 0 otherwise. Dealing with missing data very much depends on the problem at hand, and yes, how you deal with missing data may introduce bias. This book excerpt nicely describes four mechanisms that can produce missing data, which should help you consider potential bias in your own problem at hand. (In particular, section 25.1, p. 530.) Many modeling packages have a predict function of some sort, and indeed the first tutorial linked above includes a demonstration.
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values?
Yes, ordered logit or probit would be where to start. Here's a tutorial on ordered logit that uses R. Other CV questions can probably help you with any snags you run into—try the tags 'logit,' 'probit
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values? Yes, ordered logit or probit would be where to start. Here's a tutorial on ordered logit that uses R. Other CV questions can probably help you with any snags you run into—try the tags 'logit,' 'probit,' and 'ordinal.' A standard approach to dealing with a categorical independent variable with $k$ values is to dummy code it as $k-1$ binary values. This is more fully explained here, but in short: The effect of one category is subsumed into the intercept, and coefficients are fitted to the remaining categories. In your example, there would be a dummy variable caucasian that would be coded to 1 for a Caucasian respondent, 0 otherwise. Dealing with missing data very much depends on the problem at hand, and yes, how you deal with missing data may introduce bias. This book excerpt nicely describes four mechanisms that can produce missing data, which should help you consider potential bias in your own problem at hand. (In particular, section 25.1, p. 530.) Many modeling packages have a predict function of some sort, and indeed the first tutorial linked above includes a demonstration.
How do I run Ordinal Logistic Regression analysis in R with both numerical / categorical values? Yes, ordered logit or probit would be where to start. Here's a tutorial on ordered logit that uses R. Other CV questions can probably help you with any snags you run into—try the tags 'logit,' 'probit
16,590
Book recommendations for beginners about probability distributions
If you've no mathematical impediments there's a good overview in Ch. 3 of Casella & Berger, Statistical Inference, & much is covered in Grinstead & Snell, Introduction to Probability (it's free); for more detail I'd recommend Severini, Elements of Distribution Theory. But there are lots - it would be more difficult, I think, to find a less mathematical treatment that still gives the reader some feel for where different distributions come from.
Book recommendations for beginners about probability distributions
If you've no mathematical impediments there's a good overview in Ch. 3 of Casella & Berger, Statistical Inference, & much is covered in Grinstead & Snell, Introduction to Probability (it's free); for
Book recommendations for beginners about probability distributions If you've no mathematical impediments there's a good overview in Ch. 3 of Casella & Berger, Statistical Inference, & much is covered in Grinstead & Snell, Introduction to Probability (it's free); for more detail I'd recommend Severini, Elements of Distribution Theory. But there are lots - it would be more difficult, I think, to find a less mathematical treatment that still gives the reader some feel for where different distributions come from.
Book recommendations for beginners about probability distributions If you've no mathematical impediments there's a good overview in Ch. 3 of Casella & Berger, Statistical Inference, & much is covered in Grinstead & Snell, Introduction to Probability (it's free); for
16,591
Book recommendations for beginners about probability distributions
You should read "Continuous univariate distributions" Vol. 1 & 2. by Johnson and Kotz. Also "The Weibull distribution A Handbook" by Horst Rinne. Second one is a useful book to understand a distribution although this book focus on Weibull distribution. May be some material is not easy to under stand but early chapters give you some useful knowledge.
Book recommendations for beginners about probability distributions
You should read "Continuous univariate distributions" Vol. 1 & 2. by Johnson and Kotz. Also "The Weibull distribution A Handbook" by Horst Rinne. Second one is a useful book to understand a distributi
Book recommendations for beginners about probability distributions You should read "Continuous univariate distributions" Vol. 1 & 2. by Johnson and Kotz. Also "The Weibull distribution A Handbook" by Horst Rinne. Second one is a useful book to understand a distribution although this book focus on Weibull distribution. May be some material is not easy to under stand but early chapters give you some useful knowledge.
Book recommendations for beginners about probability distributions You should read "Continuous univariate distributions" Vol. 1 & 2. by Johnson and Kotz. Also "The Weibull distribution A Handbook" by Horst Rinne. Second one is a useful book to understand a distributi
16,592
Book recommendations for beginners about probability distributions
For a short and easy overview of a lot of probability distributions, I recommend Probability and statistics EBook. Most distributions are described in chapter XV, but the more common ones are spread out in earlier parts of the book.
Book recommendations for beginners about probability distributions
For a short and easy overview of a lot of probability distributions, I recommend Probability and statistics EBook. Most distributions are described in chapter XV, but the more common ones are spread o
Book recommendations for beginners about probability distributions For a short and easy overview of a lot of probability distributions, I recommend Probability and statistics EBook. Most distributions are described in chapter XV, but the more common ones are spread out in earlier parts of the book.
Book recommendations for beginners about probability distributions For a short and easy overview of a lot of probability distributions, I recommend Probability and statistics EBook. Most distributions are described in chapter XV, but the more common ones are spread o
16,593
Likelihood vs conditional distribution for Bayesian analysis
Suppose that you have $X_1,\dots,X_n$ random variables (whose values will be observed in your experiment) that are conditionally independent, given that $\Theta=\theta$, with conditional densities $f_{X_i\mid\Theta}(\,\cdot\mid\theta)$, for $i=1,\dots,n$. This is your (postulated) statistical (conditional) model, and the conditional densities express, for each possible value $\theta$ of the (random) parameter $\Theta$, your uncertainty about the values of the $X_i$'s, before you have access to any real data. With the help of the conditional densities you can, for example, compute conditional probabilities like $$ P\{X_1\in B_1,\dots,X_n\in B_n\mid \Theta=\theta\} = \int_{B_1\times\dots\times B_n} \prod_{i=1}^n f_{X_i\mid\Theta}(x_i\mid\theta)\,dx_1\dots dx_n \, , $$ for each $\theta$. After you have access to an actual sample $(x_1,\dots,x_n)$ of values (realizations) of the $X_i$'s that have been observed in one run of your experiment, the situation changes: there is no longer uncertainty about the observables $X_1,\dots,X_n$. Suppose that the random $\Theta$ assumes values in some parameter space $\Pi$. Now, you define, for those known (fixed) values $(x_1,\dots,x_n)$ a function $$ L_{x_1,\dots,x_n} : \Pi \to \mathbb{R} \, $$ by $$ L_{x_1,\dots,x_n}(\theta)=\prod_{i=1}^n f_{X_i\mid\Theta}(x_i\mid\theta) \, . $$ Note that $L_{x_1,\dots,x_n}$, known as the "likelihood function" is a function of $\theta$. In this "after you have data" situation, the likelihood $L_{x_1,\dots,x_n}$ contains, for the particular conditional model that we are considering, all the information about the parameter $\Theta$ contained in this particular sample $(x_1,\dots,x_n)$. In fact, it happens that $L_{x_1,\dots,x_n}$ is a sufficient statistic for $\Theta$. Answering your question, to understand the differences between the concepts of conditional density and likelihood, keep in mind their mathematical definitions (which are clearly different: they are different mathematical objects, with different properties), and also remember that conditional density is a "pre-sample" object/concept, while the likelihood is an "after-sample" one. I hope that all this also help you to answer why Bayesian inference (using your way of putting it, which I don't think is ideal) is done "using the likelihood function and not the conditional distribution": the goal of Bayesian inference is to compute the posterior distribution, and to do so we condition on the observed (known) data.
Likelihood vs conditional distribution for Bayesian analysis
Suppose that you have $X_1,\dots,X_n$ random variables (whose values will be observed in your experiment) that are conditionally independent, given that $\Theta=\theta$, with conditional densities $f_
Likelihood vs conditional distribution for Bayesian analysis Suppose that you have $X_1,\dots,X_n$ random variables (whose values will be observed in your experiment) that are conditionally independent, given that $\Theta=\theta$, with conditional densities $f_{X_i\mid\Theta}(\,\cdot\mid\theta)$, for $i=1,\dots,n$. This is your (postulated) statistical (conditional) model, and the conditional densities express, for each possible value $\theta$ of the (random) parameter $\Theta$, your uncertainty about the values of the $X_i$'s, before you have access to any real data. With the help of the conditional densities you can, for example, compute conditional probabilities like $$ P\{X_1\in B_1,\dots,X_n\in B_n\mid \Theta=\theta\} = \int_{B_1\times\dots\times B_n} \prod_{i=1}^n f_{X_i\mid\Theta}(x_i\mid\theta)\,dx_1\dots dx_n \, , $$ for each $\theta$. After you have access to an actual sample $(x_1,\dots,x_n)$ of values (realizations) of the $X_i$'s that have been observed in one run of your experiment, the situation changes: there is no longer uncertainty about the observables $X_1,\dots,X_n$. Suppose that the random $\Theta$ assumes values in some parameter space $\Pi$. Now, you define, for those known (fixed) values $(x_1,\dots,x_n)$ a function $$ L_{x_1,\dots,x_n} : \Pi \to \mathbb{R} \, $$ by $$ L_{x_1,\dots,x_n}(\theta)=\prod_{i=1}^n f_{X_i\mid\Theta}(x_i\mid\theta) \, . $$ Note that $L_{x_1,\dots,x_n}$, known as the "likelihood function" is a function of $\theta$. In this "after you have data" situation, the likelihood $L_{x_1,\dots,x_n}$ contains, for the particular conditional model that we are considering, all the information about the parameter $\Theta$ contained in this particular sample $(x_1,\dots,x_n)$. In fact, it happens that $L_{x_1,\dots,x_n}$ is a sufficient statistic for $\Theta$. Answering your question, to understand the differences between the concepts of conditional density and likelihood, keep in mind their mathematical definitions (which are clearly different: they are different mathematical objects, with different properties), and also remember that conditional density is a "pre-sample" object/concept, while the likelihood is an "after-sample" one. I hope that all this also help you to answer why Bayesian inference (using your way of putting it, which I don't think is ideal) is done "using the likelihood function and not the conditional distribution": the goal of Bayesian inference is to compute the posterior distribution, and to do so we condition on the observed (known) data.
Likelihood vs conditional distribution for Bayesian analysis Suppose that you have $X_1,\dots,X_n$ random variables (whose values will be observed in your experiment) that are conditionally independent, given that $\Theta=\theta$, with conditional densities $f_
16,594
Likelihood vs conditional distribution for Bayesian analysis
Proportionality is used to simplify analysis Bayesian analysis is generally done via an even simpler statement of Bayes' theorem, where we work only in terms of proportionality with respect to the parameter of interest. For a standard IID model with sampling density $f(X|\theta)$ we can express this as: $$p(\theta|\mathbf{x}) \propto L_\mathbf{x}(\theta) \cdot p(\theta) \quad \quad \quad \quad L_\mathbf{x}(\theta) \propto \prod_{i=1}^n f(x_i|\theta).$$ This statement of Bayesian updating works in terms of proportionality with respect to the parameter $\theta$. It uses two proportionality simplifications: one in the use of the likelihood function (proportional to the sampling density) and one in the posterior (proportional to the product of likelihood and prior). Since the posterior is a density function (in the continuous case), the norming rule then sets the multiplicative constant that is required to yield a valid density (i.e., to make it integrate to one). This method use of proportionality has the advantage of allowing us to ignore any multiplicative elements of the functions that do not depend on the parameter $\theta$. This tends to simplify the problem by allowing us to sweep away unnecessary parts of the mathematics, and get simpler statements of the updating mechanism. This is not a mathematical requirement (since Bayes' rule works in its non-proportional form too), but it makes things simpler for our tiny animal brains. An applied example: Consider an IID model with observed data $X_1, ..., X_n \sim \text{IID N}(\theta, 1)$. To facilitate our analysis we define the statistics $\bar{x} = \tfrac{1}{n} \sum_{i=1}^n x_i$ and $\bar{\bar{x}} = \tfrac{1}{n} \sum_{i=1}^n x_i^2$, which are the first two sample moments. For this model we have sampling density: $$\begin{equation} \begin{aligned} f(\mathbf{x}|\theta) = \prod_{i=1}^n f(x_i|\theta) &= \prod_{i=1}^n \text{N}(x_i|\theta,1) \\[6pt] &= \prod_{i=1}^n \frac{1}{\sqrt{2 \pi}} \exp \Big( -\frac{1}{2} (x_i-\theta)^2 \Big) \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{1}{2} \sum_{i=1}^n (x_i-\theta)^2 \Big). \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta + \bar{\bar{x}} ) \Big) \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{n \bar{\bar{x}}}{2} \Big) \cdot \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \\[6pt] \end{aligned} \end{equation}$$ Now, we can work directly with this sampling density if we want to. But notice that the first two terms in this density are multiplicative constants that do not depend on $\theta$. It is annoying to have to keep track of these terms, so let's just get rid of them, so we have the likelihood function: $$L_\mathbf{x}(\theta) = \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big).$$ That simplifies things a little bit, since we don't have to keep track of an additional term. Now, we could apply Bayes' rule using its full equation-version, including the integral denominator. But again, this requires us to keep track of another annoying multiplicative constant that does not depend on $\theta$ (more annoying because we have to solve an integral to get it). So let's just apply Bayes' rule in its proportional form. Using the conjugate prior $\theta \sim \text{N}(0,\lambda_0)$, with some known precision parameter $\lambda_0>0$, we get the following result (by completing the square): $$\begin{equation} \begin{aligned} p(\theta|\mathbf{x}) &\propto L_\mathbf{x}(\theta) \cdot p(\theta) \\[10pt] &= \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \cdot \text{N}(\theta|0,\lambda_0) \\[6pt] &\propto \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \cdot \exp \Big( -\frac{\lambda_0}{2} \theta^2 \Big) \\[6pt] &= \exp \Big( -\frac{1}{2} ( n\theta^2 - 2n\bar{x} \theta + \lambda_0 \theta^2 ) \Big) \\[6pt] &= \exp \Big( -\frac{1}{2} ( (n+\lambda_0) \theta^2 - 2n\bar{x} \theta ) \Big) \\[6pt] &= \exp \Big( -\frac{n+\lambda_0}{2} \Big( \theta^2 - 2 \frac{n\bar{x}}{n+\lambda_0} \theta \Big) \Big) \\[6pt] &\propto \exp \Big( -\frac{n+\lambda_0}{2} \Big( \theta - \frac{n}{n+\lambda_0} \cdot \bar{x} \Big)^2 \Big) \\[6pt] &\propto \text{N}\Big( \theta \Big| \frac{n}{n+\lambda_0} \cdot \bar{x}, n+\lambda_0 \Big). \\[6pt] \end{aligned} \end{equation}$$ So, from this working we can see that the posterior distribution is proportional to a normal density. Since the posterior must be a density, this implies that the posterior is that normal density: $$p(\theta|\mathbf{x}) = \text{N}\Big( \theta \Big| \frac{n}{n+\lambda_0} \cdot \bar{x}, n+\lambda_0 \Big).$$ Hence, we see that a posteriori the parameter $\theta$ is normally distributed with posterior mean and variance given by: $$\mathbb{E}(\theta|\mathbf{x}) = \frac{n}{n+\lambda_0} \cdot \bar{x} \quad \quad \quad \quad \mathbb{V}(\theta|\mathbf{x}) = \frac{1}{n+\lambda_0}.$$ Now, the posterior distribution we have derived has a constant of integration out the front of it (which we can find easily by looking up the form of the normal distribution). But notice that we did not have to worry about this multiplicative constant - all our working removed (or brought in) multiplicative constants whenever this simplified the mathematics. The same result can be derived while keeping track of the multiplicative constants, but this is a lot messier.
Likelihood vs conditional distribution for Bayesian analysis
Proportionality is used to simplify analysis Bayesian analysis is generally done via an even simpler statement of Bayes' theorem, where we work only in terms of proportionality with respect to the par
Likelihood vs conditional distribution for Bayesian analysis Proportionality is used to simplify analysis Bayesian analysis is generally done via an even simpler statement of Bayes' theorem, where we work only in terms of proportionality with respect to the parameter of interest. For a standard IID model with sampling density $f(X|\theta)$ we can express this as: $$p(\theta|\mathbf{x}) \propto L_\mathbf{x}(\theta) \cdot p(\theta) \quad \quad \quad \quad L_\mathbf{x}(\theta) \propto \prod_{i=1}^n f(x_i|\theta).$$ This statement of Bayesian updating works in terms of proportionality with respect to the parameter $\theta$. It uses two proportionality simplifications: one in the use of the likelihood function (proportional to the sampling density) and one in the posterior (proportional to the product of likelihood and prior). Since the posterior is a density function (in the continuous case), the norming rule then sets the multiplicative constant that is required to yield a valid density (i.e., to make it integrate to one). This method use of proportionality has the advantage of allowing us to ignore any multiplicative elements of the functions that do not depend on the parameter $\theta$. This tends to simplify the problem by allowing us to sweep away unnecessary parts of the mathematics, and get simpler statements of the updating mechanism. This is not a mathematical requirement (since Bayes' rule works in its non-proportional form too), but it makes things simpler for our tiny animal brains. An applied example: Consider an IID model with observed data $X_1, ..., X_n \sim \text{IID N}(\theta, 1)$. To facilitate our analysis we define the statistics $\bar{x} = \tfrac{1}{n} \sum_{i=1}^n x_i$ and $\bar{\bar{x}} = \tfrac{1}{n} \sum_{i=1}^n x_i^2$, which are the first two sample moments. For this model we have sampling density: $$\begin{equation} \begin{aligned} f(\mathbf{x}|\theta) = \prod_{i=1}^n f(x_i|\theta) &= \prod_{i=1}^n \text{N}(x_i|\theta,1) \\[6pt] &= \prod_{i=1}^n \frac{1}{\sqrt{2 \pi}} \exp \Big( -\frac{1}{2} (x_i-\theta)^2 \Big) \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{1}{2} \sum_{i=1}^n (x_i-\theta)^2 \Big). \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta + \bar{\bar{x}} ) \Big) \\[6pt] &= (2 \pi)^{n/2} \exp \Big( -\frac{n \bar{\bar{x}}}{2} \Big) \cdot \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \\[6pt] \end{aligned} \end{equation}$$ Now, we can work directly with this sampling density if we want to. But notice that the first two terms in this density are multiplicative constants that do not depend on $\theta$. It is annoying to have to keep track of these terms, so let's just get rid of them, so we have the likelihood function: $$L_\mathbf{x}(\theta) = \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big).$$ That simplifies things a little bit, since we don't have to keep track of an additional term. Now, we could apply Bayes' rule using its full equation-version, including the integral denominator. But again, this requires us to keep track of another annoying multiplicative constant that does not depend on $\theta$ (more annoying because we have to solve an integral to get it). So let's just apply Bayes' rule in its proportional form. Using the conjugate prior $\theta \sim \text{N}(0,\lambda_0)$, with some known precision parameter $\lambda_0>0$, we get the following result (by completing the square): $$\begin{equation} \begin{aligned} p(\theta|\mathbf{x}) &\propto L_\mathbf{x}(\theta) \cdot p(\theta) \\[10pt] &= \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \cdot \text{N}(\theta|0,\lambda_0) \\[6pt] &\propto \exp \Big( -\frac{n}{2} ( \theta^2 - 2\bar{x} \theta ) \Big) \cdot \exp \Big( -\frac{\lambda_0}{2} \theta^2 \Big) \\[6pt] &= \exp \Big( -\frac{1}{2} ( n\theta^2 - 2n\bar{x} \theta + \lambda_0 \theta^2 ) \Big) \\[6pt] &= \exp \Big( -\frac{1}{2} ( (n+\lambda_0) \theta^2 - 2n\bar{x} \theta ) \Big) \\[6pt] &= \exp \Big( -\frac{n+\lambda_0}{2} \Big( \theta^2 - 2 \frac{n\bar{x}}{n+\lambda_0} \theta \Big) \Big) \\[6pt] &\propto \exp \Big( -\frac{n+\lambda_0}{2} \Big( \theta - \frac{n}{n+\lambda_0} \cdot \bar{x} \Big)^2 \Big) \\[6pt] &\propto \text{N}\Big( \theta \Big| \frac{n}{n+\lambda_0} \cdot \bar{x}, n+\lambda_0 \Big). \\[6pt] \end{aligned} \end{equation}$$ So, from this working we can see that the posterior distribution is proportional to a normal density. Since the posterior must be a density, this implies that the posterior is that normal density: $$p(\theta|\mathbf{x}) = \text{N}\Big( \theta \Big| \frac{n}{n+\lambda_0} \cdot \bar{x}, n+\lambda_0 \Big).$$ Hence, we see that a posteriori the parameter $\theta$ is normally distributed with posterior mean and variance given by: $$\mathbb{E}(\theta|\mathbf{x}) = \frac{n}{n+\lambda_0} \cdot \bar{x} \quad \quad \quad \quad \mathbb{V}(\theta|\mathbf{x}) = \frac{1}{n+\lambda_0}.$$ Now, the posterior distribution we have derived has a constant of integration out the front of it (which we can find easily by looking up the form of the normal distribution). But notice that we did not have to worry about this multiplicative constant - all our working removed (or brought in) multiplicative constants whenever this simplified the mathematics. The same result can be derived while keeping track of the multiplicative constants, but this is a lot messier.
Likelihood vs conditional distribution for Bayesian analysis Proportionality is used to simplify analysis Bayesian analysis is generally done via an even simpler statement of Bayes' theorem, where we work only in terms of proportionality with respect to the par
16,595
Likelihood vs conditional distribution for Bayesian analysis
I think Zen's answer really tells you how conceptually the likelihood function and the joint density of values of random variables differ. Still mathematically as a function of both the x$_i$s and θ they are the same and in that sense the likelihood can be looked at as a probability density. The difference you point to in the formula for the Bayes posterior distribution is just a notational difference. But the subtlety of the difference is nicely explained in Zen's answer. This issue has come up in other questions discussed on this site regarding the likelihood function. Also other comments by kjetil and Dilip seem to support what I am saying.
Likelihood vs conditional distribution for Bayesian analysis
I think Zen's answer really tells you how conceptually the likelihood function and the joint density of values of random variables differ. Still mathematically as a function of both the x$_i$s and θ t
Likelihood vs conditional distribution for Bayesian analysis I think Zen's answer really tells you how conceptually the likelihood function and the joint density of values of random variables differ. Still mathematically as a function of both the x$_i$s and θ they are the same and in that sense the likelihood can be looked at as a probability density. The difference you point to in the formula for the Bayes posterior distribution is just a notational difference. But the subtlety of the difference is nicely explained in Zen's answer. This issue has come up in other questions discussed on this site regarding the likelihood function. Also other comments by kjetil and Dilip seem to support what I am saying.
Likelihood vs conditional distribution for Bayesian analysis I think Zen's answer really tells you how conceptually the likelihood function and the joint density of values of random variables differ. Still mathematically as a function of both the x$_i$s and θ t
16,596
Applicability of chi-square test if many cells have frequencies less than 5
Conover (1999:202) suggested that the expected values can be "as small as 0.5, as long as most are greater than 1.0, without endangering the validity of the test." He also provides a "rule of thumb" from Cochran (1952) which suggested that if expected values are less than 1 or if more than 20% are less than 5, the test may perform poorly. However, Conover (1999) provides some evidence that Cochran's "rule of thumb" is overly conservative. References Cochran, W. G. 1952. The $\chi^2$ test of goodness of fit. Annals of Mathematical Statistics 23:315-345. Conover, W. J. 1999. Practical nonparametric statistics. Third Edition. John Wiley & Sons, Inc., New York, New York, USA.
Applicability of chi-square test if many cells have frequencies less than 5
Conover (1999:202) suggested that the expected values can be "as small as 0.5, as long as most are greater than 1.0, without endangering the validity of the test." He also provides a "rule of thumb" f
Applicability of chi-square test if many cells have frequencies less than 5 Conover (1999:202) suggested that the expected values can be "as small as 0.5, as long as most are greater than 1.0, without endangering the validity of the test." He also provides a "rule of thumb" from Cochran (1952) which suggested that if expected values are less than 1 or if more than 20% are less than 5, the test may perform poorly. However, Conover (1999) provides some evidence that Cochran's "rule of thumb" is overly conservative. References Cochran, W. G. 1952. The $\chi^2$ test of goodness of fit. Annals of Mathematical Statistics 23:315-345. Conover, W. J. 1999. Practical nonparametric statistics. Third Edition. John Wiley & Sons, Inc., New York, New York, USA.
Applicability of chi-square test if many cells have frequencies less than 5 Conover (1999:202) suggested that the expected values can be "as small as 0.5, as long as most are greater than 1.0, without endangering the validity of the test." He also provides a "rule of thumb" f
16,597
Applicability of chi-square test if many cells have frequencies less than 5
The $\chi^2$-test was originally devised by Pearson as an approximation to the log-likelihood ratio, due to the fact that log-likelihoods were too computationally intensive for the time. Pearson's G is defined as $G = 2\sum_{ij}O_{ij}\ln(O_{ij}/E_{ij})$. It follows the same distribution as the corresponding $\chi^2$-test. (Forgot to mention originally: G is much less sensitive to expected cell counts < 5).
Applicability of chi-square test if many cells have frequencies less than 5
The $\chi^2$-test was originally devised by Pearson as an approximation to the log-likelihood ratio, due to the fact that log-likelihoods were too computationally intensive for the time. Pearson's G i
Applicability of chi-square test if many cells have frequencies less than 5 The $\chi^2$-test was originally devised by Pearson as an approximation to the log-likelihood ratio, due to the fact that log-likelihoods were too computationally intensive for the time. Pearson's G is defined as $G = 2\sum_{ij}O_{ij}\ln(O_{ij}/E_{ij})$. It follows the same distribution as the corresponding $\chi^2$-test. (Forgot to mention originally: G is much less sensitive to expected cell counts < 5).
Applicability of chi-square test if many cells have frequencies less than 5 The $\chi^2$-test was originally devised by Pearson as an approximation to the log-likelihood ratio, due to the fact that log-likelihoods were too computationally intensive for the time. Pearson's G i
16,598
What is the RMSE normalized by the mean observed value called?
Yes, it is called the coefficient of variation. See this question for some discussion about this parameter, or read the Wikipedia entry.
What is the RMSE normalized by the mean observed value called?
Yes, it is called the coefficient of variation. See this question for some discussion about this parameter, or read the Wikipedia entry.
What is the RMSE normalized by the mean observed value called? Yes, it is called the coefficient of variation. See this question for some discussion about this parameter, or read the Wikipedia entry.
What is the RMSE normalized by the mean observed value called? Yes, it is called the coefficient of variation. See this question for some discussion about this parameter, or read the Wikipedia entry.
16,599
What is the RMSE normalized by the mean observed value called?
In my field (analytical chemistry), absolute error / absolute value = relative error, so relative RMSE [at mean x] would be understood easily. I'd clarify that the value I divide by is the average, as often the relative error at the extreme values is used: error specification of measuring instruments often is relative error at maximum value in (chemical-analytical) calibration the relative error at the limit of quantitation or the lower limit of the actual calibration is important.
What is the RMSE normalized by the mean observed value called?
In my field (analytical chemistry), absolute error / absolute value = relative error, so relative RMSE [at mean x] would be understood easily. I'd clarify that the value I divide by is the average, as
What is the RMSE normalized by the mean observed value called? In my field (analytical chemistry), absolute error / absolute value = relative error, so relative RMSE [at mean x] would be understood easily. I'd clarify that the value I divide by is the average, as often the relative error at the extreme values is used: error specification of measuring instruments often is relative error at maximum value in (chemical-analytical) calibration the relative error at the limit of quantitation or the lower limit of the actual calibration is important.
What is the RMSE normalized by the mean observed value called? In my field (analytical chemistry), absolute error / absolute value = relative error, so relative RMSE [at mean x] would be understood easily. I'd clarify that the value I divide by is the average, as
16,600
What is the RMSE normalized by the mean observed value called?
It is called Normalised Root Mean Square Error (nRMSE) or Relative Root Mean Square Error (rRMSE). You can use either mean or range as the denominator. Read the Wikipedia article
What is the RMSE normalized by the mean observed value called?
It is called Normalised Root Mean Square Error (nRMSE) or Relative Root Mean Square Error (rRMSE). You can use either mean or range as the denominator. Read the Wikipedia article
What is the RMSE normalized by the mean observed value called? It is called Normalised Root Mean Square Error (nRMSE) or Relative Root Mean Square Error (rRMSE). You can use either mean or range as the denominator. Read the Wikipedia article
What is the RMSE normalized by the mean observed value called? It is called Normalised Root Mean Square Error (nRMSE) or Relative Root Mean Square Error (rRMSE). You can use either mean or range as the denominator. Read the Wikipedia article