idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
βŒ€
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
βŒ€
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
44,301
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)?
Apart from the reasons mentioned in the comments to your question, there is another important one: in applying maximum likelihood estimation, we essentially solve a maximization problem with respect to the unknown coefficients. Recall that finding the global maximum of a function is not a simple matter, in case where we have many unknowns, and when the objective function lacks (or is unknown whether it possesses) certain general properties, like concavity (in the case of maximization), especially when the maximization will be done through an iterative procedure (as will be the case for most likelihood functions). Moreover, concavity of the objective function is an important condition in proving consistency of the ML estimator when the parameter space is not compact (for example when you estimate variances, $\sigma^2$, the parameter space is not compact but open from below, since by conception $\sigma^2 >0$. So we would want our objective function to be concave with respect to the parameters, to guarantee a global maximum. In linear models, if we have concavity in the variable, we obtain concavity in the parameters. Now there are many widely used distributions, whose density functions are not concave, but their natural logarithms are (we call such functions "log-concave"). The Normal density is the most prominent example: the function $$f_X(x) =\frac {1}{\sigma\sqrt{2\pi}}e^{-\frac 12 (\frac{x-\mu}{\sigma})^2} $$ is neither convex nor concave in $x$ (it has a middle concave part and is convex in the tails). But the function $$\ln f_X(x) =\ln \left(\frac {1}{\sigma\sqrt{2\pi}}\right) -\frac 12 \left(\frac{x-\mu}{\sigma}\right)^2 $$ is globally concave in $x$. (Then by using the invariance property of the ML estimator, we can show by a suitable one-to-one transformation of the unknown parameter vector, that the function is concave in the re-parametrized vector). But in general, the basic point is that taking logs produces concavity of the objective function, which is a very desirable property.
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)?
Apart from the reasons mentioned in the comments to your question, there is another important one: in applying maximum likelihood estimation, we essentially solve a maximization problem with respect t
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)? Apart from the reasons mentioned in the comments to your question, there is another important one: in applying maximum likelihood estimation, we essentially solve a maximization problem with respect to the unknown coefficients. Recall that finding the global maximum of a function is not a simple matter, in case where we have many unknowns, and when the objective function lacks (or is unknown whether it possesses) certain general properties, like concavity (in the case of maximization), especially when the maximization will be done through an iterative procedure (as will be the case for most likelihood functions). Moreover, concavity of the objective function is an important condition in proving consistency of the ML estimator when the parameter space is not compact (for example when you estimate variances, $\sigma^2$, the parameter space is not compact but open from below, since by conception $\sigma^2 >0$. So we would want our objective function to be concave with respect to the parameters, to guarantee a global maximum. In linear models, if we have concavity in the variable, we obtain concavity in the parameters. Now there are many widely used distributions, whose density functions are not concave, but their natural logarithms are (we call such functions "log-concave"). The Normal density is the most prominent example: the function $$f_X(x) =\frac {1}{\sigma\sqrt{2\pi}}e^{-\frac 12 (\frac{x-\mu}{\sigma})^2} $$ is neither convex nor concave in $x$ (it has a middle concave part and is convex in the tails). But the function $$\ln f_X(x) =\ln \left(\frac {1}{\sigma\sqrt{2\pi}}\right) -\frac 12 \left(\frac{x-\mu}{\sigma}\right)^2 $$ is globally concave in $x$. (Then by using the invariance property of the ML estimator, we can show by a suitable one-to-one transformation of the unknown parameter vector, that the function is concave in the re-parametrized vector). But in general, the basic point is that taking logs produces concavity of the objective function, which is a very desirable property.
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)? Apart from the reasons mentioned in the comments to your question, there is another important one: in applying maximum likelihood estimation, we essentially solve a maximization problem with respect t
44,302
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)?
In addition to the mathematical reason that Alecos wrote, let me give you a computational reason. Remember that the likelihood function is nothing but the joint density of random variables (expressed as a function of the parameters), i.e. $$ Pr(\mathbf{x}) = Pr(x_{1})\cdot Pr(x_{2})\cdot\ldots\cdot Pr(x_{n}) = \prod_{i}^{n} Pr(x_{i}) $$ for i.i.d. data. The probability density $0 \leq Pr(x_{i}) \leq 1$ for all $i$, so this number $Pr(\mathbf{x})$ becomes very small quickly as $n$ increases. Suppose all $Pr(x_{i}) = 0.5$ and $n=1000$, then $$ \prod_{i}^{n} Pr(x_{i}) = 0.5^{1000} = 9.33 \cdot 10^{-302} $$ For only slightly larger datasets, or slightly smaller $Pr(x_{i})$, we are outside the representable range for software packages. For instance, the smallest representable number in R is $2.225074\cdot10^{-308}$. On the flipside, we have $$ \log(Pr(\mathbf{x})) = \sum_{i}^{n} \log \left( Pr(x_{i}) \right) = 1000\cdot \log(0.5) = -693.1472 $$ and even for $n=1000000$ we only have $\log(Pr(\mathbf{x})) = 1000000\cdot \log(0.5) = -693147.2$.
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)?
In addition to the mathematical reason that Alecos wrote, let me give you a computational reason. Remember that the likelihood function is nothing but the joint density of random variables (expressed
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)? In addition to the mathematical reason that Alecos wrote, let me give you a computational reason. Remember that the likelihood function is nothing but the joint density of random variables (expressed as a function of the parameters), i.e. $$ Pr(\mathbf{x}) = Pr(x_{1})\cdot Pr(x_{2})\cdot\ldots\cdot Pr(x_{n}) = \prod_{i}^{n} Pr(x_{i}) $$ for i.i.d. data. The probability density $0 \leq Pr(x_{i}) \leq 1$ for all $i$, so this number $Pr(\mathbf{x})$ becomes very small quickly as $n$ increases. Suppose all $Pr(x_{i}) = 0.5$ and $n=1000$, then $$ \prod_{i}^{n} Pr(x_{i}) = 0.5^{1000} = 9.33 \cdot 10^{-302} $$ For only slightly larger datasets, or slightly smaller $Pr(x_{i})$, we are outside the representable range for software packages. For instance, the smallest representable number in R is $2.225074\cdot10^{-308}$. On the flipside, we have $$ \log(Pr(\mathbf{x})) = \sum_{i}^{n} \log \left( Pr(x_{i}) \right) = 1000\cdot \log(0.5) = -693.1472 $$ and even for $n=1000000$ we only have $\log(Pr(\mathbf{x})) = 1000000\cdot \log(0.5) = -693147.2$.
Why we always put log() before the joint pdf when we use MLE(Maximum likelihood Estimation)? In addition to the mathematical reason that Alecos wrote, let me give you a computational reason. Remember that the likelihood function is nothing but the joint density of random variables (expressed
44,303
Can PCA be extended to account for nonlinear dependencies?
There is a technique invented by Trevor Hastie and Werner Stuetzle called principal curves, which is a nonlinear generalisation of principal components. From the abstract for the original paper: Principal curves are smooth one-dimensional curves that pass through the middle of a p-dimensional data set, providing a nonlinear summary of the data. They are nonparametric, and their shape is suggested by the data. The algorithm for constructing principal curves starts with some prior summary, such as the usual principal-component line. The curve in each successive iteration is a smooth or local average of the p-dimensional points, where the definition of local is based on the distance in arc length of the projections of the points onto the curve found in the previous iteration. Some links: http://www.iro.umontreal.ca/~kegl/research/pcurves/ Hastie & Stuetzle's original paper: http://www.stanford.edu/~hastie/Papers/Principal_Curves.pdf A recent paper in the Journal of Machine Learning Research: http://jmlr.org/papers/volume12/ozertem11a/ozertem11a.pdf
Can PCA be extended to account for nonlinear dependencies?
There is a technique invented by Trevor Hastie and Werner Stuetzle called principal curves, which is a nonlinear generalisation of principal components. From the abstract for the original paper: Prin
Can PCA be extended to account for nonlinear dependencies? There is a technique invented by Trevor Hastie and Werner Stuetzle called principal curves, which is a nonlinear generalisation of principal components. From the abstract for the original paper: Principal curves are smooth one-dimensional curves that pass through the middle of a p-dimensional data set, providing a nonlinear summary of the data. They are nonparametric, and their shape is suggested by the data. The algorithm for constructing principal curves starts with some prior summary, such as the usual principal-component line. The curve in each successive iteration is a smooth or local average of the p-dimensional points, where the definition of local is based on the distance in arc length of the projections of the points onto the curve found in the previous iteration. Some links: http://www.iro.umontreal.ca/~kegl/research/pcurves/ Hastie & Stuetzle's original paper: http://www.stanford.edu/~hastie/Papers/Principal_Curves.pdf A recent paper in the Journal of Machine Learning Research: http://jmlr.org/papers/volume12/ozertem11a/ozertem11a.pdf
Can PCA be extended to account for nonlinear dependencies? There is a technique invented by Trevor Hastie and Werner Stuetzle called principal curves, which is a nonlinear generalisation of principal components. From the abstract for the original paper: Prin
44,304
Can PCA be extended to account for nonlinear dependencies?
The nonlinear dependencies you describe are Mercer kernels. A valid kernel is any function taking two observations that is continuous, symmetric and has a positive definite gram matrix. Gram and covariance are interchangeable in this context. The observations needn't be fixed-length vectors. They could be graphs, strings, variable-length time-series or any other object with which you can endow with a distance function. Some common kernels are given here, by the author of a C# Machine Learning library. Any supervised or unsupervised algorithm expecting a design matrix can be kernelized. Linear least-squares can learn the sine function with an appropriate kernel. Kernel PCA is well studied. A popular kernel for nonlinearizing PCA or OLS is the Gaussian Kernel, sometimes called the Radial Basis Function. $X_{ij} = exp({\frac{-||x_i - x_j||^2} {2\sigma^2}}$) The parameter $\sigma$ intuitively controls how fast the importance of that comparison drops off with distance. A revolutionary algorithm for clustering small data sets defined in the paper On Spectral Clustering, is RBF Kernel PCA followed by one of the oldest clustering algorithms called K-Means. One issue with kernels is that their explicit computation can be prohibitive for larger datasets. Indeed one of the best performing nonlinear classifiers, Support Vector Machines, scale with the algorithmic complexity of evaluating the Gram matrix. To get around this a number of sampling techniques have been proposed to reduce your ultimate design matrix from $N \times N$ to $N \times B$, where $N$ is the number of observations and $B$ is a smaller basis s.t. your final covariance matrix $X X^T$ is similar. This is conceptually related to a low-rank approximation that might be performed PCA. Some are kernel specific, while others are general. A simple and effective algorithm is to use Nystroem sampling on the cluster centers of k-means++ as in Improved Nystroem Low-Rank Approximation and Error Analysis
Can PCA be extended to account for nonlinear dependencies?
The nonlinear dependencies you describe are Mercer kernels. A valid kernel is any function taking two observations that is continuous, symmetric and has a positive definite gram matrix. Gram and covar
Can PCA be extended to account for nonlinear dependencies? The nonlinear dependencies you describe are Mercer kernels. A valid kernel is any function taking two observations that is continuous, symmetric and has a positive definite gram matrix. Gram and covariance are interchangeable in this context. The observations needn't be fixed-length vectors. They could be graphs, strings, variable-length time-series or any other object with which you can endow with a distance function. Some common kernels are given here, by the author of a C# Machine Learning library. Any supervised or unsupervised algorithm expecting a design matrix can be kernelized. Linear least-squares can learn the sine function with an appropriate kernel. Kernel PCA is well studied. A popular kernel for nonlinearizing PCA or OLS is the Gaussian Kernel, sometimes called the Radial Basis Function. $X_{ij} = exp({\frac{-||x_i - x_j||^2} {2\sigma^2}}$) The parameter $\sigma$ intuitively controls how fast the importance of that comparison drops off with distance. A revolutionary algorithm for clustering small data sets defined in the paper On Spectral Clustering, is RBF Kernel PCA followed by one of the oldest clustering algorithms called K-Means. One issue with kernels is that their explicit computation can be prohibitive for larger datasets. Indeed one of the best performing nonlinear classifiers, Support Vector Machines, scale with the algorithmic complexity of evaluating the Gram matrix. To get around this a number of sampling techniques have been proposed to reduce your ultimate design matrix from $N \times N$ to $N \times B$, where $N$ is the number of observations and $B$ is a smaller basis s.t. your final covariance matrix $X X^T$ is similar. This is conceptually related to a low-rank approximation that might be performed PCA. Some are kernel specific, while others are general. A simple and effective algorithm is to use Nystroem sampling on the cluster centers of k-means++ as in Improved Nystroem Low-Rank Approximation and Error Analysis
Can PCA be extended to account for nonlinear dependencies? The nonlinear dependencies you describe are Mercer kernels. A valid kernel is any function taking two observations that is continuous, symmetric and has a positive definite gram matrix. Gram and covar
44,305
Can PCA be extended to account for nonlinear dependencies?
Nonlinear principal components are readily obtained using the MGV and MTV methods, implemented in SAS PROC PRINQUAL and the R Hmisc package's transcan function. The basic idea is to expand each continuous variable with regression spline basis functions, and to expand categorical variables into indicator variables. Then canonical variates are used to solve for the optimal transformations. The goal is to have fewer components explain more variation in the system by allowing for nonlinearities. MTV regresses the set of nonlinear terms for the variable currently being transformed against the first principal component of all (transformed) variables in an iterative fashion. MGV regresses each individual expanded variable onto the current transformations of all the other variables, combined using multiple regression. All this is generalized in the R homals package. See the R psychometrics task view for more information: http://cran.r-project.org/web/views/Psychometrics.html
Can PCA be extended to account for nonlinear dependencies?
Nonlinear principal components are readily obtained using the MGV and MTV methods, implemented in SAS PROC PRINQUAL and the R Hmisc package's transcan function. The basic idea is to expand each conti
Can PCA be extended to account for nonlinear dependencies? Nonlinear principal components are readily obtained using the MGV and MTV methods, implemented in SAS PROC PRINQUAL and the R Hmisc package's transcan function. The basic idea is to expand each continuous variable with regression spline basis functions, and to expand categorical variables into indicator variables. Then canonical variates are used to solve for the optimal transformations. The goal is to have fewer components explain more variation in the system by allowing for nonlinearities. MTV regresses the set of nonlinear terms for the variable currently being transformed against the first principal component of all (transformed) variables in an iterative fashion. MGV regresses each individual expanded variable onto the current transformations of all the other variables, combined using multiple regression. All this is generalized in the R homals package. See the R psychometrics task view for more information: http://cran.r-project.org/web/views/Psychometrics.html
Can PCA be extended to account for nonlinear dependencies? Nonlinear principal components are readily obtained using the MGV and MTV methods, implemented in SAS PROC PRINQUAL and the R Hmisc package's transcan function. The basic idea is to expand each conti
44,306
Exception for sum of deviations from mean being 0
When a mean is computed, it's not computed to infinite precision. As a result, the computed sum of deviations around a mean can be a little different from zero. We can see this, for example, in R, like so: x <- rnorm(1000) # generates 1000 standard normal random numbers, puts them in x d <- x - mean(x) # compute the deviations from the mean and put them in d sum(d) # add the deviations [1] 2.026851e-14 Now $2 \times 10^{-14}$ is very small... but it isn't exactly zero. If you want to investigate in detail how finite precision computation is different from algebra, this is a handy resource. If you compute a mean by hand and round your values off to say 3 decimal places, you'll see the same thing - frequently the sum of deviations about the mean is slightly different from zero.
Exception for sum of deviations from mean being 0
When a mean is computed, it's not computed to infinite precision. As a result, the computed sum of deviations around a mean can be a little different from zero. We can see this, for example, in R, lik
Exception for sum of deviations from mean being 0 When a mean is computed, it's not computed to infinite precision. As a result, the computed sum of deviations around a mean can be a little different from zero. We can see this, for example, in R, like so: x <- rnorm(1000) # generates 1000 standard normal random numbers, puts them in x d <- x - mean(x) # compute the deviations from the mean and put them in d sum(d) # add the deviations [1] 2.026851e-14 Now $2 \times 10^{-14}$ is very small... but it isn't exactly zero. If you want to investigate in detail how finite precision computation is different from algebra, this is a handy resource. If you compute a mean by hand and round your values off to say 3 decimal places, you'll see the same thing - frequently the sum of deviations about the mean is slightly different from zero.
Exception for sum of deviations from mean being 0 When a mean is computed, it's not computed to infinite precision. As a result, the computed sum of deviations around a mean can be a little different from zero. We can see this, for example, in R, lik
44,307
Exception for sum of deviations from mean being 0
I want to add something to the previous answer, with which I completely agree. It happens that I am working on implementing a statistical library in Java and I use as a reference point the computed values from R. A few days ago I studied algorithms for implementing mean and variance. And what I found is that the C code which computes the mean in R (mean in R calls an internal function which is written in C) uses a simple technique to compensate for loss caused by rounding. And there I found exactly what you searched for. I will show a simplified code, since the original C code uses macros and unnecessary complicated stuff: function mean(double[] x) { double s = 0.; double n = length(x); for (int i = 0; i < n; i++) s += x[i]; s /= n; double t = 0; for (int i = 0; i < n; i++) t += x[i] - s; s += t / n; return s; } In the previous code the variable t contains the sum of deviations about the mean. If that statement is interpreted strictly from a mathematical point of view, it should be 0. But when it comes to computation the same statement should be redefined as "t contains the sum of deviations of the computed mean with finite precision". The idea of the compensation is very intuitive when working on large values with small variation. In that case s might lose precision (by losing the last bits from the floating point representation) and computing t gives a better chance of not doing so since the values of x[i] and the computed s are comparable.
Exception for sum of deviations from mean being 0
I want to add something to the previous answer, with which I completely agree. It happens that I am working on implementing a statistical library in Java and I use as a reference point the computed va
Exception for sum of deviations from mean being 0 I want to add something to the previous answer, with which I completely agree. It happens that I am working on implementing a statistical library in Java and I use as a reference point the computed values from R. A few days ago I studied algorithms for implementing mean and variance. And what I found is that the C code which computes the mean in R (mean in R calls an internal function which is written in C) uses a simple technique to compensate for loss caused by rounding. And there I found exactly what you searched for. I will show a simplified code, since the original C code uses macros and unnecessary complicated stuff: function mean(double[] x) { double s = 0.; double n = length(x); for (int i = 0; i < n; i++) s += x[i]; s /= n; double t = 0; for (int i = 0; i < n; i++) t += x[i] - s; s += t / n; return s; } In the previous code the variable t contains the sum of deviations about the mean. If that statement is interpreted strictly from a mathematical point of view, it should be 0. But when it comes to computation the same statement should be redefined as "t contains the sum of deviations of the computed mean with finite precision". The idea of the compensation is very intuitive when working on large values with small variation. In that case s might lose precision (by losing the last bits from the floating point representation) and computing t gives a better chance of not doing so since the values of x[i] and the computed s are comparable.
Exception for sum of deviations from mean being 0 I want to add something to the previous answer, with which I completely agree. It happens that I am working on implementing a statistical library in Java and I use as a reference point the computed va
44,308
Why are the residuals in this model so linearly skewed?
You shouldn't plot the residuals against the predicator values because they are correlated, instead we plot against the fitted values, i.e. $\hat Y$. To see this, consider this simple data set: x = runif(20) y = rnorm(20) Clearly $x$ and $y$ are unrelated. Now, we fitted a simple linear regression model m = lm(y ~ x) and plot the residuals against outcome and fitted values plot(y, residuals(m)) plot(fitted.values(m), residuals(m)) to get: Notice the plotting against the outcome $y$, doesn't give any insight. Hence, it's not really clear if there is something wrong with your model since we don't expect random scatter.
Why are the residuals in this model so linearly skewed?
You shouldn't plot the residuals against the predicator values because they are correlated, instead we plot against the fitted values, i.e. $\hat Y$. To see this, consider this simple data set: x = ru
Why are the residuals in this model so linearly skewed? You shouldn't plot the residuals against the predicator values because they are correlated, instead we plot against the fitted values, i.e. $\hat Y$. To see this, consider this simple data set: x = runif(20) y = rnorm(20) Clearly $x$ and $y$ are unrelated. Now, we fitted a simple linear regression model m = lm(y ~ x) and plot the residuals against outcome and fitted values plot(y, residuals(m)) plot(fitted.values(m), residuals(m)) to get: Notice the plotting against the outcome $y$, doesn't give any insight. Hence, it's not really clear if there is something wrong with your model since we don't expect random scatter.
Why are the residuals in this model so linearly skewed? You shouldn't plot the residuals against the predicator values because they are correlated, instead we plot against the fitted values, i.e. $\hat Y$. To see this, consider this simple data set: x = ru
44,309
Why are the residuals in this model so linearly skewed?
What you are seeing is called "Regression towards the Mean" and is completely expected. Any time that there is variability in the data (and yours looks like it has a bunch) then the prediction values will on average be between the overall mean and the observed values. The plot you created, of the outcome vs the predicted values is not commonly done, for the reasons that you are seeing, it tends to confuse more than enlighten. It is more common to plot the predicted values against the residuals as this plot will show more randomness if the model is reasonable. Edit to address comment below csgillespie's example has been criticized for only including 1 predictor when the original question included 4. Here is some quick R code that can be run to show the same patterns with 4 predictors: # simulated data, no relationship df1 <- data.frame(y=rnorm(100), x1=rnorm(100), x2=rnorm(100), x3=rnorm(100), x4=rnorm(100)) fit1 <- lm( y ~ ., data=df1 ) #plot(df1$y, fitted(fit1), asp=1) scatter.smooth(df1$y, fitted(fit1), asp=1) abline(0,1) abline(h=mean(fitted(fit1)), col='lightgrey') plot(df1$y, resid(fit1)) abline(h=0) plot(fitted(fit1), resid(fit1)) abline(h=0) # simulated data, relationship library(MASS) df2 <- as.data.frame( mvrnorm(100, mu=1:5, Sigma= matrix(.7,5,5)+diag(rep(.3,5)))) names(df2) <- c('y','x1','x2','x3','x4') fit2 <- lm( y ~ ., data=df2 ) #plot(df2$y, fitted(fit2), asp=1) scatter.smooth(df2$y, fitted(fit2), asp=1) abline(0,1) abline(h=mean(fitted(fit2)), col='lightgrey') plot(df2$y, resid(fit2)) abline(h=0) plot(fitted(fit2), resid(fit2)) abline(h=0) # real data fit3 <- lm( Murder~Population+Income+Illiteracy+Frost, data=as.data.frame(state.x77)) scatter.smooth( state.x77[,'Murder'], fitted(fit3), asp=1) abline(0,1) abline(h=mean(fitted(fit3)), col='lightgrey') plot(state.x77[,'Murder'], resid(fit3)) abline(h=0) plot(fitted(fit3), resid(fit3)) abline(h=0) Notice that the plots look very similar to those in the original question. Notice also that in the plot of the original outcome vs. the fitted values that the points (and more so their trend) tend to fall between the $y=x$ line and the mean line. This is the idea of regression towards the mean as originally described by Galton See Here. The points are not randomly scattered about the $y=x$ line like the original poster assumed and what would happen without the regression towards the mean, rather they follow a linear trend along a line that represents proportianality between the $y=x$ line and the overall mean line, just as predicted by Galton. The term regression towards the mean (and variants) is sometimes used for other concepts (some closer related to the original than others) as can be seen in the above article, and that may be where some of the confusion comes from.
Why are the residuals in this model so linearly skewed?
What you are seeing is called "Regression towards the Mean" and is completely expected. Any time that there is variability in the data (and yours looks like it has a bunch) then the prediction values
Why are the residuals in this model so linearly skewed? What you are seeing is called "Regression towards the Mean" and is completely expected. Any time that there is variability in the data (and yours looks like it has a bunch) then the prediction values will on average be between the overall mean and the observed values. The plot you created, of the outcome vs the predicted values is not commonly done, for the reasons that you are seeing, it tends to confuse more than enlighten. It is more common to plot the predicted values against the residuals as this plot will show more randomness if the model is reasonable. Edit to address comment below csgillespie's example has been criticized for only including 1 predictor when the original question included 4. Here is some quick R code that can be run to show the same patterns with 4 predictors: # simulated data, no relationship df1 <- data.frame(y=rnorm(100), x1=rnorm(100), x2=rnorm(100), x3=rnorm(100), x4=rnorm(100)) fit1 <- lm( y ~ ., data=df1 ) #plot(df1$y, fitted(fit1), asp=1) scatter.smooth(df1$y, fitted(fit1), asp=1) abline(0,1) abline(h=mean(fitted(fit1)), col='lightgrey') plot(df1$y, resid(fit1)) abline(h=0) plot(fitted(fit1), resid(fit1)) abline(h=0) # simulated data, relationship library(MASS) df2 <- as.data.frame( mvrnorm(100, mu=1:5, Sigma= matrix(.7,5,5)+diag(rep(.3,5)))) names(df2) <- c('y','x1','x2','x3','x4') fit2 <- lm( y ~ ., data=df2 ) #plot(df2$y, fitted(fit2), asp=1) scatter.smooth(df2$y, fitted(fit2), asp=1) abline(0,1) abline(h=mean(fitted(fit2)), col='lightgrey') plot(df2$y, resid(fit2)) abline(h=0) plot(fitted(fit2), resid(fit2)) abline(h=0) # real data fit3 <- lm( Murder~Population+Income+Illiteracy+Frost, data=as.data.frame(state.x77)) scatter.smooth( state.x77[,'Murder'], fitted(fit3), asp=1) abline(0,1) abline(h=mean(fitted(fit3)), col='lightgrey') plot(state.x77[,'Murder'], resid(fit3)) abline(h=0) plot(fitted(fit3), resid(fit3)) abline(h=0) Notice that the plots look very similar to those in the original question. Notice also that in the plot of the original outcome vs. the fitted values that the points (and more so their trend) tend to fall between the $y=x$ line and the mean line. This is the idea of regression towards the mean as originally described by Galton See Here. The points are not randomly scattered about the $y=x$ line like the original poster assumed and what would happen without the regression towards the mean, rather they follow a linear trend along a line that represents proportianality between the $y=x$ line and the overall mean line, just as predicted by Galton. The term regression towards the mean (and variants) is sometimes used for other concepts (some closer related to the original than others) as can be seen in the above article, and that may be where some of the confusion comes from.
Why are the residuals in this model so linearly skewed? What you are seeing is called "Regression towards the Mean" and is completely expected. Any time that there is variability in the data (and yours looks like it has a bunch) then the prediction values
44,310
Resources or methods for determining if a technique is in current use?
There's no shortcut for experience, but one way to get a hint is to look up the method's original references on google scholar and see the number of citations.
Resources or methods for determining if a technique is in current use?
There's no shortcut for experience, but one way to get a hint is to look up the method's original references on google scholar and see the number of citations.
Resources or methods for determining if a technique is in current use? There's no shortcut for experience, but one way to get a hint is to look up the method's original references on google scholar and see the number of citations.
Resources or methods for determining if a technique is in current use? There's no shortcut for experience, but one way to get a hint is to look up the method's original references on google scholar and see the number of citations.
44,311
Resources or methods for determining if a technique is in current use?
Many techniques are not so popular, however they may be useful for specific research purposes. If a statistical methodology is supported by Monte Carlo simulations, and if it was published on prestigious journals, so I think you can take it in consideration, even though it was little used by researchers. For example, I recently used the non-parametric ANCOVA developed by Conover and Iman, but to my knowledge it is not so popular in my research field. In my opinion, it is more important to have solid foundations about why you used a specific technique (robustness related to your data, Monte Carlo simulations...) in order to adequately answer possible referees concerns.
Resources or methods for determining if a technique is in current use?
Many techniques are not so popular, however they may be useful for specific research purposes. If a statistical methodology is supported by Monte Carlo simulations, and if it was published on prestigi
Resources or methods for determining if a technique is in current use? Many techniques are not so popular, however they may be useful for specific research purposes. If a statistical methodology is supported by Monte Carlo simulations, and if it was published on prestigious journals, so I think you can take it in consideration, even though it was little used by researchers. For example, I recently used the non-parametric ANCOVA developed by Conover and Iman, but to my knowledge it is not so popular in my research field. In my opinion, it is more important to have solid foundations about why you used a specific technique (robustness related to your data, Monte Carlo simulations...) in order to adequately answer possible referees concerns.
Resources or methods for determining if a technique is in current use? Many techniques are not so popular, however they may be useful for specific research purposes. If a statistical methodology is supported by Monte Carlo simulations, and if it was published on prestigi
44,312
Resources or methods for determining if a technique is in current use?
I agree with use4733. My planned answer was to be "ask the experts". Regarding this particular technique I personally can't say much because I hadn't heard of it before even though I have some expertise in time series analysis. However, since the references seem to all be over the most recent three years it could just be that it is a very new method. New methods in almost any field take time to catch on. So I don't think that you should assume that it is not useful. It may eventually prove to be useful.
Resources or methods for determining if a technique is in current use?
I agree with use4733. My planned answer was to be "ask the experts". Regarding this particular technique I personally can't say much because I hadn't heard of it before even though I have some exper
Resources or methods for determining if a technique is in current use? I agree with use4733. My planned answer was to be "ask the experts". Regarding this particular technique I personally can't say much because I hadn't heard of it before even though I have some expertise in time series analysis. However, since the references seem to all be over the most recent three years it could just be that it is a very new method. New methods in almost any field take time to catch on. So I don't think that you should assume that it is not useful. It may eventually prove to be useful.
Resources or methods for determining if a technique is in current use? I agree with use4733. My planned answer was to be "ask the experts". Regarding this particular technique I personally can't say much because I hadn't heard of it before even though I have some exper
44,313
Is there a software package designed to automatically check the assumptions of various statistical tests?
I think you should look at applied statistics texts. An easy one to read the is one of my favorites was written by the late Rupert Miller (I took the applied statistics sequence that he taught when I was a graduate student at Stanford). At that time we had notes. His book was not finished but it is a marvel. He was a great teacher and writer. The book was published by Wiley and is titled Beyond ANOVA, Basics of Applied Statistics (on Amazon). It was originally published by Wiley but apparently is reprinted currently by Chapman & Hall/CRC. This goes through all the assumptions needed for parametric ANOVA and the methods to check them.
Is there a software package designed to automatically check the assumptions of various statistical t
I think you should look at applied statistics texts. An easy one to read the is one of my favorites was written by the late Rupert Miller (I took the applied statistics sequence that he taught when I
Is there a software package designed to automatically check the assumptions of various statistical tests? I think you should look at applied statistics texts. An easy one to read the is one of my favorites was written by the late Rupert Miller (I took the applied statistics sequence that he taught when I was a graduate student at Stanford). At that time we had notes. His book was not finished but it is a marvel. He was a great teacher and writer. The book was published by Wiley and is titled Beyond ANOVA, Basics of Applied Statistics (on Amazon). It was originally published by Wiley but apparently is reprinted currently by Chapman & Hall/CRC. This goes through all the assumptions needed for parametric ANOVA and the methods to check them.
Is there a software package designed to automatically check the assumptions of various statistical t I think you should look at applied statistics texts. An easy one to read the is one of my favorites was written by the late Rupert Miller (I took the applied statistics sequence that he taught when I
44,314
Is there a software package designed to automatically check the assumptions of various statistical tests?
The information needed to decide if the assumptions about a statistical test are reasonable are often exterior to the data itself. This means that an automated program would not have the information needed. For example it is usually assumed that the data was collected independently (or conditionally independently), but looking at the data how can you tell the difference between a simple random sample (usually fine for many stats tests) and a snowball sample (not good for most quantitative tests)? Since a simple random sample has every possible sample equally likely then any non independent sample could have also resulted from a simple random sample. You need to know how the data was collected, not just the data itself. Also note that if you do a normality test in order to decide which test to use then you are generally either getting a meaningless answer to a meaningful question (small sample size) or a meaningful answer to a meaningless question (large sample size). I expect that many of the other tests for assumptions (without outside knowledge) will have similar problems. If you "test" for every assumption that could affect the results of your test (without outside knowledge suggesting which might be the most meaningful) then you are likely to either always reject at least one assumption (if you don't correct for multiple comparisons) or you will have so little power to detect assumption violations (when you do correct for multiple comparisons) that the results will be little better than generating a p-value from a uniform distribution. Knowledge of the science that lead to the data is needed to assess which assumptions to further investigate (and plots are probably as useful as formal tests). Also note that the non-parametric tests mentioned above and the normal based tests above are testing different null hypotheses. If the results don't agree it could be that both are giving correct (or at least approximately, with a good approximation, correct) answers to different questions.
Is there a software package designed to automatically check the assumptions of various statistical t
The information needed to decide if the assumptions about a statistical test are reasonable are often exterior to the data itself. This means that an automated program would not have the information
Is there a software package designed to automatically check the assumptions of various statistical tests? The information needed to decide if the assumptions about a statistical test are reasonable are often exterior to the data itself. This means that an automated program would not have the information needed. For example it is usually assumed that the data was collected independently (or conditionally independently), but looking at the data how can you tell the difference between a simple random sample (usually fine for many stats tests) and a snowball sample (not good for most quantitative tests)? Since a simple random sample has every possible sample equally likely then any non independent sample could have also resulted from a simple random sample. You need to know how the data was collected, not just the data itself. Also note that if you do a normality test in order to decide which test to use then you are generally either getting a meaningless answer to a meaningful question (small sample size) or a meaningful answer to a meaningless question (large sample size). I expect that many of the other tests for assumptions (without outside knowledge) will have similar problems. If you "test" for every assumption that could affect the results of your test (without outside knowledge suggesting which might be the most meaningful) then you are likely to either always reject at least one assumption (if you don't correct for multiple comparisons) or you will have so little power to detect assumption violations (when you do correct for multiple comparisons) that the results will be little better than generating a p-value from a uniform distribution. Knowledge of the science that lead to the data is needed to assess which assumptions to further investigate (and plots are probably as useful as formal tests). Also note that the non-parametric tests mentioned above and the normal based tests above are testing different null hypotheses. If the results don't agree it could be that both are giving correct (or at least approximately, with a good approximation, correct) answers to different questions.
Is there a software package designed to automatically check the assumptions of various statistical t The information needed to decide if the assumptions about a statistical test are reasonable are often exterior to the data itself. This means that an automated program would not have the information
44,315
Is there a software package designed to automatically check the assumptions of various statistical tests?
This is old but your library may have it: "A guide for selecting statistical techniques for analyzing social science data" 2nd ed 1981; institute for social research,university of michigan Andrews, FM; Klem, L; Davidson, TN; O'Malley, PM; rodgers, WL Laurence
Is there a software package designed to automatically check the assumptions of various statistical t
This is old but your library may have it: "A guide for selecting statistical techniques for analyzing social science data" 2nd ed 1981; institute for social research,university of michigan Andrews, FM
Is there a software package designed to automatically check the assumptions of various statistical tests? This is old but your library may have it: "A guide for selecting statistical techniques for analyzing social science data" 2nd ed 1981; institute for social research,university of michigan Andrews, FM; Klem, L; Davidson, TN; O'Malley, PM; rodgers, WL Laurence
Is there a software package designed to automatically check the assumptions of various statistical t This is old but your library may have it: "A guide for selecting statistical techniques for analyzing social science data" 2nd ed 1981; institute for social research,university of michigan Andrews, FM
44,316
How to select best parameter for polynomial kernel?
Grid search is a sensible procedure as @JohnSmith suggests, however it is not the only stable technique. I generally use the Nelder-Mead simplex algortihm, which I have found to be very reliable and more efficient than grid search as less time is spent investigating areas of hyper-parameter space that give poor models. If you are a MATLAB user, you can get my implementation of this method here. Nelder Mead simplex methods are attractive as they don't require gradient information (I suppose you can think of the gradient of the simplex as being an approximation of the local gradient) and is very easily implemented. Also gradient descent optimisation of the span bound is a good way of optimising the hyper-parameters, see Chapelle et al. (also investigate the other papers that Olivier has written, there are some real gems). One advantage of grid search however is that it is quite easy to over-fit the cross-validation error (or span bound etc.) when optimising the hyper-parameters, especially if there is little data and many hyper-parameters. This means you can get a very poor classifier if you tune the hyper-parameters to convergence, so a coarse grid search can often perform better (I have a paper in preparation on this).
How to select best parameter for polynomial kernel?
Grid search is a sensible procedure as @JohnSmith suggests, however it is not the only stable technique. I generally use the Nelder-Mead simplex algortihm, which I have found to be very reliable and
How to select best parameter for polynomial kernel? Grid search is a sensible procedure as @JohnSmith suggests, however it is not the only stable technique. I generally use the Nelder-Mead simplex algortihm, which I have found to be very reliable and more efficient than grid search as less time is spent investigating areas of hyper-parameter space that give poor models. If you are a MATLAB user, you can get my implementation of this method here. Nelder Mead simplex methods are attractive as they don't require gradient information (I suppose you can think of the gradient of the simplex as being an approximation of the local gradient) and is very easily implemented. Also gradient descent optimisation of the span bound is a good way of optimising the hyper-parameters, see Chapelle et al. (also investigate the other papers that Olivier has written, there are some real gems). One advantage of grid search however is that it is quite easy to over-fit the cross-validation error (or span bound etc.) when optimising the hyper-parameters, especially if there is little data and many hyper-parameters. This means you can get a very poor classifier if you tune the hyper-parameters to convergence, so a coarse grid search can often perform better (I have a paper in preparation on this).
How to select best parameter for polynomial kernel? Grid search is a sensible procedure as @JohnSmith suggests, however it is not the only stable technique. I generally use the Nelder-Mead simplex algortihm, which I have found to be very reliable and
44,317
How to select best parameter for polynomial kernel?
Why don't you want to use grid search? It seems to me the only stable technique for SVM parameter estimation. Of course you can use adaptive search, but it can save you not so much time, but lead you to some strange results. And the implementation for CV procedure is pretty standart: Divide your dataset into two parts: $X_{train}$ and $X_{test}$. Run cycle through the parameter $d$ { Run cycle through $C$ { Train SVM with $X_{train}$, $d$ and $C$; Test on $X_{test}$; Remember the parameters, leading to the best result; } }
How to select best parameter for polynomial kernel?
Why don't you want to use grid search? It seems to me the only stable technique for SVM parameter estimation. Of course you can use adaptive search, but it can save you not so much time, but lead you
How to select best parameter for polynomial kernel? Why don't you want to use grid search? It seems to me the only stable technique for SVM parameter estimation. Of course you can use adaptive search, but it can save you not so much time, but lead you to some strange results. And the implementation for CV procedure is pretty standart: Divide your dataset into two parts: $X_{train}$ and $X_{test}$. Run cycle through the parameter $d$ { Run cycle through $C$ { Train SVM with $X_{train}$, $d$ and $C$; Test on $X_{test}$; Remember the parameters, leading to the best result; } }
How to select best parameter for polynomial kernel? Why don't you want to use grid search? It seems to me the only stable technique for SVM parameter estimation. Of course you can use adaptive search, but it can save you not so much time, but lead you
44,318
How to select best parameter for polynomial kernel?
You can try using a random search algorithm to get near equivalent results as grid search with a lot less work depending on the granularity of your grid. You can read more about it at Dato Blog along with other hyperparameter tuning techniques. This method is relatively quick if you set it up to run in parallel.
How to select best parameter for polynomial kernel?
You can try using a random search algorithm to get near equivalent results as grid search with a lot less work depending on the granularity of your grid. You can read more about it at Dato Blog along
How to select best parameter for polynomial kernel? You can try using a random search algorithm to get near equivalent results as grid search with a lot less work depending on the granularity of your grid. You can read more about it at Dato Blog along with other hyperparameter tuning techniques. This method is relatively quick if you set it up to run in parallel.
How to select best parameter for polynomial kernel? You can try using a random search algorithm to get near equivalent results as grid search with a lot less work depending on the granularity of your grid. You can read more about it at Dato Blog along
44,319
how to add second order terms into the model in R?
The formula documentation for R shows how to do this. In short, you use poly(). For example, make some quadratic data: x <- rnorm(100) y <- x + x**2 * 0.5 + rnorm(100) Now fit this using a second order polynomial (i.e x and x**2) like this mod <- lm(y ~ poly(x, 2)) Note that this will fit an orthogonal polynomial, so it won't recover 1 and 0.5 as the coefficients in the generating distribution. If for some reason you want that, use poly(x, 2, raw=TRUE). In general you don't for stability reasons, so stick with the cooked version. There is also polym as in: lm(y ~ polym(x, z, degree=2) for a model with a full set of crossed variables, which is a bit more trouble to interpret, but that's presumably not important with hundreds of variables.
how to add second order terms into the model in R?
The formula documentation for R shows how to do this. In short, you use poly(). For example, make some quadratic data: x <- rnorm(100) y <- x + x**2 * 0.5 + rnorm(100) Now fit this using a second
how to add second order terms into the model in R? The formula documentation for R shows how to do this. In short, you use poly(). For example, make some quadratic data: x <- rnorm(100) y <- x + x**2 * 0.5 + rnorm(100) Now fit this using a second order polynomial (i.e x and x**2) like this mod <- lm(y ~ poly(x, 2)) Note that this will fit an orthogonal polynomial, so it won't recover 1 and 0.5 as the coefficients in the generating distribution. If for some reason you want that, use poly(x, 2, raw=TRUE). In general you don't for stability reasons, so stick with the cooked version. There is also polym as in: lm(y ~ polym(x, z, degree=2) for a model with a full set of crossed variables, which is a bit more trouble to interpret, but that's presumably not important with hundreds of variables.
how to add second order terms into the model in R? The formula documentation for R shows how to do this. In short, you use poly(). For example, make some quadratic data: x <- rnorm(100) y <- x + x**2 * 0.5 + rnorm(100) Now fit this using a second
44,320
how to add second order terms into the model in R?
Type : lm(y ~ x1 + x2 + I(x1*x2) + I(x1^2) + ...)
how to add second order terms into the model in R?
Type : lm(y ~ x1 + x2 + I(x1*x2) + I(x1^2) + ...)
how to add second order terms into the model in R? Type : lm(y ~ x1 + x2 + I(x1*x2) + I(x1^2) + ...)
how to add second order terms into the model in R? Type : lm(y ~ x1 + x2 + I(x1*x2) + I(x1^2) + ...)
44,321
how to add second order terms into the model in R?
Here's how to do it in principle, illustrated on a smaller dataset with only 10 predictors: # Make fake data mydata = as.data.frame(matrix(rnorm(1100), 100)) names(mydata) = c(paste0("x", 1:10), "y") # Form a matrix containing all predictor columns but not y x = as.matrix(mydata[, 1:10]) # Use poly() to form all 2-way interactions and 2nd order terms x2 = poly(x, degree = 2, raw = TRUE) # Resave as a data frame including y mydata2 = as.data.frame(cbind(x2, y = mydata$y)) # Fit the complete linear model lm2 = lm(y ~ ., data = mydata2) However, you have 100 predictors. In my experience, with more than 10-15 predictors, R usually cannot allocate enough memory for the matrix containing every 2-way interaction. You will get unhelpful errors or R will simply crash. If so, consider whether you really need all 2-way interactions. Maybe just a subset would make sense. For instance, you could use poly() as above to form all 2-way interactions within one subset of x's, then again to form interactions between another subset of x's, but not have any interactions across those subsets.
how to add second order terms into the model in R?
Here's how to do it in principle, illustrated on a smaller dataset with only 10 predictors: # Make fake data mydata = as.data.frame(matrix(rnorm(1100), 100)) names(mydata) = c(paste0("x", 1:10), "y")
how to add second order terms into the model in R? Here's how to do it in principle, illustrated on a smaller dataset with only 10 predictors: # Make fake data mydata = as.data.frame(matrix(rnorm(1100), 100)) names(mydata) = c(paste0("x", 1:10), "y") # Form a matrix containing all predictor columns but not y x = as.matrix(mydata[, 1:10]) # Use poly() to form all 2-way interactions and 2nd order terms x2 = poly(x, degree = 2, raw = TRUE) # Resave as a data frame including y mydata2 = as.data.frame(cbind(x2, y = mydata$y)) # Fit the complete linear model lm2 = lm(y ~ ., data = mydata2) However, you have 100 predictors. In my experience, with more than 10-15 predictors, R usually cannot allocate enough memory for the matrix containing every 2-way interaction. You will get unhelpful errors or R will simply crash. If so, consider whether you really need all 2-way interactions. Maybe just a subset would make sense. For instance, you could use poly() as above to form all 2-way interactions within one subset of x's, then again to form interactions between another subset of x's, but not have any interactions across those subsets.
how to add second order terms into the model in R? Here's how to do it in principle, illustrated on a smaller dataset with only 10 predictors: # Make fake data mydata = as.data.frame(matrix(rnorm(1100), 100)) names(mydata) = c(paste0("x", 1:10), "y")
44,322
Kendall's tau and independence
I am going to interpret your question as one regarding a hypothesis on the population quantity $\tau$. If this is not what you intended, please comment to that effect and I will revise the answer accordingly. Definition and equivalent expressions Let $(X,Y)$ by a bivariate random vector with a continuous joint distribution function and let $(X',Y')$ be an independent copy. Kendall's tau is defined as $$ \renewcommand{\Pr}{\mathbb P} \tau = \Pr( (X-X')(Y-Y') > 0 ) - \Pr( (X-X')(Y-Y') < 0) \>. $$ Here are some equivalent definitions under the stated hypotheses that help elucidate this quantity. $\newcommand{\sgn}{\mathrm{sgn}}\tau = \Pr( \sgn(X-X') = \sgn(Y-Y') ) - \Pr( \sgn(X-X')) \neq \sgn(Y-Y'))$. $\tau = \mathbb E \sgn(X-X')\sgn(Y-Y') = \mathrm{Cov}(\sgn(X-X'),\sgn(Y-Y'))$. $\tau = 4 \Pr(X<X',Y<Y') - 1$. Note that $X-X'$ and $Y-Y'$ are symmetric about zero. From this and either (1) or (3), it is clear that if $X$ and $Y$ are independent then $\tau = 0$. The question at hand, as I understand it, is to characterize the reverse implication. A first characterization Using (3) above, we have that $\tau = 0$ implies that $$ \Pr(X-X' < 0, Y-Y' < 0) = \Pr(X-X'<0)\Pr(Y-Y'<0) = 1/4 \>. $$ By symmetry, this implies that the probability in each of the four quadrants of the distribution of $(X-X',Y-Y')$ is 1/4. We can give the following interpretation: $\tau = 0$ if and only if the event that $X-X'$ is positive or negative is independent of the event that $Y-Y'$ is positive or negative. This is, at least on the surface, much weaker than what (full) independence of the random variables $X-X'$ and $Y-Y'$ would require, which is that, for each $(a,b) \in \mathbb R^2$, $$ \Pr(X-X'<a,Y-Y'<b) = \Pr(X-X'<a)\Pr(Y-Y'<b) \>. $$ A useful reduction by sufficiency Since $X$ is assumed to have continuous distribution $F$, say, and $Y$ has continuous distribution $G$, say, then we can restate each of the above in terms of $U = F(X)$ and $V = G(Y)$. For example, (3) above becomes $$ \tau = 4 \Pr(X < X', Y < Y' ) - 1 = 4 \Pr( F(X) < F(X'), G(Y) < G(Y') ) - 1 \>, $$ which by substitution gives $$ \tau = 4 \Pr( U < U', V < V' ) - 1 \>. $$ Note that $U$ and $V$ are both (marginally) $\mathcal U(0,1)$ random variables. Thus, without loss of generality we can consider bivariate distributions on the unit cube with uniform marginals. Such a distribution, usually denoted $C(u,v)$ in the bivariate case, is called a copula. This also shows why Kendall's tau is invariant to monotone transformations. A (partially) explicit answer in terms of copulas Let $(U,V)$ have distribution function $C(u,v)$ with uniform marginals. The reformulation of (3) can be written in terms of $C$ as $$ \tau = 4 \Pr(U<U',V<V')-1 = 4 \mathbb E C(U,V) - 1 \>, $$ which provides us with a fairly explicit answer: Lemma: For $(X,Y)$ with continuous marginals, $\tau = 0$ if and only if $\mathbb E C(U,V) = 1/4$ where $(U,V) = (F(X),G(Y))$ and $C$ is the distribution function of $(U,V)$. Relation to independence and a counterexample If $X$ and $Y$ are independent, so are $U = F(X)$ and $V = G(Y)$, in which case $C(u,v) = uv$. Clearly $\mathbb E C(U,V) = \iint_{[0,1]^2} u v \,\mathrm du \,\mathrm dv = 1/4$. But do other examples exist? Counterexample: Consider the family of copulas $$ C(u,v) = uv + \alpha u(u-1)(2u-1)v(v-1)(2v-1) $$ indexed by the parameter $-1 \leq \alpha \leq 2$. For every value of $\alpha \in [-1,2]$, we have $\tau = 0$. Note that the subcase of independence corresponds to $\alpha = 0$.
Kendall's tau and independence
I am going to interpret your question as one regarding a hypothesis on the population quantity $\tau$. If this is not what you intended, please comment to that effect and I will revise the answer acc
Kendall's tau and independence I am going to interpret your question as one regarding a hypothesis on the population quantity $\tau$. If this is not what you intended, please comment to that effect and I will revise the answer accordingly. Definition and equivalent expressions Let $(X,Y)$ by a bivariate random vector with a continuous joint distribution function and let $(X',Y')$ be an independent copy. Kendall's tau is defined as $$ \renewcommand{\Pr}{\mathbb P} \tau = \Pr( (X-X')(Y-Y') > 0 ) - \Pr( (X-X')(Y-Y') < 0) \>. $$ Here are some equivalent definitions under the stated hypotheses that help elucidate this quantity. $\newcommand{\sgn}{\mathrm{sgn}}\tau = \Pr( \sgn(X-X') = \sgn(Y-Y') ) - \Pr( \sgn(X-X')) \neq \sgn(Y-Y'))$. $\tau = \mathbb E \sgn(X-X')\sgn(Y-Y') = \mathrm{Cov}(\sgn(X-X'),\sgn(Y-Y'))$. $\tau = 4 \Pr(X<X',Y<Y') - 1$. Note that $X-X'$ and $Y-Y'$ are symmetric about zero. From this and either (1) or (3), it is clear that if $X$ and $Y$ are independent then $\tau = 0$. The question at hand, as I understand it, is to characterize the reverse implication. A first characterization Using (3) above, we have that $\tau = 0$ implies that $$ \Pr(X-X' < 0, Y-Y' < 0) = \Pr(X-X'<0)\Pr(Y-Y'<0) = 1/4 \>. $$ By symmetry, this implies that the probability in each of the four quadrants of the distribution of $(X-X',Y-Y')$ is 1/4. We can give the following interpretation: $\tau = 0$ if and only if the event that $X-X'$ is positive or negative is independent of the event that $Y-Y'$ is positive or negative. This is, at least on the surface, much weaker than what (full) independence of the random variables $X-X'$ and $Y-Y'$ would require, which is that, for each $(a,b) \in \mathbb R^2$, $$ \Pr(X-X'<a,Y-Y'<b) = \Pr(X-X'<a)\Pr(Y-Y'<b) \>. $$ A useful reduction by sufficiency Since $X$ is assumed to have continuous distribution $F$, say, and $Y$ has continuous distribution $G$, say, then we can restate each of the above in terms of $U = F(X)$ and $V = G(Y)$. For example, (3) above becomes $$ \tau = 4 \Pr(X < X', Y < Y' ) - 1 = 4 \Pr( F(X) < F(X'), G(Y) < G(Y') ) - 1 \>, $$ which by substitution gives $$ \tau = 4 \Pr( U < U', V < V' ) - 1 \>. $$ Note that $U$ and $V$ are both (marginally) $\mathcal U(0,1)$ random variables. Thus, without loss of generality we can consider bivariate distributions on the unit cube with uniform marginals. Such a distribution, usually denoted $C(u,v)$ in the bivariate case, is called a copula. This also shows why Kendall's tau is invariant to monotone transformations. A (partially) explicit answer in terms of copulas Let $(U,V)$ have distribution function $C(u,v)$ with uniform marginals. The reformulation of (3) can be written in terms of $C$ as $$ \tau = 4 \Pr(U<U',V<V')-1 = 4 \mathbb E C(U,V) - 1 \>, $$ which provides us with a fairly explicit answer: Lemma: For $(X,Y)$ with continuous marginals, $\tau = 0$ if and only if $\mathbb E C(U,V) = 1/4$ where $(U,V) = (F(X),G(Y))$ and $C$ is the distribution function of $(U,V)$. Relation to independence and a counterexample If $X$ and $Y$ are independent, so are $U = F(X)$ and $V = G(Y)$, in which case $C(u,v) = uv$. Clearly $\mathbb E C(U,V) = \iint_{[0,1]^2} u v \,\mathrm du \,\mathrm dv = 1/4$. But do other examples exist? Counterexample: Consider the family of copulas $$ C(u,v) = uv + \alpha u(u-1)(2u-1)v(v-1)(2v-1) $$ indexed by the parameter $-1 \leq \alpha \leq 2$. For every value of $\alpha \in [-1,2]$, we have $\tau = 0$. Note that the subcase of independence corresponds to $\alpha = 0$.
Kendall's tau and independence I am going to interpret your question as one regarding a hypothesis on the population quantity $\tau$. If this is not what you intended, please comment to that effect and I will revise the answer acc
44,323
Calculating proportions by age in R
Your approach seems way too complicated to me. Let's start with some data: ## make up some data status <- factor(rbinom(1000, 1, 0.3), labels = c("single", "married")) age <- sample(20:50, 1000, replace = TRUE) df <- data.frame(status, age) head(df) Print the first six cases: > head(df) status age 1 married 21 2 single 50 3 single 43 4 single 28 5 married 28 6 single 40 Next, we need to calculate row wise percentages; even if I doubt that this makes sense (it refers to your statement: "What i need to do is to count number of people that were never married at each age and divide it by the total number of never married people to get a percentage."). ## calculate row wise percentages (is that what you are looking for?) (tab <- prop.table(table(df), 1)*100) The resulting table looks like this: > (tab <- prop.table(table(df), 1)*100) age status 20 21 22 23 24 25 26 single 1.857143 3.142857 3.428571 2.285714 2.142857 2.857143 3.428571 married 2.333333 2.333333 5.666667 1.333333 3.333333 5.333333 2.000000 age status 27 28 29 30 31 32 33 single 2.857143 3.142857 3.428571 3.285714 2.714286 3.714286 3.571429 married 5.000000 4.333333 2.666667 4.000000 1.666667 4.666667 3.000000 age status 34 35 36 37 38 39 40 single 3.000000 2.857143 5.000000 3.571429 2.857143 3.571429 3.000000 married 3.333333 4.000000 4.000000 2.333333 2.000000 2.000000 2.000000 age status 41 42 43 44 45 46 47 single 4.285714 3.000000 3.714286 3.857143 2.857143 3.714286 1.714286 married 2.333333 3.333333 2.000000 4.333333 3.666667 5.333333 2.666667 age status 48 49 50 single 2.857143 3.428571 4.857143 married 2.333333 3.000000 3.666667 That is, if you sum up row wise, it gives 100% > sum(tab[1,]) [1] 100 Finally, plot it. ## plot it plot(as.numeric(dimnames(tab)$age), tab[1,], xlab = "Age", ylab = "Single [%]")
Calculating proportions by age in R
Your approach seems way too complicated to me. Let's start with some data: ## make up some data status <- factor(rbinom(1000, 1, 0.3), labels = c("single", "married")) age <- sample(20:50, 1000, repla
Calculating proportions by age in R Your approach seems way too complicated to me. Let's start with some data: ## make up some data status <- factor(rbinom(1000, 1, 0.3), labels = c("single", "married")) age <- sample(20:50, 1000, replace = TRUE) df <- data.frame(status, age) head(df) Print the first six cases: > head(df) status age 1 married 21 2 single 50 3 single 43 4 single 28 5 married 28 6 single 40 Next, we need to calculate row wise percentages; even if I doubt that this makes sense (it refers to your statement: "What i need to do is to count number of people that were never married at each age and divide it by the total number of never married people to get a percentage."). ## calculate row wise percentages (is that what you are looking for?) (tab <- prop.table(table(df), 1)*100) The resulting table looks like this: > (tab <- prop.table(table(df), 1)*100) age status 20 21 22 23 24 25 26 single 1.857143 3.142857 3.428571 2.285714 2.142857 2.857143 3.428571 married 2.333333 2.333333 5.666667 1.333333 3.333333 5.333333 2.000000 age status 27 28 29 30 31 32 33 single 2.857143 3.142857 3.428571 3.285714 2.714286 3.714286 3.571429 married 5.000000 4.333333 2.666667 4.000000 1.666667 4.666667 3.000000 age status 34 35 36 37 38 39 40 single 3.000000 2.857143 5.000000 3.571429 2.857143 3.571429 3.000000 married 3.333333 4.000000 4.000000 2.333333 2.000000 2.000000 2.000000 age status 41 42 43 44 45 46 47 single 4.285714 3.000000 3.714286 3.857143 2.857143 3.714286 1.714286 married 2.333333 3.333333 2.000000 4.333333 3.666667 5.333333 2.666667 age status 48 49 50 single 2.857143 3.428571 4.857143 married 2.333333 3.000000 3.666667 That is, if you sum up row wise, it gives 100% > sum(tab[1,]) [1] 100 Finally, plot it. ## plot it plot(as.numeric(dimnames(tab)$age), tab[1,], xlab = "Age", ylab = "Single [%]")
Calculating proportions by age in R Your approach seems way too complicated to me. Let's start with some data: ## make up some data status <- factor(rbinom(1000, 1, 0.3), labels = c("single", "married")) age <- sample(20:50, 1000, repla
44,324
Calculating proportions by age in R
I did something similar recently. There are quite a few ways to aggregate data like this in R, but the ddply function from the package plyr is my security blanket, and I turn to it for things like this. I'm assuming that you have individual records for each person in your dataset, with age, sex, and marital status. There's no need to split up the data into multiple tables for this approach - if you have women in the original table, just leave them in and add sex as a grouping variable. require(plyr) results.by.age <- ddply(.data = yourdata, .var = c("sex", "age"), .fun = function(x) { data.frame(n = nrow(x), ever.married.n = nrow(subset(x, marital.status %in% c("Married", "Divorced"))), ever.married.prop = nrow(subset(x, marital.status %in% c("Married", "Divorced"))) / nrow(x) ) } ) This splits the data.frame yourdata by unique combinations of the variables sex and age. Then, for each of those chunks (referred to as x), it calculates the number of people who belong to that group (n), how many of them are married (ever.married.n), and what proportion of them are married (ever.married.prop). It will then return a data.frame called results.by.age with rows like sex age n ever.married.n ever.married.prop "Male" 25 264 167 0.633 This is perhaps not the most elegant or efficient way to do this, but this general pattern has been very helpful for me. One advantage of this is that you can easily and transparently collect whatever statistics you want from the subset, which can be helpful if you want to, say, add a regression line to the plot (weight by n) or have both male and female proportions on the same plot and color the points by sex. Here's a revised version using the summarise() function from plyr - the effect is the same, but summarise() has a couple of key advantages: - It works within the environment of the current subset - so rather than typing x$marital.status, I can just type marital.status. - It lets me refer to other variables I've already created, which makes percentages, transformations and the like much easier - if I've already made num and denom, the proportion of num is just num / denom. results.by.age <- ddply(.data = yourdata, .var = c("sex", "age"), .fun = summarise, n = length(marital.status), ever.married = sum(marital.status %in% c("Married", "Divorced")), ever.married.prop = ever.married / n # Referring to vars I just created )
Calculating proportions by age in R
I did something similar recently. There are quite a few ways to aggregate data like this in R, but the ddply function from the package plyr is my security blanket, and I turn to it for things like th
Calculating proportions by age in R I did something similar recently. There are quite a few ways to aggregate data like this in R, but the ddply function from the package plyr is my security blanket, and I turn to it for things like this. I'm assuming that you have individual records for each person in your dataset, with age, sex, and marital status. There's no need to split up the data into multiple tables for this approach - if you have women in the original table, just leave them in and add sex as a grouping variable. require(plyr) results.by.age <- ddply(.data = yourdata, .var = c("sex", "age"), .fun = function(x) { data.frame(n = nrow(x), ever.married.n = nrow(subset(x, marital.status %in% c("Married", "Divorced"))), ever.married.prop = nrow(subset(x, marital.status %in% c("Married", "Divorced"))) / nrow(x) ) } ) This splits the data.frame yourdata by unique combinations of the variables sex and age. Then, for each of those chunks (referred to as x), it calculates the number of people who belong to that group (n), how many of them are married (ever.married.n), and what proportion of them are married (ever.married.prop). It will then return a data.frame called results.by.age with rows like sex age n ever.married.n ever.married.prop "Male" 25 264 167 0.633 This is perhaps not the most elegant or efficient way to do this, but this general pattern has been very helpful for me. One advantage of this is that you can easily and transparently collect whatever statistics you want from the subset, which can be helpful if you want to, say, add a regression line to the plot (weight by n) or have both male and female proportions on the same plot and color the points by sex. Here's a revised version using the summarise() function from plyr - the effect is the same, but summarise() has a couple of key advantages: - It works within the environment of the current subset - so rather than typing x$marital.status, I can just type marital.status. - It lets me refer to other variables I've already created, which makes percentages, transformations and the like much easier - if I've already made num and denom, the proportion of num is just num / denom. results.by.age <- ddply(.data = yourdata, .var = c("sex", "age"), .fun = summarise, n = length(marital.status), ever.married = sum(marital.status %in% c("Married", "Divorced")), ever.married.prop = ever.married / n # Referring to vars I just created )
Calculating proportions by age in R I did something similar recently. There are quite a few ways to aggregate data like this in R, but the ddply function from the package plyr is my security blanket, and I turn to it for things like th
44,325
Calculating proportions by age in R
Probably what you need is table or aggregate. If you add more details I can give you a more in-depth explanation.
Calculating proportions by age in R
Probably what you need is table or aggregate. If you add more details I can give you a more in-depth explanation.
Calculating proportions by age in R Probably what you need is table or aggregate. If you add more details I can give you a more in-depth explanation.
Calculating proportions by age in R Probably what you need is table or aggregate. If you add more details I can give you a more in-depth explanation.
44,326
Is there a verifiable way to generate discrete random variables on the basis of an external event?
Just as another source of verifiable randomness: random.org generates random numbers from atmospheric noise. They publish a daily file (most days) of random bits; the first digit of each day's file might prove suitably verifiable to your parties. Update 2013-11-12: Access to these files is now restricted, but it looks like you can email random.org's operators to gain access: Note: Access to the pregenerated files is currently restricted due to bandwidth considerations. Let us know (contact@random.org) if you require access.
Is there a verifiable way to generate discrete random variables on the basis of an external event?
Just as another source of verifiable randomness: random.org generates random numbers from atmospheric noise. They publish a daily file (most days) of random bits; the first digit of each day's file m
Is there a verifiable way to generate discrete random variables on the basis of an external event? Just as another source of verifiable randomness: random.org generates random numbers from atmospheric noise. They publish a daily file (most days) of random bits; the first digit of each day's file might prove suitably verifiable to your parties. Update 2013-11-12: Access to these files is now restricted, but it looks like you can email random.org's operators to gain access: Note: Access to the pregenerated files is currently restricted due to bandwidth considerations. Let us know (contact@random.org) if you require access.
Is there a verifiable way to generate discrete random variables on the basis of an external event? Just as another source of verifiable randomness: random.org generates random numbers from atmospheric noise. They publish a daily file (most days) of random bits; the first digit of each day's file m
44,327
Is there a verifiable way to generate discrete random variables on the basis of an external event?
Many countries have state lottery which is regularly audited, and whose results are announced online: e.g. UK national lottery. You just need to construct an appropriate function which maps this output space to your desired output. A continuous distribution would be more tricky, but you could obtain a discrete approximation: in the UK case there are ${}^{49}C_6 \times 43$ = 601 304 088 equally likely outcomes, which, depending on context, could give sufficient granularity.
Is there a verifiable way to generate discrete random variables on the basis of an external event?
Many countries have state lottery which is regularly audited, and whose results are announced online: e.g. UK national lottery. You just need to construct an appropriate function which maps this outpu
Is there a verifiable way to generate discrete random variables on the basis of an external event? Many countries have state lottery which is regularly audited, and whose results are announced online: e.g. UK national lottery. You just need to construct an appropriate function which maps this output space to your desired output. A continuous distribution would be more tricky, but you could obtain a discrete approximation: in the UK case there are ${}^{49}C_6 \times 43$ = 601 304 088 equally likely outcomes, which, depending on context, could give sufficient granularity.
Is there a verifiable way to generate discrete random variables on the basis of an external event? Many countries have state lottery which is regularly audited, and whose results are announced online: e.g. UK national lottery. You just need to construct an appropriate function which maps this outpu
44,328
Is there a verifiable way to generate discrete random variables on the basis of an external event?
This reminds me of a question from Algorithms class a long time ago. Let the external event be a (preferrably continuous) random variable $Y$. To generate a value of $X$, take two independent observations of $Y$ and let $X$ be $1$ if the first observation of $Y$ is greater than the second, let it be $0$ if the second is greater than the first, and repeat the experiment if there is a tie. Obviously, this works better if $Y$ is continuous. If only a coinflip is available as a generator, one can let the number of consecutive heads before seeing a tail be the random variable $Y$. (The homework question, I believe, was how to turn a biased coinflip into an unbiased coinflip. One part of the homework was proving that the process would terminate...) This obviously can be extended to the discrete case as well, although one may run into more difficulties with ties. If you have $n$ possible outcomes for $X$, take some $k$ such that $n$ divides $k!$ and then partition the $k!$ possible orderings of $k$ observations from $Y$ into equivalence classes for $X$. edit: per @srikant's comment, an example of a possible generator of $Y$: (as anticipated by @andyW) Let $Z_i$ be the number of shares traded on a given highly-liquid ETF as reported by a given source over a fixed time period unambiguously indexed by $i$. Let $Y_i = \tan{(Z_i)},$ where the tangent function is computed by a fixed standard library (in a fixed revision of R, say, on a fixed platform.) Such a generator of $Y$ is pseudorandom enough for me. Other generators of $Z$ are also amenable to this process if they vary widely enough with respect to $2\pi$.
Is there a verifiable way to generate discrete random variables on the basis of an external event?
This reminds me of a question from Algorithms class a long time ago. Let the external event be a (preferrably continuous) random variable $Y$. To generate a value of $X$, take two independent observat
Is there a verifiable way to generate discrete random variables on the basis of an external event? This reminds me of a question from Algorithms class a long time ago. Let the external event be a (preferrably continuous) random variable $Y$. To generate a value of $X$, take two independent observations of $Y$ and let $X$ be $1$ if the first observation of $Y$ is greater than the second, let it be $0$ if the second is greater than the first, and repeat the experiment if there is a tie. Obviously, this works better if $Y$ is continuous. If only a coinflip is available as a generator, one can let the number of consecutive heads before seeing a tail be the random variable $Y$. (The homework question, I believe, was how to turn a biased coinflip into an unbiased coinflip. One part of the homework was proving that the process would terminate...) This obviously can be extended to the discrete case as well, although one may run into more difficulties with ties. If you have $n$ possible outcomes for $X$, take some $k$ such that $n$ divides $k!$ and then partition the $k!$ possible orderings of $k$ observations from $Y$ into equivalence classes for $X$. edit: per @srikant's comment, an example of a possible generator of $Y$: (as anticipated by @andyW) Let $Z_i$ be the number of shares traded on a given highly-liquid ETF as reported by a given source over a fixed time period unambiguously indexed by $i$. Let $Y_i = \tan{(Z_i)},$ where the tangent function is computed by a fixed standard library (in a fixed revision of R, say, on a fixed platform.) Such a generator of $Y$ is pseudorandom enough for me. Other generators of $Z$ are also amenable to this process if they vary widely enough with respect to $2\pi$.
Is there a verifiable way to generate discrete random variables on the basis of an external event? This reminds me of a question from Algorithms class a long time ago. Let the external event be a (preferrably continuous) random variable $Y$. To generate a value of $X$, take two independent observat
44,329
Is there a verifiable way to generate discrete random variables on the basis of an external event?
I didn't quite understand what you meant by "on the basis of an external event." But you can certainly flip a fair coin in a manner that a remote user can cryptographically verify. Consider this algorithm: Bob picks a uniformly random boolean value, TRUE or FALSE. He also chooses a large random number. He sends Alice the SHA-256 hash of the boolean value concatenated with the number. (E.g. he sends the hash of "TRUE|12345678".) Since Alice doesn't know the random number and the hash is one-way, Alice doesn't know the boolean value. Alice flips a coin and sends Bob the value -- TRUE or FALSE. Bob reveals the random number, and thus his own boolean value. Alice verifies that the boolean value and the random number indeed hash to the value she received earlier. This final output of the coin flip is the exclusive-or of Alice's boolean value and Bob's boolean value. With this algorithm, no party can cheat without the cooperation of the counterparty. If either party plays fairly, the output will be a uniform random boolean value. (EDIT) I now understand the problem to mean you have no internal source of nondeterminism at all, so all randomness has to come from an external source and the algorithm has to be deterministic. In that case, we can still use cryptography to help. How about taking the SHA-256 of the PDF version of The New York Times every day, or the SHA-256 of the volume and closing price of all the stocks in the Dow Jones Industrial Average in alphabetical order by ticker symbol, or really the secure hash of anything that can be mutually observed and that you can't influence. If you want just one bit, take the first bit of the SHA-256. If you want a normal distribution, you could take the whole thing in two parts (128 bits, then 128 bits) as two uniform deviates and use the Box-Muller transform to get two normal deviates.
Is there a verifiable way to generate discrete random variables on the basis of an external event?
I didn't quite understand what you meant by "on the basis of an external event." But you can certainly flip a fair coin in a manner that a remote user can cryptographically verify. Consider this algor
Is there a verifiable way to generate discrete random variables on the basis of an external event? I didn't quite understand what you meant by "on the basis of an external event." But you can certainly flip a fair coin in a manner that a remote user can cryptographically verify. Consider this algorithm: Bob picks a uniformly random boolean value, TRUE or FALSE. He also chooses a large random number. He sends Alice the SHA-256 hash of the boolean value concatenated with the number. (E.g. he sends the hash of "TRUE|12345678".) Since Alice doesn't know the random number and the hash is one-way, Alice doesn't know the boolean value. Alice flips a coin and sends Bob the value -- TRUE or FALSE. Bob reveals the random number, and thus his own boolean value. Alice verifies that the boolean value and the random number indeed hash to the value she received earlier. This final output of the coin flip is the exclusive-or of Alice's boolean value and Bob's boolean value. With this algorithm, no party can cheat without the cooperation of the counterparty. If either party plays fairly, the output will be a uniform random boolean value. (EDIT) I now understand the problem to mean you have no internal source of nondeterminism at all, so all randomness has to come from an external source and the algorithm has to be deterministic. In that case, we can still use cryptography to help. How about taking the SHA-256 of the PDF version of The New York Times every day, or the SHA-256 of the volume and closing price of all the stocks in the Dow Jones Industrial Average in alphabetical order by ticker symbol, or really the secure hash of anything that can be mutually observed and that you can't influence. If you want just one bit, take the first bit of the SHA-256. If you want a normal distribution, you could take the whole thing in two parts (128 bits, then 128 bits) as two uniform deviates and use the Box-Muller transform to get two normal deviates.
Is there a verifiable way to generate discrete random variables on the basis of an external event? I didn't quite understand what you meant by "on the basis of an external event." But you can certainly flip a fair coin in a manner that a remote user can cryptographically verify. Consider this algor
44,330
Is there a verifiable way to generate discrete random variables on the basis of an external event?
an easy way to generate symmetric bernoulli trials is to flip a coin twice. if the first toss is H and the second is T, say X = 1. if it's the other way round, say X = 0. if the two tosses match [2H or 2T], discard the outcome and continue. no matter what the bias of the coin, X will be symmetric bernoulli.
Is there a verifiable way to generate discrete random variables on the basis of an external event?
an easy way to generate symmetric bernoulli trials is to flip a coin twice. if the first toss is H and the second is T, say X = 1. if it's the other way round, say X = 0. if the two tosses match [2H o
Is there a verifiable way to generate discrete random variables on the basis of an external event? an easy way to generate symmetric bernoulli trials is to flip a coin twice. if the first toss is H and the second is T, say X = 1. if it's the other way round, say X = 0. if the two tosses match [2H or 2T], discard the outcome and continue. no matter what the bias of the coin, X will be symmetric bernoulli.
Is there a verifiable way to generate discrete random variables on the basis of an external event? an easy way to generate symmetric bernoulli trials is to flip a coin twice. if the first toss is H and the second is T, say X = 1. if it's the other way round, say X = 0. if the two tosses match [2H o
44,331
Incorporating boolean data into analysis
You are decribing "categorical variables" (represented in R a factors). These can be incorporated into almost any statistical model by being assigned levels. You would need to give more detail about your particular problem in order to be advised on a particular method. Edit If the response variable has two possible outcomes, you might consider binomial or logistic regression. Note: If you're not familiar with the different kinds of variables in statistics, I suggest reading the first few chapters of Andrew Gelman's "Data Analysis Using Regression and Multilevel/Hierarchical Models" which covers this in a very understandable manner.
Incorporating boolean data into analysis
You are decribing "categorical variables" (represented in R a factors). These can be incorporated into almost any statistical model by being assigned levels. You would need to give more detail about
Incorporating boolean data into analysis You are decribing "categorical variables" (represented in R a factors). These can be incorporated into almost any statistical model by being assigned levels. You would need to give more detail about your particular problem in order to be advised on a particular method. Edit If the response variable has two possible outcomes, you might consider binomial or logistic regression. Note: If you're not familiar with the different kinds of variables in statistics, I suggest reading the first few chapters of Andrew Gelman's "Data Analysis Using Regression and Multilevel/Hierarchical Models" which covers this in a very understandable manner.
Incorporating boolean data into analysis You are decribing "categorical variables" (represented in R a factors). These can be incorporated into almost any statistical model by being assigned levels. You would need to give more detail about
44,332
Incorporating boolean data into analysis
It sounds like you are trying to predict your boolean response, yes? This is called classification. Logistic Regression is the obvious choice here, but there are other methods too. You can't do traditional regression, because the response is not a real number. The lookup variables are called nominals, and can be dealt with in regression by using "dummy" variables. For example, if your lookup variable is type=[steel, aluminum, plastic] (N=3), then your dummy variables would look like this: IsSteel = [1,0] IsAlum = [1,0] There would only be two (N-1) dummy variables, as IsSteel=0 AND IsAlum=0 represents "IsPlastic"=1 But any good stats program should handle this. If you need a book, I recommend Multivariate Data Analysis by Hair.
Incorporating boolean data into analysis
It sounds like you are trying to predict your boolean response, yes? This is called classification. Logistic Regression is the obvious choice here, but there are other methods too. You can't do tradit
Incorporating boolean data into analysis It sounds like you are trying to predict your boolean response, yes? This is called classification. Logistic Regression is the obvious choice here, but there are other methods too. You can't do traditional regression, because the response is not a real number. The lookup variables are called nominals, and can be dealt with in regression by using "dummy" variables. For example, if your lookup variable is type=[steel, aluminum, plastic] (N=3), then your dummy variables would look like this: IsSteel = [1,0] IsAlum = [1,0] There would only be two (N-1) dummy variables, as IsSteel=0 AND IsAlum=0 represents "IsPlastic"=1 But any good stats program should handle this. If you need a book, I recommend Multivariate Data Analysis by Hair.
Incorporating boolean data into analysis It sounds like you are trying to predict your boolean response, yes? This is called classification. Logistic Regression is the obvious choice here, but there are other methods too. You can't do tradit
44,333
Incorporating boolean data into analysis
Ingo Ruczinski has contributed to promote the use of Logic regression for data set consisting of binary variables, with an emphasis on higher-order interaction terms. The main advantage compared to usual or penalized GLMs is that it is more parcimonious in terms of degrees of freedom. The outcome may be continuous or categorical, and continuous covariates can be added to the model (or the outcome can first be residualized on them if these are the binary predictors that are of interest). The original paper Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression. Journal of Computational and Graphical Statistics, 12(3), 475-511. includes several applications in biomedical studies, and a comparison of LR with CART and MARS. Although it has mainly been applied in large-scale genetic studies (e.g. genome-wide association studies), it should work with any binary variables whose combinations of interest can be expressed with a set of logical operators. The LogicReg R package implements this technique; see also the related packages on CRAN and Bioconductor, esp. LogicForest which shares some ideas with Random Forests.
Incorporating boolean data into analysis
Ingo Ruczinski has contributed to promote the use of Logic regression for data set consisting of binary variables, with an emphasis on higher-order interaction terms. The main advantage compared to us
Incorporating boolean data into analysis Ingo Ruczinski has contributed to promote the use of Logic regression for data set consisting of binary variables, with an emphasis on higher-order interaction terms. The main advantage compared to usual or penalized GLMs is that it is more parcimonious in terms of degrees of freedom. The outcome may be continuous or categorical, and continuous covariates can be added to the model (or the outcome can first be residualized on them if these are the binary predictors that are of interest). The original paper Ruczinski I, Kooperberg C, LeBlanc ML (2003). Logic Regression. Journal of Computational and Graphical Statistics, 12(3), 475-511. includes several applications in biomedical studies, and a comparison of LR with CART and MARS. Although it has mainly been applied in large-scale genetic studies (e.g. genome-wide association studies), it should work with any binary variables whose combinations of interest can be expressed with a set of logical operators. The LogicReg R package implements this technique; see also the related packages on CRAN and Bioconductor, esp. LogicForest which shares some ideas with Random Forests.
Incorporating boolean data into analysis Ingo Ruczinski has contributed to promote the use of Logic regression for data set consisting of binary variables, with an emphasis on higher-order interaction terms. The main advantage compared to us
44,334
Incorporating boolean data into analysis
Try Random Forest; from my experience it may perform well on such kind of data, and gives you a some additional interesting information, like variable importance and object similarity measure.
Incorporating boolean data into analysis
Try Random Forest; from my experience it may perform well on such kind of data, and gives you a some additional interesting information, like variable importance and object similarity measure.
Incorporating boolean data into analysis Try Random Forest; from my experience it may perform well on such kind of data, and gives you a some additional interesting information, like variable importance and object similarity measure.
Incorporating boolean data into analysis Try Random Forest; from my experience it may perform well on such kind of data, and gives you a some additional interesting information, like variable importance and object similarity measure.
44,335
Is Kendall's tau uniquely determined by Pearson rho?
Can two different data sets have the same Pearson's ρ, but different Kendall's Ο„? Anscombe's quartet gives you four two-dimensional datasets with (almost) identical Pearson correlations, but their Kendall correlations are quite different. In R: > with(anscombe,cor(x1,y1,method="pearson")) [1] 0.8164205 > with(anscombe,cor(x2,y2,method="pearson")) [1] 0.8162365 > with(anscombe,cor(x1,y1,method="kendall")) [1] 0.6363636 > with(anscombe,cor(x2,y2,method="kendall")) [1] 0.5636364 In general, there is no bijective transformation between the two correlations. You can also see this by the fact that small changes in data points will always change the Pearson correlation continuously - but the Kendall correlation will not change at first and suddenly change when data points change position, because the Kendall correlation only looks at whether two points are to the left or the right, respectively above or below each other.
Is Kendall's tau uniquely determined by Pearson rho?
Can two different data sets have the same Pearson's ρ, but different Kendall's Ο„? Anscombe's quartet gives you four two-dimensional datasets with (almost) identical Pearson correlations, but their Ke
Is Kendall's tau uniquely determined by Pearson rho? Can two different data sets have the same Pearson's ρ, but different Kendall's Ο„? Anscombe's quartet gives you four two-dimensional datasets with (almost) identical Pearson correlations, but their Kendall correlations are quite different. In R: > with(anscombe,cor(x1,y1,method="pearson")) [1] 0.8164205 > with(anscombe,cor(x2,y2,method="pearson")) [1] 0.8162365 > with(anscombe,cor(x1,y1,method="kendall")) [1] 0.6363636 > with(anscombe,cor(x2,y2,method="kendall")) [1] 0.5636364 In general, there is no bijective transformation between the two correlations. You can also see this by the fact that small changes in data points will always change the Pearson correlation continuously - but the Kendall correlation will not change at first and suddenly change when data points change position, because the Kendall correlation only looks at whether two points are to the left or the right, respectively above or below each other.
Is Kendall's tau uniquely determined by Pearson rho? Can two different data sets have the same Pearson's ρ, but different Kendall's Ο„? Anscombe's quartet gives you four two-dimensional datasets with (almost) identical Pearson correlations, but their Ke
44,336
Is Kendall's tau uniquely determined by Pearson rho?
An indirect approach: If two $\rho_1 > \rho_2$ can relate to the same $\tau$, then imagine adjusting the dataset a little such that we increase all these three values. We should be able to arrive to some values $\rho^\prime_1 > \rho_1$, $\rho^\prime_2 > \rho_2$ and $\tau^\prime > \tau$. This should be possible in a continuous way such that we get at some point $\rho^\prime_2 = \rho_1$. That means that we have got the same Pearson's $\rho$, but with different $\tau^\prime$ and $\tau$.
Is Kendall's tau uniquely determined by Pearson rho?
An indirect approach: If two $\rho_1 > \rho_2$ can relate to the same $\tau$, then imagine adjusting the dataset a little such that we increase all these three values. We should be able to arrive to s
Is Kendall's tau uniquely determined by Pearson rho? An indirect approach: If two $\rho_1 > \rho_2$ can relate to the same $\tau$, then imagine adjusting the dataset a little such that we increase all these three values. We should be able to arrive to some values $\rho^\prime_1 > \rho_1$, $\rho^\prime_2 > \rho_2$ and $\tau^\prime > \tau$. This should be possible in a continuous way such that we get at some point $\rho^\prime_2 = \rho_1$. That means that we have got the same Pearson's $\rho$, but with different $\tau^\prime$ and $\tau$.
Is Kendall's tau uniquely determined by Pearson rho? An indirect approach: If two $\rho_1 > \rho_2$ can relate to the same $\tau$, then imagine adjusting the dataset a little such that we increase all these three values. We should be able to arrive to s
44,337
Question about running Spearman's correlation instead of Pearson's
Pearson's correlation coefficient ($\boldsymbol{r}$) provides a measure of linear association between paired variables. Spearman's correlation coefficient ($\boldsymbol{r_{\bf{S}}}$) provides a measure of monotonic association between paired variables. The latter is different than the former. A linear relationship is just one kind of monotonic relationship between two variables. For example, an exponential curve, a logistic curve, and a stair step function are also all examples of monotonic functions between $x$ and $y$. Because of this, it is possible to observe $r > r_{\text{S}}$, $r \approx r_{\text{S}}$ and $r < r_{\text{S}}$ to a significant degree depending on what's going on in your data. These two measures can even have different signs. As a consequence, without knowing the specifics of your data and sample distributions ahead of time, it is probably best to respect that $\boldsymbol{r}$ and $\boldsymbol{r_{\bf{S}}}$ are measures of substantively different things. Aside: Spearman's correlation can also be thought of as a measure of linear association between ranks of paired variables..
Question about running Spearman's correlation instead of Pearson's
Pearson's correlation coefficient ($\boldsymbol{r}$) provides a measure of linear association between paired variables. Spearman's correlation coefficient ($\boldsymbol{r_{\bf{S}}}$) provides a measur
Question about running Spearman's correlation instead of Pearson's Pearson's correlation coefficient ($\boldsymbol{r}$) provides a measure of linear association between paired variables. Spearman's correlation coefficient ($\boldsymbol{r_{\bf{S}}}$) provides a measure of monotonic association between paired variables. The latter is different than the former. A linear relationship is just one kind of monotonic relationship between two variables. For example, an exponential curve, a logistic curve, and a stair step function are also all examples of monotonic functions between $x$ and $y$. Because of this, it is possible to observe $r > r_{\text{S}}$, $r \approx r_{\text{S}}$ and $r < r_{\text{S}}$ to a significant degree depending on what's going on in your data. These two measures can even have different signs. As a consequence, without knowing the specifics of your data and sample distributions ahead of time, it is probably best to respect that $\boldsymbol{r}$ and $\boldsymbol{r_{\bf{S}}}$ are measures of substantively different things. Aside: Spearman's correlation can also be thought of as a measure of linear association between ranks of paired variables..
Question about running Spearman's correlation instead of Pearson's Pearson's correlation coefficient ($\boldsymbol{r}$) provides a measure of linear association between paired variables. Spearman's correlation coefficient ($\boldsymbol{r_{\bf{S}}}$) provides a measur
44,338
Question about running Spearman's correlation instead of Pearson's
I think a couple valuable journal articles on this subject are de Winter et al., 2016 and Bishara & Hittner, 2015. I highlight the main points of both below, focusing primarily on Pearson and Spearman coefficients since that is what your question asks. Bishara & Hittner, 2015 In this simulation study, the authors mainly sought to test how non-normality affected correlation coefficients since so much of psychological research has non-normal data anyway. Their conclusions generally were the following: Non-normality causes exaggerated point estimates for Pearson's $r$, with particular issues present when kurtosis is present. Therefore, in these cases, something like Spearman's $\rho$ can be better, but that of course is also dependent on the shape of the data distribution. Pearson's allow for much easier interpretation when the relationship is very linear. It does not require a rank-transformation explanation of why the data is weak or strong. RMSE (re: error) for Pearson and Spearman coefficients is generally the same for both at low estimates, but RMSE decreases as the point estimates for Spearman become larger. For a variety of distributions, the differences in RMSE is minimal while in other cases it is more drastic. These differences also vary across sample size but not by much. de Winter et al., 2016 This study used a large pool of real world data, and showed some interesting similarities and differences. Normally distributed variables show similar values for $r$ and $\rho$, but $\rho$ seemed to be less consistent when the correlation was strong and prone to lower values, which meant that Pearson coefficients are more consistent for normal data. Reflecting what the other simulation study stipulated, kurtosis seemed to affect Pearson coefficients more. Outliers also unsurprisingly affected Pearson values more. Pearson coefficients perform much better for light-tailed distributions, whereas Spearman values performed better for heavy-tailed distributions. So looking at these results, we can say that in some cases, each correlation coefficient approximates bivariate relationships in a more straightforward fashion when meeting the particular class of association it is intended for (strictly linear vs monotonic), whether the data is normal (the tail shape, etc.), how large the sample size is, and other relevant factors. By the way, both of these papers have some good material that explains past lit on the properties of correlations if you feel you would like to explore this topic further. Citations Bishara, A. J., & Hittner, J. B. (2015). Reducing bias and error in the correlation coefficient due to nonnormality. Educational and Psychological Measurement, 75(5), 785–804. https://doi.org/10.1177/0013164414557639 de Winter, J. C. F., Gosling, S. D., & Potter, J. (2016). Comparing the Pearson and Spearman correlation coefficients across distributions and sample sizes: A tutorial using simulations and empirical data. Psychological Methods, 21(3), 273–290. https://doi.org/10.1037/met0000079
Question about running Spearman's correlation instead of Pearson's
I think a couple valuable journal articles on this subject are de Winter et al., 2016 and Bishara & Hittner, 2015. I highlight the main points of both below, focusing primarily on Pearson and Spearman
Question about running Spearman's correlation instead of Pearson's I think a couple valuable journal articles on this subject are de Winter et al., 2016 and Bishara & Hittner, 2015. I highlight the main points of both below, focusing primarily on Pearson and Spearman coefficients since that is what your question asks. Bishara & Hittner, 2015 In this simulation study, the authors mainly sought to test how non-normality affected correlation coefficients since so much of psychological research has non-normal data anyway. Their conclusions generally were the following: Non-normality causes exaggerated point estimates for Pearson's $r$, with particular issues present when kurtosis is present. Therefore, in these cases, something like Spearman's $\rho$ can be better, but that of course is also dependent on the shape of the data distribution. Pearson's allow for much easier interpretation when the relationship is very linear. It does not require a rank-transformation explanation of why the data is weak or strong. RMSE (re: error) for Pearson and Spearman coefficients is generally the same for both at low estimates, but RMSE decreases as the point estimates for Spearman become larger. For a variety of distributions, the differences in RMSE is minimal while in other cases it is more drastic. These differences also vary across sample size but not by much. de Winter et al., 2016 This study used a large pool of real world data, and showed some interesting similarities and differences. Normally distributed variables show similar values for $r$ and $\rho$, but $\rho$ seemed to be less consistent when the correlation was strong and prone to lower values, which meant that Pearson coefficients are more consistent for normal data. Reflecting what the other simulation study stipulated, kurtosis seemed to affect Pearson coefficients more. Outliers also unsurprisingly affected Pearson values more. Pearson coefficients perform much better for light-tailed distributions, whereas Spearman values performed better for heavy-tailed distributions. So looking at these results, we can say that in some cases, each correlation coefficient approximates bivariate relationships in a more straightforward fashion when meeting the particular class of association it is intended for (strictly linear vs monotonic), whether the data is normal (the tail shape, etc.), how large the sample size is, and other relevant factors. By the way, both of these papers have some good material that explains past lit on the properties of correlations if you feel you would like to explore this topic further. Citations Bishara, A. J., & Hittner, J. B. (2015). Reducing bias and error in the correlation coefficient due to nonnormality. Educational and Psychological Measurement, 75(5), 785–804. https://doi.org/10.1177/0013164414557639 de Winter, J. C. F., Gosling, S. D., & Potter, J. (2016). Comparing the Pearson and Spearman correlation coefficients across distributions and sample sizes: A tutorial using simulations and empirical data. Psychological Methods, 21(3), 273–290. https://doi.org/10.1037/met0000079
Question about running Spearman's correlation instead of Pearson's I think a couple valuable journal articles on this subject are de Winter et al., 2016 and Bishara & Hittner, 2015. I highlight the main points of both below, focusing primarily on Pearson and Spearman
44,339
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
The TLDR The short answer to your question is no. You can engage in both null hypothesis significance testing (NHST) as well as exploratory data analysis (EDA) without engaging in morally corrupt research practices. The longer answer to that question can be summarized with "it also depends." A Practical Example If we remove the frame of formal scientific research, we can apply both of these types of data analysis on everyday life and see why they are both important (and of consequence, why they are not always at odds with each other). Let's say my computer breaks one day. I hypothesize that this is due to the power button being dysfunctional. My null hypothesis would be that pressing the power button should have no effect on the outcome. So let's say I press the button a thousand times and nothing happens. I have now failed to reject the null hypothesis. But of course somebody who has broken their computer wouldn't just throw their digital baby into the trash bin. They would try to find some way to figure out the problem, and thus would explore other options. That can be done both with formal hypotheses ("perhaps it is because of the charger") or by simply mashing all the buttons until something works ("idk what is going on with my computer but maybe blunt force trauma will do the trick."). You can see where this would be a solution rather than a problem, because now you are combining exploratory and confirmatory methods. Consider the below chart for the scientific method: You can see that some parts of this method are confirmatory and others are exploratory. Take for example the section that shows where one would "troubleshoot." We do this all the time with broken computers, and that would also apply with our scenario above. You would also engage in updates to your hypotheses ("maybe it is broken because of X, Y, or Z"). Only by exploring further can we figure this out. Drawing up hypotheses from nowhere is a crackpot's idea of science anyway. Now if we were to inject a p-hacking scenario into this real-life situation, it may look something like the next scenario. Let's say my roommate also has a broken computer and I have no pre-conceived notion of what is causing the issue. So I mash all of the buttons on his keyboard until it decides to turn on. I don't know what actually fixed it, but because one of the buttons was the power button, I tell him after that I already devised that it was the power button the whole time. Obviously this is lying...I didn't fix the button because I knew the cause already, I simply explored around and conceived of the idea after. This situation is more where you will find issues with blending NHST and EDA. If you decide to dig around until you get something you want, then naturally you cannot say with certainty that you hypothesized it. But that's not to say that you shouldn't engage in EDA to facilitate NHST. It only means that you should engage in other practices, such as reporting your failed hypotheses, including newly developed hypotheses, and providing justification for why EDA was used (usually to motivate a decision on what the causes of a phenomenon are). Final Remarks The reason that I suspect he has made this hard distinction in your class is because failing to state some explicit ideas before data analysis can be very problematic if you are going to be a researcher or statistician, and he is probably attempting to get you to think in a more scientifically rigorous way. This isn't inherently wrong, but I do think that stating this in such a rigid way isn't always helpful. Perhaps some others here may disagree with me, but that is my assumption based off my intuition on the subject. Edit In the comments, Karolis mentioned the potential issue with using the power button analogy as being a false example because you always get the answer to your outcome. But as I mentioned there, this is actually a probabilistic outcome disguised as a closed solution. I give a "power surge scenario" in the comments, but there are other factors that can influence this outcome (and are not limited to just these instances): Your battery is dead before you do a certain number of trials. While you are gone, somebody replaces it. You turn it on and suddenly your computer turns on after more trials. You have falsely rejected the null because the button wasn't the issue. Your glasses were not on that day and you can't see the buttons clearly. You think you are pressing the power button, but you actually pressed something else and now the computer is on. So your perception was the computer was turned on by the power button, but it was actually something entirely different. The computer doesn't turn on because you didn't apply enough pressure when pushing down with your finger. You retain the null hypothesis but this in fact isn't true...you simply didn't push down hard enough on the button. This is actually in line with what the professor said...getting the laptop to power on or not power on may be purely by chance, but having a solid theory and evidence behind your claim will help reduce the risk of chance outcomes and give you a solid starting point for attacking the problem. To your question in the comments about cross-validation...you have asked a lot here so I will simply state that cross-validation doesn't become a magic bullet for solving the dilemma. Karolis has provided some reasons for why this can be an issue that I agree with.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
The TLDR The short answer to your question is no. You can engage in both null hypothesis significance testing (NHST) as well as exploratory data analysis (EDA) without engaging in morally corrupt rese
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] The TLDR The short answer to your question is no. You can engage in both null hypothesis significance testing (NHST) as well as exploratory data analysis (EDA) without engaging in morally corrupt research practices. The longer answer to that question can be summarized with "it also depends." A Practical Example If we remove the frame of formal scientific research, we can apply both of these types of data analysis on everyday life and see why they are both important (and of consequence, why they are not always at odds with each other). Let's say my computer breaks one day. I hypothesize that this is due to the power button being dysfunctional. My null hypothesis would be that pressing the power button should have no effect on the outcome. So let's say I press the button a thousand times and nothing happens. I have now failed to reject the null hypothesis. But of course somebody who has broken their computer wouldn't just throw their digital baby into the trash bin. They would try to find some way to figure out the problem, and thus would explore other options. That can be done both with formal hypotheses ("perhaps it is because of the charger") or by simply mashing all the buttons until something works ("idk what is going on with my computer but maybe blunt force trauma will do the trick."). You can see where this would be a solution rather than a problem, because now you are combining exploratory and confirmatory methods. Consider the below chart for the scientific method: You can see that some parts of this method are confirmatory and others are exploratory. Take for example the section that shows where one would "troubleshoot." We do this all the time with broken computers, and that would also apply with our scenario above. You would also engage in updates to your hypotheses ("maybe it is broken because of X, Y, or Z"). Only by exploring further can we figure this out. Drawing up hypotheses from nowhere is a crackpot's idea of science anyway. Now if we were to inject a p-hacking scenario into this real-life situation, it may look something like the next scenario. Let's say my roommate also has a broken computer and I have no pre-conceived notion of what is causing the issue. So I mash all of the buttons on his keyboard until it decides to turn on. I don't know what actually fixed it, but because one of the buttons was the power button, I tell him after that I already devised that it was the power button the whole time. Obviously this is lying...I didn't fix the button because I knew the cause already, I simply explored around and conceived of the idea after. This situation is more where you will find issues with blending NHST and EDA. If you decide to dig around until you get something you want, then naturally you cannot say with certainty that you hypothesized it. But that's not to say that you shouldn't engage in EDA to facilitate NHST. It only means that you should engage in other practices, such as reporting your failed hypotheses, including newly developed hypotheses, and providing justification for why EDA was used (usually to motivate a decision on what the causes of a phenomenon are). Final Remarks The reason that I suspect he has made this hard distinction in your class is because failing to state some explicit ideas before data analysis can be very problematic if you are going to be a researcher or statistician, and he is probably attempting to get you to think in a more scientifically rigorous way. This isn't inherently wrong, but I do think that stating this in such a rigid way isn't always helpful. Perhaps some others here may disagree with me, but that is my assumption based off my intuition on the subject. Edit In the comments, Karolis mentioned the potential issue with using the power button analogy as being a false example because you always get the answer to your outcome. But as I mentioned there, this is actually a probabilistic outcome disguised as a closed solution. I give a "power surge scenario" in the comments, but there are other factors that can influence this outcome (and are not limited to just these instances): Your battery is dead before you do a certain number of trials. While you are gone, somebody replaces it. You turn it on and suddenly your computer turns on after more trials. You have falsely rejected the null because the button wasn't the issue. Your glasses were not on that day and you can't see the buttons clearly. You think you are pressing the power button, but you actually pressed something else and now the computer is on. So your perception was the computer was turned on by the power button, but it was actually something entirely different. The computer doesn't turn on because you didn't apply enough pressure when pushing down with your finger. You retain the null hypothesis but this in fact isn't true...you simply didn't push down hard enough on the button. This is actually in line with what the professor said...getting the laptop to power on or not power on may be purely by chance, but having a solid theory and evidence behind your claim will help reduce the risk of chance outcomes and give you a solid starting point for attacking the problem. To your question in the comments about cross-validation...you have asked a lot here so I will simply state that cross-validation doesn't become a magic bullet for solving the dilemma. Karolis has provided some reasons for why this can be an issue that I agree with.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] The TLDR The short answer to your question is no. You can engage in both null hypothesis significance testing (NHST) as well as exploratory data analysis (EDA) without engaging in morally corrupt rese
44,340
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
The problem with p-hacking in my view is not the hacking itself, but rather the interpretation of the outcome. Your professor is right saying that if you test and test and test, you will at some point find significance even if nothing is going on. This means that significances that you found in this way cannot be reliably interpreted as meaningful. However, if you get at things from an exploratory angle, this should not be the point. Whatever turns up from an exploratory analysis should not be interpreted as a meaningful final result (some people argue that significances from testing should never be interpreted in this way, but I leave this discussion out here). Rather it should be interpreted as a potential hint at something, possibly be investigated on new independent data. If you look at certain data, test one hypothesis and get $p=0.44$ and another and get $p=0.0002$, the data that you have are more critical against the second null hypothesis than against the first, and there may be something going on. This kind of information is gradual and not dichotomous; If you run lots of tests, you should know that $p=0.04$ isn't particularly convincing, $p=0.012$ or $p=0.009$ may still occasionally happen accidentally, but $p=10^{-8}$ is still quite a strong indication (unless you have so much data that basically everything becomes significant; and also always look at effect sizes!). Digression: There are formal procedures for multiple testing such as Bonferroni, Benjamini-Hochberg etc. I think it is good to know about these, because they give some information about what kind of p-value to expect in situations where multiple testing goes on. However, I think in EDA their worth is that they provide some orientation, but they shouldn't be literally followed and "trusted". They are based on simplifying assumptions (e.g., Bonferroni can be very conservative), and they can't take into account all the informal, visual snooping around that is done in EDA. Keep in mind that the "p-hacking" problem does not only come from running multiple tests, but also from running tests conditionally on informal decisions ("I run test $T$ because this connection here looks nonlinear, so I try out adding a squared term and test it"), which runs counter to the standard assumptions of the tests. (End digression.) Ultimately I'd use p-values as exploratory indicators for things that may be worthwhile investigating without interpreting them as final meaningful result. Another issue is the automatic use of multiple significance tests inside a procedure that ultimately does something else, for example a variable selection/prediction routine. You are right that the success of these procedures can be tested and validated on independent data, and the procedure can be seen as good to the extent that it leads to a model with good prediction power, if that's your ultimate aim. The issue here is the same as before: The significance tests are not interpreted as individually meaningful; i.e., you shouldn't claim that just because a model with variable $X_4$ was selected in such a procedure you have significant evidence that variable $X_4$ is important in a meaningful way. The tests here are not used as tests in the usual sense, but rather as building blocks of a method that actually does something else, and has to be assessed on its own merits. Now of course one can ask whether it is a good idea to use significance tests in situations in which they cannot be interpreted in the standard way. My answer would be: It depends. You can hear often these days that for variable selection regularisation using ideas such as the Lasso is better than stepwise selection using significance tests, sometimes with the implicit suspicion that this is because the significance tests are used "wrongly". Well, my experience is, sometimes this is true and sometimes it isn't. I have seen data sets on which cross-validated prediction worked better using stepwise regression than the Lasso. If you don't have very many variables, this may not even be that exceptional. Also, when doing exploratory analysis, I like to look at p-values just to address the question as how "surprising" a find should actually be seen given a model in which nothing meaningful is going on behind it. However it is clear that this is just one bit of information, and the detailed visual impression and things such as effect sizes are still very relevant. Also of course I should not forget that "p-hacking" is going on, i.e., that the "model in which nothing meaningful is going on" is already violated to some extent by me snooping around. If I could formalise my "snooping" in advance, i.e., formulate a battery of things to test and maybe even some things to look at conditional on earlier results, I can generate data from a null model and in fact explore what kind of p-values I should expect to find in such a situation using the whole battery ($10^{-8}$ not often, I suspect). A key to suitable interpretation may be to say goodbye to the idea that significance is something inherently good and meaningful. If you look at the data in order to find significances, you will find significances many of which will likely be meaningless. We should try to address the questions that are meaningful to us using the data, and then a (strong) significance is just something of a marker for further attention.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
The problem with p-hacking in my view is not the hacking itself, but rather the interpretation of the outcome. Your professor is right saying that if you test and test and test, you will at some point
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] The problem with p-hacking in my view is not the hacking itself, but rather the interpretation of the outcome. Your professor is right saying that if you test and test and test, you will at some point find significance even if nothing is going on. This means that significances that you found in this way cannot be reliably interpreted as meaningful. However, if you get at things from an exploratory angle, this should not be the point. Whatever turns up from an exploratory analysis should not be interpreted as a meaningful final result (some people argue that significances from testing should never be interpreted in this way, but I leave this discussion out here). Rather it should be interpreted as a potential hint at something, possibly be investigated on new independent data. If you look at certain data, test one hypothesis and get $p=0.44$ and another and get $p=0.0002$, the data that you have are more critical against the second null hypothesis than against the first, and there may be something going on. This kind of information is gradual and not dichotomous; If you run lots of tests, you should know that $p=0.04$ isn't particularly convincing, $p=0.012$ or $p=0.009$ may still occasionally happen accidentally, but $p=10^{-8}$ is still quite a strong indication (unless you have so much data that basically everything becomes significant; and also always look at effect sizes!). Digression: There are formal procedures for multiple testing such as Bonferroni, Benjamini-Hochberg etc. I think it is good to know about these, because they give some information about what kind of p-value to expect in situations where multiple testing goes on. However, I think in EDA their worth is that they provide some orientation, but they shouldn't be literally followed and "trusted". They are based on simplifying assumptions (e.g., Bonferroni can be very conservative), and they can't take into account all the informal, visual snooping around that is done in EDA. Keep in mind that the "p-hacking" problem does not only come from running multiple tests, but also from running tests conditionally on informal decisions ("I run test $T$ because this connection here looks nonlinear, so I try out adding a squared term and test it"), which runs counter to the standard assumptions of the tests. (End digression.) Ultimately I'd use p-values as exploratory indicators for things that may be worthwhile investigating without interpreting them as final meaningful result. Another issue is the automatic use of multiple significance tests inside a procedure that ultimately does something else, for example a variable selection/prediction routine. You are right that the success of these procedures can be tested and validated on independent data, and the procedure can be seen as good to the extent that it leads to a model with good prediction power, if that's your ultimate aim. The issue here is the same as before: The significance tests are not interpreted as individually meaningful; i.e., you shouldn't claim that just because a model with variable $X_4$ was selected in such a procedure you have significant evidence that variable $X_4$ is important in a meaningful way. The tests here are not used as tests in the usual sense, but rather as building blocks of a method that actually does something else, and has to be assessed on its own merits. Now of course one can ask whether it is a good idea to use significance tests in situations in which they cannot be interpreted in the standard way. My answer would be: It depends. You can hear often these days that for variable selection regularisation using ideas such as the Lasso is better than stepwise selection using significance tests, sometimes with the implicit suspicion that this is because the significance tests are used "wrongly". Well, my experience is, sometimes this is true and sometimes it isn't. I have seen data sets on which cross-validated prediction worked better using stepwise regression than the Lasso. If you don't have very many variables, this may not even be that exceptional. Also, when doing exploratory analysis, I like to look at p-values just to address the question as how "surprising" a find should actually be seen given a model in which nothing meaningful is going on behind it. However it is clear that this is just one bit of information, and the detailed visual impression and things such as effect sizes are still very relevant. Also of course I should not forget that "p-hacking" is going on, i.e., that the "model in which nothing meaningful is going on" is already violated to some extent by me snooping around. If I could formalise my "snooping" in advance, i.e., formulate a battery of things to test and maybe even some things to look at conditional on earlier results, I can generate data from a null model and in fact explore what kind of p-values I should expect to find in such a situation using the whole battery ($10^{-8}$ not often, I suspect). A key to suitable interpretation may be to say goodbye to the idea that significance is something inherently good and meaningful. If you look at the data in order to find significances, you will find significances many of which will likely be meaningless. We should try to address the questions that are meaningful to us using the data, and then a (strong) significance is just something of a marker for further attention.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] The problem with p-hacking in my view is not the hacking itself, but rather the interpretation of the outcome. Your professor is right saying that if you test and test and test, you will at some point
44,341
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
Here is my take at the answer. The problem with exploratory analysis Your professor is correct - exploratory analysis, if done for long enough, will always find some trend that will seem interesting. You can easily check this yourself - just fill the data you had in class with random numbers (or shuffle it between participants so that all the real trends are gone) and perform an exploratory analysis. If you will use hypothesis testing with a traditional 0.05 p-value cut-off you should find that around every 20th result appears to be significant. But this cannot be true, since the data now is a random sea of numbers. Hence all these "findings" are false positives. The logic is quite simple - you cannot use such a procedure (extensive exploratory analysis) to claim you have found something when the same procedure would also find something where there is nothing to find. The best way to address the issue Of course in science everyone is doing exploratory analyses all the time and they are wonderful. Calculating one predefined hypothesis only would be a waste of scientific resources. Imagine we collect 1000 biopsies from cancer patients and perform gene expression analysis (which can be an experiment worth hundreds of thousands of dollars). And then we only test if one pre-selected gene is different between cases and controls. If not we throw the dataset away (because not doing so would be performing an exploratory analysis) and collect another sample to test another hypothesis. Nobody does that. The way to deal with the issue is to have a "confirmatory" dataset which is then used in order to check if the results found via exploratory phase can be replicated. In an ideal case this confirmatory dataset should come from a separate collection of samples - not merely on collection split into two (a.k.a. "tain" and "test" in machine learning). However, splitting into two is still better than having no dataset for confirmation. So the whole procedure looks like this: Collect a sample of data for exploratory analysis. Explore the trends in the data by trying anything you like to try. Out of the things you found - select a few that are strongest and most interesting. Collect another sample for confirmatory analysis. Perform a predefined test on confirmatory dataset based on what you found in step 2. Another way of dealing with the issue Another way to deal with the issue, as you have mentioned yourself, is to do a correction for multiple testing. So if in the exploratory phase you performed 100 hypothesis tests you then use something like Bonferroni correction in order to adjust the p-values such that, instead of every 20th being significant, the chance of at least one significant result out of this 100 (in a data with no real trends) would be 5% (one in 20). The issue here of course is that it is hard to track the number of performed tests in exploratory phase. Also exploration involves a lot of peaking at the data. Say you do some kind of scatter plot and you see that there is a difference between adults and children. Did you perform one test here? No. Surprisingly, you might have performed 10 tests just by one glance. Probably, unknowingly, you just checked for differences between men and women, for differences between different socioeconomic status, etc etc. And you just formally checked one that had the most chance of turning out significant. So in the end it's hard to estimate how to correct for multiple testing. On top of that many real world experiments nowadays (i.e. that gene expression example) involve multiple testing even in exploratory phases. For example imagine you are looking which genes express differently between cases and controls, between cases and controls stratified by age, between cases and controls stratified by sex, etc. Here in each stage you are checking thousands of genes at once, and you should do some form of multiple testing correction (probably something like FDR), in each exploratory step. So multiple testing is only valid in quite restricted exploratory analyses when you know how many tests you perform. Otherwise it goes out of hand. Is cross validation an answer Just like in machine learning you can't train a model on full data and then check it by doing cross validation here you cannot do exploratory analysis on whole dataset and then cross-validate the hypothesis that were significant. If the whole dataset shows a trend (real or perceived) this already predisposes all the subset of that dataset to follow this "detected" pattern. So this tells us that we have to split the data into parts before doing exploratory analysis and then perform the exploration only on one part and test on the others. But is there a need for multiple parts as in cross validation, or is one "confirmatory" dataset enough - that is a good question. I think the answer is - the more confirmations, the better. It should boil down to the probability of accepting a false-positive. If something replicates on one confirmatory dataset with a p-value of 0.05 - there is a 5% chance of a false positive. If it replicates on two the chance is 0.25%. But probably we can achieve the same thing by simply adjusting our p-value for confirmation to be below 0.05. Also here we should remember that a real confirmation comes from a different sample altogether, not the same sample split into multiple parts. Why is this not a problem with predefined hypotheses Well, no. There is a difference between testing a single hypothesis and fitting a single classifier. Classifier will go through an optimisation stage and will try to fit the data as best as it can. A predefined hypothesis in this case would be more similar to the final model of a classifier. If you have a final model (say a neural network with all weights set in place) - you can test it's performance on a dataset once, without cross validation, as there is nothing to cross-validate. Same idea here. When you have a pre-defined hypothesis it is not adapting to the data anymore. It's just testing how likely that effect is to be obtained by chance. Hence, predefined hypothesis are not potentially misleading, when calculated correctly. Also note that sample size does not change the probability of a false positive - you will have same chance to get a significant result on random data with 10 samples and with 1,000,000 samples. The main thing sample size gives you is statistical power - that is it increases the chance of detecting TRUE trends. Why is stating all the procedures and all the results not an answer Think about the proposed exploratory experiment on random data. We can do 1000 hypotheses and you would find around 50 significant trends. We can then publish these results of our exploration and say that we did a 1000, describe each of them, and we found 50 to be significant and showcase these. But all these are false positives. So merely describing how we p-hacked does not prevent us from p-hacking and there is no way to judge which of these results are true, if any.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
Here is my take at the answer. The problem with exploratory analysis Your professor is correct - exploratory analysis, if done for long enough, will always find some trend that will seem interesting.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] Here is my take at the answer. The problem with exploratory analysis Your professor is correct - exploratory analysis, if done for long enough, will always find some trend that will seem interesting. You can easily check this yourself - just fill the data you had in class with random numbers (or shuffle it between participants so that all the real trends are gone) and perform an exploratory analysis. If you will use hypothesis testing with a traditional 0.05 p-value cut-off you should find that around every 20th result appears to be significant. But this cannot be true, since the data now is a random sea of numbers. Hence all these "findings" are false positives. The logic is quite simple - you cannot use such a procedure (extensive exploratory analysis) to claim you have found something when the same procedure would also find something where there is nothing to find. The best way to address the issue Of course in science everyone is doing exploratory analyses all the time and they are wonderful. Calculating one predefined hypothesis only would be a waste of scientific resources. Imagine we collect 1000 biopsies from cancer patients and perform gene expression analysis (which can be an experiment worth hundreds of thousands of dollars). And then we only test if one pre-selected gene is different between cases and controls. If not we throw the dataset away (because not doing so would be performing an exploratory analysis) and collect another sample to test another hypothesis. Nobody does that. The way to deal with the issue is to have a "confirmatory" dataset which is then used in order to check if the results found via exploratory phase can be replicated. In an ideal case this confirmatory dataset should come from a separate collection of samples - not merely on collection split into two (a.k.a. "tain" and "test" in machine learning). However, splitting into two is still better than having no dataset for confirmation. So the whole procedure looks like this: Collect a sample of data for exploratory analysis. Explore the trends in the data by trying anything you like to try. Out of the things you found - select a few that are strongest and most interesting. Collect another sample for confirmatory analysis. Perform a predefined test on confirmatory dataset based on what you found in step 2. Another way of dealing with the issue Another way to deal with the issue, as you have mentioned yourself, is to do a correction for multiple testing. So if in the exploratory phase you performed 100 hypothesis tests you then use something like Bonferroni correction in order to adjust the p-values such that, instead of every 20th being significant, the chance of at least one significant result out of this 100 (in a data with no real trends) would be 5% (one in 20). The issue here of course is that it is hard to track the number of performed tests in exploratory phase. Also exploration involves a lot of peaking at the data. Say you do some kind of scatter plot and you see that there is a difference between adults and children. Did you perform one test here? No. Surprisingly, you might have performed 10 tests just by one glance. Probably, unknowingly, you just checked for differences between men and women, for differences between different socioeconomic status, etc etc. And you just formally checked one that had the most chance of turning out significant. So in the end it's hard to estimate how to correct for multiple testing. On top of that many real world experiments nowadays (i.e. that gene expression example) involve multiple testing even in exploratory phases. For example imagine you are looking which genes express differently between cases and controls, between cases and controls stratified by age, between cases and controls stratified by sex, etc. Here in each stage you are checking thousands of genes at once, and you should do some form of multiple testing correction (probably something like FDR), in each exploratory step. So multiple testing is only valid in quite restricted exploratory analyses when you know how many tests you perform. Otherwise it goes out of hand. Is cross validation an answer Just like in machine learning you can't train a model on full data and then check it by doing cross validation here you cannot do exploratory analysis on whole dataset and then cross-validate the hypothesis that were significant. If the whole dataset shows a trend (real or perceived) this already predisposes all the subset of that dataset to follow this "detected" pattern. So this tells us that we have to split the data into parts before doing exploratory analysis and then perform the exploration only on one part and test on the others. But is there a need for multiple parts as in cross validation, or is one "confirmatory" dataset enough - that is a good question. I think the answer is - the more confirmations, the better. It should boil down to the probability of accepting a false-positive. If something replicates on one confirmatory dataset with a p-value of 0.05 - there is a 5% chance of a false positive. If it replicates on two the chance is 0.25%. But probably we can achieve the same thing by simply adjusting our p-value for confirmation to be below 0.05. Also here we should remember that a real confirmation comes from a different sample altogether, not the same sample split into multiple parts. Why is this not a problem with predefined hypotheses Well, no. There is a difference between testing a single hypothesis and fitting a single classifier. Classifier will go through an optimisation stage and will try to fit the data as best as it can. A predefined hypothesis in this case would be more similar to the final model of a classifier. If you have a final model (say a neural network with all weights set in place) - you can test it's performance on a dataset once, without cross validation, as there is nothing to cross-validate. Same idea here. When you have a pre-defined hypothesis it is not adapting to the data anymore. It's just testing how likely that effect is to be obtained by chance. Hence, predefined hypothesis are not potentially misleading, when calculated correctly. Also note that sample size does not change the probability of a false positive - you will have same chance to get a significant result on random data with 10 samples and with 1,000,000 samples. The main thing sample size gives you is statistical power - that is it increases the chance of detecting TRUE trends. Why is stating all the procedures and all the results not an answer Think about the proposed exploratory experiment on random data. We can do 1000 hypotheses and you would find around 50 significant trends. We can then publish these results of our exploration and say that we did a 1000, describe each of them, and we found 50 to be significant and showcase these. But all these are false positives. So merely describing how we p-hacked does not prevent us from p-hacking and there is no way to judge which of these results are true, if any.
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] Here is my take at the answer. The problem with exploratory analysis Your professor is correct - exploratory analysis, if done for long enough, will always find some trend that will seem interesting.
44,342
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
couldn't procedures like Cross Validation be used Yes, p-hacking, can certainly be reduced by tests like these that represent the significance correctly. But that's the whole point about p-hacking, it is the case when such techniques as cross validation are not used and when the expression of the statistical significance is corrupted by ignoring the multiple repetitions that are used to observe some result. P-hacking is a mistake where we do not express significance correctly or out of context. Sure this mistake can be 'solved' by not making the mistake β€” by expressing the significance correctly or by adding more independent data to test significance of a potential effect. sidenote: Cross validation can itself be prone to p-hacking as the same validation set is fitted by multiple models (the point of cross validation is to select a test that has the best generalising performance, a best balance between variance and bias). It is another (third) test dataset, which is only used once on a single model, that gives the correct indication of statistical significance. (What is the difference between test set and validation set?)
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed]
couldn't procedures like Cross Validation be used Yes, p-hacking, can certainly be reduced by tests like these that represent the significance correctly. But that's the whole point about p-hacking, i
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] couldn't procedures like Cross Validation be used Yes, p-hacking, can certainly be reduced by tests like these that represent the significance correctly. But that's the whole point about p-hacking, it is the case when such techniques as cross validation are not used and when the expression of the statistical significance is corrupted by ignoring the multiple repetitions that are used to observe some result. P-hacking is a mistake where we do not express significance correctly or out of context. Sure this mistake can be 'solved' by not making the mistake β€” by expressing the significance correctly or by adding more independent data to test significance of a potential effect. sidenote: Cross validation can itself be prone to p-hacking as the same validation set is fitted by multiple models (the point of cross validation is to select a test that has the best generalising performance, a best balance between variance and bias). It is another (third) test dataset, which is only used once on a single model, that gives the correct indication of statistical significance. (What is the difference between test set and validation set?)
Is "Exploratory Data Analysis" Fundamentally At Odds With "P-Hacking"? [closed] couldn't procedures like Cross Validation be used Yes, p-hacking, can certainly be reduced by tests like these that represent the significance correctly. But that's the whole point about p-hacking, i
44,343
Is more data really always better in machine learning?
You are right, it is not only about the size of the dataset. As two other answers pointed out, having more data (vs very little) is desired, as even in a noiseless scenario it may help you to get a more precise estimate. On another hand, as you argue, it is also about the quality of the data. There's a great lecture by Xiao-Li Meng titled "Statistical paradises and paradoxes in Big Data", it was recorded and is available on YouTube. He argues that it is not only about quantity, but also quality. Having a lot of very poor quality or biased data is not necessarily great. As he shows, how much you gain from the quantity raises very slowly. That's one of the reasons why we need all those poor-quality, non-randomly sampled datasets, scrapped from the internet to be so big. On another hand, as he argues, having a large dataset can lead to overtly optimistic error estimates, which could give us a false sense of the estimates being precise. So in fact, there may be scenarios where "too much" data is not great. So it is not (only) about quantity, but also if the data is relevant, not biased, how noisy it is, if it was randomly sampled, etc, i.e. about the quality of the data. If you have good quality data, more is better, though at some point you start hitting diminishing returns, where getting more data is simply not worth it.
Is more data really always better in machine learning?
You are right, it is not only about the size of the dataset. As two other answers pointed out, having more data (vs very little) is desired, as even in a noiseless scenario it may help you to get a mo
Is more data really always better in machine learning? You are right, it is not only about the size of the dataset. As two other answers pointed out, having more data (vs very little) is desired, as even in a noiseless scenario it may help you to get a more precise estimate. On another hand, as you argue, it is also about the quality of the data. There's a great lecture by Xiao-Li Meng titled "Statistical paradises and paradoxes in Big Data", it was recorded and is available on YouTube. He argues that it is not only about quantity, but also quality. Having a lot of very poor quality or biased data is not necessarily great. As he shows, how much you gain from the quantity raises very slowly. That's one of the reasons why we need all those poor-quality, non-randomly sampled datasets, scrapped from the internet to be so big. On another hand, as he argues, having a large dataset can lead to overtly optimistic error estimates, which could give us a false sense of the estimates being precise. So in fact, there may be scenarios where "too much" data is not great. So it is not (only) about quantity, but also if the data is relevant, not biased, how noisy it is, if it was randomly sampled, etc, i.e. about the quality of the data. If you have good quality data, more is better, though at some point you start hitting diminishing returns, where getting more data is simply not worth it.
Is more data really always better in machine learning? You are right, it is not only about the size of the dataset. As two other answers pointed out, having more data (vs very little) is desired, as even in a noiseless scenario it may help you to get a mo
44,344
Is more data really always better in machine learning?
Intuitively, having more data will tell the neural network where to turn, by how much, and in what direction (up/down, left/right, combinations, extensions in high-dimension spaces, etc). Imagine your true function to be a parabola. However, you only have two data points. You have no way to capture the curvature. You cannot figure out if the parabola opens up or down. You cannot figure out how wide the parabola is. When you add a third point, you can start to figure out some of this. However, that assumes you know the shape to be a parabola. If you do not know the function, how can you distinguish that from something like an absolute value function that uses straight lines? By having more data, you provide more opportunities to penalize the network for turning incorrectly, even if the fit on fewer points is perfect. This sounds like resolution, and I suspect that there is a way to tie this notion to the Nyquist rate and Nyquist–Shannon sampling theorem in signal processing (or some generalization to higher-dimension spaces) to bring full mathematical rigor.
Is more data really always better in machine learning?
Intuitively, having more data will tell the neural network where to turn, by how much, and in what direction (up/down, left/right, combinations, extensions in high-dimension spaces, etc). Imagine your
Is more data really always better in machine learning? Intuitively, having more data will tell the neural network where to turn, by how much, and in what direction (up/down, left/right, combinations, extensions in high-dimension spaces, etc). Imagine your true function to be a parabola. However, you only have two data points. You have no way to capture the curvature. You cannot figure out if the parabola opens up or down. You cannot figure out how wide the parabola is. When you add a third point, you can start to figure out some of this. However, that assumes you know the shape to be a parabola. If you do not know the function, how can you distinguish that from something like an absolute value function that uses straight lines? By having more data, you provide more opportunities to penalize the network for turning incorrectly, even if the fit on fewer points is perfect. This sounds like resolution, and I suspect that there is a way to tie this notion to the Nyquist rate and Nyquist–Shannon sampling theorem in signal processing (or some generalization to higher-dimension spaces) to bring full mathematical rigor.
Is more data really always better in machine learning? Intuitively, having more data will tell the neural network where to turn, by how much, and in what direction (up/down, left/right, combinations, extensions in high-dimension spaces, etc). Imagine your
44,345
Is more data really always better in machine learning?
My intuition is that, given $(x_{i},y_{i})_{i=1}^n$ and $(x_{i},y_{i})_{i=1}^N$ have the same "information" (I know this is a fuzzy term), using $(x_{i},y_{i})_{i=1}^N$ should not better the fit. It should even make generalisation worse since we overfit. At first I was skeptical, thinking 'how can you overfit if there is no noise'. But with a misspecified model this is possible. Here is a situation where more data can lead to "overfitting": It is not overfitting due to fitting of random noise, but overfitting due to the model being misspecified and the bias of interpolation is increasing as the fitted curve can become less smooth (this is a case with polynomials, but a similar effect may occur when fitting with some NN, or the NN might even contain those polynomials as output). It might not be unimaginable that this situation can be remedied by considering regularization and cross validation. In that case one might expect that more data should reduce the bias.
Is more data really always better in machine learning?
My intuition is that, given $(x_{i},y_{i})_{i=1}^n$ and $(x_{i},y_{i})_{i=1}^N$ have the same "information" (I know this is a fuzzy term), using $(x_{i},y_{i})_{i=1}^N$ should not better the fit. It s
Is more data really always better in machine learning? My intuition is that, given $(x_{i},y_{i})_{i=1}^n$ and $(x_{i},y_{i})_{i=1}^N$ have the same "information" (I know this is a fuzzy term), using $(x_{i},y_{i})_{i=1}^N$ should not better the fit. It should even make generalisation worse since we overfit. At first I was skeptical, thinking 'how can you overfit if there is no noise'. But with a misspecified model this is possible. Here is a situation where more data can lead to "overfitting": It is not overfitting due to fitting of random noise, but overfitting due to the model being misspecified and the bias of interpolation is increasing as the fitted curve can become less smooth (this is a case with polynomials, but a similar effect may occur when fitting with some NN, or the NN might even contain those polynomials as output). It might not be unimaginable that this situation can be remedied by considering regularization and cross validation. In that case one might expect that more data should reduce the bias.
Is more data really always better in machine learning? My intuition is that, given $(x_{i},y_{i})_{i=1}^n$ and $(x_{i},y_{i})_{i=1}^N$ have the same "information" (I know this is a fuzzy term), using $(x_{i},y_{i})_{i=1}^N$ should not better the fit. It s
44,346
Misuse of mixed effects model
The misunderstanding here is in how random intercepts are modeled. They aren't confounded with the diagnosis predictor in the way that you fear. The random intercepts are modeled as a Gaussian distribution with a mean of 0. They are not modeled individually in the same way as the fixed effects diagnosis and sequencing_saturation. The model finds the variance of that Gaussian distribution (around 0) that best fits the data along with the fixed effects. That restriction to zero mean allows the fixed-effect coefficients to represent the values when $u=0$ in your terminology. The distribution of random effects then represents the additional contributions of the sample_ids around those fixed-effect predictions. That said, there certainly can be problems with over-specification of models like this. From what you say of the Belonwu et al. paper, the problem there seems to be that the batch and diagnosis fixed-effect values are linearly dependent. That would be a problem for standard linear regression and has nothing to do with mixed modeling.
Misuse of mixed effects model
The misunderstanding here is in how random intercepts are modeled. They aren't confounded with the diagnosis predictor in the way that you fear. The random intercepts are modeled as a Gaussian distrib
Misuse of mixed effects model The misunderstanding here is in how random intercepts are modeled. They aren't confounded with the diagnosis predictor in the way that you fear. The random intercepts are modeled as a Gaussian distribution with a mean of 0. They are not modeled individually in the same way as the fixed effects diagnosis and sequencing_saturation. The model finds the variance of that Gaussian distribution (around 0) that best fits the data along with the fixed effects. That restriction to zero mean allows the fixed-effect coefficients to represent the values when $u=0$ in your terminology. The distribution of random effects then represents the additional contributions of the sample_ids around those fixed-effect predictions. That said, there certainly can be problems with over-specification of models like this. From what you say of the Belonwu et al. paper, the problem there seems to be that the batch and diagnosis fixed-effect values are linearly dependent. That would be a problem for standard linear regression and has nothing to do with mixed modeling.
Misuse of mixed effects model The misunderstanding here is in how random intercepts are modeled. They aren't confounded with the diagnosis predictor in the way that you fear. The random intercepts are modeled as a Gaussian distrib
44,347
Misuse of mixed effects model
You are missing something fundamental about mixed models; the model does not look erroneous to me: adding diagnosis to the model gives you the effect of the diagnosis, adding the random intercept just gives you random variation around that effect. eg if effect of diagnosis is +5 then all individuals with the diagnosis will be "around" +5 and all non-diagnosed will be around 0. "In other words, if you know the sample ID, then you know the diagnosis." but you do not know the effect of the diagnosis which is what is measured in the model by the coefficient for diagnosis EDIT: From your comment: " It is still my understanding that when removing the variation from sample id and fitting the model, that the variation explained by diagnosis is also removed. This is because diagnosis does not vary within a sample." This is not true. Imagine you didn't have the sample ids and you (incorrectly) assumed all the observations were independent (ie did not include the random intercept). But you did know the diagnosis. Lets ignore the other variable sequencing_saturation for now. If you plot the dependent variable by diagnosis you would see a difference (in your simulation a +10 difference). Your comment is suggesting that in that scenario you would expect the estimated effect of diagnosis to be 0, which doesn't make sense.
Misuse of mixed effects model
You are missing something fundamental about mixed models; the model does not look erroneous to me: adding diagnosis to the model gives you the effect of the diagnosis, adding the random intercept just
Misuse of mixed effects model You are missing something fundamental about mixed models; the model does not look erroneous to me: adding diagnosis to the model gives you the effect of the diagnosis, adding the random intercept just gives you random variation around that effect. eg if effect of diagnosis is +5 then all individuals with the diagnosis will be "around" +5 and all non-diagnosed will be around 0. "In other words, if you know the sample ID, then you know the diagnosis." but you do not know the effect of the diagnosis which is what is measured in the model by the coefficient for diagnosis EDIT: From your comment: " It is still my understanding that when removing the variation from sample id and fitting the model, that the variation explained by diagnosis is also removed. This is because diagnosis does not vary within a sample." This is not true. Imagine you didn't have the sample ids and you (incorrectly) assumed all the observations were independent (ie did not include the random intercept). But you did know the diagnosis. Lets ignore the other variable sequencing_saturation for now. If you plot the dependent variable by diagnosis you would see a difference (in your simulation a +10 difference). Your comment is suggesting that in that scenario you would expect the estimated effect of diagnosis to be 0, which doesn't make sense.
Misuse of mixed effects model You are missing something fundamental about mixed models; the model does not look erroneous to me: adding diagnosis to the model gives you the effect of the diagnosis, adding the random intercept just
44,348
Simple linear regressions among three pairs of variables
First, it is possible for these conditions simultaneously to hold, as I will show. Second, the regression of $Y$ on $X+Z$ must lie in the open interval $(10/9,2)$ and can attain any value in that interval. Vector notation is particularly convenient here. The given information tells us (in the order given in the question) that $Y = 2X + E$ where $E$ is orthogonal to $X.$ $Y = 2Z + \beta W + F$ where $F$ is orthogonal to $Z$ and $W$ (and $\beta$ is at this point unknown). $X = 2Z + W$ where $W$ is a zero-sum vector orthogonal to $Z.$ Implicitly, not all of $X,Y,$ and $Z$ are zero, for otherwise there's nothing of interest: we would just be saying, three times over, that $2$ times the zero vector is zero; and then there would be no bounds on the regression of $Y$ against $X+Z.$ Consequently, all of these vectors must be nonzero. To find $\beta,$ use $(2)$ to regress $Y$ on $X$ as $$2 = \hat\beta_{Y;X} = \frac{Y\cdot X}{||X||^2} = \frac{4||Z||^2 + \beta||W||^2}{4||Z||^2 + ||W||^2}.$$ When $W\ne 0,$ the unique solution is $$\beta = 2 + \frac{4||Z||^2}{||W||^2}.$$ (When $W=0$ the equation reads $2=1,$ which has no solutions.) We may now compute the regression of $Y$ against $X+Z$ as $$\hat\beta_{Y;X+Z} = \frac{Y\cdot(X+Z)}{||X+Z||^2} = \frac{(2Z+\beta W + F)\cdot(3Z + W)}{||3Z + W||^2} = \frac{10||Z||^2 + 2||W||^2}{9||Z||^2 + ||W||^2}.$$ The right hand fraction is the slope of a ray emanating from the origin and passing through some point in the interior of the segment connecting the points $(10,9)$ and $(2,1)$ in the plane (with the weights given by the relative values of $||Z||^2$ and $||W||^2$), making it obvious the bounds are $10/9$ and $2/1$ -- and they cannot be attained because both weights are nonzero, QED. Here is a histogram of the regression coefficients for a thousand simulated configurations (in $\mathbb{R}^{10}$): The red vertical lines mark the bounds. The simulation supports these by exhibiting a full range of values filling these bounds but never extending beyond them. The R code shows how the foregoing analysis was implemented. (It includes a post-simulation check that all the given regression coefficients equal $2,$ as intended.) z <- scale(c(1, rep(0,9))) z <- z / sqrt(length(z)-1) # Must be zero mean, unit norm set.seed(17) sim <- replicate(1e3, { w <- rexp(length(z)) w <- residuals(lm(w ~ z)) w2 <- sum(w*w) y <- 2 * z + (4/w2 + 2)*w x <- 2*z + w a <- coefficients(lm(y ~ x + 0)) b <- coefficients(lm(y ~ z + 0)) c. <- coefficients(lm(x ~ z + 0)) d <- coefficients(lm(y ~ I(x+z) + 0)) c(a,b,c.,d) }) table(sim[1:3,]) # All 2 hist(sim[4,], xlim=c(10/9,2), breaks=seq(10/9, 2, by=1/18), freq=FALSE, col=gray(.9), xlab="Value", main=expression(hat(beta)[group("", list(Y, X+Z), "")])) abline(v=c(10/9, 2), col="Red", lwd=2, lty=2)
Simple linear regressions among three pairs of variables
First, it is possible for these conditions simultaneously to hold, as I will show. Second, the regression of $Y$ on $X+Z$ must lie in the open interval $(10/9,2)$ and can attain any value in that inte
Simple linear regressions among three pairs of variables First, it is possible for these conditions simultaneously to hold, as I will show. Second, the regression of $Y$ on $X+Z$ must lie in the open interval $(10/9,2)$ and can attain any value in that interval. Vector notation is particularly convenient here. The given information tells us (in the order given in the question) that $Y = 2X + E$ where $E$ is orthogonal to $X.$ $Y = 2Z + \beta W + F$ where $F$ is orthogonal to $Z$ and $W$ (and $\beta$ is at this point unknown). $X = 2Z + W$ where $W$ is a zero-sum vector orthogonal to $Z.$ Implicitly, not all of $X,Y,$ and $Z$ are zero, for otherwise there's nothing of interest: we would just be saying, three times over, that $2$ times the zero vector is zero; and then there would be no bounds on the regression of $Y$ against $X+Z.$ Consequently, all of these vectors must be nonzero. To find $\beta,$ use $(2)$ to regress $Y$ on $X$ as $$2 = \hat\beta_{Y;X} = \frac{Y\cdot X}{||X||^2} = \frac{4||Z||^2 + \beta||W||^2}{4||Z||^2 + ||W||^2}.$$ When $W\ne 0,$ the unique solution is $$\beta = 2 + \frac{4||Z||^2}{||W||^2}.$$ (When $W=0$ the equation reads $2=1,$ which has no solutions.) We may now compute the regression of $Y$ against $X+Z$ as $$\hat\beta_{Y;X+Z} = \frac{Y\cdot(X+Z)}{||X+Z||^2} = \frac{(2Z+\beta W + F)\cdot(3Z + W)}{||3Z + W||^2} = \frac{10||Z||^2 + 2||W||^2}{9||Z||^2 + ||W||^2}.$$ The right hand fraction is the slope of a ray emanating from the origin and passing through some point in the interior of the segment connecting the points $(10,9)$ and $(2,1)$ in the plane (with the weights given by the relative values of $||Z||^2$ and $||W||^2$), making it obvious the bounds are $10/9$ and $2/1$ -- and they cannot be attained because both weights are nonzero, QED. Here is a histogram of the regression coefficients for a thousand simulated configurations (in $\mathbb{R}^{10}$): The red vertical lines mark the bounds. The simulation supports these by exhibiting a full range of values filling these bounds but never extending beyond them. The R code shows how the foregoing analysis was implemented. (It includes a post-simulation check that all the given regression coefficients equal $2,$ as intended.) z <- scale(c(1, rep(0,9))) z <- z / sqrt(length(z)-1) # Must be zero mean, unit norm set.seed(17) sim <- replicate(1e3, { w <- rexp(length(z)) w <- residuals(lm(w ~ z)) w2 <- sum(w*w) y <- 2 * z + (4/w2 + 2)*w x <- 2*z + w a <- coefficients(lm(y ~ x + 0)) b <- coefficients(lm(y ~ z + 0)) c. <- coefficients(lm(x ~ z + 0)) d <- coefficients(lm(y ~ I(x+z) + 0)) c(a,b,c.,d) }) table(sim[1:3,]) # All 2 hist(sim[4,], xlim=c(10/9,2), breaks=seq(10/9, 2, by=1/18), freq=FALSE, col=gray(.9), xlab="Value", main=expression(hat(beta)[group("", list(Y, X+Z), "")])) abline(v=c(10/9, 2), col="Red", lwd=2, lty=2)
Simple linear regressions among three pairs of variables First, it is possible for these conditions simultaneously to hold, as I will show. Second, the regression of $Y$ on $X+Z$ must lie in the open interval $(10/9,2)$ and can attain any value in that inte
44,349
Simple linear regressions among three pairs of variables
Note: OP states there is likely an error in the original question. My answer assumes everything OP states is correct thus the following answer may be incorrect Let's focus on the denominator of the final expression. Let $$A = \sum_{i = 1}^n x_i^2 + 2x_i z_i + z_i^2$$ If we can show that $A > 2$ then we know that $\hat{\beta}_{Y, X+Z} = \frac{4}{A} < 2$. Now you've assumed that $\sum_{i=1}^n x_i z_i = 2$. We also know that each $x_i^2$, $z_i^2$ $\geq 0$. Therefore: \begin{align} A &= \sum_{i = 1}^n x_i^2 + 2x_i z_i + z_i^2 \\ &= \sum_{i = 1}^n x_i^2 + 2\sum_{i = 1}^nx_i z_i + \sum_{i = 1}^n z_i^2 \\ &\geq \sum_{i = 1}^n 0 + 2 \times 2 + \sum_{i = 1}^n 0 \end{align} (because $x_i^2, z_i^2 \geq 0$ and $\sum x_i z_i = 2$) $$ \geq 4$$ Now since $A > 4$ (and specifically, $A > 2$) we can conclude that $\hat{\beta}_{X, Y+X} < 2$
Simple linear regressions among three pairs of variables
Note: OP states there is likely an error in the original question. My answer assumes everything OP states is correct thus the following answer may be incorrect Let's focus on the denominator of the fi
Simple linear regressions among three pairs of variables Note: OP states there is likely an error in the original question. My answer assumes everything OP states is correct thus the following answer may be incorrect Let's focus on the denominator of the final expression. Let $$A = \sum_{i = 1}^n x_i^2 + 2x_i z_i + z_i^2$$ If we can show that $A > 2$ then we know that $\hat{\beta}_{Y, X+Z} = \frac{4}{A} < 2$. Now you've assumed that $\sum_{i=1}^n x_i z_i = 2$. We also know that each $x_i^2$, $z_i^2$ $\geq 0$. Therefore: \begin{align} A &= \sum_{i = 1}^n x_i^2 + 2x_i z_i + z_i^2 \\ &= \sum_{i = 1}^n x_i^2 + 2\sum_{i = 1}^nx_i z_i + \sum_{i = 1}^n z_i^2 \\ &\geq \sum_{i = 1}^n 0 + 2 \times 2 + \sum_{i = 1}^n 0 \end{align} (because $x_i^2, z_i^2 \geq 0$ and $\sum x_i z_i = 2$) $$ \geq 4$$ Now since $A > 4$ (and specifically, $A > 2$) we can conclude that $\hat{\beta}_{X, Y+X} < 2$
Simple linear regressions among three pairs of variables Note: OP states there is likely an error in the original question. My answer assumes everything OP states is correct thus the following answer may be incorrect Let's focus on the denominator of the fi
44,350
What is the probability of having all wealth concentrated into one single pocket after n trades?
it's a rigged game :) you have an absorbing state: one guy got all money. if somehow at any given moment one guy got all the money, then nobody has anything left to trade, and the game stops. it's pretty much certainty that if you play long enough this is bound to happen eventually, i.e. at some point you'll observe the sequence of trades that will lead to all money in one pocket. this is not about the equilibrium, this is related to a problem known as first-hitting-time in a random walk. there's actually another absorbing state if we disallow short selling and margin trading: a player hits zero wealth and stops trading, while others continue trading. that's why estimating probabilities in the game with more than two traders is not straightforward, you must account for players dropping off over time
What is the probability of having all wealth concentrated into one single pocket after n trades?
it's a rigged game :) you have an absorbing state: one guy got all money. if somehow at any given moment one guy got all the money, then nobody has anything left to trade, and the game stops. it's pre
What is the probability of having all wealth concentrated into one single pocket after n trades? it's a rigged game :) you have an absorbing state: one guy got all money. if somehow at any given moment one guy got all the money, then nobody has anything left to trade, and the game stops. it's pretty much certainty that if you play long enough this is bound to happen eventually, i.e. at some point you'll observe the sequence of trades that will lead to all money in one pocket. this is not about the equilibrium, this is related to a problem known as first-hitting-time in a random walk. there's actually another absorbing state if we disallow short selling and margin trading: a player hits zero wealth and stops trading, while others continue trading. that's why estimating probabilities in the game with more than two traders is not straightforward, you must account for players dropping off over time
What is the probability of having all wealth concentrated into one single pocket after n trades? it's a rigged game :) you have an absorbing state: one guy got all money. if somehow at any given moment one guy got all the money, then nobody has anything left to trade, and the game stops. it's pre
44,351
What is the probability of having all wealth concentrated into one single pocket after n trades?
Here is an order-of-magnitude calculation of how long it takes to have only one player remaining. For any player, let $p$ be the probability that they have exited the game after $n$ turns. So the probability that $8$ players have exited and $2$ remain is $45p^8(1-p)^2$. The probability that $9$ players have exited and $1$ remains is $10p^9(1-p)$. The most likely scenario is that there is only one player remaining when $10p>45(1-p)$, i.e. when $p>9/11$. An exit occurs when a player goes to negative wealth. By the reflection principle, a player has a $9/11$ probability of negative wealth by the $n^{th}$ turn iff they have a $9/22$ probability of negative wealth at the $n^{th}$ turn. Since the standard deviation of their wealth is $\sqrt{n}$ after $n$ turns, this happens if $$\frac{9}{22}=.409=\Phi\left(\frac{-100}{\sqrt{n}}\right)$$ $$-0.23=\frac{-100}{\sqrt{n}}$$ $$n\sim 189000$$ where $\Phi$ is the cumulative normal probability. So, by this estimate, the modal scenario is that all but one player has dropped out after 189000 turns, which is the same order of magnitude as the 70000 that you found in your experiment.
What is the probability of having all wealth concentrated into one single pocket after n trades?
Here is an order-of-magnitude calculation of how long it takes to have only one player remaining. For any player, let $p$ be the probability that they have exited the game after $n$ turns. So the prob
What is the probability of having all wealth concentrated into one single pocket after n trades? Here is an order-of-magnitude calculation of how long it takes to have only one player remaining. For any player, let $p$ be the probability that they have exited the game after $n$ turns. So the probability that $8$ players have exited and $2$ remain is $45p^8(1-p)^2$. The probability that $9$ players have exited and $1$ remains is $10p^9(1-p)$. The most likely scenario is that there is only one player remaining when $10p>45(1-p)$, i.e. when $p>9/11$. An exit occurs when a player goes to negative wealth. By the reflection principle, a player has a $9/11$ probability of negative wealth by the $n^{th}$ turn iff they have a $9/22$ probability of negative wealth at the $n^{th}$ turn. Since the standard deviation of their wealth is $\sqrt{n}$ after $n$ turns, this happens if $$\frac{9}{22}=.409=\Phi\left(\frac{-100}{\sqrt{n}}\right)$$ $$-0.23=\frac{-100}{\sqrt{n}}$$ $$n\sim 189000$$ where $\Phi$ is the cumulative normal probability. So, by this estimate, the modal scenario is that all but one player has dropped out after 189000 turns, which is the same order of magnitude as the 70000 that you found in your experiment.
What is the probability of having all wealth concentrated into one single pocket after n trades? Here is an order-of-magnitude calculation of how long it takes to have only one player remaining. For any player, let $p$ be the probability that they have exited the game after $n$ turns. So the prob
44,352
What is the probability of having all wealth concentrated into one single pocket after n trades?
The answer by Aksakal already explains it enough why the wealth is ending up into one single pocket. In this answer we elaborate a bit further on the quantitative approach by Matt F. One could compute the probability in terms of the probability of a specific player remaining in the game and consider the position of the players independent. Then there are two ways The probability that only one player is in the game is equal to the probability that a player has reached the maximum amount of money. Let's call the probability for an independent player to win $p_{win}$. The probability that none of the players have won is $$(1-p_{win})^n$$ The probability that only one player is in the game is equal to the probability that no more than $n-2$ players have lost their money yet. Let's call this probability for an independent player to loose $p_{loose}$. The probability that none of the players have won, is the probability that less than 9 have lost and is $$1-(p_{loose})^{n}-n(1-p_{loose})(p_{loose})^{n-1}$$ However, when I apply these formulas then I get small discrepancies. One way overestimates the number of trials before the game ends, and the other underestimates it. The reason for the discrepancy is that the scores of the individual players are correlated. If one player has lost after $n$ games, then this reduces the probability for the other players to have lost after $n$ games. In the image, we also plotted an inverse Gaussian distribution fitted with the method of moments, and it seems to agree reasonably well with the shape of the distribution determined from the simulations. So possibly an inverse gaussian could be used as a model for the distribution (but one would still need to figure out the mean and variance). ### function to simulate game sim = function(k=100,n=5) { # x: is a variable that keeps track of values, # the size of this variable will reduce # once participants hit zero x = rep(k,n) ### n_active: number of active participants ### these equals the lenght of 'x' but we do not ### want to compute that length everytime n_active = n ### counts: keeping track of the number of games counts = 0 while (n_active>1) { counts = counts + 1 ### sample two players s = sample(1:n_active,2) ### add +1 and -1 to the wealth of the players x[s] = x[s] + c(1,-1) ### check for zero wealth and remove the participant from 'x' if neccesary if (x[s[1]]==0) { x = x[-s[1]] n_active = n_active -1 } if (x[s[2]]==0) { x = x[-s[2]] n_active = n_active -1 } } return(counts) } ### simulations set.seed(1) y = replicate(10^3,sim()) ### plot histogram hist(y, breaks = seq(0,10^6,10^4), main = "histogram of simulations \n compared with approximations") ### add estimates based on an individual's probability to loose or win after n turns n = seq(0,10^6,10^4) p1 = pnorm(500,mean = 100,sd = sqrt(0.4*n))-pnorm(-500,mean = 100,sd = sqrt(0.4*n)) lines(n[-1],-diff(p1^5)*10^3, col = 2) p2 = pnorm(0,mean = 100,sd = sqrt(0.4*n))*2 lines(n[-1],-diff(pbinom(1,5,p2))*10^3, col = 3) ### add inverse gaussian curve fitted with method of moments lines(n,statmod::dinvgauss(n, mean(y), dispersion = var(y)/mean(y)^3)*10^7, col = 4) legend(4*10^5, 80, c("estimate based on probability of winning", "estimate based on probability of loosing", "inverse Gauss distribution"), cex = 0.7, col = c(2,3,4), lty = 1)
What is the probability of having all wealth concentrated into one single pocket after n trades?
The answer by Aksakal already explains it enough why the wealth is ending up into one single pocket. In this answer we elaborate a bit further on the quantitative approach by Matt F. One could compute
What is the probability of having all wealth concentrated into one single pocket after n trades? The answer by Aksakal already explains it enough why the wealth is ending up into one single pocket. In this answer we elaborate a bit further on the quantitative approach by Matt F. One could compute the probability in terms of the probability of a specific player remaining in the game and consider the position of the players independent. Then there are two ways The probability that only one player is in the game is equal to the probability that a player has reached the maximum amount of money. Let's call the probability for an independent player to win $p_{win}$. The probability that none of the players have won is $$(1-p_{win})^n$$ The probability that only one player is in the game is equal to the probability that no more than $n-2$ players have lost their money yet. Let's call this probability for an independent player to loose $p_{loose}$. The probability that none of the players have won, is the probability that less than 9 have lost and is $$1-(p_{loose})^{n}-n(1-p_{loose})(p_{loose})^{n-1}$$ However, when I apply these formulas then I get small discrepancies. One way overestimates the number of trials before the game ends, and the other underestimates it. The reason for the discrepancy is that the scores of the individual players are correlated. If one player has lost after $n$ games, then this reduces the probability for the other players to have lost after $n$ games. In the image, we also plotted an inverse Gaussian distribution fitted with the method of moments, and it seems to agree reasonably well with the shape of the distribution determined from the simulations. So possibly an inverse gaussian could be used as a model for the distribution (but one would still need to figure out the mean and variance). ### function to simulate game sim = function(k=100,n=5) { # x: is a variable that keeps track of values, # the size of this variable will reduce # once participants hit zero x = rep(k,n) ### n_active: number of active participants ### these equals the lenght of 'x' but we do not ### want to compute that length everytime n_active = n ### counts: keeping track of the number of games counts = 0 while (n_active>1) { counts = counts + 1 ### sample two players s = sample(1:n_active,2) ### add +1 and -1 to the wealth of the players x[s] = x[s] + c(1,-1) ### check for zero wealth and remove the participant from 'x' if neccesary if (x[s[1]]==0) { x = x[-s[1]] n_active = n_active -1 } if (x[s[2]]==0) { x = x[-s[2]] n_active = n_active -1 } } return(counts) } ### simulations set.seed(1) y = replicate(10^3,sim()) ### plot histogram hist(y, breaks = seq(0,10^6,10^4), main = "histogram of simulations \n compared with approximations") ### add estimates based on an individual's probability to loose or win after n turns n = seq(0,10^6,10^4) p1 = pnorm(500,mean = 100,sd = sqrt(0.4*n))-pnorm(-500,mean = 100,sd = sqrt(0.4*n)) lines(n[-1],-diff(p1^5)*10^3, col = 2) p2 = pnorm(0,mean = 100,sd = sqrt(0.4*n))*2 lines(n[-1],-diff(pbinom(1,5,p2))*10^3, col = 3) ### add inverse gaussian curve fitted with method of moments lines(n,statmod::dinvgauss(n, mean(y), dispersion = var(y)/mean(y)^3)*10^7, col = 4) legend(4*10^5, 80, c("estimate based on probability of winning", "estimate based on probability of loosing", "inverse Gauss distribution"), cex = 0.7, col = c(2,3,4), lty = 1)
What is the probability of having all wealth concentrated into one single pocket after n trades? The answer by Aksakal already explains it enough why the wealth is ending up into one single pocket. In this answer we elaborate a bit further on the quantitative approach by Matt F. One could compute
44,353
What should it mean when someone says: "There's a $70$% chance of something happening
It's not an elementary or trivial question. It's a philosophical one. It touches the deepest foundations of statistics. It's almost a religious question if Bayesians overhear it. There are many ways to answer it. For instance, it could mean that if our Universe forked this moment and we observed infinite number of evolutions of these universes then in 70% of cases in next 6 months US stock market will drop below March lows. Surely, this may sound extravagant, but I came to accept it as a possibility. Another answer is that it's about the subjective gauge that helps you decide whether or not to invest in US stock market. We have only one realization of reality, so 70% of chance has no means of being tested in terms of frequencies of occurrence of this event. Yet another way to answer is to assume an ergodic hypothesis which states that although we can't fork the Universe and see across all different realizations of future; we can, nevertheless, observe one Universe for long time, and that when you observe it for a long enough period it's the same as observing a set of forked universes. In practical terms it means that if you follow the forecast of whoever gave you the "70% prediction" then in 70% of the cases the advice will pay off. Over long period of time.
What should it mean when someone says: "There's a $70$% chance of something happening
It's not an elementary or trivial question. It's a philosophical one. It touches the deepest foundations of statistics. It's almost a religious question if Bayesians overhear it. There are many ways t
What should it mean when someone says: "There's a $70$% chance of something happening It's not an elementary or trivial question. It's a philosophical one. It touches the deepest foundations of statistics. It's almost a religious question if Bayesians overhear it. There are many ways to answer it. For instance, it could mean that if our Universe forked this moment and we observed infinite number of evolutions of these universes then in 70% of cases in next 6 months US stock market will drop below March lows. Surely, this may sound extravagant, but I came to accept it as a possibility. Another answer is that it's about the subjective gauge that helps you decide whether or not to invest in US stock market. We have only one realization of reality, so 70% of chance has no means of being tested in terms of frequencies of occurrence of this event. Yet another way to answer is to assume an ergodic hypothesis which states that although we can't fork the Universe and see across all different realizations of future; we can, nevertheless, observe one Universe for long time, and that when you observe it for a long enough period it's the same as observing a set of forked universes. In practical terms it means that if you follow the forecast of whoever gave you the "70% prediction" then in 70% of the cases the advice will pay off. Over long period of time.
What should it mean when someone says: "There's a $70$% chance of something happening It's not an elementary or trivial question. It's a philosophical one. It touches the deepest foundations of statistics. It's almost a religious question if Bayesians overhear it. There are many ways t
44,354
What should it mean when someone says: "There's a $70$% chance of something happening
When you're talking about a repeatable event, the interpretation is pretty easy. A probability of 70% means that when you observe the event, the prediction should be borne out (in the long run) 7 times out of 10. When you're talking about a non-repeatable event, then the best interpretation is as a level of confidence in the prediction. The idea is that if you take all the times a forecaster makes a prediction of 70%, about 7/10 of those predictions should be borne out. Thus, you can have an idea, based on a forecaster's track record, of how likely the prediction is to be correct, even though you can't replay the individual events to see empirically how often the counterfactuals happened. In fact, this is exactly how the Good Judgement Project scored its forecasting tournament. The scoring metric was designed so that being well calibrated was as important as being right most of the time. In other words, if your 70%-forecasts are right 60% of the time, that's bad (you are overconfident), but it's also bad if they're right 80% of the time (you are underconfident). Notwithstanding the rather cynical take offered by some of the other answers, the main finding of GJP was that with suitable training people can be taught to make well-calibrated forecasts.
What should it mean when someone says: "There's a $70$% chance of something happening
When you're talking about a repeatable event, the interpretation is pretty easy. A probability of 70% means that when you observe the event, the prediction should be borne out (in the long run) 7 tim
What should it mean when someone says: "There's a $70$% chance of something happening When you're talking about a repeatable event, the interpretation is pretty easy. A probability of 70% means that when you observe the event, the prediction should be borne out (in the long run) 7 times out of 10. When you're talking about a non-repeatable event, then the best interpretation is as a level of confidence in the prediction. The idea is that if you take all the times a forecaster makes a prediction of 70%, about 7/10 of those predictions should be borne out. Thus, you can have an idea, based on a forecaster's track record, of how likely the prediction is to be correct, even though you can't replay the individual events to see empirically how often the counterfactuals happened. In fact, this is exactly how the Good Judgement Project scored its forecasting tournament. The scoring metric was designed so that being well calibrated was as important as being right most of the time. In other words, if your 70%-forecasts are right 60% of the time, that's bad (you are overconfident), but it's also bad if they're right 80% of the time (you are underconfident). Notwithstanding the rather cynical take offered by some of the other answers, the main finding of GJP was that with suitable training people can be taught to make well-calibrated forecasts.
What should it mean when someone says: "There's a $70$% chance of something happening When you're talking about a repeatable event, the interpretation is pretty easy. A probability of 70% means that when you observe the event, the prediction should be borne out (in the long run) 7 tim
44,355
What should it mean when someone says: "There's a $70$% chance of something happening
First of all, without any kind of demonstration (transparency) this value means nothing. On the other hand, my guess about this specific statement should mean this: Prediction Guy: Me and my team are using a model that fits and predicts the stock market (Specifically the Dow Jones, for example). Now, we made the model run several times giving us X possible predictions, from that set of runs, we've seen that in 70% of cases we've seen that stock market has took out march lows in six months. The thing is, it's impossible to have an specific percentage value of a success about stock market, because these indices are not dices or coins. There's no probability of success A or B. What it's really possible to do is to make predictions based in a model. Nonetheless, any estimation should be followed by a significance level and/or a confidence interval. My conclusion: What the guy said may be just a guess (he's quite sure that it will happen but he can't be sure, and 70% is an atractive number). My suggestion: Check (or demand) references about how this value has been extracted.
What should it mean when someone says: "There's a $70$% chance of something happening
First of all, without any kind of demonstration (transparency) this value means nothing. On the other hand, my guess about this specific statement should mean this: Prediction Guy: Me and my team ar
What should it mean when someone says: "There's a $70$% chance of something happening First of all, without any kind of demonstration (transparency) this value means nothing. On the other hand, my guess about this specific statement should mean this: Prediction Guy: Me and my team are using a model that fits and predicts the stock market (Specifically the Dow Jones, for example). Now, we made the model run several times giving us X possible predictions, from that set of runs, we've seen that in 70% of cases we've seen that stock market has took out march lows in six months. The thing is, it's impossible to have an specific percentage value of a success about stock market, because these indices are not dices or coins. There's no probability of success A or B. What it's really possible to do is to make predictions based in a model. Nonetheless, any estimation should be followed by a significance level and/or a confidence interval. My conclusion: What the guy said may be just a guess (he's quite sure that it will happen but he can't be sure, and 70% is an atractive number). My suggestion: Check (or demand) references about how this value has been extracted.
What should it mean when someone says: "There's a $70$% chance of something happening First of all, without any kind of demonstration (transparency) this value means nothing. On the other hand, my guess about this specific statement should mean this: Prediction Guy: Me and my team ar
44,356
Limitations of Shapiro test
The Shapiro-Wilk test is not especially sensitive to outliers. There are normality tests that focus on outliers, by looking at a combination of skewness and kurtosis, but they are different. Patrick Royston says about the Shapiro-Wilk test Its power characteristics are well known and may be summarized by saying that it is strongest against short-tailed (platykurtic) and skew distributions and weakest against symmetric moderately long- tailed (leptokurtic) distributions. An outlier-based test would be the opposite, strongest against leptokurtic distributions. This also supports the idea that removing extreme observations from a sample that's truly from a Normal distribution might lead the Shapiro-Wilk test to reject -- correctly, since you no longer have a sample from a Normal distribution, but instead have a sample that has lighter tails than if it were from a Normal. I have a longer rant about the Shapiro-Wilk test, which isn't necessarily relevant to the specific question here
Limitations of Shapiro test
The Shapiro-Wilk test is not especially sensitive to outliers. There are normality tests that focus on outliers, by looking at a combination of skewness and kurtosis, but they are different. Patrick
Limitations of Shapiro test The Shapiro-Wilk test is not especially sensitive to outliers. There are normality tests that focus on outliers, by looking at a combination of skewness and kurtosis, but they are different. Patrick Royston says about the Shapiro-Wilk test Its power characteristics are well known and may be summarized by saying that it is strongest against short-tailed (platykurtic) and skew distributions and weakest against symmetric moderately long- tailed (leptokurtic) distributions. An outlier-based test would be the opposite, strongest against leptokurtic distributions. This also supports the idea that removing extreme observations from a sample that's truly from a Normal distribution might lead the Shapiro-Wilk test to reject -- correctly, since you no longer have a sample from a Normal distribution, but instead have a sample that has lighter tails than if it were from a Normal. I have a longer rant about the Shapiro-Wilk test, which isn't necessarily relevant to the specific question here
Limitations of Shapiro test The Shapiro-Wilk test is not especially sensitive to outliers. There are normality tests that focus on outliers, by looking at a combination of skewness and kurtosis, but they are different. Patrick
44,357
Limitations of Shapiro test
Certainly that can happen. Assume your original data was normal. Really normal. Then remove "outliers". E.g., everything more than 3 standard deviations away from the mean. What are we left with? A truncated normal distribution. Which is, by definition, not a normal distribution any more. So the Shapiro-Wilk test should in this situation tell you that the original data was normal, and the truncated data is not. Here is a little R code to simulate this: sample_size <- 100 n_experiments <- 1000 result <- matrix(NA,nrow=n_experiments,ncol=2,dimnames=list(NULL,c("Before","After"))) for ( ii in 1:n_experiments ) { set.seed(ii) # for replicability foo <- rnorm(sample_size) result[ii,"Before"] <- shapiro.test(foo)$p.value>0.05 result[ii,"After"] <- shapiro.test(foo[abs(foo)<=3])$p.value>0.05 } table(data.frame(result)) Result: After Before FALSE TRUE FALSE 32 26 TRUE 3 939 (I recommend skimming through the comments at this post to see how controversial "outlier" removal is.)
Limitations of Shapiro test
Certainly that can happen. Assume your original data was normal. Really normal. Then remove "outliers". E.g., everything more than 3 standard deviations away from the mean. What are we left with? A tr
Limitations of Shapiro test Certainly that can happen. Assume your original data was normal. Really normal. Then remove "outliers". E.g., everything more than 3 standard deviations away from the mean. What are we left with? A truncated normal distribution. Which is, by definition, not a normal distribution any more. So the Shapiro-Wilk test should in this situation tell you that the original data was normal, and the truncated data is not. Here is a little R code to simulate this: sample_size <- 100 n_experiments <- 1000 result <- matrix(NA,nrow=n_experiments,ncol=2,dimnames=list(NULL,c("Before","After"))) for ( ii in 1:n_experiments ) { set.seed(ii) # for replicability foo <- rnorm(sample_size) result[ii,"Before"] <- shapiro.test(foo)$p.value>0.05 result[ii,"After"] <- shapiro.test(foo[abs(foo)<=3])$p.value>0.05 } table(data.frame(result)) Result: After Before FALSE TRUE FALSE 32 26 TRUE 3 939 (I recommend skimming through the comments at this post to see how controversial "outlier" removal is.)
Limitations of Shapiro test Certainly that can happen. Assume your original data was normal. Really normal. Then remove "outliers". E.g., everything more than 3 standard deviations away from the mean. What are we left with? A tr
44,358
Activation function between LSTM layers
The purpose of the Rectified Linear Activation Function (or ReLU for short) is to allow the neural network to learn nonlinear dependencies. Specifically, the way this works is that ReLU will return input directly if the value is greater than 0. If less than 0, then 0.0 is simply returned. The idea is to allow the network to approximate a linear function when necessary, with the flexibility to also account for nonlinearity. This article from Machine Learning Mastery goes into more detail on the same. As for whether having an activation function would make much difference to the analysis, much of this depends on the data. Given that ReLUs can have quite large outputs, they have traditionally been regarded as inappropriate for use with LSTMs. Let’s consider the following example. Suppose an LSTM is being used as a time series tool to forecast weekly fluctuations in hotel cancellations (all values in the time series are positive, as the number of cancellations cannot be negative). The network structure is as follows: # Generate LSTM network model = tf.keras.Sequential() model.add(LSTM(4, input_shape=(1, previous))) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') history=model.fit(X_train, Y_train, validation_split=0.2, epochs=500, batch_size=1, verbose=2) When the predictions are compared with the test data, the following readings are obtained: Mean Directional Accuracy: 80% Root Mean Squared Error: 92 Mean Forecast Error: 29 Now, suppose that a ReLU activation function is invoked: # Generate LSTM network model = tf.keras.Sequential() model.add(LSTM(4, activation="relu", input_shape=(1, previous))) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') history=model.fit(X_train, Y_train, validation_split=0.2, epochs=500, batch_size=1, verbose=2) Mean Directional Accuracy: 80% Root Mean Squared Error: 96.78 Mean Forecast Error: 9.40 We see better performance on MFE and slightly worse performance for RMSE. That said, note the difference between the two graphs: Predictions without ReLU Predictions with ReLU We can see that the predictions with ReLU flatten out the volatility in the time series. While this might result in better performance on some metrics (in this case RMSE), it also means that the network is not picking up the right volatility trends in the data as the activation function is not appropriate for the type of data under analysis. Therefore, superior performance for MFE becomes irrelevant under these circumstances. In this regard, one should not use ReLU (or any activation function for that matter) blindly – it may not be appropriate for the data (or model) in question.
Activation function between LSTM layers
The purpose of the Rectified Linear Activation Function (or ReLU for short) is to allow the neural network to learn nonlinear dependencies. Specifically, the way this works is that ReLU will return in
Activation function between LSTM layers The purpose of the Rectified Linear Activation Function (or ReLU for short) is to allow the neural network to learn nonlinear dependencies. Specifically, the way this works is that ReLU will return input directly if the value is greater than 0. If less than 0, then 0.0 is simply returned. The idea is to allow the network to approximate a linear function when necessary, with the flexibility to also account for nonlinearity. This article from Machine Learning Mastery goes into more detail on the same. As for whether having an activation function would make much difference to the analysis, much of this depends on the data. Given that ReLUs can have quite large outputs, they have traditionally been regarded as inappropriate for use with LSTMs. Let’s consider the following example. Suppose an LSTM is being used as a time series tool to forecast weekly fluctuations in hotel cancellations (all values in the time series are positive, as the number of cancellations cannot be negative). The network structure is as follows: # Generate LSTM network model = tf.keras.Sequential() model.add(LSTM(4, input_shape=(1, previous))) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') history=model.fit(X_train, Y_train, validation_split=0.2, epochs=500, batch_size=1, verbose=2) When the predictions are compared with the test data, the following readings are obtained: Mean Directional Accuracy: 80% Root Mean Squared Error: 92 Mean Forecast Error: 29 Now, suppose that a ReLU activation function is invoked: # Generate LSTM network model = tf.keras.Sequential() model.add(LSTM(4, activation="relu", input_shape=(1, previous))) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') history=model.fit(X_train, Y_train, validation_split=0.2, epochs=500, batch_size=1, verbose=2) Mean Directional Accuracy: 80% Root Mean Squared Error: 96.78 Mean Forecast Error: 9.40 We see better performance on MFE and slightly worse performance for RMSE. That said, note the difference between the two graphs: Predictions without ReLU Predictions with ReLU We can see that the predictions with ReLU flatten out the volatility in the time series. While this might result in better performance on some metrics (in this case RMSE), it also means that the network is not picking up the right volatility trends in the data as the activation function is not appropriate for the type of data under analysis. Therefore, superior performance for MFE becomes irrelevant under these circumstances. In this regard, one should not use ReLU (or any activation function for that matter) blindly – it may not be appropriate for the data (or model) in question.
Activation function between LSTM layers The purpose of the Rectified Linear Activation Function (or ReLU for short) is to allow the neural network to learn nonlinear dependencies. Specifically, the way this works is that ReLU will return in
44,359
Is A truly better than B, given that 56% of 131 respondednts said so?
Let's say you have $X = 73$ out of $n = 131$ favoring A over B. Then a 95% Agresti-Coull CI for the population proportion $p$ favoring A is of the form $$\check p \pm 1.96\sqrt{\frac{\check p(1-\check p)}{\check n}},$$ where $\check n = n+ 4$ and $\check p = \frac{X+2}{n+4}.$ This computes to $(.472, .639),$ which includes 50%. p.ac = 75/135; n.ac = 135; pm=c(-1,1) p.ac + pm*1.96*(sqrt(p.ac*(1-p.ac)/n.ac)) [1] 0.4717328 0.6393783 Testing the null hypothesis $H_0: p = 1/2$ against the one-sided alternative $H_a: p > 1/2,$ one obtains the P-value $P(X \ge 73) = 1 - P(X \le 72) \approx 0.11$ (under the assumption $H_0$ is true). Even though 65% > 50%, it appears the 56% is not significantly greater that 50% at the 5% level. This can be computed in R as follows: 1 - pbinom(72, 131, .5) [1] 0.110558 More formally, the exact binomial test binom.test in R, gives this P-value along with a one-sided 95% CI (that is a 95% lower bound). binom.test(73, 131, alte="g") Exact binomial test data: 73 and 131 number of successes = 73, number of trials = 131, p-value = 0.1106 alternative hypothesis: true probability of success is greater than 0.5 95 percent confidence interval: 0.4816258 1.0000000 sample estimates: probability of success 0.5572519 Addendum; Sometimes a 95% Bayesian posterior probability ('credible') interval based on a 'non-informative' or 'flat' prior distribution, such as $\mathsf{Unif}(0,1) \equiv \mathsf{Beta}(1,1),$ is used by frequentist statisticians as a 95% confidence interval. I mention this partly for completeness and partly because @MatthewDrury almost seems to suggest a Bayesian framework in his answer (+1). For $X = 73$ and $n - X = 58,$ this interval estimate can be computed by finding quantiles 0.025 and 0.975 of $\mathsf{Beta}(X+1, n-X+1).$ Specifically, $(0.472, 0.640),$ which is numerically very similar to the Agresti-Coull interval mentioned above. qbeta(c(.025,.975), 74, 59) [1] 0.4716082 0.6395668 Note: For more on binomial interval estimates see this Q & A and its References.
Is A truly better than B, given that 56% of 131 respondednts said so?
Let's say you have $X = 73$ out of $n = 131$ favoring A over B. Then a 95% Agresti-Coull CI for the population proportion $p$ favoring A is of the form $$\check p \pm 1.96\sqrt{\frac{\check p(1-\check
Is A truly better than B, given that 56% of 131 respondednts said so? Let's say you have $X = 73$ out of $n = 131$ favoring A over B. Then a 95% Agresti-Coull CI for the population proportion $p$ favoring A is of the form $$\check p \pm 1.96\sqrt{\frac{\check p(1-\check p)}{\check n}},$$ where $\check n = n+ 4$ and $\check p = \frac{X+2}{n+4}.$ This computes to $(.472, .639),$ which includes 50%. p.ac = 75/135; n.ac = 135; pm=c(-1,1) p.ac + pm*1.96*(sqrt(p.ac*(1-p.ac)/n.ac)) [1] 0.4717328 0.6393783 Testing the null hypothesis $H_0: p = 1/2$ against the one-sided alternative $H_a: p > 1/2,$ one obtains the P-value $P(X \ge 73) = 1 - P(X \le 72) \approx 0.11$ (under the assumption $H_0$ is true). Even though 65% > 50%, it appears the 56% is not significantly greater that 50% at the 5% level. This can be computed in R as follows: 1 - pbinom(72, 131, .5) [1] 0.110558 More formally, the exact binomial test binom.test in R, gives this P-value along with a one-sided 95% CI (that is a 95% lower bound). binom.test(73, 131, alte="g") Exact binomial test data: 73 and 131 number of successes = 73, number of trials = 131, p-value = 0.1106 alternative hypothesis: true probability of success is greater than 0.5 95 percent confidence interval: 0.4816258 1.0000000 sample estimates: probability of success 0.5572519 Addendum; Sometimes a 95% Bayesian posterior probability ('credible') interval based on a 'non-informative' or 'flat' prior distribution, such as $\mathsf{Unif}(0,1) \equiv \mathsf{Beta}(1,1),$ is used by frequentist statisticians as a 95% confidence interval. I mention this partly for completeness and partly because @MatthewDrury almost seems to suggest a Bayesian framework in his answer (+1). For $X = 73$ and $n - X = 58,$ this interval estimate can be computed by finding quantiles 0.025 and 0.975 of $\mathsf{Beta}(X+1, n-X+1).$ Specifically, $(0.472, 0.640),$ which is numerically very similar to the Agresti-Coull interval mentioned above. qbeta(c(.025,.975), 74, 59) [1] 0.4716082 0.6395668 Note: For more on binomial interval estimates see this Q & A and its References.
Is A truly better than B, given that 56% of 131 respondednts said so? Let's say you have $X = 73$ out of $n = 131$ favoring A over B. Then a 95% Agresti-Coull CI for the population proportion $p$ favoring A is of the form $$\check p \pm 1.96\sqrt{\frac{\check p(1-\check
44,360
Is A truly better than B, given that 56% of 131 respondednts said so?
First, @NuclearWang is correct. If your survey is as stated, you're learning about what procedure people prefer, not what is better (for some unspecified purpose). I don't think it's a pedantic point, its important to measure what we intend to measure. The statistics here is pretty simple. You want to know if your data indicates that the respondents were not guessing randomly. The standard approach is to assume that they are guessing randomly (usually called the null hypothesis), then show that your data is very unlikely to have been collected under that hypothesis. Under the random guessing assumption, your data would be generated from a binomial process: $$ \text{# of votes for A} \sim \text{Binomial}(n = 131, p = 0.5) $$ You actually observed $72$ votes for A. We can easily calculate the probability that we would observe greater than or equal to $72$ votes for A if the respondents were guessing randomly. I'll use python: In [1]: import scipy.stats as stats In [2]: 1 - stats.binom(n=131, p=0.5).cdf(71) Out[2]: 0.14720307826175671 It looks like there's a 15% chance of observing data equal or more extreme than you actually collected when the respondents were guessing randomly. How you use this probability to affect your beliefs is up to you.
Is A truly better than B, given that 56% of 131 respondednts said so?
First, @NuclearWang is correct. If your survey is as stated, you're learning about what procedure people prefer, not what is better (for some unspecified purpose). I don't think it's a pedantic poin
Is A truly better than B, given that 56% of 131 respondednts said so? First, @NuclearWang is correct. If your survey is as stated, you're learning about what procedure people prefer, not what is better (for some unspecified purpose). I don't think it's a pedantic point, its important to measure what we intend to measure. The statistics here is pretty simple. You want to know if your data indicates that the respondents were not guessing randomly. The standard approach is to assume that they are guessing randomly (usually called the null hypothesis), then show that your data is very unlikely to have been collected under that hypothesis. Under the random guessing assumption, your data would be generated from a binomial process: $$ \text{# of votes for A} \sim \text{Binomial}(n = 131, p = 0.5) $$ You actually observed $72$ votes for A. We can easily calculate the probability that we would observe greater than or equal to $72$ votes for A if the respondents were guessing randomly. I'll use python: In [1]: import scipy.stats as stats In [2]: 1 - stats.binom(n=131, p=0.5).cdf(71) Out[2]: 0.14720307826175671 It looks like there's a 15% chance of observing data equal or more extreme than you actually collected when the respondents were guessing randomly. How you use this probability to affect your beliefs is up to you.
Is A truly better than B, given that 56% of 131 respondednts said so? First, @NuclearWang is correct. If your survey is as stated, you're learning about what procedure people prefer, not what is better (for some unspecified purpose). I don't think it's a pedantic poin
44,361
What type of data are dates?
This is a tricky question, and personally I feel this question is more about semantics and conventions. Let's go to basics. What is Date? It's just a name we give to 86,400 seconds period. Date by definition, is counted from a reference point (year 1 AD). You could simply treat dates as natural numbers, if your problem is about number of days. Or you could convert days to seconds. And count seconds from 1st day of 1 AD. In other words, it's a 'name' we give to that specific range of numbers. You can argue that date is a category variable, as you can put them in "Sunday", "Monday", etc into 7 categories.. But will it serve the purpose? Or you could treat date as range of numbers(seconds/minutes/hours), using seconds/minutes/hours with reference to a particular date/point in time. I feel this question doesn't have a universally agreeable answer as dates can be used in so many ways in variety of applications. Ultimately you'll have to think about the specific application you're looking at and then take a call.
What type of data are dates?
This is a tricky question, and personally I feel this question is more about semantics and conventions. Let's go to basics. What is Date? It's just a name we give to 86,400 seconds period. Date by def
What type of data are dates? This is a tricky question, and personally I feel this question is more about semantics and conventions. Let's go to basics. What is Date? It's just a name we give to 86,400 seconds period. Date by definition, is counted from a reference point (year 1 AD). You could simply treat dates as natural numbers, if your problem is about number of days. Or you could convert days to seconds. And count seconds from 1st day of 1 AD. In other words, it's a 'name' we give to that specific range of numbers. You can argue that date is a category variable, as you can put them in "Sunday", "Monday", etc into 7 categories.. But will it serve the purpose? Or you could treat date as range of numbers(seconds/minutes/hours), using seconds/minutes/hours with reference to a particular date/point in time. I feel this question doesn't have a universally agreeable answer as dates can be used in so many ways in variety of applications. Ultimately you'll have to think about the specific application you're looking at and then take a call.
What type of data are dates? This is a tricky question, and personally I feel this question is more about semantics and conventions. Let's go to basics. What is Date? It's just a name we give to 86,400 seconds period. Date by def
44,362
What type of data are dates?
It is correct that dates do not fit nicely into the Stevens typology https://en.wikipedia.org/wiki/Level_of_measurement#Ordinal_scale of different levels of measurement. Dates are certainly ordered, so we could say that dates are ordinal type, but they are certainly more than that. When talking specifically about days in this sense, astronomers use Julian days. I take your question to be what mathematical structure can we give to the set of dates (or more generally dates/times). That is about a mathematical representation of time, and we talk generally of time in at least two ways: events ("when did something happen") and durations "how long did the last winter Olympic games in PyeongChang last"? If $P$ is the date of the opening ceremony and $Q$ the date of the closing ceremony, then the duration is $Q-P$. So we can take a difference of two events (dates); that difference is a duration. But we cannot sum two events (dates), what should we mean by $P+Q$? But the halfway point of the winter Olympics has meaning; that is the average $0.5 P+0.5 Q$. So averages make sense! This looks like a strange mathematical structure, with two kinds of objects "events" and "durations" and operations only defined in some cases, not all. But it is a very well-known object, an affine space; see https://en.wikipedia.org/wiki/Affine_space. The usual way of introducing an affine space is saying it is a vector space "where we have forgotten the origin". Since we have forgotten the origin, any operation whose result depends on the origin is invalid or undefined. We can now define "events" (dates) as vectors in the underlying (1-dim) vector space, which we can identify with the real line. But note that this representation depends on choice of an origin! We must just remember that anything we actually do must not depend on this choice. We can represent "durations" as differences between the vectors representing dates. It should be quite obvious that the duration of the winter Olympic Games do not depend on if we choose as time origin the birth of Christ or 1 january 1970 (time origin used in linux). The average of events also has meaning: if we write the events as $P_i$, then the average of the $P_i$ is an event $Q$ such that $$ \sum_i (P_i - Q)=0 $$ (In affine geometry $Q$ is called often the barycenter.) Note that here we are only summing durations, which is allowed. If we want to implement some data type representing dates in a computing environment, it must have these properties. Let us see in R: P <- as.Date("2018-2-9") # Starting date of Olympics Q <- as.Date("2018-2-25") # end date Q-P # duration Time difference of 16 days Q+P Error in `+.Date`(Q, P) : binary + is not defined for "Date" objects mean(c(P, Q)) # time midpoint of the games [1] "2018-02-17" weighted.mean(c(P, Q), c(1/4, 3/4)) # games 3/4-finnished. [1] "2018-02-21" P+16 # 16 days after the opening ceremony [1] "2018-02-25" That all seems to be well-behaved.
What type of data are dates?
It is correct that dates do not fit nicely into the Stevens typology https://en.wikipedia.org/wiki/Level_of_measurement#Ordinal_scale of different levels of measurement. Dates are certainly ordered,
What type of data are dates? It is correct that dates do not fit nicely into the Stevens typology https://en.wikipedia.org/wiki/Level_of_measurement#Ordinal_scale of different levels of measurement. Dates are certainly ordered, so we could say that dates are ordinal type, but they are certainly more than that. When talking specifically about days in this sense, astronomers use Julian days. I take your question to be what mathematical structure can we give to the set of dates (or more generally dates/times). That is about a mathematical representation of time, and we talk generally of time in at least two ways: events ("when did something happen") and durations "how long did the last winter Olympic games in PyeongChang last"? If $P$ is the date of the opening ceremony and $Q$ the date of the closing ceremony, then the duration is $Q-P$. So we can take a difference of two events (dates); that difference is a duration. But we cannot sum two events (dates), what should we mean by $P+Q$? But the halfway point of the winter Olympics has meaning; that is the average $0.5 P+0.5 Q$. So averages make sense! This looks like a strange mathematical structure, with two kinds of objects "events" and "durations" and operations only defined in some cases, not all. But it is a very well-known object, an affine space; see https://en.wikipedia.org/wiki/Affine_space. The usual way of introducing an affine space is saying it is a vector space "where we have forgotten the origin". Since we have forgotten the origin, any operation whose result depends on the origin is invalid or undefined. We can now define "events" (dates) as vectors in the underlying (1-dim) vector space, which we can identify with the real line. But note that this representation depends on choice of an origin! We must just remember that anything we actually do must not depend on this choice. We can represent "durations" as differences between the vectors representing dates. It should be quite obvious that the duration of the winter Olympic Games do not depend on if we choose as time origin the birth of Christ or 1 january 1970 (time origin used in linux). The average of events also has meaning: if we write the events as $P_i$, then the average of the $P_i$ is an event $Q$ such that $$ \sum_i (P_i - Q)=0 $$ (In affine geometry $Q$ is called often the barycenter.) Note that here we are only summing durations, which is allowed. If we want to implement some data type representing dates in a computing environment, it must have these properties. Let us see in R: P <- as.Date("2018-2-9") # Starting date of Olympics Q <- as.Date("2018-2-25") # end date Q-P # duration Time difference of 16 days Q+P Error in `+.Date`(Q, P) : binary + is not defined for "Date" objects mean(c(P, Q)) # time midpoint of the games [1] "2018-02-17" weighted.mean(c(P, Q), c(1/4, 3/4)) # games 3/4-finnished. [1] "2018-02-21" P+16 # 16 days after the opening ceremony [1] "2018-02-25" That all seems to be well-behaved.
What type of data are dates? It is correct that dates do not fit nicely into the Stevens typology https://en.wikipedia.org/wiki/Level_of_measurement#Ordinal_scale of different levels of measurement. Dates are certainly ordered,
44,363
What type of data are dates?
Dates can be ordinal, categorical or both. It really depends on what these dates represent and what you are trying to answer with them. If the data your dates represent can be described as elapsed time then I would use ordinal. Examples: If you are looking at how your process affects the growth of a population over decades and the date field represents the day the population was counted, I would treat this field as ordinal How much does a company's historical stock price influence the current value of a stock? The effect a process has on a person's memory over time, where the date field is the date a person took a memory test and their score. If the data your dates represent can be described as part of a cycle then I would use categorical. Examples: If you want to determine if your process has an effect on the number of births per calendar week, I would use categorical Does the day of the week influence the value of a stock price. Does the month the process was started on influence its results. Looking at the two example pairs, it can be easily seen that a model looking at the effect a process has on the reproduction of a species or a model looking at influences on stock prices would most likely convert dates into both categorical and ordinal. I believe that depending on what question the model is created to answer and what the data represents would greatly influence which (categorical and/or ordinal) should be used.
What type of data are dates?
Dates can be ordinal, categorical or both. It really depends on what these dates represent and what you are trying to answer with them. If the data your dates represent can be described as elapsed tim
What type of data are dates? Dates can be ordinal, categorical or both. It really depends on what these dates represent and what you are trying to answer with them. If the data your dates represent can be described as elapsed time then I would use ordinal. Examples: If you are looking at how your process affects the growth of a population over decades and the date field represents the day the population was counted, I would treat this field as ordinal How much does a company's historical stock price influence the current value of a stock? The effect a process has on a person's memory over time, where the date field is the date a person took a memory test and their score. If the data your dates represent can be described as part of a cycle then I would use categorical. Examples: If you want to determine if your process has an effect on the number of births per calendar week, I would use categorical Does the day of the week influence the value of a stock price. Does the month the process was started on influence its results. Looking at the two example pairs, it can be easily seen that a model looking at the effect a process has on the reproduction of a species or a model looking at influences on stock prices would most likely convert dates into both categorical and ordinal. I believe that depending on what question the model is created to answer and what the data represents would greatly influence which (categorical and/or ordinal) should be used.
What type of data are dates? Dates can be ordinal, categorical or both. It really depends on what these dates represent and what you are trying to answer with them. If the data your dates represent can be described as elapsed tim
44,364
How does statistical control work in logistic regression?
Is it fair to say that each log-odds associated with a predictor assumes that the others are held constant at 0? The logit model is $\begin{align*} E(Y_t\vert x_t) &= p_t \\ \log \left( \frac{p_t}{1-p_t}\right) &= \vec{\beta}^\top \vec{x}_t \end{align*}$ So $\beta_j$ describes a unit move on the log-odds scale of the $j$th covariate regardless of whether the other covariates are zero or not as long as the other covariates stays fixed. And would this change based on continuous vs. binary predictors? No that does not change anything.
How does statistical control work in logistic regression?
Is it fair to say that each log-odds associated with a predictor assumes that the others are held constant at 0? The logit model is $\begin{align*} E(Y_t\vert x_t) &= p_t \\ \log \left( \frac{
How does statistical control work in logistic regression? Is it fair to say that each log-odds associated with a predictor assumes that the others are held constant at 0? The logit model is $\begin{align*} E(Y_t\vert x_t) &= p_t \\ \log \left( \frac{p_t}{1-p_t}\right) &= \vec{\beta}^\top \vec{x}_t \end{align*}$ So $\beta_j$ describes a unit move on the log-odds scale of the $j$th covariate regardless of whether the other covariates are zero or not as long as the other covariates stays fixed. And would this change based on continuous vs. binary predictors? No that does not change anything.
How does statistical control work in logistic regression? Is it fair to say that each log-odds associated with a predictor assumes that the others are held constant at 0? The logit model is $\begin{align*} E(Y_t\vert x_t) &= p_t \\ \log \left( \frac{
44,365
How does statistical control work in logistic regression?
Even in standard linear regression, the coefficient for a predictor represents the association of the outcome variable with that particular predictor when all other predictors are held constant. There is no requirement that they be held constant at values of 0; so long as the others are held constant, under the assumptions of the linear model it won't matter what their values are. That's true for both standard and logistic regression based on linear models. The interpretation of the intercept, however, will differ dramatically depending on how the values of the predictors are coded. With the default treatments contrasts used in R, the intercept will be the value of the outcome variable when continuous predictors have values of 0 and categorical variables are at their reference levels. You have to be careful with intercepts as not all statistical software programs use the same defaults for choosing reference values of categorical variables, and different handling of predictor contrasts might also affect them. Things do get a bit tricky when you consider interactions, however, with both standard and logistic regression. An interaction term then effectively represents the product of the values of the interacting predictors. For continuous variables, interpretation of interaction coefficients can be simpler if you center the continuous predictors to mean values of 0 first. Then any such interaction term will have a value of 0 when all individual predictors are at their mean values.
How does statistical control work in logistic regression?
Even in standard linear regression, the coefficient for a predictor represents the association of the outcome variable with that particular predictor when all other predictors are held constant. There
How does statistical control work in logistic regression? Even in standard linear regression, the coefficient for a predictor represents the association of the outcome variable with that particular predictor when all other predictors are held constant. There is no requirement that they be held constant at values of 0; so long as the others are held constant, under the assumptions of the linear model it won't matter what their values are. That's true for both standard and logistic regression based on linear models. The interpretation of the intercept, however, will differ dramatically depending on how the values of the predictors are coded. With the default treatments contrasts used in R, the intercept will be the value of the outcome variable when continuous predictors have values of 0 and categorical variables are at their reference levels. You have to be careful with intercepts as not all statistical software programs use the same defaults for choosing reference values of categorical variables, and different handling of predictor contrasts might also affect them. Things do get a bit tricky when you consider interactions, however, with both standard and logistic regression. An interaction term then effectively represents the product of the values of the interacting predictors. For continuous variables, interpretation of interaction coefficients can be simpler if you center the continuous predictors to mean values of 0 first. Then any such interaction term will have a value of 0 when all individual predictors are at their mean values.
How does statistical control work in logistic regression? Even in standard linear regression, the coefficient for a predictor represents the association of the outcome variable with that particular predictor when all other predictors are held constant. There
44,366
Expected Value of $X \sin(X)$ with $X$ normally distributed
Like many exercises involving trigonometric functions, the trick is to use complex numbers, i.e., $\int(\sin(x))\mathrm{d}x = \int Im(e^{ix})\mathrm{d}x = Im(\int e^{ix} \mathrm{d}x)$ here. Knowing, the sum becomes \begin{align} I \triangleq \mathbb{E}[X\sin(X)] = Im \left( \int_{\mathbb{R}} x e^{ix} e^{-\frac{1}{2\sigma^2} (x-\mu)^2} \mathrm{d}x \right) . \end{align} To compute this sum, we have to factorise the two exponential terms. A rule of thumb for such calculation is that a gaussian stays gaussian when multiplied by an exponential term of the form $e^{ax}$. I let you do the math, but one can write \begin{equation} -\frac{1}{2\sigma^2} (x-\mu)^2 + ix = -\frac{1}{2 \sigma^2}\big( x- (\mu+i\sigma^2) \big)^2 + i\mu - \frac{\sigma^2}{2} . \end{equation} Then, by recognising the expectation of a new gaussian distribution \begin{align} I =& Im \left( e^{-\frac{\sigma^2}{2} + i\mu} \int_{\mathbb{R}} \frac{1}{\sqrt{2\pi \sigma^2}} x e^{-\frac{1}{2\sigma^2}(x - \mu - i\sigma^2)^2} \mathrm{d}x \right) \\ =& Im \left( e^{-\frac{\sigma^2}{2} + i\mu} \times (\mu + i \sigma^2) \right) \\ =&e^{-\frac{\sigma^2}{2}} \times \left( \sigma^2 \cos(\mu) + \mu \sin(\mu) \right), \end{align} which corresponds to wolfies's answer.
Expected Value of $X \sin(X)$ with $X$ normally distributed
Like many exercises involving trigonometric functions, the trick is to use complex numbers, i.e., $\int(\sin(x))\mathrm{d}x = \int Im(e^{ix})\mathrm{d}x = Im(\int e^{ix} \mathrm{d}x)$ here. Knowing, t
Expected Value of $X \sin(X)$ with $X$ normally distributed Like many exercises involving trigonometric functions, the trick is to use complex numbers, i.e., $\int(\sin(x))\mathrm{d}x = \int Im(e^{ix})\mathrm{d}x = Im(\int e^{ix} \mathrm{d}x)$ here. Knowing, the sum becomes \begin{align} I \triangleq \mathbb{E}[X\sin(X)] = Im \left( \int_{\mathbb{R}} x e^{ix} e^{-\frac{1}{2\sigma^2} (x-\mu)^2} \mathrm{d}x \right) . \end{align} To compute this sum, we have to factorise the two exponential terms. A rule of thumb for such calculation is that a gaussian stays gaussian when multiplied by an exponential term of the form $e^{ax}$. I let you do the math, but one can write \begin{equation} -\frac{1}{2\sigma^2} (x-\mu)^2 + ix = -\frac{1}{2 \sigma^2}\big( x- (\mu+i\sigma^2) \big)^2 + i\mu - \frac{\sigma^2}{2} . \end{equation} Then, by recognising the expectation of a new gaussian distribution \begin{align} I =& Im \left( e^{-\frac{\sigma^2}{2} + i\mu} \int_{\mathbb{R}} \frac{1}{\sqrt{2\pi \sigma^2}} x e^{-\frac{1}{2\sigma^2}(x - \mu - i\sigma^2)^2} \mathrm{d}x \right) \\ =& Im \left( e^{-\frac{\sigma^2}{2} + i\mu} \times (\mu + i \sigma^2) \right) \\ =&e^{-\frac{\sigma^2}{2}} \times \left( \sigma^2 \cos(\mu) + \mu \sin(\mu) \right), \end{align} which corresponds to wolfies's answer.
Expected Value of $X \sin(X)$ with $X$ normally distributed Like many exercises involving trigonometric functions, the trick is to use complex numbers, i.e., $\int(\sin(x))\mathrm{d}x = \int Im(e^{ix})\mathrm{d}x = Im(\int e^{ix} \mathrm{d}x)$ here. Knowing, t
44,367
Expected Value of $X \sin(X)$ with $X$ normally distributed
Have you tried a computer algebra system? Here $X \sim N(\mu, \sigma^2)$ with pdf $f(x)$: Here is the output from mathStatica / Mathematica:
Expected Value of $X \sin(X)$ with $X$ normally distributed
Have you tried a computer algebra system? Here $X \sim N(\mu, \sigma^2)$ with pdf $f(x)$: Here is the output from mathStatica / Mathematica:
Expected Value of $X \sin(X)$ with $X$ normally distributed Have you tried a computer algebra system? Here $X \sim N(\mu, \sigma^2)$ with pdf $f(x)$: Here is the output from mathStatica / Mathematica:
Expected Value of $X \sin(X)$ with $X$ normally distributed Have you tried a computer algebra system? Here $X \sim N(\mu, \sigma^2)$ with pdf $f(x)$: Here is the output from mathStatica / Mathematica:
44,368
What is the jacobian for a neural network
A Jacobian is quite a general term indeed. Lets take this simple, single-hidden-layer network $$\hat{\boldsymbol{y}} = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b}^{(0)}) + \boldsymbol{b}^{(1)})$$ as an example. When looking around online, I found most people (e.g. here or here) to refer to the weight updates, i.e. $$\frac{\partial \hat{y}}{\partial W^{(0)}_{ij}}, \frac{\partial \hat{y}}{\partial W^{(1)}_{ij}}, \frac{\partial \hat{y}}{\partial b^{(0)}_i}, \frac{\partial \hat{y}}{\partial b^{(1)}_i} $$ In my opinion, though, the Jacobian of a neural network should rather be the Jacobian of the function that is represented by the neural network, i.e. $$net : \mathbb{R}^m \to \mathbb{R}^n : \boldsymbol{x} \mapsto net(\boldsymbol{x}) = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b}^{(0)}) + \boldsymbol{b}^{(1)}),$$ where $m$ is the dimensionality of the input vectors (the number of features) and $n$ is the dimensionality of the output (the number of classes). The Jacobian of this network would then simply be $\mathbf{J} = \frac{\partial \hat{\boldsymbol{y}}}{\partial{\boldsymbol{x}}}$ with entries $J_{ij} = \frac{\partial \hat{y}_i}{\partial x_j}.$
What is the jacobian for a neural network
A Jacobian is quite a general term indeed. Lets take this simple, single-hidden-layer network $$\hat{\boldsymbol{y}} = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b
What is the jacobian for a neural network A Jacobian is quite a general term indeed. Lets take this simple, single-hidden-layer network $$\hat{\boldsymbol{y}} = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b}^{(0)}) + \boldsymbol{b}^{(1)})$$ as an example. When looking around online, I found most people (e.g. here or here) to refer to the weight updates, i.e. $$\frac{\partial \hat{y}}{\partial W^{(0)}_{ij}}, \frac{\partial \hat{y}}{\partial W^{(1)}_{ij}}, \frac{\partial \hat{y}}{\partial b^{(0)}_i}, \frac{\partial \hat{y}}{\partial b^{(1)}_i} $$ In my opinion, though, the Jacobian of a neural network should rather be the Jacobian of the function that is represented by the neural network, i.e. $$net : \mathbb{R}^m \to \mathbb{R}^n : \boldsymbol{x} \mapsto net(\boldsymbol{x}) = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b}^{(0)}) + \boldsymbol{b}^{(1)}),$$ where $m$ is the dimensionality of the input vectors (the number of features) and $n$ is the dimensionality of the output (the number of classes). The Jacobian of this network would then simply be $\mathbf{J} = \frac{\partial \hat{\boldsymbol{y}}}{\partial{\boldsymbol{x}}}$ with entries $J_{ij} = \frac{\partial \hat{y}_i}{\partial x_j}.$
What is the jacobian for a neural network A Jacobian is quite a general term indeed. Lets take this simple, single-hidden-layer network $$\hat{\boldsymbol{y}} = g(\mathbf{W}^{(1)} \cdot f(\mathbf{W}^{(0)} \cdot \boldsymbol{x} + \boldsymbol{b
44,369
What is the jacobian for a neural network
Classical approach for neural network is to take a batch of samples and calculate average gradient over these samples. For the Jacobian instead of calculating average gradient - you calculate gradient per each sample separately. At the end you end up with matrix that has N rows and M columns, where N is a number of sample propagated through the network and M is total number of parameter in the network. Every row in the Jacobian is the full gradient per individual input sample. Important to say that computing Jacobian for Neural Network is inefficient in case if you deal with large number of input samples.
What is the jacobian for a neural network
Classical approach for neural network is to take a batch of samples and calculate average gradient over these samples. For the Jacobian instead of calculating average gradient - you calculate gradient
What is the jacobian for a neural network Classical approach for neural network is to take a batch of samples and calculate average gradient over these samples. For the Jacobian instead of calculating average gradient - you calculate gradient per each sample separately. At the end you end up with matrix that has N rows and M columns, where N is a number of sample propagated through the network and M is total number of parameter in the network. Every row in the Jacobian is the full gradient per individual input sample. Important to say that computing Jacobian for Neural Network is inefficient in case if you deal with large number of input samples.
What is the jacobian for a neural network Classical approach for neural network is to take a batch of samples and calculate average gradient over these samples. For the Jacobian instead of calculating average gradient - you calculate gradient
44,370
What is the jacobian for a neural network
Just a graphical representation of what @Mr Tsjolder has said: The Input for the network is $\mathbf{X}$ and Let's take the network $\mathbf{O}$=$\mathbf{W}$*$\mathbf{X}$ (We can any other relationship also!! This is just an example!!) The Jacobian of this network would then simply be $\mathbf{J} = \frac{\partial {\mathbf{O}}}{\partial{\mathbf{X}}}$
What is the jacobian for a neural network
Just a graphical representation of what @Mr Tsjolder has said: The Input for the network is $\mathbf{X}$ and Let's take the network $\mathbf{O}$=$\mathbf{W}$*$\mathbf{X}$ (We can any other relationshi
What is the jacobian for a neural network Just a graphical representation of what @Mr Tsjolder has said: The Input for the network is $\mathbf{X}$ and Let's take the network $\mathbf{O}$=$\mathbf{W}$*$\mathbf{X}$ (We can any other relationship also!! This is just an example!!) The Jacobian of this network would then simply be $\mathbf{J} = \frac{\partial {\mathbf{O}}}{\partial{\mathbf{X}}}$
What is the jacobian for a neural network Just a graphical representation of what @Mr Tsjolder has said: The Input for the network is $\mathbf{X}$ and Let's take the network $\mathbf{O}$=$\mathbf{W}$*$\mathbf{X}$ (We can any other relationshi
44,371
Use of prior and posterior predictive distributions?
Some uses of the posterior predictive: Simulating future data based on your model assumptions and data observed to this point. This is useful for predictions, forecasting, etc. Model checking via posterior predictive checking. Some comments have directed you to Bayesian Data Analysis, and its author has made a relevant chapter available. Tim's answer to this question should also prove helpful. I've less help to offer on the prior predictive. I've found it useful as a sort of summary check on my combined priors: It can serve as an intuitive summary of your ultimate prior assumptions on expected data. In a similar vein, some view it as a tool to arrive at informative priors. Consider this correspondence shared on Andrew Gelman's blog: I don’t ever see parameters. Some model have few and some have hundreds. Instead, I see data. So I don’t know how to have an opinion on parameters themselves. Rather I think it far more natural to have opinions on the behavior of models. The prior predictive density is a good and sensible notion. A further post continues: The goal is to use the β€œblack box” of the prior predictive density and the prior conditional density (the conditional in particular since you can look at model behaviour in a dynamic, scenario based setting) to inform us about how the informative priors should be constrained. Put another way, if you're struggling to set prior parameters, you may find it sensible to examine those parameters' consequences on expected data. Doing so requires the prior predictive.
Use of prior and posterior predictive distributions?
Some uses of the posterior predictive: Simulating future data based on your model assumptions and data observed to this point. This is useful for predictions, forecasting, etc. Model checking via pos
Use of prior and posterior predictive distributions? Some uses of the posterior predictive: Simulating future data based on your model assumptions and data observed to this point. This is useful for predictions, forecasting, etc. Model checking via posterior predictive checking. Some comments have directed you to Bayesian Data Analysis, and its author has made a relevant chapter available. Tim's answer to this question should also prove helpful. I've less help to offer on the prior predictive. I've found it useful as a sort of summary check on my combined priors: It can serve as an intuitive summary of your ultimate prior assumptions on expected data. In a similar vein, some view it as a tool to arrive at informative priors. Consider this correspondence shared on Andrew Gelman's blog: I don’t ever see parameters. Some model have few and some have hundreds. Instead, I see data. So I don’t know how to have an opinion on parameters themselves. Rather I think it far more natural to have opinions on the behavior of models. The prior predictive density is a good and sensible notion. A further post continues: The goal is to use the β€œblack box” of the prior predictive density and the prior conditional density (the conditional in particular since you can look at model behaviour in a dynamic, scenario based setting) to inform us about how the informative priors should be constrained. Put another way, if you're struggling to set prior parameters, you may find it sensible to examine those parameters' consequences on expected data. Doing so requires the prior predictive.
Use of prior and posterior predictive distributions? Some uses of the posterior predictive: Simulating future data based on your model assumptions and data observed to this point. This is useful for predictions, forecasting, etc. Model checking via pos
44,372
Use of prior and posterior predictive distributions?
Let's you denote your data as $X$ and imagine that you have some probabilistic model that describes your data in terms of the likelihood of observing your data given some parameter $\theta$. The parameter $\theta$ is unknown and is to be estimated from your data. To estimate your parameter you could use many different approaches, e.g. use maximum likelihood estimation to find such value of $\theta$ that maximizes the likelihood, or use Bayesian approach. In Bayesian approach to estimate the parameter we need one more thing, a prior distribution for $\theta$. If you take those things together, you can use Bayes theorem to obtain the posterior distribution of $\theta$ (i.e. your estimate): $$ \underbrace{p(\theta|X)}_\text{posterior} \propto \underbrace{p(X|\theta)}_\text{likelihood} \, \underbrace{p(\theta)}_\text{prior} $$ So to catch up: prior is the distribution of $\theta$ that is assumed by you before seeing the data. You do not "know" it, it is something that you assume. likelihood is the conditional distribution of data given the prior, it defines your model, posterior is the "estimated" distribution of parameter $\theta$ given data and the prior, posterior predictive distribution is the distribution of data that is "predicted" by your model given your data and the prior, it describes your predictions from the model. For example, in the classical beta-binomial model (see beta-binomial for multiple examples and more details) we have $$ X \mid \theta \sim \mathrm{Binom}(n, \theta) \\ \theta \sim \mathrm{Beta}(\alpha, \beta) $$ so binomial distribution parametrized by $\theta$ is our likelihood, beta distribution with hyperparameters $\alpha,\beta$ is our prior and by using conjugacy we can obtain a closed-form solution for posterior $$ \theta \mid X \sim \mathrm{Beta}(x+\alpha, n-x+\beta) $$ and posterior predictive distribution $$ \tilde X \mid X,\theta \sim \mathrm{BetaBinom}(n, x+\alpha, n-x+\beta) $$ where $\tilde X$ are the $X$'s predicted by our model. If this all is still unclear for you you can check the multiple threads tagged as bayesian on this site, or multiple handbooks on this topic.
Use of prior and posterior predictive distributions?
Let's you denote your data as $X$ and imagine that you have some probabilistic model that describes your data in terms of the likelihood of observing your data given some parameter $\theta$. The param
Use of prior and posterior predictive distributions? Let's you denote your data as $X$ and imagine that you have some probabilistic model that describes your data in terms of the likelihood of observing your data given some parameter $\theta$. The parameter $\theta$ is unknown and is to be estimated from your data. To estimate your parameter you could use many different approaches, e.g. use maximum likelihood estimation to find such value of $\theta$ that maximizes the likelihood, or use Bayesian approach. In Bayesian approach to estimate the parameter we need one more thing, a prior distribution for $\theta$. If you take those things together, you can use Bayes theorem to obtain the posterior distribution of $\theta$ (i.e. your estimate): $$ \underbrace{p(\theta|X)}_\text{posterior} \propto \underbrace{p(X|\theta)}_\text{likelihood} \, \underbrace{p(\theta)}_\text{prior} $$ So to catch up: prior is the distribution of $\theta$ that is assumed by you before seeing the data. You do not "know" it, it is something that you assume. likelihood is the conditional distribution of data given the prior, it defines your model, posterior is the "estimated" distribution of parameter $\theta$ given data and the prior, posterior predictive distribution is the distribution of data that is "predicted" by your model given your data and the prior, it describes your predictions from the model. For example, in the classical beta-binomial model (see beta-binomial for multiple examples and more details) we have $$ X \mid \theta \sim \mathrm{Binom}(n, \theta) \\ \theta \sim \mathrm{Beta}(\alpha, \beta) $$ so binomial distribution parametrized by $\theta$ is our likelihood, beta distribution with hyperparameters $\alpha,\beta$ is our prior and by using conjugacy we can obtain a closed-form solution for posterior $$ \theta \mid X \sim \mathrm{Beta}(x+\alpha, n-x+\beta) $$ and posterior predictive distribution $$ \tilde X \mid X,\theta \sim \mathrm{BetaBinom}(n, x+\alpha, n-x+\beta) $$ where $\tilde X$ are the $X$'s predicted by our model. If this all is still unclear for you you can check the multiple threads tagged as bayesian on this site, or multiple handbooks on this topic.
Use of prior and posterior predictive distributions? Let's you denote your data as $X$ and imagine that you have some probabilistic model that describes your data in terms of the likelihood of observing your data given some parameter $\theta$. The param
44,373
Analysis strategy for rare outcome with matching
Removing good data from an analysis is scientifically suspect in my humble opinion, and naive matching methods are inefficient. It may be very easy to adjust for patient characteristics using ordinary regression models, paying attention to linearity assumptions etc. Of course it is a good idea to look at overlap in covariate distributions across treatment groups to see where assumptions of no interaction between treatment and characteristics might be on shaky ground and untestable.
Analysis strategy for rare outcome with matching
Removing good data from an analysis is scientifically suspect in my humble opinion, and naive matching methods are inefficient. It may be very easy to adjust for patient characteristics using ordinar
Analysis strategy for rare outcome with matching Removing good data from an analysis is scientifically suspect in my humble opinion, and naive matching methods are inefficient. It may be very easy to adjust for patient characteristics using ordinary regression models, paying attention to linearity assumptions etc. Of course it is a good idea to look at overlap in covariate distributions across treatment groups to see where assumptions of no interaction between treatment and characteristics might be on shaky ground and untestable.
Analysis strategy for rare outcome with matching Removing good data from an analysis is scientifically suspect in my humble opinion, and naive matching methods are inefficient. It may be very easy to adjust for patient characteristics using ordinar
44,374
Analysis strategy for rare outcome with matching
Based on the comments and the availability of such a large control group, I would probably advise to do in a step first exact matching on age groups and sex, and perhaps common disease groups. Hereby, you built different strata. In a second step, you can apply propensity score matching to ensure that treatment and control group are as balanced as possible with respect to the remaining observables. You can do this apparently using the psmatch2 package for Stata (I have used that package only briefly out of interested). A code example is given in the help file: g att = . egen g = group(groupvars) levels g, local(gr) qui foreach j of local gr { psmatch2 treatvar varlist if g==`j', out(outvar) replace att = r(att) if g==`j' } sum att See here for further information http://repec.org/bocode/p/psmatch2.html You should -- of course -- verify that there is enough overlap between treatment and control group within each strata. * Update: Response to the comment of Frank Harrell * Why I argue for matching: It is a trade-off between, on the one hand, balancing covariates as close as possible between treatment and control group, and, on the other hand, removing data (what Frank Harrell emphasized). It is clear that the estimator becomes in a first step less efficient if you remove data, and you should justify ignoring data. But radek has asked for matching approaches and I agree that this is a good idea. Matching avoids to some extent "extrapolation bias" if the covariate distribution differs between treatment and control group. You drop observations which give you few or any information about the treatment effect because their covariates are very far away from the sample. Many prominent researchers therefore recommend matching or subclassificatioon plus regression. See Imbens & Rubin, Ho et al., Imbens & Wooldridge
Analysis strategy for rare outcome with matching
Based on the comments and the availability of such a large control group, I would probably advise to do in a step first exact matching on age groups and sex, and perhaps common disease groups. Hereby,
Analysis strategy for rare outcome with matching Based on the comments and the availability of such a large control group, I would probably advise to do in a step first exact matching on age groups and sex, and perhaps common disease groups. Hereby, you built different strata. In a second step, you can apply propensity score matching to ensure that treatment and control group are as balanced as possible with respect to the remaining observables. You can do this apparently using the psmatch2 package for Stata (I have used that package only briefly out of interested). A code example is given in the help file: g att = . egen g = group(groupvars) levels g, local(gr) qui foreach j of local gr { psmatch2 treatvar varlist if g==`j', out(outvar) replace att = r(att) if g==`j' } sum att See here for further information http://repec.org/bocode/p/psmatch2.html You should -- of course -- verify that there is enough overlap between treatment and control group within each strata. * Update: Response to the comment of Frank Harrell * Why I argue for matching: It is a trade-off between, on the one hand, balancing covariates as close as possible between treatment and control group, and, on the other hand, removing data (what Frank Harrell emphasized). It is clear that the estimator becomes in a first step less efficient if you remove data, and you should justify ignoring data. But radek has asked for matching approaches and I agree that this is a good idea. Matching avoids to some extent "extrapolation bias" if the covariate distribution differs between treatment and control group. You drop observations which give you few or any information about the treatment effect because their covariates are very far away from the sample. Many prominent researchers therefore recommend matching or subclassificatioon plus regression. See Imbens & Rubin, Ho et al., Imbens & Wooldridge
Analysis strategy for rare outcome with matching Based on the comments and the availability of such a large control group, I would probably advise to do in a step first exact matching on age groups and sex, and perhaps common disease groups. Hereby,
44,375
Analysis strategy for rare outcome with matching
The propensity score (PS) is a balancing score indicating the probability of treatment assignment conditional on observed baseline characteristics. In a randomized controlled Trial (RCT) the PS is known. Estimation and application of PS therefore, mimic some of the particular characteristics of an RCT and therefore are method of choice to estimate the treatment effect in an observational study, provided that you have no unmeasured confounders and all subjects have a non-zero probability of receiving Treatment. You can estimate the PS using logistic regression or generalized boosting methods and therefore, include all observed (continous and categorical) baseline variables. Notably, you do not include the outcome parameter. (There is an ongoing debate, which variables to include, however, Austin postulates it is safe to include all observed baseline variables https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3144483/). It is important to underscore that you do not aim to find the best "predictive model" but instead the model that balances your covariates best. After application of the PS using stratification, matching, inverse probability Treatment weights or covariate adjustment (all of them have pros and cons and are somewhat dependent on your data), you can test the treatment effect on your outcomes.
Analysis strategy for rare outcome with matching
The propensity score (PS) is a balancing score indicating the probability of treatment assignment conditional on observed baseline characteristics. In a randomized controlled Trial (RCT) the PS is kn
Analysis strategy for rare outcome with matching The propensity score (PS) is a balancing score indicating the probability of treatment assignment conditional on observed baseline characteristics. In a randomized controlled Trial (RCT) the PS is known. Estimation and application of PS therefore, mimic some of the particular characteristics of an RCT and therefore are method of choice to estimate the treatment effect in an observational study, provided that you have no unmeasured confounders and all subjects have a non-zero probability of receiving Treatment. You can estimate the PS using logistic regression or generalized boosting methods and therefore, include all observed (continous and categorical) baseline variables. Notably, you do not include the outcome parameter. (There is an ongoing debate, which variables to include, however, Austin postulates it is safe to include all observed baseline variables https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3144483/). It is important to underscore that you do not aim to find the best "predictive model" but instead the model that balances your covariates best. After application of the PS using stratification, matching, inverse probability Treatment weights or covariate adjustment (all of them have pros and cons and are somewhat dependent on your data), you can test the treatment effect on your outcomes.
Analysis strategy for rare outcome with matching The propensity score (PS) is a balancing score indicating the probability of treatment assignment conditional on observed baseline characteristics. In a randomized controlled Trial (RCT) the PS is kn
44,376
Unbiased estimator of variance for a sample drawn from a finite population without replacement
When sampling from a finite population without replacement, the observations are negatively correlated with each other, and the sample variance $s^2 = \frac{1}{n-1} \sum_i \left( x_i - \bar{x} \right)^2$ is a slightly biased estimate of the population variance $\sigma^2$. The derivation in this link from Robert Serfling provides a clear explanation of what's going on. The author first proves that if the observations in a sample have constant covariance (i.e. $\mathrm{Cov}\left(x_i, x_j \right) = \gamma$ for all $i\neq j$) that: $$ E[s^2] = \sigma^2 - \gamma$$ For independent draws (hence $\gamma = 0$), you have $E[s^2] = \sigma^2$ and the sample variance is an unbiased estimate of the population variance. But the issue you have with sampling without replacement from a finite population is that your draws are negatively correlated with each other! In the case of sampling without replacement from a population of size $N$: $$ \text{For $i\neq j$ }\quad \mathrm{Cov}\left(x_i, x_j \right) = \frac{-\sigma^2}{N-1}$$ Hence: $$ E\left[s^2\right] = \frac{N}{N-1}\sigma^2 $$
Unbiased estimator of variance for a sample drawn from a finite population without replacement
When sampling from a finite population without replacement, the observations are negatively correlated with each other, and the sample variance $s^2 = \frac{1}{n-1} \sum_i \left( x_i - \bar{x} \right)
Unbiased estimator of variance for a sample drawn from a finite population without replacement When sampling from a finite population without replacement, the observations are negatively correlated with each other, and the sample variance $s^2 = \frac{1}{n-1} \sum_i \left( x_i - \bar{x} \right)^2$ is a slightly biased estimate of the population variance $\sigma^2$. The derivation in this link from Robert Serfling provides a clear explanation of what's going on. The author first proves that if the observations in a sample have constant covariance (i.e. $\mathrm{Cov}\left(x_i, x_j \right) = \gamma$ for all $i\neq j$) that: $$ E[s^2] = \sigma^2 - \gamma$$ For independent draws (hence $\gamma = 0$), you have $E[s^2] = \sigma^2$ and the sample variance is an unbiased estimate of the population variance. But the issue you have with sampling without replacement from a finite population is that your draws are negatively correlated with each other! In the case of sampling without replacement from a population of size $N$: $$ \text{For $i\neq j$ }\quad \mathrm{Cov}\left(x_i, x_j \right) = \frac{-\sigma^2}{N-1}$$ Hence: $$ E\left[s^2\right] = \frac{N}{N-1}\sigma^2 $$
Unbiased estimator of variance for a sample drawn from a finite population without replacement When sampling from a finite population without replacement, the observations are negatively correlated with each other, and the sample variance $s^2 = \frac{1}{n-1} \sum_i \left( x_i - \bar{x} \right)
44,377
Unbiased estimator of variance for a sample drawn from a finite population without replacement
The sample variance is indeed biased for a finite population with simple random sampling without replacement. And the solution to get an unbiased result is to multiply the sample variance by $\frac{N-1}{N}$, where $N$ is the population size. I’m an engineer, not a mathematician. So my proof was to build a complete sampling distribution in Excel from a finite population and assuming sampling without replacement. I found that the mean of the sampling distribution sample variances ($s^2$) did not equal the population variance. $s^2$ is biased in this case. I don’t know why the literature so often ignores this fact. But if I multiply the mean $s^2$ by $\frac{N-1}{N}$, where $N$ is the population size, then lo and behold the product is exactly equal to the population variance. Intuitively, as my sample size n increases and approaches and eventually equals the population size $N$ ($n=N$), I should expect the sample variance to approach the population variance if the sample variance is unbiased. That does not happen since the sample is divided by $n-1$ and the population by $N$. Multiplying the sample variance by $\frac{N-1}{N}$ solves this dilemma.
Unbiased estimator of variance for a sample drawn from a finite population without replacement
The sample variance is indeed biased for a finite population with simple random sampling without replacement. And the solution to get an unbiased result is to multiply the sample variance by $\frac{N-
Unbiased estimator of variance for a sample drawn from a finite population without replacement The sample variance is indeed biased for a finite population with simple random sampling without replacement. And the solution to get an unbiased result is to multiply the sample variance by $\frac{N-1}{N}$, where $N$ is the population size. I’m an engineer, not a mathematician. So my proof was to build a complete sampling distribution in Excel from a finite population and assuming sampling without replacement. I found that the mean of the sampling distribution sample variances ($s^2$) did not equal the population variance. $s^2$ is biased in this case. I don’t know why the literature so often ignores this fact. But if I multiply the mean $s^2$ by $\frac{N-1}{N}$, where $N$ is the population size, then lo and behold the product is exactly equal to the population variance. Intuitively, as my sample size n increases and approaches and eventually equals the population size $N$ ($n=N$), I should expect the sample variance to approach the population variance if the sample variance is unbiased. That does not happen since the sample is divided by $n-1$ and the population by $N$. Multiplying the sample variance by $\frac{N-1}{N}$ solves this dilemma.
Unbiased estimator of variance for a sample drawn from a finite population without replacement The sample variance is indeed biased for a finite population with simple random sampling without replacement. And the solution to get an unbiased result is to multiply the sample variance by $\frac{N-
44,378
Unbiased estimator of variance for a sample drawn from a finite population without replacement
I don't know where your statements come from, but it the way you present them they are false. Taking directly the variance of the sample (that is, dividing by $n$) we get a biased estimator, but using sample variance (dividing by $n-1$) we get an unbiased estimator. I think your statement comes from different conflicting sources or your source uses different notations in different parts. Maybe "$s^2$" means variance ($n$) in one page and sample variance ($n-1$) in the other. The fact that one formula uses "$n$" with the same meaning the other uses "$N$" makes me suspect that they aren't consistent.
Unbiased estimator of variance for a sample drawn from a finite population without replacement
I don't know where your statements come from, but it the way you present them they are false. Taking directly the variance of the sample (that is, dividing by $n$) we get a biased estimator, but using
Unbiased estimator of variance for a sample drawn from a finite population without replacement I don't know where your statements come from, but it the way you present them they are false. Taking directly the variance of the sample (that is, dividing by $n$) we get a biased estimator, but using sample variance (dividing by $n-1$) we get an unbiased estimator. I think your statement comes from different conflicting sources or your source uses different notations in different parts. Maybe "$s^2$" means variance ($n$) in one page and sample variance ($n-1$) in the other. The fact that one formula uses "$n$" with the same meaning the other uses "$N$" makes me suspect that they aren't consistent.
Unbiased estimator of variance for a sample drawn from a finite population without replacement I don't know where your statements come from, but it the way you present them they are false. Taking directly the variance of the sample (that is, dividing by $n$) we get a biased estimator, but using
44,379
Can the coefficients of dummy variables be more than 1 or less than 0?
Yes, coefficients of dummy variables can be more than one or less than zero. Remember that you can interpret that coefficient as the mean change in your response (dependent) variable when the dummy changes from 0 to 1, holding all other variables constant (i.e. ceteris paribus). The mean height of people in the United States is around 176 cm for males and 162 cm for females. If we regressed our dependent variable $\text{Height}$ against a dummy variable $\text{Male}$ (which is one for males and zero for females), then in the model $$\text{Height}_i = \beta_0 + \beta_1 \text{Male}_i + \varepsilon_i$$ we would estimate $\hat \beta_0 = 162$ and $\hat \beta_1 = 176 - 162 = 14$, meaning that the mean height is 162 cm when the dummy is zero (i.e. at the baseline or reference level, which is female in our case) and mean height increases by 14 cm when the dummy variable changes from 0 to 1 (in other words males are, relative to females, 14 cm taller). If instead we used a dummy variable $\text{Female}$, coded one for females and zero for males, then in the model $$\text{Height}_i = \beta_0 + \beta_1 \text{Female}_i + \varepsilon_i$$ we would estimate $\hat \beta_0 = 176$ and $\hat \beta_1 = 162 - 176 = -14$, meaning that the mean height is 176 cm for males (baseline) and mean height is 14 cm lower for females relative to males. (If you are surprised that coefficients of dummies do not have to lie between zero and one, I wonder whether you are incorrectly thinking of the coefficient as the effect on, or value of, the dummy itself?)
Can the coefficients of dummy variables be more than 1 or less than 0?
Yes, coefficients of dummy variables can be more than one or less than zero. Remember that you can interpret that coefficient as the mean change in your response (dependent) variable when the dummy ch
Can the coefficients of dummy variables be more than 1 or less than 0? Yes, coefficients of dummy variables can be more than one or less than zero. Remember that you can interpret that coefficient as the mean change in your response (dependent) variable when the dummy changes from 0 to 1, holding all other variables constant (i.e. ceteris paribus). The mean height of people in the United States is around 176 cm for males and 162 cm for females. If we regressed our dependent variable $\text{Height}$ against a dummy variable $\text{Male}$ (which is one for males and zero for females), then in the model $$\text{Height}_i = \beta_0 + \beta_1 \text{Male}_i + \varepsilon_i$$ we would estimate $\hat \beta_0 = 162$ and $\hat \beta_1 = 176 - 162 = 14$, meaning that the mean height is 162 cm when the dummy is zero (i.e. at the baseline or reference level, which is female in our case) and mean height increases by 14 cm when the dummy variable changes from 0 to 1 (in other words males are, relative to females, 14 cm taller). If instead we used a dummy variable $\text{Female}$, coded one for females and zero for males, then in the model $$\text{Height}_i = \beta_0 + \beta_1 \text{Female}_i + \varepsilon_i$$ we would estimate $\hat \beta_0 = 176$ and $\hat \beta_1 = 162 - 176 = -14$, meaning that the mean height is 176 cm for males (baseline) and mean height is 14 cm lower for females relative to males. (If you are surprised that coefficients of dummies do not have to lie between zero and one, I wonder whether you are incorrectly thinking of the coefficient as the effect on, or value of, the dummy itself?)
Can the coefficients of dummy variables be more than 1 or less than 0? Yes, coefficients of dummy variables can be more than one or less than zero. Remember that you can interpret that coefficient as the mean change in your response (dependent) variable when the dummy ch
44,380
R - lmer vs glmer
lmer is used to fit linear mixed-effect models, so it assumes that the residual error has a Gaussian distribution. If your dependent variable A is a binary outcome (e.g. a yes/no response), then the error distribution is binomial and not Gaussian. In this case you have to use glmer, which allow to fit a generalized linear mixed-effects model: these models include a link function that allows to predict response variables with non-Gaussian distributions. One example of link function that could work in your case is the logistic function, which takes an input with any value from negative to positive infinity and return an output that always takes values between zero and one, which is interpretable as the probability of the binary outcome (e.g. the probability of the subject responding 'yes'). About the repeated measurement design, both lmer and glmer can handle it equally well, you just have to set 'subject' as a grouping factor (in the random-effect part of the model) for the within-subject predictors. In this way you allow these predictors to have a fixed-effect (common to all subjects) and a subject-specific random effect, so that you can test statistically the effect common to all subjects, and treat the subject-specific variations as a nuisance term. For more details on how to proceed I would recommend this excellent book by Knoblauch and Maloney that dedicates a large section on the application of mixed-effects models (using R and the lme4 library) to the modelling of psychophysical data.
R - lmer vs glmer
lmer is used to fit linear mixed-effect models, so it assumes that the residual error has a Gaussian distribution. If your dependent variable A is a binary outcome (e.g. a yes/no response), then the e
R - lmer vs glmer lmer is used to fit linear mixed-effect models, so it assumes that the residual error has a Gaussian distribution. If your dependent variable A is a binary outcome (e.g. a yes/no response), then the error distribution is binomial and not Gaussian. In this case you have to use glmer, which allow to fit a generalized linear mixed-effects model: these models include a link function that allows to predict response variables with non-Gaussian distributions. One example of link function that could work in your case is the logistic function, which takes an input with any value from negative to positive infinity and return an output that always takes values between zero and one, which is interpretable as the probability of the binary outcome (e.g. the probability of the subject responding 'yes'). About the repeated measurement design, both lmer and glmer can handle it equally well, you just have to set 'subject' as a grouping factor (in the random-effect part of the model) for the within-subject predictors. In this way you allow these predictors to have a fixed-effect (common to all subjects) and a subject-specific random effect, so that you can test statistically the effect common to all subjects, and treat the subject-specific variations as a nuisance term. For more details on how to proceed I would recommend this excellent book by Knoblauch and Maloney that dedicates a large section on the application of mixed-effects models (using R and the lme4 library) to the modelling of psychophysical data.
R - lmer vs glmer lmer is used to fit linear mixed-effect models, so it assumes that the residual error has a Gaussian distribution. If your dependent variable A is a binary outcome (e.g. a yes/no response), then the e
44,381
difference between Nash-Sutcliffe efficiency and coefficient of determination
The Nash-Sutcliffe model efficiency coefficient is nearly identical to the coefficient of determination. The primary difference is how it is used. The coefficient of determination ($R^2$) is a measure of the goodness of fit of a statistical model. \begin{equation} \begin{aligned} R^2 = 1 - \frac{\sum (y_i - \hat{y_i})^2}{\sum (y_i - \bar{y})^2} \end{aligned} \end{equation} Where $y_i$ are the observed values of the variable of interest, $\hat{y_i}$ are the predicted values, and $\bar{y}$ is the mean of the observations. For example, if we have a set of obervations $x_i$ and $y_i$, we might assume a linear model $y=ax + b$ to predict this relationship, resulting in set of predicted values, $\hat{y_i}$. The smallest $R^2$ occurs when there is no correlation between $x$ and $y$ and the best prediction is to assume $b=\bar{y}$ and $m=0$. This corresponds to an $R^2$ value of 0, which is the lower limit of $R^2$ because the the sum of squares of the rediduals, $\sum (y_i - \hat{y_i})^2$, will never be greater than the total sum of squares, $\sum (y_i - \bar{y})^2$. The Nash-Sutcliffe model efficiency coefficient ($E$) is used to quantify how well a model simulation can predict the outcome variable. \begin{equation} \begin{aligned} E = 1 - \frac{\sum (y_i - y_{i,sim})^2}{\sum (y_i - \bar{y})^2} \end{aligned} \end{equation} The variables are the same as described above, but $y_{i,sim}$ are the predictions from the simulation (instead of the $\hat{y_i}$ from a statistical model). The model may be calibrated, but the predicted values of the outcome variable $y_{i,sim}$ are not inferred from the observed values. Unlike with a statistical model, the sum of squares of the model error, $\sum (y_i - y_{i,sim})^2$, may be greater than the total sum of squares, $\sum (y_i - \bar{y})^2$, and the coefficient can therefore be negative.
difference between Nash-Sutcliffe efficiency and coefficient of determination
The Nash-Sutcliffe model efficiency coefficient is nearly identical to the coefficient of determination. The primary difference is how it is used. The coefficient of determination ($R^2$) is a measure
difference between Nash-Sutcliffe efficiency and coefficient of determination The Nash-Sutcliffe model efficiency coefficient is nearly identical to the coefficient of determination. The primary difference is how it is used. The coefficient of determination ($R^2$) is a measure of the goodness of fit of a statistical model. \begin{equation} \begin{aligned} R^2 = 1 - \frac{\sum (y_i - \hat{y_i})^2}{\sum (y_i - \bar{y})^2} \end{aligned} \end{equation} Where $y_i$ are the observed values of the variable of interest, $\hat{y_i}$ are the predicted values, and $\bar{y}$ is the mean of the observations. For example, if we have a set of obervations $x_i$ and $y_i$, we might assume a linear model $y=ax + b$ to predict this relationship, resulting in set of predicted values, $\hat{y_i}$. The smallest $R^2$ occurs when there is no correlation between $x$ and $y$ and the best prediction is to assume $b=\bar{y}$ and $m=0$. This corresponds to an $R^2$ value of 0, which is the lower limit of $R^2$ because the the sum of squares of the rediduals, $\sum (y_i - \hat{y_i})^2$, will never be greater than the total sum of squares, $\sum (y_i - \bar{y})^2$. The Nash-Sutcliffe model efficiency coefficient ($E$) is used to quantify how well a model simulation can predict the outcome variable. \begin{equation} \begin{aligned} E = 1 - \frac{\sum (y_i - y_{i,sim})^2}{\sum (y_i - \bar{y})^2} \end{aligned} \end{equation} The variables are the same as described above, but $y_{i,sim}$ are the predictions from the simulation (instead of the $\hat{y_i}$ from a statistical model). The model may be calibrated, but the predicted values of the outcome variable $y_{i,sim}$ are not inferred from the observed values. Unlike with a statistical model, the sum of squares of the model error, $\sum (y_i - y_{i,sim})^2$, may be greater than the total sum of squares, $\sum (y_i - \bar{y})^2$, and the coefficient can therefore be negative.
difference between Nash-Sutcliffe efficiency and coefficient of determination The Nash-Sutcliffe model efficiency coefficient is nearly identical to the coefficient of determination. The primary difference is how it is used. The coefficient of determination ($R^2$) is a measure
44,382
difference between Nash-Sutcliffe efficiency and coefficient of determination
This answer is directly copied from Krause et al., (2005) Krause P, Boyle DP, BΓ€se F. 2005. Comparison of different efficiency criteria for hydrological model assessment. Advances in Geosciences 5 (5): 89–97 DOI: 10.5194/adgeo-5-89-2005 The coefficient of determination r2 is defined as the squared value of the coefficient of correlation. R2 can also be expressed as the squared ratio between the covariance and the multiplied standard deviations of the observed and predicted values. Therefore it estimates the combined dispersion against the single dispersion of the observed and predicted series. The range of r2 lies between 0 and 1 which describes how much of the observed dispersion is explained by the prediction. A value of zero means no correlation at all whereas a value of 1 means that the dispersion of the prediction is equal to that of the observation. The fact that only the dispersion is quantified is one of the ma jor drawbacks of r2 if it is considered alone. A model which systematically over- or underpredicts all the time will still result in good r2 values close to 1.0 even if all predictions were wrong. If r2 is used for model validation it therefore is advisable to take into account additional information which can cope with that problem. Such information is provided by the gradient b and the intercept a of the regression on which r2 is based. For a good agreement the intercept a should be close to zero which means that an observed runoff of zero would also result in a prediction near zero and the gradient b should be close to one. The efficiency E proposed by Nash and Sutcliffe (1970) is defined as one minus the sum of the absolute squared differences between the predicted and observed values normalized by the variance of the observed values during the period un der investigation. It is calculated as: The normalization of the variance of the observation series results in relatively higher values of E in catchments with higher dynamics and lower values of E in catchments with lower dynamics. To obtain comparable values of E in a catchment with lower dynamics the prediction has to be bet- ter than in a basin with high dynamics. The range of E lies between 1.0 (perfect fit) and βˆ’βˆž. An efficiency of lower than zero indicates that the mean value of the observed time series would have been a better predictor than the model. The largest disadvantage of the Nash-Sutcliffe efficiency is the fact that the differences between the observed and predicted values are calculated as squared values. As a re- sult larger values in a time series are strongly overestimated whereas lower values are neglected (Legates and McCabe, 1999). For the quantification of runoff predictions this leads to an overestimation of the model performance during peak flows and an underestimation during low flow conditions. Similar to r2, the Nash-Sutcliffe is not very sensitive to sys- tematic model over- or underprediction especially during low flow periods.
difference between Nash-Sutcliffe efficiency and coefficient of determination
This answer is directly copied from Krause et al., (2005) Krause P, Boyle DP, BΓ€se F. 2005. Comparison of different efficiency criteria for hydrological model assessment. Advances in Geosciences 5 (5)
difference between Nash-Sutcliffe efficiency and coefficient of determination This answer is directly copied from Krause et al., (2005) Krause P, Boyle DP, BΓ€se F. 2005. Comparison of different efficiency criteria for hydrological model assessment. Advances in Geosciences 5 (5): 89–97 DOI: 10.5194/adgeo-5-89-2005 The coefficient of determination r2 is defined as the squared value of the coefficient of correlation. R2 can also be expressed as the squared ratio between the covariance and the multiplied standard deviations of the observed and predicted values. Therefore it estimates the combined dispersion against the single dispersion of the observed and predicted series. The range of r2 lies between 0 and 1 which describes how much of the observed dispersion is explained by the prediction. A value of zero means no correlation at all whereas a value of 1 means that the dispersion of the prediction is equal to that of the observation. The fact that only the dispersion is quantified is one of the ma jor drawbacks of r2 if it is considered alone. A model which systematically over- or underpredicts all the time will still result in good r2 values close to 1.0 even if all predictions were wrong. If r2 is used for model validation it therefore is advisable to take into account additional information which can cope with that problem. Such information is provided by the gradient b and the intercept a of the regression on which r2 is based. For a good agreement the intercept a should be close to zero which means that an observed runoff of zero would also result in a prediction near zero and the gradient b should be close to one. The efficiency E proposed by Nash and Sutcliffe (1970) is defined as one minus the sum of the absolute squared differences between the predicted and observed values normalized by the variance of the observed values during the period un der investigation. It is calculated as: The normalization of the variance of the observation series results in relatively higher values of E in catchments with higher dynamics and lower values of E in catchments with lower dynamics. To obtain comparable values of E in a catchment with lower dynamics the prediction has to be bet- ter than in a basin with high dynamics. The range of E lies between 1.0 (perfect fit) and βˆ’βˆž. An efficiency of lower than zero indicates that the mean value of the observed time series would have been a better predictor than the model. The largest disadvantage of the Nash-Sutcliffe efficiency is the fact that the differences between the observed and predicted values are calculated as squared values. As a re- sult larger values in a time series are strongly overestimated whereas lower values are neglected (Legates and McCabe, 1999). For the quantification of runoff predictions this leads to an overestimation of the model performance during peak flows and an underestimation during low flow conditions. Similar to r2, the Nash-Sutcliffe is not very sensitive to sys- tematic model over- or underprediction especially during low flow periods.
difference between Nash-Sutcliffe efficiency and coefficient of determination This answer is directly copied from Krause et al., (2005) Krause P, Boyle DP, BΓ€se F. 2005. Comparison of different efficiency criteria for hydrological model assessment. Advances in Geosciences 5 (5)
44,383
what is the meaning of 'tail' of kurtosis?
There are two parts to address here -- 1. what does it mean for something to be heavy-tailed? and 2. does higher kurtosis mean a heavier tail and vice-versa? What's heavy-tailed mean? a. What heavier tail means in a "handwavy" sense -- most people picture it this way: but because the tail is quite small, it's better to look at the log-density (which preserves the ordering of height of density) (that handwavy sense fails, however, in a variety of cases, including the rather basic situations of when you try to encompass distributions which are not continuous and unimodal) b. More strictly, a good definition (about which, see whuber's answer here) for heavy-tailedness would be that if $Y$ is heavier-tailed than $X$, as $t$ becomes sufficiently large, then $S_Y(t)>S_X(t)$ for all $t>t_0$ fr some $t_0$, where $S$ is the survivor function, $1-F$. [This is of course, for heavier-tailed on the right; there'd be a similar definition for left-tail heavy tailedness in terms of $F$ rather than $S$. When both tails are under consideration, as they would need to be for comparing kurtosis, "heavier tailed" would apply if it was heavier in both tails.] (Again, however, if you're trying to look at it, a log-scale comparison would often be more useful than a direct comparison of $S(t)$) How does heavy-tailedness relate to kurtosis? Now we have a definition of what a heavy tail is, the premise (which is not your own, since it's in countless textbooks) in your question is false -- there is no absolutely general connection between heavy-tailedness and higher 4th standardized moment. It tends to be the case that higher kurtosis goes with heavier tail and vice-versa -- we see that when comparing a t(5) with a normal, for example -- but it's not always the case; one can readily find a lighter-tailed distribution by that definition in 2.b. which nevertheless has higher kurtosis. See this example -- t with 10d.f. vs Laplace: (in this case, because $f$ is always higher past a certain point, the survivor function must also be higher at least in that region so we can just stick with density for the comparison. Note that these two densities cross six times. the Laplace has a higher tail between about 2.5145 and 12.8, as well as a higher peak; that gives it higher kurtosis even though its extreme tail is lower)
what is the meaning of 'tail' of kurtosis?
There are two parts to address here -- 1. what does it mean for something to be heavy-tailed? and 2. does higher kurtosis mean a heavier tail and vice-versa? What's heavy-tailed mean? a. What heavier
what is the meaning of 'tail' of kurtosis? There are two parts to address here -- 1. what does it mean for something to be heavy-tailed? and 2. does higher kurtosis mean a heavier tail and vice-versa? What's heavy-tailed mean? a. What heavier tail means in a "handwavy" sense -- most people picture it this way: but because the tail is quite small, it's better to look at the log-density (which preserves the ordering of height of density) (that handwavy sense fails, however, in a variety of cases, including the rather basic situations of when you try to encompass distributions which are not continuous and unimodal) b. More strictly, a good definition (about which, see whuber's answer here) for heavy-tailedness would be that if $Y$ is heavier-tailed than $X$, as $t$ becomes sufficiently large, then $S_Y(t)>S_X(t)$ for all $t>t_0$ fr some $t_0$, where $S$ is the survivor function, $1-F$. [This is of course, for heavier-tailed on the right; there'd be a similar definition for left-tail heavy tailedness in terms of $F$ rather than $S$. When both tails are under consideration, as they would need to be for comparing kurtosis, "heavier tailed" would apply if it was heavier in both tails.] (Again, however, if you're trying to look at it, a log-scale comparison would often be more useful than a direct comparison of $S(t)$) How does heavy-tailedness relate to kurtosis? Now we have a definition of what a heavy tail is, the premise (which is not your own, since it's in countless textbooks) in your question is false -- there is no absolutely general connection between heavy-tailedness and higher 4th standardized moment. It tends to be the case that higher kurtosis goes with heavier tail and vice-versa -- we see that when comparing a t(5) with a normal, for example -- but it's not always the case; one can readily find a lighter-tailed distribution by that definition in 2.b. which nevertheless has higher kurtosis. See this example -- t with 10d.f. vs Laplace: (in this case, because $f$ is always higher past a certain point, the survivor function must also be higher at least in that region so we can just stick with density for the comparison. Note that these two densities cross six times. the Laplace has a higher tail between about 2.5145 and 12.8, as well as a higher peak; that gives it higher kurtosis even though its extreme tail is lower)
what is the meaning of 'tail' of kurtosis? There are two parts to address here -- 1. what does it mean for something to be heavy-tailed? and 2. does higher kurtosis mean a heavier tail and vice-versa? What's heavy-tailed mean? a. What heavier
44,384
what is the meaning of 'tail' of kurtosis?
Comments from probably deleted duplicate question that are useful: In fact, higher kurtosis is associated with both increased peakedness and heavier extreme tails, but there's no necessary relationship in either case (you can find counterexamples to higher peak or heavier extreme tails, even though both are typical with higher kurtosis). A variety of shapes is possible in either case. – Glen_b♦ Sep 17 '13 at 11:10 Kendall and Stuart (I think in Vol I) present a collection of counterexamples to the various combinations of peak and tails. See also the discussion here – Glen_b♦ Sep 17 '13 at 11:16 Also see the paper by Kevin P. Balanda and H.L. MacGillivray. "Kurtosis: A Critical Review". The American Statistician 42:2 [May 1988], pp 111–119. (And yes, generally speaking, fat-tailed and heavy-tailed are synonyms, except for contexts where one or both has been given an explicit definition.) – Glen_b♦ Sep 17 '13 at 11:23 You might want to read the following paper: DeCarlo, L. T. (1997). On the meaning and use of kurtosis. Psychological Methods, 2(3), 292. – Alecos Papadopoulos Sep 17 '13 at 23:31 A caveat about the DeCarlo paper - the very first sentence of the abstract is wrong! Even for symmetric, unimodal distributions, high kurtosis does not mean "peakedness," and low kurtosis does not mean flatness. There are symmetric, unimodal flat-topped distributions with extremely high (even infinite) kurtosis; there are also infinitely peaked distributions with negative excess kurtosis. See specific examples given here: en.wikipedia.org/wiki/… – Peter Westfall Oct 21 '17 at 12:20 Glen_b, your "you can find counterexamples to heavier extreme tails, though both are typical with higher kurtosis" is only correct if you define "heavier extreme tails" in a particular way out of infinite ways. There is no counterexample to the mathematical facts that (i) as kurtosis tends to infinity, E(Z^4*I(|Z| >b))/kurtosis ->1, for all b; and (ii) kurtosis is within +- .5 of E(Z^4*I(|Z| > 1)) +.5; both of these statements explain how kurtosis is related to tails of the distribution, and not the peak. If you define "heavier tails" as larger "E(Z^4*I(|Z| > 1))" then there you have kurtosis. – Peter Westfall Nov 15 '17 at 23:32 Glen_b, your comment "In fact, higher kurtosis is associated with both increased peakedness ..." seems patently false in the face of numerous counterexamples. Can you provide a theorem to justify it? – Peter Westfall Nov 20 '17 at 1:43 The above, and the question itself are rooted in what kurtosis is. It may be useful to review a physical problem for which kurtosis is defined. For that, the fourth moment about the mean is analogous to a thin sheet of material rotated about its mean mass, or vertical balance point, as a rate of change of a rate of change of torque. This says very little about the thin sheet's height at any particular distance from the axis of rotation, but rather is an integral behaviour over the whole sheet.
what is the meaning of 'tail' of kurtosis?
Comments from probably deleted duplicate question that are useful: In fact, higher kurtosis is associated with both increased peakedness and heavier extreme tails, but there's no necessary relationshi
what is the meaning of 'tail' of kurtosis? Comments from probably deleted duplicate question that are useful: In fact, higher kurtosis is associated with both increased peakedness and heavier extreme tails, but there's no necessary relationship in either case (you can find counterexamples to higher peak or heavier extreme tails, even though both are typical with higher kurtosis). A variety of shapes is possible in either case. – Glen_b♦ Sep 17 '13 at 11:10 Kendall and Stuart (I think in Vol I) present a collection of counterexamples to the various combinations of peak and tails. See also the discussion here – Glen_b♦ Sep 17 '13 at 11:16 Also see the paper by Kevin P. Balanda and H.L. MacGillivray. "Kurtosis: A Critical Review". The American Statistician 42:2 [May 1988], pp 111–119. (And yes, generally speaking, fat-tailed and heavy-tailed are synonyms, except for contexts where one or both has been given an explicit definition.) – Glen_b♦ Sep 17 '13 at 11:23 You might want to read the following paper: DeCarlo, L. T. (1997). On the meaning and use of kurtosis. Psychological Methods, 2(3), 292. – Alecos Papadopoulos Sep 17 '13 at 23:31 A caveat about the DeCarlo paper - the very first sentence of the abstract is wrong! Even for symmetric, unimodal distributions, high kurtosis does not mean "peakedness," and low kurtosis does not mean flatness. There are symmetric, unimodal flat-topped distributions with extremely high (even infinite) kurtosis; there are also infinitely peaked distributions with negative excess kurtosis. See specific examples given here: en.wikipedia.org/wiki/… – Peter Westfall Oct 21 '17 at 12:20 Glen_b, your "you can find counterexamples to heavier extreme tails, though both are typical with higher kurtosis" is only correct if you define "heavier extreme tails" in a particular way out of infinite ways. There is no counterexample to the mathematical facts that (i) as kurtosis tends to infinity, E(Z^4*I(|Z| >b))/kurtosis ->1, for all b; and (ii) kurtosis is within +- .5 of E(Z^4*I(|Z| > 1)) +.5; both of these statements explain how kurtosis is related to tails of the distribution, and not the peak. If you define "heavier tails" as larger "E(Z^4*I(|Z| > 1))" then there you have kurtosis. – Peter Westfall Nov 15 '17 at 23:32 Glen_b, your comment "In fact, higher kurtosis is associated with both increased peakedness ..." seems patently false in the face of numerous counterexamples. Can you provide a theorem to justify it? – Peter Westfall Nov 20 '17 at 1:43 The above, and the question itself are rooted in what kurtosis is. It may be useful to review a physical problem for which kurtosis is defined. For that, the fourth moment about the mean is analogous to a thin sheet of material rotated about its mean mass, or vertical balance point, as a rate of change of a rate of change of torque. This says very little about the thin sheet's height at any particular distance from the axis of rotation, but rather is an integral behaviour over the whole sheet.
what is the meaning of 'tail' of kurtosis? Comments from probably deleted duplicate question that are useful: In fact, higher kurtosis is associated with both increased peakedness and heavier extreme tails, but there's no necessary relationshi
44,385
what is the meaning of 'tail' of kurtosis?
There is most definitely a direct relationship connection between kurtosis and the tails of distribution. One simple connection is as follows: Let $X$ be any random variable with finite fourth moment, let $Z = (X - \mu)/\sigma$, and let $U = Z^4$. Then the kurtosis of $X$ is $E(U)$. A common way of teaching and understanding expectation is using the "point of balance" concept, where the expected value of a random variable is equal to the point on the horizontal axis where the distribution plot balances. Consider the plot of the probability distribution function (pdf) of $U$, and locate the value 3.0 on the horizontal axis. This is the kurtosis of the normal distribution. If the pdf is too heavy to the right of 3.0, so that it is pulled down to the right when attempted to balance at 3.0, then the kurtosis is greater than 3.0, and the distribution of $X$ can be said to be "heavier tailed than the normal distribution." Conversely, if the pdf of $U$ is too light to the right of 3.0, so that the curve is pulled down to the left when attempted to balance at 3.0, then the kurtosis is less than 3.0, and the distribution of $X$ can be said to be "lighter tailed than the normal distribution." In light of the above discussion, "tail leverage" is perhaps a better characterization of kurtosis than "tail mass." It is possible that more mass in the tails corresponds to less kurtosis, and that less mass in the tails corresponds to greater kurtosis. It all depends on the remoteness of the mass; i.e., it depends on the leverage. Precise mathematical logic showing that kurtosis is mostly determined by the tails is given as follows: For all possible distributions of random variables $X$ having finite fourth moment (discrete, continuous, skewed, empirical), kurtosis is necessarily between $\int Z^4 I(|Z| > 1) dF(Z)$ and $\int Z^4 I(|Z| > 1) dF(Z) + 1$, where $Z = (X-\mu)/\sigma$. For continuous distributions in this class with density of $Z^2$ decreasing on the interval $[0,1]$, the "$+1$" is reduced to "$+.5$" or less. Finally, for any sequence of distributions where the kurtosis $k$ tends to infinity, $\int Z^4 I(|Z| > b) dF(Z) / k \rightarrow 1$, for all real $b$. These are all mathematical theorems so there can be no counterexamples. Thus, it is primarily the values in the tails of the $Z$ distribution that determine the value of kurtosis. Yes, there are other tailweight measures that are not kurtosis, in fact there are infinitely many. So it is a red herring to state that kurtosis does not measure tailweight if it does not correspond to a particular tailweight measure. It is an unsupported generalization to say that, just because kurtosis does not measure one of infinitely many tailweight measures, that kurtosis itself does not measure tailweight. I have seen no theorems generally linking kurtosis to the peak, or to the probability concentration within the $\mu \pm \sigma$ range, but I have seen plenty of counterexamples to such notions. Can anyone point to such a theorem? The three theorems I mentioned above are proven in Westfall, P.H. (2014). Kurtosis as Peakedness, 1905 – 2014. R.I.P. The American Statistician, 68, 191–195. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4321753/ Edit, 7/18/2018: Yet another theorem to connect kurtosis to the tails (and not the peak). Take any distribution (or data set). Remove the data or mass within one standard deviation of the mean. Replace the data/mass in any way you like, but keep the mean and standard deviation the same as with the original data/distribution. Then the difference between the maximum and minimum kurtosis for all such replacements is $\le$ 0.25. If you play the same game with the tails, the difference is unbounded.
what is the meaning of 'tail' of kurtosis?
There is most definitely a direct relationship connection between kurtosis and the tails of distribution. One simple connection is as follows: Let $X$ be any random variable with finite fourth moment,
what is the meaning of 'tail' of kurtosis? There is most definitely a direct relationship connection between kurtosis and the tails of distribution. One simple connection is as follows: Let $X$ be any random variable with finite fourth moment, let $Z = (X - \mu)/\sigma$, and let $U = Z^4$. Then the kurtosis of $X$ is $E(U)$. A common way of teaching and understanding expectation is using the "point of balance" concept, where the expected value of a random variable is equal to the point on the horizontal axis where the distribution plot balances. Consider the plot of the probability distribution function (pdf) of $U$, and locate the value 3.0 on the horizontal axis. This is the kurtosis of the normal distribution. If the pdf is too heavy to the right of 3.0, so that it is pulled down to the right when attempted to balance at 3.0, then the kurtosis is greater than 3.0, and the distribution of $X$ can be said to be "heavier tailed than the normal distribution." Conversely, if the pdf of $U$ is too light to the right of 3.0, so that the curve is pulled down to the left when attempted to balance at 3.0, then the kurtosis is less than 3.0, and the distribution of $X$ can be said to be "lighter tailed than the normal distribution." In light of the above discussion, "tail leverage" is perhaps a better characterization of kurtosis than "tail mass." It is possible that more mass in the tails corresponds to less kurtosis, and that less mass in the tails corresponds to greater kurtosis. It all depends on the remoteness of the mass; i.e., it depends on the leverage. Precise mathematical logic showing that kurtosis is mostly determined by the tails is given as follows: For all possible distributions of random variables $X$ having finite fourth moment (discrete, continuous, skewed, empirical), kurtosis is necessarily between $\int Z^4 I(|Z| > 1) dF(Z)$ and $\int Z^4 I(|Z| > 1) dF(Z) + 1$, where $Z = (X-\mu)/\sigma$. For continuous distributions in this class with density of $Z^2$ decreasing on the interval $[0,1]$, the "$+1$" is reduced to "$+.5$" or less. Finally, for any sequence of distributions where the kurtosis $k$ tends to infinity, $\int Z^4 I(|Z| > b) dF(Z) / k \rightarrow 1$, for all real $b$. These are all mathematical theorems so there can be no counterexamples. Thus, it is primarily the values in the tails of the $Z$ distribution that determine the value of kurtosis. Yes, there are other tailweight measures that are not kurtosis, in fact there are infinitely many. So it is a red herring to state that kurtosis does not measure tailweight if it does not correspond to a particular tailweight measure. It is an unsupported generalization to say that, just because kurtosis does not measure one of infinitely many tailweight measures, that kurtosis itself does not measure tailweight. I have seen no theorems generally linking kurtosis to the peak, or to the probability concentration within the $\mu \pm \sigma$ range, but I have seen plenty of counterexamples to such notions. Can anyone point to such a theorem? The three theorems I mentioned above are proven in Westfall, P.H. (2014). Kurtosis as Peakedness, 1905 – 2014. R.I.P. The American Statistician, 68, 191–195. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4321753/ Edit, 7/18/2018: Yet another theorem to connect kurtosis to the tails (and not the peak). Take any distribution (or data set). Remove the data or mass within one standard deviation of the mean. Replace the data/mass in any way you like, but keep the mean and standard deviation the same as with the original data/distribution. Then the difference between the maximum and minimum kurtosis for all such replacements is $\le$ 0.25. If you play the same game with the tails, the difference is unbounded.
what is the meaning of 'tail' of kurtosis? There is most definitely a direct relationship connection between kurtosis and the tails of distribution. One simple connection is as follows: Let $X$ be any random variable with finite fourth moment,
44,386
What is the difference between a $\log_{10}$ and logit transformation?
The function $f(x)=\log_{10}(x)$ is the inverse of exponentiation with base 10. It is a monotonic injective function mapping positive numbers to $\mathbb{R}$. Positive numbers less than 1 are mapped to negative numbers. Positive numbers greater than one are mapped to positive numbers. In regression analysis, logarithm transformations are used when effects are multiplicative, especially when the regression involves something monetary like insurance claims or income. (The choice of base is not relevant to these properties; you could write the same about $\log_e$ and $\log_2.$) The function $g(x)=\text{logit}(x)=\log\left(\frac{x}{1-x}\right)=\log(x)-\log(1-x)$ maps $x\in(0,1)$ to $\mathbb{R}$. It is also monotonic injective. The most common use for the logit function is that it can be used to transform probabilities from the unit interval to the real line; this plays a vital role in logistic regression, where one models the odds of two or more binary outcomes. The logit function also preserves symmetry about $0.5$. For example, $g(0.25)=-g(0.75).$ The logarithm function $f$ does not have the same role in linking real-valued numbers to probabilities. Likewise, the logarithm function does not have the same symmetry as the logit function. So those are two major differences.
What is the difference between a $\log_{10}$ and logit transformation?
The function $f(x)=\log_{10}(x)$ is the inverse of exponentiation with base 10. It is a monotonic injective function mapping positive numbers to $\mathbb{R}$. Positive numbers less than 1 are mapped t
What is the difference between a $\log_{10}$ and logit transformation? The function $f(x)=\log_{10}(x)$ is the inverse of exponentiation with base 10. It is a monotonic injective function mapping positive numbers to $\mathbb{R}$. Positive numbers less than 1 are mapped to negative numbers. Positive numbers greater than one are mapped to positive numbers. In regression analysis, logarithm transformations are used when effects are multiplicative, especially when the regression involves something monetary like insurance claims or income. (The choice of base is not relevant to these properties; you could write the same about $\log_e$ and $\log_2.$) The function $g(x)=\text{logit}(x)=\log\left(\frac{x}{1-x}\right)=\log(x)-\log(1-x)$ maps $x\in(0,1)$ to $\mathbb{R}$. It is also monotonic injective. The most common use for the logit function is that it can be used to transform probabilities from the unit interval to the real line; this plays a vital role in logistic regression, where one models the odds of two or more binary outcomes. The logit function also preserves symmetry about $0.5$. For example, $g(0.25)=-g(0.75).$ The logarithm function $f$ does not have the same role in linking real-valued numbers to probabilities. Likewise, the logarithm function does not have the same symmetry as the logit function. So those are two major differences.
What is the difference between a $\log_{10}$ and logit transformation? The function $f(x)=\log_{10}(x)$ is the inverse of exponentiation with base 10. It is a monotonic injective function mapping positive numbers to $\mathbb{R}$. Positive numbers less than 1 are mapped t
44,387
How does the GLM handle collinear predictors?
Let's predict income with two highly positively correlated variables: Years of work experience and number of carrots eaten in one's lifetime. Let's ignore omitted variable bias issues. Also, let's say years of work experience has a much greater impact on income than carrots eaten. Your beta parameter estimates would be unbiased, but the standard errors of the parameter estimates would be greater than if the predictors were not correlated. Collinearity does not violate any assumptions of GLMs (unless there is perfect collinearity). Collinearity is fundamentally a data problem. In small datasets, you might not have enough data to estimate beta coefficients. In large datasets, you likely will. Either way, you can interpret the beta parameters and the standard errors just as if collinearity were not an issue. Just be aware that some of your parameter estimates might not be significant. In the event your parameter estimates are not significant, get more data. Dropping a variable that should be in your model ensures your estimates are biased. For example, if you were to drop the years of experience variables, the carrots eaten variables would become positively biased due to "absorbing" the impact of the dropped variable. To answer the shared variance question, here is a fun test you can do in a statistical program of your choice: Make two highly correlated variables (x1 and x2) Add an error term (normally distributed, zero mean) Create y by adding x1 to the error term. (i.e. The actual beta values of x1 and x2 are 1 and 0 respectively) Regress y on x1 and x2 with a large data set. Although there is a very large shared variance between x1 and x2, only x1 has a ceteris paribus, marginal effect relationship to y. In contrast, holding x1 constant and changing x2 does nothing to the expected value of y, so the shared variance is irrelevant.
How does the GLM handle collinear predictors?
Let's predict income with two highly positively correlated variables: Years of work experience and number of carrots eaten in one's lifetime. Let's ignore omitted variable bias issues. Also, let's say
How does the GLM handle collinear predictors? Let's predict income with two highly positively correlated variables: Years of work experience and number of carrots eaten in one's lifetime. Let's ignore omitted variable bias issues. Also, let's say years of work experience has a much greater impact on income than carrots eaten. Your beta parameter estimates would be unbiased, but the standard errors of the parameter estimates would be greater than if the predictors were not correlated. Collinearity does not violate any assumptions of GLMs (unless there is perfect collinearity). Collinearity is fundamentally a data problem. In small datasets, you might not have enough data to estimate beta coefficients. In large datasets, you likely will. Either way, you can interpret the beta parameters and the standard errors just as if collinearity were not an issue. Just be aware that some of your parameter estimates might not be significant. In the event your parameter estimates are not significant, get more data. Dropping a variable that should be in your model ensures your estimates are biased. For example, if you were to drop the years of experience variables, the carrots eaten variables would become positively biased due to "absorbing" the impact of the dropped variable. To answer the shared variance question, here is a fun test you can do in a statistical program of your choice: Make two highly correlated variables (x1 and x2) Add an error term (normally distributed, zero mean) Create y by adding x1 to the error term. (i.e. The actual beta values of x1 and x2 are 1 and 0 respectively) Regress y on x1 and x2 with a large data set. Although there is a very large shared variance between x1 and x2, only x1 has a ceteris paribus, marginal effect relationship to y. In contrast, holding x1 constant and changing x2 does nothing to the expected value of y, so the shared variance is irrelevant.
How does the GLM handle collinear predictors? Let's predict income with two highly positively correlated variables: Years of work experience and number of carrots eaten in one's lifetime. Let's ignore omitted variable bias issues. Also, let's say
44,388
How does the GLM handle collinear predictors?
This is one of those situations where what is theoretically true, and what is true in practice can be quite different. I'll try to give an example. Let's suppose we have centered ant standardized both $X$ and $y$ so that: The predictor covariance is $\Sigma = X^{t} X$. The intercept estimate is $\beta_0 = 0$. I'll focus on the case of a linear regression, and try to say something about general glm's at the end. I'll also assume we have two predictors, because it captures all the essential points of the situation. The solution parameter estimates for a linear model satisfy the equation $$ X^t X \beta = X^t y $$ which under our assumptions, can be written as $$ \Sigma \beta = X^t y $$ On the right hand side, are simply taking the dot product of the response vector $y$ with $X$, so we can write $$ X^t y = \left( \begin{array}{c} cov(X_1, y) \\ cov(X_2, y) \end{array} \right) $$ On the left hand side, we get $$ \Sigma \beta = \left( \begin{array}{c} \beta_1 + cov(X_1, X_2) \beta_2 \\ cov(X_1, X_2) \beta_1 + \beta_2 \end{array} \right) $$ So the system of equations is $$ \beta_1 + cov(X_1, X_2) \beta_2 = cov(X_1, y) $$ $$ cov(X_1, X_2) \beta_1 + \beta_2 = cov(X_2, y) $$ As a sanity check, if the predictors are uncorrelated, we get $$ \beta_1 = cov(X_1, y) $$ $$ \beta_2 = cov(X_2, y) $$ which is intuitive. So, now, what if the predictors are corellated? Then we can solve by multiplying the bottom equation through by $cov(X_1, X_2)$ to get $$cov(X_1, X_2)^2 \beta_1 + cov(X_1, X_2) \beta_2 = cov(X_1, X_2) cov(X_2, y) $$ And then subtracting from the top equation cancels out the $\beta_2$'s $$(1 - cov(X_1, X_2)^2) \beta_1 = cov(X_1, y) - cov(X_1, X_2) cov(X_2, y) $$ Which can be solved for $\beta_1$ $$\beta_1 = \frac{cov(X_1, y) - cov(X_1, X_2) cov(X_2, y)}{(1 - cov(X_1, X_2)^2) } $$ So what do we see here? The numerator is what you would get naively, if you first regressed $Y$ on $X_2$, and then regressed $X_1$ on the residual. The denominator is the "correction" to the above procedure. If you follow the step-by-step procedure from the first bullet point, it seems you are under-explaining the variance in $Y$ due to $X_1$ and $X_2$. This makes sense, because you have ignored the additional variance due to the fact that $X_1$ and $X_2$ tend to move together. If $X_1$ and $X_2$ are tightly correlated, then the denominator is close to zero. This means that any errors in estimation of $cov(X_1, X_2)$ get magnified in the final coefficient estimates. This explains why parameter estimates can be so unstable in high correlation situations. An analysis on a general glm is much harder to work through, but I'll mention one thing. The glm fitting algorithm reduces to a repeated application of the linear fitting algorithm (using newton's method, this is usually called iteratively re-weighted least squares. The same considerations will hold at each step of that procedure, so you can see how the same general phenomena will be true for the final estimates as well.
How does the GLM handle collinear predictors?
This is one of those situations where what is theoretically true, and what is true in practice can be quite different. I'll try to give an example. Let's suppose we have centered ant standardized bot
How does the GLM handle collinear predictors? This is one of those situations where what is theoretically true, and what is true in practice can be quite different. I'll try to give an example. Let's suppose we have centered ant standardized both $X$ and $y$ so that: The predictor covariance is $\Sigma = X^{t} X$. The intercept estimate is $\beta_0 = 0$. I'll focus on the case of a linear regression, and try to say something about general glm's at the end. I'll also assume we have two predictors, because it captures all the essential points of the situation. The solution parameter estimates for a linear model satisfy the equation $$ X^t X \beta = X^t y $$ which under our assumptions, can be written as $$ \Sigma \beta = X^t y $$ On the right hand side, are simply taking the dot product of the response vector $y$ with $X$, so we can write $$ X^t y = \left( \begin{array}{c} cov(X_1, y) \\ cov(X_2, y) \end{array} \right) $$ On the left hand side, we get $$ \Sigma \beta = \left( \begin{array}{c} \beta_1 + cov(X_1, X_2) \beta_2 \\ cov(X_1, X_2) \beta_1 + \beta_2 \end{array} \right) $$ So the system of equations is $$ \beta_1 + cov(X_1, X_2) \beta_2 = cov(X_1, y) $$ $$ cov(X_1, X_2) \beta_1 + \beta_2 = cov(X_2, y) $$ As a sanity check, if the predictors are uncorrelated, we get $$ \beta_1 = cov(X_1, y) $$ $$ \beta_2 = cov(X_2, y) $$ which is intuitive. So, now, what if the predictors are corellated? Then we can solve by multiplying the bottom equation through by $cov(X_1, X_2)$ to get $$cov(X_1, X_2)^2 \beta_1 + cov(X_1, X_2) \beta_2 = cov(X_1, X_2) cov(X_2, y) $$ And then subtracting from the top equation cancels out the $\beta_2$'s $$(1 - cov(X_1, X_2)^2) \beta_1 = cov(X_1, y) - cov(X_1, X_2) cov(X_2, y) $$ Which can be solved for $\beta_1$ $$\beta_1 = \frac{cov(X_1, y) - cov(X_1, X_2) cov(X_2, y)}{(1 - cov(X_1, X_2)^2) } $$ So what do we see here? The numerator is what you would get naively, if you first regressed $Y$ on $X_2$, and then regressed $X_1$ on the residual. The denominator is the "correction" to the above procedure. If you follow the step-by-step procedure from the first bullet point, it seems you are under-explaining the variance in $Y$ due to $X_1$ and $X_2$. This makes sense, because you have ignored the additional variance due to the fact that $X_1$ and $X_2$ tend to move together. If $X_1$ and $X_2$ are tightly correlated, then the denominator is close to zero. This means that any errors in estimation of $cov(X_1, X_2)$ get magnified in the final coefficient estimates. This explains why parameter estimates can be so unstable in high correlation situations. An analysis on a general glm is much harder to work through, but I'll mention one thing. The glm fitting algorithm reduces to a repeated application of the linear fitting algorithm (using newton's method, this is usually called iteratively re-weighted least squares. The same considerations will hold at each step of that procedure, so you can see how the same general phenomena will be true for the final estimates as well.
How does the GLM handle collinear predictors? This is one of those situations where what is theoretically true, and what is true in practice can be quite different. I'll try to give an example. Let's suppose we have centered ant standardized bot
44,389
How does the GLM handle collinear predictors?
@Jason Sanchez has provided a good answer. Let me add some complementary information. The beta estimates from OLS estimation are each conditional on the other variables included in the model. No variable is given precedence, or used first, etc. For example, it is not the case that the slope for $x_1$ is the slope you would have if only $x_1$ were included in the model, and then the slope for $x_2$ tried to account for the variability that was 'left over'. The effect that you would have ignoring other variables is called the 'marginal' association, but when you have multiple variables, all associations are conditional instead. Of course, you can always just fit two models to see the marginal effect of (say) $x_1$, and then the conditional effect when $x_2$ is also included, but you need to be sure you understand what the results will be telling you; if they are highly correlated, the marginal effect of $x_1$ is the effect of $x_1$ conflated with the proportion of $x_2$ that is correlated with $x_1$. (It may help to read my answer here: Is there a difference between 'controlling for' and 'ignoring' other variables in multiple regression?) Another issue that comes up in situations like this is that your standard errors will be larger than they would otherwise be. This is appropriate, and reflects the fact that when variables are highly correlated, it is very difficult to determine the slope of the relationships with good precision. It is often best to simply recognize that it is difficult to tell the independent roles of the collinear variables. You can test that something is related to the response by dropping all of the collinear variables and performing a nested model test. With small- to moderately-sized datasets and strongly collinear variables, it is typical to have no individual variable be significant but for the set of variables to be clearly significant. At that point, that there is an association in there somewhere is what you can say from that dataset. On the other hand, you should realize that the $t$-tests that come with your output are analogous to so-called 'type III sums of squares', and that much of the information available to you has been set aside. If you have an a-priori reason to allocate that to a particular variable (to give it precedence), you can use a sequential testing strategy (i.e., type I SS). This will give you more power for the test of that variable. For more information on this, it may help to read my answer here: How to interpret type I (sequential) ANOVA and MANOVA?
How does the GLM handle collinear predictors?
@Jason Sanchez has provided a good answer. Let me add some complementary information. The beta estimates from OLS estimation are each conditional on the other variables included in the model. No va
How does the GLM handle collinear predictors? @Jason Sanchez has provided a good answer. Let me add some complementary information. The beta estimates from OLS estimation are each conditional on the other variables included in the model. No variable is given precedence, or used first, etc. For example, it is not the case that the slope for $x_1$ is the slope you would have if only $x_1$ were included in the model, and then the slope for $x_2$ tried to account for the variability that was 'left over'. The effect that you would have ignoring other variables is called the 'marginal' association, but when you have multiple variables, all associations are conditional instead. Of course, you can always just fit two models to see the marginal effect of (say) $x_1$, and then the conditional effect when $x_2$ is also included, but you need to be sure you understand what the results will be telling you; if they are highly correlated, the marginal effect of $x_1$ is the effect of $x_1$ conflated with the proportion of $x_2$ that is correlated with $x_1$. (It may help to read my answer here: Is there a difference between 'controlling for' and 'ignoring' other variables in multiple regression?) Another issue that comes up in situations like this is that your standard errors will be larger than they would otherwise be. This is appropriate, and reflects the fact that when variables are highly correlated, it is very difficult to determine the slope of the relationships with good precision. It is often best to simply recognize that it is difficult to tell the independent roles of the collinear variables. You can test that something is related to the response by dropping all of the collinear variables and performing a nested model test. With small- to moderately-sized datasets and strongly collinear variables, it is typical to have no individual variable be significant but for the set of variables to be clearly significant. At that point, that there is an association in there somewhere is what you can say from that dataset. On the other hand, you should realize that the $t$-tests that come with your output are analogous to so-called 'type III sums of squares', and that much of the information available to you has been set aside. If you have an a-priori reason to allocate that to a particular variable (to give it precedence), you can use a sequential testing strategy (i.e., type I SS). This will give you more power for the test of that variable. For more information on this, it may help to read my answer here: How to interpret type I (sequential) ANOVA and MANOVA?
How does the GLM handle collinear predictors? @Jason Sanchez has provided a good answer. Let me add some complementary information. The beta estimates from OLS estimation are each conditional on the other variables included in the model. No va
44,390
How to implement GLM computationally in C++ (or other languages)? [closed]
While there is definitely some educational value of re-implementing GLM framework (or any other statistical framework, for that matter), I question the feasibility of this approach due to complexity and, consequently, time and efforts involved. Having said that, if you indeed want to go this route and review existing open source GLM implementations, you have, at least, the following options: Standard GLM implementation by R package stats. See the corresponding source code here on GitHub or by typing the function name (without parentheses) in R's command line. Alternative and specific GLM implementations for R include the following packages: glm2, glmnet and some others. Additionally, GLM-releated R packages are listed in this blog post. Excellent GLM Notes webpage (by Michael Kane and Bryan W. Lewis) offers a wealth of interesting and useful details on standard and alternative R GLM implementations aspects. For Julia GLM implementations, check similar to R's GLM and GLMNet packages. For Python GLM implementations, check the one in statsmodels library and the one in scikit-learn library (implements Ridge, OLS and Lasso - find corresponding modules). For .NET GLM implementations, check IMHO very interesting Accord.NET framework - the GLM source code is here on GitHub. For C/C++ GLM implementations, check apophenia C library (this source code seems to be relevant) and, perhaps, C++ GNU Scientific Library (GSL) (see this GitHub repo, but I was unable to find the relevant source code). Also of interest could be: this C++ IRLS GLM implementation (which uses GSL) as well as the Bayesian Object Oriented Modeling (BOOM) C++ library (GLM-focused source code is here on GitHub).
How to implement GLM computationally in C++ (or other languages)? [closed]
While there is definitely some educational value of re-implementing GLM framework (or any other statistical framework, for that matter), I question the feasibility of this approach due to complexity a
How to implement GLM computationally in C++ (or other languages)? [closed] While there is definitely some educational value of re-implementing GLM framework (or any other statistical framework, for that matter), I question the feasibility of this approach due to complexity and, consequently, time and efforts involved. Having said that, if you indeed want to go this route and review existing open source GLM implementations, you have, at least, the following options: Standard GLM implementation by R package stats. See the corresponding source code here on GitHub or by typing the function name (without parentheses) in R's command line. Alternative and specific GLM implementations for R include the following packages: glm2, glmnet and some others. Additionally, GLM-releated R packages are listed in this blog post. Excellent GLM Notes webpage (by Michael Kane and Bryan W. Lewis) offers a wealth of interesting and useful details on standard and alternative R GLM implementations aspects. For Julia GLM implementations, check similar to R's GLM and GLMNet packages. For Python GLM implementations, check the one in statsmodels library and the one in scikit-learn library (implements Ridge, OLS and Lasso - find corresponding modules). For .NET GLM implementations, check IMHO very interesting Accord.NET framework - the GLM source code is here on GitHub. For C/C++ GLM implementations, check apophenia C library (this source code seems to be relevant) and, perhaps, C++ GNU Scientific Library (GSL) (see this GitHub repo, but I was unable to find the relevant source code). Also of interest could be: this C++ IRLS GLM implementation (which uses GSL) as well as the Bayesian Object Oriented Modeling (BOOM) C++ library (GLM-focused source code is here on GitHub).
How to implement GLM computationally in C++ (or other languages)? [closed] While there is definitely some educational value of re-implementing GLM framework (or any other statistical framework, for that matter), I question the feasibility of this approach due to complexity a
44,391
Aperiodicity in markov chain
Definition Let $p_{ii}^{(n)}$ denote the probability of returning to state $i$ at step $n$ and let $t\in\{2, 3\dots\}$. State $i$ is said to be periodic with period $t$ iff $ p_{ii}^{(n)} = 0 $ for $n \neq t, 2t, \dots$ $ p_{ii}^{(n)} \neq 0 $ for $n = t, 2t, \dots$ If we can not find a $t$ such that this holds, the state is said to be aperiodic. Solution In your case it would be useful to draw a transition diagram of the matrix. You can see that if the chain starts in $c$ then returns to $c$ are possible at steps $2, 3, 4, 5, \dots$. As we can not find a $t$ such that the definition holds, $c$ is an aperiodic state. ╔═════╦═════╗ β•‘ n β•‘ p β•‘ ╠═════╬═════╣ β•‘ 1 β•‘ 0 β•‘ β•‘ 2 β•‘ >0 β•‘ β•‘ 3 β•‘ >0 β•‘ β•‘ ... β•‘ ... β•‘ β•šβ•β•β•β•β•β•©β•β•β•β•β•β•
Aperiodicity in markov chain
Definition Let $p_{ii}^{(n)}$ denote the probability of returning to state $i$ at step $n$ and let $t\in\{2, 3\dots\}$. State $i$ is said to be periodic with period $t$ iff $ p_{ii}^{(n)} = 0 $ for $
Aperiodicity in markov chain Definition Let $p_{ii}^{(n)}$ denote the probability of returning to state $i$ at step $n$ and let $t\in\{2, 3\dots\}$. State $i$ is said to be periodic with period $t$ iff $ p_{ii}^{(n)} = 0 $ for $n \neq t, 2t, \dots$ $ p_{ii}^{(n)} \neq 0 $ for $n = t, 2t, \dots$ If we can not find a $t$ such that this holds, the state is said to be aperiodic. Solution In your case it would be useful to draw a transition diagram of the matrix. You can see that if the chain starts in $c$ then returns to $c$ are possible at steps $2, 3, 4, 5, \dots$. As we can not find a $t$ such that the definition holds, $c$ is an aperiodic state. ╔═════╦═════╗ β•‘ n β•‘ p β•‘ ╠═════╬═════╣ β•‘ 1 β•‘ 0 β•‘ β•‘ 2 β•‘ >0 β•‘ β•‘ 3 β•‘ >0 β•‘ β•‘ ... β•‘ ... β•‘ β•šβ•β•β•β•β•β•©β•β•β•β•β•β•
Aperiodicity in markov chain Definition Let $p_{ii}^{(n)}$ denote the probability of returning to state $i$ at step $n$ and let $t\in\{2, 3\dots\}$. State $i$ is said to be periodic with period $t$ iff $ p_{ii}^{(n)} = 0 $ for $
44,392
Aperiodicity in markov chain
In an irreducible chain all states belong to a single communicating class. Periodicity is a class property. This means that, if one of the states in an irreducible Markov Chain is aperiodic, say, then all the remaining states are also aperiodic. Since, $p_{aa}^{(1)}>0$, by the definition of periodicity, state a is aperiodic. As the given Markov Chain is irreducible, the rest of the states of the Markov Chain are also aperiodic. We can also observe that, the two-step transition probability matrix(TPM) for the given chain is given by \begin{equation*} P^{(2)}=\left( \begin{array}{ccc} 0.5& 0.25& 0.25\\ 0.5& 0.25& 0.25\\ 0.5& 0.25& 0.25\\ \end{array}\right) \end{equation*} Note that, all the elements of $P^{(2)}$ are positive. This ensures that, $P^{(3)}>0, P^{(4)}>0$ and so on. The greatest common divisor of the times $2,3,4,\cdots$ is $1$. Hence, by the definition of periodicity, the period of every state is aperiodic.
Aperiodicity in markov chain
In an irreducible chain all states belong to a single communicating class. Periodicity is a class property. This means that, if one of the states in an irreducible Markov Chain is aperiodic, say, then
Aperiodicity in markov chain In an irreducible chain all states belong to a single communicating class. Periodicity is a class property. This means that, if one of the states in an irreducible Markov Chain is aperiodic, say, then all the remaining states are also aperiodic. Since, $p_{aa}^{(1)}>0$, by the definition of periodicity, state a is aperiodic. As the given Markov Chain is irreducible, the rest of the states of the Markov Chain are also aperiodic. We can also observe that, the two-step transition probability matrix(TPM) for the given chain is given by \begin{equation*} P^{(2)}=\left( \begin{array}{ccc} 0.5& 0.25& 0.25\\ 0.5& 0.25& 0.25\\ 0.5& 0.25& 0.25\\ \end{array}\right) \end{equation*} Note that, all the elements of $P^{(2)}$ are positive. This ensures that, $P^{(3)}>0, P^{(4)}>0$ and so on. The greatest common divisor of the times $2,3,4,\cdots$ is $1$. Hence, by the definition of periodicity, the period of every state is aperiodic.
Aperiodicity in markov chain In an irreducible chain all states belong to a single communicating class. Periodicity is a class property. This means that, if one of the states in an irreducible Markov Chain is aperiodic, say, then
44,393
Aperiodicity in markov chain
For an irreducible markov chain, Aperiodic: When starting from some state i, we don't know when we will return to the same state i after some transition. We may see the state i after 1,2,3,4,5.. etc number of transition. Periodic: When we can say that we can return to the state i after some transition with certainty. If a state is reachable after transition step of 2,4,6,8...etc. then it has periodicity of 2. For your example, if you draw a transition diagram you can see that it is possible to arrive at each state after different transition(1,2,3,4) which means there is no period to a state or state is aperiodic. This link also gives a good understanding of markov chain perdiocity.
Aperiodicity in markov chain
For an irreducible markov chain, Aperiodic: When starting from some state i, we don't know when we will return to the same state i after some transition. We may see the state i after 1,2,3,4,5.. etc n
Aperiodicity in markov chain For an irreducible markov chain, Aperiodic: When starting from some state i, we don't know when we will return to the same state i after some transition. We may see the state i after 1,2,3,4,5.. etc number of transition. Periodic: When we can say that we can return to the state i after some transition with certainty. If a state is reachable after transition step of 2,4,6,8...etc. then it has periodicity of 2. For your example, if you draw a transition diagram you can see that it is possible to arrive at each state after different transition(1,2,3,4) which means there is no period to a state or state is aperiodic. This link also gives a good understanding of markov chain perdiocity.
Aperiodicity in markov chain For an irreducible markov chain, Aperiodic: When starting from some state i, we don't know when we will return to the same state i after some transition. We may see the state i after 1,2,3,4,5.. etc n
44,394
Aperiodicity in markov chain
For any state we find the possible no. Of steps in which we can return to the same state. If gcd of these nos. =1 then state is aperiodic. If gcd not equals 1 (say 'd'), then period equals 'd'. For a self loop state it is possible to return to the state in 1,2,3,4........ steps. Gcd = 1. So the state is certainly aperiodic. For non self loop state we find possible no. of steps and then find gcd which may be 1. This makes the state aperiodic. Here state 3 is non self loop but return to it is possible in 2,3,4,5...... steps which has gcd =1. So the state is aperiodic.
Aperiodicity in markov chain
For any state we find the possible no. Of steps in which we can return to the same state. If gcd of these nos. =1 then state is aperiodic. If gcd not equals 1 (say 'd'), then period equals 'd'. For a
Aperiodicity in markov chain For any state we find the possible no. Of steps in which we can return to the same state. If gcd of these nos. =1 then state is aperiodic. If gcd not equals 1 (say 'd'), then period equals 'd'. For a self loop state it is possible to return to the state in 1,2,3,4........ steps. Gcd = 1. So the state is certainly aperiodic. For non self loop state we find possible no. of steps and then find gcd which may be 1. This makes the state aperiodic. Here state 3 is non self loop but return to it is possible in 2,3,4,5...... steps which has gcd =1. So the state is aperiodic.
Aperiodicity in markov chain For any state we find the possible no. Of steps in which we can return to the same state. If gcd of these nos. =1 then state is aperiodic. If gcd not equals 1 (say 'd'), then period equals 'd'. For a
44,395
How to prove linearity assumption in regression analysis for a continuous dependent and nominal independent variable?
Let me explain what linearity means with nominal/dummy variables. In essence, it means there is no interaction term between your independent variables that you have left out.† Suppose we have two nominal variables $x_0$ and $x_1$, each taking values 0 or 1, and a response variable $y$. (The general case is similar.) If we model $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \epsilon$: $\beta_0$ is the expected response when $x_1 = x_2 = 0$ $\beta_0 + \beta_1$ is the expected response when $x_1 = 1, x_2 = 0$ $\beta_0 + \beta_2$ is the expected response when $x_1 = 0, x_2 = 1$ $\beta_0 + \beta_1 + \beta_2$ is the expected response when $x_1 = x_2 = 1$ There's a relationship here, since we have 3 coefficients but four cases: The last minus the first is the sum of the second minus the first and the third minus the first. If this relationship actually holds in your situation between the expected responses, then this linear model can be a good one. If not, then the failure of this relationship is a type of nonlinearity. If we include an interaction term, then linearity is automatically satisfied, because we have four coefficients to fit the four cases. That is, with a model $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_1 x_2 + \epsilon$ there is no restriction on the relationship between the expected responses in the four cases above. (However the distributions of y in these 4 cases may still be different, which would violate the model as written.) How do you test whether you can leave out the interaction term? One way would be to try including it and test whether the coefficient $\beta_3$ is distinct from zero. For example, in the case of normal error $\epsilon$, this would be a $t$-test for a slope coefficient in a regression. † An interaction between $x_1$ & $x_2$ is a type of (multi-dimensional) nonlinearity: there's no possibility of a nonlinear relationship between $\operatorname{E}Y$ and $x_1$ when $x_1$ is a dummy variable, but there is between $\operatorname{E}Y$ and $(x_1,x_2)$. That is, there may be no plane passing through the four points $(0,0,\operatorname{E}(Y|\,0,0))$, $(1,0,\operatorname{\operatorname{E}}(Y|\,1,0))$, $(0,1,\operatorname{E}(Y|\,0,1))$, $(1,1,\operatorname{E}(Y|\,1,1))$. For dummy variables, these interaction terms are the only potential source of nonlinearity of the expected responses.
How to prove linearity assumption in regression analysis for a continuous dependent and nominal inde
Let me explain what linearity means with nominal/dummy variables. In essence, it means there is no interaction term between your independent variables that you have left out.† Suppose we have two nomi
How to prove linearity assumption in regression analysis for a continuous dependent and nominal independent variable? Let me explain what linearity means with nominal/dummy variables. In essence, it means there is no interaction term between your independent variables that you have left out.† Suppose we have two nominal variables $x_0$ and $x_1$, each taking values 0 or 1, and a response variable $y$. (The general case is similar.) If we model $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \epsilon$: $\beta_0$ is the expected response when $x_1 = x_2 = 0$ $\beta_0 + \beta_1$ is the expected response when $x_1 = 1, x_2 = 0$ $\beta_0 + \beta_2$ is the expected response when $x_1 = 0, x_2 = 1$ $\beta_0 + \beta_1 + \beta_2$ is the expected response when $x_1 = x_2 = 1$ There's a relationship here, since we have 3 coefficients but four cases: The last minus the first is the sum of the second minus the first and the third minus the first. If this relationship actually holds in your situation between the expected responses, then this linear model can be a good one. If not, then the failure of this relationship is a type of nonlinearity. If we include an interaction term, then linearity is automatically satisfied, because we have four coefficients to fit the four cases. That is, with a model $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_1 x_2 + \epsilon$ there is no restriction on the relationship between the expected responses in the four cases above. (However the distributions of y in these 4 cases may still be different, which would violate the model as written.) How do you test whether you can leave out the interaction term? One way would be to try including it and test whether the coefficient $\beta_3$ is distinct from zero. For example, in the case of normal error $\epsilon$, this would be a $t$-test for a slope coefficient in a regression. † An interaction between $x_1$ & $x_2$ is a type of (multi-dimensional) nonlinearity: there's no possibility of a nonlinear relationship between $\operatorname{E}Y$ and $x_1$ when $x_1$ is a dummy variable, but there is between $\operatorname{E}Y$ and $(x_1,x_2)$. That is, there may be no plane passing through the four points $(0,0,\operatorname{E}(Y|\,0,0))$, $(1,0,\operatorname{\operatorname{E}}(Y|\,1,0))$, $(0,1,\operatorname{E}(Y|\,0,1))$, $(1,1,\operatorname{E}(Y|\,1,1))$. For dummy variables, these interaction terms are the only potential source of nonlinearity of the expected responses.
How to prove linearity assumption in regression analysis for a continuous dependent and nominal inde Let me explain what linearity means with nominal/dummy variables. In essence, it means there is no interaction term between your independent variables that you have left out.† Suppose we have two nomi
44,396
How to prove linearity assumption in regression analysis for a continuous dependent and nominal independent variable?
Consider the model for regression of $y$ on $x$: $$\operatorname{E}Y=\beta_0 + \beta_1 x$$ If $x$ is a dummy variable representing a level of a categorical variable then it can take only the values 0 & 1: $$\operatorname{E}Y=\beta_0 \qquad \text{when } x=0$$ $$\operatorname{E}Y=\beta_0 + \beta_1 \qquad \text{when } x=1$$ and there is no question of linearity, merely two different fitted responses for each of two different groups. (Two points always lie in a straight line.) You can have other predictors $\boldsymbol{x}$ in the model $$\operatorname{E}Y=\beta_0 + \beta_1 x_1 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}$$ ; for any given values of those there are still only two values of $x_1$ to compare, & the difference in the response is given by $\beta_1$ $$\operatorname{E}Y=\beta_0 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}\qquad \text{when } x_1=0$$ $$\operatorname{E}Y=\beta_0 + \beta_1 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}\qquad \text{when } x_1=1$$ As @awcc explains, interaction can be considered a form of non-linearity, but it's not what people usually mean when they talk about non-linearity in the context of regression.
How to prove linearity assumption in regression analysis for a continuous dependent and nominal inde
Consider the model for regression of $y$ on $x$: $$\operatorname{E}Y=\beta_0 + \beta_1 x$$ If $x$ is a dummy variable representing a level of a categorical variable then it can take only the values 0
How to prove linearity assumption in regression analysis for a continuous dependent and nominal independent variable? Consider the model for regression of $y$ on $x$: $$\operatorname{E}Y=\beta_0 + \beta_1 x$$ If $x$ is a dummy variable representing a level of a categorical variable then it can take only the values 0 & 1: $$\operatorname{E}Y=\beta_0 \qquad \text{when } x=0$$ $$\operatorname{E}Y=\beta_0 + \beta_1 \qquad \text{when } x=1$$ and there is no question of linearity, merely two different fitted responses for each of two different groups. (Two points always lie in a straight line.) You can have other predictors $\boldsymbol{x}$ in the model $$\operatorname{E}Y=\beta_0 + \beta_1 x_1 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}$$ ; for any given values of those there are still only two values of $x_1$ to compare, & the difference in the response is given by $\beta_1$ $$\operatorname{E}Y=\beta_0 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}\qquad \text{when } x_1=0$$ $$\operatorname{E}Y=\beta_0 + \beta_1 + \boldsymbol\beta^\mathrm{T}\boldsymbol{x}\qquad \text{when } x_1=1$$ As @awcc explains, interaction can be considered a form of non-linearity, but it's not what people usually mean when they talk about non-linearity in the context of regression.
How to prove linearity assumption in regression analysis for a continuous dependent and nominal inde Consider the model for regression of $y$ on $x$: $$\operatorname{E}Y=\beta_0 + \beta_1 x$$ If $x$ is a dummy variable representing a level of a categorical variable then it can take only the values 0
44,397
What does "shift invariant" mean in convolutional neural network?
For CNNs, I think it means the invariance to small* displacements of the input image. For example in the character recognition task, if you train the system by shifting (i.e. sliding the images to left/right and up/down) a little bit, you learn a more generalizable detector, that works under difficult conditions, i.e. when the character is not perfectly aligned to the center of the image. Similar precautions are also taken for rotation, scale, etc. $^*$ I Googled to be sure about "small" and saw a similar discussion here, it made me realize that CNNs can be resistant to big displacements too, since the pooling process summarizes the local features in a smaller vector (that is representing the whole), it doesn't matter where you see the objects in the image.
What does "shift invariant" mean in convolutional neural network?
For CNNs, I think it means the invariance to small* displacements of the input image. For example in the character recognition task, if you train the system by shifting (i.e. sliding the images to lef
What does "shift invariant" mean in convolutional neural network? For CNNs, I think it means the invariance to small* displacements of the input image. For example in the character recognition task, if you train the system by shifting (i.e. sliding the images to left/right and up/down) a little bit, you learn a more generalizable detector, that works under difficult conditions, i.e. when the character is not perfectly aligned to the center of the image. Similar precautions are also taken for rotation, scale, etc. $^*$ I Googled to be sure about "small" and saw a similar discussion here, it made me realize that CNNs can be resistant to big displacements too, since the pooling process summarizes the local features in a smaller vector (that is representing the whole), it doesn't matter where you see the objects in the image.
What does "shift invariant" mean in convolutional neural network? For CNNs, I think it means the invariance to small* displacements of the input image. For example in the character recognition task, if you train the system by shifting (i.e. sliding the images to lef
44,398
What does "shift invariant" mean in convolutional neural network?
Shift-invariance: this means that if we shift the input in time (or shift the entries in a vector) then the output is shifted by the same amount http://pillowlab.princeton.edu/teaching/mathtools16/slides/lec22_LSIsystems.pdf
What does "shift invariant" mean in convolutional neural network?
Shift-invariance: this means that if we shift the input in time (or shift the entries in a vector) then the output is shifted by the same amount http://pillowlab.princeton.edu/teaching/mathtools16/sl
What does "shift invariant" mean in convolutional neural network? Shift-invariance: this means that if we shift the input in time (or shift the entries in a vector) then the output is shifted by the same amount http://pillowlab.princeton.edu/teaching/mathtools16/slides/lec22_LSIsystems.pdf
What does "shift invariant" mean in convolutional neural network? Shift-invariance: this means that if we shift the input in time (or shift the entries in a vector) then the output is shifted by the same amount http://pillowlab.princeton.edu/teaching/mathtools16/sl
44,399
What does "shift invariant" mean in convolutional neural network?
Adding to the previous answers, in math terms: $$f(x)\implies Transform\ T\implies g(x)$$ If the transform is shift invariant, then: $$f(x+a)\implies Transform\ T\implies g(x+a)$$ I.e. the $a$ shift is carried through the transform "untouched" Source: This excellent ETH lecture by Prof. Buhmann
What does "shift invariant" mean in convolutional neural network?
Adding to the previous answers, in math terms: $$f(x)\implies Transform\ T\implies g(x)$$ If the transform is shift invariant, then: $$f(x+a)\implies Transform\ T\implies g(x+a)$$ I.e. the $a$ shift i
What does "shift invariant" mean in convolutional neural network? Adding to the previous answers, in math terms: $$f(x)\implies Transform\ T\implies g(x)$$ If the transform is shift invariant, then: $$f(x+a)\implies Transform\ T\implies g(x+a)$$ I.e. the $a$ shift is carried through the transform "untouched" Source: This excellent ETH lecture by Prof. Buhmann
What does "shift invariant" mean in convolutional neural network? Adding to the previous answers, in math terms: $$f(x)\implies Transform\ T\implies g(x)$$ If the transform is shift invariant, then: $$f(x+a)\implies Transform\ T\implies g(x+a)$$ I.e. the $a$ shift i
44,400
What does "shift invariant" mean in convolutional neural network?
Shift-Invariance arises from Computer Vision tasks such as Image Classification. At a high level it means that the classifier should not be affected by the position of the object (e.g. cat) in the image. [From Bronstein et. al. Geometric DL] A little more: MLPs do not have this property. The claim that CNNs are shift-invariant is contested by Bronstein et. al., CNNs are shift-equivariant ("a shift of the input to a convolutional layer produces a shift in the output feature maps by the same amount"). What is shift invariant in traditional CV architectures are the pooling layers.
What does "shift invariant" mean in convolutional neural network?
Shift-Invariance arises from Computer Vision tasks such as Image Classification. At a high level it means that the classifier should not be affected by the position of the object (e.g. cat) in the ima
What does "shift invariant" mean in convolutional neural network? Shift-Invariance arises from Computer Vision tasks such as Image Classification. At a high level it means that the classifier should not be affected by the position of the object (e.g. cat) in the image. [From Bronstein et. al. Geometric DL] A little more: MLPs do not have this property. The claim that CNNs are shift-invariant is contested by Bronstein et. al., CNNs are shift-equivariant ("a shift of the input to a convolutional layer produces a shift in the output feature maps by the same amount"). What is shift invariant in traditional CV architectures are the pooling layers.
What does "shift invariant" mean in convolutional neural network? Shift-Invariance arises from Computer Vision tasks such as Image Classification. At a high level it means that the classifier should not be affected by the position of the object (e.g. cat) in the ima