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
35,801
p-value as a distance?
I believe the answer is yes. One could think of the "similarity" between two variables to be measured by (say) correlation. And for the p-value to be the significance of the correlation being different than 0. In such a case, a small p-value (nearing zero) is one that reflects a large distance ("difference") between the variables. You could turn the p-values into z scores (where the "distance" of them will have to "usual" direction), and see if the methods you mentioned will make sense on that...
p-value as a distance?
I believe the answer is yes. One could think of the "similarity" between two variables to be measured by (say) correlation. And for the p-value to be the significance of the correlation being differe
p-value as a distance? I believe the answer is yes. One could think of the "similarity" between two variables to be measured by (say) correlation. And for the p-value to be the significance of the correlation being different than 0. In such a case, a small p-value (nearing zero) is one that reflects a large distance ("difference") between the variables. You could turn the p-values into z scores (where the "distance" of them will have to "usual" direction), and see if the methods you mentioned will make sense on that...
p-value as a distance? I believe the answer is yes. One could think of the "similarity" between two variables to be measured by (say) correlation. And for the p-value to be the significance of the correlation being differe
35,802
p-value as a distance?
I am not sure what you mean by "p-values between multiple pair-wise tests ". The p-value is a measure of how likely / unlikely for a particular test it would be to see a value as extreme or more extreme than what was actually observed if the null hypothesis is true. When doing pairwise testing there is no particular connection between one p-value and another. I do not see how any p-values could be looked at as a similarity measure between pairwise tests.
p-value as a distance?
I am not sure what you mean by "p-values between multiple pair-wise tests ". The p-value is a measure of how likely / unlikely for a particular test it would be to see a value as extreme or more extr
p-value as a distance? I am not sure what you mean by "p-values between multiple pair-wise tests ". The p-value is a measure of how likely / unlikely for a particular test it would be to see a value as extreme or more extreme than what was actually observed if the null hypothesis is true. When doing pairwise testing there is no particular connection between one p-value and another. I do not see how any p-values could be looked at as a similarity measure between pairwise tests.
p-value as a distance? I am not sure what you mean by "p-values between multiple pair-wise tests ". The p-value is a measure of how likely / unlikely for a particular test it would be to see a value as extreme or more extr
35,803
Estimating ability using IRT when the model parameters are known
I can't find a way to do this in the ltm package, though it's relatively straightforward if you are willing to use the mirt package. First, write out some arbitrary matrix or data frame consisting of possible but random response patterns. You can include the actual response patterns you are interested in as well for later use. dat <- matrix(sample(c(0,1), 10000, TRUE), ncol = 5) colnames(dat) <- paste0('item', 1:5) Use this as the data input and to mirt() and give the option pars = 'values' to return a data frame containing parameter names, numbers, starting values, etc. Edit this object to contain the values you want for the intercepts, slopes, or whatever else, and set all the estimation logical to FALSE. This will cause the model to instantly converge with the parameters that you want. library(mirt) sv <- mirt(dat, 1, itemtype = '3PL', pars = 'values') #custom discrimination, easiness, and guessing values sv$value[sv$name == 'a1'] <- c(1,.9,.8,1,1.1) sv$value[sv$name == 'd'] <- c(-1,0,1.5,-1.5,0) sv$value[sv$name == 'g'] <- c(.2,.15,.17,.19,.15) #set the parameters as fixed sv$est <- FALSE Finally, (arbitrarily) estimate this model by using pars = sv, and use the returned object to calculate the factor scores. If you included the response patterns you are interested in then using fscores() directly work, otherwise use the response.pattern option to estimate the patterns directly. mod <- mirt(dat, 1, pars = sv) fscores(mod) #more interested in pattern: 0, 1, 1, 0, 1 fscores(mod, response.pattern = c(0,1,1,0,1)) Hope that's helpful. EDIT: Since I posted this answer a while back, the mirtCAT package was developed as an extension to mirt and contains a helper function called generate.mirt_object() for setting up a suitable mirt model with known coefficients. Here's how that can be done using the parameters above. library(mirtCAT) pars <- data.frame(a1 = c(1,.9,.8,1,1.1), d = c(-1,0,1.5,-1.5,0), g = c(.2,.15,.17,.19,.15)) mod <- generate.mirt_object(pars, itemtype = '3PL') # trait scores for pattern: 0, 1, 1, 0, 1 fscores(mod, response.pattern = c(0,1,1,0,1)) I think the wrapper version is less error prone, and certainly nicer to look at and understand.
Estimating ability using IRT when the model parameters are known
I can't find a way to do this in the ltm package, though it's relatively straightforward if you are willing to use the mirt package. First, write out some arbitrary matrix or data frame consisting of
Estimating ability using IRT when the model parameters are known I can't find a way to do this in the ltm package, though it's relatively straightforward if you are willing to use the mirt package. First, write out some arbitrary matrix or data frame consisting of possible but random response patterns. You can include the actual response patterns you are interested in as well for later use. dat <- matrix(sample(c(0,1), 10000, TRUE), ncol = 5) colnames(dat) <- paste0('item', 1:5) Use this as the data input and to mirt() and give the option pars = 'values' to return a data frame containing parameter names, numbers, starting values, etc. Edit this object to contain the values you want for the intercepts, slopes, or whatever else, and set all the estimation logical to FALSE. This will cause the model to instantly converge with the parameters that you want. library(mirt) sv <- mirt(dat, 1, itemtype = '3PL', pars = 'values') #custom discrimination, easiness, and guessing values sv$value[sv$name == 'a1'] <- c(1,.9,.8,1,1.1) sv$value[sv$name == 'd'] <- c(-1,0,1.5,-1.5,0) sv$value[sv$name == 'g'] <- c(.2,.15,.17,.19,.15) #set the parameters as fixed sv$est <- FALSE Finally, (arbitrarily) estimate this model by using pars = sv, and use the returned object to calculate the factor scores. If you included the response patterns you are interested in then using fscores() directly work, otherwise use the response.pattern option to estimate the patterns directly. mod <- mirt(dat, 1, pars = sv) fscores(mod) #more interested in pattern: 0, 1, 1, 0, 1 fscores(mod, response.pattern = c(0,1,1,0,1)) Hope that's helpful. EDIT: Since I posted this answer a while back, the mirtCAT package was developed as an extension to mirt and contains a helper function called generate.mirt_object() for setting up a suitable mirt model with known coefficients. Here's how that can be done using the parameters above. library(mirtCAT) pars <- data.frame(a1 = c(1,.9,.8,1,1.1), d = c(-1,0,1.5,-1.5,0), g = c(.2,.15,.17,.19,.15)) mod <- generate.mirt_object(pars, itemtype = '3PL') # trait scores for pattern: 0, 1, 1, 0, 1 fscores(mod, response.pattern = c(0,1,1,0,1)) I think the wrapper version is less error prone, and certainly nicer to look at and understand.
Estimating ability using IRT when the model parameters are known I can't find a way to do this in the ltm package, though it's relatively straightforward if you are willing to use the mirt package. First, write out some arbitrary matrix or data frame consisting of
35,804
Estimating ability using IRT when the model parameters are known
Try thetaEst from catR. From the manual: This command returns the ability estimate for a given response pattern and a given matrix of item parameters.
Estimating ability using IRT when the model parameters are known
Try thetaEst from catR. From the manual: This command returns the ability estimate for a given response pattern and a given matrix of item parameters.
Estimating ability using IRT when the model parameters are known Try thetaEst from catR. From the manual: This command returns the ability estimate for a given response pattern and a given matrix of item parameters.
Estimating ability using IRT when the model parameters are known Try thetaEst from catR. From the manual: This command returns the ability estimate for a given response pattern and a given matrix of item parameters.
35,805
How to draw mean, median and mode lines in R that end at density?
The density is represented as a polyline, which is a pair of parallel arrays, one for $x$, one for $y$, forming vertices along the graph of the density (with equal spacings in the $x$ direction). As such it is a discrete approximation to the idealized continuous density and we can use discrete versions of the relevant integrals to compute statistics. Because the spacing is typically so close, there's probably little need to interpolate between successive points: we can use simple algorithms. Whence, x <- seq(-2.5, 10, length=1000000) hx5 <- rnorm(x,0,1) + rexp(x,1/5) # tau=5 (rate = 1/tau) # # Compute the density. # dens <- density(hx5) # # Compute some measures of location. # n <- length(dens$y) #$ dx <- mean(diff(dens$x)) # Typical spacing in x $ y.unit <- sum(dens$y) * dx # Check: this should integrate to 1 $ dx <- dx / y.unit # Make a minor adjustment x.mean <- sum(dens$y * dens$x) * dx y.mean <- dens$y[length(dens$x[dens$x < x.mean])] #$ x.mode <- dens$x[i.mode <- which.max(dens$y)] y.mode <- dens$y[i.mode] #$ y.cs <- cumsum(dens$y) #$ x.med <- dens$x[i.med <- length(y.cs[2*y.cs <= y.cs[n]])] #$ y.med <- dens$y[i.med] #$ # # Plot the density and the statistics. # plot(dens, xlim=c(-2.5,10), type="l", col="green", xlab="x", main="ExGaussian curve",lwd=2) temp <- mapply(function(x,y,c) lines(c(x,x), c(0,y), lwd=2, col=c), c(x.mean, x.med, x.mode), c(y.mean, y.med, y.mode), c("Blue", "Gray", "Red"))
How to draw mean, median and mode lines in R that end at density?
The density is represented as a polyline, which is a pair of parallel arrays, one for $x$, one for $y$, forming vertices along the graph of the density (with equal spacings in the $x$ direction). As s
How to draw mean, median and mode lines in R that end at density? The density is represented as a polyline, which is a pair of parallel arrays, one for $x$, one for $y$, forming vertices along the graph of the density (with equal spacings in the $x$ direction). As such it is a discrete approximation to the idealized continuous density and we can use discrete versions of the relevant integrals to compute statistics. Because the spacing is typically so close, there's probably little need to interpolate between successive points: we can use simple algorithms. Whence, x <- seq(-2.5, 10, length=1000000) hx5 <- rnorm(x,0,1) + rexp(x,1/5) # tau=5 (rate = 1/tau) # # Compute the density. # dens <- density(hx5) # # Compute some measures of location. # n <- length(dens$y) #$ dx <- mean(diff(dens$x)) # Typical spacing in x $ y.unit <- sum(dens$y) * dx # Check: this should integrate to 1 $ dx <- dx / y.unit # Make a minor adjustment x.mean <- sum(dens$y * dens$x) * dx y.mean <- dens$y[length(dens$x[dens$x < x.mean])] #$ x.mode <- dens$x[i.mode <- which.max(dens$y)] y.mode <- dens$y[i.mode] #$ y.cs <- cumsum(dens$y) #$ x.med <- dens$x[i.med <- length(y.cs[2*y.cs <= y.cs[n]])] #$ y.med <- dens$y[i.med] #$ # # Plot the density and the statistics. # plot(dens, xlim=c(-2.5,10), type="l", col="green", xlab="x", main="ExGaussian curve",lwd=2) temp <- mapply(function(x,y,c) lines(c(x,x), c(0,y), lwd=2, col=c), c(x.mean, x.med, x.mode), c(y.mean, y.med, y.mode), c("Blue", "Gray", "Red"))
How to draw mean, median and mode lines in R that end at density? The density is represented as a polyline, which is a pair of parallel arrays, one for $x$, one for $y$, forming vertices along the graph of the density (with equal spacings in the $x$ direction). As s
35,806
Using ARMA when data is missing
There is no need to do anything. An ARMA model can easily be estimated with missing values within the time series. You need to use the state space representation of an ARMA model to compute the likelihood. If you use R, this is already handled automatically via the arima() function.
Using ARMA when data is missing
There is no need to do anything. An ARMA model can easily be estimated with missing values within the time series. You need to use the state space representation of an ARMA model to compute the likeli
Using ARMA when data is missing There is no need to do anything. An ARMA model can easily be estimated with missing values within the time series. You need to use the state space representation of an ARMA model to compute the likelihood. If you use R, this is already handled automatically via the arima() function.
Using ARMA when data is missing There is no need to do anything. An ARMA model can easily be estimated with missing values within the time series. You need to use the state space representation of an ARMA model to compute the likeli
35,807
How to interpret the output for calculating concordance index (c-index)?
The index of concordance is a "global" index for validating the predictive ability of a survival model. It is the fraction of pairs in your data, where the observation with the higher survival time has the higher probability of survival predicted by your model. As far as I remember it it equivalent to a rank correlation. The index is not calculated for every observation/subject. So the c-index can not be interpreted as the risk of a subject. High values mean that your model predicts higher probabilities of survival for higher observed survival times. If you are interested in the risk of a subject in a timeperiod t, I think you have to estimate the survival and hazard function for a given set of regressors. My main reference on this subject is Harrell (2001): Rgression Modeling Strategies, Springer
How to interpret the output for calculating concordance index (c-index)?
The index of concordance is a "global" index for validating the predictive ability of a survival model. It is the fraction of pairs in your data, where the observation with the higher survival time ha
How to interpret the output for calculating concordance index (c-index)? The index of concordance is a "global" index for validating the predictive ability of a survival model. It is the fraction of pairs in your data, where the observation with the higher survival time has the higher probability of survival predicted by your model. As far as I remember it it equivalent to a rank correlation. The index is not calculated for every observation/subject. So the c-index can not be interpreted as the risk of a subject. High values mean that your model predicts higher probabilities of survival for higher observed survival times. If you are interested in the risk of a subject in a timeperiod t, I think you have to estimate the survival and hazard function for a given set of regressors. My main reference on this subject is Harrell (2001): Rgression Modeling Strategies, Springer
How to interpret the output for calculating concordance index (c-index)? The index of concordance is a "global" index for validating the predictive ability of a survival model. It is the fraction of pairs in your data, where the observation with the higher survival time ha
35,808
How to interpret the output for calculating concordance index (c-index)?
High risk by your definition means likely to have short survival times.
How to interpret the output for calculating concordance index (c-index)?
High risk by your definition means likely to have short survival times.
How to interpret the output for calculating concordance index (c-index)? High risk by your definition means likely to have short survival times.
How to interpret the output for calculating concordance index (c-index)? High risk by your definition means likely to have short survival times.
35,809
Flexible version of logistic regression
This problem surfaces in virtually all classification approaches, whether logistic regression, support vector classification, or Naive Bayes classification. There are two intertwined issues: A model trained on an imbalanced dataset may overfit in the sense of acquiring a bias in favour of the majority class. When evaluating this model on a test dataset with the same degree of imbalance, classification accuracy can be a hugely misleading performance measure. The literature on these issues has come up with three solution strategies: You can restore balance on the training set by undersampling the large class or by oversampling the small class, to prevent bias from arising in the first place (see the response by @grotos). Alternatively, you can modify the costs of misclassification to prevent the model from acquiring a bias in the first place. An additional safeguard is to replace the accuracy by the so-called balanced accuracy. It is defined as the arithmetic mean of the class-specific accuracies, $\phi := \frac{1}{2}\left(\pi^+ + \pi^-\right),$ where $\pi^+$ and $\pi^-$ represent the accuracy obtained on positive and negative examples, respectively. If the classifier performs equally well on either class, this term reduces to the conventional accuracy (i.e., the number of correct predictions divided by the total number of predictions). In contrast, if the conventional accuracy is above chance only because the classifier takes advantage of an imbalanced test set, then the balanced accuracy, as appropriate, will drop to chance (see sketch below which I have taken from my response to a related question). As detailed in my previous response, I would recommend to consider at least two of the above approaches in conjunction. For example, you could oversample your minority class to prevent your classifier from acquiring a bias in favour the majority class. Following this, when evaluating the performance of your classifier, you could replace the accuracy by the balanced accuracy.
Flexible version of logistic regression
This problem surfaces in virtually all classification approaches, whether logistic regression, support vector classification, or Naive Bayes classification. There are two intertwined issues: A model
Flexible version of logistic regression This problem surfaces in virtually all classification approaches, whether logistic regression, support vector classification, or Naive Bayes classification. There are two intertwined issues: A model trained on an imbalanced dataset may overfit in the sense of acquiring a bias in favour of the majority class. When evaluating this model on a test dataset with the same degree of imbalance, classification accuracy can be a hugely misleading performance measure. The literature on these issues has come up with three solution strategies: You can restore balance on the training set by undersampling the large class or by oversampling the small class, to prevent bias from arising in the first place (see the response by @grotos). Alternatively, you can modify the costs of misclassification to prevent the model from acquiring a bias in the first place. An additional safeguard is to replace the accuracy by the so-called balanced accuracy. It is defined as the arithmetic mean of the class-specific accuracies, $\phi := \frac{1}{2}\left(\pi^+ + \pi^-\right),$ where $\pi^+$ and $\pi^-$ represent the accuracy obtained on positive and negative examples, respectively. If the classifier performs equally well on either class, this term reduces to the conventional accuracy (i.e., the number of correct predictions divided by the total number of predictions). In contrast, if the conventional accuracy is above chance only because the classifier takes advantage of an imbalanced test set, then the balanced accuracy, as appropriate, will drop to chance (see sketch below which I have taken from my response to a related question). As detailed in my previous response, I would recommend to consider at least two of the above approaches in conjunction. For example, you could oversample your minority class to prevent your classifier from acquiring a bias in favour the majority class. Following this, when evaluating the performance of your classifier, you could replace the accuracy by the balanced accuracy.
Flexible version of logistic regression This problem surfaces in virtually all classification approaches, whether logistic regression, support vector classification, or Naive Bayes classification. There are two intertwined issues: A model
35,810
Flexible version of logistic regression
That it doesn't work does not come from the unbalanced size of the groups, but from the smallness of one of the groups. Downsampling the larger group is ok but does not help with overfitting. (BTW, there is an easy and elegant way to correct the predictions from the downsampled model, by adding ±log(r) to the linear terms where r is the downsampling ratio.) If overfitting really is the problem, you need to either decrease the number of variables, or regularize the model.
Flexible version of logistic regression
That it doesn't work does not come from the unbalanced size of the groups, but from the smallness of one of the groups. Downsampling the larger group is ok but does not help with overfitting. (BTW, th
Flexible version of logistic regression That it doesn't work does not come from the unbalanced size of the groups, but from the smallness of one of the groups. Downsampling the larger group is ok but does not help with overfitting. (BTW, there is an easy and elegant way to correct the predictions from the downsampled model, by adding ±log(r) to the linear terms where r is the downsampling ratio.) If overfitting really is the problem, you need to either decrease the number of variables, or regularize the model.
Flexible version of logistic regression That it doesn't work does not come from the unbalanced size of the groups, but from the smallness of one of the groups. Downsampling the larger group is ok but does not help with overfitting. (BTW, th
35,811
Flexible version of logistic regression
Do you mean the distribution of response, i.e. you have 70 cases of "YES" and 10000 of "NO"? If so, that is a common problem in data mining applications. Imagine a database with 1,000,000 instances, where only about 1,000 cases are "YES". Response rate of 1% and even less is a common thing in a business predictive modeling. And if you pick a sample to train a model that is a huge problem, especially with assessing stability of given model. What we do is pick a sample with different proportions. In aforementioned example, that would be 1000 cases of "YES" and, for instance, 9000 of "NO" cases. This approach gives more stable models. However, it have to be tested on a real sample (that with 1,000,000 rows). I've tested it with data mining models, such as logistic regression, decision trees, etc. However, I haven't used it with "proper" [1] statistic models. You can search it as "oversampling in statistics", the first result is pretty good: http://www.statssa.gov.za/isi2009/ScientificProgramme/IPMS/1621.pdf [1] "proper" in meaning "not data mining".
Flexible version of logistic regression
Do you mean the distribution of response, i.e. you have 70 cases of "YES" and 10000 of "NO"? If so, that is a common problem in data mining applications. Imagine a database with 1,000,000 instances, w
Flexible version of logistic regression Do you mean the distribution of response, i.e. you have 70 cases of "YES" and 10000 of "NO"? If so, that is a common problem in data mining applications. Imagine a database with 1,000,000 instances, where only about 1,000 cases are "YES". Response rate of 1% and even less is a common thing in a business predictive modeling. And if you pick a sample to train a model that is a huge problem, especially with assessing stability of given model. What we do is pick a sample with different proportions. In aforementioned example, that would be 1000 cases of "YES" and, for instance, 9000 of "NO" cases. This approach gives more stable models. However, it have to be tested on a real sample (that with 1,000,000 rows). I've tested it with data mining models, such as logistic regression, decision trees, etc. However, I haven't used it with "proper" [1] statistic models. You can search it as "oversampling in statistics", the first result is pretty good: http://www.statssa.gov.za/isi2009/ScientificProgramme/IPMS/1621.pdf [1] "proper" in meaning "not data mining".
Flexible version of logistic regression Do you mean the distribution of response, i.e. you have 70 cases of "YES" and 10000 of "NO"? If so, that is a common problem in data mining applications. Imagine a database with 1,000,000 instances, w
35,812
Flexible version of logistic regression
If you want a classification technique that is insensitive to the relative proportion of examples from different classes, Support Vector Machines have that property as do decision trees.
Flexible version of logistic regression
If you want a classification technique that is insensitive to the relative proportion of examples from different classes, Support Vector Machines have that property as do decision trees.
Flexible version of logistic regression If you want a classification technique that is insensitive to the relative proportion of examples from different classes, Support Vector Machines have that property as do decision trees.
Flexible version of logistic regression If you want a classification technique that is insensitive to the relative proportion of examples from different classes, Support Vector Machines have that property as do decision trees.
35,813
How does glm.nb work?
Thanks for clarifying. So, it appears you want to have the inner workings of GLM estimation explained. I can give a sketch, but I doubt it will help you much. It's probably better to read a book on GLM, e.g McCullagh and Nelder's book. Anyway: Question 1 The standard error for the $β_j$ in a GLM that uses Fischer scoring or IWLS (iteratively weighted least squares) gets calculated as: The square roots of the diagonal elements of $cov(\hat{β}) = \phi(X^T\hat{W}X)^{−1}$ in which $(X^T\hat{W}X)^{−1}$ is a by-product of the final IWLS iteration (the inverse of the estimated Fisher information). If $\phi$ is unknown, an estimate is required (as in quasi families). In glm.nb fitting this whole thing is actually achieved by fitting a negative binomial model with a fixed shape (or a Poisson in the initial fit) and then estimating the shape parameter iteratively and alternating both steps, and hence the standard error gets calculated as with glm(..., family=negbin(shape)) (Edit: The estimated shape parameter in your example is 163.32) Question 2 Has already been explained. The $z$ value is a Wald test, which divides the estimate of $\beta_j$ by it's standard error (the diagonal element from above), i.e. $z_j=\frac{\hat{\beta_j}}{\sqrt{\phi(X^T\hat{W}X)_{jj}^{−1}}} $ Question 3 I still don't understand the part about "And how is the fitting of negative binomial distribution influence the std. error, z-value or the p-value?" But I think you would like to know where dispersion parameter comes from: The dispersion parameter $\phi$ here is simply fixed at 1 (because it is a Negative Binomial GLM with known shape parameter that is used in the second stage).
How does glm.nb work?
Thanks for clarifying. So, it appears you want to have the inner workings of GLM estimation explained. I can give a sketch, but I doubt it will help you much. It's probably better to read a book on GL
How does glm.nb work? Thanks for clarifying. So, it appears you want to have the inner workings of GLM estimation explained. I can give a sketch, but I doubt it will help you much. It's probably better to read a book on GLM, e.g McCullagh and Nelder's book. Anyway: Question 1 The standard error for the $β_j$ in a GLM that uses Fischer scoring or IWLS (iteratively weighted least squares) gets calculated as: The square roots of the diagonal elements of $cov(\hat{β}) = \phi(X^T\hat{W}X)^{−1}$ in which $(X^T\hat{W}X)^{−1}$ is a by-product of the final IWLS iteration (the inverse of the estimated Fisher information). If $\phi$ is unknown, an estimate is required (as in quasi families). In glm.nb fitting this whole thing is actually achieved by fitting a negative binomial model with a fixed shape (or a Poisson in the initial fit) and then estimating the shape parameter iteratively and alternating both steps, and hence the standard error gets calculated as with glm(..., family=negbin(shape)) (Edit: The estimated shape parameter in your example is 163.32) Question 2 Has already been explained. The $z$ value is a Wald test, which divides the estimate of $\beta_j$ by it's standard error (the diagonal element from above), i.e. $z_j=\frac{\hat{\beta_j}}{\sqrt{\phi(X^T\hat{W}X)_{jj}^{−1}}} $ Question 3 I still don't understand the part about "And how is the fitting of negative binomial distribution influence the std. error, z-value or the p-value?" But I think you would like to know where dispersion parameter comes from: The dispersion parameter $\phi$ here is simply fixed at 1 (because it is a Negative Binomial GLM with known shape parameter that is used in the second stage).
How does glm.nb work? Thanks for clarifying. So, it appears you want to have the inner workings of GLM estimation explained. I can give a sketch, but I doubt it will help you much. It's probably better to read a book on GL
35,814
Why is my replication of Silver & Dunlap 1987 not working out?
To me, the r bias entry for rho of 0.5 in the Silver & Dunlap table looks the most suspiciously different to me. However, that said, it does match your estimated value quite closely. Unfortunately, I don't have access to the Silver & Dunlap paper at the moment, but a Google search did turn up a recent paper that performs a similar study to the one you've done. It is R. L. Gorsuch and C. S. Lehmann (2010), Correlation coefficients: Mean bias and confidence interval distortions, Journal of Methods and Measurement in the Social Sciences, vol. 1, no. 2, 52–65. See, in particular, their Table 3 which, at least by eye, appears to corroborate your results. I certainly can't vouch for the quality of the journal (or the whole paper), which looks quite new and a bit rough around the edges, in my estimation. Caveat lector. For an in-depth, more theoretical, treatment of inference on correlation (simple, partial, and multiple) primarily in a multivariate normal framework, a good reference is F. A. Graybill, Theory and application of the linear model, Duxbury Press, 1976, Chapter 11. It does not concern itself much with small-sample performance or applied aspects, though.
Why is my replication of Silver & Dunlap 1987 not working out?
To me, the r bias entry for rho of 0.5 in the Silver & Dunlap table looks the most suspiciously different to me. However, that said, it does match your estimated value quite closely. Unfortunately, I
Why is my replication of Silver & Dunlap 1987 not working out? To me, the r bias entry for rho of 0.5 in the Silver & Dunlap table looks the most suspiciously different to me. However, that said, it does match your estimated value quite closely. Unfortunately, I don't have access to the Silver & Dunlap paper at the moment, but a Google search did turn up a recent paper that performs a similar study to the one you've done. It is R. L. Gorsuch and C. S. Lehmann (2010), Correlation coefficients: Mean bias and confidence interval distortions, Journal of Methods and Measurement in the Social Sciences, vol. 1, no. 2, 52–65. See, in particular, their Table 3 which, at least by eye, appears to corroborate your results. I certainly can't vouch for the quality of the journal (or the whole paper), which looks quite new and a bit rough around the edges, in my estimation. Caveat lector. For an in-depth, more theoretical, treatment of inference on correlation (simple, partial, and multiple) primarily in a multivariate normal framework, a good reference is F. A. Graybill, Theory and application of the linear model, Duxbury Press, 1976, Chapter 11. It does not concern itself much with small-sample performance or applied aspects, though.
Why is my replication of Silver & Dunlap 1987 not working out? To me, the r bias entry for rho of 0.5 in the Silver & Dunlap table looks the most suspiciously different to me. However, that said, it does match your estimated value quite closely. Unfortunately, I
35,815
Can simple vector distance work as a SVM kernel?
No, this kernel doesn't give a positive (semi-) definite Gram matrix, so it is not a valid kernel (the first randomly generated Gram matrix $\matrix{K}$ and vector $\vec{v}$ I tried gave $\vec{v}'\matrix{K}\vec{v} < 0$ so $\matrix{K}$ isn't positive semi-definite. If you infer from that that I am an engineer - you are correct! ;o). ISTR that Kernel functions need to be "diagonally dominant", i.e. the largest magnitude element in any row or column needs to be the one on the principal diagonal, which won't be true here as the principal diagonal is all zeros (the distance from any point to itself being zero). This is guaranteed for the RBF kernel as taking the negative exponential of the distance can never be greater than 1, which ocurrs when $\vec{x}_1$ and $\vec{x}_2$ are the same. Note however if the kernel is too diagonally dominant then it is likely to lead to over-fitting.
Can simple vector distance work as a SVM kernel?
No, this kernel doesn't give a positive (semi-) definite Gram matrix, so it is not a valid kernel (the first randomly generated Gram matrix $\matrix{K}$ and vector $\vec{v}$ I tried gave $\vec{v}'\mat
Can simple vector distance work as a SVM kernel? No, this kernel doesn't give a positive (semi-) definite Gram matrix, so it is not a valid kernel (the first randomly generated Gram matrix $\matrix{K}$ and vector $\vec{v}$ I tried gave $\vec{v}'\matrix{K}\vec{v} < 0$ so $\matrix{K}$ isn't positive semi-definite. If you infer from that that I am an engineer - you are correct! ;o). ISTR that Kernel functions need to be "diagonally dominant", i.e. the largest magnitude element in any row or column needs to be the one on the principal diagonal, which won't be true here as the principal diagonal is all zeros (the distance from any point to itself being zero). This is guaranteed for the RBF kernel as taking the negative exponential of the distance can never be greater than 1, which ocurrs when $\vec{x}_1$ and $\vec{x}_2$ are the same. Note however if the kernel is too diagonally dominant then it is likely to lead to over-fitting.
Can simple vector distance work as a SVM kernel? No, this kernel doesn't give a positive (semi-) definite Gram matrix, so it is not a valid kernel (the first randomly generated Gram matrix $\matrix{K}$ and vector $\vec{v}$ I tried gave $\vec{v}'\mat
35,816
Are these populations non-random and different?
For question 2, I would start by looking at the distributions of the percentages of each group that have a given trait. e.g.: A <- c(126,86,63,54,47,40,32,32,29,29,27,26,20,18,14) B <- c(357,196,185,137,95,74,45,69,64,49,54,80,62,41,56) C <- c(348,139,162,126,82,69,35,63,40,42,40,55,44,29,35) N <- c(382,207,193,143,100,80,45,70,70,53,55,84,67,42,57) A <- A/N B <- B/N C <- C/N Then you can make some stem and leaf plots to examine the distributions: > stem(A) The decimal point is 1 digit(s) to the left of the | 2 | 5 3 | 01338 4 | 123679 5 | 05 6 | 7 | 1 > stem(B) The decimal point is 2 digit(s) to the left of the | 90 | 4 92 | 5555 94 | 70289 96 | 6 98 | 226 100 | 0 > stem(C) The decimal point is 1 digit(s) to the left of the | 5 | 7 6 | 15679 7 | 389 8 | 2468 9 | 01 All three look somewhat normal, but that's pretty subjective. Only the .71 in stem(A) appears to be an outlier to me.
Are these populations non-random and different?
For question 2, I would start by looking at the distributions of the percentages of each group that have a given trait. e.g.: A <- c(126,86,63,54,47,40,32,32,29,29,27,26,20,18,14) B <- c(357,196,185,
Are these populations non-random and different? For question 2, I would start by looking at the distributions of the percentages of each group that have a given trait. e.g.: A <- c(126,86,63,54,47,40,32,32,29,29,27,26,20,18,14) B <- c(357,196,185,137,95,74,45,69,64,49,54,80,62,41,56) C <- c(348,139,162,126,82,69,35,63,40,42,40,55,44,29,35) N <- c(382,207,193,143,100,80,45,70,70,53,55,84,67,42,57) A <- A/N B <- B/N C <- C/N Then you can make some stem and leaf plots to examine the distributions: > stem(A) The decimal point is 1 digit(s) to the left of the | 2 | 5 3 | 01338 4 | 123679 5 | 05 6 | 7 | 1 > stem(B) The decimal point is 2 digit(s) to the left of the | 90 | 4 92 | 5555 94 | 70289 96 | 6 98 | 226 100 | 0 > stem(C) The decimal point is 1 digit(s) to the left of the | 5 | 7 6 | 15679 7 | 389 8 | 2468 9 | 01 All three look somewhat normal, but that's pretty subjective. Only the .71 in stem(A) appears to be an outlier to me.
Are these populations non-random and different? For question 2, I would start by looking at the distributions of the percentages of each group that have a given trait. e.g.: A <- c(126,86,63,54,47,40,32,32,29,29,27,26,20,18,14) B <- c(357,196,185,
35,817
Are these populations non-random and different?
i'm not sure if i understand the problem correctly - so correct me if i'm wrong but here's my thoughts: So, is spottiness non-random for members in a group? And does spottiness vary significantly between the groups? I'm not sure if the first question is answerable with the data presented. If the data was available in the following form: Head Tail Body Group Lizard 1 Y N N A Lizard 2 Y Y N A ... One would be able to test the randomness of individuals. However, the individuals are - as far as I understand not available - right? The same applies for the second question which I would simply test with a Mann-Whitney-U test or something like that (in R use ?wilcox.test). So I hope i got your problem right - if not please correct me! EDIT As for the second question: whether to determine if you have significantly more individuals with spots in one group than in another. one (maybe to simple) way was taking the distributions given above (with normal densities in blue): and assuming a normal distribution and then testing each group against the mean. that would be: $z = (A_1 - \bar{A}) / \sigma_A$ with $\bar{A}$ being the mean of group $A$. Correct me if I made a mistake but this would give the following p-values: pnorm((A-mean(A))/sd(A)) [1] 0.21718755 0.47952112 0.20871568 0.35415346 0.66053450 0.74852194 [7] 0.99325922 0.61952780 0.47553465 0.85819411 0.72317286 0.16977245 [13] 0.14707919 0.52412299 0.06677287
Are these populations non-random and different?
i'm not sure if i understand the problem correctly - so correct me if i'm wrong but here's my thoughts: So, is spottiness non-random for members in a group? And does spottiness vary significantly bet
Are these populations non-random and different? i'm not sure if i understand the problem correctly - so correct me if i'm wrong but here's my thoughts: So, is spottiness non-random for members in a group? And does spottiness vary significantly between the groups? I'm not sure if the first question is answerable with the data presented. If the data was available in the following form: Head Tail Body Group Lizard 1 Y N N A Lizard 2 Y Y N A ... One would be able to test the randomness of individuals. However, the individuals are - as far as I understand not available - right? The same applies for the second question which I would simply test with a Mann-Whitney-U test or something like that (in R use ?wilcox.test). So I hope i got your problem right - if not please correct me! EDIT As for the second question: whether to determine if you have significantly more individuals with spots in one group than in another. one (maybe to simple) way was taking the distributions given above (with normal densities in blue): and assuming a normal distribution and then testing each group against the mean. that would be: $z = (A_1 - \bar{A}) / \sigma_A$ with $\bar{A}$ being the mean of group $A$. Correct me if I made a mistake but this would give the following p-values: pnorm((A-mean(A))/sd(A)) [1] 0.21718755 0.47952112 0.20871568 0.35415346 0.66053450 0.74852194 [7] 0.99325922 0.61952780 0.47553465 0.85819411 0.72317286 0.16977245 [13] 0.14707919 0.52412299 0.06677287
Are these populations non-random and different? i'm not sure if i understand the problem correctly - so correct me if i'm wrong but here's my thoughts: So, is spottiness non-random for members in a group? And does spottiness vary significantly bet
35,818
Are these populations non-random and different?
I'm not sure I fully understand the situation (your data or your question). @Zach has some good ideas, so I thought I'd follow his lead and throw out some information and we'll see if something helps. 1) To determine if data are random, the runs test can be used. A run is a series of data points that are similar in some way. There are (at least) two ways of doing a runs test. First, you can check if each new data point is higher or lower than the previous one, alternatively, you can check if each data point is high or low relative to the median. Both of these assume that your data are ordered by the temporal sequence in which they were generated. From there, you use one of the methods above to convert your data into a string of ones and zeros. Sequential values of the same type are a run (e.g., 1101 is 3 runs). The number of runs is a binomial random variable. Here is some code for R: # compute proportions & create vectors for runs Aprop = A/N; Bprop = B/N; Cprop = C/N Achange = c(); Bchange = c(); Cchange = c() Ahigh = c(); Bhigh = c(); Chigh = c() for(i in 1:length(N)) { if(i>1) { # determine if values went up or down Achange[i-1] = (Aprop[i]-Aprop[i-1])>0 Bchange[i-1] = (Bprop[i]-Bprop[i-1])>0 Cchange[i-1] = (Cprop[i]-Cprop[i-1])>0 } # determine if values are high or low Ahigh[i] = Aprop[i]>median(Aprop) Bhigh[i] = Bprop[i]>median(Bprop) Chigh[i] = Cprop[i]>median(Cprop) } # conduct analyses round(Aprop, 2) # [1] 0.33 0.42 0.33 0.38 0.47 0.50 0.71 0.46 0.41 0.55 0.49 0.31 0.30 0.43 0.25 as.numeric(Achange) # [1] 1 0 1 1 1 1 0 0 1 0 0 0 1 0 (8 runs) runs.test(as.factor(Achange)) Runs Test data: as.factor(Achange) Standard Normal = 0, p-value = 1 alternative hypothesis: two.sided as.numeric(Ahigh) # [1] 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 (7 runs) runs.test(as.factor(Ahigh)) Runs Test data: as.factor(Ahigh) Standard Normal = -0.7898, p-value = 0.4297 alternative hypothesis: two.sided So group A looks random according to both methods. (Bear in mind that the test relies on large sample theory, and your N is 15, but the data seem OK. Also remember that, if you have a bunch of groups and you run a bunch of tests on them, something is likely to show up whether its real or not.) 2) To determine if the distributions are similar, you can calculate summary statistics and plot graphs. I often find graphs most helpful. Two graphs that I like are kernal density plots and qq-plots. A kernal desity plot is like a smoothed histogram. It's easy to plot several distributions together. A qq-plot is a scatterplot of one distribution against another after both have been sorted into ascending order. If the two distributions have similar shapes, the points should lie along a 45 degree line through the origin. Most people think of qq-plots as a way to compare a distribution to a theoretical normal distribution, but they can be used for any theoretical distribution (e.g., Weibull) or the empirical distribution of another data set. Thus, you could make a series of plots for pairwise comparisons. It also helps to plot the 45 degree line to help with interpretation. Here is some R code and graphs: summary(Aprop) # Min. 1st Qu. Median Mean 3rd Qu. Max. # 0.2456 0.3281 0.4155 0.4215 0.4805 0.7111 windows() plot( density(Aprop), col="gold", xlim=c(0,1)) lines(density(Bprop), col="red") lines(density(Cprop), col="blue") legend("topleft", c("Aprop","Bprop","Cprop"), lty=1, col=c("gold","red","blue")) windows() qqplot(Aprop, Cprop) abline(0, 1) windows() qqplot(Aprop, Bprop) abline(0, 1) The first qq-plot shows that the distributions of the A group and the C group are pretty similar--they follow the 45 degree line pretty well. It's just that C is consistently higher than A. This can be confirmed by looking at the density plot. At first, the lower qq-plot looks OK, but you notice that the 45 degree line doesn't even show up in the plot window. That's a big tip-off. If you look at the scales, you see that B varies between .91 and 1.0, whereas A varies from .3 to .7. A and B are just not that similar, as you can see in the density plot. Density plots are really informative, but they can also exaggerate the shape of a distribution. That's why it's nice to plot both. A and C look rather different in the density plot, but based on the qq-plot, I'd bet the differences in the shapes of the distributions wouldn't be reliable. And both plots suggest @Zach is right about that outlier.
Are these populations non-random and different?
I'm not sure I fully understand the situation (your data or your question). @Zach has some good ideas, so I thought I'd follow his lead and throw out some information and we'll see if something helps
Are these populations non-random and different? I'm not sure I fully understand the situation (your data or your question). @Zach has some good ideas, so I thought I'd follow his lead and throw out some information and we'll see if something helps. 1) To determine if data are random, the runs test can be used. A run is a series of data points that are similar in some way. There are (at least) two ways of doing a runs test. First, you can check if each new data point is higher or lower than the previous one, alternatively, you can check if each data point is high or low relative to the median. Both of these assume that your data are ordered by the temporal sequence in which they were generated. From there, you use one of the methods above to convert your data into a string of ones and zeros. Sequential values of the same type are a run (e.g., 1101 is 3 runs). The number of runs is a binomial random variable. Here is some code for R: # compute proportions & create vectors for runs Aprop = A/N; Bprop = B/N; Cprop = C/N Achange = c(); Bchange = c(); Cchange = c() Ahigh = c(); Bhigh = c(); Chigh = c() for(i in 1:length(N)) { if(i>1) { # determine if values went up or down Achange[i-1] = (Aprop[i]-Aprop[i-1])>0 Bchange[i-1] = (Bprop[i]-Bprop[i-1])>0 Cchange[i-1] = (Cprop[i]-Cprop[i-1])>0 } # determine if values are high or low Ahigh[i] = Aprop[i]>median(Aprop) Bhigh[i] = Bprop[i]>median(Bprop) Chigh[i] = Cprop[i]>median(Cprop) } # conduct analyses round(Aprop, 2) # [1] 0.33 0.42 0.33 0.38 0.47 0.50 0.71 0.46 0.41 0.55 0.49 0.31 0.30 0.43 0.25 as.numeric(Achange) # [1] 1 0 1 1 1 1 0 0 1 0 0 0 1 0 (8 runs) runs.test(as.factor(Achange)) Runs Test data: as.factor(Achange) Standard Normal = 0, p-value = 1 alternative hypothesis: two.sided as.numeric(Ahigh) # [1] 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 (7 runs) runs.test(as.factor(Ahigh)) Runs Test data: as.factor(Ahigh) Standard Normal = -0.7898, p-value = 0.4297 alternative hypothesis: two.sided So group A looks random according to both methods. (Bear in mind that the test relies on large sample theory, and your N is 15, but the data seem OK. Also remember that, if you have a bunch of groups and you run a bunch of tests on them, something is likely to show up whether its real or not.) 2) To determine if the distributions are similar, you can calculate summary statistics and plot graphs. I often find graphs most helpful. Two graphs that I like are kernal density plots and qq-plots. A kernal desity plot is like a smoothed histogram. It's easy to plot several distributions together. A qq-plot is a scatterplot of one distribution against another after both have been sorted into ascending order. If the two distributions have similar shapes, the points should lie along a 45 degree line through the origin. Most people think of qq-plots as a way to compare a distribution to a theoretical normal distribution, but they can be used for any theoretical distribution (e.g., Weibull) or the empirical distribution of another data set. Thus, you could make a series of plots for pairwise comparisons. It also helps to plot the 45 degree line to help with interpretation. Here is some R code and graphs: summary(Aprop) # Min. 1st Qu. Median Mean 3rd Qu. Max. # 0.2456 0.3281 0.4155 0.4215 0.4805 0.7111 windows() plot( density(Aprop), col="gold", xlim=c(0,1)) lines(density(Bprop), col="red") lines(density(Cprop), col="blue") legend("topleft", c("Aprop","Bprop","Cprop"), lty=1, col=c("gold","red","blue")) windows() qqplot(Aprop, Cprop) abline(0, 1) windows() qqplot(Aprop, Bprop) abline(0, 1) The first qq-plot shows that the distributions of the A group and the C group are pretty similar--they follow the 45 degree line pretty well. It's just that C is consistently higher than A. This can be confirmed by looking at the density plot. At first, the lower qq-plot looks OK, but you notice that the 45 degree line doesn't even show up in the plot window. That's a big tip-off. If you look at the scales, you see that B varies between .91 and 1.0, whereas A varies from .3 to .7. A and B are just not that similar, as you can see in the density plot. Density plots are really informative, but they can also exaggerate the shape of a distribution. That's why it's nice to plot both. A and C look rather different in the density plot, but based on the qq-plot, I'd bet the differences in the shapes of the distributions wouldn't be reliable. And both plots suggest @Zach is right about that outlier.
Are these populations non-random and different? I'm not sure I fully understand the situation (your data or your question). @Zach has some good ideas, so I thought I'd follow his lead and throw out some information and we'll see if something helps
35,819
Textbooks on the numerical solution of stochastic differential equations
In addition to the Kloeden and Platen books already mentioned, the book Simulation and Inference for Stochastic Differential Equations by Stefano Iacus is good. He is also the author of the sde package for R.
Textbooks on the numerical solution of stochastic differential equations
In addition to the Kloeden and Platen books already mentioned, the book Simulation and Inference for Stochastic Differential Equations by Stefano Iacus is good. He is also the author of the sde packag
Textbooks on the numerical solution of stochastic differential equations In addition to the Kloeden and Platen books already mentioned, the book Simulation and Inference for Stochastic Differential Equations by Stefano Iacus is good. He is also the author of the sde package for R.
Textbooks on the numerical solution of stochastic differential equations In addition to the Kloeden and Platen books already mentioned, the book Simulation and Inference for Stochastic Differential Equations by Stefano Iacus is good. He is also the author of the sde packag
35,820
Textbooks on the numerical solution of stochastic differential equations
These two books may be a good starting point Numerical Solution of Stochastic Differential Equations (Stochastic Modelling and Applied Probability, 23) by Peter E. Kloeden and Eckhard Platen. Numerical Solution of SDE Through Computer Experiments (Universitext) by Peter Eris Kloeden, Eckhard Platen and Henri Schurz.
Textbooks on the numerical solution of stochastic differential equations
These two books may be a good starting point Numerical Solution of Stochastic Differential Equations (Stochastic Modelling and Applied Probability, 23) by Peter E. Kloeden and Eckhard Platen. Numeri
Textbooks on the numerical solution of stochastic differential equations These two books may be a good starting point Numerical Solution of Stochastic Differential Equations (Stochastic Modelling and Applied Probability, 23) by Peter E. Kloeden and Eckhard Platen. Numerical Solution of SDE Through Computer Experiments (Universitext) by Peter Eris Kloeden, Eckhard Platen and Henri Schurz.
Textbooks on the numerical solution of stochastic differential equations These two books may be a good starting point Numerical Solution of Stochastic Differential Equations (Stochastic Modelling and Applied Probability, 23) by Peter E. Kloeden and Eckhard Platen. Numeri
35,821
Testing homoscedasticity with Breusch-Pagan test
The problem isn't heteroskedasticity, that's why it's passing the test. The problem is that your model doesn't work well for (at least some of) your observations. I've never seen anyone analyze stock prices without looking at their differences. Try a Dickey-Fuller test for a unit root---I bet that you can't reject that there is one, as @mpiktas alludes to in his comment. If there isn't a unit root, perhaps there is a time trend or seasonality. You might try including a linear time trend or seasonal components. Alternatively, you might try working with the log of the prices, which sometimes helps the fit.
Testing homoscedasticity with Breusch-Pagan test
The problem isn't heteroskedasticity, that's why it's passing the test. The problem is that your model doesn't work well for (at least some of) your observations. I've never seen anyone analyze stock
Testing homoscedasticity with Breusch-Pagan test The problem isn't heteroskedasticity, that's why it's passing the test. The problem is that your model doesn't work well for (at least some of) your observations. I've never seen anyone analyze stock prices without looking at their differences. Try a Dickey-Fuller test for a unit root---I bet that you can't reject that there is one, as @mpiktas alludes to in his comment. If there isn't a unit root, perhaps there is a time trend or seasonality. You might try including a linear time trend or seasonal components. Alternatively, you might try working with the log of the prices, which sometimes helps the fit.
Testing homoscedasticity with Breusch-Pagan test The problem isn't heteroskedasticity, that's why it's passing the test. The problem is that your model doesn't work well for (at least some of) your observations. I've never seen anyone analyze stock
35,822
What to do in case of low inter-rater reliability (ICC)?
I'd rather answer on the grounds of the methodology itself, rather than how to "fix" the situation. In another context, I assisted in working on a ratings and classification system, and found that inter-rater agreement was disappointingly low. Two paths were considered Change how rating agreements were defined and identify those who seemed to "understand" the task, or Refine the definitions used, along with the guidance and examples provider to raters, so that they could more easily understand how to rate things. In the first sceneario, the whole methodology and results could be rendered a waste simply because the inter-rater reliability was low. It indicated that either the original definitions were bad or that the raters were given poor instructions. If I proceeded along that path, I was sure to have problems. In the second case, the agreement between raters was very good. Since they rated quite a lot of items, they could also give feedback with when they thought the original definitions and guidance were inadequate. In the end, the methodology was very reproducible. Based on that, I would not yet modify your set of raters, but return to the original definitions and guidance. Any tinkering after the rating is a problem, though it can be useful as a quality check. There are sometimes raters that are going to do what they want, no matter the guidance given. With good statistical methods, it is easy to identify them and weight their contributions appropriately. Now, if I'm mistaken and you don't plan to do further collection, i.e. your data is already collected and done, what you may do is PCA or something like it, and see if you can get a sense of how the different doctors (or patients) cluster. Were the patients exposed to all of the doctors at the same time (e.g. through a video recording) or were they exposed sequentially, and had a chance to modify their presentation with each interaction? If the latter, then there could be issues with the patients, and not the doctors.
What to do in case of low inter-rater reliability (ICC)?
I'd rather answer on the grounds of the methodology itself, rather than how to "fix" the situation. In another context, I assisted in working on a ratings and classification system, and found that in
What to do in case of low inter-rater reliability (ICC)? I'd rather answer on the grounds of the methodology itself, rather than how to "fix" the situation. In another context, I assisted in working on a ratings and classification system, and found that inter-rater agreement was disappointingly low. Two paths were considered Change how rating agreements were defined and identify those who seemed to "understand" the task, or Refine the definitions used, along with the guidance and examples provider to raters, so that they could more easily understand how to rate things. In the first sceneario, the whole methodology and results could be rendered a waste simply because the inter-rater reliability was low. It indicated that either the original definitions were bad or that the raters were given poor instructions. If I proceeded along that path, I was sure to have problems. In the second case, the agreement between raters was very good. Since they rated quite a lot of items, they could also give feedback with when they thought the original definitions and guidance were inadequate. In the end, the methodology was very reproducible. Based on that, I would not yet modify your set of raters, but return to the original definitions and guidance. Any tinkering after the rating is a problem, though it can be useful as a quality check. There are sometimes raters that are going to do what they want, no matter the guidance given. With good statistical methods, it is easy to identify them and weight their contributions appropriately. Now, if I'm mistaken and you don't plan to do further collection, i.e. your data is already collected and done, what you may do is PCA or something like it, and see if you can get a sense of how the different doctors (or patients) cluster. Were the patients exposed to all of the doctors at the same time (e.g. through a video recording) or were they exposed sequentially, and had a chance to modify their presentation with each interaction? If the latter, then there could be issues with the patients, and not the doctors.
What to do in case of low inter-rater reliability (ICC)? I'd rather answer on the grounds of the methodology itself, rather than how to "fix" the situation. In another context, I assisted in working on a ratings and classification system, and found that in
35,823
What to do in case of low inter-rater reliability (ICC)?
Cherry-picking the best ICC value out of 28 possible pairs is definitely NOT a good idea, as that estimate of ICC is certainly optimistic. Neuendorf's The Content Analysis Handbook has a pretty good discussion of options for dealing with poor reliability in coding. Citation is: Neuendorf, Kimberly A. The Content Analysis Handbook. Sage, Thousand Oaks, CA, 2002 There's an accompanying website.
What to do in case of low inter-rater reliability (ICC)?
Cherry-picking the best ICC value out of 28 possible pairs is definitely NOT a good idea, as that estimate of ICC is certainly optimistic. Neuendorf's The Content Analysis Handbook has a pretty good
What to do in case of low inter-rater reliability (ICC)? Cherry-picking the best ICC value out of 28 possible pairs is definitely NOT a good idea, as that estimate of ICC is certainly optimistic. Neuendorf's The Content Analysis Handbook has a pretty good discussion of options for dealing with poor reliability in coding. Citation is: Neuendorf, Kimberly A. The Content Analysis Handbook. Sage, Thousand Oaks, CA, 2002 There's an accompanying website.
What to do in case of low inter-rater reliability (ICC)? Cherry-picking the best ICC value out of 28 possible pairs is definitely NOT a good idea, as that estimate of ICC is certainly optimistic. Neuendorf's The Content Analysis Handbook has a pretty good
35,824
Preferred methods for graphing time-series data to present "averages"?
I suggest adding an example or two of what you are presently doing so we can better see what you are dealing with. What you are concerned with is an important issue: how do you convey the "overall" pattern in the time series data while also not misleading viewers by showing just average values? One way I have dealt with this situation is plotting an average or median line along with surrounding quantile bands. For example, Here, the time series data are from a bootstrap-based simulation so there are hundreds of values associated with each time point. The actual data are plotted in the black line with colored bands showing the variability of values from the simulation. This particular plot is maybe not the best example to show, but you can see that some points have much more variability than others, and you can also assess how the variability is skewed above/below the actual values depending on the position in the series. UPDATE: Given your update here are some additional questions and thoughts... What decisions, if any, are made from this visualization? For example, are you looking for specific points in time where there is very slow response time, perhaps above a specific threshold? If so, it may be better to simply plot all of the points as a scatter plot, and then also plot a time series line showing the average value, as well as some lines delineating the bounds you are concerned about. This recommendation is not appropriate if you have numerous observations at some time points (too much clutter), or if your time measurement is not sufficiently coarse (in which case you can bin response data into minute-wide time of day intervals). But the visualization recommendation will certainly be affected by what decision(s) will be supported with it. In my example, I was looking at such plots side by side, one from one simulation and the other from another simulation (each simulation using different parameters) so I could assess the variability of the underlying model due to sampling error.
Preferred methods for graphing time-series data to present "averages"?
I suggest adding an example or two of what you are presently doing so we can better see what you are dealing with. What you are concerned with is an important issue: how do you convey the "overall" pa
Preferred methods for graphing time-series data to present "averages"? I suggest adding an example or two of what you are presently doing so we can better see what you are dealing with. What you are concerned with is an important issue: how do you convey the "overall" pattern in the time series data while also not misleading viewers by showing just average values? One way I have dealt with this situation is plotting an average or median line along with surrounding quantile bands. For example, Here, the time series data are from a bootstrap-based simulation so there are hundreds of values associated with each time point. The actual data are plotted in the black line with colored bands showing the variability of values from the simulation. This particular plot is maybe not the best example to show, but you can see that some points have much more variability than others, and you can also assess how the variability is skewed above/below the actual values depending on the position in the series. UPDATE: Given your update here are some additional questions and thoughts... What decisions, if any, are made from this visualization? For example, are you looking for specific points in time where there is very slow response time, perhaps above a specific threshold? If so, it may be better to simply plot all of the points as a scatter plot, and then also plot a time series line showing the average value, as well as some lines delineating the bounds you are concerned about. This recommendation is not appropriate if you have numerous observations at some time points (too much clutter), or if your time measurement is not sufficiently coarse (in which case you can bin response data into minute-wide time of day intervals). But the visualization recommendation will certainly be affected by what decision(s) will be supported with it. In my example, I was looking at such plots side by side, one from one simulation and the other from another simulation (each simulation using different parameters) so I could assess the variability of the underlying model due to sampling error.
Preferred methods for graphing time-series data to present "averages"? I suggest adding an example or two of what you are presently doing so we can better see what you are dealing with. What you are concerned with is an important issue: how do you convey the "overall" pa
35,825
Preferred methods for graphing time-series data to present "averages"?
Have you considered a scatterplot of the data themselves? That's an approach I really like. It lets the viewer make their own conclusions about the presence and significance of trends, and it doesn't conceal variability or outliers. Alpha-blending the points will help if you have serious overplotting (which it sounds like you might). You can also overlay whatever trend you like and take comfort in knowing that the data are still present to speak for themselves.
Preferred methods for graphing time-series data to present "averages"?
Have you considered a scatterplot of the data themselves? That's an approach I really like. It lets the viewer make their own conclusions about the presence and significance of trends, and it doesn'
Preferred methods for graphing time-series data to present "averages"? Have you considered a scatterplot of the data themselves? That's an approach I really like. It lets the viewer make their own conclusions about the presence and significance of trends, and it doesn't conceal variability or outliers. Alpha-blending the points will help if you have serious overplotting (which it sounds like you might). You can also overlay whatever trend you like and take comfort in knowing that the data are still present to speak for themselves.
Preferred methods for graphing time-series data to present "averages"? Have you considered a scatterplot of the data themselves? That's an approach I really like. It lets the viewer make their own conclusions about the presence and significance of trends, and it doesn'
35,826
Multinomial choice with binary observations
Unless I misunderstood the question, this refers to paired preference (1) or pair comparison data. A well-known example of such a model is the Bradley-Terry model (2), which shares some connections with item scaling in psychometrics (3). There is an R package, BradleyTerry2, described in the JSS (2005) 12(1), Bradley-Terry Models in R, and a detailed overview in Agresti's CDA, pp. 436-439, with R code available in Laura Thompson's textbook, R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis (2002) 2nd edition. References Thurstone, L.L. (1927). A law of comparative judgment. Psychological Review, 3, 273-286. Bradley, R.A. and Terry, M.E. (1952). Rank analysis of incomplete block designs I: The methods of paired comparisons. Biometrika, 39, 324-345. Andrich, D. (1978). Relationships between the Thurstone and Rasch approaches to item scaling. Applied Psychological Measurement, 2(3), 451-462.
Multinomial choice with binary observations
Unless I misunderstood the question, this refers to paired preference (1) or pair comparison data. A well-known example of such a model is the Bradley-Terry model (2), which shares some connections wi
Multinomial choice with binary observations Unless I misunderstood the question, this refers to paired preference (1) or pair comparison data. A well-known example of such a model is the Bradley-Terry model (2), which shares some connections with item scaling in psychometrics (3). There is an R package, BradleyTerry2, described in the JSS (2005) 12(1), Bradley-Terry Models in R, and a detailed overview in Agresti's CDA, pp. 436-439, with R code available in Laura Thompson's textbook, R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis (2002) 2nd edition. References Thurstone, L.L. (1927). A law of comparative judgment. Psychological Review, 3, 273-286. Bradley, R.A. and Terry, M.E. (1952). Rank analysis of incomplete block designs I: The methods of paired comparisons. Biometrika, 39, 324-345. Andrich, D. (1978). Relationships between the Thurstone and Rasch approaches to item scaling. Applied Psychological Measurement, 2(3), 451-462.
Multinomial choice with binary observations Unless I misunderstood the question, this refers to paired preference (1) or pair comparison data. A well-known example of such a model is the Bradley-Terry model (2), which shares some connections wi
35,827
Anscombe transform and normal approximation
Here is a sketch of a proof which combines three ideas: (a) the delta method, (b) variance-stabilization transformations and (c) the closure of the Poisson distribution under independent sums. First, let's consider a sequence of iid Poisson random variables $X_1, X_2, \ldots$ with mean $\lambda > 0$. Then, the Central Limit Theorem asserts that $$\newcommand{\barX}{\bar{X}_n}\newcommand{\convd}{\,\xrightarrow{\,d\,}\,}\newcommand{\Nml}{\mathcal{N}} \sqrt{n} (\barX - \lambda) \convd \Nml(0,\lambda) \> . $$ Notice that the asymptotic variance depends on the (presumably unknown) parameter $\lambda$. It would be nice if we could find some function of the data other than $\bar{X}_n$ such that, after centering and rescaling, it had the same asymptotic variance no matter what the parameter $\lambda$ was. The delta method provides a handy way for determining the distribution of smooth functions of some statistic whose limiting distribution is already known. Let $g$ be a function with continuous first derivative such that $g'(\lambda) \neq 0$. Then, by the delta method (specialized to our particular case of interest), $$ \sqrt{n}\big(g(\barX) - g(\lambda)\big) \convd \Nml(0, \lambda g'(\lambda)^2) \>. $$ So, how can we make the asymptotic variance constant (say, the value $1$) for all possible $\lambda$? From the expression above, we know we need to solve $$g'(\lambda) = \lambda^{-1/2} \>.$$ It is not hard to see that the general antiderivative is $g(\lambda) = 2 \sqrt{\lambda} + c$ for any $c$, and the limiting distribution is invariant to the choice of $c$ (by subtraction), so we can set $c = 0$ without loss of generality. Such a function $g$ is called a variance-stabilizing transformation. Hence, by the delta method and our choice of $g$, we conclude that $$ \sqrt{n}\Big(2\sqrt{\barX} - 2\sqrt{\lambda}\Big) \convd \Nml(0, 1) \>. $$ Now, the Poisson distribution is closed under independent sums. So, if $X$ is Poisson with mean $\lambda$, then there exist random variables $Z_1, \ldots, Z_n$ that are iid Poisson with mean $\lambda/n$ such that $\sum_{i=1}^n Z_i$ has the same distribution as $X$. This motivates the approximation in the case of a single Poisson random variable. What Anscombe (1948) found was that modifying the transformation $g$ (slightly) to $\tilde{g}(\lambda) = 2\sqrt{\lambda + b}$ for some constant $b$ actually worked better for smaller $\lambda$. In this case, $b = 3/8$ is about optimal. Note that this modification "destroys" the true variance-stabilizing property of $g$, i.e., $\tilde{g}$ is not variance-stabilizing in the strict sense. But, it is close and gives better results for smaller $\lambda$.
Anscombe transform and normal approximation
Here is a sketch of a proof which combines three ideas: (a) the delta method, (b) variance-stabilization transformations and (c) the closure of the Poisson distribution under independent sums. First,
Anscombe transform and normal approximation Here is a sketch of a proof which combines three ideas: (a) the delta method, (b) variance-stabilization transformations and (c) the closure of the Poisson distribution under independent sums. First, let's consider a sequence of iid Poisson random variables $X_1, X_2, \ldots$ with mean $\lambda > 0$. Then, the Central Limit Theorem asserts that $$\newcommand{\barX}{\bar{X}_n}\newcommand{\convd}{\,\xrightarrow{\,d\,}\,}\newcommand{\Nml}{\mathcal{N}} \sqrt{n} (\barX - \lambda) \convd \Nml(0,\lambda) \> . $$ Notice that the asymptotic variance depends on the (presumably unknown) parameter $\lambda$. It would be nice if we could find some function of the data other than $\bar{X}_n$ such that, after centering and rescaling, it had the same asymptotic variance no matter what the parameter $\lambda$ was. The delta method provides a handy way for determining the distribution of smooth functions of some statistic whose limiting distribution is already known. Let $g$ be a function with continuous first derivative such that $g'(\lambda) \neq 0$. Then, by the delta method (specialized to our particular case of interest), $$ \sqrt{n}\big(g(\barX) - g(\lambda)\big) \convd \Nml(0, \lambda g'(\lambda)^2) \>. $$ So, how can we make the asymptotic variance constant (say, the value $1$) for all possible $\lambda$? From the expression above, we know we need to solve $$g'(\lambda) = \lambda^{-1/2} \>.$$ It is not hard to see that the general antiderivative is $g(\lambda) = 2 \sqrt{\lambda} + c$ for any $c$, and the limiting distribution is invariant to the choice of $c$ (by subtraction), so we can set $c = 0$ without loss of generality. Such a function $g$ is called a variance-stabilizing transformation. Hence, by the delta method and our choice of $g$, we conclude that $$ \sqrt{n}\Big(2\sqrt{\barX} - 2\sqrt{\lambda}\Big) \convd \Nml(0, 1) \>. $$ Now, the Poisson distribution is closed under independent sums. So, if $X$ is Poisson with mean $\lambda$, then there exist random variables $Z_1, \ldots, Z_n$ that are iid Poisson with mean $\lambda/n$ such that $\sum_{i=1}^n Z_i$ has the same distribution as $X$. This motivates the approximation in the case of a single Poisson random variable. What Anscombe (1948) found was that modifying the transformation $g$ (slightly) to $\tilde{g}(\lambda) = 2\sqrt{\lambda + b}$ for some constant $b$ actually worked better for smaller $\lambda$. In this case, $b = 3/8$ is about optimal. Note that this modification "destroys" the true variance-stabilizing property of $g$, i.e., $\tilde{g}$ is not variance-stabilizing in the strict sense. But, it is close and gives better results for smaller $\lambda$.
Anscombe transform and normal approximation Here is a sketch of a proof which combines three ideas: (a) the delta method, (b) variance-stabilization transformations and (c) the closure of the Poisson distribution under independent sums. First,
35,828
Power calculation for likelihood ratio test
You can do this using simulation. Write a function that does your test and accepts the lambdas and sample size(s) as arguments (you have a good start above). Now for a given set of lambdas and sample size(s) run the function a bunch of times (the replicate function in R is great for that). Then the power is just the proportion of times that you reject the null hypothesis, you can use the mean function to compute the proportion and prop.test to give a confidence interval on the power. Here is some example code: tmpfunc1 <- function(l1, l2=l1, n1=10, n2=n1) { x1 <- rpois(n1, l1) x2 <- rpois(n2, l2) m1 <- mean(x1) m2 <- mean(x2) m <- mean( c(x1,x2) ) ll <- sum( dpois(x1, m1, log=TRUE) ) + sum( dpois(x2, m2, log=TRUE) ) - sum( dpois(x1, m, log=TRUE) ) - sum( dpois(x2, m, log=TRUE) ) pchisq(2*ll, 1, lower=FALSE) } # verify under null n=10 out1 <- replicate(10000, tmpfunc1(3)) mean(out1 <= 0.05) hist(out1) prop.test( sum(out1<=0.05), 10000 )$conf.int # power for l1=3, l2=3.5, n1=n2=10 out2 <- replicate(10000, tmpfunc1(3,3.5)) mean(out2 <= 0.05) hist(out2) # power for l1=3, l2=3.5, n1=n2=50 out3 <- replicate(10000, tmpfunc1(3,3.5,n1=50)) mean(out3 <= 0.05) hist(out3) My results (your will differ with a different seed, but should be similar) showed a type I error rate (alpha) of 0.0496 (95% CI 0.0455-0.0541) which is close to 0.05, more precision can be obtained by increasing the 10000 in the replicate command. The powers I computed were: 9.86% and 28.6%. The histograms are not strictly necessary, but I like seeing the patterns.
Power calculation for likelihood ratio test
You can do this using simulation. Write a function that does your test and accepts the lambdas and sample size(s) as arguments (you have a good start above). Now for a given set of lambdas and sample
Power calculation for likelihood ratio test You can do this using simulation. Write a function that does your test and accepts the lambdas and sample size(s) as arguments (you have a good start above). Now for a given set of lambdas and sample size(s) run the function a bunch of times (the replicate function in R is great for that). Then the power is just the proportion of times that you reject the null hypothesis, you can use the mean function to compute the proportion and prop.test to give a confidence interval on the power. Here is some example code: tmpfunc1 <- function(l1, l2=l1, n1=10, n2=n1) { x1 <- rpois(n1, l1) x2 <- rpois(n2, l2) m1 <- mean(x1) m2 <- mean(x2) m <- mean( c(x1,x2) ) ll <- sum( dpois(x1, m1, log=TRUE) ) + sum( dpois(x2, m2, log=TRUE) ) - sum( dpois(x1, m, log=TRUE) ) - sum( dpois(x2, m, log=TRUE) ) pchisq(2*ll, 1, lower=FALSE) } # verify under null n=10 out1 <- replicate(10000, tmpfunc1(3)) mean(out1 <= 0.05) hist(out1) prop.test( sum(out1<=0.05), 10000 )$conf.int # power for l1=3, l2=3.5, n1=n2=10 out2 <- replicate(10000, tmpfunc1(3,3.5)) mean(out2 <= 0.05) hist(out2) # power for l1=3, l2=3.5, n1=n2=50 out3 <- replicate(10000, tmpfunc1(3,3.5,n1=50)) mean(out3 <= 0.05) hist(out3) My results (your will differ with a different seed, but should be similar) showed a type I error rate (alpha) of 0.0496 (95% CI 0.0455-0.0541) which is close to 0.05, more precision can be obtained by increasing the 10000 in the replicate command. The powers I computed were: 9.86% and 28.6%. The histograms are not strictly necessary, but I like seeing the patterns.
Power calculation for likelihood ratio test You can do this using simulation. Write a function that does your test and accepts the lambdas and sample size(s) as arguments (you have a good start above). Now for a given set of lambdas and sample
35,829
Symbolic computer algebra for statistics
Support for matrix algebra. The vast majority of practiced statistics is multivariate and involves matrices, and often simplifying matrix forms requires special rules that aren't easily translated from a univariate case, so good matrix support would be really helpful.
Symbolic computer algebra for statistics
Support for matrix algebra. The vast majority of practiced statistics is multivariate and involves matrices, and often simplifying matrix forms requires special rules that aren't easily translated fro
Symbolic computer algebra for statistics Support for matrix algebra. The vast majority of practiced statistics is multivariate and involves matrices, and often simplifying matrix forms requires special rules that aren't easily translated from a univariate case, so good matrix support would be really helpful.
Symbolic computer algebra for statistics Support for matrix algebra. The vast majority of practiced statistics is multivariate and involves matrices, and often simplifying matrix forms requires special rules that aren't easily translated fro
35,830
Estimating Lambda for Box Cox transformation for ANOVA
It is not appropriate to do ordinary ANOVA after using the same dataset to fit lambda. The analysis should be unified, penalizing for uncertainty in lambda (a parameter to be estimated, and included in the covariance matrix).
Estimating Lambda for Box Cox transformation for ANOVA
It is not appropriate to do ordinary ANOVA after using the same dataset to fit lambda. The analysis should be unified, penalizing for uncertainty in lambda (a parameter to be estimated, and included
Estimating Lambda for Box Cox transformation for ANOVA It is not appropriate to do ordinary ANOVA after using the same dataset to fit lambda. The analysis should be unified, penalizing for uncertainty in lambda (a parameter to be estimated, and included in the covariance matrix).
Estimating Lambda for Box Cox transformation for ANOVA It is not appropriate to do ordinary ANOVA after using the same dataset to fit lambda. The analysis should be unified, penalizing for uncertainty in lambda (a parameter to be estimated, and included
35,831
Estimating Lambda for Box Cox transformation for ANOVA
The Box-Cox transformation tries to improve the normality of the residuals. Since that is the assumption of ANOVA as well, you should run it on the model that you are actually going to use, i.e. the full model. For example, if you have two well separated groups, the distribution of the response variable will be strongly bimodal and nowhere near normal even if within each group the distribution is normal. Additionally, you certainly want to take whuber's comment to heart, and check for outliers, missing predictors, etc to make sure that some artifact is not driving your transformation. Also consider the confidence interval around the optimal lambda, and whether a particular transformation within that interval does make applied sense. For example, if you have linear measurements, but the outcome would reasonably be related to a volume, then a lambda=3 or lambda=-3 might be meaningful. If, on the other hand, areas are involved, then 2 or -2 might be better choices.
Estimating Lambda for Box Cox transformation for ANOVA
The Box-Cox transformation tries to improve the normality of the residuals. Since that is the assumption of ANOVA as well, you should run it on the model that you are actually going to use, i.e. the f
Estimating Lambda for Box Cox transformation for ANOVA The Box-Cox transformation tries to improve the normality of the residuals. Since that is the assumption of ANOVA as well, you should run it on the model that you are actually going to use, i.e. the full model. For example, if you have two well separated groups, the distribution of the response variable will be strongly bimodal and nowhere near normal even if within each group the distribution is normal. Additionally, you certainly want to take whuber's comment to heart, and check for outliers, missing predictors, etc to make sure that some artifact is not driving your transformation. Also consider the confidence interval around the optimal lambda, and whether a particular transformation within that interval does make applied sense. For example, if you have linear measurements, but the outcome would reasonably be related to a volume, then a lambda=3 or lambda=-3 might be meaningful. If, on the other hand, areas are involved, then 2 or -2 might be better choices.
Estimating Lambda for Box Cox transformation for ANOVA The Box-Cox transformation tries to improve the normality of the residuals. Since that is the assumption of ANOVA as well, you should run it on the model that you are actually going to use, i.e. the f
35,832
Two-stage clustering in R
The closest package that I can think of is birch, but it is not available on CRAN anymore so you have to get the source and install it yourself (R CMD install birch_1.1-3.tar.gz works fine for me, OS X 10.6 with R version 2.13.0 (2011-04-13)). It implements the original algorithm described in Zhang, T. and Ramakrishnan, R. and Livny, M. (1997). BIRCH: A New Data Clustering Algorithm and Its Applications. Data Mining and Knowledge Discovery, 1, 141-182. which relies on cluster feature tree, as does SPSS TwoStep (I cannot check, though). There's a possibility of using the k-means algorithm to perform clustering on birch object (kmeans.birch()), that is partition the subclusters into k groups such that the sum of squares of all the points in each subcluster to the assigned cluster centers is minimized.
Two-stage clustering in R
The closest package that I can think of is birch, but it is not available on CRAN anymore so you have to get the source and install it yourself (R CMD install birch_1.1-3.tar.gz works fine for me, OS
Two-stage clustering in R The closest package that I can think of is birch, but it is not available on CRAN anymore so you have to get the source and install it yourself (R CMD install birch_1.1-3.tar.gz works fine for me, OS X 10.6 with R version 2.13.0 (2011-04-13)). It implements the original algorithm described in Zhang, T. and Ramakrishnan, R. and Livny, M. (1997). BIRCH: A New Data Clustering Algorithm and Its Applications. Data Mining and Knowledge Discovery, 1, 141-182. which relies on cluster feature tree, as does SPSS TwoStep (I cannot check, though). There's a possibility of using the k-means algorithm to perform clustering on birch object (kmeans.birch()), that is partition the subclusters into k groups such that the sum of squares of all the points in each subcluster to the assigned cluster centers is minimized.
Two-stage clustering in R The closest package that I can think of is birch, but it is not available on CRAN anymore so you have to get the source and install it yourself (R CMD install birch_1.1-3.tar.gz works fine for me, OS
35,833
Two-stage clustering in R
Maybe this also can help: https://cran.r-project.org/web/packages/prcr/ Provides an easy-to-use yet adaptable set of tools to conduct person-center analysis using a two-step clustering procedure. As described in Bergman and El-Khouri (1999) doi:10.1002/(SICI)1521-4036(199910)41:6%3C753::AID-BIMJ753%3E3.0.CO;2-K, hierarchical clustering is performed to determine the initial partition for the subsequent k-means clustering procedure.
Two-stage clustering in R
Maybe this also can help: https://cran.r-project.org/web/packages/prcr/ Provides an easy-to-use yet adaptable set of tools to conduct person-center analysis using a two-step clustering procedure. As
Two-stage clustering in R Maybe this also can help: https://cran.r-project.org/web/packages/prcr/ Provides an easy-to-use yet adaptable set of tools to conduct person-center analysis using a two-step clustering procedure. As described in Bergman and El-Khouri (1999) doi:10.1002/(SICI)1521-4036(199910)41:6%3C753::AID-BIMJ753%3E3.0.CO;2-K, hierarchical clustering is performed to determine the initial partition for the subsequent k-means clustering procedure.
Two-stage clustering in R Maybe this also can help: https://cran.r-project.org/web/packages/prcr/ Provides an easy-to-use yet adaptable set of tools to conduct person-center analysis using a two-step clustering procedure. As
35,834
Two-stage clustering in R
If you are looking for something akin to a 2-step, have you considered looking into Self Organizing Maps. I think it is based on similar (but not the same) principle as 2-step.
Two-stage clustering in R
If you are looking for something akin to a 2-step, have you considered looking into Self Organizing Maps. I think it is based on similar (but not the same) principle as 2-step.
Two-stage clustering in R If you are looking for something akin to a 2-step, have you considered looking into Self Organizing Maps. I think it is based on similar (but not the same) principle as 2-step.
Two-stage clustering in R If you are looking for something akin to a 2-step, have you considered looking into Self Organizing Maps. I think it is based on similar (but not the same) principle as 2-step.
35,835
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
You just described the difference. No one can know in advance outcome differences because it greatly depends on the nature of your data. Do you know the non-normal distribution you're working with? If so, you could simulate some results and see what the typical error rates for the different tests were and how they differed.
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
You just described the difference. No one can know in advance outcome differences because it greatly depends on the nature of your data. Do you know the non-normal distribution you're working with?
What method is preferred, a bootstrapping test or a nonparametric rank-based test? You just described the difference. No one can know in advance outcome differences because it greatly depends on the nature of your data. Do you know the non-normal distribution you're working with? If so, you could simulate some results and see what the typical error rates for the different tests were and how they differed.
What method is preferred, a bootstrapping test or a nonparametric rank-based test? You just described the difference. No one can know in advance outcome differences because it greatly depends on the nature of your data. Do you know the non-normal distribution you're working with?
35,836
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
This answer may be helpful, and/or it may be annoying. Your welcome and my apologies at the same time :) One thing to remember when using a normal distribution, is that it has a set of sufficient statistics, namely the mean and variance. What this indicates is that only the mean and variance matter in the inference. Any property of your sample besides the mean and variance will be thrown away when you use a normal distribution. The statement that the "population is not normally distributed" is a bit of a misnomer - the population is not "distributed" at all - there is one and only one population (imaginary data sets and alternate worlds aside). It sounds like what you are actually saying is that your knowledge of the population consists of something other than the average and variance So presumably, the only thing to do is to state what this extra/different knowledge is. Perhaps you know the skewness (or you know the skewness is important/relevant for the analysis, and not "noise"). I would suggest that you simply calculate the probability that your hypothesis is true, conditional on the information you have. This would include the data, and whatever "structure" you claim to know about the population that makes it non-normal (something other than the mean and variance of the population). So call your one sided test $T$, then you simply calculate: $$P(T|D,I)=\frac{P(T|I)P(D|T,I)}{P(D|I)}$$ $P(T|I)$ is the prior probability for the test being "true" or "successful" (what did know about the test prior to seeing the data?). $P(D|T,I)$ is the "model" or "likelihood" and is similar to a p-value (How likely is the data you observed, given the test is true?). And $P(D|I)$ is often called the "evidence" (how well do any of the hypothesis predict the observed data?) - this quantity does not need to be explicitly assigned, as it can be derived from the requirement that the probability must add to 1. The good thing about this method, is that probability theory will "construct the optimal test for you". You just need describe your prior information, and then simply do the mathematics. Now you may find that a bootstrap may be necessary in order to evaluate some mathematical formula - you may find that you should do the wilcoxon test - or probability theory will construct a test which is better than either of them (in terms of that type 1 and type 2 error you speak of).
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
This answer may be helpful, and/or it may be annoying. Your welcome and my apologies at the same time :) One thing to remember when using a normal distribution, is that it has a set of sufficient sta
What method is preferred, a bootstrapping test or a nonparametric rank-based test? This answer may be helpful, and/or it may be annoying. Your welcome and my apologies at the same time :) One thing to remember when using a normal distribution, is that it has a set of sufficient statistics, namely the mean and variance. What this indicates is that only the mean and variance matter in the inference. Any property of your sample besides the mean and variance will be thrown away when you use a normal distribution. The statement that the "population is not normally distributed" is a bit of a misnomer - the population is not "distributed" at all - there is one and only one population (imaginary data sets and alternate worlds aside). It sounds like what you are actually saying is that your knowledge of the population consists of something other than the average and variance So presumably, the only thing to do is to state what this extra/different knowledge is. Perhaps you know the skewness (or you know the skewness is important/relevant for the analysis, and not "noise"). I would suggest that you simply calculate the probability that your hypothesis is true, conditional on the information you have. This would include the data, and whatever "structure" you claim to know about the population that makes it non-normal (something other than the mean and variance of the population). So call your one sided test $T$, then you simply calculate: $$P(T|D,I)=\frac{P(T|I)P(D|T,I)}{P(D|I)}$$ $P(T|I)$ is the prior probability for the test being "true" or "successful" (what did know about the test prior to seeing the data?). $P(D|T,I)$ is the "model" or "likelihood" and is similar to a p-value (How likely is the data you observed, given the test is true?). And $P(D|I)$ is often called the "evidence" (how well do any of the hypothesis predict the observed data?) - this quantity does not need to be explicitly assigned, as it can be derived from the requirement that the probability must add to 1. The good thing about this method, is that probability theory will "construct the optimal test for you". You just need describe your prior information, and then simply do the mathematics. Now you may find that a bootstrap may be necessary in order to evaluate some mathematical formula - you may find that you should do the wilcoxon test - or probability theory will construct a test which is better than either of them (in terms of that type 1 and type 2 error you speak of).
What method is preferred, a bootstrapping test or a nonparametric rank-based test? This answer may be helpful, and/or it may be annoying. Your welcome and my apologies at the same time :) One thing to remember when using a normal distribution, is that it has a set of sufficient sta
35,837
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
The inferences generated by Wilcoxon vs bootstrapping cannot be compared as they pertain to different data. Wilcoxon is a rank test, thus generates inferences that pertain to ranks. Bootstrapping applies to the raw data, and thus generates inferences that pertain to the raw data. If you dislike bootstrapping but want inferences that pertain to the raw data, then you may want to try a permutation test (sometimes referred to as a randomization test).
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
The inferences generated by Wilcoxon vs bootstrapping cannot be compared as they pertain to different data. Wilcoxon is a rank test, thus generates inferences that pertain to ranks. Bootstrapping appl
What method is preferred, a bootstrapping test or a nonparametric rank-based test? The inferences generated by Wilcoxon vs bootstrapping cannot be compared as they pertain to different data. Wilcoxon is a rank test, thus generates inferences that pertain to ranks. Bootstrapping applies to the raw data, and thus generates inferences that pertain to the raw data. If you dislike bootstrapping but want inferences that pertain to the raw data, then you may want to try a permutation test (sometimes referred to as a randomization test).
What method is preferred, a bootstrapping test or a nonparametric rank-based test? The inferences generated by Wilcoxon vs bootstrapping cannot be compared as they pertain to different data. Wilcoxon is a rank test, thus generates inferences that pertain to ranks. Bootstrapping appl
35,838
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
I have two notes and one suggestion. The first note is that testing theory is typically done by setting an acceptable level where you would reject a true hypothesis (Type I error), then minimize the risk of accepting a false hypothesis (Type II error). There are two reasons for this, first is that all your tests use this assumption, and second of all in almost all cases you can't minimize both errors simultaneously. My second note is that the Wilcoxon Test hypothesis is actually $H_0: F_0 = F_1, H_1: F_0 \ne F_1$, where $F_i$ are CDFs, the relationship of this test to the mean is a property of the class of CDFs you are considering and the conditions you are considering them under. Under the data discussed I think bootstrapping would probably be appropriate if you think the sample is representative of the population of interest. Other possible choices include deriving an empirical likelihood ratio test, or resampling t-tests and checking robustness.
What method is preferred, a bootstrapping test or a nonparametric rank-based test?
I have two notes and one suggestion. The first note is that testing theory is typically done by setting an acceptable level where you would reject a true hypothesis (Type I error), then minimize the r
What method is preferred, a bootstrapping test or a nonparametric rank-based test? I have two notes and one suggestion. The first note is that testing theory is typically done by setting an acceptable level where you would reject a true hypothesis (Type I error), then minimize the risk of accepting a false hypothesis (Type II error). There are two reasons for this, first is that all your tests use this assumption, and second of all in almost all cases you can't minimize both errors simultaneously. My second note is that the Wilcoxon Test hypothesis is actually $H_0: F_0 = F_1, H_1: F_0 \ne F_1$, where $F_i$ are CDFs, the relationship of this test to the mean is a property of the class of CDFs you are considering and the conditions you are considering them under. Under the data discussed I think bootstrapping would probably be appropriate if you think the sample is representative of the population of interest. Other possible choices include deriving an empirical likelihood ratio test, or resampling t-tests and checking robustness.
What method is preferred, a bootstrapping test or a nonparametric rank-based test? I have two notes and one suggestion. The first note is that testing theory is typically done by setting an acceptable level where you would reject a true hypothesis (Type I error), then minimize the r
35,839
How to identify invalid online survey responses?
1) Flag all responses with duplicate IP addresses. Create a new variable for this purpose -- say FLAG1, which takes on values of 1 or 0. 2) Choose a threshold for an impossibly fast response time based on common sense (e.g., less than 1 second per question) and the aid of a histogram of response times -- flag people faster than this threshold again using another variable, FLAG2. 3) "Some respondents clearly randomly clicked through..." -- Apparently you can manually identify some respondents who cheated. Sort the data by response time and look at the fastest 5% or 10% (25 or 50 respondents for your data). Manually examine these respondents and flag any "clearly random" ones using FLAG3. 4) Apply Sheldon's suggestion by creating an inconsistency score -- 1 point for each inconsistency. You can do this by creating a new variable that identifies inconsistencies for each pair of redundant items, and then adding across these variables. You could keep this variable as is, as higher inconsistency scores obviously correspond to higher probabilities of cheating. But a reasonable approach is to flag people who fall above a cut-off chosen by inspecting a histogram -- call this FLAG4. Anyone who is flagged on each of FLAG1-4 is highly likely to have cheated, but you can set aside flagged people for a separate analysis based on any weighting scheme of FLAG1-4 you want. Given your tolerance for false positives, I would eliminate anyone flagged on FLAG1, FLAG2, or FLAG4.
How to identify invalid online survey responses?
1) Flag all responses with duplicate IP addresses. Create a new variable for this purpose -- say FLAG1, which takes on values of 1 or 0. 2) Choose a threshold for an impossibly fast response time base
How to identify invalid online survey responses? 1) Flag all responses with duplicate IP addresses. Create a new variable for this purpose -- say FLAG1, which takes on values of 1 or 0. 2) Choose a threshold for an impossibly fast response time based on common sense (e.g., less than 1 second per question) and the aid of a histogram of response times -- flag people faster than this threshold again using another variable, FLAG2. 3) "Some respondents clearly randomly clicked through..." -- Apparently you can manually identify some respondents who cheated. Sort the data by response time and look at the fastest 5% or 10% (25 or 50 respondents for your data). Manually examine these respondents and flag any "clearly random" ones using FLAG3. 4) Apply Sheldon's suggestion by creating an inconsistency score -- 1 point for each inconsistency. You can do this by creating a new variable that identifies inconsistencies for each pair of redundant items, and then adding across these variables. You could keep this variable as is, as higher inconsistency scores obviously correspond to higher probabilities of cheating. But a reasonable approach is to flag people who fall above a cut-off chosen by inspecting a histogram -- call this FLAG4. Anyone who is flagged on each of FLAG1-4 is highly likely to have cheated, but you can set aside flagged people for a separate analysis based on any weighting scheme of FLAG1-4 you want. Given your tolerance for false positives, I would eliminate anyone flagged on FLAG1, FLAG2, or FLAG4.
How to identify invalid online survey responses? 1) Flag all responses with duplicate IP addresses. Create a new variable for this purpose -- say FLAG1, which takes on values of 1 or 0. 2) Choose a threshold for an impossibly fast response time base
35,840
Efficient way to populate matrix in R? [closed]
Generally tables are handled as matrices or arrays and matrix indexing allows two column arguments as (i,j)-indexing (and if the object being indexed has higher dimensions then matrices with more columns are used) so: > inp.mtx <- as.matrix(inp) > mat[inp.mtx[,1:2] ]<- inp.mtx[,3] > mat [,1] [,2] [,3] [1,] NA 0.05 0.040 [2,] NA NA 0.001 [3,] NA NA NA
Efficient way to populate matrix in R? [closed]
Generally tables are handled as matrices or arrays and matrix indexing allows two column arguments as (i,j)-indexing (and if the object being indexed has higher dimensions then matrices with more colu
Efficient way to populate matrix in R? [closed] Generally tables are handled as matrices or arrays and matrix indexing allows two column arguments as (i,j)-indexing (and if the object being indexed has higher dimensions then matrices with more columns are used) so: > inp.mtx <- as.matrix(inp) > mat[inp.mtx[,1:2] ]<- inp.mtx[,3] > mat [,1] [,2] [,3] [1,] NA 0.05 0.040 [2,] NA NA 0.001 [3,] NA NA NA
Efficient way to populate matrix in R? [closed] Generally tables are handled as matrices or arrays and matrix indexing allows two column arguments as (i,j)-indexing (and if the object being indexed has higher dimensions then matrices with more colu
35,841
Efficient way to populate matrix in R? [closed]
mat <- matrix(c(1, 1, 2, 2, 3, 3, 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat mat1 <- matrix(c(rep(NA,6), 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat1 mat2 <- matrix(NA, nrow = 3, ncol = 3) mat2 mat2[,3] <- c(0.05, 0.04, 0.001) mat2 df <- data.frame(x=c(1, 1, 2), y=c(2, 3, 3), z=c(0.05, 0.04, 0.001)) df mat3 <- matrix(NA, nrow = 3, ncol =3) mat3 mat3[,3] <- df$z mat3 mat4 <- matrix(NA, nrow = 3, ncol =3) mat4 mat4[,3] <- unlist(df[3]) mat4
Efficient way to populate matrix in R? [closed]
mat <- matrix(c(1, 1, 2, 2, 3, 3, 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat mat1 <- matrix(c(rep(NA,6), 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat1 mat2 <- matrix(NA, nrow = 3, ncol = 3) mat
Efficient way to populate matrix in R? [closed] mat <- matrix(c(1, 1, 2, 2, 3, 3, 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat mat1 <- matrix(c(rep(NA,6), 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat1 mat2 <- matrix(NA, nrow = 3, ncol = 3) mat2 mat2[,3] <- c(0.05, 0.04, 0.001) mat2 df <- data.frame(x=c(1, 1, 2), y=c(2, 3, 3), z=c(0.05, 0.04, 0.001)) df mat3 <- matrix(NA, nrow = 3, ncol =3) mat3 mat3[,3] <- df$z mat3 mat4 <- matrix(NA, nrow = 3, ncol =3) mat4 mat4[,3] <- unlist(df[3]) mat4
Efficient way to populate matrix in R? [closed] mat <- matrix(c(1, 1, 2, 2, 3, 3, 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat mat1 <- matrix(c(rep(NA,6), 0.05, 0.04, 0.001), nrow = 3, ncol = 3) mat1 mat2 <- matrix(NA, nrow = 3, ncol = 3) mat
35,842
Proof that CRF models and logistic models are convex functions
One trick is to rewrite objective functions in terms of functions which are known to be convex. Objective function of ML trained log-linear model is a sum of negative log-likelihoods, so it's sufficient to show that negative log-likelihood for each datapoint is convex. Considering datapoint fixed, we can write its negative log-likelihood term as $$-\langle \theta,\phi(y)\rangle+\log \sum_y \exp(\langle \theta,\phi(y)\rangle)$$ First term is linear so it's sufficient to show that second term, known as the log-normalizer, is convex. Write it as $f(\mathbf{g}(\mathbf{\theta}))$ where $f(\mathbf{y})=\log \sum_y \exp y$ and $g_y(\theta)=\langle \mathbf{\theta},\phi(y)\rangle$. Here $g$ is a linear function, and $f$ is a known convex function called log-sum-exp. See page 72 of Boyd's Convex Optimization book. Composition of a convex function and a linear function is convex, see section 3.2.2 Another approach is to use the fact that log-normalizer is the cumulant generating function. For instance see example 3.41 in Boyd's book, or Proposition 3.1 in Wainwright's "Graphical models, exponential families, and variational inference" manuscript. This means that second derivative is the covariance matrix of sufficient statistic $\phi$ which by definition is positive semi-definite, which means that Hessian of the log-normalizer is positive semi-definite. Positive semi-definite Hessian guarantees the function is convex, see section 3.1.4 of Boyd's book. Technically, the log-normalizer is not the traditional cumulant generating function. CGF is $g(\phi)=\log(Z(\theta+\phi))-\log(Z(\theta))$. However, derivative of log-normalizer evaluated at $\theta$ is the same as the derivative of the CGF evaluated at $\mathbf{0}$, so it produces cumulants just like CGF. I couldn't find full proof of equivalence, usually people omit it because it's just several steps of uninspiring algebra. A very terse derivation for continuous output space is on page 5 of Xinhua Zhang's "Graphical Models" thesis. I believe a saw full derivation in Lawrence D. Brown's "Fundamentals of statistical exponential families"
Proof that CRF models and logistic models are convex functions
One trick is to rewrite objective functions in terms of functions which are known to be convex. Objective function of ML trained log-linear model is a sum of negative log-likelihoods, so it's sufficie
Proof that CRF models and logistic models are convex functions One trick is to rewrite objective functions in terms of functions which are known to be convex. Objective function of ML trained log-linear model is a sum of negative log-likelihoods, so it's sufficient to show that negative log-likelihood for each datapoint is convex. Considering datapoint fixed, we can write its negative log-likelihood term as $$-\langle \theta,\phi(y)\rangle+\log \sum_y \exp(\langle \theta,\phi(y)\rangle)$$ First term is linear so it's sufficient to show that second term, known as the log-normalizer, is convex. Write it as $f(\mathbf{g}(\mathbf{\theta}))$ where $f(\mathbf{y})=\log \sum_y \exp y$ and $g_y(\theta)=\langle \mathbf{\theta},\phi(y)\rangle$. Here $g$ is a linear function, and $f$ is a known convex function called log-sum-exp. See page 72 of Boyd's Convex Optimization book. Composition of a convex function and a linear function is convex, see section 3.2.2 Another approach is to use the fact that log-normalizer is the cumulant generating function. For instance see example 3.41 in Boyd's book, or Proposition 3.1 in Wainwright's "Graphical models, exponential families, and variational inference" manuscript. This means that second derivative is the covariance matrix of sufficient statistic $\phi$ which by definition is positive semi-definite, which means that Hessian of the log-normalizer is positive semi-definite. Positive semi-definite Hessian guarantees the function is convex, see section 3.1.4 of Boyd's book. Technically, the log-normalizer is not the traditional cumulant generating function. CGF is $g(\phi)=\log(Z(\theta+\phi))-\log(Z(\theta))$. However, derivative of log-normalizer evaluated at $\theta$ is the same as the derivative of the CGF evaluated at $\mathbf{0}$, so it produces cumulants just like CGF. I couldn't find full proof of equivalence, usually people omit it because it's just several steps of uninspiring algebra. A very terse derivation for continuous output space is on page 5 of Xinhua Zhang's "Graphical Models" thesis. I believe a saw full derivation in Lawrence D. Brown's "Fundamentals of statistical exponential families"
Proof that CRF models and logistic models are convex functions One trick is to rewrite objective functions in terms of functions which are known to be convex. Objective function of ML trained log-linear model is a sum of negative log-likelihoods, so it's sufficie
35,843
Proof that CRF models and logistic models are convex functions
First, convexity is not only a feature of a function, but rather, a function and the domain over which it is defined. To address your question more directly, another trick (rather another formulation) is to compute the Hessian matrix of your likelihood function. A per wiki a continuous, twice differentiable function of several variables is convex on a convex set if and only if its Hessian matrix is positive semidefinite on the interior of the convex set. Since the Hessian is real symmetric, it is sufficient to have diagonal dominance, for it to be PSD (this is obvious to show for the logistic model).
Proof that CRF models and logistic models are convex functions
First, convexity is not only a feature of a function, but rather, a function and the domain over which it is defined. To address your question more directly, another trick (rather another formulation)
Proof that CRF models and logistic models are convex functions First, convexity is not only a feature of a function, but rather, a function and the domain over which it is defined. To address your question more directly, another trick (rather another formulation) is to compute the Hessian matrix of your likelihood function. A per wiki a continuous, twice differentiable function of several variables is convex on a convex set if and only if its Hessian matrix is positive semidefinite on the interior of the convex set. Since the Hessian is real symmetric, it is sufficient to have diagonal dominance, for it to be PSD (this is obvious to show for the logistic model).
Proof that CRF models and logistic models are convex functions First, convexity is not only a feature of a function, but rather, a function and the domain over which it is defined. To address your question more directly, another trick (rather another formulation)
35,844
How should one define the sample variance for scalar input?
Scalars can't 'have' a population variance although they can be single samples from population that has a (population) variance. If you want to estimate that then you need at least: more than one data point in the sample, another sample from the same distribution, or some prior information about the population variance by way of a model. btw R has returned missing (NA) not NaN is.nan(var(rnorm(1,1))) [1] FALSE
How should one define the sample variance for scalar input?
Scalars can't 'have' a population variance although they can be single samples from population that has a (population) variance. If you want to estimate that then you need at least: more than one dat
How should one define the sample variance for scalar input? Scalars can't 'have' a population variance although they can be single samples from population that has a (population) variance. If you want to estimate that then you need at least: more than one data point in the sample, another sample from the same distribution, or some prior information about the population variance by way of a model. btw R has returned missing (NA) not NaN is.nan(var(rnorm(1,1))) [1] FALSE
How should one define the sample variance for scalar input? Scalars can't 'have' a population variance although they can be single samples from population that has a (population) variance. If you want to estimate that then you need at least: more than one dat
35,845
How should one define the sample variance for scalar input?
I am sure people in this forum will have better answers, here is what I think: I think R's answer is logical. The random variable has a population variance, but it turns out that with 1 sample you don't have enough degrees of freedom to estimate sample variance i-e- you are trying to extract information that is NOT there. Regarding Matlab's answer, I don't know how to justify 0, except that it is from the numerator. Consequences can be bizarre. But I can think of anything else related to the estimation.
How should one define the sample variance for scalar input?
I am sure people in this forum will have better answers, here is what I think: I think R's answer is logical. The random variable has a population variance, but it turns out that with 1 sample you don
How should one define the sample variance for scalar input? I am sure people in this forum will have better answers, here is what I think: I think R's answer is logical. The random variable has a population variance, but it turns out that with 1 sample you don't have enough degrees of freedom to estimate sample variance i-e- you are trying to extract information that is NOT there. Regarding Matlab's answer, I don't know how to justify 0, except that it is from the numerator. Consequences can be bizarre. But I can think of anything else related to the estimation.
How should one define the sample variance for scalar input? I am sure people in this forum will have better answers, here is what I think: I think R's answer is logical. The random variable has a population variance, but it turns out that with 1 sample you don
35,846
How should one define the sample variance for scalar input?
I think Matlab is using the following logic for a scalar (analogous to how we define population variance) to avoid having to deal with NA and NAN. $Var(x) = \frac{(x - \bar{x})^2}{1} = 0$ The above follows as for a scalar: $\bar{x} = x$. Their definition is probably a programming convention that may perhaps make some aspect of coding easier.
How should one define the sample variance for scalar input?
I think Matlab is using the following logic for a scalar (analogous to how we define population variance) to avoid having to deal with NA and NAN. $Var(x) = \frac{(x - \bar{x})^2}{1} = 0$ The above fo
How should one define the sample variance for scalar input? I think Matlab is using the following logic for a scalar (analogous to how we define population variance) to avoid having to deal with NA and NAN. $Var(x) = \frac{(x - \bar{x})^2}{1} = 0$ The above follows as for a scalar: $\bar{x} = x$. Their definition is probably a programming convention that may perhaps make some aspect of coding easier.
How should one define the sample variance for scalar input? I think Matlab is using the following logic for a scalar (analogous to how we define population variance) to avoid having to deal with NA and NAN. $Var(x) = \frac{(x - \bar{x})^2}{1} = 0$ The above fo
35,847
Recommendations for visualization type when data has an extremely wide variance
A standard approach to dealing with data that has a wide variance is to use a log scale (or some other kind of scaling approach) regardless of the visualization itself. This could be applied in any graphical package (including a JS library like Protovis). Another strategy is to use bands, and fold the data over several times (as in this example), although personally I find this approach to be harder to read. This ends up looking like:
Recommendations for visualization type when data has an extremely wide variance
A standard approach to dealing with data that has a wide variance is to use a log scale (or some other kind of scaling approach) regardless of the visualization itself. This could be applied in any g
Recommendations for visualization type when data has an extremely wide variance A standard approach to dealing with data that has a wide variance is to use a log scale (or some other kind of scaling approach) regardless of the visualization itself. This could be applied in any graphical package (including a JS library like Protovis). Another strategy is to use bands, and fold the data over several times (as in this example), although personally I find this approach to be harder to read. This ends up looking like:
Recommendations for visualization type when data has an extremely wide variance A standard approach to dealing with data that has a wide variance is to use a log scale (or some other kind of scaling approach) regardless of the visualization itself. This could be applied in any g
35,848
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
What about monitoring network congestion. An underlying stochastic process is assumed to be driving the congestion, and the process has reached an equilibrium state and is stationary. That is, process characteristics such as the mean level does not depend on time. You can then use this the stochastic process to give you an idea of when you check the network for possible congestion. Some recent papers: N. Dueld, C. Lund, and M. Thorup. Optimal combination of sampled network measurements. Proceedings of IMC '05, Internet Measurement Conference, 91-104, 2005. B. M. Parker, S. G. Gilmour, and J. Schormans. Measurement of packet loss probability by optimal design of packet probing experiments. IET Communications, 3:979-991, 2009.
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
What about monitoring network congestion. An underlying stochastic process is assumed to be driving the congestion, and the process has reached an equilibrium state and is stationary. That is, process
What are the examples for stochastic processes in Electrical Engineering and Computer Science? What about monitoring network congestion. An underlying stochastic process is assumed to be driving the congestion, and the process has reached an equilibrium state and is stationary. That is, process characteristics such as the mean level does not depend on time. You can then use this the stochastic process to give you an idea of when you check the network for possible congestion. Some recent papers: N. Dueld, C. Lund, and M. Thorup. Optimal combination of sampled network measurements. Proceedings of IMC '05, Internet Measurement Conference, 91-104, 2005. B. M. Parker, S. G. Gilmour, and J. Schormans. Measurement of packet loss probability by optimal design of packet probing experiments. IET Communications, 3:979-991, 2009.
What are the examples for stochastic processes in Electrical Engineering and Computer Science? What about monitoring network congestion. An underlying stochastic process is assumed to be driving the congestion, and the process has reached an equilibrium state and is stationary. That is, process
35,849
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
Google's Pagerank algorithm is a stochastic approximation (through Markov's stationary state) of the proportion of visits received asymptotically by website $x_i$.
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
Google's Pagerank algorithm is a stochastic approximation (through Markov's stationary state) of the proportion of visits received asymptotically by website $x_i$.
What are the examples for stochastic processes in Electrical Engineering and Computer Science? Google's Pagerank algorithm is a stochastic approximation (through Markov's stationary state) of the proportion of visits received asymptotically by website $x_i$.
What are the examples for stochastic processes in Electrical Engineering and Computer Science? Google's Pagerank algorithm is a stochastic approximation (through Markov's stationary state) of the proportion of visits received asymptotically by website $x_i$.
35,850
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
As you have alluded to, communications engineering (and signal processing in general) is filled with stochastic processes. See, for example: Chapter 9 and later of Communications Systems by Carlson and Crilly Chapter 13 of A Course in Digtial Signal Processing by Porat This is only two textbook examples. You will find many (many) more. It's fair to say that your mobile phone, the internet and etcetera all rely extremely heavily on our understanding of stochastic processes.
What are the examples for stochastic processes in Electrical Engineering and Computer Science?
As you have alluded to, communications engineering (and signal processing in general) is filled with stochastic processes. See, for example: Chapter 9 and later of Communications Systems by Carlson a
What are the examples for stochastic processes in Electrical Engineering and Computer Science? As you have alluded to, communications engineering (and signal processing in general) is filled with stochastic processes. See, for example: Chapter 9 and later of Communications Systems by Carlson and Crilly Chapter 13 of A Course in Digtial Signal Processing by Porat This is only two textbook examples. You will find many (many) more. It's fair to say that your mobile phone, the internet and etcetera all rely extremely heavily on our understanding of stochastic processes.
What are the examples for stochastic processes in Electrical Engineering and Computer Science? As you have alluded to, communications engineering (and signal processing in general) is filled with stochastic processes. See, for example: Chapter 9 and later of Communications Systems by Carlson a
35,851
The expected value of random variable on tosses of a coin
If n is large enough, your expected value should approach the mean of the distribution. Yes that's correct. So probability that value is greater than expected value should be 0.5. This would only be correct if the distribution is symmetric - which in your game isn't the case. You can see this easily if you think about what the median value of your winnings should be after $n$ throws. You can think of your problem as a random walk. A basic one-dimensional random walk is a walk on the integer real line, where at each point we move $\pm 1$ with probability $p$. This is exactly what you have if we ignore the doubling/halving of money and set $p=0.5$. All we have to do is remap your coordinate system to this example. Let $x$ be your initial starting pot. Then we remap in the following way: x*2^{-2} = -2 x*2^{-1} = -1 x = 0 x*2 = 1 i.e. $2^k x=k$. Let $S_n$ denote how much money we have made from the game after $n$ turns, then \begin{equation} Pr(S_n = 2^k x) = 2^{-n} \binom{n}{(n+k)/2} \end{equation} for $n \ge (n+k)/2 \ge 0$. When $(n+k)$ isn't a multiple of 2, then $Pr(S_n)=0$. To understand this, assume that we begin with £10. After $n=1$ turns, the only possible values are £5 or £20, i.e. $k=-1$ or $k=1$. The above result is a standard result from Random walks. Google random walks for more info. Also from random walk theory, we can calculate the median return to be $x$, which is not the same as the expected value. Note: I have assumed that you can always half your money. For example, 1pence, 0.5pence, 0.25pence are all allowed. If you remove this assumption, then you have a random walk with an absorbing wall. For completeness Here's a quick simulation in R of your process: #Simulate 10 throws with a starting amount of x=money=10 #n=10 simulate = function(){ #money won/lost in a single game money = 10 for(i in 1:10){ if(runif(1) < 0.5) money = money/2 else money = 2*money } return(money) } #The Money vector keeps track of all the games #N is the number of games we play N = 1000 Money = numeric(N) for(i in 1:N) Money[i]= simulate() mean(Money);median(Money) #Probabilities #Simulated table(Money)/1000 #Exact 2^{-10}*choose(10,10/2) #Plot the simulations plot(Money)
The expected value of random variable on tosses of a coin
If n is large enough, your expected value should approach the mean of the distribution. Yes that's correct. So probability that value is greater than expected value should be 0.5. This would
The expected value of random variable on tosses of a coin If n is large enough, your expected value should approach the mean of the distribution. Yes that's correct. So probability that value is greater than expected value should be 0.5. This would only be correct if the distribution is symmetric - which in your game isn't the case. You can see this easily if you think about what the median value of your winnings should be after $n$ throws. You can think of your problem as a random walk. A basic one-dimensional random walk is a walk on the integer real line, where at each point we move $\pm 1$ with probability $p$. This is exactly what you have if we ignore the doubling/halving of money and set $p=0.5$. All we have to do is remap your coordinate system to this example. Let $x$ be your initial starting pot. Then we remap in the following way: x*2^{-2} = -2 x*2^{-1} = -1 x = 0 x*2 = 1 i.e. $2^k x=k$. Let $S_n$ denote how much money we have made from the game after $n$ turns, then \begin{equation} Pr(S_n = 2^k x) = 2^{-n} \binom{n}{(n+k)/2} \end{equation} for $n \ge (n+k)/2 \ge 0$. When $(n+k)$ isn't a multiple of 2, then $Pr(S_n)=0$. To understand this, assume that we begin with £10. After $n=1$ turns, the only possible values are £5 or £20, i.e. $k=-1$ or $k=1$. The above result is a standard result from Random walks. Google random walks for more info. Also from random walk theory, we can calculate the median return to be $x$, which is not the same as the expected value. Note: I have assumed that you can always half your money. For example, 1pence, 0.5pence, 0.25pence are all allowed. If you remove this assumption, then you have a random walk with an absorbing wall. For completeness Here's a quick simulation in R of your process: #Simulate 10 throws with a starting amount of x=money=10 #n=10 simulate = function(){ #money won/lost in a single game money = 10 for(i in 1:10){ if(runif(1) < 0.5) money = money/2 else money = 2*money } return(money) } #The Money vector keeps track of all the games #N is the number of games we play N = 1000 Money = numeric(N) for(i in 1:N) Money[i]= simulate() mean(Money);median(Money) #Probabilities #Simulated table(Money)/1000 #Exact 2^{-10}*choose(10,10/2) #Plot the simulations plot(Money)
The expected value of random variable on tosses of a coin If n is large enough, your expected value should approach the mean of the distribution. Yes that's correct. So probability that value is greater than expected value should be 0.5. This would
35,852
The expected value of random variable on tosses of a coin
Let $S_k$ be the wealth after $k$ plays of this game, where we assume $S_0 = 1.$ The temptation here is to take $X_k = \log{S_k}$, and study $X_k$ as a symmetric random walk, with innovations of size $\pm \log{2}$. This, as it turns out, will be fine for the second question, but not the first. A bit of work will show that, asymptotically we have $X_k \sim \mathcal{N}(0,k(\log{2})^2)$. From this you cannot conclude that $S_k$ is asymptotically log normally distributed with $\mu = 0, \sigma = \log{2}\sqrt{k}.$ The log operation does not commute with the limit. If it did, you would get the expected value of $S_k$ as $\exp{(k \log{2}\log{2}/2)}$, which is nearly correct, but not quite. However, this method is just fine for finding quantiles of $S_k$, and other questions of probability, like question (2). We have $S_k \ge (\frac{5}{4})^k \Leftrightarrow X_k \ge k \log{(5/4)} \Leftrightarrow X_k / \sqrt{k}\log{2} \ge \sqrt{k}\log{(5/4})/\log{2}.$ The quantity on the lefthand side of the last inequality is, asymptotically, a standard normal, and so the probability that $S_k$ exceeds its mean approaches $1 - \Phi{(\sqrt{k}\log{(5/4)}/\log{2})},$ where $\Phi$ is the CDF of the standard normal. This approaches zero fairly quickly. Matlab code to check this: top_k = 512; nsamps = 8192; innovs = log(2) * cumsum(sign(randn(top_k,nsamps)),1); s_k = exp(innovs); k_vals = (1:top_k)'; mean_v = (5/4) .^ k_vals; exceed = bsxfun(@ge,s_k,mean_v); prob_g = mean(double(exceed),2); %theoretical value %(can you believe matlab doesn't come with normal cdf function!?) nrmcdf = @(x)((1 + erf(x / sqrt(2)))/2); p_thry = 1 - nrmcdf(sqrt(k_vals) * log(5/4) / log(2)); loglog(k_vals,prob_g,'b-',k_vals,p_thry,'r-'); legend('empirical probability','theoretical probability'); the graph produced:
The expected value of random variable on tosses of a coin
Let $S_k$ be the wealth after $k$ plays of this game, where we assume $S_0 = 1.$ The temptation here is to take $X_k = \log{S_k}$, and study $X_k$ as a symmetric random walk, with innovations of size
The expected value of random variable on tosses of a coin Let $S_k$ be the wealth after $k$ plays of this game, where we assume $S_0 = 1.$ The temptation here is to take $X_k = \log{S_k}$, and study $X_k$ as a symmetric random walk, with innovations of size $\pm \log{2}$. This, as it turns out, will be fine for the second question, but not the first. A bit of work will show that, asymptotically we have $X_k \sim \mathcal{N}(0,k(\log{2})^2)$. From this you cannot conclude that $S_k$ is asymptotically log normally distributed with $\mu = 0, \sigma = \log{2}\sqrt{k}.$ The log operation does not commute with the limit. If it did, you would get the expected value of $S_k$ as $\exp{(k \log{2}\log{2}/2)}$, which is nearly correct, but not quite. However, this method is just fine for finding quantiles of $S_k$, and other questions of probability, like question (2). We have $S_k \ge (\frac{5}{4})^k \Leftrightarrow X_k \ge k \log{(5/4)} \Leftrightarrow X_k / \sqrt{k}\log{2} \ge \sqrt{k}\log{(5/4})/\log{2}.$ The quantity on the lefthand side of the last inequality is, asymptotically, a standard normal, and so the probability that $S_k$ exceeds its mean approaches $1 - \Phi{(\sqrt{k}\log{(5/4)}/\log{2})},$ where $\Phi$ is the CDF of the standard normal. This approaches zero fairly quickly. Matlab code to check this: top_k = 512; nsamps = 8192; innovs = log(2) * cumsum(sign(randn(top_k,nsamps)),1); s_k = exp(innovs); k_vals = (1:top_k)'; mean_v = (5/4) .^ k_vals; exceed = bsxfun(@ge,s_k,mean_v); prob_g = mean(double(exceed),2); %theoretical value %(can you believe matlab doesn't come with normal cdf function!?) nrmcdf = @(x)((1 + erf(x / sqrt(2)))/2); p_thry = 1 - nrmcdf(sqrt(k_vals) * log(5/4) / log(2)); loglog(k_vals,prob_g,'b-',k_vals,p_thry,'r-'); legend('empirical probability','theoretical probability'); the graph produced:
The expected value of random variable on tosses of a coin Let $S_k$ be the wealth after $k$ plays of this game, where we assume $S_0 = 1.$ The temptation here is to take $X_k = \log{S_k}$, and study $X_k$ as a symmetric random walk, with innovations of size
35,853
The expected value of random variable on tosses of a coin
You're right about the expectation. You actually also have the right answer to the probability of getting more than your original stake back, although not the right proof. Consider, instead of the raw amount of money you have, its base-2 logarithm. This turns out to be the number of times you've doubled your money, minus the number of times you've halved it. This is the sum $S_n$ of $n$ independent random variables, each equal to $+1$ or $-1$ with probability $1/2$. The probability that you want is the probability that this is positive. If $n$ is odd, then by symmetry it's exactly $1/2$; if $n$ is even (call it $2k$) then it's $1/2$ minus half the probability that $S_n = 0$. But $P(S_{2k} = 0) = {2k \choose k}/2^{2k}$, which approaches $0$ as $k \to \infty$.
The expected value of random variable on tosses of a coin
You're right about the expectation. You actually also have the right answer to the probability of getting more than your original stake back, although not the right proof. Consider, instead of the raw
The expected value of random variable on tosses of a coin You're right about the expectation. You actually also have the right answer to the probability of getting more than your original stake back, although not the right proof. Consider, instead of the raw amount of money you have, its base-2 logarithm. This turns out to be the number of times you've doubled your money, minus the number of times you've halved it. This is the sum $S_n$ of $n$ independent random variables, each equal to $+1$ or $-1$ with probability $1/2$. The probability that you want is the probability that this is positive. If $n$ is odd, then by symmetry it's exactly $1/2$; if $n$ is even (call it $2k$) then it's $1/2$ minus half the probability that $S_n = 0$. But $P(S_{2k} = 0) = {2k \choose k}/2^{2k}$, which approaches $0$ as $k \to \infty$.
The expected value of random variable on tosses of a coin You're right about the expectation. You actually also have the right answer to the probability of getting more than your original stake back, although not the right proof. Consider, instead of the raw
35,854
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
A "right" answer cannot depend on an arbitrary ordering of some method you are using. You need to consider all possible orderings (or some representative sample) and estimate your parameters for every case. This will give you distributions for the parameters you are trying to estimate. Estimate the "true" parameter values from these distributions (this will also give you an estimate for your estimator error). Alternatively use a method that doesn't introduce an ordering.
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
A "right" answer cannot depend on an arbitrary ordering of some method you are using. You need to consider all possible orderings (or some representative sample) and estimate your parameters for every
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? A "right" answer cannot depend on an arbitrary ordering of some method you are using. You need to consider all possible orderings (or some representative sample) and estimate your parameters for every case. This will give you distributions for the parameters you are trying to estimate. Estimate the "true" parameter values from these distributions (this will also give you an estimate for your estimator error). Alternatively use a method that doesn't introduce an ordering.
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? A "right" answer cannot depend on an arbitrary ordering of some method you are using. You need to consider all possible orderings (or some representative sample) and estimate your parameters for every
35,855
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
What you're discovering is a degree of instability in either the algorithm or the data itself. The approach termed 'consensus' or 'ensemble' clustering is a way of dealing with the problem. The problem there is: given a collection of clusterings, find a "consensus" clustering that is in some sense the "average" of the clusterings. There's a fair bit of work on this topic, and a good place to start is the clustering ensembles paper by Strehl and Ghosh.
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
What you're discovering is a degree of instability in either the algorithm or the data itself. The approach termed 'consensus' or 'ensemble' clustering is a way of dealing with the problem. The proble
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? What you're discovering is a degree of instability in either the algorithm or the data itself. The approach termed 'consensus' or 'ensemble' clustering is a way of dealing with the problem. The problem there is: given a collection of clusterings, find a "consensus" clustering that is in some sense the "average" of the clusterings. There's a fair bit of work on this topic, and a good place to start is the clustering ensembles paper by Strehl and Ghosh.
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? What you're discovering is a degree of instability in either the algorithm or the data itself. The approach termed 'consensus' or 'ensemble' clustering is a way of dealing with the problem. The proble
35,856
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
Which flat-clustering algorithm are you using? It might also be the case that the different results are because maybe it's not your data but your algorithm itself is non-deterministic (e.g., using K-means with random initialization, or using a model-based clustering with EM or MCMC for inference with random initialization)?
How to deal with the effect of the order of observations in a non hierarchical cluster analysis?
Which flat-clustering algorithm are you using? It might also be the case that the different results are because maybe it's not your data but your algorithm itself is non-deterministic (e.g., using K-m
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? Which flat-clustering algorithm are you using? It might also be the case that the different results are because maybe it's not your data but your algorithm itself is non-deterministic (e.g., using K-means with random initialization, or using a model-based clustering with EM or MCMC for inference with random initialization)?
How to deal with the effect of the order of observations in a non hierarchical cluster analysis? Which flat-clustering algorithm are you using? It might also be the case that the different results are because maybe it's not your data but your algorithm itself is non-deterministic (e.g., using K-m
35,857
Why do we need normality test if we already have CLT?
1. The CLT certainly doesn't solve all problems. For example: (a) There are distributions for which the CLT doesn't hold. Here's an example: This density is a mixture of a symmetric 4-parameter beta and a $t_2$. There's a normal distribution that looks visually pretty close to it (e.g. in the way that a Kolmogorov-Smirnov statistic measures distance, largest absolute difference in cdf), but this distribution does not have a finite variance, and the ordinary central limit theorem fails to hold for this seemingly unremarkable-looking case. (While it is close in the stated sense to a normal distribution, I did not spend time getting it as close as possible; there are examples that look even closer to a normal, indeed it can be as close as you like.) (b) There are distributions for which the CLT does hold, but for which even averages of a million observations are not really close to a normal. There's an example discussed here, a lognormal distribution with sufficiently large shape parameter ($\sigma$). That number ($n= 10^6$) can be pushed up, beyond any fixed value. That is, there's really no "large enough" that's sufficient to make the distribution of standardized sums or means 'close to normal' for every distribution among the set of distributions for which the CLT does hold. (c) There are tests that assume normality but which do not involve means. In those cases the CLT isn't necessarily of any direct relevance. 2. None of this is an argument for using formal tests of assumptions. That doesn't really answer the right question. There's a nice discussion of that point (in relation to testing normality) in Harvey Motulsky's answer here. Much more could be said about testing but that's perhaps not the direct issue here, so I won't labor the point further.
Why do we need normality test if we already have CLT?
1. The CLT certainly doesn't solve all problems. For example: (a) There are distributions for which the CLT doesn't hold. Here's an example: This density is a mixture of a symmetric 4-parameter beta
Why do we need normality test if we already have CLT? 1. The CLT certainly doesn't solve all problems. For example: (a) There are distributions for which the CLT doesn't hold. Here's an example: This density is a mixture of a symmetric 4-parameter beta and a $t_2$. There's a normal distribution that looks visually pretty close to it (e.g. in the way that a Kolmogorov-Smirnov statistic measures distance, largest absolute difference in cdf), but this distribution does not have a finite variance, and the ordinary central limit theorem fails to hold for this seemingly unremarkable-looking case. (While it is close in the stated sense to a normal distribution, I did not spend time getting it as close as possible; there are examples that look even closer to a normal, indeed it can be as close as you like.) (b) There are distributions for which the CLT does hold, but for which even averages of a million observations are not really close to a normal. There's an example discussed here, a lognormal distribution with sufficiently large shape parameter ($\sigma$). That number ($n= 10^6$) can be pushed up, beyond any fixed value. That is, there's really no "large enough" that's sufficient to make the distribution of standardized sums or means 'close to normal' for every distribution among the set of distributions for which the CLT does hold. (c) There are tests that assume normality but which do not involve means. In those cases the CLT isn't necessarily of any direct relevance. 2. None of this is an argument for using formal tests of assumptions. That doesn't really answer the right question. There's a nice discussion of that point (in relation to testing normality) in Harvey Motulsky's answer here. Much more could be said about testing but that's perhaps not the direct issue here, so I won't labor the point further.
Why do we need normality test if we already have CLT? 1. The CLT certainly doesn't solve all problems. For example: (a) There are distributions for which the CLT doesn't hold. Here's an example: This density is a mixture of a symmetric 4-parameter beta
35,858
Median of the squared difference from the median of a Cauchy random variable
Suppose $F$ is the distribution function of a random variable $X$ with median $m.$ By definition, a median is any number for which $F(m)\ge 1/2$ and $F(x) \le 1/2$ for all $x \lt m.$ For any non-negative number $y,$ let $$G(y) = F(m+y) - F(m-y) = \Pr(X \in (m-y, m+y]).$$ Clearly (by the probability axioms) $G(0)=0$ and $G$ is a nondecreasing function rising to a limiting value of $1.$ Consequently there is at least one $y$ for which $G(y) \ge 1/2$ and $G(x)\le 1/2$ for all $x \lt y.$ $y^2$ is a median of $(X-m)^2.$ Proof: $$\Pr((X-m)^2 \le y^2) = \Pr(|X-m| \le y) = \Pr(X \in [m-y, m+y] = G(y) \ge 1/2.$$ At the same time, if $0 \le y-\epsilon \lt y,$ $$\begin{aligned} \Pr((X-m)^2 \le (y-\epsilon)^2) &= \Pr(X \in [m-y+\epsilon, m+y-\epsilon]) \\ &\le \Pr(X \in (m-y + \epsilon/2, m+y-\epsilon/2])\\ &= G(y-\epsilon/2) \lt 1/2. \end{aligned}$$ Thus the definition of median is satisfied, QED. Application: Let $X$ have a Cauchy distribution. This means it has a density function $$f_X(x) = \frac{1}{\pi}\frac{1}{1+x^2}.$$ Thus $$\frac{1}{2} = G(y) = \frac{1}{\pi}\int_{-y}^y \frac{\mathrm{d}x}{1+x^2} = \frac{2}{\pi}\arctan(y)$$ has unique solution $y = 1.$ Consequently the median squared deviation from the median is $1^2 = 1.$ Remarks on shifting and scaling When you shift and scale the random variable $X,$ creating the new variable $Z=\mu + \sigma X,$ you are really just changing the units of measurement. Accordingly, the median $m$ becomes $\mu + \sigma m$ and all squared differences relative to $m$ are multiplied by $\sigma^2.$ This is why you found, when setting $\sigma=3,$ that the median squared difference from the median is $3^2\times 1 = 9;$ and when setting $\mu=10,$ you found the median squared difference remained $1.$ Terminology $y$ is called the Median Absolute Deviation from the Median, or MAD. It is a standard robust measure of dispersion.
Median of the squared difference from the median of a Cauchy random variable
Suppose $F$ is the distribution function of a random variable $X$ with median $m.$ By definition, a median is any number for which $F(m)\ge 1/2$ and $F(x) \le 1/2$ for all $x \lt m.$ For any non-neg
Median of the squared difference from the median of a Cauchy random variable Suppose $F$ is the distribution function of a random variable $X$ with median $m.$ By definition, a median is any number for which $F(m)\ge 1/2$ and $F(x) \le 1/2$ for all $x \lt m.$ For any non-negative number $y,$ let $$G(y) = F(m+y) - F(m-y) = \Pr(X \in (m-y, m+y]).$$ Clearly (by the probability axioms) $G(0)=0$ and $G$ is a nondecreasing function rising to a limiting value of $1.$ Consequently there is at least one $y$ for which $G(y) \ge 1/2$ and $G(x)\le 1/2$ for all $x \lt y.$ $y^2$ is a median of $(X-m)^2.$ Proof: $$\Pr((X-m)^2 \le y^2) = \Pr(|X-m| \le y) = \Pr(X \in [m-y, m+y] = G(y) \ge 1/2.$$ At the same time, if $0 \le y-\epsilon \lt y,$ $$\begin{aligned} \Pr((X-m)^2 \le (y-\epsilon)^2) &= \Pr(X \in [m-y+\epsilon, m+y-\epsilon]) \\ &\le \Pr(X \in (m-y + \epsilon/2, m+y-\epsilon/2])\\ &= G(y-\epsilon/2) \lt 1/2. \end{aligned}$$ Thus the definition of median is satisfied, QED. Application: Let $X$ have a Cauchy distribution. This means it has a density function $$f_X(x) = \frac{1}{\pi}\frac{1}{1+x^2}.$$ Thus $$\frac{1}{2} = G(y) = \frac{1}{\pi}\int_{-y}^y \frac{\mathrm{d}x}{1+x^2} = \frac{2}{\pi}\arctan(y)$$ has unique solution $y = 1.$ Consequently the median squared deviation from the median is $1^2 = 1.$ Remarks on shifting and scaling When you shift and scale the random variable $X,$ creating the new variable $Z=\mu + \sigma X,$ you are really just changing the units of measurement. Accordingly, the median $m$ becomes $\mu + \sigma m$ and all squared differences relative to $m$ are multiplied by $\sigma^2.$ This is why you found, when setting $\sigma=3,$ that the median squared difference from the median is $3^2\times 1 = 9;$ and when setting $\mu=10,$ you found the median squared difference remained $1.$ Terminology $y$ is called the Median Absolute Deviation from the Median, or MAD. It is a standard robust measure of dispersion.
Median of the squared difference from the median of a Cauchy random variable Suppose $F$ is the distribution function of a random variable $X$ with median $m.$ By definition, a median is any number for which $F(m)\ge 1/2$ and $F(x) \le 1/2$ for all $x \lt m.$ For any non-neg
35,859
Probability of collision: mathematical vs probabilistic modeling
Related scattering theory and free path length Change frame of reference You can compute your method 1 more easily by switching the frame of reference to a co-moving frame along with the stream of cars. If the car 1 has the velocity $\vec{v}_1$ and car 2 have the velocity $\vec{v}_2$ then in the co-moving frame the relative speed between the cars is $\vec{u} = \vec{v}_1 - \vec{v}_2$ with the components $$\begin{array}{} u_{x,2} &=& v_2 \text{cos}\,\theta -v_1 \\ u_{y,2} &=& v_2 \text{sin}\, \theta \\ \end{array}$$ Then we consider a different angle $\theta^\prime$ at which the car2 is passing the stream while the cars 2 are standing still. This angle is related to the new vertical and horizontal velocities in the co-moving frame of reference. In 'Motivation for the choice of integral bounds' you work with two components: The probability of the car 1 hitting car 2, which relates to $u_{x}$ the relative horizontal speed at which car 1 approaches car 2. The probability of the car 2 hitting car 1, which relates to the $u_{y}$ the relative vertical speed at which car 1 crosses the stream. In the viewpoint of the frame of reference that is co-moving with the cars 1, you can see that this idea of two components 'car 1 hitting car 2' and 'car 2 hitting car 1' is confusing. One should not add the horizontal and vertical components $u_{x}$ and $u_{y}$ together (which is like computing the Manhattan distance), but you should use the Euclidian measure for the distance traveled by car 2 relative to the cars in the stream $\sqrt{u_{x}^2 + u_{y}^2}$. Effective cross-section To compute the collision rate or collision probability, you will have to consider the effective cross-section of the car moving through the stream. If you would do this accurately you will have to determine the distances $d_1$ and $d_2$ which are the distances between the point where the two cars are just touching and lines through the centers of the two cars, these lines are drawn in the direction of travel. To compute these distances is a bit annoying and you have to consider both the angles $\theta$ and $\theta^\prime$. And, there are different cases, for instance, car 2 might hit the other car on the left or the right side depending on the angle. You could approximate the distance with $\lambda$ if you simplify the shape of the cars as spheres with diameter $\lambda$. The cross section will then be twice this distance because the car 2 can hit the car 1 on the left and on the right. The distance between the cars 1 or the density in the stream. If we approach the stream at an angle than the distance between the cars in the stream becomes smaller. In the figure below you see that this distance is not $l$ but instead $l \sin \, \theta^\prime$. Probability of hit with method 1 The probability that a car 2 hits another car in the stream is then $$\frac{\text{cross-section}}{\text{path-width}} \approx \frac{2 \lambda}{l \cdot \sin \, \theta^\prime}$$ and with $$\sin \theta^\prime = \frac{u_{y}}{\sqrt{{u_{x}}^2+{u_{y}}^2}}$$ we can rewrite it as $$\frac{\text{cross-section}}{\text{path-width}} \approx \frac{2 \lambda}{l} \sqrt{ 1 + \left( \frac{v_2 \cos \, \theta - v_1}{v_2 \sin \, \theta} \right)^2}$$ It is possible that this ratio becomes larger than 1 when the cross-section becomes larger than the path width. In that case a collision is certain (if the cars in the stream are with constant distance/gaps in between). Method 2, using density With the method you will have to compute the area that is swept by car 2 and integrate over that area the density of the cars 1 (which is more easy if this density is constant). Note that the angle of the path changes the area of the path. The integral that you compute, and the motivation for it, is not so clear. It is like you are computing the area of the path of a 1 dimensional line. That area is not dependent on the angle of the car 1. But, it is wrong to use a line. You need to consider the entire block. See in the image below how car 2, if it would be taking an alternative path, would sweep a different area of the stream. Also the velocity of cars 1 plays a role because they change the effective angle $\theta^\prime$ which will change the size of the area that the car 2 sweeps through the stream. Note: in the image $\cos \theta^\prime$ should be $\sin \theta^\prime$. This will be edited later. The image above depicts a stream of uniform density, but you can also consider a nonuniform density in which case you perform an integration over infinitely small slabs. So this area is equal to $$w \cdot x = w \cdot \frac{2\lambda}{\sin\, \theta^\prime}$$ You will have to multiply by the density of the cars which is 1 car per block of size $w$ by $l$, ie $\rho = 1/(l\cdot w)$ and you will end up with the same expression as method 1. $$w \cdot x \cdot \rho = w \cdot \frac{2\lambda}{\sin\, \theta^\prime} \cdot \frac{1}{l\cdot w} = \frac{2\lambda}{l \cdot \sin\, \theta^\prime} $$ Method 2 variant We can also compute the integral from method 2 in the stationary frame of reference. The area computed above is using the area of the parallelogram as (height times width). This can be done in two ways: one is $w \cdot x$ where $w$ is the width of the stream and $x$ the length of the intersection. Another way would be to multiply the cross-section $2\lambda$ with the length of the path which is depending of the width of the stream and the angle $\theta^\prime$. This length of the path can be seen as an effective velocity relating how many area the car 2 effectively travels in the co-moving frame of reference of the car 1 stream. Instead of computing the area in the frame of reference of the co-moving frame we could also compute the area in the stationary frame of reference. In the stationary frame of reference the distance traveled is $$\Delta x \cdot \text{cross-section} = v_2 \Delta t \cdot \text{cross-section}$$ In the co-moving frame of reference the distance traveled is $$v_{effective} \Delta t \cdot \text{cross-section}$$ So we could compute the effective area as the area in the stationary frame of reference multiplied by a factor $$v_2 \Delta t \cdot \text{cross-section} \cdot \frac{v_{effective}}{v_2}$$ This factor at the end is the ratio of the difference in speeds of car 1 and car 2 in the numerator and the speed of car 1 in the denominator $$ \frac{v_{effective}}{v_2} = \frac{\sqrt{(v_2 \cos \, \theta -v_1)^2+(v_2 \sin \, \theta)^2}}{v_2}$$ The time traveled in the stream of width $w$ is relating to another factor $$\Delta t = \frac{w}{v_2 \sin \, \theta}$$ If you put those together you get the same result again. If you like to compute an integral to account for some nonhomogeneous density then you could use a path integral $$ \int \text{cross-section}(s) \rho(s) \frac{|\vec{v}_1(s)-\vec{v}_2(s)|}{|\vec{v}_2(s)|} \text{d}\, s$$ Where the velocities are now considered as vectors $\vec{v}_1$ and $\vec{v}_2$, and the vertical bars $|\cdot|$ denotes the magnitude. If the cross-section $2 \lambda$, density $\rho = \frac{1}{l\cdot w}$ and speeds are constant then we can take them outside of te integral and we end with $$ \begin{array}{} \text{cross-section} \cdot \rho \cdot \frac{|\vec{v}_1-\vec{v}_2|}{|\vec{v}_2|} \cdot \int \text{d}\, s &=& \overbrace{\left(2 \lambda\right)}^{\text{cross-section}} \cdot \overbrace{\left( \frac{1}{l \cdot w} \right)}^{\text{density}} \cdot \overbrace{\left(\frac{|\vec{v}_1-\vec{v}_2|}{|\vec{v}_2|}\right)}^{\text{velocity factor}} \cdot \overbrace{\left( w \frac{|\vec{v}_2|}{{v}_{2,y}} \right)}^{\text{path length $\int \text{d}s$}} \\ &=& \frac{2 \lambda}{l} \frac{|\vec{v}_1-\vec{v}_2|}{{v}_{2,y}} \\ &=& \frac{2 \lambda}{l} \frac{\sqrt{(v_2 \sin \theta)^2 + (v_2 \cos \theta- v_1)^2}}{v_2 \sin \theta} \end{array}$$ Note that this gives the average number of collisions. The meaning of an average is different depending on the distribution of the cars in the stream. (See: What distribution to use to model time before a train arrives?) In your final application with airplanes you might consider the collisions between two streams. Then you can have an integral over the space and use the concentrations of both streams $$ \iint \rho_1(x,y) \rho_2(x,y) \text{cross-section}(x,y) {|\vec{v}_1(x,y)-\vec{v}_2(x,y)|} \text{d}x \text{d} y $$ which gives the rate of collisions per second. You could in addition take into account variations in the speeds at given positions $x,y$ and compute the average of the factor $\text{cross-section}(x,y) {|\vec{v}_1(x,y)-\vec{v}_2(x,y)|}$.
Probability of collision: mathematical vs probabilistic modeling
Related scattering theory and free path length Change frame of reference You can compute your method 1 more easily by switching the frame of reference to a co-moving frame along with the stream of car
Probability of collision: mathematical vs probabilistic modeling Related scattering theory and free path length Change frame of reference You can compute your method 1 more easily by switching the frame of reference to a co-moving frame along with the stream of cars. If the car 1 has the velocity $\vec{v}_1$ and car 2 have the velocity $\vec{v}_2$ then in the co-moving frame the relative speed between the cars is $\vec{u} = \vec{v}_1 - \vec{v}_2$ with the components $$\begin{array}{} u_{x,2} &=& v_2 \text{cos}\,\theta -v_1 \\ u_{y,2} &=& v_2 \text{sin}\, \theta \\ \end{array}$$ Then we consider a different angle $\theta^\prime$ at which the car2 is passing the stream while the cars 2 are standing still. This angle is related to the new vertical and horizontal velocities in the co-moving frame of reference. In 'Motivation for the choice of integral bounds' you work with two components: The probability of the car 1 hitting car 2, which relates to $u_{x}$ the relative horizontal speed at which car 1 approaches car 2. The probability of the car 2 hitting car 1, which relates to the $u_{y}$ the relative vertical speed at which car 1 crosses the stream. In the viewpoint of the frame of reference that is co-moving with the cars 1, you can see that this idea of two components 'car 1 hitting car 2' and 'car 2 hitting car 1' is confusing. One should not add the horizontal and vertical components $u_{x}$ and $u_{y}$ together (which is like computing the Manhattan distance), but you should use the Euclidian measure for the distance traveled by car 2 relative to the cars in the stream $\sqrt{u_{x}^2 + u_{y}^2}$. Effective cross-section To compute the collision rate or collision probability, you will have to consider the effective cross-section of the car moving through the stream. If you would do this accurately you will have to determine the distances $d_1$ and $d_2$ which are the distances between the point where the two cars are just touching and lines through the centers of the two cars, these lines are drawn in the direction of travel. To compute these distances is a bit annoying and you have to consider both the angles $\theta$ and $\theta^\prime$. And, there are different cases, for instance, car 2 might hit the other car on the left or the right side depending on the angle. You could approximate the distance with $\lambda$ if you simplify the shape of the cars as spheres with diameter $\lambda$. The cross section will then be twice this distance because the car 2 can hit the car 1 on the left and on the right. The distance between the cars 1 or the density in the stream. If we approach the stream at an angle than the distance between the cars in the stream becomes smaller. In the figure below you see that this distance is not $l$ but instead $l \sin \, \theta^\prime$. Probability of hit with method 1 The probability that a car 2 hits another car in the stream is then $$\frac{\text{cross-section}}{\text{path-width}} \approx \frac{2 \lambda}{l \cdot \sin \, \theta^\prime}$$ and with $$\sin \theta^\prime = \frac{u_{y}}{\sqrt{{u_{x}}^2+{u_{y}}^2}}$$ we can rewrite it as $$\frac{\text{cross-section}}{\text{path-width}} \approx \frac{2 \lambda}{l} \sqrt{ 1 + \left( \frac{v_2 \cos \, \theta - v_1}{v_2 \sin \, \theta} \right)^2}$$ It is possible that this ratio becomes larger than 1 when the cross-section becomes larger than the path width. In that case a collision is certain (if the cars in the stream are with constant distance/gaps in between). Method 2, using density With the method you will have to compute the area that is swept by car 2 and integrate over that area the density of the cars 1 (which is more easy if this density is constant). Note that the angle of the path changes the area of the path. The integral that you compute, and the motivation for it, is not so clear. It is like you are computing the area of the path of a 1 dimensional line. That area is not dependent on the angle of the car 1. But, it is wrong to use a line. You need to consider the entire block. See in the image below how car 2, if it would be taking an alternative path, would sweep a different area of the stream. Also the velocity of cars 1 plays a role because they change the effective angle $\theta^\prime$ which will change the size of the area that the car 2 sweeps through the stream. Note: in the image $\cos \theta^\prime$ should be $\sin \theta^\prime$. This will be edited later. The image above depicts a stream of uniform density, but you can also consider a nonuniform density in which case you perform an integration over infinitely small slabs. So this area is equal to $$w \cdot x = w \cdot \frac{2\lambda}{\sin\, \theta^\prime}$$ You will have to multiply by the density of the cars which is 1 car per block of size $w$ by $l$, ie $\rho = 1/(l\cdot w)$ and you will end up with the same expression as method 1. $$w \cdot x \cdot \rho = w \cdot \frac{2\lambda}{\sin\, \theta^\prime} \cdot \frac{1}{l\cdot w} = \frac{2\lambda}{l \cdot \sin\, \theta^\prime} $$ Method 2 variant We can also compute the integral from method 2 in the stationary frame of reference. The area computed above is using the area of the parallelogram as (height times width). This can be done in two ways: one is $w \cdot x$ where $w$ is the width of the stream and $x$ the length of the intersection. Another way would be to multiply the cross-section $2\lambda$ with the length of the path which is depending of the width of the stream and the angle $\theta^\prime$. This length of the path can be seen as an effective velocity relating how many area the car 2 effectively travels in the co-moving frame of reference of the car 1 stream. Instead of computing the area in the frame of reference of the co-moving frame we could also compute the area in the stationary frame of reference. In the stationary frame of reference the distance traveled is $$\Delta x \cdot \text{cross-section} = v_2 \Delta t \cdot \text{cross-section}$$ In the co-moving frame of reference the distance traveled is $$v_{effective} \Delta t \cdot \text{cross-section}$$ So we could compute the effective area as the area in the stationary frame of reference multiplied by a factor $$v_2 \Delta t \cdot \text{cross-section} \cdot \frac{v_{effective}}{v_2}$$ This factor at the end is the ratio of the difference in speeds of car 1 and car 2 in the numerator and the speed of car 1 in the denominator $$ \frac{v_{effective}}{v_2} = \frac{\sqrt{(v_2 \cos \, \theta -v_1)^2+(v_2 \sin \, \theta)^2}}{v_2}$$ The time traveled in the stream of width $w$ is relating to another factor $$\Delta t = \frac{w}{v_2 \sin \, \theta}$$ If you put those together you get the same result again. If you like to compute an integral to account for some nonhomogeneous density then you could use a path integral $$ \int \text{cross-section}(s) \rho(s) \frac{|\vec{v}_1(s)-\vec{v}_2(s)|}{|\vec{v}_2(s)|} \text{d}\, s$$ Where the velocities are now considered as vectors $\vec{v}_1$ and $\vec{v}_2$, and the vertical bars $|\cdot|$ denotes the magnitude. If the cross-section $2 \lambda$, density $\rho = \frac{1}{l\cdot w}$ and speeds are constant then we can take them outside of te integral and we end with $$ \begin{array}{} \text{cross-section} \cdot \rho \cdot \frac{|\vec{v}_1-\vec{v}_2|}{|\vec{v}_2|} \cdot \int \text{d}\, s &=& \overbrace{\left(2 \lambda\right)}^{\text{cross-section}} \cdot \overbrace{\left( \frac{1}{l \cdot w} \right)}^{\text{density}} \cdot \overbrace{\left(\frac{|\vec{v}_1-\vec{v}_2|}{|\vec{v}_2|}\right)}^{\text{velocity factor}} \cdot \overbrace{\left( w \frac{|\vec{v}_2|}{{v}_{2,y}} \right)}^{\text{path length $\int \text{d}s$}} \\ &=& \frac{2 \lambda}{l} \frac{|\vec{v}_1-\vec{v}_2|}{{v}_{2,y}} \\ &=& \frac{2 \lambda}{l} \frac{\sqrt{(v_2 \sin \theta)^2 + (v_2 \cos \theta- v_1)^2}}{v_2 \sin \theta} \end{array}$$ Note that this gives the average number of collisions. The meaning of an average is different depending on the distribution of the cars in the stream. (See: What distribution to use to model time before a train arrives?) In your final application with airplanes you might consider the collisions between two streams. Then you can have an integral over the space and use the concentrations of both streams $$ \iint \rho_1(x,y) \rho_2(x,y) \text{cross-section}(x,y) {|\vec{v}_1(x,y)-\vec{v}_2(x,y)|} \text{d}x \text{d} y $$ which gives the rate of collisions per second. You could in addition take into account variations in the speeds at given positions $x,y$ and compute the average of the factor $\text{cross-section}(x,y) {|\vec{v}_1(x,y)-\vec{v}_2(x,y)|}$.
Probability of collision: mathematical vs probabilistic modeling Related scattering theory and free path length Change frame of reference You can compute your method 1 more easily by switching the frame of reference to a co-moving frame along with the stream of car
35,860
Probability of collision: mathematical vs probabilistic modeling
First, once you know where you are in this picture relative to the position of the car 1, there's nothing probabilistic left in the problem: you know exactly whether you're colliding or not. So the event of collision and its probability boils down to what is random about your relative location. Reduction to 1D Let's describe how car 1 moves and looks in the coordinate system where car 2 is stationary and y-axis is parallel with car 1 speed vector. This also means that x-component of car 1 speed is zero. We start with the original setup here: Then we introduce a new coordinate system as follows: In the new coordinate system Car 1 has a speed vector $$\vec v=(v_x,v_y)=\left(0,-\sqrt{v_1^2+v_2^2-2v_1v_2\cos\theta}\right)$$ Its cross section in direction of y-axis is $\lambda_1=\lambda(|\sin\alpha|+\cos\alpha)$, where $\cos\alpha=\frac{v_2\sin\theta}{v_y}$ and $\sin\alpha=\frac{v1-v_2\cos\theta}{v_y}$. Note, that in this coordinate system x-axis isn't parallel to the speed vector $\vec v_2$ of a Car 2. The angle between them is defined by speeds and angle $\theta$. The gap between cars 1 is then $l\cos\alpha-\lambda_1$. Notice that, depending on parameters of the problem the gap can be zero or even negative, meaning there's no way for car 2 to avoid a collision. Now, the car 2 cross section relative to this new y-axis is $\lambda_2=\lambda(|\sin(\theta-\alpha)|+|\cos(\theta-\alpha)|)$. Probabilities: nothing is known about car locations Finally, the probability to avoid collision given $v_1,v_2,\lambda,l,\theta$ seems to be a simple ratio: $$p=\max\left[\frac{l\cos\alpha-\lambda_1-\lambda_2}{l\cos\alpha},0\right],$$ where $\theta\in(0,\pi)$. When $\theta=0$ there's no crossing the road, so I exclude this case. When formulate it like this, we assume that all parameters are given except the current locations of cars! Now we need to make an assumption on what is probability density of car locations. Due to translation symmetry, we can further reduce the free variables to the relative location of Car 2 to Car 1. If we assume that the location is a uniform random point on Euclidian space of the surface, then the equation will work. Why? Because the new coordinate system is a simple rotation relative to that Euclidian system. Therefore, we can assume that the location of car 2 in this new system's x-axis is a uniform random. Special cases Let's see what happens when $v_1=v_2\cos\theta$: $$v_y=v_2\sin\theta\\ \cos\alpha=1\\ \sin\alpha=0\Rightarrow \alpha=0\\ \lambda_1=\lambda\\ \lambda_2=\lambda\left(|\sin(\theta)|+\cos\theta\right)\\ p=\frac{l-\lambda(1+(|\sin\theta|+\cos\theta))}{l}$$ This is a intuitive expression for cars 1 and 2 moving along at the same East-West speed while car 2 is drifting North bound. When $\theta\to 0+$ this further simplifies into a intuitive expression of cars 1 and 2 moving almost in parallel West bound at the same speed while car 2 is also slowly drifting North bound: $$p\to 1-2\frac{\lambda}{l}$$ When $\theta\to\pi$ we get another intuitive solution: $$\cos\alpha\to 0+\\ \sin\alpha=1\Rightarrow \alpha=\pi/2\\ \lambda_1=\lambda\\ \lambda_2=\lambda\\ p=\max\left[0,\frac{-2\lambda}{0+}\right]=0$$ This is an unavoidable head on collision. Conclusion In my solution the important thing is not the equations, they may have errors in them. The important thing is to recognize that this problem is univariate! By turning the coordinate system we revealed 1D nature of this problem that was formulated in 3 dimensions originally: 2D plane plus time dimension. I then explain why uniform distribution can be used here, which also important. Then the probability becomes simply the ratio.
Probability of collision: mathematical vs probabilistic modeling
First, once you know where you are in this picture relative to the position of the car 1, there's nothing probabilistic left in the problem: you know exactly whether you're colliding or not. So the ev
Probability of collision: mathematical vs probabilistic modeling First, once you know where you are in this picture relative to the position of the car 1, there's nothing probabilistic left in the problem: you know exactly whether you're colliding or not. So the event of collision and its probability boils down to what is random about your relative location. Reduction to 1D Let's describe how car 1 moves and looks in the coordinate system where car 2 is stationary and y-axis is parallel with car 1 speed vector. This also means that x-component of car 1 speed is zero. We start with the original setup here: Then we introduce a new coordinate system as follows: In the new coordinate system Car 1 has a speed vector $$\vec v=(v_x,v_y)=\left(0,-\sqrt{v_1^2+v_2^2-2v_1v_2\cos\theta}\right)$$ Its cross section in direction of y-axis is $\lambda_1=\lambda(|\sin\alpha|+\cos\alpha)$, where $\cos\alpha=\frac{v_2\sin\theta}{v_y}$ and $\sin\alpha=\frac{v1-v_2\cos\theta}{v_y}$. Note, that in this coordinate system x-axis isn't parallel to the speed vector $\vec v_2$ of a Car 2. The angle between them is defined by speeds and angle $\theta$. The gap between cars 1 is then $l\cos\alpha-\lambda_1$. Notice that, depending on parameters of the problem the gap can be zero or even negative, meaning there's no way for car 2 to avoid a collision. Now, the car 2 cross section relative to this new y-axis is $\lambda_2=\lambda(|\sin(\theta-\alpha)|+|\cos(\theta-\alpha)|)$. Probabilities: nothing is known about car locations Finally, the probability to avoid collision given $v_1,v_2,\lambda,l,\theta$ seems to be a simple ratio: $$p=\max\left[\frac{l\cos\alpha-\lambda_1-\lambda_2}{l\cos\alpha},0\right],$$ where $\theta\in(0,\pi)$. When $\theta=0$ there's no crossing the road, so I exclude this case. When formulate it like this, we assume that all parameters are given except the current locations of cars! Now we need to make an assumption on what is probability density of car locations. Due to translation symmetry, we can further reduce the free variables to the relative location of Car 2 to Car 1. If we assume that the location is a uniform random point on Euclidian space of the surface, then the equation will work. Why? Because the new coordinate system is a simple rotation relative to that Euclidian system. Therefore, we can assume that the location of car 2 in this new system's x-axis is a uniform random. Special cases Let's see what happens when $v_1=v_2\cos\theta$: $$v_y=v_2\sin\theta\\ \cos\alpha=1\\ \sin\alpha=0\Rightarrow \alpha=0\\ \lambda_1=\lambda\\ \lambda_2=\lambda\left(|\sin(\theta)|+\cos\theta\right)\\ p=\frac{l-\lambda(1+(|\sin\theta|+\cos\theta))}{l}$$ This is a intuitive expression for cars 1 and 2 moving along at the same East-West speed while car 2 is drifting North bound. When $\theta\to 0+$ this further simplifies into a intuitive expression of cars 1 and 2 moving almost in parallel West bound at the same speed while car 2 is also slowly drifting North bound: $$p\to 1-2\frac{\lambda}{l}$$ When $\theta\to\pi$ we get another intuitive solution: $$\cos\alpha\to 0+\\ \sin\alpha=1\Rightarrow \alpha=\pi/2\\ \lambda_1=\lambda\\ \lambda_2=\lambda\\ p=\max\left[0,\frac{-2\lambda}{0+}\right]=0$$ This is an unavoidable head on collision. Conclusion In my solution the important thing is not the equations, they may have errors in them. The important thing is to recognize that this problem is univariate! By turning the coordinate system we revealed 1D nature of this problem that was formulated in 3 dimensions originally: 2D plane plus time dimension. I then explain why uniform distribution can be used here, which also important. Then the probability becomes simply the ratio.
Probability of collision: mathematical vs probabilistic modeling First, once you know where you are in this picture relative to the position of the car 1, there's nothing probabilistic left in the problem: you know exactly whether you're colliding or not. So the ev
35,861
Interpreting nonlinear regression $R^2$
NO Let’s start by deriving $R^2$ in the linear case. Notation $y_i$ is observation $i$ of some response variable $Y$. $\hat{y}_i$ is the value of $y_i$ predicted by the regression. $\bar{y}$ is the average of all observations of the response variable. $$ y_i-\bar{y} = (y_i - \hat{y_i} + \hat{y_i} - \bar{y}) = (y_i - \hat{y_i}) + (\hat{y_i} - \bar{y}) $$ $$( y_i-\bar{y})^2 = \Big[ (y_i - \hat{y_i}) + (\hat{y_i} - \bar{y}) \Big]^2 = (y_i - \hat{y_i})^2 + (\hat{y_i} - \bar{y})^2 + 2(y_i - \hat{y_i})(\hat{y_i} - \bar{y}) $$ $$SSTotal := \sum_i ( y_i-\bar{y})^2 = \sum_i(y_i - \hat{y_i})^2 + \sum_i(\hat{y_i} - \bar{y})^2 + 2\sum_i\Big[ (y_i - \hat{y_i})(\hat{y_i} - \bar{y}) \Big]$$ $$ :=SSRes + SSReg + Other $$ Divide through by the sample size $n$ (or $n-1$) to get variance estimates. In OLS linear regression, $Other$ drops to zero. Consequently, all of the variance in $Y$ is accounted for by the residual variance (unexplained) and regression variance (explained). We, therefore, can describe the proportion of total variance explained by the regression, which would be the variance explained by the regression model $(SSReg/n)$ divided by the total variance $(SSTotal/n)$. $$ \dfrac{SSReg/n}{SSTotal/n} $$$$= \dfrac{SSReg}{SSTotal} $$$$= \dfrac{SSTotal -SSRes-Other}{SSTotal} $$$$= 1-\dfrac{SSRes}{SSTotal} $$ That final line is a common definition of $R^2$ (and equivalent to other common definitions like squared correlation in the two-variable setting, and squared correlation between predictions and true $y$ values in a multiple linear regression that has several predictor variables (assuming an intercept parameter estimate)). However, that relied on $Other =0$. When that is false, as it is in nonlinear regression, the formula is not so clean. There’s something contributing to the total variance besides the residual and regression variances, and the usual $R^2$ no longer means what it meant in OLS linear regression. This does not invalidate $R^2$ as a performance metric in nonlinear regression, however. Aside from possible numerical funkiness that comes from doing math on a computer, minimizing mean squared error (MSE), which is common in regression, is equivalent to minimizing $SSRes$ or maximizing $R^2$, so if you were comfortable using MSE, you should be comfortable using $R^2$. However, since $Other\ne 0$, it would be incorrect to interpret $R^2=1-\dfrac{SSRes}{SSTotal}$ as the proportion of variance explained. (Why we don’t seek to maximize $SSReg$ instead of minimizing $SSRes$ is the subject of another question by someone with a username that might look familiar, and I do believe the question here to be somewhat different.)
Interpreting nonlinear regression $R^2$
NO Let’s start by deriving $R^2$ in the linear case. Notation $y_i$ is observation $i$ of some response variable $Y$. $\hat{y}_i$ is the value of $y_i$ predicted by the regression. $\bar{y}$ is the av
Interpreting nonlinear regression $R^2$ NO Let’s start by deriving $R^2$ in the linear case. Notation $y_i$ is observation $i$ of some response variable $Y$. $\hat{y}_i$ is the value of $y_i$ predicted by the regression. $\bar{y}$ is the average of all observations of the response variable. $$ y_i-\bar{y} = (y_i - \hat{y_i} + \hat{y_i} - \bar{y}) = (y_i - \hat{y_i}) + (\hat{y_i} - \bar{y}) $$ $$( y_i-\bar{y})^2 = \Big[ (y_i - \hat{y_i}) + (\hat{y_i} - \bar{y}) \Big]^2 = (y_i - \hat{y_i})^2 + (\hat{y_i} - \bar{y})^2 + 2(y_i - \hat{y_i})(\hat{y_i} - \bar{y}) $$ $$SSTotal := \sum_i ( y_i-\bar{y})^2 = \sum_i(y_i - \hat{y_i})^2 + \sum_i(\hat{y_i} - \bar{y})^2 + 2\sum_i\Big[ (y_i - \hat{y_i})(\hat{y_i} - \bar{y}) \Big]$$ $$ :=SSRes + SSReg + Other $$ Divide through by the sample size $n$ (or $n-1$) to get variance estimates. In OLS linear regression, $Other$ drops to zero. Consequently, all of the variance in $Y$ is accounted for by the residual variance (unexplained) and regression variance (explained). We, therefore, can describe the proportion of total variance explained by the regression, which would be the variance explained by the regression model $(SSReg/n)$ divided by the total variance $(SSTotal/n)$. $$ \dfrac{SSReg/n}{SSTotal/n} $$$$= \dfrac{SSReg}{SSTotal} $$$$= \dfrac{SSTotal -SSRes-Other}{SSTotal} $$$$= 1-\dfrac{SSRes}{SSTotal} $$ That final line is a common definition of $R^2$ (and equivalent to other common definitions like squared correlation in the two-variable setting, and squared correlation between predictions and true $y$ values in a multiple linear regression that has several predictor variables (assuming an intercept parameter estimate)). However, that relied on $Other =0$. When that is false, as it is in nonlinear regression, the formula is not so clean. There’s something contributing to the total variance besides the residual and regression variances, and the usual $R^2$ no longer means what it meant in OLS linear regression. This does not invalidate $R^2$ as a performance metric in nonlinear regression, however. Aside from possible numerical funkiness that comes from doing math on a computer, minimizing mean squared error (MSE), which is common in regression, is equivalent to minimizing $SSRes$ or maximizing $R^2$, so if you were comfortable using MSE, you should be comfortable using $R^2$. However, since $Other\ne 0$, it would be incorrect to interpret $R^2=1-\dfrac{SSRes}{SSTotal}$ as the proportion of variance explained. (Why we don’t seek to maximize $SSReg$ instead of minimizing $SSRes$ is the subject of another question by someone with a username that might look familiar, and I do believe the question here to be somewhat different.)
Interpreting nonlinear regression $R^2$ NO Let’s start by deriving $R^2$ in the linear case. Notation $y_i$ is observation $i$ of some response variable $Y$. $\hat{y}_i$ is the value of $y_i$ predicted by the regression. $\bar{y}$ is the av
35,862
Can a (possibly infinite) mixture of Gaussians be Gaussian?
Copying from the Wikipedia page on compound distributions Gaussian scale mixtures: Compounding a normal distribution with variance distributed according to an inverse gamma distribution (or equivalently, with precision distributed as a gamma distribution) yields a non-standardized Student's t-distribution. This distribution has the same symmetrical shape as a normal distribution with the same central point, but has greater variance and heavy tails. Compounding a Gaussian distribution with variance distributed according to an exponential distribution (or with standard deviation according to a Rayleigh distribution) yields a Laplace distribution. Compounding a Gaussian distribution with variance distributed according to an exponential distribution whose rate parameter is itself distributed according to a gamma distribution yields a Normal-exponential-gamma distribution. (This involves two compounding stages. The variance itself then follows a Lomax distribution; see below.) Compounding a Gaussian distribution with standard deviation distributed according to a (standard) inverse uniform distribution yields a Slash distribution. but I do not think there is a case outside the Dirac mass at $\sigma_0$ where the compound is also a Gaussian. This 2005 conference paper by Alecu et al. contains a proof of this result (among other things).
Can a (possibly infinite) mixture of Gaussians be Gaussian?
Copying from the Wikipedia page on compound distributions Gaussian scale mixtures: Compounding a normal distribution with variance distributed according to an inverse gamma distribution (or equivale
Can a (possibly infinite) mixture of Gaussians be Gaussian? Copying from the Wikipedia page on compound distributions Gaussian scale mixtures: Compounding a normal distribution with variance distributed according to an inverse gamma distribution (or equivalently, with precision distributed as a gamma distribution) yields a non-standardized Student's t-distribution. This distribution has the same symmetrical shape as a normal distribution with the same central point, but has greater variance and heavy tails. Compounding a Gaussian distribution with variance distributed according to an exponential distribution (or with standard deviation according to a Rayleigh distribution) yields a Laplace distribution. Compounding a Gaussian distribution with variance distributed according to an exponential distribution whose rate parameter is itself distributed according to a gamma distribution yields a Normal-exponential-gamma distribution. (This involves two compounding stages. The variance itself then follows a Lomax distribution; see below.) Compounding a Gaussian distribution with standard deviation distributed according to a (standard) inverse uniform distribution yields a Slash distribution. but I do not think there is a case outside the Dirac mass at $\sigma_0$ where the compound is also a Gaussian. This 2005 conference paper by Alecu et al. contains a proof of this result (among other things).
Can a (possibly infinite) mixture of Gaussians be Gaussian? Copying from the Wikipedia page on compound distributions Gaussian scale mixtures: Compounding a normal distribution with variance distributed according to an inverse gamma distribution (or equivale
35,863
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed]
It can be helpful to have a "gross reality check" (or grc) ((some people call it a sanity check)) that comes at the problem side-ways and can tell you if you are doing something wrong. Here is R-code to simulate the problem, and give an estimate: set.seed(1) temp <- numeric(length=20000) for(i in 1:20000){ # y <- sample(c(0,1),20,T) #(wrong! Thanks @whuber) discrete y <- runif(n=20) # continuous outputs #is it 8 or more temp[i] <- ifelse(sum(y)>=8,1,0) } mean(temp) This is what it gives: > mean(temp) [1] 0.94265 After 20k trials I would expect the estimate to be within 1% or 0.1% of theoretical result. Here is a plot of 20 runs, showing convergence and spread of the estimate Here is the list of the tail value for the runs, and the residual from the ensemble mean: mean err 1 0.94265 0.00324 2 0.94160 0.00219 3 0.93955 0.00014 4 0.94190 0.00249 5 0.93775 -0.00166 6 0.93580 -0.00361 7 0.93840 -0.00101 8 0.93500 -0.00441 9 0.93735 -0.00206 10 0.94030 0.00089 11 0.94160 0.00219 12 0.93965 0.00024 13 0.94005 0.00064 14 0.93810 -0.00131 15 0.93990 0.00049 16 0.93995 0.00054 17 0.93735 -0.00206 18 0.94125 0.00184 19 0.94070 0.00129 20 0.93935 -0.00006 They don't move around much. The standard deviation in those means is ~0.00204, while the ensemble mean is 93.941% The estimates 93.94% (analytic) and 93.941% (simulated) are ~0.0048 standard deviations apart, which indicates to me that the analytic approach is on the right track.
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s
It can be helpful to have a "gross reality check" (or grc) ((some people call it a sanity check)) that comes at the problem side-ways and can tell you if you are doing something wrong. Here is R-code
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed] It can be helpful to have a "gross reality check" (or grc) ((some people call it a sanity check)) that comes at the problem side-ways and can tell you if you are doing something wrong. Here is R-code to simulate the problem, and give an estimate: set.seed(1) temp <- numeric(length=20000) for(i in 1:20000){ # y <- sample(c(0,1),20,T) #(wrong! Thanks @whuber) discrete y <- runif(n=20) # continuous outputs #is it 8 or more temp[i] <- ifelse(sum(y)>=8,1,0) } mean(temp) This is what it gives: > mean(temp) [1] 0.94265 After 20k trials I would expect the estimate to be within 1% or 0.1% of theoretical result. Here is a plot of 20 runs, showing convergence and spread of the estimate Here is the list of the tail value for the runs, and the residual from the ensemble mean: mean err 1 0.94265 0.00324 2 0.94160 0.00219 3 0.93955 0.00014 4 0.94190 0.00249 5 0.93775 -0.00166 6 0.93580 -0.00361 7 0.93840 -0.00101 8 0.93500 -0.00441 9 0.93735 -0.00206 10 0.94030 0.00089 11 0.94160 0.00219 12 0.93965 0.00024 13 0.94005 0.00064 14 0.93810 -0.00131 15 0.93990 0.00049 16 0.93995 0.00054 17 0.93735 -0.00206 18 0.94125 0.00184 19 0.94070 0.00129 20 0.93935 -0.00006 They don't move around much. The standard deviation in those means is ~0.00204, while the ensemble mean is 93.941% The estimates 93.94% (analytic) and 93.941% (simulated) are ~0.0048 standard deviations apart, which indicates to me that the analytic approach is on the right track.
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s It can be helpful to have a "gross reality check" (or grc) ((some people call it a sanity check)) that comes at the problem side-ways and can tell you if you are doing something wrong. Here is R-code
35,864
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed]
Let $ \ X_i $ be the $ \ i^{th}$ number selected where $\ i= 1,2,3,4...20 $ $To $ $ calculate $ $ \ P( \sum_{i=1}^{20} X_i \ge 8 ) $ $ E(\ X_i) = \frac{(0+1)}{2} $ $ [uniform $ $ distribution ] $ $ E(\ X_i) = \frac{1}{2} $ $ E(\sum_{i=1}^{20} X_i) = 20/2 = 10 $ $ Var(\ X_i) = \frac{\ (1-0)^2}{12} $ $ [uniform $ $ distribution ] $ $ Var(\ X_i) = \frac{\ 1}{12} $ $ Var(\sum_{i=1}^{20} X_i) = 20/12 = 5/3 $ $ \ P(\frac{ \sum_{i=1}^{20} X_i - E(\sum_{i=1}^{20} X_i) }{\sqrt Var(\sum_{i=1}^{20} X_i)} \ge \frac {8 -E(\sum_{i=1}^{20} X_i)}{\sqrt Var(\sum_{i=1}^{20} X_i} ) $ $ \ P(\frac{ \sum_{i=1}^{20} X_i - 10) }{\sqrt {5/3}} \ge \frac {8 -10}{\sqrt 5/3} ) $ $ 1- P(Z \le -1.55)$ = $ 0.9394 $ $ approx $
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s
Let $ \ X_i $ be the $ \ i^{th}$ number selected where $\ i= 1,2,3,4...20 $ $To $ $ calculate $ $ \ P( \sum_{i=1}^{20} X_i \ge 8 ) $ $ E(\ X_i) = \frac{(0+1)}{2} $ $ [uniform $ $ distribution ] $ $ E
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed] Let $ \ X_i $ be the $ \ i^{th}$ number selected where $\ i= 1,2,3,4...20 $ $To $ $ calculate $ $ \ P( \sum_{i=1}^{20} X_i \ge 8 ) $ $ E(\ X_i) = \frac{(0+1)}{2} $ $ [uniform $ $ distribution ] $ $ E(\ X_i) = \frac{1}{2} $ $ E(\sum_{i=1}^{20} X_i) = 20/2 = 10 $ $ Var(\ X_i) = \frac{\ (1-0)^2}{12} $ $ [uniform $ $ distribution ] $ $ Var(\ X_i) = \frac{\ 1}{12} $ $ Var(\sum_{i=1}^{20} X_i) = 20/12 = 5/3 $ $ \ P(\frac{ \sum_{i=1}^{20} X_i - E(\sum_{i=1}^{20} X_i) }{\sqrt Var(\sum_{i=1}^{20} X_i)} \ge \frac {8 -E(\sum_{i=1}^{20} X_i)}{\sqrt Var(\sum_{i=1}^{20} X_i} ) $ $ \ P(\frac{ \sum_{i=1}^{20} X_i - 10) }{\sqrt {5/3}} \ge \frac {8 -10}{\sqrt 5/3} ) $ $ 1- P(Z \le -1.55)$ = $ 0.9394 $ $ approx $
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s Let $ \ X_i $ be the $ \ i^{th}$ number selected where $\ i= 1,2,3,4...20 $ $To $ $ calculate $ $ \ P( \sum_{i=1}^{20} X_i \ge 8 ) $ $ E(\ X_i) = \frac{(0+1)}{2} $ $ [uniform $ $ distribution ] $ $ E
35,865
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed]
Here is a histogram of 100,000 simulations each taking the sum of 20 uniform random deviates. Based on this simulation the sum of uniform deviates is well approximated by a normal distribution with an estimated mean of 10.004 and an estimated variance of 1.680. Using the normal approximation the probability that $\sum_{i=1}^n X_i \ge 8$ is $0.94$. Code follows: data uniform; do sim=1 to 100000; do i=1 to 20; y=rand('uniform'); output; end; end; run; proc means data=uniform noprint; by sim; var y; output out=out sum(y)=sum; run; ods graphics / height=3in width=6in border=no; proc sgplot data=out; histogram sum; density sum / type=normal; run; proc means data=out mean var; var sum; output out=estimates mean(sum)=mean var(sum)=var; run; data estimates; set estimates; prob=1-cdf('normal',8,mean,sqrt(var)); run; proc print data=estimates noobs; var prob; run;
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s
Here is a histogram of 100,000 simulations each taking the sum of 20 uniform random deviates. Based on this simulation the sum of uniform deviates is well approximated by a normal distribution with a
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the sum of these numbers is at least $8$? [closed] Here is a histogram of 100,000 simulations each taking the sum of 20 uniform random deviates. Based on this simulation the sum of uniform deviates is well approximated by a normal distribution with an estimated mean of 10.004 and an estimated variance of 1.680. Using the normal approximation the probability that $\sum_{i=1}^n X_i \ge 8$ is $0.94$. Code follows: data uniform; do sim=1 to 100000; do i=1 to 20; y=rand('uniform'); output; end; end; run; proc means data=uniform noprint; by sim; var y; output out=out sum(y)=sum; run; ods graphics / height=3in width=6in border=no; proc sgplot data=out; histogram sum; density sum / type=normal; run; proc means data=out mean var; var sum; output out=estimates mean(sum)=mean var(sum)=var; run; data estimates; set estimates; prob=1-cdf('normal',8,mean,sqrt(var)); run; proc print data=estimates noobs; var prob; run;
If $20 $ random numbers are selected independently from the interval $(0,1) $ probability that the s Here is a histogram of 100,000 simulations each taking the sum of 20 uniform random deviates. Based on this simulation the sum of uniform deviates is well approximated by a normal distribution with a
35,866
MCMC sampling for a model with a multinomial choice--so the parameters need to sum to 1
The problem does not seem to stand with MCMC but with the prior modelling. If the data comes from a Multinomial distribution $$\mathcal D_k(n,p_1,\ldots,p_k)$$ where the probability vector $\mathbf{p}=(p_1,\ldots,p_k)$ belongs to the $k$-dimensional simplex, the prior on $\mathbf{p}$ must put some mass on the simplex (and should logically be allocating all its mass to the simplex. Using truncated Normals is thus inadequate as the prior puts zero mass on the simplex. As suggested by microhaus, a natural family of distributions in this setting is the family of Dirichlet priors. An alternative (or a generalisation) is to over-parametrise the model and set the constraint later. For instance, take $$p_1=\dfrac{\rho_1}{\sum_{i=1}^k \rho_i},\ldots,p_k=\dfrac{\rho_k}{\sum_{i=1}^k \rho_i}$$ with$$\rho_i\sim\mathcal N^+(a_i,b_i^2)$$ (when using a Gamma prior with a constant scale instead of a truncated Normal, this returns a Dirichlet).
MCMC sampling for a model with a multinomial choice--so the parameters need to sum to 1
The problem does not seem to stand with MCMC but with the prior modelling. If the data comes from a Multinomial distribution $$\mathcal D_k(n,p_1,\ldots,p_k)$$ where the probability vector $\mathbf{p}
MCMC sampling for a model with a multinomial choice--so the parameters need to sum to 1 The problem does not seem to stand with MCMC but with the prior modelling. If the data comes from a Multinomial distribution $$\mathcal D_k(n,p_1,\ldots,p_k)$$ where the probability vector $\mathbf{p}=(p_1,\ldots,p_k)$ belongs to the $k$-dimensional simplex, the prior on $\mathbf{p}$ must put some mass on the simplex (and should logically be allocating all its mass to the simplex. Using truncated Normals is thus inadequate as the prior puts zero mass on the simplex. As suggested by microhaus, a natural family of distributions in this setting is the family of Dirichlet priors. An alternative (or a generalisation) is to over-parametrise the model and set the constraint later. For instance, take $$p_1=\dfrac{\rho_1}{\sum_{i=1}^k \rho_i},\ldots,p_k=\dfrac{\rho_k}{\sum_{i=1}^k \rho_i}$$ with$$\rho_i\sim\mathcal N^+(a_i,b_i^2)$$ (when using a Gamma prior with a constant scale instead of a truncated Normal, this returns a Dirichlet).
MCMC sampling for a model with a multinomial choice--so the parameters need to sum to 1 The problem does not seem to stand with MCMC but with the prior modelling. If the data comes from a Multinomial distribution $$\mathcal D_k(n,p_1,\ldots,p_k)$$ where the probability vector $\mathbf{p}
35,867
Multivariate normal distribution vs. sampling multiple times from univariate normal distribution
What you propose ignores correlations. When marginals have correlation (say positive for now), then when one is high, the others will tend to be high. Example Marginals are $X,Y\sim N(0,1)$. Draw from $X$ and $Y$ independently and get $X = 1.5$ and $Y=-1$. So far so good, right? Maybe the values are a little unusual and away from the means, but there's nothing too strange going on. If $X$ and $Y$ have a strong positive correlation, then this pair of $(1.5, -1)$ is extremely unlikely. When $X$ is positive, $Y$ tends to be positive. Sampling only from the marginals means that this pairing is reasonably likely when it should not be. If the marginals are independent of one another, then what you propose is fine.
Multivariate normal distribution vs. sampling multiple times from univariate normal distribution
What you propose ignores correlations. When marginals have correlation (say positive for now), then when one is high, the others will tend to be high. Example Marginals are $X,Y\sim N(0,1)$. Draw from
Multivariate normal distribution vs. sampling multiple times from univariate normal distribution What you propose ignores correlations. When marginals have correlation (say positive for now), then when one is high, the others will tend to be high. Example Marginals are $X,Y\sim N(0,1)$. Draw from $X$ and $Y$ independently and get $X = 1.5$ and $Y=-1$. So far so good, right? Maybe the values are a little unusual and away from the means, but there's nothing too strange going on. If $X$ and $Y$ have a strong positive correlation, then this pair of $(1.5, -1)$ is extremely unlikely. When $X$ is positive, $Y$ tends to be positive. Sampling only from the marginals means that this pairing is reasonably likely when it should not be. If the marginals are independent of one another, then what you propose is fine.
Multivariate normal distribution vs. sampling multiple times from univariate normal distribution What you propose ignores correlations. When marginals have correlation (say positive for now), then when one is high, the others will tend to be high. Example Marginals are $X,Y\sim N(0,1)$. Draw from
35,868
Does zero Spearman's rho imply zero Covariance?
Counterexample: X Y 1 500 2 1 3 2 4 3 5 4 For these values, Pearson's $r \approx -0.70$ Spearman's $\rho = 0$ That single large Y value affects the covariance much more than it affects Spearman's rank correlation coefficient.
Does zero Spearman's rho imply zero Covariance?
Counterexample: X Y 1 500 2 1 3 2 4 3 5 4 For these values, Pearson's $r \approx -0.70$ Spearman's $\rho = 0$ That single large Y value affects the covariance much more than it affects Spearman's r
Does zero Spearman's rho imply zero Covariance? Counterexample: X Y 1 500 2 1 3 2 4 3 5 4 For these values, Pearson's $r \approx -0.70$ Spearman's $\rho = 0$ That single large Y value affects the covariance much more than it affects Spearman's rank correlation coefficient.
Does zero Spearman's rho imply zero Covariance? Counterexample: X Y 1 500 2 1 3 2 4 3 5 4 For these values, Pearson's $r \approx -0.70$ Spearman's $\rho = 0$ That single large Y value affects the covariance much more than it affects Spearman's r
35,869
Does zero Spearman's rho imply zero Covariance?
No. Easy to see why. The use case of rank correlation is when we’re not satisfied with Pearson correlation, e.g. with its proneness to fall for outliers. Therefore, clearly Spearman correlation should not correspond to Pearson correlation outcomes. Sometimes zero spearman correlation coincides with zero Pearson correlation and consequently zero covariance, but it’s not a general case.
Does zero Spearman's rho imply zero Covariance?
No. Easy to see why. The use case of rank correlation is when we’re not satisfied with Pearson correlation, e.g. with its proneness to fall for outliers. Therefore, clearly Spearman correlation should
Does zero Spearman's rho imply zero Covariance? No. Easy to see why. The use case of rank correlation is when we’re not satisfied with Pearson correlation, e.g. with its proneness to fall for outliers. Therefore, clearly Spearman correlation should not correspond to Pearson correlation outcomes. Sometimes zero spearman correlation coincides with zero Pearson correlation and consequently zero covariance, but it’s not a general case.
Does zero Spearman's rho imply zero Covariance? No. Easy to see why. The use case of rank correlation is when we’re not satisfied with Pearson correlation, e.g. with its proneness to fall for outliers. Therefore, clearly Spearman correlation should
35,870
Probability that the sample comes from a certain distribution
phibog's goal is to find out the probability that a set of data samples belongs to the distribution with pdf $f(x)$. It can be expressed as $P(f(x)|x_1,x_2,...,x_n)$. From Bayes theorem, $P(f(x)|x_1,x_2,...,x_n)=\frac{P(x_1,x_2,...,x_n|f(x))P(f(x))}{P(x_1,x_2,...,x_n|f(x))P(f(x))+P(x_1,x_2,...,x_n|g(x))P(g(x))},$ where $P(f(x))$ and $P(g(x))$ are a prior probabilities that the data samples belong to $f(x)$ and $g(x)$ respectively. Since no information is available about which distribution is more likely than another, simply let $P(f(x))=P(g(x))$. The above expression then becomes $P(f(x)|x_1,x_2,...,x_n)=\frac{P(x_1,x_2,...,x_n|f(x))}{P(x_1,x_2,...,x_n|f(x))+P(x_1,x_2,...,x_n|g(x))}$. When $x_1,x_2,...,x_n$ are all independent, finally we have $P(f(x)|x_1,x_2,...,x_n)=\frac{L_1}{L_1+L_2}$, where $L_1$ and $L_2$ have been defined in the OP.
Probability that the sample comes from a certain distribution
phibog's goal is to find out the probability that a set of data samples belongs to the distribution with pdf $f(x)$. It can be expressed as $P(f(x)|x_1,x_2,...,x_n)$. From Bayes theorem, $P(f(x)|x_1,x
Probability that the sample comes from a certain distribution phibog's goal is to find out the probability that a set of data samples belongs to the distribution with pdf $f(x)$. It can be expressed as $P(f(x)|x_1,x_2,...,x_n)$. From Bayes theorem, $P(f(x)|x_1,x_2,...,x_n)=\frac{P(x_1,x_2,...,x_n|f(x))P(f(x))}{P(x_1,x_2,...,x_n|f(x))P(f(x))+P(x_1,x_2,...,x_n|g(x))P(g(x))},$ where $P(f(x))$ and $P(g(x))$ are a prior probabilities that the data samples belong to $f(x)$ and $g(x)$ respectively. Since no information is available about which distribution is more likely than another, simply let $P(f(x))=P(g(x))$. The above expression then becomes $P(f(x)|x_1,x_2,...,x_n)=\frac{P(x_1,x_2,...,x_n|f(x))}{P(x_1,x_2,...,x_n|f(x))+P(x_1,x_2,...,x_n|g(x))}$. When $x_1,x_2,...,x_n$ are all independent, finally we have $P(f(x)|x_1,x_2,...,x_n)=\frac{L_1}{L_1+L_2}$, where $L_1$ and $L_2$ have been defined in the OP.
Probability that the sample comes from a certain distribution phibog's goal is to find out the probability that a set of data samples belongs to the distribution with pdf $f(x)$. It can be expressed as $P(f(x)|x_1,x_2,...,x_n)$. From Bayes theorem, $P(f(x)|x_1,x
35,871
Probability that the sample comes from a certain distribution
A simple method here is to use Bayesian analysis. For notational simplicity, let's "parameterise" your family of (two) distributions by defining the probability density $h$ by: $$h(x|\theta) = \begin{cases} f(x) & & & \text{if } \theta = 0, \\[6pt] g(x) & & & \text{if } \theta = 1. \\[6pt] \end{cases}$$ The binary parameter $\theta$ now tells you which is the true distribution --- $f$ or $g$. Now, to determine which is the correct distribution given your data, we set a prior probability $\pi = \mathbb{P}(\theta = 0)$ that the data come from the distribution $f$, and we compute the corresponding posterior probability: $$\mathbb{P}(\theta=0 | \mathbf{x}) = \frac{ \pi \prod_{i=1}^n f(x_i)}{ \pi \prod_{i=1}^n f(x_i) + (1-\pi) \prod_{i=1}^n g(x_i)}.$$ This tells you the posterior probability that the data come from the distribution $f$ (and the corresponding probability that they come from $g$ is one minus this probability).
Probability that the sample comes from a certain distribution
A simple method here is to use Bayesian analysis. For notational simplicity, let's "parameterise" your family of (two) distributions by defining the probability density $h$ by: $$h(x|\theta) = \begin
Probability that the sample comes from a certain distribution A simple method here is to use Bayesian analysis. For notational simplicity, let's "parameterise" your family of (two) distributions by defining the probability density $h$ by: $$h(x|\theta) = \begin{cases} f(x) & & & \text{if } \theta = 0, \\[6pt] g(x) & & & \text{if } \theta = 1. \\[6pt] \end{cases}$$ The binary parameter $\theta$ now tells you which is the true distribution --- $f$ or $g$. Now, to determine which is the correct distribution given your data, we set a prior probability $\pi = \mathbb{P}(\theta = 0)$ that the data come from the distribution $f$, and we compute the corresponding posterior probability: $$\mathbb{P}(\theta=0 | \mathbf{x}) = \frac{ \pi \prod_{i=1}^n f(x_i)}{ \pi \prod_{i=1}^n f(x_i) + (1-\pi) \prod_{i=1}^n g(x_i)}.$$ This tells you the posterior probability that the data come from the distribution $f$ (and the corresponding probability that they come from $g$ is one minus this probability).
Probability that the sample comes from a certain distribution A simple method here is to use Bayesian analysis. For notational simplicity, let's "parameterise" your family of (two) distributions by defining the probability density $h$ by: $$h(x|\theta) = \begin
35,872
Probability that the sample comes from a certain distribution
If one of your distribution is a more/less restricted version of the other, then the Likelihood-ratio test might be what you want. More specifically: Assuming $H_0$ is true, there is a fundamental result by Samuel S. Wilks: As the sample size $n$ approaches $\infty$, the test statistic $-2\log(\lambda)$ asymptotically will be chi-squared distributed ($\chi ^{2}$) with degrees of freedom equal to the difference in dimensionality of $\Theta$ and $\Theta_0$. where $\lambda$ is the likelihood ratio $\frac{L_\mathrm{null}}{L_\mathrm{alter}}$. I am not sure if this method would be appropriate for comparing likelihoods from two arbitrary distributions though.
Probability that the sample comes from a certain distribution
If one of your distribution is a more/less restricted version of the other, then the Likelihood-ratio test might be what you want. More specifically: Assuming $H_0$ is true, there is a fundamental re
Probability that the sample comes from a certain distribution If one of your distribution is a more/less restricted version of the other, then the Likelihood-ratio test might be what you want. More specifically: Assuming $H_0$ is true, there is a fundamental result by Samuel S. Wilks: As the sample size $n$ approaches $\infty$, the test statistic $-2\log(\lambda)$ asymptotically will be chi-squared distributed ($\chi ^{2}$) with degrees of freedom equal to the difference in dimensionality of $\Theta$ and $\Theta_0$. where $\lambda$ is the likelihood ratio $\frac{L_\mathrm{null}}{L_\mathrm{alter}}$. I am not sure if this method would be appropriate for comparing likelihoods from two arbitrary distributions though.
Probability that the sample comes from a certain distribution If one of your distribution is a more/less restricted version of the other, then the Likelihood-ratio test might be what you want. More specifically: Assuming $H_0$ is true, there is a fundamental re
35,873
Probability that the sample comes from a certain distribution
The data either come from the specified model or they do not. There is no probability regarding this concern. The candidate model serves as a convenient yet imperfect representation of the data generative process. To compare how competing models fit your data you can use a criterion such as AIC based on the likelihood. You can base your choice of probability model at least in part on this criterion. Regarding the K-S test, rather than defining an "acceptance/rejection" region you could view the p-value as the weight of the evidence regarding a particular model. For various competing models you could compare K-S p-values analogous to comparing AIC values. Models with larger p-values do a better job representing your data. You may instead be interested in a Bayesian belief probability regarding whether a candidate model is the "right" model. This would be the realm of Bayes factor or other type of model selection and would require a prior distribution on the candidate models. According to the adage, "All models are wrong but some are useful," you could end up assigning a 0% probability to every candidate model. You are also free to assign any other prior distribution. This would allow you to arrive at any conclusion for the belief probability that the sample comes from a certain distribution.
Probability that the sample comes from a certain distribution
The data either come from the specified model or they do not. There is no probability regarding this concern. The candidate model serves as a convenient yet imperfect representation of the data gene
Probability that the sample comes from a certain distribution The data either come from the specified model or they do not. There is no probability regarding this concern. The candidate model serves as a convenient yet imperfect representation of the data generative process. To compare how competing models fit your data you can use a criterion such as AIC based on the likelihood. You can base your choice of probability model at least in part on this criterion. Regarding the K-S test, rather than defining an "acceptance/rejection" region you could view the p-value as the weight of the evidence regarding a particular model. For various competing models you could compare K-S p-values analogous to comparing AIC values. Models with larger p-values do a better job representing your data. You may instead be interested in a Bayesian belief probability regarding whether a candidate model is the "right" model. This would be the realm of Bayes factor or other type of model selection and would require a prior distribution on the candidate models. According to the adage, "All models are wrong but some are useful," you could end up assigning a 0% probability to every candidate model. You are also free to assign any other prior distribution. This would allow you to arrive at any conclusion for the belief probability that the sample comes from a certain distribution.
Probability that the sample comes from a certain distribution The data either come from the specified model or they do not. There is no probability regarding this concern. The candidate model serves as a convenient yet imperfect representation of the data gene
35,874
Probability that the sample comes from a certain distribution
To answer your question, you can select from a few available tests. To quote Wikipedia on the Kolmogorov–Smirnov test where other competitive tests are also cited (placed in bold): Kolmogorov–Smirnov test (K–S test or KS test) is a nonparametric test of the equality of continuous (or discontinuous, see Section 2.2), one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution (one-sample K–S test), or to compare two samples (two-sample K–S test)...the Kolmogorov–Smirnov statistic quantifies a distance between the empirical distribution function of the sample and the cumulative distribution function of the reference distribution, or between the empirical distribution functions of two samples. The null distribution of this statistic is calculated under the null hypothesis that the sample is drawn from the reference distribution (in the one-sample case) or that the samples are drawn from the same distribution (in the two-sample case). In the one-sample case, the distribution considered under the null hypothesis may be continuous (see Section 2), purely discrete or mixed (see Section 2.2). In the two-sample case (see Section 3), the distribution considered under the null hypothesis is a continuous distribution but is otherwise unrestricted. The two-sample K–S test is one of the most useful and general nonparametric methods for comparing two samples, as it is sensitive to differences in both location and shape of the empirical cumulative distribution functions of the two samples. The Kolmogorov–Smirnov test can be modified to serve as a goodness of fit test. In the special case of testing for normality of the distribution, samples are standardized and compared with a standard normal distribution. This is equivalent to setting the mean and variance of the reference distribution equal to the sample estimates, and it is known that using these to define the specific reference distribution changes the null distribution of the test statistic (see Test with estimated parameters). Various studies have found that, even in this corrected form, the test is less powerful for testing normality than the Shapiro–Wilk test or Anderson–Darling test.[1] However, these other tests have their own disadvantages. For instance the Shapiro–Wilk test is known not to work well in samples with many identical values. I trust this is a good start. [EDIT] To answer the question as to whether one could develop an implied probability of actually being a member of a specified distribution, likely difficult in practice. To confirm my opinion, one could first compute the statistic that is the basis for say the KS test for say 10,000 pairs where both distributions are random draws from a selected single parent distribution. Tabulate the empirical distribution for the KS test statistic. Likely, accuracy of the developed probabilities would be sensitive to the test chosen, simulation run length, and the particular parent distribution. Note: this is only a Type I Error assessment. One could postulate an appropriate different distribution of concern for the second distribution to assess a Type II Error.
Probability that the sample comes from a certain distribution
To answer your question, you can select from a few available tests. To quote Wikipedia on the Kolmogorov–Smirnov test where other competitive tests are also cited (placed in bold): Kolmogorov–Smirnov
Probability that the sample comes from a certain distribution To answer your question, you can select from a few available tests. To quote Wikipedia on the Kolmogorov–Smirnov test where other competitive tests are also cited (placed in bold): Kolmogorov–Smirnov test (K–S test or KS test) is a nonparametric test of the equality of continuous (or discontinuous, see Section 2.2), one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution (one-sample K–S test), or to compare two samples (two-sample K–S test)...the Kolmogorov–Smirnov statistic quantifies a distance between the empirical distribution function of the sample and the cumulative distribution function of the reference distribution, or between the empirical distribution functions of two samples. The null distribution of this statistic is calculated under the null hypothesis that the sample is drawn from the reference distribution (in the one-sample case) or that the samples are drawn from the same distribution (in the two-sample case). In the one-sample case, the distribution considered under the null hypothesis may be continuous (see Section 2), purely discrete or mixed (see Section 2.2). In the two-sample case (see Section 3), the distribution considered under the null hypothesis is a continuous distribution but is otherwise unrestricted. The two-sample K–S test is one of the most useful and general nonparametric methods for comparing two samples, as it is sensitive to differences in both location and shape of the empirical cumulative distribution functions of the two samples. The Kolmogorov–Smirnov test can be modified to serve as a goodness of fit test. In the special case of testing for normality of the distribution, samples are standardized and compared with a standard normal distribution. This is equivalent to setting the mean and variance of the reference distribution equal to the sample estimates, and it is known that using these to define the specific reference distribution changes the null distribution of the test statistic (see Test with estimated parameters). Various studies have found that, even in this corrected form, the test is less powerful for testing normality than the Shapiro–Wilk test or Anderson–Darling test.[1] However, these other tests have their own disadvantages. For instance the Shapiro–Wilk test is known not to work well in samples with many identical values. I trust this is a good start. [EDIT] To answer the question as to whether one could develop an implied probability of actually being a member of a specified distribution, likely difficult in practice. To confirm my opinion, one could first compute the statistic that is the basis for say the KS test for say 10,000 pairs where both distributions are random draws from a selected single parent distribution. Tabulate the empirical distribution for the KS test statistic. Likely, accuracy of the developed probabilities would be sensitive to the test chosen, simulation run length, and the particular parent distribution. Note: this is only a Type I Error assessment. One could postulate an appropriate different distribution of concern for the second distribution to assess a Type II Error.
Probability that the sample comes from a certain distribution To answer your question, you can select from a few available tests. To quote Wikipedia on the Kolmogorov–Smirnov test where other competitive tests are also cited (placed in bold): Kolmogorov–Smirnov
35,875
Parsimonious Mixed Models
Yes, your understanding is correct, but it if probabily a good idea to understand that background of that paper. Following the publication of the "Keep it Maximal" paper by Barr etc al (2013), which is referenced substantially by Bates, practitioners were increasingly confronted with models that convereged with a singular fit, due to a hopelessly over-parameterised random effects structure. Just see the number of posts on here about singular fits as some evidence for that. Bates et al (2015) were specifically attempting to address this problem and I wrote an answer based on their recommendations here: How to simplify a singular random structure when reported correlations are not near +1/-1 However I don't think it is correct to say that Bates recommends starting with a maximal model and simplifying. This is the recommendation for the people who think a maximal model is a good idea in the first place. It clearly isn't when the number of estimated variance components becomes close to the number of observations, but it might be a good idea when this is not the case. For example in many observational studies it is perfectly reasonable to allow all the main exposure(s) to vary by subject. But the same can't as easily said for competing exposures and confounders. It might very well be the case that models with random slopes for these have a better fit to the data than ones without, but starting out with a fully maximal model and pruning it according to p-value thresholds of likelihood ratio tests, is in my opinion the wrong thing to do. I would start with a parsimonious model only including random slopes that I believe a priori should be allowed to vary by subject, based on domain knowledge and theory - and this would not normally include confounders and competing exposures. If that model had a singular fit then I would use the approach outlined in my answer above, but if it didn't then I would not seek to make the random structure any more complex. References: Bates, D., Kliegl, R., Vasishth, S. and Baayen, H., 2015. Parsimonious mixed models. arXiv preprint arXiv:1506.04967. https://arxiv.org/pdf/1506.04967.pdf Barr, D.J., Levy, R., Scheepers, C. and Tily, H.J., 2013. Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of memory and language, 68(3), pp.255-278. http://idiom.ucsd.edu/~rlevy/papers/barr-etal-2013-jml.pdf
Parsimonious Mixed Models
Yes, your understanding is correct, but it if probabily a good idea to understand that background of that paper. Following the publication of the "Keep it Maximal" paper by Barr etc al (2013), which i
Parsimonious Mixed Models Yes, your understanding is correct, but it if probabily a good idea to understand that background of that paper. Following the publication of the "Keep it Maximal" paper by Barr etc al (2013), which is referenced substantially by Bates, practitioners were increasingly confronted with models that convereged with a singular fit, due to a hopelessly over-parameterised random effects structure. Just see the number of posts on here about singular fits as some evidence for that. Bates et al (2015) were specifically attempting to address this problem and I wrote an answer based on their recommendations here: How to simplify a singular random structure when reported correlations are not near +1/-1 However I don't think it is correct to say that Bates recommends starting with a maximal model and simplifying. This is the recommendation for the people who think a maximal model is a good idea in the first place. It clearly isn't when the number of estimated variance components becomes close to the number of observations, but it might be a good idea when this is not the case. For example in many observational studies it is perfectly reasonable to allow all the main exposure(s) to vary by subject. But the same can't as easily said for competing exposures and confounders. It might very well be the case that models with random slopes for these have a better fit to the data than ones without, but starting out with a fully maximal model and pruning it according to p-value thresholds of likelihood ratio tests, is in my opinion the wrong thing to do. I would start with a parsimonious model only including random slopes that I believe a priori should be allowed to vary by subject, based on domain knowledge and theory - and this would not normally include confounders and competing exposures. If that model had a singular fit then I would use the approach outlined in my answer above, but if it didn't then I would not seek to make the random structure any more complex. References: Bates, D., Kliegl, R., Vasishth, S. and Baayen, H., 2015. Parsimonious mixed models. arXiv preprint arXiv:1506.04967. https://arxiv.org/pdf/1506.04967.pdf Barr, D.J., Levy, R., Scheepers, C. and Tily, H.J., 2013. Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of memory and language, 68(3), pp.255-278. http://idiom.ucsd.edu/~rlevy/papers/barr-etal-2013-jml.pdf
Parsimonious Mixed Models Yes, your understanding is correct, but it if probabily a good idea to understand that background of that paper. Following the publication of the "Keep it Maximal" paper by Barr etc al (2013), which i
35,876
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal
Let's lead off with a wonderful approximation. Here is a plot of two functions. The underlying tan curve is the graph of $\Phi,$ the standard Normal CDF. The overplotted blue curve is the graph of $\Lambda:z \to 1/(1 + \exp(-7z/4)),$ a scaled version of the logistic function. To see how well they approximate each other, here is a plot of their difference $\Phi-\Lambda$ (over a wider range): Their values never differ more than $\pm 0.015,$ less than one sixtieth of their full range (from $0$ to $1$). That's close. It means you can use one or the other as the link in a logistic regression and it will make practically no difference. ($\Lambda$ implements (up to a scale factor that will be absorbed in the coefficient estimates) the usual logit link while $\Phi$ implements the probit link.) Turn now to the question. With no loss of generality, choose units of measurement for $X$ that give it a unit variance. To emphasize this, I will call this variable $Z,$ because it has a standard Normal distribution. Let $\Phi$ be the cdf of the standard Normal distribution. Adopting conventional notation, let $Y$ be the response given by thresholding a noisy version of $\beta_0 + \beta_ 1 Z$ at a value $t$ (for "threshold," instead of the less mnemonic $c$ in the question), $$Y = \mathcal{I}\left(\beta_0 + \beta_1 Z + \sigma W \gt t\right)$$ where $W$ has a standard Normal distribution independently of $Z$ and $|\sigma|$ is the error standard deviation. With the foregoing conventions, the question concerns the case $\beta_0=0$ and $\beta_1=1,$ but it will turn out there's nothing special about these choices: we will derive a universal result. It is immediate that $Y$, conditional on $Z,$ has a Bernoulli$(p(Z))$ distribution with $$\eqalign{ p(Z) &= \Pr(Y = 1) = \Pr(\beta_0+\beta_1 Z + \sigma W \gt t) \\ &= \Pr\left(W \gt \frac{t - (\beta_0+\beta_1 Z)}{\sigma}\right) \\ &= \Phi\left(\frac{-t + (\beta_0+\beta_1 Z)}{\sigma}\right). }$$ The trick is to approximate $\Phi$ by $\Lambda.$ (Alternatively, perform your logistic regression using the probit link, which will give an exact result.) Applying the logit (the inverse of $\Lambda$) to both sides of the foregoing equation produces $$\operatorname{Logit}(p(Z)) \approx \frac{-t + (\beta_0+\beta_1 Z)}{4\sigma/7} = \frac{7(\beta_0-t)}{4\sigma} + \frac{7\beta_1}{4\sigma}Z.$$ This is the (approximate) logistic regression for the model (or, if you wish to think of it this way, of an entire population). Therefore, the logistic regression estimates from any sufficiently large random sample of this model must approximate its coefficients. (This is a well-known asymptotic property of the Maximum Likelihood procedure used to estimate those coefficients.) Writing such estimated coefficients as $\hat\beta_0$ and $\hat\beta_1,$ we find that $$-\frac{\hat\beta_0}{\hat\beta_1} \approx -\frac{7(\beta_0-t)/(4\sigma)}{7\beta_1/(4\sigma)} = \frac{t - \beta_0}{\beta_1}.$$ (It is now obvious that the potentially annoying factor of $7/4$ in the preliminary approximation is not a problem!) In the question, $\beta_0=0$ and $\beta_1=1,$ giving $$-\frac{\hat\beta_0}{\hat\beta_1} \approx t,$$ QED.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i
Let's lead off with a wonderful approximation. Here is a plot of two functions. The underlying tan curve is the graph of $\Phi,$ the standard Normal CDF. The overplotted blue curve is the graph of
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal Let's lead off with a wonderful approximation. Here is a plot of two functions. The underlying tan curve is the graph of $\Phi,$ the standard Normal CDF. The overplotted blue curve is the graph of $\Lambda:z \to 1/(1 + \exp(-7z/4)),$ a scaled version of the logistic function. To see how well they approximate each other, here is a plot of their difference $\Phi-\Lambda$ (over a wider range): Their values never differ more than $\pm 0.015,$ less than one sixtieth of their full range (from $0$ to $1$). That's close. It means you can use one or the other as the link in a logistic regression and it will make practically no difference. ($\Lambda$ implements (up to a scale factor that will be absorbed in the coefficient estimates) the usual logit link while $\Phi$ implements the probit link.) Turn now to the question. With no loss of generality, choose units of measurement for $X$ that give it a unit variance. To emphasize this, I will call this variable $Z,$ because it has a standard Normal distribution. Let $\Phi$ be the cdf of the standard Normal distribution. Adopting conventional notation, let $Y$ be the response given by thresholding a noisy version of $\beta_0 + \beta_ 1 Z$ at a value $t$ (for "threshold," instead of the less mnemonic $c$ in the question), $$Y = \mathcal{I}\left(\beta_0 + \beta_1 Z + \sigma W \gt t\right)$$ where $W$ has a standard Normal distribution independently of $Z$ and $|\sigma|$ is the error standard deviation. With the foregoing conventions, the question concerns the case $\beta_0=0$ and $\beta_1=1,$ but it will turn out there's nothing special about these choices: we will derive a universal result. It is immediate that $Y$, conditional on $Z,$ has a Bernoulli$(p(Z))$ distribution with $$\eqalign{ p(Z) &= \Pr(Y = 1) = \Pr(\beta_0+\beta_1 Z + \sigma W \gt t) \\ &= \Pr\left(W \gt \frac{t - (\beta_0+\beta_1 Z)}{\sigma}\right) \\ &= \Phi\left(\frac{-t + (\beta_0+\beta_1 Z)}{\sigma}\right). }$$ The trick is to approximate $\Phi$ by $\Lambda.$ (Alternatively, perform your logistic regression using the probit link, which will give an exact result.) Applying the logit (the inverse of $\Lambda$) to both sides of the foregoing equation produces $$\operatorname{Logit}(p(Z)) \approx \frac{-t + (\beta_0+\beta_1 Z)}{4\sigma/7} = \frac{7(\beta_0-t)}{4\sigma} + \frac{7\beta_1}{4\sigma}Z.$$ This is the (approximate) logistic regression for the model (or, if you wish to think of it this way, of an entire population). Therefore, the logistic regression estimates from any sufficiently large random sample of this model must approximate its coefficients. (This is a well-known asymptotic property of the Maximum Likelihood procedure used to estimate those coefficients.) Writing such estimated coefficients as $\hat\beta_0$ and $\hat\beta_1,$ we find that $$-\frac{\hat\beta_0}{\hat\beta_1} \approx -\frac{7(\beta_0-t)/(4\sigma)}{7\beta_1/(4\sigma)} = \frac{t - \beta_0}{\beta_1}.$$ (It is now obvious that the potentially annoying factor of $7/4$ in the preliminary approximation is not a problem!) In the question, $\beta_0=0$ and $\beta_1=1,$ giving $$-\frac{\hat\beta_0}{\hat\beta_1} \approx t,$$ QED.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i Let's lead off with a wonderful approximation. Here is a plot of two functions. The underlying tan curve is the graph of $\Phi,$ the standard Normal CDF. The overplotted blue curve is the graph of
35,877
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal
Indipendently on the distribution of $X$, if $C$ is computed in that deterministic way, estimation won't converge because there is no couple of parameters $\beta$ for which likelihood is maximized. It is easy to notice that $\hat c = -\frac{\hat \beta_0}{\hat \beta_1}$ maximises the likelihood at some middle value between last x value before $c$ and first one after it, but you have to keep $\beta_1$ fixed to observe this, and vary just $\beta_0$, because of the absence of one ML point for in the whole parametric space. I will make this clear now. Let's say we take that value $\hat c$ fixed at the point we just described, for which likelihood is maximized for any given slope $\beta_1$, and we now vary $\beta_1$, to see how likelihood varies. Mind that $\beta_0$ will vary together with $\beta_1$ to keep $\hat c$ constant. We will notice that the higher the slope is, the higher the likelihood, without convergence. This always happens when logistic regression is used in a deterministic setting and no misclassifications happen. I will add the mathematical details when I have time, but you can already verify my claims.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i
Indipendently on the distribution of $X$, if $C$ is computed in that deterministic way, estimation won't converge because there is no couple of parameters $\beta$ for which likelihood is maximized. I
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal Indipendently on the distribution of $X$, if $C$ is computed in that deterministic way, estimation won't converge because there is no couple of parameters $\beta$ for which likelihood is maximized. It is easy to notice that $\hat c = -\frac{\hat \beta_0}{\hat \beta_1}$ maximises the likelihood at some middle value between last x value before $c$ and first one after it, but you have to keep $\beta_1$ fixed to observe this, and vary just $\beta_0$, because of the absence of one ML point for in the whole parametric space. I will make this clear now. Let's say we take that value $\hat c$ fixed at the point we just described, for which likelihood is maximized for any given slope $\beta_1$, and we now vary $\beta_1$, to see how likelihood varies. Mind that $\beta_0$ will vary together with $\beta_1$ to keep $\hat c$ constant. We will notice that the higher the slope is, the higher the likelihood, without convergence. This always happens when logistic regression is used in a deterministic setting and no misclassifications happen. I will add the mathematical details when I have time, but you can already verify my claims.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i Indipendently on the distribution of $X$, if $C$ is computed in that deterministic way, estimation won't converge because there is no couple of parameters $\beta$ for which likelihood is maximized. I
35,878
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal
One way to understand the solution to the problem - the answers by carlo, whuber and comments already say a lot of this - is to re-express the logit expression as $\exp(\beta_1 (\gamma+X))\over 1+\exp(\beta_1(\gamma+X))$, where $\gamma={\beta_0\over \beta_1}$. Doing so, you can maximize the likelihood $$ \max_{\beta_1,\gamma} E\left [\mathbf{1}(X>c)\beta_1(\gamma+X)-\log[1+\exp(\beta_1(\gamma+X))] \right ] $$ Taking first order conditions with respect to $\gamma$, you get: $$ \beta_1 E\left[\mathbf{1}(X>c)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] = 0 $$ That is, conditional on the value for $\beta_1$, you'll set $\gamma$ so that the prediction errors of the logit function equal zero on average. For particular distributions of $X$ and values for $c$, the exact minimum will be $\gamma=c$. For other cases, this error minimization might choose different values for $\gamma$ as a way of minimizing the error for most observations. Now, note that if $\beta_1\rightarrow \infty$, $$ {\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \rightarrow \begin{cases} 1\ &if\ \gamma+X>0\\ 1/2\ &if\ \gamma+X=0\\ 0\ &if\ \gamma+X<0 \end{cases} $$ Then, if $\beta_1$ is picked to be high enough, the logit function will look very close to an indicator function stating that $X>-\gamma$. In such a case, the way to solve the first order condition for $\gamma$ when $\beta_1$ gets very high will be to set $\gamma\rightarrow -c$. All I have leftover here is how the likelihood function solves for $\beta_1$. For this, the first order condition with respect to $\beta_1$ will be: $$ E\left\{(\gamma+X)\left [\mathbf{1}(X>c)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] \right \} = 0 $$ Given that the term in square brackets has mean zero (from the first order condition with respect to $\gamma$), this FOC states that the "prediction error" from the logit function is uncorrelated with $\gamma+X$. Once again, if we let $\beta_1$ diverge to $\infty$, we can set the term in brackets to be arbitrarily close to zero, which will lead this expectation to be zero. If you add white noise $W|X\sim F_W(W)$ that is independent of $X$, the first order conditions become $$ \beta_1 E_X\left[1-F_W(c-X)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] = 0 \\ E_X\left\{(\gamma+X)\left [1-F_W(c-X)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] \right \} = 0 $$ Once again, the details of the approximation will depend on the distribution of $X$, the distribution of $W$ and the value of $c$. For $W\sim N(0,\sigma^2)$, the logit function can be very similar to $1-F_W(c-X)$ for the right values of $\beta_1,\gamma$. For other thicker tailed functions $F_W$, or bi-modal functions $F_W$, results might become more sensitive to the values of $c$, distribution of $X$ and distribution of $W$.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i
One way to understand the solution to the problem - the answers by carlo, whuber and comments already say a lot of this - is to re-express the logit expression as $\exp(\beta_1 (\gamma+X))\over 1+\exp
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ is normal One way to understand the solution to the problem - the answers by carlo, whuber and comments already say a lot of this - is to re-express the logit expression as $\exp(\beta_1 (\gamma+X))\over 1+\exp(\beta_1(\gamma+X))$, where $\gamma={\beta_0\over \beta_1}$. Doing so, you can maximize the likelihood $$ \max_{\beta_1,\gamma} E\left [\mathbf{1}(X>c)\beta_1(\gamma+X)-\log[1+\exp(\beta_1(\gamma+X))] \right ] $$ Taking first order conditions with respect to $\gamma$, you get: $$ \beta_1 E\left[\mathbf{1}(X>c)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] = 0 $$ That is, conditional on the value for $\beta_1$, you'll set $\gamma$ so that the prediction errors of the logit function equal zero on average. For particular distributions of $X$ and values for $c$, the exact minimum will be $\gamma=c$. For other cases, this error minimization might choose different values for $\gamma$ as a way of minimizing the error for most observations. Now, note that if $\beta_1\rightarrow \infty$, $$ {\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \rightarrow \begin{cases} 1\ &if\ \gamma+X>0\\ 1/2\ &if\ \gamma+X=0\\ 0\ &if\ \gamma+X<0 \end{cases} $$ Then, if $\beta_1$ is picked to be high enough, the logit function will look very close to an indicator function stating that $X>-\gamma$. In such a case, the way to solve the first order condition for $\gamma$ when $\beta_1$ gets very high will be to set $\gamma\rightarrow -c$. All I have leftover here is how the likelihood function solves for $\beta_1$. For this, the first order condition with respect to $\beta_1$ will be: $$ E\left\{(\gamma+X)\left [\mathbf{1}(X>c)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] \right \} = 0 $$ Given that the term in square brackets has mean zero (from the first order condition with respect to $\gamma$), this FOC states that the "prediction error" from the logit function is uncorrelated with $\gamma+X$. Once again, if we let $\beta_1$ diverge to $\infty$, we can set the term in brackets to be arbitrarily close to zero, which will lead this expectation to be zero. If you add white noise $W|X\sim F_W(W)$ that is independent of $X$, the first order conditions become $$ \beta_1 E_X\left[1-F_W(c-X)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] = 0 \\ E_X\left\{(\gamma+X)\left [1-F_W(c-X)-{\exp(\beta_1(\gamma+X))\over 1+\exp(\beta_1(\gamma+X))} \right ] \right \} = 0 $$ Once again, the details of the approximation will depend on the distribution of $X$, the distribution of $W$ and the value of $c$. For $W\sim N(0,\sigma^2)$, the logit function can be very similar to $1-F_W(c-X)$ for the right values of $\beta_1,\gamma$. For other thicker tailed functions $F_W$, or bi-modal functions $F_W$, results might become more sensitive to the values of $c$, distribution of $X$ and distribution of $W$.
Proving that logistic regression on $I(X>c)$ by $X$ itself recovers decision boundary $c$ when $X$ i One way to understand the solution to the problem - the answers by carlo, whuber and comments already say a lot of this - is to re-express the logit expression as $\exp(\beta_1 (\gamma+X))\over 1+\exp
35,879
How to choose delta parameter in Huber Loss function?
Huber loss will clip gradients to delta for residual (abs) values larger than delta. You want that when some part of your data points poorly fit the model and you would like to limit their influence. Also, clipping the grads is a common way to make optimization stable (not necessarily with huber). Set delta to the value of the residual for the data points you trust. See how the derivative is a const for abs(a)>delta import numpy as np import matplotlib.pyplot as plt def huber(a, delta): value = np.where(np.abs(a)<delta, .5*a**2, delta*(np.abs(a) - .5*delta)) deriv = np.where(np.abs(a)<delta, a, np.sign(a)*delta) return value, deriv h, d = huber(np.arange(-1, 1, .01), delta=0.2) fig, ax = plt.subplots(1) ax.plot(h, label='loss value') ax.plot(d, label='loss derivative') ax.grid(True) ax.legend()
How to choose delta parameter in Huber Loss function?
Huber loss will clip gradients to delta for residual (abs) values larger than delta. You want that when some part of your data points poorly fit the model and you would like to limit their influence.
How to choose delta parameter in Huber Loss function? Huber loss will clip gradients to delta for residual (abs) values larger than delta. You want that when some part of your data points poorly fit the model and you would like to limit their influence. Also, clipping the grads is a common way to make optimization stable (not necessarily with huber). Set delta to the value of the residual for the data points you trust. See how the derivative is a const for abs(a)>delta import numpy as np import matplotlib.pyplot as plt def huber(a, delta): value = np.where(np.abs(a)<delta, .5*a**2, delta*(np.abs(a) - .5*delta)) deriv = np.where(np.abs(a)<delta, a, np.sign(a)*delta) return value, deriv h, d = huber(np.arange(-1, 1, .01), delta=0.2) fig, ax = plt.subplots(1) ax.plot(h, label='loss value') ax.plot(d, label='loss derivative') ax.grid(True) ax.legend()
How to choose delta parameter in Huber Loss function? Huber loss will clip gradients to delta for residual (abs) values larger than delta. You want that when some part of your data points poorly fit the model and you would like to limit their influence.
35,880
How to choose delta parameter in Huber Loss function?
As Alex Kreimer said you want to set $\delta$ as a measure of spread of the inliers. Most of the time (for example in R) it is done using the MADN (median absolute deviation about the median renormalized to be efficient at the Gaussian), the other possibility is to choose $\delta=1.35$ because it is what you would choose if you inliers are standard Gaussian, this is not data driven but it is a good start. To get better results, I advise you to use Cross-Validation or other similar model selection methods to tune $\delta$ optimally.
How to choose delta parameter in Huber Loss function?
As Alex Kreimer said you want to set $\delta$ as a measure of spread of the inliers. Most of the time (for example in R) it is done using the MADN (median absolute deviation about the median renormali
How to choose delta parameter in Huber Loss function? As Alex Kreimer said you want to set $\delta$ as a measure of spread of the inliers. Most of the time (for example in R) it is done using the MADN (median absolute deviation about the median renormalized to be efficient at the Gaussian), the other possibility is to choose $\delta=1.35$ because it is what you would choose if you inliers are standard Gaussian, this is not data driven but it is a good start. To get better results, I advise you to use Cross-Validation or other similar model selection methods to tune $\delta$ optimally.
How to choose delta parameter in Huber Loss function? As Alex Kreimer said you want to set $\delta$ as a measure of spread of the inliers. Most of the time (for example in R) it is done using the MADN (median absolute deviation about the median renormali
35,881
Hypothesis testing for difference in medians vs. median difference
Data. There are some minor discrepancies (maybe from rounding) in your data table. The table below is what I get from inputting your x1 and x2. These are the values I will use: x1 x2 d [1,] 1.37 1.68 -0.31 [2,] 2.18 2.99 -0.81 [3,] 1.16 3.24 -2.08 [4,] 3.60 3.08 0.52 [5,] 2.33 2.19 0.14 Sample means and medians behave differently. The reason there needs to be a discussion here is that sample means and sample medians behave in substantially different ways. Means: If $D_i = X_{1i} - X_{2i},$ then $\bar D = \bar X_1 - \bar X_2,$ where bars designate sample means. Medians: However, as for your data, one may have $\tilde D \ne \tilde X_1 - \tilde X_2,$ where tildes designate sample medians. Paired Wilcoxon test. The point made in your link is that the paired Wilcoxon test is a essentially a one-sample signed-rank test on differences. Thus, you get the same results from the following two tests involving medians. (I'm using R.) One-sample Wilcoxon test on differences. wilcox.test(d) Wilcoxon signed rank test data: d V = 4, p-value = 0.4375 alternative hypothesis: true location is not equal to 0 Paired Wilcoxon test. wilcox.test(x1, x2, paired=T) # computes differences first Wilcoxon signed rank test data: x1 and x2 V = 4, p-value = 0.4375 alternative hypothesis: true location shift is not equal to 0 Incorrect procedure: If you forget the parameter 'paired=T' in the paired test, then R does a Mann-Whitney-Wilcoxon (rank-sum) two-sample test. The P-value is not enormously different, but it should be clear that the test below is not the paired test. wilcox.test(x1, x2) # TWO-sample test, NOT PAIRED Wilcoxon rank sum test data: x1 and x2 W = 8, p-value = 0.4206 alternative hypothesis: true location shift is not equal to 0 Graphical presentation of paired data. For much the same reasons, if you want to show a boxplot for paired data, you must make a single boxplot of differences (as at left), not two separate boxplots of for Before and After. (In showing boxplots, I am assuming that your actual data have more than five subjects. It is unusual to make boxplots of as few as five observations.) Confusion results from making separate stripcharts (dotplots) of scores Before and After because the plot does not show which Before values are paired with which After values. You might try connecting data points to show pairs. Note: For only five subjects, as in the data you show in your Question, the nonparametric Wilcoxon signed rank test would not show a significant result unless all five differences have the same sign.
Hypothesis testing for difference in medians vs. median difference
Data. There are some minor discrepancies (maybe from rounding) in your data table. The table below is what I get from inputting your x1 and x2. These are the values I will use: x1 x2 d [1
Hypothesis testing for difference in medians vs. median difference Data. There are some minor discrepancies (maybe from rounding) in your data table. The table below is what I get from inputting your x1 and x2. These are the values I will use: x1 x2 d [1,] 1.37 1.68 -0.31 [2,] 2.18 2.99 -0.81 [3,] 1.16 3.24 -2.08 [4,] 3.60 3.08 0.52 [5,] 2.33 2.19 0.14 Sample means and medians behave differently. The reason there needs to be a discussion here is that sample means and sample medians behave in substantially different ways. Means: If $D_i = X_{1i} - X_{2i},$ then $\bar D = \bar X_1 - \bar X_2,$ where bars designate sample means. Medians: However, as for your data, one may have $\tilde D \ne \tilde X_1 - \tilde X_2,$ where tildes designate sample medians. Paired Wilcoxon test. The point made in your link is that the paired Wilcoxon test is a essentially a one-sample signed-rank test on differences. Thus, you get the same results from the following two tests involving medians. (I'm using R.) One-sample Wilcoxon test on differences. wilcox.test(d) Wilcoxon signed rank test data: d V = 4, p-value = 0.4375 alternative hypothesis: true location is not equal to 0 Paired Wilcoxon test. wilcox.test(x1, x2, paired=T) # computes differences first Wilcoxon signed rank test data: x1 and x2 V = 4, p-value = 0.4375 alternative hypothesis: true location shift is not equal to 0 Incorrect procedure: If you forget the parameter 'paired=T' in the paired test, then R does a Mann-Whitney-Wilcoxon (rank-sum) two-sample test. The P-value is not enormously different, but it should be clear that the test below is not the paired test. wilcox.test(x1, x2) # TWO-sample test, NOT PAIRED Wilcoxon rank sum test data: x1 and x2 W = 8, p-value = 0.4206 alternative hypothesis: true location shift is not equal to 0 Graphical presentation of paired data. For much the same reasons, if you want to show a boxplot for paired data, you must make a single boxplot of differences (as at left), not two separate boxplots of for Before and After. (In showing boxplots, I am assuming that your actual data have more than five subjects. It is unusual to make boxplots of as few as five observations.) Confusion results from making separate stripcharts (dotplots) of scores Before and After because the plot does not show which Before values are paired with which After values. You might try connecting data points to show pairs. Note: For only five subjects, as in the data you show in your Question, the nonparametric Wilcoxon signed rank test would not show a significant result unless all five differences have the same sign.
Hypothesis testing for difference in medians vs. median difference Data. There are some minor discrepancies (maybe from rounding) in your data table. The table below is what I get from inputting your x1 and x2. These are the values I will use: x1 x2 d [1
35,882
Is the t distribution a member of the exponential family?
No, the t distribution is not an exponential family. Exponential family distributions do have existing moment generating functions, and the t distribution do not. See also Why doesn't the exponential family include all distributions?
Is the t distribution a member of the exponential family?
No, the t distribution is not an exponential family. Exponential family distributions do have existing moment generating functions, and the t distribution do not. See also Why doesn't the exponent
Is the t distribution a member of the exponential family? No, the t distribution is not an exponential family. Exponential family distributions do have existing moment generating functions, and the t distribution do not. See also Why doesn't the exponential family include all distributions?
Is the t distribution a member of the exponential family? No, the t distribution is not an exponential family. Exponential family distributions do have existing moment generating functions, and the t distribution do not. See also Why doesn't the exponent
35,883
Do I need a second validation set to select model class?
Prior to the revival of deep learning in the last few years, hyperparameter tuning used to be called model selection. The purpose of the validation set is to choose among several model candidates. It shouldn't make a difference whether these models have the same architecture with different hyperparameters or are completely different architectures. So no, you shouldn't need a second validation set.
Do I need a second validation set to select model class?
Prior to the revival of deep learning in the last few years, hyperparameter tuning used to be called model selection. The purpose of the validation set is to choose among several model candidates. It
Do I need a second validation set to select model class? Prior to the revival of deep learning in the last few years, hyperparameter tuning used to be called model selection. The purpose of the validation set is to choose among several model candidates. It shouldn't make a difference whether these models have the same architecture with different hyperparameters or are completely different architectures. So no, you shouldn't need a second validation set.
Do I need a second validation set to select model class? Prior to the revival of deep learning in the last few years, hyperparameter tuning used to be called model selection. The purpose of the validation set is to choose among several model candidates. It
35,884
Do I need a second validation set to select model class?
I am actually doing this right now too! :) I have 3 model classes, logistic, random forest and GP. My design is this (with 5-fold crossvalidation): training data set - optimize parameters and hyperparameters (not sure if we have the same definition of hyperparameters; in my case these are the length-scales for GP covariance matrix). validation data set - cross-validate models and compare them within & between classes using common test statistics I suppose this should be perfectly OK, if you have any ideas why this could be a problem let us discuss it.
Do I need a second validation set to select model class?
I am actually doing this right now too! :) I have 3 model classes, logistic, random forest and GP. My design is this (with 5-fold crossvalidation): training data set - optimize parameters and hyperpa
Do I need a second validation set to select model class? I am actually doing this right now too! :) I have 3 model classes, logistic, random forest and GP. My design is this (with 5-fold crossvalidation): training data set - optimize parameters and hyperparameters (not sure if we have the same definition of hyperparameters; in my case these are the length-scales for GP covariance matrix). validation data set - cross-validate models and compare them within & between classes using common test statistics I suppose this should be perfectly OK, if you have any ideas why this could be a problem let us discuss it.
Do I need a second validation set to select model class? I am actually doing this right now too! :) I have 3 model classes, logistic, random forest and GP. My design is this (with 5-fold crossvalidation): training data set - optimize parameters and hyperpa
35,885
How to use PCA to detect outliers?
One approach is to consider outliers those points that can not be well reconstructed using the principal vectors that you have selected. The procedure goes like this: 1.Fix two positive numbers, a and b (see the next steps for there meaning an to understand how to select them; to be refined using cross-validation). Compute PCA. Keep the principal vectors that are associated with principal values greater than a, say $v_1,v_2,..,v_k$ (this are orthonormal vectors). For each data point compute the reconstruction error using the principal vectors from step 3. For a data point x, the reconstruction error is: $e = ||x-\sum_{i=1}^{k}w_iv_i||_2$ , where $w_i = v_i^Tx$ Output as outliers those data points that have a reconstruction error greater than b. Update: The procedure capture only "direction" outliers . Additionally, before the first step, a "norm" outliers detection step can be included. This consist of computing the norms of the data points and labeling as outliers those that have a too small or too big norm. It depends on what an outlier is in your context.
How to use PCA to detect outliers?
One approach is to consider outliers those points that can not be well reconstructed using the principal vectors that you have selected. The procedure goes like this: 1.Fix two positive numbers, a and
How to use PCA to detect outliers? One approach is to consider outliers those points that can not be well reconstructed using the principal vectors that you have selected. The procedure goes like this: 1.Fix two positive numbers, a and b (see the next steps for there meaning an to understand how to select them; to be refined using cross-validation). Compute PCA. Keep the principal vectors that are associated with principal values greater than a, say $v_1,v_2,..,v_k$ (this are orthonormal vectors). For each data point compute the reconstruction error using the principal vectors from step 3. For a data point x, the reconstruction error is: $e = ||x-\sum_{i=1}^{k}w_iv_i||_2$ , where $w_i = v_i^Tx$ Output as outliers those data points that have a reconstruction error greater than b. Update: The procedure capture only "direction" outliers . Additionally, before the first step, a "norm" outliers detection step can be included. This consist of computing the norms of the data points and labeling as outliers those that have a too small or too big norm. It depends on what an outlier is in your context.
How to use PCA to detect outliers? One approach is to consider outliers those points that can not be well reconstructed using the principal vectors that you have selected. The procedure goes like this: 1.Fix two positive numbers, a and
35,886
advantages and disadvantages of IPTW vs propensity score matching?
Despite some similarities, propensity score matching (PSM) and inverse probability of treatment weighting (IPTW) behave differently, mainly because matching selects some cases/controls and discards others, while IPTW includes all study units. The scholarly literature suggests indeed that PSM and IPTW have similar accuracy in many cases, but in some specific scenarios PSM behaves better. However, in my experience when there are discrepancies between these methods, eventually the data collection approach and the study itself ends up being less credible and externally valid. In any case, you can peruse the following works on the subject (it is only a quick selection): https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5564952/ https://elischolar.library.yale.edu/cgi/viewcontent.cgi?referer=https://www.google.com/&httpsredir=1&article=1347&context=ysphtdl https://www.sciencedirect.com/science/article/pii/S073510971637036X
advantages and disadvantages of IPTW vs propensity score matching?
Despite some similarities, propensity score matching (PSM) and inverse probability of treatment weighting (IPTW) behave differently, mainly because matching selects some cases/controls and discards ot
advantages and disadvantages of IPTW vs propensity score matching? Despite some similarities, propensity score matching (PSM) and inverse probability of treatment weighting (IPTW) behave differently, mainly because matching selects some cases/controls and discards others, while IPTW includes all study units. The scholarly literature suggests indeed that PSM and IPTW have similar accuracy in many cases, but in some specific scenarios PSM behaves better. However, in my experience when there are discrepancies between these methods, eventually the data collection approach and the study itself ends up being less credible and externally valid. In any case, you can peruse the following works on the subject (it is only a quick selection): https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5564952/ https://elischolar.library.yale.edu/cgi/viewcontent.cgi?referer=https://www.google.com/&httpsredir=1&article=1347&context=ysphtdl https://www.sciencedirect.com/science/article/pii/S073510971637036X
advantages and disadvantages of IPTW vs propensity score matching? Despite some similarities, propensity score matching (PSM) and inverse probability of treatment weighting (IPTW) behave differently, mainly because matching selects some cases/controls and discards ot
35,887
advantages and disadvantages of IPTW vs propensity score matching?
The choice between propensity score matching and weighting seems to be a widely debated topic among statistical sholars. Some thoughts, after having read through many papers of infuriated statisticians: Propensity score matching Advantages: Often used, thus familiar to non-statisticians Simple and intuitive subject to subject comparison by reducing the multidimensional covariate space to one dimension Disadvantages: The imperfect balance of covariates is often ignored (two individuals with the same propensity score are considered equal while they may have a strongly different set of covariates) A measure of proximity between propensity scores may be arbitrary Some subjects have to be excluded because no match can be found and the analysis is therefore restricted to a sub-population that is not explicitly described. For a more detailed analysis by the main critics of this method: [1], [2]. Propensity score weighting / Inverse probability weighting Advantages Explicit global population (if no clipping is used) Can be easily combined with more advanced methods (see below) Disadvantages Extreme weights at the tails of the propensity score distribution increase the variance and decrease the balance between covariates Finally, both methods are subject to significant biases when the propensity score model is misspecified. Therefore, the use of doubly-robust estimators, a combination of propensity score adjustement and covariable outcome estimation, seems to be becoming standard practice [3]. This combination aims to reduce the risk of bias due to suboptimal specification of the models used to estimate the propensity score or outcome regression. The possible cost of this method to reduce bias is an increase in variance. References: King, G., & Nielsen, R. (2019). Why Propensity Scores Should Not Be Used for Matching. Political Analysis, 27(4), 435-454. doi:10.1017/pan.2019.11 Pearl, J. (2000). Causality: Models, Reasoning, and Inference. New York: Cambridge University Press. ISBN 978-0-521-77362-1. Causal Inference: What If. Miguel A. Hernán, James M. Robins. 2020.
advantages and disadvantages of IPTW vs propensity score matching?
The choice between propensity score matching and weighting seems to be a widely debated topic among statistical sholars. Some thoughts, after having read through many papers of infuriated statistician
advantages and disadvantages of IPTW vs propensity score matching? The choice between propensity score matching and weighting seems to be a widely debated topic among statistical sholars. Some thoughts, after having read through many papers of infuriated statisticians: Propensity score matching Advantages: Often used, thus familiar to non-statisticians Simple and intuitive subject to subject comparison by reducing the multidimensional covariate space to one dimension Disadvantages: The imperfect balance of covariates is often ignored (two individuals with the same propensity score are considered equal while they may have a strongly different set of covariates) A measure of proximity between propensity scores may be arbitrary Some subjects have to be excluded because no match can be found and the analysis is therefore restricted to a sub-population that is not explicitly described. For a more detailed analysis by the main critics of this method: [1], [2]. Propensity score weighting / Inverse probability weighting Advantages Explicit global population (if no clipping is used) Can be easily combined with more advanced methods (see below) Disadvantages Extreme weights at the tails of the propensity score distribution increase the variance and decrease the balance between covariates Finally, both methods are subject to significant biases when the propensity score model is misspecified. Therefore, the use of doubly-robust estimators, a combination of propensity score adjustement and covariable outcome estimation, seems to be becoming standard practice [3]. This combination aims to reduce the risk of bias due to suboptimal specification of the models used to estimate the propensity score or outcome regression. The possible cost of this method to reduce bias is an increase in variance. References: King, G., & Nielsen, R. (2019). Why Propensity Scores Should Not Be Used for Matching. Political Analysis, 27(4), 435-454. doi:10.1017/pan.2019.11 Pearl, J. (2000). Causality: Models, Reasoning, and Inference. New York: Cambridge University Press. ISBN 978-0-521-77362-1. Causal Inference: What If. Miguel A. Hernán, James M. Robins. 2020.
advantages and disadvantages of IPTW vs propensity score matching? The choice between propensity score matching and weighting seems to be a widely debated topic among statistical sholars. Some thoughts, after having read through many papers of infuriated statistician
35,888
KL divergence between gaussian and uniform distribution
The KL divergence $$ KL\left(P \middle\| Q\right) = \int \log \frac{d P}{d Q }dP $$ is only defined if the Radon-Nikodym derivative exists, which is when $P$ is dominated by $Q$ (written $P \ll Q$). This means that there can't be any sets $A$ where $P(A) > 0$ and $Q(A) = 0$, otherwise we would be dividing by zero. In your case, $p$ is the density of the uniform random variable, and $q$ is the density of the normal random variable (they are both dominated by the Lebesgue measure), so you could calculate $$ KL\left(P \middle\| Q\right) = \int \log \frac{p(x)}{q(x)}p(x)dx, $$ but you couldn't calculate $KL\left(Q \middle\| P\right)$. You can calculate $KL\left(P \middle\| Q\right)$ because there are no sets $A$ such that $\int_A p(x) dx > 0$ and $\int_A q(x) dx = 0$.
KL divergence between gaussian and uniform distribution
The KL divergence $$ KL\left(P \middle\| Q\right) = \int \log \frac{d P}{d Q }dP $$ is only defined if the Radon-Nikodym derivative exists, which is when $P$ is dominated by $Q$ (written $P \ll Q$).
KL divergence between gaussian and uniform distribution The KL divergence $$ KL\left(P \middle\| Q\right) = \int \log \frac{d P}{d Q }dP $$ is only defined if the Radon-Nikodym derivative exists, which is when $P$ is dominated by $Q$ (written $P \ll Q$). This means that there can't be any sets $A$ where $P(A) > 0$ and $Q(A) = 0$, otherwise we would be dividing by zero. In your case, $p$ is the density of the uniform random variable, and $q$ is the density of the normal random variable (they are both dominated by the Lebesgue measure), so you could calculate $$ KL\left(P \middle\| Q\right) = \int \log \frac{p(x)}{q(x)}p(x)dx, $$ but you couldn't calculate $KL\left(Q \middle\| P\right)$. You can calculate $KL\left(P \middle\| Q\right)$ because there are no sets $A$ such that $\int_A p(x) dx > 0$ and $\int_A q(x) dx = 0$.
KL divergence between gaussian and uniform distribution The KL divergence $$ KL\left(P \middle\| Q\right) = \int \log \frac{d P}{d Q }dP $$ is only defined if the Radon-Nikodym derivative exists, which is when $P$ is dominated by $Q$ (written $P \ll Q$).
35,889
KL divergence between gaussian and uniform distribution
How else can I calculate the distance of my gaussian to a 'maximum entropy' distribution if I can't use the uniform distribution? You basically answered your question, you can use the entropy of the distribution as a measure of randomness. For a Gaussian distribution, it can be computed directly from the standard standard deviation (and you could also directly use the standard deviation as a measure of randomness): $$\operatorname{H}_{p}[X] = \operatorname{E}_{p}[-\ln p(x)] = \frac{1}{2}\ln\big(2\pi\sigma^2\big)+\frac{1}{2}$$ The KL from some distribution $q$ to a uniform distribution $p$ actually contains two terms, the negative entropy of the first distribution and the cross entropy between the two distributions. Because the log probability of an unbounded uniform distribution is constant, the cross entropy is a constant: $$ \operatorname{KL}[q(x) \,\|\, p(x)] = \operatorname{E}_{q}[\ln q(x) - \ln p(x)] \\ = \operatorname{E}_{q}[\ln q(x)] - \operatorname{E}_{q}[\ln p(x)] \\ = -\operatorname{H}[q(x)] - \operatorname{E}_{q}[\mathrm{const}] \\ = -\operatorname{H}[q(x)] - \mathrm{const} $$ For categorical variables, the constant is the log probability of uniform categorical distribution, which is $\ln \frac{1}{N}=-\ln N$. For continuous variables, you can't have an unbounded uniform distribution because it would have an infinite normalizer. A trick is to instead consider an improper uniform distribution that is unnormalized, $p(x)\propto 1$.
KL divergence between gaussian and uniform distribution
How else can I calculate the distance of my gaussian to a 'maximum entropy' distribution if I can't use the uniform distribution? You basically answered your question, you can use the entropy of the
KL divergence between gaussian and uniform distribution How else can I calculate the distance of my gaussian to a 'maximum entropy' distribution if I can't use the uniform distribution? You basically answered your question, you can use the entropy of the distribution as a measure of randomness. For a Gaussian distribution, it can be computed directly from the standard standard deviation (and you could also directly use the standard deviation as a measure of randomness): $$\operatorname{H}_{p}[X] = \operatorname{E}_{p}[-\ln p(x)] = \frac{1}{2}\ln\big(2\pi\sigma^2\big)+\frac{1}{2}$$ The KL from some distribution $q$ to a uniform distribution $p$ actually contains two terms, the negative entropy of the first distribution and the cross entropy between the two distributions. Because the log probability of an unbounded uniform distribution is constant, the cross entropy is a constant: $$ \operatorname{KL}[q(x) \,\|\, p(x)] = \operatorname{E}_{q}[\ln q(x) - \ln p(x)] \\ = \operatorname{E}_{q}[\ln q(x)] - \operatorname{E}_{q}[\ln p(x)] \\ = -\operatorname{H}[q(x)] - \operatorname{E}_{q}[\mathrm{const}] \\ = -\operatorname{H}[q(x)] - \mathrm{const} $$ For categorical variables, the constant is the log probability of uniform categorical distribution, which is $\ln \frac{1}{N}=-\ln N$. For continuous variables, you can't have an unbounded uniform distribution because it would have an infinite normalizer. A trick is to instead consider an improper uniform distribution that is unnormalized, $p(x)\propto 1$.
KL divergence between gaussian and uniform distribution How else can I calculate the distance of my gaussian to a 'maximum entropy' distribution if I can't use the uniform distribution? You basically answered your question, you can use the entropy of the
35,890
Can small SGD batch size lead to faster overfitting?
Using "epoch" on the x-axis to compare "speed" of convergence while comparing different batch sizes makes no sense since the number of weight updates per epoch depends on the batch size. When using smaller batches, the learning algorithm performs more weight updates per epoch and it naturally it seems to converge faster. In your image, the gray curve (batch size = 32) starts decreasing (overfitting) around epoch 40. The orange curve (batch size = 128, four times more) seems to peak around epoch 160—four times later, which is exactly after the same number of weight updates. Possibly you might see similar peak on the blue curve around epoch 320. Generally, smaller batches lead to noisier gradient estimates and are better capable to escape poor local minima and prevent overfitting. On the other hand, tiny batches may be too noisy for good learning. In the end, it is just another hyperparameter that one needs to tune on the specific dataset. In your case, it does not seem to play a big role, since all curves peak around the same accuracy, and early stopping should lead to the same performance regardless of the batch size.
Can small SGD batch size lead to faster overfitting?
Using "epoch" on the x-axis to compare "speed" of convergence while comparing different batch sizes makes no sense since the number of weight updates per epoch depends on the batch size. When using sm
Can small SGD batch size lead to faster overfitting? Using "epoch" on the x-axis to compare "speed" of convergence while comparing different batch sizes makes no sense since the number of weight updates per epoch depends on the batch size. When using smaller batches, the learning algorithm performs more weight updates per epoch and it naturally it seems to converge faster. In your image, the gray curve (batch size = 32) starts decreasing (overfitting) around epoch 40. The orange curve (batch size = 128, four times more) seems to peak around epoch 160—four times later, which is exactly after the same number of weight updates. Possibly you might see similar peak on the blue curve around epoch 320. Generally, smaller batches lead to noisier gradient estimates and are better capable to escape poor local minima and prevent overfitting. On the other hand, tiny batches may be too noisy for good learning. In the end, it is just another hyperparameter that one needs to tune on the specific dataset. In your case, it does not seem to play a big role, since all curves peak around the same accuracy, and early stopping should lead to the same performance regardless of the batch size.
Can small SGD batch size lead to faster overfitting? Using "epoch" on the x-axis to compare "speed" of convergence while comparing different batch sizes makes no sense since the number of weight updates per epoch depends on the batch size. When using sm
35,891
How to approximate the student-t CDF at a point without the hypergeometric function?
The Wikipedia article on the $t$ distribution helpfully informs us that If $X$ has a Student's t-distribution with degree of freedom $\nu$ then one can obtain a Beta distribution: $$\frac {\nu }{\nu +X^{2}}\sim \mathrm {B} \left({\frac {1}{2}},{\frac {\nu }{2}}\right).$$ Equivalently, $1-\nu/(\nu + X^2) = X^2/(\nu + X^2)$ has a $B\left(\frac{\nu}{2},\frac{1}{2}\right)$ distribution. This is referred to as a "symmetry relation" below. Here is an implementation in a C-like language. extern FLOAT tcum(FLOAT t, DEGREES m) { if (m == INFINITY) return zcum(t); assert(m > 0); if (t == 0.0) return 0.5; if (t < 0.0) return 0.5 * (1.0 - inbet(t*t / (m + t*t), 1, m)); else return 0.5 * (1.0 + inbet(t*t / (m + t*t), 1, m)); } (It falls back to the standard Normal CDF zcum for arbitrarily large $\nu$.) A good implementation of the Beta cumulative distribution inbet is given in Numerical Recipes, where inbet(x,a,b) is the incomplete Beta function $I_x(a,b).$ Long ago I ported their Fortran version of the function to C (cleaning up a few problems along the way). It wasn't too painful. It's a continued fraction expansion. Numerical Recipes remarks This continued fraction converges rapidly for $x\lt (a+1)/(a+b+2),$ taking in the worst case $O\left(\sqrt{\max(a,b)}\right)$ iterations. But for $x \gt (a+1)/(a+b+2)$ we can just use the symmetry relation $I_x(a,b)=1-I_{1-x}(b,a)$ to obtain an equivalent computation where the continued fraction will also converge rapidly. You can see this strategy in the extensively tested version below. You don't need the details of the header (.h) files to port this. You do need enough experience writing scientific software to know that you must test your port thoroughly and to know how to do the testing and debugging. (Reproducing extensive tables of the function to perfect accuracy is one approach. It helps to graph the results, too: that catches all kinds of erratic errors that can afflict numerical programs.) /* * INBET.C * * The incomplete beta function with parameters a/2 and b/2, i.e., * integral, 0 to x, of * pow(t,(FLOAT)a/2-1)*pow(1-t,(FLOAT)b/2-1), * divided by beta(a/2,b/2). * x must be >= 0, <= 1, a, b must be > 0. */ #include <math.h> #include <float.h> #include "stats.h" static FLOAT betacf(FLOAT a, FLOAT b, FLOAT x); /*--------------------------------------------------------------------*/ extern FLOAT inbet(FLOAT x, DEGREES a, DEGREES b) { FLOAT bt; assert((FLOAT)0.0<=x && x<=(FLOAT)1.0); if (x==0.0 || x==1.0) { bt = 0.0; } else { bt = exp( lngamma2(a+b)-lngamma2(a)-lngamma2(b) + 0.5 * (a*log(x) + b*log(1.0-x)) ); } if (x < (a+2.0) / (a+b+4.0)) return 2 * bt * betacf((FLOAT)a/2.0, (FLOAT)b/2.0, x) / a; else return 1.0 - 2 * bt * betacf((FLOAT)b/2.0, (FLOAT)a/2.0, 1.0-x) / b; } /* inbet() */ /*--------------------------------------------------------------------*/ FLOAT betacf(FLOAT a, FLOAT b, FLOAT x) { FLOAT am = 1.0, bm = 1.0, az = 1.0, qab = a+b, qap = a+1.0, qam = a-1.0, bz = 1.0 - qab * x / qap; FLOAT em, tem, d, ap, bp, app, bpp, aold; long m=1; do { em = m; tem = em+em; d = em * (b-m) * x / ((qam+tem) * (a+tem)); ap = az + d*am; bp = bz + d*bm; d = -(a+em) * (qab+em) * x / ((a+tem) * (qap+tem)); app = ap + d*az; bpp = bp + d*bz; aold = az; am = ap/bpp; bm = bp/bpp; az = app/bpp; bz = 1.0; } while (fabs(az-aold) >= stat_eps * fabs(az) && m++ <= _stat_iter); if (m > _stat_iter) _stat_err = _ERR_STAT_EPS; return az; } /* betacf() */ /* eof inbet.c */
How to approximate the student-t CDF at a point without the hypergeometric function?
The Wikipedia article on the $t$ distribution helpfully informs us that If $X$ has a Student's t-distribution with degree of freedom $\nu$ then one can obtain a Beta distribution: $$\frac {\nu }{\nu
How to approximate the student-t CDF at a point without the hypergeometric function? The Wikipedia article on the $t$ distribution helpfully informs us that If $X$ has a Student's t-distribution with degree of freedom $\nu$ then one can obtain a Beta distribution: $$\frac {\nu }{\nu +X^{2}}\sim \mathrm {B} \left({\frac {1}{2}},{\frac {\nu }{2}}\right).$$ Equivalently, $1-\nu/(\nu + X^2) = X^2/(\nu + X^2)$ has a $B\left(\frac{\nu}{2},\frac{1}{2}\right)$ distribution. This is referred to as a "symmetry relation" below. Here is an implementation in a C-like language. extern FLOAT tcum(FLOAT t, DEGREES m) { if (m == INFINITY) return zcum(t); assert(m > 0); if (t == 0.0) return 0.5; if (t < 0.0) return 0.5 * (1.0 - inbet(t*t / (m + t*t), 1, m)); else return 0.5 * (1.0 + inbet(t*t / (m + t*t), 1, m)); } (It falls back to the standard Normal CDF zcum for arbitrarily large $\nu$.) A good implementation of the Beta cumulative distribution inbet is given in Numerical Recipes, where inbet(x,a,b) is the incomplete Beta function $I_x(a,b).$ Long ago I ported their Fortran version of the function to C (cleaning up a few problems along the way). It wasn't too painful. It's a continued fraction expansion. Numerical Recipes remarks This continued fraction converges rapidly for $x\lt (a+1)/(a+b+2),$ taking in the worst case $O\left(\sqrt{\max(a,b)}\right)$ iterations. But for $x \gt (a+1)/(a+b+2)$ we can just use the symmetry relation $I_x(a,b)=1-I_{1-x}(b,a)$ to obtain an equivalent computation where the continued fraction will also converge rapidly. You can see this strategy in the extensively tested version below. You don't need the details of the header (.h) files to port this. You do need enough experience writing scientific software to know that you must test your port thoroughly and to know how to do the testing and debugging. (Reproducing extensive tables of the function to perfect accuracy is one approach. It helps to graph the results, too: that catches all kinds of erratic errors that can afflict numerical programs.) /* * INBET.C * * The incomplete beta function with parameters a/2 and b/2, i.e., * integral, 0 to x, of * pow(t,(FLOAT)a/2-1)*pow(1-t,(FLOAT)b/2-1), * divided by beta(a/2,b/2). * x must be >= 0, <= 1, a, b must be > 0. */ #include <math.h> #include <float.h> #include "stats.h" static FLOAT betacf(FLOAT a, FLOAT b, FLOAT x); /*--------------------------------------------------------------------*/ extern FLOAT inbet(FLOAT x, DEGREES a, DEGREES b) { FLOAT bt; assert((FLOAT)0.0<=x && x<=(FLOAT)1.0); if (x==0.0 || x==1.0) { bt = 0.0; } else { bt = exp( lngamma2(a+b)-lngamma2(a)-lngamma2(b) + 0.5 * (a*log(x) + b*log(1.0-x)) ); } if (x < (a+2.0) / (a+b+4.0)) return 2 * bt * betacf((FLOAT)a/2.0, (FLOAT)b/2.0, x) / a; else return 1.0 - 2 * bt * betacf((FLOAT)b/2.0, (FLOAT)a/2.0, 1.0-x) / b; } /* inbet() */ /*--------------------------------------------------------------------*/ FLOAT betacf(FLOAT a, FLOAT b, FLOAT x) { FLOAT am = 1.0, bm = 1.0, az = 1.0, qab = a+b, qap = a+1.0, qam = a-1.0, bz = 1.0 - qab * x / qap; FLOAT em, tem, d, ap, bp, app, bpp, aold; long m=1; do { em = m; tem = em+em; d = em * (b-m) * x / ((qam+tem) * (a+tem)); ap = az + d*am; bp = bz + d*bm; d = -(a+em) * (qab+em) * x / ((a+tem) * (qap+tem)); app = ap + d*az; bpp = bp + d*bz; aold = az; am = ap/bpp; bm = bp/bpp; az = app/bpp; bz = 1.0; } while (fabs(az-aold) >= stat_eps * fabs(az) && m++ <= _stat_iter); if (m > _stat_iter) _stat_err = _ERR_STAT_EPS; return az; } /* betacf() */ /* eof inbet.c */
How to approximate the student-t CDF at a point without the hypergeometric function? The Wikipedia article on the $t$ distribution helpfully informs us that If $X$ has a Student's t-distribution with degree of freedom $\nu$ then one can obtain a Beta distribution: $$\frac {\nu }{\nu
35,892
KNN parameter tuning with cross validation: score draw
This problem occurs when you have a small test set, which can cause multiple models to tie, by achieving the same number of correct predictions. The method you said first should do. Because in CV each model sees each training sample once, I'd consider it unlikely for your 3 models to have the same accuracy. If this persists, it is safe to choose at random (I'd go for 3 because it is the middle element)
KNN parameter tuning with cross validation: score draw
This problem occurs when you have a small test set, which can cause multiple models to tie, by achieving the same number of correct predictions. The method you said first should do. Because in CV each
KNN parameter tuning with cross validation: score draw This problem occurs when you have a small test set, which can cause multiple models to tie, by achieving the same number of correct predictions. The method you said first should do. Because in CV each model sees each training sample once, I'd consider it unlikely for your 3 models to have the same accuracy. If this persists, it is safe to choose at random (I'd go for 3 because it is the middle element)
KNN parameter tuning with cross validation: score draw This problem occurs when you have a small test set, which can cause multiple models to tie, by achieving the same number of correct predictions. The method you said first should do. Because in CV each
35,893
KNN parameter tuning with cross validation: score draw
Occam's principle suggest's that you should go for the simplest model possible. So you should go for that one. But to get a better idea of the model's generalization, i would suggest you to use nested cross validation.
KNN parameter tuning with cross validation: score draw
Occam's principle suggest's that you should go for the simplest model possible. So you should go for that one. But to get a better idea of the model's generalization, i would suggest you to use nested
KNN parameter tuning with cross validation: score draw Occam's principle suggest's that you should go for the simplest model possible. So you should go for that one. But to get a better idea of the model's generalization, i would suggest you to use nested cross validation.
KNN parameter tuning with cross validation: score draw Occam's principle suggest's that you should go for the simplest model possible. So you should go for that one. But to get a better idea of the model's generalization, i would suggest you to use nested
35,894
Is there a universal approximation theorem for monotone functions?
I am not sure if a single hidden layer is sufficient, but it can be shown that if your input is in $\mathbb{R}^k$, you will need at most $k$ hidden layers. See Theorem 3.1 in https://ieeexplore.ieee.org/document/5443743 Theorem 3.1: For any continuous monotone nondecreasing function $f : K \rightarrow \mathbb{R}$, where $K$ is a compact subset of $\mathbb{R}^k$, there exists a feedforward neural network with at most $k$ hidden layers, positive weights, and output $O$ such that $|f(\mathbf{x}) - O_{\mathbf{x}}| < \varepsilon$, for any $\mathbf{x} \in K$ and $\varepsilon > 0$.
Is there a universal approximation theorem for monotone functions?
I am not sure if a single hidden layer is sufficient, but it can be shown that if your input is in $\mathbb{R}^k$, you will need at most $k$ hidden layers. See Theorem 3.1 in https://ieeexplore.ieee.o
Is there a universal approximation theorem for monotone functions? I am not sure if a single hidden layer is sufficient, but it can be shown that if your input is in $\mathbb{R}^k$, you will need at most $k$ hidden layers. See Theorem 3.1 in https://ieeexplore.ieee.org/document/5443743 Theorem 3.1: For any continuous monotone nondecreasing function $f : K \rightarrow \mathbb{R}$, where $K$ is a compact subset of $\mathbb{R}^k$, there exists a feedforward neural network with at most $k$ hidden layers, positive weights, and output $O$ such that $|f(\mathbf{x}) - O_{\mathbf{x}}| < \varepsilon$, for any $\mathbf{x} \in K$ and $\varepsilon > 0$.
Is there a universal approximation theorem for monotone functions? I am not sure if a single hidden layer is sufficient, but it can be shown that if your input is in $\mathbb{R}^k$, you will need at most $k$ hidden layers. See Theorem 3.1 in https://ieeexplore.ieee.o
35,895
Are products of exchangeable RVs exchangeable?
The product does not have to be exchangeable. The following counterexample will show what can go wrong and why. We will specify the joint distributions $P_1$ of $(X_1,Y_1)$ and $P_2$ of $(X_2,Y_2)$ and assume each of these bivariate random variables is independent. Thus, the $X_i$ will be exchangeable provided they are identically distributed, and likewise for the $Y_i.$ All variables will be Bernoulli variables: by definition, their probabilities will be concentrated on the set $\{0,1\}.$ Let $P_1(0,0) = P_1(1,1) = 1/2$ and $P_2(x,y)=1/4$ for $x,y\in\{0,1\}.$ Since all marginal distributions are Bernoulli$(1/2),$ the marginal exchangeability assumption holds. But now compute that $\Pr(X_1Y_1=0) = 1/2$ and $\Pr(X_2Y_2=0)=3/4,$ showing the products have different distributions (and therefore cannot be exchangeable). This shows that the joint distribution matters. However, the joint distributions could differ, yet the products could be exchangeable, so exchangeability of the bivariate random variables $(X_i,Y_i)$, albeit a sufficient condition for exchangeability of the products $X_iY_i,$ is not a necessary condition. An example of this is given by ternary variables with values in $\{-1,0,1\}.$ For instance, consider the following probabilities: $$P_1((-1,y)) = 1/6\quad(y\in\{-1,0,1\});\quad P_1((1,-1)) = P_1((1,1))=1/4$$ and $$P_2((x,y)) = P_1((-x,y)).$$ It is straightforward to check that the marginal distributions of the $X_i$ assign equal probabilities of $1/2$ to $\pm 1,$ the marginal distributions of the $Y_i$ have probability vectors $(5/12, 1/6, 5/12),$ and that the distribution of the $X_iY_i$ is the same as that of the $Y_i.$ Note that the $(X_i,Y_i)$ have different distributions, though, because $$P_1((-1,0)) = 1/6 \ne 0 = P_2((-1,0)).$$ Thus the $X_i$ are exchangeable, the $Y_i$ are exchangeable, the $X_iY_i$ are exchangeable, but the $(X_i,Y_i)$ are not exchangeable.
Are products of exchangeable RVs exchangeable?
The product does not have to be exchangeable. The following counterexample will show what can go wrong and why. We will specify the joint distributions $P_1$ of $(X_1,Y_1)$ and $P_2$ of $(X_2,Y_2)$ a
Are products of exchangeable RVs exchangeable? The product does not have to be exchangeable. The following counterexample will show what can go wrong and why. We will specify the joint distributions $P_1$ of $(X_1,Y_1)$ and $P_2$ of $(X_2,Y_2)$ and assume each of these bivariate random variables is independent. Thus, the $X_i$ will be exchangeable provided they are identically distributed, and likewise for the $Y_i.$ All variables will be Bernoulli variables: by definition, their probabilities will be concentrated on the set $\{0,1\}.$ Let $P_1(0,0) = P_1(1,1) = 1/2$ and $P_2(x,y)=1/4$ for $x,y\in\{0,1\}.$ Since all marginal distributions are Bernoulli$(1/2),$ the marginal exchangeability assumption holds. But now compute that $\Pr(X_1Y_1=0) = 1/2$ and $\Pr(X_2Y_2=0)=3/4,$ showing the products have different distributions (and therefore cannot be exchangeable). This shows that the joint distribution matters. However, the joint distributions could differ, yet the products could be exchangeable, so exchangeability of the bivariate random variables $(X_i,Y_i)$, albeit a sufficient condition for exchangeability of the products $X_iY_i,$ is not a necessary condition. An example of this is given by ternary variables with values in $\{-1,0,1\}.$ For instance, consider the following probabilities: $$P_1((-1,y)) = 1/6\quad(y\in\{-1,0,1\});\quad P_1((1,-1)) = P_1((1,1))=1/4$$ and $$P_2((x,y)) = P_1((-x,y)).$$ It is straightforward to check that the marginal distributions of the $X_i$ assign equal probabilities of $1/2$ to $\pm 1,$ the marginal distributions of the $Y_i$ have probability vectors $(5/12, 1/6, 5/12),$ and that the distribution of the $X_iY_i$ is the same as that of the $Y_i.$ Note that the $(X_i,Y_i)$ have different distributions, though, because $$P_1((-1,0)) = 1/6 \ne 0 = P_2((-1,0)).$$ Thus the $X_i$ are exchangeable, the $Y_i$ are exchangeable, the $X_iY_i$ are exchangeable, but the $(X_i,Y_i)$ are not exchangeable.
Are products of exchangeable RVs exchangeable? The product does not have to be exchangeable. The following counterexample will show what can go wrong and why. We will specify the joint distributions $P_1$ of $(X_1,Y_1)$ and $P_2$ of $(X_2,Y_2)$ a
35,896
Are products of exchangeable RVs exchangeable?
No. Suppose that the sample space consists of three equally likely outomes for which $X$ takes values of $$(1,0,0), (0,1,0), (0,0,1)$$ and for which $Y$ takes values of $$(1,0,0), (0,0,1), (0,1,0).$$ Then $X_1,X_2,X_3$ are exchangeable and so are $Y_1,Y_2,Y_3$. But the corresponding values of $Z=(X_1 Y_1,\dots, X_3 Y_3)$ are $$ (1,0,0),(0,0,0),(0,0,0) $$ so clearly $Z_1,Z_2,Z_3$ are not exchangeable.
Are products of exchangeable RVs exchangeable?
No. Suppose that the sample space consists of three equally likely outomes for which $X$ takes values of $$(1,0,0), (0,1,0), (0,0,1)$$ and for which $Y$ takes values of $$(1,0,0), (0,0,1), (0,1,0).$$
Are products of exchangeable RVs exchangeable? No. Suppose that the sample space consists of three equally likely outomes for which $X$ takes values of $$(1,0,0), (0,1,0), (0,0,1)$$ and for which $Y$ takes values of $$(1,0,0), (0,0,1), (0,1,0).$$ Then $X_1,X_2,X_3$ are exchangeable and so are $Y_1,Y_2,Y_3$. But the corresponding values of $Z=(X_1 Y_1,\dots, X_3 Y_3)$ are $$ (1,0,0),(0,0,0),(0,0,0) $$ so clearly $Z_1,Z_2,Z_3$ are not exchangeable.
Are products of exchangeable RVs exchangeable? No. Suppose that the sample space consists of three equally likely outomes for which $X$ takes values of $$(1,0,0), (0,1,0), (0,0,1)$$ and for which $Y$ takes values of $$(1,0,0), (0,0,1), (0,1,0).$$
35,897
McDonald's Omega: Assumptions, Coefficients and Interpretation
The topic is old, but the questions interesting, so I would like to include some of available information regarding some questions. Statistical requirements/assumptions underlying Omega: Omega and omega hierarchical are based on parameter estimates (i.e., estimates of factor loadings and factor variances) that are derived for a certain CFA model. Hence, two vital statistical requirements need to be fulfilled: (1) Proper interpretation of omega and omega hierarchical requires that the target model fits the empirical data well (2) Parameter estimates need to be precise Brunner, Nagy, Wilhelm, 2012 Rule of thumb regarding sample size, or a ratio between variables and observations that should be considered? Similarly, the sample size should follow the CFA sample size definition, using preferably simulation methods, as those enabled by R simsem package. sample size needs to be sufficiently large to obtain trustworthy estimates of model parameters (Yang & Green, 2010).5 In general, a larger sample size is always better, and a sample size of N 200 allows proper estimation of model parameters (e.g., nonnegative variances of subtest-specific factors) under a large variety of conditions (Boomsma & Hoogland, 2001). There is also growing consensus that the required sample size depends on the properties of the model investigated and the data to be analyzed: A higher ratio of measures per factor and higher factor loadings may compensate for smaller sample size (Marsh, Hau, Balla, & Grayson, 1998; Yang & Green, 2010). Thus, methodologists strongly encourage applied researchers to conduct Monte Carlo studies of the target CFA models to determine the required sample size (L. K. Muthén & Muthén, 2002).Brunner, Nagy, Wilhelm, 2012 An interesting reference for this discussion is available on: Brunner M, Nagy G, Wilhelm O. A tutorial on hierarchically structured constructs. J Pers. 2012;80(4):796-846. doi:10.1111/j.1467-6494.2011.00749.x
McDonald's Omega: Assumptions, Coefficients and Interpretation
The topic is old, but the questions interesting, so I would like to include some of available information regarding some questions. Statistical requirements/assumptions underlying Omega: Omega and om
McDonald's Omega: Assumptions, Coefficients and Interpretation The topic is old, but the questions interesting, so I would like to include some of available information regarding some questions. Statistical requirements/assumptions underlying Omega: Omega and omega hierarchical are based on parameter estimates (i.e., estimates of factor loadings and factor variances) that are derived for a certain CFA model. Hence, two vital statistical requirements need to be fulfilled: (1) Proper interpretation of omega and omega hierarchical requires that the target model fits the empirical data well (2) Parameter estimates need to be precise Brunner, Nagy, Wilhelm, 2012 Rule of thumb regarding sample size, or a ratio between variables and observations that should be considered? Similarly, the sample size should follow the CFA sample size definition, using preferably simulation methods, as those enabled by R simsem package. sample size needs to be sufficiently large to obtain trustworthy estimates of model parameters (Yang & Green, 2010).5 In general, a larger sample size is always better, and a sample size of N 200 allows proper estimation of model parameters (e.g., nonnegative variances of subtest-specific factors) under a large variety of conditions (Boomsma & Hoogland, 2001). There is also growing consensus that the required sample size depends on the properties of the model investigated and the data to be analyzed: A higher ratio of measures per factor and higher factor loadings may compensate for smaller sample size (Marsh, Hau, Balla, & Grayson, 1998; Yang & Green, 2010). Thus, methodologists strongly encourage applied researchers to conduct Monte Carlo studies of the target CFA models to determine the required sample size (L. K. Muthén & Muthén, 2002).Brunner, Nagy, Wilhelm, 2012 An interesting reference for this discussion is available on: Brunner M, Nagy G, Wilhelm O. A tutorial on hierarchically structured constructs. J Pers. 2012;80(4):796-846. doi:10.1111/j.1467-6494.2011.00749.x
McDonald's Omega: Assumptions, Coefficients and Interpretation The topic is old, but the questions interesting, so I would like to include some of available information regarding some questions. Statistical requirements/assumptions underlying Omega: Omega and om
35,898
McDonald's Omega: Assumptions, Coefficients and Interpretation
A useful source that alleviated some of my confusion around this topic was: McNeish, Daniel. 2018. “Thanks Coefficient Alpha, We’ll Take It from Here.” Psychological Methods 23(3):412–33. doi: 10.1037/met0000144. One important note is that the Omega-function in the psych (refereed to as Revelle’s omega total. by the paper) package is different to many other implementations.
McDonald's Omega: Assumptions, Coefficients and Interpretation
A useful source that alleviated some of my confusion around this topic was: McNeish, Daniel. 2018. “Thanks Coefficient Alpha, We’ll Take It from Here.” Psychological Methods 23(3):412–33. doi: 10.103
McDonald's Omega: Assumptions, Coefficients and Interpretation A useful source that alleviated some of my confusion around this topic was: McNeish, Daniel. 2018. “Thanks Coefficient Alpha, We’ll Take It from Here.” Psychological Methods 23(3):412–33. doi: 10.1037/met0000144. One important note is that the Omega-function in the psych (refereed to as Revelle’s omega total. by the paper) package is different to many other implementations.
McDonald's Omega: Assumptions, Coefficients and Interpretation A useful source that alleviated some of my confusion around this topic was: McNeish, Daniel. 2018. “Thanks Coefficient Alpha, We’ll Take It from Here.” Psychological Methods 23(3):412–33. doi: 10.103
35,899
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"?
I still fail to see why all of the remaining actions after some point in an episode are guaranteed to be greedy, It is not the case, there is no guarantee of any number of steps being greedy. The very last step can be non-greedy. In that case, then the only return that will get assessed in off-policy Monte Carlo control is for $S_{T-1}, A_{T-1}$. That step does get processed (and in general the last exploratory step in any trajectory), because you don't apply importance sampling to the action in the $Q(s,a)$ that is being updated. In general, there will be a number of steps prior to the end of the episode where the behaviour policy took an action that was valid in the target policy. The number will be anything from 0 to the length of the entire episode. Distribution of this number depends on the overlap between behaviour policy and target policy. An $\epsilon$-greedy behaviour policy learning a greedy target policy may have relatively long series where the actions are greedy, depending on value of $\epsilon$. or how these greedy actions belong to the only time steps from which the above method can learn This is due to weighted importance sampling. The importance sampling ratio, applied on each time step with target policy $\pi$ and behaviour policy $b$ is: $$\frac{\pi(a|s)}{b(a|s)}$$ If the target policy is the greedy policy over current $Q(s,a)$ (which it is in the given Monte Carlo Control algorithm), then any exploration will insert a multiplication by 0 into the importance sampling ratio (because $\pi(a|s)=0$ for exploring actions), making the adjusted return estimate zero regardless of any other values. In addition, the weighting when taking the mean also uses this factor, so there will be no change to any $(s,a)$ pair with a later exploratory action. If you used non-weighted importance sampling, then in theory you do need to add these zeros into the mean Q estimates, because the denominator for the average return is the number of visits to each $(s,a)$. This adding of zeroes counters the over-estimates made when the trajectory from that point on is greedy (and multiplied by a factor of $\frac{1}{(1-\epsilon + \frac{\epsilon}{|\mathcal{A}|})^{T-t-1}}$ for example if you are using $\epsilon$-greedy). In a sense then it is Monte Carlo Control with weighted importance sampling which has this limitation (of only learning from tails of episodes). However, un-weighted importance sampling is not learning much, it is just learning a correction to its over-estimates elsewhere. And in general weighted importance sampling is preferred due to lower variance.
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"?
I still fail to see why all of the remaining actions after some point in an episode are guaranteed to be greedy, It is not the case, there is no guarantee of any number of steps being greedy. The ve
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"? I still fail to see why all of the remaining actions after some point in an episode are guaranteed to be greedy, It is not the case, there is no guarantee of any number of steps being greedy. The very last step can be non-greedy. In that case, then the only return that will get assessed in off-policy Monte Carlo control is for $S_{T-1}, A_{T-1}$. That step does get processed (and in general the last exploratory step in any trajectory), because you don't apply importance sampling to the action in the $Q(s,a)$ that is being updated. In general, there will be a number of steps prior to the end of the episode where the behaviour policy took an action that was valid in the target policy. The number will be anything from 0 to the length of the entire episode. Distribution of this number depends on the overlap between behaviour policy and target policy. An $\epsilon$-greedy behaviour policy learning a greedy target policy may have relatively long series where the actions are greedy, depending on value of $\epsilon$. or how these greedy actions belong to the only time steps from which the above method can learn This is due to weighted importance sampling. The importance sampling ratio, applied on each time step with target policy $\pi$ and behaviour policy $b$ is: $$\frac{\pi(a|s)}{b(a|s)}$$ If the target policy is the greedy policy over current $Q(s,a)$ (which it is in the given Monte Carlo Control algorithm), then any exploration will insert a multiplication by 0 into the importance sampling ratio (because $\pi(a|s)=0$ for exploring actions), making the adjusted return estimate zero regardless of any other values. In addition, the weighting when taking the mean also uses this factor, so there will be no change to any $(s,a)$ pair with a later exploratory action. If you used non-weighted importance sampling, then in theory you do need to add these zeros into the mean Q estimates, because the denominator for the average return is the number of visits to each $(s,a)$. This adding of zeroes counters the over-estimates made when the trajectory from that point on is greedy (and multiplied by a factor of $\frac{1}{(1-\epsilon + \frac{\epsilon}{|\mathcal{A}|})^{T-t-1}}$ for example if you are using $\epsilon$-greedy). In a sense then it is Monte Carlo Control with weighted importance sampling which has this limitation (of only learning from tails of episodes). However, un-weighted importance sampling is not learning much, it is just learning a correction to its over-estimates elsewhere. And in general weighted importance sampling is preferred due to lower variance.
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"? I still fail to see why all of the remaining actions after some point in an episode are guaranteed to be greedy, It is not the case, there is no guarantee of any number of steps being greedy. The ve
35,900
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"?
short Lets say you recorded the following episode: $$s_1, a_1^o, r_1,\quad s_2, a_2^o, r_2,\quad s_3, a_3^o, r_3,\quad s_4, a_4^p, r_4,\quad s_5, a_5^p, r_5,\quad s_6, a_6^p, r_6 $$ $a^o$ is an off-policy or non-greedy action and $a^p$ is the best action according to the current policy (greedy action). If you learn from $a^p_4$, you improve your model for $Q(s, a^p)$ concerning actions according to the current policy. If you learn from $a^o_3$ you improve you model for $Q(s, a^o)$. This is the understanding of what happens if you choose an off-policy action. Most likely the rest score $r_3 + r_4 + r_5 + r_6$ will be lower. But in a few cases not - this is when you learn a new tactics. If you learn from $a^o_1$, you will most likely have a very low rest-score, as $r_1$, $r_2$ and $r_3$ are on average lower then if acting according to the current policy. For this reason, your learning will just confirm the current policy. Even if $a_1^o$ was a brilliant action, probably $a_2^o$ and $a_3^o$ were not and $\sum\limits_{t \geq 1} r_t$ is smaller compared to a purely greedy episode. Hence, the algorithm can not see the brilliance of what he tried at $t=1$. detailed explanation Your algorithm relies on two ingredients to find the optimal $Q(s,a)$, i.e. $Q^*(s,a)$: A good estimate of the final score based on the current policy $\pi$ A good estimate of what would happen in a state $s$, when the next action would be off-policy and all / most further steps would be on-policy. Ingredient 2 ensures, that new actions are tried, which eventually improves the current policy. This is the reason you use non-greedy actions. Otherwise, $Q(s, a)$ would only give you great predictions if $a$ is an action according to the current policy ($a=\pi(s)$) and horrible predictions for all other possible actions ($a\in A \backslash \{\pi(s)\}$). This corresponds to learning from the tail of an episode. But this is not to be confused with learning from sequences of random actions! Your algorithm learns backwards, i.e. starting with the last rewards and propagating this information step-wise forward to earlier times. If you try to learn from a state $s_{t=7}$ and a lot of off-policy actions follow later at $t \gt 7$, then the corresponding Q-value will be very low, as (most likely) you did a lot of unfavorable actions. Hence, the learning of your algorithms will be: I stick to my (non-optimal) policy for all early stages of the game. For the reason you do not (or just slowly) learn from early portions of the game if non-greedy actions are common.
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"?
short Lets say you recorded the following episode: $$s_1, a_1^o, r_1,\quad s_2, a_2^o, r_2,\quad s_3, a_3^o, r_3,\quad s_4, a_4^p, r_4,\quad s_5, a_5^p, r_5,\quad s_6, a_6^p, r_6 $$ $a^o$ is an of
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"? short Lets say you recorded the following episode: $$s_1, a_1^o, r_1,\quad s_2, a_2^o, r_2,\quad s_3, a_3^o, r_3,\quad s_4, a_4^p, r_4,\quad s_5, a_5^p, r_5,\quad s_6, a_6^p, r_6 $$ $a^o$ is an off-policy or non-greedy action and $a^p$ is the best action according to the current policy (greedy action). If you learn from $a^p_4$, you improve your model for $Q(s, a^p)$ concerning actions according to the current policy. If you learn from $a^o_3$ you improve you model for $Q(s, a^o)$. This is the understanding of what happens if you choose an off-policy action. Most likely the rest score $r_3 + r_4 + r_5 + r_6$ will be lower. But in a few cases not - this is when you learn a new tactics. If you learn from $a^o_1$, you will most likely have a very low rest-score, as $r_1$, $r_2$ and $r_3$ are on average lower then if acting according to the current policy. For this reason, your learning will just confirm the current policy. Even if $a_1^o$ was a brilliant action, probably $a_2^o$ and $a_3^o$ were not and $\sum\limits_{t \geq 1} r_t$ is smaller compared to a purely greedy episode. Hence, the algorithm can not see the brilliance of what he tried at $t=1$. detailed explanation Your algorithm relies on two ingredients to find the optimal $Q(s,a)$, i.e. $Q^*(s,a)$: A good estimate of the final score based on the current policy $\pi$ A good estimate of what would happen in a state $s$, when the next action would be off-policy and all / most further steps would be on-policy. Ingredient 2 ensures, that new actions are tried, which eventually improves the current policy. This is the reason you use non-greedy actions. Otherwise, $Q(s, a)$ would only give you great predictions if $a$ is an action according to the current policy ($a=\pi(s)$) and horrible predictions for all other possible actions ($a\in A \backslash \{\pi(s)\}$). This corresponds to learning from the tail of an episode. But this is not to be confused with learning from sequences of random actions! Your algorithm learns backwards, i.e. starting with the last rewards and propagating this information step-wise forward to earlier times. If you try to learn from a state $s_{t=7}$ and a lot of off-policy actions follow later at $t \gt 7$, then the corresponding Q-value will be very low, as (most likely) you did a lot of unfavorable actions. Hence, the learning of your algorithms will be: I stick to my (non-optimal) policy for all early stages of the game. For the reason you do not (or just slowly) learn from early portions of the game if non-greedy actions are common.
Why does Off-Policy Monte Carlo Control only learn from the "Tails of Episodes"? short Lets say you recorded the following episode: $$s_1, a_1^o, r_1,\quad s_2, a_2^o, r_2,\quad s_3, a_3^o, r_3,\quad s_4, a_4^p, r_4,\quad s_5, a_5^p, r_5,\quad s_6, a_6^p, r_6 $$ $a^o$ is an of