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
26,101
"Good" classifier destroyed my Precision-Recall curve. What happened?
The best way to evaluate a model is to look at how it will be used in the real world and develop a cost function. As an aside, for example, there is too much emphasis on r squared but many believe it is a useless statistic. So do not get hung up on any one statistic. I suspect that your answer is an example of the accuracy paradox. https://en.m.wikipedia.org/wiki/Accuracy_paradox Recall (also known as sensitivity aka true positive rate) is the fraction of relevant instances that are retrieved. tpr = tp / ( tp + fn ) Precision (aka positive predictive value) is the fraction of retrieved instances that are relevant. ppv = tp / (tp + fp) Let's say you have a very imbalanced set of 99 positives and one negative. Let's say a model is trained in which the model says everything is positive. tp = 99 fp = 1 ppv becomes 0.99 Clearly a junk model despite the "good" positive predictive value. I recommend building a training set that is more balanced either through oversampling or undersampling. After the model is built then use a validation set that the keeps the original imbalance and build a performance chart on that.
"Good" classifier destroyed my Precision-Recall curve. What happened?
The best way to evaluate a model is to look at how it will be used in the real world and develop a cost function. As an aside, for example, there is too much emphasis on r squared but many believe it
"Good" classifier destroyed my Precision-Recall curve. What happened? The best way to evaluate a model is to look at how it will be used in the real world and develop a cost function. As an aside, for example, there is too much emphasis on r squared but many believe it is a useless statistic. So do not get hung up on any one statistic. I suspect that your answer is an example of the accuracy paradox. https://en.m.wikipedia.org/wiki/Accuracy_paradox Recall (also known as sensitivity aka true positive rate) is the fraction of relevant instances that are retrieved. tpr = tp / ( tp + fn ) Precision (aka positive predictive value) is the fraction of retrieved instances that are relevant. ppv = tp / (tp + fp) Let's say you have a very imbalanced set of 99 positives and one negative. Let's say a model is trained in which the model says everything is positive. tp = 99 fp = 1 ppv becomes 0.99 Clearly a junk model despite the "good" positive predictive value. I recommend building a training set that is more balanced either through oversampling or undersampling. After the model is built then use a validation set that the keeps the original imbalance and build a performance chart on that.
"Good" classifier destroyed my Precision-Recall curve. What happened? The best way to evaluate a model is to look at how it will be used in the real world and develop a cost function. As an aside, for example, there is too much emphasis on r squared but many believe it
26,102
Conditional Mean in Linear Regression
It's important to be precise in these situations, and distinguish between the data model, and the data itself. One way to think about linear regression is that we hypothesize the following relationship on the unknowable statistical process that generated the data we do have $$ E[Y \mid X] = \beta_0 + X \beta $$ Beta is an unknown constant at this point, so we are just setting down a hypothesis on what we believe the shape of the relationship is like. Then, given the data, we use some method to determine what $\beta$ should be so that the hypothesized relationship is likely to generate the data we do have (maximum likelihood being very popular). Even without knowing $\beta$, we can manipulate the relationship to learn some things about the consequences of our assumptions $$ E[Y] = E[E[Y \mid X]] = \beta_0 + \beta E[X] = \beta_0 + \beta E[X] $$ Now, the distribution of $X$ is generally not part of our structural assumptions in regression, so, in general, this is as far as we can go. Oftentimes, we will center our data for $X$, which imposes the constraint $E[X] = 0$ on our model. In this case, we can derive $$ E[Y] = \beta_0 $$ This is why, for example this book recommends centering predictors (in some situations) so that the model intercept is interpretable. Now, my question is how is this related to the sample average of y? If you fit the model by least squares, and you have centered the predictor $x$, then the model intercept is the sample average. Geometrically, the least squares line must pass through the center of mass of the data $(\bar x, \bar y)$. When you have centered $x$, $\bar x = 0$, so the line passes through $(0, \bar y)$. If you plug these values into the model equation, you get $\beta_0 = \bar y$. Algebraically, the least squares equation is is $(X^t X) \vec{\beta} = X^t y$. If you think about the matrix $X$, the first column is all ones (the intercept column), and since $x$ is centered, this intercept column is orthogonal to the data column. This means that the first row of $X^t X$ looks like $(N, 0)$ (where $N$ is the number of data points). Then first component of the left hand side is $N\beta_0$. On the right hand side, the first component is $\sum_i y_i$. Equating them, you get the result $\beta_0 = \bar y$. It is also true that the mean of the predictions is equal to $\bar y$. As these are the estimated conditional means (by assumption), this gives you a relationship like the one you seek. To see this, just observe that the predictions are $X \vec{\beta}$, and group the least squares equation as $$ X^t (X \vec{\beta}) = X^t y $$ Now use a similar argument to what I did above.
Conditional Mean in Linear Regression
It's important to be precise in these situations, and distinguish between the data model, and the data itself. One way to think about linear regression is that we hypothesize the following relationsh
Conditional Mean in Linear Regression It's important to be precise in these situations, and distinguish between the data model, and the data itself. One way to think about linear regression is that we hypothesize the following relationship on the unknowable statistical process that generated the data we do have $$ E[Y \mid X] = \beta_0 + X \beta $$ Beta is an unknown constant at this point, so we are just setting down a hypothesis on what we believe the shape of the relationship is like. Then, given the data, we use some method to determine what $\beta$ should be so that the hypothesized relationship is likely to generate the data we do have (maximum likelihood being very popular). Even without knowing $\beta$, we can manipulate the relationship to learn some things about the consequences of our assumptions $$ E[Y] = E[E[Y \mid X]] = \beta_0 + \beta E[X] = \beta_0 + \beta E[X] $$ Now, the distribution of $X$ is generally not part of our structural assumptions in regression, so, in general, this is as far as we can go. Oftentimes, we will center our data for $X$, which imposes the constraint $E[X] = 0$ on our model. In this case, we can derive $$ E[Y] = \beta_0 $$ This is why, for example this book recommends centering predictors (in some situations) so that the model intercept is interpretable. Now, my question is how is this related to the sample average of y? If you fit the model by least squares, and you have centered the predictor $x$, then the model intercept is the sample average. Geometrically, the least squares line must pass through the center of mass of the data $(\bar x, \bar y)$. When you have centered $x$, $\bar x = 0$, so the line passes through $(0, \bar y)$. If you plug these values into the model equation, you get $\beta_0 = \bar y$. Algebraically, the least squares equation is is $(X^t X) \vec{\beta} = X^t y$. If you think about the matrix $X$, the first column is all ones (the intercept column), and since $x$ is centered, this intercept column is orthogonal to the data column. This means that the first row of $X^t X$ looks like $(N, 0)$ (where $N$ is the number of data points). Then first component of the left hand side is $N\beta_0$. On the right hand side, the first component is $\sum_i y_i$. Equating them, you get the result $\beta_0 = \bar y$. It is also true that the mean of the predictions is equal to $\bar y$. As these are the estimated conditional means (by assumption), this gives you a relationship like the one you seek. To see this, just observe that the predictions are $X \vec{\beta}$, and group the least squares equation as $$ X^t (X \vec{\beta}) = X^t y $$ Now use a similar argument to what I did above.
Conditional Mean in Linear Regression It's important to be precise in these situations, and distinguish between the data model, and the data itself. One way to think about linear regression is that we hypothesize the following relationsh
26,103
Conditional Mean in Linear Regression
To get the unconditional mean (or marginal mean) of Y, the distribution of X is needed when the mean of Y depends on X as in your question. If you do not know and cannot estimate the distribution of X, it is impossible to derive the unconditional mean of Y.
Conditional Mean in Linear Regression
To get the unconditional mean (or marginal mean) of Y, the distribution of X is needed when the mean of Y depends on X as in your question. If you do not know and cannot estimate the distribution of X
Conditional Mean in Linear Regression To get the unconditional mean (or marginal mean) of Y, the distribution of X is needed when the mean of Y depends on X as in your question. If you do not know and cannot estimate the distribution of X, it is impossible to derive the unconditional mean of Y.
Conditional Mean in Linear Regression To get the unconditional mean (or marginal mean) of Y, the distribution of X is needed when the mean of Y depends on X as in your question. If you do not know and cannot estimate the distribution of X
26,104
Single layer NeuralNetwork with ReLU activation equal to SVM?
Maybe what makes you think of ReLU is the hinge loss $E = max(1-ty,0)$ of SVMs, but the loss does not restrict the output activation function to be non-negative (ReLU). For the network loss to be in the same form as SVMs, we can just remove any non-linear activation functions off the output layer, and use the hinge loss for backpropagation. Moreover, if we replace the hinge loss with $E = ln (1 + exp(−ty))$ (which looks like a smooth version of hinge loss), then we'll be doing logistic regression as typical sigmoid + cross-entropy networks. It can be thought of as moving the sigmoid function from the output layer to the loss. So in terms of loss functions, SVMs and logistic regression are pretty close, though SVMs use a very different algorithm for training and inference based on support vectors. There's a nice discussion on the relation of SVM and logistic regression in section 7.1.2 of the book Pattern Recognition and Machine Learning.
Single layer NeuralNetwork with ReLU activation equal to SVM?
Maybe what makes you think of ReLU is the hinge loss $E = max(1-ty,0)$ of SVMs, but the loss does not restrict the output activation function to be non-negative (ReLU). For the network loss to be in t
Single layer NeuralNetwork with ReLU activation equal to SVM? Maybe what makes you think of ReLU is the hinge loss $E = max(1-ty,0)$ of SVMs, but the loss does not restrict the output activation function to be non-negative (ReLU). For the network loss to be in the same form as SVMs, we can just remove any non-linear activation functions off the output layer, and use the hinge loss for backpropagation. Moreover, if we replace the hinge loss with $E = ln (1 + exp(−ty))$ (which looks like a smooth version of hinge loss), then we'll be doing logistic regression as typical sigmoid + cross-entropy networks. It can be thought of as moving the sigmoid function from the output layer to the loss. So in terms of loss functions, SVMs and logistic regression are pretty close, though SVMs use a very different algorithm for training and inference based on support vectors. There's a nice discussion on the relation of SVM and logistic regression in section 7.1.2 of the book Pattern Recognition and Machine Learning.
Single layer NeuralNetwork with ReLU activation equal to SVM? Maybe what makes you think of ReLU is the hinge loss $E = max(1-ty,0)$ of SVMs, but the loss does not restrict the output activation function to be non-negative (ReLU). For the network loss to be in t
26,105
Choosing Random Forests' parameters
Random forests have the reputation of being relatively easy to tune. This is because they only have a few hyperparameters, and aren't overly sensitive to the particular values they take. Tuning the hyperparameters can often increase generalization performance somewhat. Tree size can be controlled in different ways depending on the implementation, including the maximum depth, maximum number of nodes, and minimum number of points per leaf node. Larger trees can fit more complex functions, but also increase the ability to overfit. Some implementations don't impose any restrictions by default, and grow trees fully. Tuning tree size can improve performance by balancing between over- and underfitting. Number of features to consider per split. Each time a node is split, a random subset of features is considered, and the best is selected to perform the split. Considering more features increases the chance of finding a better split. But, it also increases the correlation between trees, increasing the variance of the overall model. Recommended default values are the square root of the total number of features for classification problems, and 1/3 the total number for regression problems. As with tree size, it may be possible to increase performance by tuning. Number of trees. Increasing the number of trees in the forest decreases the variance of the overall model, and doesn't contribute to overfitting. From the standpoint of generalization performance, using more trees is therefore better. But, there are diminishing returns, and adding trees increases the computational burden. Therefore, it's best to fit some large number of trees while remaining within the computational budget. Several hundred is typically a good choice, but it may depend on the problem. Tuning isn't really needed. But, it's possible to monitor generalization performance while sequentially adding new trees to the model, then stop when performance plateaus. Choosing hyperparameters Tuning random forest hyperparameters uses the same general procedure as other models: Explore possible hyperparameter values using some search algorithm. For each set of hyperparameter values, train the model and estimate its generalization performance. Choose the hyperparameters that optimize this estimate. Finally, estimate the generalization performance of the final, tuned model on an independent data set. For many models, this procedure often involves splitting the data into training, validation, and test sets, using holdout or nested cross validation. However, random forests have a unique, convenient property: bootstrapping is used to fit the individual trees, which readily yields the out-of-bag (OOB) error. This is an unbiased estimate of the error on future data, and can therefore take the place of the validation or test set error. This leaves more data available for training, and is computationally cheaper than nested cross validation. See this post for more information. Grid search is probably the most popular search algorithm for hyperparameter optimization. Random search can be faster in some situations. I mention more about this (and some other hyperparameter optimization issues) here. Fancier algorithms (e.g. Bayesian optimization) are also possible.
Choosing Random Forests' parameters
Random forests have the reputation of being relatively easy to tune. This is because they only have a few hyperparameters, and aren't overly sensitive to the particular values they take. Tuning the hy
Choosing Random Forests' parameters Random forests have the reputation of being relatively easy to tune. This is because they only have a few hyperparameters, and aren't overly sensitive to the particular values they take. Tuning the hyperparameters can often increase generalization performance somewhat. Tree size can be controlled in different ways depending on the implementation, including the maximum depth, maximum number of nodes, and minimum number of points per leaf node. Larger trees can fit more complex functions, but also increase the ability to overfit. Some implementations don't impose any restrictions by default, and grow trees fully. Tuning tree size can improve performance by balancing between over- and underfitting. Number of features to consider per split. Each time a node is split, a random subset of features is considered, and the best is selected to perform the split. Considering more features increases the chance of finding a better split. But, it also increases the correlation between trees, increasing the variance of the overall model. Recommended default values are the square root of the total number of features for classification problems, and 1/3 the total number for regression problems. As with tree size, it may be possible to increase performance by tuning. Number of trees. Increasing the number of trees in the forest decreases the variance of the overall model, and doesn't contribute to overfitting. From the standpoint of generalization performance, using more trees is therefore better. But, there are diminishing returns, and adding trees increases the computational burden. Therefore, it's best to fit some large number of trees while remaining within the computational budget. Several hundred is typically a good choice, but it may depend on the problem. Tuning isn't really needed. But, it's possible to monitor generalization performance while sequentially adding new trees to the model, then stop when performance plateaus. Choosing hyperparameters Tuning random forest hyperparameters uses the same general procedure as other models: Explore possible hyperparameter values using some search algorithm. For each set of hyperparameter values, train the model and estimate its generalization performance. Choose the hyperparameters that optimize this estimate. Finally, estimate the generalization performance of the final, tuned model on an independent data set. For many models, this procedure often involves splitting the data into training, validation, and test sets, using holdout or nested cross validation. However, random forests have a unique, convenient property: bootstrapping is used to fit the individual trees, which readily yields the out-of-bag (OOB) error. This is an unbiased estimate of the error on future data, and can therefore take the place of the validation or test set error. This leaves more data available for training, and is computationally cheaper than nested cross validation. See this post for more information. Grid search is probably the most popular search algorithm for hyperparameter optimization. Random search can be faster in some situations. I mention more about this (and some other hyperparameter optimization issues) here. Fancier algorithms (e.g. Bayesian optimization) are also possible.
Choosing Random Forests' parameters Random forests have the reputation of being relatively easy to tune. This is because they only have a few hyperparameters, and aren't overly sensitive to the particular values they take. Tuning the hy
26,106
Choosing Random Forests' parameters
Randomized and grid search are possibilities, http://scikit-learn.org/stable/auto_examples/model_selection/randomized_search.html Bayesian methods are suggested as well.
Choosing Random Forests' parameters
Randomized and grid search are possibilities, http://scikit-learn.org/stable/auto_examples/model_selection/randomized_search.html Bayesian methods are suggested as well.
Choosing Random Forests' parameters Randomized and grid search are possibilities, http://scikit-learn.org/stable/auto_examples/model_selection/randomized_search.html Bayesian methods are suggested as well.
Choosing Random Forests' parameters Randomized and grid search are possibilities, http://scikit-learn.org/stable/auto_examples/model_selection/randomized_search.html Bayesian methods are suggested as well.
26,107
How do I calculate the confidence interval of an ICC?
A straightforward way to calculate a confidence interval would be to create a bootstrapped distribution, then obtain the relevant quantiles from that distribution. This can be done as a parametric or nonparametric bootstrap, depending on what assumptions you're comfortable with. Generally, if you accept a Normal distribution for the random effects, a parametric bootstrap is also appropriate. Since you're using R, the lme4 package offers a very nice parametric bootstrap function, bootMer() to calculate a bootstrapped distribution of any statistic of interest derived from a random effects model. The parametric method is fully implemented, which simulates the model of interest using new values of the random effects with each iteration. New values are drawn from a Normal distribution using parameters derived from the mixed model. See the documentation in bootMer() for some detail on control over what effects get bootstrapped. Set your own number of iterations, but 1000+ is a good rule of thumb. To calculate this in R, you need to fit the random effects model and pass a function to bootMer() that calculates the statistic of interest. An example implementation is below: Example Code using R #Make some mocked data library(lme4) library(reshape2) set.seed(2024) #For the Bell Riots id <- factor(seq(1, 15)) id.mu <- rnorm(15, 10, 5) mydat <- NULL for (a in 1:length(id)){ score <- rnorm(2, id.mu[a], 3) id.fr <- data.frame(id=id[a], score1=score[1], score2=score[2]) mydat <- rbind(mydat, id.fr) } mydat <- melt(mydat, id.vars='id', value.name='score') #Create function to calculate ICC from fitted model calc.icc <- function(y) { sumy <- summary(y) (sumy$varcor$id[1]) / (sumy$varcor$id[1] + sumy$sigma^2) } #Fit the random effects model and calculate the ICC mymod <- lmer(score ~ 1 + (1|id), data=mydat) summary(mymod) calc.icc(mymod) #Calculate the bootstrap distribution boot.icc <- bootMer(mymod, calc.icc, nsim=1000) #Draw from the bootstrap distribution the usual 95% upper and lower confidence limits quantile(boot.icc$t, c(0.025, 0.975))
How do I calculate the confidence interval of an ICC?
A straightforward way to calculate a confidence interval would be to create a bootstrapped distribution, then obtain the relevant quantiles from that distribution. This can be done as a parametric or
How do I calculate the confidence interval of an ICC? A straightforward way to calculate a confidence interval would be to create a bootstrapped distribution, then obtain the relevant quantiles from that distribution. This can be done as a parametric or nonparametric bootstrap, depending on what assumptions you're comfortable with. Generally, if you accept a Normal distribution for the random effects, a parametric bootstrap is also appropriate. Since you're using R, the lme4 package offers a very nice parametric bootstrap function, bootMer() to calculate a bootstrapped distribution of any statistic of interest derived from a random effects model. The parametric method is fully implemented, which simulates the model of interest using new values of the random effects with each iteration. New values are drawn from a Normal distribution using parameters derived from the mixed model. See the documentation in bootMer() for some detail on control over what effects get bootstrapped. Set your own number of iterations, but 1000+ is a good rule of thumb. To calculate this in R, you need to fit the random effects model and pass a function to bootMer() that calculates the statistic of interest. An example implementation is below: Example Code using R #Make some mocked data library(lme4) library(reshape2) set.seed(2024) #For the Bell Riots id <- factor(seq(1, 15)) id.mu <- rnorm(15, 10, 5) mydat <- NULL for (a in 1:length(id)){ score <- rnorm(2, id.mu[a], 3) id.fr <- data.frame(id=id[a], score1=score[1], score2=score[2]) mydat <- rbind(mydat, id.fr) } mydat <- melt(mydat, id.vars='id', value.name='score') #Create function to calculate ICC from fitted model calc.icc <- function(y) { sumy <- summary(y) (sumy$varcor$id[1]) / (sumy$varcor$id[1] + sumy$sigma^2) } #Fit the random effects model and calculate the ICC mymod <- lmer(score ~ 1 + (1|id), data=mydat) summary(mymod) calc.icc(mymod) #Calculate the bootstrap distribution boot.icc <- bootMer(mymod, calc.icc, nsim=1000) #Draw from the bootstrap distribution the usual 95% upper and lower confidence limits quantile(boot.icc$t, c(0.025, 0.975))
How do I calculate the confidence interval of an ICC? A straightforward way to calculate a confidence interval would be to create a bootstrapped distribution, then obtain the relevant quantiles from that distribution. This can be done as a parametric or
26,108
How do I calculate the confidence interval of an ICC?
I had the same need, here's another solution that I ended up with using the irr package to bootstrap this more easily. (And less clever too, but if it can help future users ...) I know the package gives you a confidence interval as well as the ICC package but if you're bothered because of the distribution and need a bootstrap: #create the matrix needed for your task matrix <- select(dataframe, var1, var2) #you need to define the model, type and unit according to the question you're asking, here's for the example irr:icc(matrix, model ="twoway", type = "agreement", unit = "single") #New fuction, [7] is to get the value we want (icc in this case) icc.boot <- function(data,x) {irr::icc(data[x,], model ="twoway", type = "agreement", unit = "single")[[7]]} #bootstsrap distribution with 10 000 samples in this example boot <- boot(matrix,icc.boot, 10000) # get the confidence interval quantile(boot$t,c(0.025,0.975)) # If you're unsure of the number of samples to choose, you can get a look of the distribution of the bootstrap hist(boot) I hope it helps.
How do I calculate the confidence interval of an ICC?
I had the same need, here's another solution that I ended up with using the irr package to bootstrap this more easily. (And less clever too, but if it can help future users ...) I know the package giv
How do I calculate the confidence interval of an ICC? I had the same need, here's another solution that I ended up with using the irr package to bootstrap this more easily. (And less clever too, but if it can help future users ...) I know the package gives you a confidence interval as well as the ICC package but if you're bothered because of the distribution and need a bootstrap: #create the matrix needed for your task matrix <- select(dataframe, var1, var2) #you need to define the model, type and unit according to the question you're asking, here's for the example irr:icc(matrix, model ="twoway", type = "agreement", unit = "single") #New fuction, [7] is to get the value we want (icc in this case) icc.boot <- function(data,x) {irr::icc(data[x,], model ="twoway", type = "agreement", unit = "single")[[7]]} #bootstsrap distribution with 10 000 samples in this example boot <- boot(matrix,icc.boot, 10000) # get the confidence interval quantile(boot$t,c(0.025,0.975)) # If you're unsure of the number of samples to choose, you can get a look of the distribution of the bootstrap hist(boot) I hope it helps.
How do I calculate the confidence interval of an ICC? I had the same need, here's another solution that I ended up with using the irr package to bootstrap this more easily. (And less clever too, but if it can help future users ...) I know the package giv
26,109
Understanding Hazard Function Values Exceeding 1
The hazard is indeed a rate. It is the expected number of events a person can expect per time unit conditional on being at risk, i.e. not having died before. Say we are studying the time until you get the flu [influenza] , and we measured time in months and we got a hazard rate of .10, that is, a person is expected to get the flu .10 times per month assuming the hazard remains constant during that month. We could just as well measure time in decades (120 months), and we would get a hazard rate of 12, i.e. a person is expected to get flu 12 times per decade. These are just different ways of saying the exact same thing. This is easy to see with something like the flu, which you can easily get multiple times. It is a bit harder to see when we talk about dying, which typically happens only once. But that is a substantive problem: from a statistical point of view the expectation could still be larger than 1, which means you are unlikely to survive a unit of time.
Understanding Hazard Function Values Exceeding 1
The hazard is indeed a rate. It is the expected number of events a person can expect per time unit conditional on being at risk, i.e. not having died before. Say we are studying the time until you get
Understanding Hazard Function Values Exceeding 1 The hazard is indeed a rate. It is the expected number of events a person can expect per time unit conditional on being at risk, i.e. not having died before. Say we are studying the time until you get the flu [influenza] , and we measured time in months and we got a hazard rate of .10, that is, a person is expected to get the flu .10 times per month assuming the hazard remains constant during that month. We could just as well measure time in decades (120 months), and we would get a hazard rate of 12, i.e. a person is expected to get flu 12 times per decade. These are just different ways of saying the exact same thing. This is easy to see with something like the flu, which you can easily get multiple times. It is a bit harder to see when we talk about dying, which typically happens only once. But that is a substantive problem: from a statistical point of view the expectation could still be larger than 1, which means you are unlikely to survive a unit of time.
Understanding Hazard Function Values Exceeding 1 The hazard is indeed a rate. It is the expected number of events a person can expect per time unit conditional on being at risk, i.e. not having died before. Say we are studying the time until you get
26,110
Understanding Hazard Function Values Exceeding 1
This is perhaps best understood by looking at the exponential (time to a single event) distribution with a constant hazard rate $\lambda $, there the probability of an event by time $t$ is $1-e^{-\lambda t}$. So it is always $\in [0,1] $. In contrast the Poisson distribution is the corresponding distribution for recurring events, where the expected number of events seen in time $t $ is $t\times \lambda $.
Understanding Hazard Function Values Exceeding 1
This is perhaps best understood by looking at the exponential (time to a single event) distribution with a constant hazard rate $\lambda $, there the probability of an event by time $t$ is $1-e^{-\lam
Understanding Hazard Function Values Exceeding 1 This is perhaps best understood by looking at the exponential (time to a single event) distribution with a constant hazard rate $\lambda $, there the probability of an event by time $t$ is $1-e^{-\lambda t}$. So it is always $\in [0,1] $. In contrast the Poisson distribution is the corresponding distribution for recurring events, where the expected number of events seen in time $t $ is $t\times \lambda $.
Understanding Hazard Function Values Exceeding 1 This is perhaps best understood by looking at the exponential (time to a single event) distribution with a constant hazard rate $\lambda $, there the probability of an event by time $t$ is $1-e^{-\lam
26,111
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered?
The proper analog of univariate moments in a multivariate setting is to view the exponent $\mathbf{k} = (k_1, k_2, \ldots, k_n)$ as a vector, too. The exponential notation with vector bases and vector exponents is a shorthand for the product, $$\mathbf{y}^\mathbf{k} = y_1^{k_1} y_2 ^{k_2} \cdots y_n^{k_n}.$$ For any such vector $\mathbf{k}$, the (raw) $\mathbf{k}^\text{th}$ moment of the random variable $\mathbf{Y}$ is defined to be $$\mu_\mathbf{k} = \mathbb{E}\left(\mathbf{Y}^\mathbf{k}\right).$$ To motivate such a definition, consider a univariate moment of a linear function of $\mathbf{Y}$: $$\mathbb{E}\left(\left(\lambda_1 Y_1 + \cdots + \lambda_n Y_n\right)^m\right) = \sum_\mathbf{k} \binom{m}{\mathbf{k}}\lambda^\mathbf{k} \mu_\mathbf{k}$$ where the sum occurs over all $\mathbf{k}$ whose components are whole non-negative numbers summing to $m$ and $\binom{m}{\mathbf{k}} = m!/(k_1!k_2!\cdots k_n!)$ are the multinomial coefficients. The appearance of the multivariate moments on the right hand side shows why they are natural and important generalizations of the univariate moments. These show up all the time. For instance, the covariance between $Y_i$ and $Y_j$ is none other than $$\text{Cov}(Y_i, Y_j) = \mathbb{E}(Y_i Y_j)- \mathbb{E}(Y_i)\mathbb{E}(Y_j) = \mu_{\mathbf{k}_i + \mathbf{k}_j} - \mu_{\mathbf{k}_i}\mu_{\mathbf{k}_j}$$ where $\mathbf{k}_i$ and $\mathbf{k}_j$ are the indicator vectors with zeros in all but one place and a one in the indicated location. (The same formula elegantly yields the variance of $Y_i$ when $i=j$.) There are natural generalizations of all univariate moment concepts to the multivariate setting: a moment generating function, cumulants, a cumulant generating function, central moments, a characteristic function, and algebraic and analytical relationships among them all. Reference Alan Stuart and J. Keith Ord, Kendall's Advanced Theory of Statistics, Fifth Edition. Oxford University Press, 1987: Volume I, Chapter 3, Moments and Cumulants.
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered?
The proper analog of univariate moments in a multivariate setting is to view the exponent $\mathbf{k} = (k_1, k_2, \ldots, k_n)$ as a vector, too. The exponential notation with vector bases and vecto
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered? The proper analog of univariate moments in a multivariate setting is to view the exponent $\mathbf{k} = (k_1, k_2, \ldots, k_n)$ as a vector, too. The exponential notation with vector bases and vector exponents is a shorthand for the product, $$\mathbf{y}^\mathbf{k} = y_1^{k_1} y_2 ^{k_2} \cdots y_n^{k_n}.$$ For any such vector $\mathbf{k}$, the (raw) $\mathbf{k}^\text{th}$ moment of the random variable $\mathbf{Y}$ is defined to be $$\mu_\mathbf{k} = \mathbb{E}\left(\mathbf{Y}^\mathbf{k}\right).$$ To motivate such a definition, consider a univariate moment of a linear function of $\mathbf{Y}$: $$\mathbb{E}\left(\left(\lambda_1 Y_1 + \cdots + \lambda_n Y_n\right)^m\right) = \sum_\mathbf{k} \binom{m}{\mathbf{k}}\lambda^\mathbf{k} \mu_\mathbf{k}$$ where the sum occurs over all $\mathbf{k}$ whose components are whole non-negative numbers summing to $m$ and $\binom{m}{\mathbf{k}} = m!/(k_1!k_2!\cdots k_n!)$ are the multinomial coefficients. The appearance of the multivariate moments on the right hand side shows why they are natural and important generalizations of the univariate moments. These show up all the time. For instance, the covariance between $Y_i$ and $Y_j$ is none other than $$\text{Cov}(Y_i, Y_j) = \mathbb{E}(Y_i Y_j)- \mathbb{E}(Y_i)\mathbb{E}(Y_j) = \mu_{\mathbf{k}_i + \mathbf{k}_j} - \mu_{\mathbf{k}_i}\mu_{\mathbf{k}_j}$$ where $\mathbf{k}_i$ and $\mathbf{k}_j$ are the indicator vectors with zeros in all but one place and a one in the indicated location. (The same formula elegantly yields the variance of $Y_i$ when $i=j$.) There are natural generalizations of all univariate moment concepts to the multivariate setting: a moment generating function, cumulants, a cumulant generating function, central moments, a characteristic function, and algebraic and analytical relationships among them all. Reference Alan Stuart and J. Keith Ord, Kendall's Advanced Theory of Statistics, Fifth Edition. Oxford University Press, 1987: Volume I, Chapter 3, Moments and Cumulants.
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered? The proper analog of univariate moments in a multivariate setting is to view the exponent $\mathbf{k} = (k_1, k_2, \ldots, k_n)$ as a vector, too. The exponential notation with vector bases and vecto
26,112
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered?
In addition to @whuber's points 1) I am not sure what linear model theory entails but remember that in linear models we are generally dealing with normal random variables which have 0 skew and 0 kurtosis. 2) More generally, the question is of the form "How precise is precise?". If I want to describe IID samples I could say I only want the mean. Alternatively I could say I want the mean and the errors in the means. An even more detailed alternative would be means, errors in the means and errors in the errors in the means. From this pattern you can see how the higher moments keep mounting. There is no real solution to this problem so people generally stop at level 2 (i.e., mean and variance). That is not to say the higher moments are useless. In fact, for problems involving fat-tailed distributions these problems become relevant
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered?
In addition to @whuber's points 1) I am not sure what linear model theory entails but remember that in linear models we are generally dealing with normal random variables which have 0 skew and 0 kurt
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered? In addition to @whuber's points 1) I am not sure what linear model theory entails but remember that in linear models we are generally dealing with normal random variables which have 0 skew and 0 kurtosis. 2) More generally, the question is of the form "How precise is precise?". If I want to describe IID samples I could say I only want the mean. Alternatively I could say I want the mean and the errors in the means. An even more detailed alternative would be means, errors in the means and errors in the errors in the means. From this pattern you can see how the higher moments keep mounting. There is no real solution to this problem so people generally stop at level 2 (i.e., mean and variance). That is not to say the higher moments are useless. In fact, for problems involving fat-tailed distributions these problems become relevant
Let $\mathbf{Y}$ be a random vector. Are $k$th moments of $\mathbf{Y}$ considered? In addition to @whuber's points 1) I am not sure what linear model theory entails but remember that in linear models we are generally dealing with normal random variables which have 0 skew and 0 kurt
26,113
How to derive the conjugate prior of an exponential family distribution
The intuitive approach to conjugate priors is to try to deduce a family of distributions from the likelihood function. In the normal case, the likelihood is \begin{align*}\ell(\mu,\Sigma|x_1,\ldots,x_n)&\propto|\Sigma|^{-n/2}\,\exp\left\{ -\frac{1}{2}\sum_{i=1}^n (x_i-\mu)^\text{T}\Sigma^{-1}(x_i-\mu)\right\}\\ &\propto|\Sigma|^{-n/2}\,\exp\left\{-\frac{1}{2}\sum_{i=1}^n (x_i-\bar{x})^\text{T}\Sigma^{-1}(x_i-\bar{x})\right\}\\&\qquad \times \exp\left\{-\frac{n}{2}(\bar{x}-\mu)^\text{T}\Sigma^{-1}(\bar{x}-\mu)\right\}\\ &\propto |\Sigma|^{-n/2}\,\exp\left\{-\frac{1}{2}\text{tr}\left(\Sigma^{-1}S_n \right)-\frac{n}{2}(\bar{x}-\mu)^\text{T}\Sigma^{-1}(\bar{x}-\mu)\right\}\\ \end{align*}where $$S_n=\sum_{i=1}^n (x_i-\bar{x})(x_i-\bar{x})^\text{T}$$So we have three items in this likelihood: a power of $|\Sigma|$; an exponential of a trace of $\Sigma^{-1}$ times another matrix; an exponential of a quadratic in $\mu$ with matrix $\Sigma^{-1}$. And all three terms are stable by multiplication, i.e. $|\Sigma|^a\times |\Sigma|^b = |\Sigma|^{a+b}$; $\exp\left\{-\text{tr}\left(\Sigma^{-1}A\right)\right\}\times\exp\left\{-\text{tr}\left(\Sigma^{-1}B\right)\right\}=\exp\left\{-\text{tr}\left(\Sigma^{-1}[A+B]\right)\right\}$; $\exp\left\{-(a-\mu)^\text{T}\alpha\Sigma^{-1}(a-\mu)\right\}\times\exp\left\{-(b-\mu)^\text{T}\beta\Sigma^{-1}(b-\mu)\right\}$ remains an exponential of a quadratic in $\mu$ with matrix $\Sigma^{-1}$ (with an extra term of the form $\exp\left\{-\text{tr}\left(\Sigma^{-1}A\right)\right\}$ as this is not a perfect quadratic term). This means that the likelihood induces a shape of prior that remains stable by multiplication with another term with this shape. Which is a way of defining conjugacy. So, if I take my prior to be $$\pi(\mu,\Sigma)\propto|\Sigma|^{-\gamma/2}\,\exp\left\{-\frac{1}{2}\text{tr}\left(\Sigma^{-1}\Xi \right)-\frac{\nu}{2}(\xi-\mu)^\text{T}\Sigma^{-1}(\xi-\mu)\right\}$$the posterior will look the same, except that $\gamma,\Xi,\nu,\xi$ will change.
How to derive the conjugate prior of an exponential family distribution
The intuitive approach to conjugate priors is to try to deduce a family of distributions from the likelihood function. In the normal case, the likelihood is \begin{align*}\ell(\mu,\Sigma|x_1,\ldots,x_
How to derive the conjugate prior of an exponential family distribution The intuitive approach to conjugate priors is to try to deduce a family of distributions from the likelihood function. In the normal case, the likelihood is \begin{align*}\ell(\mu,\Sigma|x_1,\ldots,x_n)&\propto|\Sigma|^{-n/2}\,\exp\left\{ -\frac{1}{2}\sum_{i=1}^n (x_i-\mu)^\text{T}\Sigma^{-1}(x_i-\mu)\right\}\\ &\propto|\Sigma|^{-n/2}\,\exp\left\{-\frac{1}{2}\sum_{i=1}^n (x_i-\bar{x})^\text{T}\Sigma^{-1}(x_i-\bar{x})\right\}\\&\qquad \times \exp\left\{-\frac{n}{2}(\bar{x}-\mu)^\text{T}\Sigma^{-1}(\bar{x}-\mu)\right\}\\ &\propto |\Sigma|^{-n/2}\,\exp\left\{-\frac{1}{2}\text{tr}\left(\Sigma^{-1}S_n \right)-\frac{n}{2}(\bar{x}-\mu)^\text{T}\Sigma^{-1}(\bar{x}-\mu)\right\}\\ \end{align*}where $$S_n=\sum_{i=1}^n (x_i-\bar{x})(x_i-\bar{x})^\text{T}$$So we have three items in this likelihood: a power of $|\Sigma|$; an exponential of a trace of $\Sigma^{-1}$ times another matrix; an exponential of a quadratic in $\mu$ with matrix $\Sigma^{-1}$. And all three terms are stable by multiplication, i.e. $|\Sigma|^a\times |\Sigma|^b = |\Sigma|^{a+b}$; $\exp\left\{-\text{tr}\left(\Sigma^{-1}A\right)\right\}\times\exp\left\{-\text{tr}\left(\Sigma^{-1}B\right)\right\}=\exp\left\{-\text{tr}\left(\Sigma^{-1}[A+B]\right)\right\}$; $\exp\left\{-(a-\mu)^\text{T}\alpha\Sigma^{-1}(a-\mu)\right\}\times\exp\left\{-(b-\mu)^\text{T}\beta\Sigma^{-1}(b-\mu)\right\}$ remains an exponential of a quadratic in $\mu$ with matrix $\Sigma^{-1}$ (with an extra term of the form $\exp\left\{-\text{tr}\left(\Sigma^{-1}A\right)\right\}$ as this is not a perfect quadratic term). This means that the likelihood induces a shape of prior that remains stable by multiplication with another term with this shape. Which is a way of defining conjugacy. So, if I take my prior to be $$\pi(\mu,\Sigma)\propto|\Sigma|^{-\gamma/2}\,\exp\left\{-\frac{1}{2}\text{tr}\left(\Sigma^{-1}\Xi \right)-\frac{\nu}{2}(\xi-\mu)^\text{T}\Sigma^{-1}(\xi-\mu)\right\}$$the posterior will look the same, except that $\gamma,\Xi,\nu,\xi$ will change.
How to derive the conjugate prior of an exponential family distribution The intuitive approach to conjugate priors is to try to deduce a family of distributions from the likelihood function. In the normal case, the likelihood is \begin{align*}\ell(\mu,\Sigma|x_1,\ldots,x_
26,114
How to determine the number of convolutional operators in CNN?
I'm assuming that when you say 11x11x10 you mean that you have a layer with 10, 11x11 filters. So the number of convolutions that you'll be doing is simply 10, 2D discrete convolution per filter in your filter bank. So, let's say that you have a network: 480x480x1 # your input image of 1 channel 11x11x10 # your first filter bank of 10, 11x11 filters 5x5x20 # your second filter bank of 20, 5x5 filters 4x4x100 # your final filter bank of 100, 4x4 filters You're going to be doing: $10 + 20 + 100 = 130$ multi channel 2D convolutions each with a depth of 1, 10, and 20 respectively. As you can see, the depth of each convolution is going to change as a function of the depth of the input volume from the previous layer. But I assumed that you're trying to figure out how to compare this to a single channel 2D convolution. Well, you could just multiply the depth of each input volume by the number of filters in each layer and add them together. In your case: $10 + 200 + 2000 = 2,210$. Now this only tells you how many single channel 2D convolutions you're doing, not how computationally intensive each convolution is, the computational intensity of each convolution will depend on a variety of parameters including image_size, image_depth, filter_size, your stride (how far you step between each individual filter calculation), the number of pooling layers you have, etc.
How to determine the number of convolutional operators in CNN?
I'm assuming that when you say 11x11x10 you mean that you have a layer with 10, 11x11 filters. So the number of convolutions that you'll be doing is simply 10, 2D discrete convolution per filter in yo
How to determine the number of convolutional operators in CNN? I'm assuming that when you say 11x11x10 you mean that you have a layer with 10, 11x11 filters. So the number of convolutions that you'll be doing is simply 10, 2D discrete convolution per filter in your filter bank. So, let's say that you have a network: 480x480x1 # your input image of 1 channel 11x11x10 # your first filter bank of 10, 11x11 filters 5x5x20 # your second filter bank of 20, 5x5 filters 4x4x100 # your final filter bank of 100, 4x4 filters You're going to be doing: $10 + 20 + 100 = 130$ multi channel 2D convolutions each with a depth of 1, 10, and 20 respectively. As you can see, the depth of each convolution is going to change as a function of the depth of the input volume from the previous layer. But I assumed that you're trying to figure out how to compare this to a single channel 2D convolution. Well, you could just multiply the depth of each input volume by the number of filters in each layer and add them together. In your case: $10 + 200 + 2000 = 2,210$. Now this only tells you how many single channel 2D convolutions you're doing, not how computationally intensive each convolution is, the computational intensity of each convolution will depend on a variety of parameters including image_size, image_depth, filter_size, your stride (how far you step between each individual filter calculation), the number of pooling layers you have, etc.
How to determine the number of convolutional operators in CNN? I'm assuming that when you say 11x11x10 you mean that you have a layer with 10, 11x11 filters. So the number of convolutions that you'll be doing is simply 10, 2D discrete convolution per filter in yo
26,115
What is this trick with adding 1 here?
The explanation on the referenced page is Under the null hypothesis the probability $\Pr(P \le k / n_\text{sim})$ is exactly $k / n_\text{sim}$ when both the randomness in the data and the randomness in the simulation are taken into account. To understand this, we must look at the code, of which the key lines (considerably abbreviated) are fred <- function(x) {ks.test(...)$statistic} # Apply a statistical test to an array d.hat <- fred(x) # Apply the test to the data d.star <- apply(matrix(rnorm(n*nsim), n, nsim), 2, fred) # Apply the test to nsim simulated datasets pval <- (sum(d.star > d.hat) + 1) / (nsim + 1)# Estimate a simulation p-value The salient problem is that the code does not match the quotation. How can we reconcile them? One attempt begins with the last half of the quotation. We might interpret the procedure as comprising the following steps: Collect independently and identically distributed data $X_1, X_2, \ldots, X_n$ according to some probability law $G$. Apply a test procedure $t$ (implemented in the code as fred) to produce the number $T_0=t(X_1, \ldots, X_n)$. Generate via computer $N=n_\text{sim}$ comparable datasets, each of size $n$, according to a null hypothesis with probability law $F$. Apply $t$ to each such dataset to produce $N$ numbers $T_1,T_2,\ldots,T_N$. Compute $$P = \left(\sum_{i=1}^N I(T_i \gt T_0) + 1\right) / (N+1).$$ ("$I$" is the indicator function implemented by the vector-valued comparison d.star > d.hat in the code.) The right hand side is understood to be random by virtue of the simultaneous randomness of $T_0$ (the actual test statistic) and the randomness of the $T_i$ (the simulated test statistics). To say that the data conform to the null hypothesis is to assert that $F=G$. Pick a test size $\alpha$, $0 \lt \alpha \lt 1$. Multiplying both sides by $N+1$ and subtracting $1$ shows that the chance that $P\le \alpha$ for any number $\alpha$ is the chance that no more than $(N+1)\alpha - 1$ of the $T_i$ exceed $T_0$. This says merely that $T_0$ lies within the top $(N+1)\alpha$ of the sorted set of all $N+1$ test statistics. Since (by construction) $T_0$ is independent of all the $T_i$, when $F$ is a continuous distribution this chance will be the fraction of the total represented by the integer part $\lfloor (N+1)\alpha\rfloor$; that is, $$\Pr(P\le \alpha)=\frac{\lfloor(N+1)\alpha\rfloor}{N+1} \approx \alpha$$ and it will be exactly equal to it provided $(N+1)\alpha$ is a whole number $k$; that is, when $\alpha = k/(N+1)$. This certainly is one of the things we want to be true of any quantity that deserves to be called a "p-value": it should have a uniform distribution on $[0,1]$. Provided $N+1$ is fairly large, so that any $\alpha$ is close to some fraction of the form $k/(N+1) = k/(n_\text{sim}+1)$, this $P$ will have close to a uniform distribution. (To learn about additional conditions required of a p-value, please read the dialog I posted on the subject of p-values.) Evidently the quotation should use "$n_\text{sim}+1$" instead of "$n_\text{sim}$" wherever it appears.
What is this trick with adding 1 here?
The explanation on the referenced page is Under the null hypothesis the probability $\Pr(P \le k / n_\text{sim})$ is exactly $k / n_\text{sim}$ when both the randomness in the data and the randomness
What is this trick with adding 1 here? The explanation on the referenced page is Under the null hypothesis the probability $\Pr(P \le k / n_\text{sim})$ is exactly $k / n_\text{sim}$ when both the randomness in the data and the randomness in the simulation are taken into account. To understand this, we must look at the code, of which the key lines (considerably abbreviated) are fred <- function(x) {ks.test(...)$statistic} # Apply a statistical test to an array d.hat <- fred(x) # Apply the test to the data d.star <- apply(matrix(rnorm(n*nsim), n, nsim), 2, fred) # Apply the test to nsim simulated datasets pval <- (sum(d.star > d.hat) + 1) / (nsim + 1)# Estimate a simulation p-value The salient problem is that the code does not match the quotation. How can we reconcile them? One attempt begins with the last half of the quotation. We might interpret the procedure as comprising the following steps: Collect independently and identically distributed data $X_1, X_2, \ldots, X_n$ according to some probability law $G$. Apply a test procedure $t$ (implemented in the code as fred) to produce the number $T_0=t(X_1, \ldots, X_n)$. Generate via computer $N=n_\text{sim}$ comparable datasets, each of size $n$, according to a null hypothesis with probability law $F$. Apply $t$ to each such dataset to produce $N$ numbers $T_1,T_2,\ldots,T_N$. Compute $$P = \left(\sum_{i=1}^N I(T_i \gt T_0) + 1\right) / (N+1).$$ ("$I$" is the indicator function implemented by the vector-valued comparison d.star > d.hat in the code.) The right hand side is understood to be random by virtue of the simultaneous randomness of $T_0$ (the actual test statistic) and the randomness of the $T_i$ (the simulated test statistics). To say that the data conform to the null hypothesis is to assert that $F=G$. Pick a test size $\alpha$, $0 \lt \alpha \lt 1$. Multiplying both sides by $N+1$ and subtracting $1$ shows that the chance that $P\le \alpha$ for any number $\alpha$ is the chance that no more than $(N+1)\alpha - 1$ of the $T_i$ exceed $T_0$. This says merely that $T_0$ lies within the top $(N+1)\alpha$ of the sorted set of all $N+1$ test statistics. Since (by construction) $T_0$ is independent of all the $T_i$, when $F$ is a continuous distribution this chance will be the fraction of the total represented by the integer part $\lfloor (N+1)\alpha\rfloor$; that is, $$\Pr(P\le \alpha)=\frac{\lfloor(N+1)\alpha\rfloor}{N+1} \approx \alpha$$ and it will be exactly equal to it provided $(N+1)\alpha$ is a whole number $k$; that is, when $\alpha = k/(N+1)$. This certainly is one of the things we want to be true of any quantity that deserves to be called a "p-value": it should have a uniform distribution on $[0,1]$. Provided $N+1$ is fairly large, so that any $\alpha$ is close to some fraction of the form $k/(N+1) = k/(n_\text{sim}+1)$, this $P$ will have close to a uniform distribution. (To learn about additional conditions required of a p-value, please read the dialog I posted on the subject of p-values.) Evidently the quotation should use "$n_\text{sim}+1$" instead of "$n_\text{sim}$" wherever it appears.
What is this trick with adding 1 here? The explanation on the referenced page is Under the null hypothesis the probability $\Pr(P \le k / n_\text{sim})$ is exactly $k / n_\text{sim}$ when both the randomness in the data and the randomness
26,116
What is this trick with adding 1 here?
I believe that here, 1 is added to both because the observed statistic is included in the reference distribution; if this is the case, it's because of the "at least as large" part of the definition of p-value. I don't know for sure because the text seems to be saying something different, but that would be why I'd do it.
What is this trick with adding 1 here?
I believe that here, 1 is added to both because the observed statistic is included in the reference distribution; if this is the case, it's because of the "at least as large" part of the definition of
What is this trick with adding 1 here? I believe that here, 1 is added to both because the observed statistic is included in the reference distribution; if this is the case, it's because of the "at least as large" part of the definition of p-value. I don't know for sure because the text seems to be saying something different, but that would be why I'd do it.
What is this trick with adding 1 here? I believe that here, 1 is added to both because the observed statistic is included in the reference distribution; if this is the case, it's because of the "at least as large" part of the definition of
26,117
How do I interpret the variance of random effect in a generalized linear mixed model
It's probably most helpful if you show us more information about your model, but: the baseline value of the log-odds of whatever your response is (e.g. mortality) varies across hospitals. The baseline value (the per-hospital intercept term) is the log-odds of mortality (or whatever) in the baseline category (e.g. "untreated"), at a zero value of any continuous predictors. That variation is assumed to be Normally distributed, on the log-odds scale. The among-hospital standard deviation of the intercept is 0.6554; the variance (just the standard deviation squared -- not a measure of the uncertainty of the standard deviation) is $0.6554^2=0.4295$. (If you clarify your question/add more detail about your model I can try to say more.) update: your interpretation of the variation seems correct. More precisely, cc <- fixef(fitted_model)[1] ## intercept ss <- sqrt(unlist(VarCorr(fitted_model))) ## random effects SD plogis(qnorm(c(0.025,0.975),mean=cc,sd=ss)) should give you the 95% interval (not really quite confidence intervals, but very similar) for the probabilities of a baseline (male/average age/etc.) individual getting treated across hospitals. For testing the significance of the random effect, you have a variety of choices (see http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html for more information). (Note that the standard error of a RE variance is usually not a reliable way to test significance, since the sampling distribution is often skewed/non-Normal.) The simplest approach is to do a likelihood ratio test, e.g. pchisq(2*(logLik(fitted_model)-logLik(fitted_model_without_RE)), df=1,lower.tail=FALSE)/2 The final division by 2 corrects for the fact that the likelihood ratio test is conservative when the null value (i.e. RE variance=0) is on the boundary of the feasible space (i.e. the RE variance cannot be <0).
How do I interpret the variance of random effect in a generalized linear mixed model
It's probably most helpful if you show us more information about your model, but: the baseline value of the log-odds of whatever your response is (e.g. mortality) varies across hospitals. The baselin
How do I interpret the variance of random effect in a generalized linear mixed model It's probably most helpful if you show us more information about your model, but: the baseline value of the log-odds of whatever your response is (e.g. mortality) varies across hospitals. The baseline value (the per-hospital intercept term) is the log-odds of mortality (or whatever) in the baseline category (e.g. "untreated"), at a zero value of any continuous predictors. That variation is assumed to be Normally distributed, on the log-odds scale. The among-hospital standard deviation of the intercept is 0.6554; the variance (just the standard deviation squared -- not a measure of the uncertainty of the standard deviation) is $0.6554^2=0.4295$. (If you clarify your question/add more detail about your model I can try to say more.) update: your interpretation of the variation seems correct. More precisely, cc <- fixef(fitted_model)[1] ## intercept ss <- sqrt(unlist(VarCorr(fitted_model))) ## random effects SD plogis(qnorm(c(0.025,0.975),mean=cc,sd=ss)) should give you the 95% interval (not really quite confidence intervals, but very similar) for the probabilities of a baseline (male/average age/etc.) individual getting treated across hospitals. For testing the significance of the random effect, you have a variety of choices (see http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html for more information). (Note that the standard error of a RE variance is usually not a reliable way to test significance, since the sampling distribution is often skewed/non-Normal.) The simplest approach is to do a likelihood ratio test, e.g. pchisq(2*(logLik(fitted_model)-logLik(fitted_model_without_RE)), df=1,lower.tail=FALSE)/2 The final division by 2 corrects for the fact that the likelihood ratio test is conservative when the null value (i.e. RE variance=0) is on the boundary of the feasible space (i.e. the RE variance cannot be <0).
How do I interpret the variance of random effect in a generalized linear mixed model It's probably most helpful if you show us more information about your model, but: the baseline value of the log-odds of whatever your response is (e.g. mortality) varies across hospitals. The baselin
26,118
Example of two *correlated* normal variables whose sum is not normal
Almost any bivariate copula will produce a pair of normal random variates with some nonzero correlation (some will give zero but they are special cases). Most (nearly all) of them will produce a non-normal sum. In some copula families any desired (population) Spearman correlation can be produced; the difficulty is only in finding the Pearson correlation for normal margins; it's doable in principle, but the algebra may be fairly complicated in general. [However, if you have the population Spearman correlation, the Pearson correlation - at least for light tailed margins such as the Gaussian - may not be too far from it in many cases.] All but the first two examples in cardinal's plot should give non-normal sums. Some examples -- the first two are both from the same copula family as the fifth of cardinal's example bivariate distributions, the third is degenerate. Example 1: Clayton copula ($\theta=-0.7$) Here the sum is very distinctly peaked and fairly strongly right skew $\ $ Example 2: Clayton copula ($\theta=2$) Here the sum is mildly left skew. Just in case that's not quite obvious to everyone, here I flipped the distribution (i.e. we have a histogram of $-(x+y)$ in pale purple) and superimposed it so we can see the asymmetry more clearly: $\hspace{1cm}$ $\ $ We could readily interchange the direction of skewness of the sum so that the negative correlation went with the left skew and positive correlation with the right skew (for example, by taking $X^*=-X$ and $Y^*=-Y$ in each of the above cases - the correlation of the new variables would be the same as before, but distribution of the sum would be flipped around 0, reversing the skewness). On the other hand if we just negate one of them, we would change association between the strength of the skewness with the sign of the correlation (but not the direction of it). It's worth also playing around with a few different copulas to get a sense of what can happen with the bivariate distribution and normal margins. The Gaussian margins with a t-copula can be experimented with, without worrying much about details of copulas (generate from correlated bivariate t, which is easy, then transform to uniform margins via the probability integral transform, then transform uniform margins to Gaussian via the inverse normal cdf). It will have a non-normal-but-symmetric sum. So even if you don't have nice copula-packages, you can still do some things fairly readily (e.g. if I was trying to show an example quicly in Excel, I'd probably start with the t-copula). -- Example 3: (this is more like what I should have started with initially) Consider a copula based on a standard uniform $U$, and letting $V=U$ for $0\leq U<\frac{1}{2}$ and $V=\frac{3}{2}-U$ for $\frac{1}{2}\leq U\leq 1$. The result has uniform margins for $U$ and $V$, but the bivariate distribution is degenerate. Transforming both margins to normal $X=\Phi^{-1}(U), Y=\Phi^{-1}(V)\,$, we get a distribution for $X+Y$ that looks like this: In this case the correlation between them is around 0.66. So again, $X$ and $Y$ are correlated normals with a (in this case, distinctly) non-normal sum -- because they're not bivariate normal. [One could generate a range of correlations by flipping the center of $U$ (in $(\frac{1}{2}-c,\frac{1}{2}+c)$, for $c$ in $[0,\frac{1}{2}]$), to obtain $V$. These would have a spike at 0 then a gap either side of that, with normal tails.] Some code: library("copula") par(mfrow=c(2,2)) # Example 1 U <- rCopula(100000, claytonCopula(-.7)) x <- qnorm(U[,1]) y <- qnorm(U[,2]) cor(x,y) hist(x,n=100) hist(y,n=100) xysum <- rowSums(qnorm(U)) hist(xysum,n=100,main="Histogram of x+y") plot(x,y,cex=.6, col=rgb(0,100,0,70,maxColorValue=255), main="Bivariate distribution") text(-3,-1.2,"cor = -0.68") text(-2.5,-2.8,expression(paste("Clayton: ",theta," = -0.7"))) The second example: #-- # Example 2: U <- rCopula(100000, claytonCopula(2)) x <- qnorm(U[,1]) y <- qnorm(U[,2]) cor(x,y) hist(x,n=100) hist(y,n=100) xysum <- rowSums(qnorm(U)) hist(xysum,n=100,main="Histogram of x+y") plot(x,y,cex=.6, col=rgb(0,100,0,70,maxColorValue=255), main="Bivariate distribution") text(3,-2.5,"cor = 0.68") text(2.5,-3.6,expression(paste("Clayton: ",theta," = 2"))) # par(mfrow=c(1,1)) Code for the the third example: #-- # Example 3: u <- runif(10000) v <- ifelse(u<.5,u,1.5-u) x <- qnorm(u) y <- qnorm(v) hist(x+y,n=100)
Example of two *correlated* normal variables whose sum is not normal
Almost any bivariate copula will produce a pair of normal random variates with some nonzero correlation (some will give zero but they are special cases). Most (nearly all) of them will produce a non-n
Example of two *correlated* normal variables whose sum is not normal Almost any bivariate copula will produce a pair of normal random variates with some nonzero correlation (some will give zero but they are special cases). Most (nearly all) of them will produce a non-normal sum. In some copula families any desired (population) Spearman correlation can be produced; the difficulty is only in finding the Pearson correlation for normal margins; it's doable in principle, but the algebra may be fairly complicated in general. [However, if you have the population Spearman correlation, the Pearson correlation - at least for light tailed margins such as the Gaussian - may not be too far from it in many cases.] All but the first two examples in cardinal's plot should give non-normal sums. Some examples -- the first two are both from the same copula family as the fifth of cardinal's example bivariate distributions, the third is degenerate. Example 1: Clayton copula ($\theta=-0.7$) Here the sum is very distinctly peaked and fairly strongly right skew $\ $ Example 2: Clayton copula ($\theta=2$) Here the sum is mildly left skew. Just in case that's not quite obvious to everyone, here I flipped the distribution (i.e. we have a histogram of $-(x+y)$ in pale purple) and superimposed it so we can see the asymmetry more clearly: $\hspace{1cm}$ $\ $ We could readily interchange the direction of skewness of the sum so that the negative correlation went with the left skew and positive correlation with the right skew (for example, by taking $X^*=-X$ and $Y^*=-Y$ in each of the above cases - the correlation of the new variables would be the same as before, but distribution of the sum would be flipped around 0, reversing the skewness). On the other hand if we just negate one of them, we would change association between the strength of the skewness with the sign of the correlation (but not the direction of it). It's worth also playing around with a few different copulas to get a sense of what can happen with the bivariate distribution and normal margins. The Gaussian margins with a t-copula can be experimented with, without worrying much about details of copulas (generate from correlated bivariate t, which is easy, then transform to uniform margins via the probability integral transform, then transform uniform margins to Gaussian via the inverse normal cdf). It will have a non-normal-but-symmetric sum. So even if you don't have nice copula-packages, you can still do some things fairly readily (e.g. if I was trying to show an example quicly in Excel, I'd probably start with the t-copula). -- Example 3: (this is more like what I should have started with initially) Consider a copula based on a standard uniform $U$, and letting $V=U$ for $0\leq U<\frac{1}{2}$ and $V=\frac{3}{2}-U$ for $\frac{1}{2}\leq U\leq 1$. The result has uniform margins for $U$ and $V$, but the bivariate distribution is degenerate. Transforming both margins to normal $X=\Phi^{-1}(U), Y=\Phi^{-1}(V)\,$, we get a distribution for $X+Y$ that looks like this: In this case the correlation between them is around 0.66. So again, $X$ and $Y$ are correlated normals with a (in this case, distinctly) non-normal sum -- because they're not bivariate normal. [One could generate a range of correlations by flipping the center of $U$ (in $(\frac{1}{2}-c,\frac{1}{2}+c)$, for $c$ in $[0,\frac{1}{2}]$), to obtain $V$. These would have a spike at 0 then a gap either side of that, with normal tails.] Some code: library("copula") par(mfrow=c(2,2)) # Example 1 U <- rCopula(100000, claytonCopula(-.7)) x <- qnorm(U[,1]) y <- qnorm(U[,2]) cor(x,y) hist(x,n=100) hist(y,n=100) xysum <- rowSums(qnorm(U)) hist(xysum,n=100,main="Histogram of x+y") plot(x,y,cex=.6, col=rgb(0,100,0,70,maxColorValue=255), main="Bivariate distribution") text(-3,-1.2,"cor = -0.68") text(-2.5,-2.8,expression(paste("Clayton: ",theta," = -0.7"))) The second example: #-- # Example 2: U <- rCopula(100000, claytonCopula(2)) x <- qnorm(U[,1]) y <- qnorm(U[,2]) cor(x,y) hist(x,n=100) hist(y,n=100) xysum <- rowSums(qnorm(U)) hist(xysum,n=100,main="Histogram of x+y") plot(x,y,cex=.6, col=rgb(0,100,0,70,maxColorValue=255), main="Bivariate distribution") text(3,-2.5,"cor = 0.68") text(2.5,-3.6,expression(paste("Clayton: ",theta," = 2"))) # par(mfrow=c(1,1)) Code for the the third example: #-- # Example 3: u <- runif(10000) v <- ifelse(u<.5,u,1.5-u) x <- qnorm(u) y <- qnorm(v) hist(x+y,n=100)
Example of two *correlated* normal variables whose sum is not normal Almost any bivariate copula will produce a pair of normal random variates with some nonzero correlation (some will give zero but they are special cases). Most (nearly all) of them will produce a non-n
26,119
Example of two *correlated* normal variables whose sum is not normal
I came up with one example. X is standard normal variable, and Y=-X. Then X+Y=0, which is constant. Can anyone confirm it's a counterexample? We know the fact if X,Y are jointly normal, then their sum is also normal. But what if their correlation is -1?? I am a little confused about this. Thx.
Example of two *correlated* normal variables whose sum is not normal
I came up with one example. X is standard normal variable, and Y=-X. Then X+Y=0, which is constant. Can anyone confirm it's a counterexample? We know the fact if X,Y are jointly normal, then their su
Example of two *correlated* normal variables whose sum is not normal I came up with one example. X is standard normal variable, and Y=-X. Then X+Y=0, which is constant. Can anyone confirm it's a counterexample? We know the fact if X,Y are jointly normal, then their sum is also normal. But what if their correlation is -1?? I am a little confused about this. Thx.
Example of two *correlated* normal variables whose sum is not normal I came up with one example. X is standard normal variable, and Y=-X. Then X+Y=0, which is constant. Can anyone confirm it's a counterexample? We know the fact if X,Y are jointly normal, then their su
26,120
If a time series is second order stationary, does this imply it is strictly stationary?
Second order stationarity is weaker than strict stationarity. Second order stationarity requires that first and second order moments (mean, variance and covariances) are constant throughout time and, hence, do not depend on the time at which the process is observed. In particular, as you say, the covariance depends only on the lag order, $k$, but not on the time at which it is measured, $Cov(x_t, x_{t-k}) = Cov(x_{t+h}, x_{t+h-k})$ for all $t$. In a strict stationarity process, the moments of all orders remain constant throughout time, i.e., as you say, the joint distribution of $X_{t1},X_{t2},...,X_{tm}$ is the same as the joint distribution of $X_{t1+k}+X_{t2+k}+...+X_{tm+k}$ for all $t1,t2,...,tm$ and $k$. Therefore, strict stationarity involves second order stationarity but the converse is not true. Edit (edited as answer to @whuber's comment) The previous statement is the general understanding of weak and strong stationarity. Although the idea that stationarity in the weak sense does not imply stationarity in a stronger sense may agree with intuition, it may not be so straightforward to proof, as pointed out by whuber in the comment below. It can be helpful to illustrate the idea as suggested in that comment. How could we define a process that is second-order stationary (mean, variance and covariance constant throughout time) but it is not stationary in strict sense (moments of higher order depend on time)? As suggested by @whuber (if I understood correctly) we can concatenate batches of observations coming from different distributions. We just need to be careful that those distributions have the same mean and variance (at this point let's consider that they are sampled independently of each other). On one hand, We can for example generate observations from the Student's $t$-distribution with $5$ degrees of freedom. The mean is zero and the variance is $5/(5-2)=5/3$. On another hand, we can take the Gaussian distribution with zero mean and variance $5/3$. Both distributions share the same mean (zero) and variance ($5/3$). Thus, the concatenation of random values from these distribution will be, at least, second-order stationary. However, the kurtosis at those points governed by the Gaussian distribution will be $3$, while at those time points where the data come from the Student's $t$-distribution it will be $3+6/(5-4)=9$. Therefore, the data generated in this way are not stationary in strict sense because moments of fourth order are not constant. The covariances are also constant and equal to zero, since we considered independent observations. This may seem trivial, so we can create some dependence among observations according the following autoregressive model. $$ y_t = \phi y_{t-1} + \epsilon_t \,, \quad |\phi| < 1 \,, \quad t = 1,2,...,120 $$ with \begin{eqnarray} \epsilon_t \sim \left\{ \begin{array}{ll} N(0, \sigma^2=5/3) \quad & \hbox{if} \; t \in [0,20], [41,60], [81,100] \\ t_5 \quad & \hbox{if} \; t \in [21,40], [61,80], [101,120] \,. \end{array} \right. \end{eqnarray} $|\phi| < 1$ ensures that second-order stationarity is satisfied. We can simulate some of these series in the R software and check whether the sample mean, variance, first order covariance and kurtosis remain constant across batches of $20$ observations (the code below uses $\phi=0.8$ and sample size $n=240$, the Figure displays one of the simulated series): # this function is required below kurtosis <- function(x) { n <- length(x) m1 <- sum(x)/n m2 <- sum((x - m1)^2)/n m3 <- sum((x - m1)^3)/n m4 <- sum((x - m1)^4)/n b1 <- (m3/m2^(3/2))^2 (m4/m2^2) } # begin simulation set.seed(123) n <- 240 Mmeans <- Mvars <- Mcovs <- Mkurts <- matrix(nrow = 1000, ncol = n/20) for (i in seq(nrow(Mmeans))) { eps1 <- rnorm(n = n/2, sd = sqrt(5/3)) eps2 <- rt(n = n/2, df = 5) eps <- c(eps1[1:20], eps2[1:20], eps1[21:40], eps2[21:40], eps1[41:60], eps2[41:60], eps1[61:80], eps2[61:80], eps1[81:100], eps2[81:100], eps1[101:120], eps2[101:120]) y <- arima.sim(n = n, model = list(order = c(1,0,0), ar = 0.8), innov = eps) ly <- split(y, gl(n/20, 20)) Mmeans[i,] <- unlist(lapply(ly, mean)) Mvars[i,] <- unlist(lapply(ly, var)) Mcovs[i,] <- unlist(lapply(ly, function(x) acf(x, lag.max = 1, type = "cov", plot = FALSE)$acf[2,,1])) Mkurts[i,] <- unlist(lapply(ly, kurtosis)) } The results are not what I expected: round(colMeans(Mmeans), 4) # [1] 0.0549 -0.0102 -0.0077 -0.0624 -0.0355 -0.0120 0.0191 0.0094 -0.0384 # [10] 0.0390 -0.0056 -0.0236 round(colMeans(Mvars), 4) # [1] 3.0430 3.0769 3.1963 3.1102 3.1551 3.2853 3.1344 3.2351 3.2053 3.1714 # [11] 3.1115 3.2148 round(colMeans(Mcovs), 4) # [1] 1.8417 1.8675 1.9571 1.8940 1.9175 2.0123 1.8905 1.9863 1.9653 1.9313 # [11] 1.8820 1.9491 round(colMeans(Mkurts), 4) # [1] 2.4603 2.5800 2.4576 2.5927 2.5048 2.6269 2.5251 2.5340 2.4762 2.5731 # [11] 2.5001 2.6279 The mean, variance and covariance are relatively constant across batches as expected for a second-order stationary process. However, the kurtosis remains relatively constant as well. We could have expected higher values of the kurtosis at those batches related to draws from the Student's $t$-distribution. Maybe $20$ observations is not enough to capture changes in kurtosis. If we didn't know the data generating process of these series and we looked at rolling statistics, we would probably conclude that the series is stationary at least up to order fourth. Either I didn't take the right example or some features of the series get masked for this sample size.
If a time series is second order stationary, does this imply it is strictly stationary?
Second order stationarity is weaker than strict stationarity. Second order stationarity requires that first and second order moments (mean, variance and covariances) are constant throughout time and,
If a time series is second order stationary, does this imply it is strictly stationary? Second order stationarity is weaker than strict stationarity. Second order stationarity requires that first and second order moments (mean, variance and covariances) are constant throughout time and, hence, do not depend on the time at which the process is observed. In particular, as you say, the covariance depends only on the lag order, $k$, but not on the time at which it is measured, $Cov(x_t, x_{t-k}) = Cov(x_{t+h}, x_{t+h-k})$ for all $t$. In a strict stationarity process, the moments of all orders remain constant throughout time, i.e., as you say, the joint distribution of $X_{t1},X_{t2},...,X_{tm}$ is the same as the joint distribution of $X_{t1+k}+X_{t2+k}+...+X_{tm+k}$ for all $t1,t2,...,tm$ and $k$. Therefore, strict stationarity involves second order stationarity but the converse is not true. Edit (edited as answer to @whuber's comment) The previous statement is the general understanding of weak and strong stationarity. Although the idea that stationarity in the weak sense does not imply stationarity in a stronger sense may agree with intuition, it may not be so straightforward to proof, as pointed out by whuber in the comment below. It can be helpful to illustrate the idea as suggested in that comment. How could we define a process that is second-order stationary (mean, variance and covariance constant throughout time) but it is not stationary in strict sense (moments of higher order depend on time)? As suggested by @whuber (if I understood correctly) we can concatenate batches of observations coming from different distributions. We just need to be careful that those distributions have the same mean and variance (at this point let's consider that they are sampled independently of each other). On one hand, We can for example generate observations from the Student's $t$-distribution with $5$ degrees of freedom. The mean is zero and the variance is $5/(5-2)=5/3$. On another hand, we can take the Gaussian distribution with zero mean and variance $5/3$. Both distributions share the same mean (zero) and variance ($5/3$). Thus, the concatenation of random values from these distribution will be, at least, second-order stationary. However, the kurtosis at those points governed by the Gaussian distribution will be $3$, while at those time points where the data come from the Student's $t$-distribution it will be $3+6/(5-4)=9$. Therefore, the data generated in this way are not stationary in strict sense because moments of fourth order are not constant. The covariances are also constant and equal to zero, since we considered independent observations. This may seem trivial, so we can create some dependence among observations according the following autoregressive model. $$ y_t = \phi y_{t-1} + \epsilon_t \,, \quad |\phi| < 1 \,, \quad t = 1,2,...,120 $$ with \begin{eqnarray} \epsilon_t \sim \left\{ \begin{array}{ll} N(0, \sigma^2=5/3) \quad & \hbox{if} \; t \in [0,20], [41,60], [81,100] \\ t_5 \quad & \hbox{if} \; t \in [21,40], [61,80], [101,120] \,. \end{array} \right. \end{eqnarray} $|\phi| < 1$ ensures that second-order stationarity is satisfied. We can simulate some of these series in the R software and check whether the sample mean, variance, first order covariance and kurtosis remain constant across batches of $20$ observations (the code below uses $\phi=0.8$ and sample size $n=240$, the Figure displays one of the simulated series): # this function is required below kurtosis <- function(x) { n <- length(x) m1 <- sum(x)/n m2 <- sum((x - m1)^2)/n m3 <- sum((x - m1)^3)/n m4 <- sum((x - m1)^4)/n b1 <- (m3/m2^(3/2))^2 (m4/m2^2) } # begin simulation set.seed(123) n <- 240 Mmeans <- Mvars <- Mcovs <- Mkurts <- matrix(nrow = 1000, ncol = n/20) for (i in seq(nrow(Mmeans))) { eps1 <- rnorm(n = n/2, sd = sqrt(5/3)) eps2 <- rt(n = n/2, df = 5) eps <- c(eps1[1:20], eps2[1:20], eps1[21:40], eps2[21:40], eps1[41:60], eps2[41:60], eps1[61:80], eps2[61:80], eps1[81:100], eps2[81:100], eps1[101:120], eps2[101:120]) y <- arima.sim(n = n, model = list(order = c(1,0,0), ar = 0.8), innov = eps) ly <- split(y, gl(n/20, 20)) Mmeans[i,] <- unlist(lapply(ly, mean)) Mvars[i,] <- unlist(lapply(ly, var)) Mcovs[i,] <- unlist(lapply(ly, function(x) acf(x, lag.max = 1, type = "cov", plot = FALSE)$acf[2,,1])) Mkurts[i,] <- unlist(lapply(ly, kurtosis)) } The results are not what I expected: round(colMeans(Mmeans), 4) # [1] 0.0549 -0.0102 -0.0077 -0.0624 -0.0355 -0.0120 0.0191 0.0094 -0.0384 # [10] 0.0390 -0.0056 -0.0236 round(colMeans(Mvars), 4) # [1] 3.0430 3.0769 3.1963 3.1102 3.1551 3.2853 3.1344 3.2351 3.2053 3.1714 # [11] 3.1115 3.2148 round(colMeans(Mcovs), 4) # [1] 1.8417 1.8675 1.9571 1.8940 1.9175 2.0123 1.8905 1.9863 1.9653 1.9313 # [11] 1.8820 1.9491 round(colMeans(Mkurts), 4) # [1] 2.4603 2.5800 2.4576 2.5927 2.5048 2.6269 2.5251 2.5340 2.4762 2.5731 # [11] 2.5001 2.6279 The mean, variance and covariance are relatively constant across batches as expected for a second-order stationary process. However, the kurtosis remains relatively constant as well. We could have expected higher values of the kurtosis at those batches related to draws from the Student's $t$-distribution. Maybe $20$ observations is not enough to capture changes in kurtosis. If we didn't know the data generating process of these series and we looked at rolling statistics, we would probably conclude that the series is stationary at least up to order fourth. Either I didn't take the right example or some features of the series get masked for this sample size.
If a time series is second order stationary, does this imply it is strictly stationary? Second order stationarity is weaker than strict stationarity. Second order stationarity requires that first and second order moments (mean, variance and covariances) are constant throughout time and,
26,121
If a time series is second order stationary, does this imply it is strictly stationary?
Since I can't comment, and I have a worthwhile caveat to @javlacalle's answer, I am forced to include this is a separate answer: @javlacalle wrote that strict stationarity involves second order stationarity but the converse is not true. However, strong stationarity does not imply weak stationarity. The reason is that strong stationarity does not mean the process necessarily has a finite second moment. For example, an iid process with standard Cauchy distribution is strictly stationary but has no finite second moment. Indeed, having a finite second moment is a necessary and sufficient condition for the weak stationarity of a strongly stationary process. Reference: Myers, D.E., 1989. To be or not to be . . . stationary? That is the question. Math. Geol. 21, 347–362.
If a time series is second order stationary, does this imply it is strictly stationary?
Since I can't comment, and I have a worthwhile caveat to @javlacalle's answer, I am forced to include this is a separate answer: @javlacalle wrote that strict stationarity involves second order sta
If a time series is second order stationary, does this imply it is strictly stationary? Since I can't comment, and I have a worthwhile caveat to @javlacalle's answer, I am forced to include this is a separate answer: @javlacalle wrote that strict stationarity involves second order stationarity but the converse is not true. However, strong stationarity does not imply weak stationarity. The reason is that strong stationarity does not mean the process necessarily has a finite second moment. For example, an iid process with standard Cauchy distribution is strictly stationary but has no finite second moment. Indeed, having a finite second moment is a necessary and sufficient condition for the weak stationarity of a strongly stationary process. Reference: Myers, D.E., 1989. To be or not to be . . . stationary? That is the question. Math. Geol. 21, 347–362.
If a time series is second order stationary, does this imply it is strictly stationary? Since I can't comment, and I have a worthwhile caveat to @javlacalle's answer, I am forced to include this is a separate answer: @javlacalle wrote that strict stationarity involves second order sta
26,122
Anomaly detection: what algorithm to use?
A typical formulation of Anomaly Detection is to find the mean and variance for each of $m$ features of non anomalous data and if $x$ is a vector of those features having components $x_i$ then define the probability $p(x)$ of a combination of features as $$p(x) = \prod_{i=1}^m{p(x_i;\mu_i,\sigma_i^2})$$ where each $x_i$ is gaussian distributed: $x_i \sim \mathcal{N(\mu_i,\sigma_i^2)}$ an anomaly occurs whenever $p(x) < \epsilon$ The distribution of each $x_i$ does not need to actually be normal, but it is better if it is at least normal-like. But the features you use are arbitrary; they can be taken directly from the raw data or computed, so for example if you think that a feature $x_i$ is better modeled using $log$ then set the feature to $log(x_i)$ rather than $x_i$. This appears to be very similar to what you are doing already if you take $q = \mu$. Determining $\epsilon$ The algorithm is fit to negative examples (non-anomalies). But $\epsilon$ is determined from the cross-validation set, and is typically selected as the value that provides the best $F1$ score $$F1 = {2*Precision*Recall\over Precision + Recall}$$ But to compute F1 you need to know what is anomalous and what is not; that is true positives are when the system predicts an anomaly and it actually is an anomaly, false positives are predicted anomalies that actually aren't and so on. So unless you have that, then you may have to fall back to guesswork. The problem of correlated features The above has a drawback though if the features are correlated. If they are then the above computation can fail to flag something as anomalous that actually is. A fix for this is using the multivariate gaussian for $m$ features where $\Sigma$ is the covariance matrix. $$p(x)= {1\over (2\pi)^{m\over 2}(\det\Sigma)^{1/2}}e^{-{1\over2}(x-\mu)^T\Sigma^{-1}(x - \mu)}$$ Same thing goes for finding $\epsilon$ and this approach also has a drawback which is you must calculate the inverse of $\Sigma$. So there must be at least as many samples as features and if the number of features is large the process will be computationally intensive, and you must guard agains linearly dependent features. Keep those caveats in mind, but it appears for you to not be a problem.
Anomaly detection: what algorithm to use?
A typical formulation of Anomaly Detection is to find the mean and variance for each of $m$ features of non anomalous data and if $x$ is a vector of those features having components $x_i$ then define
Anomaly detection: what algorithm to use? A typical formulation of Anomaly Detection is to find the mean and variance for each of $m$ features of non anomalous data and if $x$ is a vector of those features having components $x_i$ then define the probability $p(x)$ of a combination of features as $$p(x) = \prod_{i=1}^m{p(x_i;\mu_i,\sigma_i^2})$$ where each $x_i$ is gaussian distributed: $x_i \sim \mathcal{N(\mu_i,\sigma_i^2)}$ an anomaly occurs whenever $p(x) < \epsilon$ The distribution of each $x_i$ does not need to actually be normal, but it is better if it is at least normal-like. But the features you use are arbitrary; they can be taken directly from the raw data or computed, so for example if you think that a feature $x_i$ is better modeled using $log$ then set the feature to $log(x_i)$ rather than $x_i$. This appears to be very similar to what you are doing already if you take $q = \mu$. Determining $\epsilon$ The algorithm is fit to negative examples (non-anomalies). But $\epsilon$ is determined from the cross-validation set, and is typically selected as the value that provides the best $F1$ score $$F1 = {2*Precision*Recall\over Precision + Recall}$$ But to compute F1 you need to know what is anomalous and what is not; that is true positives are when the system predicts an anomaly and it actually is an anomaly, false positives are predicted anomalies that actually aren't and so on. So unless you have that, then you may have to fall back to guesswork. The problem of correlated features The above has a drawback though if the features are correlated. If they are then the above computation can fail to flag something as anomalous that actually is. A fix for this is using the multivariate gaussian for $m$ features where $\Sigma$ is the covariance matrix. $$p(x)= {1\over (2\pi)^{m\over 2}(\det\Sigma)^{1/2}}e^{-{1\over2}(x-\mu)^T\Sigma^{-1}(x - \mu)}$$ Same thing goes for finding $\epsilon$ and this approach also has a drawback which is you must calculate the inverse of $\Sigma$. So there must be at least as many samples as features and if the number of features is large the process will be computationally intensive, and you must guard agains linearly dependent features. Keep those caveats in mind, but it appears for you to not be a problem.
Anomaly detection: what algorithm to use? A typical formulation of Anomaly Detection is to find the mean and variance for each of $m$ features of non anomalous data and if $x$ is a vector of those features having components $x_i$ then define
26,123
Anomaly detection: what algorithm to use?
I almost finished the project where I needed to solve these problems and I would like to share my solution, in case anyone has the same problems. First of all, the approach I described is very similar to a Kernel Density Estimation. So, that was good to know for research... Independent Features Independent features can be filtered out by measuring its Correlation Coefficient. I compared all features by pair and measured the correlation. Then, I took the maximum absolute correlation coefficient of each feature as the scaling factor. That way, features that do not correlate with any other are multiplied by a value close to 0 and thus their effect on the Euclidean distance $||x_1 - x_2||$ (a.k.a. $distance(x_1, x_2)$) is negligible. Be warned: the correlation coefficient can only measure linear correlations. See the linked wiki page for details. If the correlation in the data can be approximated linearly, this works fine. If not, you should have a look at the last page of this paper and see if you can use their measurement of correlation to come up with a scaling factor. Discrete values I used the described algorithm only for continuos values. Discrete values were used to filter the training set. So if I have the height and weight of a person and I know that she's female, I will only look at samples from other females to check for an anomaly.
Anomaly detection: what algorithm to use?
I almost finished the project where I needed to solve these problems and I would like to share my solution, in case anyone has the same problems. First of all, the approach I described is very similar
Anomaly detection: what algorithm to use? I almost finished the project where I needed to solve these problems and I would like to share my solution, in case anyone has the same problems. First of all, the approach I described is very similar to a Kernel Density Estimation. So, that was good to know for research... Independent Features Independent features can be filtered out by measuring its Correlation Coefficient. I compared all features by pair and measured the correlation. Then, I took the maximum absolute correlation coefficient of each feature as the scaling factor. That way, features that do not correlate with any other are multiplied by a value close to 0 and thus their effect on the Euclidean distance $||x_1 - x_2||$ (a.k.a. $distance(x_1, x_2)$) is negligible. Be warned: the correlation coefficient can only measure linear correlations. See the linked wiki page for details. If the correlation in the data can be approximated linearly, this works fine. If not, you should have a look at the last page of this paper and see if you can use their measurement of correlation to come up with a scaling factor. Discrete values I used the described algorithm only for continuos values. Discrete values were used to filter the training set. So if I have the height and weight of a person and I know that she's female, I will only look at samples from other females to check for an anomaly.
Anomaly detection: what algorithm to use? I almost finished the project where I needed to solve these problems and I would like to share my solution, in case anyone has the same problems. First of all, the approach I described is very similar
26,124
Hierarchical Bayesian modeling of incidence rates
A similar problem is discussed in Gelman, Bayesian Data Analysis, (2nd ed, p. 128; 3rd edition p. 110). Gelman suggests a prior $p(a,b)\propto (a+b)^{-5/2}$, which effectively constrains the "prior sample size" $a+b$, and therefore the beta hyperprior is not likely to be highly informative on its own. (As the quantity $a+b$ grows, the variance of the beta distribution shrinks; in this case, smaller prior variance constrains the "weight" of the observed data in the posterior.) Additionally, this prior does not set whether $a>b$, or the opposite, so appropriate distributions of pairs of $(a,b)$ are inferred from all the data together, as you would prefer in this problem. Gelman also suggests reparameterizing the model in terms of the logit of the mean of $\theta$ and the "sample size" of the prior. So instead of doing inference on $(a,b)$ directly, the problem is about inference on the transformed quantities $\text{logit}\left(\frac{a}{a+b}\right)$ and $\log(a+b)$. This admits transformed prior values on the real plane, rather than untransformed prior values that must be strictly positive. Also, this accomplishes a posterior density that is more diffuse when plotted. This makes the accompanying graphs more legible, which I find helpful.
Hierarchical Bayesian modeling of incidence rates
A similar problem is discussed in Gelman, Bayesian Data Analysis, (2nd ed, p. 128; 3rd edition p. 110). Gelman suggests a prior $p(a,b)\propto (a+b)^{-5/2}$, which effectively constrains the "prior sa
Hierarchical Bayesian modeling of incidence rates A similar problem is discussed in Gelman, Bayesian Data Analysis, (2nd ed, p. 128; 3rd edition p. 110). Gelman suggests a prior $p(a,b)\propto (a+b)^{-5/2}$, which effectively constrains the "prior sample size" $a+b$, and therefore the beta hyperprior is not likely to be highly informative on its own. (As the quantity $a+b$ grows, the variance of the beta distribution shrinks; in this case, smaller prior variance constrains the "weight" of the observed data in the posterior.) Additionally, this prior does not set whether $a>b$, or the opposite, so appropriate distributions of pairs of $(a,b)$ are inferred from all the data together, as you would prefer in this problem. Gelman also suggests reparameterizing the model in terms of the logit of the mean of $\theta$ and the "sample size" of the prior. So instead of doing inference on $(a,b)$ directly, the problem is about inference on the transformed quantities $\text{logit}\left(\frac{a}{a+b}\right)$ and $\log(a+b)$. This admits transformed prior values on the real plane, rather than untransformed prior values that must be strictly positive. Also, this accomplishes a posterior density that is more diffuse when plotted. This makes the accompanying graphs more legible, which I find helpful.
Hierarchical Bayesian modeling of incidence rates A similar problem is discussed in Gelman, Bayesian Data Analysis, (2nd ed, p. 128; 3rd edition p. 110). Gelman suggests a prior $p(a,b)\propto (a+b)^{-5/2}$, which effectively constrains the "prior sa
26,125
Multi-armed bandit algorithms vs Uplift modeling
Almost five months with no answer! Here's how I understand it: uplift models use results gathered from a randomized control experiment to better choose targets for the next cycle. Multi-armed bandit problems don't have control and experiment groups. Instead, they're a problem of online learning, where you switch between different treatments on the fly.
Multi-armed bandit algorithms vs Uplift modeling
Almost five months with no answer! Here's how I understand it: uplift models use results gathered from a randomized control experiment to better choose targets for the next cycle. Multi-armed bandit p
Multi-armed bandit algorithms vs Uplift modeling Almost five months with no answer! Here's how I understand it: uplift models use results gathered from a randomized control experiment to better choose targets for the next cycle. Multi-armed bandit problems don't have control and experiment groups. Instead, they're a problem of online learning, where you switch between different treatments on the fly.
Multi-armed bandit algorithms vs Uplift modeling Almost five months with no answer! Here's how I understand it: uplift models use results gathered from a randomized control experiment to better choose targets for the next cycle. Multi-armed bandit p
26,126
Multi-armed bandit algorithms vs Uplift modeling
TL;DR Both approaches address the general problem of choosing an optimal treatment. Uplift models can be flexibly used with all state-of-the-art ML models, e.g. tree-based learners, and provide an interpretable estimate of the treatment effect on a customer. Uplift models are difficult to apply when there are more than a few treatment options, because we conduct a randomized experiment collecting data on each potential treatment. Imagine, for example, not four coupon values but 1000 banner designs. Contextual bandit algorithms also model treatment outcome for the customer, but conduct the experiment one observation at a time and focus on treatments that are profitable or yet underexplored. The focus allows them to deal with a large number of treatments, but often requires an estimate of model uncertainty and online updating, so analysis and deployment are different from the standard ML pipeline. Effect estimation vs. decision optimization Uplift modeling and Bandit algorithms are both approaches to investigate the causal effect of treatment, but their original applications differ. Uplift-type models come from the medical and econometric literature with the original application to estimate the average and later estimate the conditional average treatment effect (2), by conducting a randomized experimental study (3) with a small number of treatments (1). While the goal of much of the literature is the accurate estimation of the treatment effect, the 'uplift' stream uses the same methods to inform the customer targeting decision and target those with high treatment 'scores'. Bandit algorithms come from the computer science and optimization literature and are a type of reinforcement learning. The original application to choose between actions (2), when there might many possible actions (1) by exploring their outcomes efficiently through repeated trials (3) with the goal to identify the most profitable action after as few suboptimal decisions as possible. Basic bandit algorithms search actions that are profitable on average and ignore customer attributes, but contextual bandits model the outcome conditional on the customer. 1) Number of treatments/actions Bandit algorithms are, at least in principle, designed to work on a large action space, e.g. hundreds of potential banners. We expect them to disregard unprofitable actions quickly and focus on few profitable actions during experimentation. Uplift models use a random sample of observations under each treatment to estimate its effect compared to other treatments or the control group. We would, for example, collect the outcomes for 5000 customers per available banner. The experiment becomes huge if we show each of hundreds of banners to random 5000 customers. Nevertheless, when applicable uplift models are stable and treatment estimates have nice statistical properties. 2) Interpretation of the estimate Uplift models predict the effect of the treatment on a customer, e.g. how much more would that customer spend if we would show him this ad banner. This prediction could be the goal of the investigation, but is typically used to do a cost-benefit analysis and target customers for whom the incremental revenue outweights the offer cost. Bandit algorithms are focused on the decision-problem directly. I believe some common methods do allow interpretation of the estimated effect (e.g. linUCB) but the predicted score of policy gradient methods is hard to analyze. 3) Data collection The data used for uplift modeling is collected in a randomized experiment, where N customers see one of the banners at random. Whenever we want to reestimate the model, we will need to run another experiment. Bandit algorithms collect data actively in a setting where customers are evaluated one-by-one. The treatment assignment is not randomized, but based on current estimates. Typically, bandit algorithms will play treatments with high expected outcome and treatments for which the outcome is uncertain. Conversely, they stop playing treatments with certain, low outcomes. The necessity of an estimate of the uncertainty is one thing that makes the design of bandit algorithms difficult. In principle, bandit algorithms are designed to work by assigning treatment, then observing the outcome, then updating the model before the next prediction. Model updating can be done in batch after collecting some observations, but online training is a big part of the decision optimization. Online training is another thing that makes the design and deployment more difficult. Further reading Contextual bandits: Athey, S., & Wager, S. (2017). Efficient policy learning. arXiv:1702.02896. Uplift modeling: Knaus, M. C., Lechner, M., & Strittmatter, A. (2019). Machine Learning Estimation of Heterogeneous Causal Effects: Empirical Monte Carlo Evidence. IZA Discussion Paper, 12039.
Multi-armed bandit algorithms vs Uplift modeling
TL;DR Both approaches address the general problem of choosing an optimal treatment. Uplift models can be flexibly used with all state-of-the-art ML models, e.g. tree-based learners, and provide an int
Multi-armed bandit algorithms vs Uplift modeling TL;DR Both approaches address the general problem of choosing an optimal treatment. Uplift models can be flexibly used with all state-of-the-art ML models, e.g. tree-based learners, and provide an interpretable estimate of the treatment effect on a customer. Uplift models are difficult to apply when there are more than a few treatment options, because we conduct a randomized experiment collecting data on each potential treatment. Imagine, for example, not four coupon values but 1000 banner designs. Contextual bandit algorithms also model treatment outcome for the customer, but conduct the experiment one observation at a time and focus on treatments that are profitable or yet underexplored. The focus allows them to deal with a large number of treatments, but often requires an estimate of model uncertainty and online updating, so analysis and deployment are different from the standard ML pipeline. Effect estimation vs. decision optimization Uplift modeling and Bandit algorithms are both approaches to investigate the causal effect of treatment, but their original applications differ. Uplift-type models come from the medical and econometric literature with the original application to estimate the average and later estimate the conditional average treatment effect (2), by conducting a randomized experimental study (3) with a small number of treatments (1). While the goal of much of the literature is the accurate estimation of the treatment effect, the 'uplift' stream uses the same methods to inform the customer targeting decision and target those with high treatment 'scores'. Bandit algorithms come from the computer science and optimization literature and are a type of reinforcement learning. The original application to choose between actions (2), when there might many possible actions (1) by exploring their outcomes efficiently through repeated trials (3) with the goal to identify the most profitable action after as few suboptimal decisions as possible. Basic bandit algorithms search actions that are profitable on average and ignore customer attributes, but contextual bandits model the outcome conditional on the customer. 1) Number of treatments/actions Bandit algorithms are, at least in principle, designed to work on a large action space, e.g. hundreds of potential banners. We expect them to disregard unprofitable actions quickly and focus on few profitable actions during experimentation. Uplift models use a random sample of observations under each treatment to estimate its effect compared to other treatments or the control group. We would, for example, collect the outcomes for 5000 customers per available banner. The experiment becomes huge if we show each of hundreds of banners to random 5000 customers. Nevertheless, when applicable uplift models are stable and treatment estimates have nice statistical properties. 2) Interpretation of the estimate Uplift models predict the effect of the treatment on a customer, e.g. how much more would that customer spend if we would show him this ad banner. This prediction could be the goal of the investigation, but is typically used to do a cost-benefit analysis and target customers for whom the incremental revenue outweights the offer cost. Bandit algorithms are focused on the decision-problem directly. I believe some common methods do allow interpretation of the estimated effect (e.g. linUCB) but the predicted score of policy gradient methods is hard to analyze. 3) Data collection The data used for uplift modeling is collected in a randomized experiment, where N customers see one of the banners at random. Whenever we want to reestimate the model, we will need to run another experiment. Bandit algorithms collect data actively in a setting where customers are evaluated one-by-one. The treatment assignment is not randomized, but based on current estimates. Typically, bandit algorithms will play treatments with high expected outcome and treatments for which the outcome is uncertain. Conversely, they stop playing treatments with certain, low outcomes. The necessity of an estimate of the uncertainty is one thing that makes the design of bandit algorithms difficult. In principle, bandit algorithms are designed to work by assigning treatment, then observing the outcome, then updating the model before the next prediction. Model updating can be done in batch after collecting some observations, but online training is a big part of the decision optimization. Online training is another thing that makes the design and deployment more difficult. Further reading Contextual bandits: Athey, S., & Wager, S. (2017). Efficient policy learning. arXiv:1702.02896. Uplift modeling: Knaus, M. C., Lechner, M., & Strittmatter, A. (2019). Machine Learning Estimation of Heterogeneous Causal Effects: Empirical Monte Carlo Evidence. IZA Discussion Paper, 12039.
Multi-armed bandit algorithms vs Uplift modeling TL;DR Both approaches address the general problem of choosing an optimal treatment. Uplift models can be flexibly used with all state-of-the-art ML models, e.g. tree-based learners, and provide an int
26,127
Multi-armed bandit algorithms vs Uplift modeling
SUMMARY per your example: This is a situation in which you'd use A/B testing (more batch approach) or multi-arm bandits (more online approach) to do uplift modeling. szkx's answer makes a reasonable distinction, but has a slight error in that uplift modeling is not designed to better choose targets for the next cycle. The key point of uplift models is that they consider both treated and untreated (control) groups. If you naively don't do this, you can't tell the individuals with characteristics that tend to lead to positive outcomes -- regardless of treatment -- from individuals who are likely to benefit from treatment. So uplift modeling is aimed at honestly quantifying the treatment's actual effect, and identifying the characteristics of individuals most likely to benefit from the treatment. This could be expressed as an A/B test, where A is the control group and B is the treated group. Which could also be expressed as a two-armed bandit where one arm is the control group and one arm is the treated group. (A/B testing can be thought of as a kind of bandit problem where you have a batch update rather than continuous update.) So the two concepts are varied and complex. You can do batch or online uplift modeling. The most common case would be batch, with lots of additional features besides treatment/non-treatment. And you can do bandits with additional features -- contextual bandits -- which are much more complex than simple bandits. And the arms of multi-arm bandits need not be reflections of treatment or non-treatment categories. Bottom line is that you can use a multi-arm bandit to do online uplift modeling, but neither concept is a subset of and whether one is "better than" the other depends on your goals and constraints.
Multi-armed bandit algorithms vs Uplift modeling
SUMMARY per your example: This is a situation in which you'd use A/B testing (more batch approach) or multi-arm bandits (more online approach) to do uplift modeling. szkx's answer makes a reasonable d
Multi-armed bandit algorithms vs Uplift modeling SUMMARY per your example: This is a situation in which you'd use A/B testing (more batch approach) or multi-arm bandits (more online approach) to do uplift modeling. szkx's answer makes a reasonable distinction, but has a slight error in that uplift modeling is not designed to better choose targets for the next cycle. The key point of uplift models is that they consider both treated and untreated (control) groups. If you naively don't do this, you can't tell the individuals with characteristics that tend to lead to positive outcomes -- regardless of treatment -- from individuals who are likely to benefit from treatment. So uplift modeling is aimed at honestly quantifying the treatment's actual effect, and identifying the characteristics of individuals most likely to benefit from the treatment. This could be expressed as an A/B test, where A is the control group and B is the treated group. Which could also be expressed as a two-armed bandit where one arm is the control group and one arm is the treated group. (A/B testing can be thought of as a kind of bandit problem where you have a batch update rather than continuous update.) So the two concepts are varied and complex. You can do batch or online uplift modeling. The most common case would be batch, with lots of additional features besides treatment/non-treatment. And you can do bandits with additional features -- contextual bandits -- which are much more complex than simple bandits. And the arms of multi-arm bandits need not be reflections of treatment or non-treatment categories. Bottom line is that you can use a multi-arm bandit to do online uplift modeling, but neither concept is a subset of and whether one is "better than" the other depends on your goals and constraints.
Multi-armed bandit algorithms vs Uplift modeling SUMMARY per your example: This is a situation in which you'd use A/B testing (more batch approach) or multi-arm bandits (more online approach) to do uplift modeling. szkx's answer makes a reasonable d
26,128
Multi-armed bandit algorithms vs Uplift modeling
Uplift modeling assumes past data whilst bandits do not. You can treat uplift modeling as a "warm-start" for a bandit model, or vice versa, you can treat bandits as an adaptive continuation to uplift modeling. A greedy uplift model (choosing the best action) is risky as the regret is linear.
Multi-armed bandit algorithms vs Uplift modeling
Uplift modeling assumes past data whilst bandits do not. You can treat uplift modeling as a "warm-start" for a bandit model, or vice versa, you can treat bandits as an adaptive continuation to uplift
Multi-armed bandit algorithms vs Uplift modeling Uplift modeling assumes past data whilst bandits do not. You can treat uplift modeling as a "warm-start" for a bandit model, or vice versa, you can treat bandits as an adaptive continuation to uplift modeling. A greedy uplift model (choosing the best action) is risky as the regret is linear.
Multi-armed bandit algorithms vs Uplift modeling Uplift modeling assumes past data whilst bandits do not. You can treat uplift modeling as a "warm-start" for a bandit model, or vice versa, you can treat bandits as an adaptive continuation to uplift
26,129
How to handle incomplete data in Kalman Filter?
What is needed is simply to have a variable observation matrix, i.e. in the observation equation: $$ \boldsymbol{Y_t} = \boldsymbol{A_t}\boldsymbol{\theta_t} + \boldsymbol{R_t}\boldsymbol{e_t} $$ matrix $\boldsymbol{A_t}$ (and $\boldsymbol{R_t}$) should omit at time $t$ the rows corresponding to NA entries in $\boldsymbol{Y_t}$. Most packages in R, for instance, will take care of that: you can have the observed multivariate time series with NA values without problems.
How to handle incomplete data in Kalman Filter?
What is needed is simply to have a variable observation matrix, i.e. in the observation equation: $$ \boldsymbol{Y_t} = \boldsymbol{A_t}\boldsymbol{\theta_t} + \boldsymbol{R_t}\boldsymbol{e_t} $$ matr
How to handle incomplete data in Kalman Filter? What is needed is simply to have a variable observation matrix, i.e. in the observation equation: $$ \boldsymbol{Y_t} = \boldsymbol{A_t}\boldsymbol{\theta_t} + \boldsymbol{R_t}\boldsymbol{e_t} $$ matrix $\boldsymbol{A_t}$ (and $\boldsymbol{R_t}$) should omit at time $t$ the rows corresponding to NA entries in $\boldsymbol{Y_t}$. Most packages in R, for instance, will take care of that: you can have the observed multivariate time series with NA values without problems.
How to handle incomplete data in Kalman Filter? What is needed is simply to have a variable observation matrix, i.e. in the observation equation: $$ \boldsymbol{Y_t} = \boldsymbol{A_t}\boldsymbol{\theta_t} + \boldsymbol{R_t}\boldsymbol{e_t} $$ matr
26,130
How to handle incomplete data in Kalman Filter?
Durbin and Koopman (2012) have a useful paragraph when it comes to missing observations. They differentiate between two cases: where all observations at time $t$ are missing and, where a subset of observations at time $t$ are missing. If we use the following set of equations: $$ \begin{align} y_t & = Z x_t + \varepsilon_t \qquad & \varepsilon_t \sim N(0, H) \\ x_{t+1} & = T x_t + \eta_t & \eta_t \sim N(0, Q) \end{align} $$ They suggest reducing the dimensions of the equation at any suitable time points $t$ by introducing a matrix $W_t$ whose rows are a subset of the rows of the identity matrix, so that $y_t^{*}$ only reflects the actual measurements. So essentially you get: $$ \begin{align} y_t^{*}= Z_t^{*}x_t + \epsilon_t^{*} \qquad & \epsilon_t \sim N(0, H^{*}) \\ \end{align} $$ where $$ \begin{align} y_t^{*}&=W_t y_t\\ Z_t^{*}&=W_t Z_t\\ \epsilon_t^{*}&=W_t\epsilon_t\\ H_t^{*}&= W_t H_t W_t^{T} \end{align} $$ Reference: Time series analysis by state space methods by Durbin, J., & Koopman, S. J. (2012)
How to handle incomplete data in Kalman Filter?
Durbin and Koopman (2012) have a useful paragraph when it comes to missing observations. They differentiate between two cases: where all observations at time $t$ are missing and, where a subset of ob
How to handle incomplete data in Kalman Filter? Durbin and Koopman (2012) have a useful paragraph when it comes to missing observations. They differentiate between two cases: where all observations at time $t$ are missing and, where a subset of observations at time $t$ are missing. If we use the following set of equations: $$ \begin{align} y_t & = Z x_t + \varepsilon_t \qquad & \varepsilon_t \sim N(0, H) \\ x_{t+1} & = T x_t + \eta_t & \eta_t \sim N(0, Q) \end{align} $$ They suggest reducing the dimensions of the equation at any suitable time points $t$ by introducing a matrix $W_t$ whose rows are a subset of the rows of the identity matrix, so that $y_t^{*}$ only reflects the actual measurements. So essentially you get: $$ \begin{align} y_t^{*}= Z_t^{*}x_t + \epsilon_t^{*} \qquad & \epsilon_t \sim N(0, H^{*}) \\ \end{align} $$ where $$ \begin{align} y_t^{*}&=W_t y_t\\ Z_t^{*}&=W_t Z_t\\ \epsilon_t^{*}&=W_t\epsilon_t\\ H_t^{*}&= W_t H_t W_t^{T} \end{align} $$ Reference: Time series analysis by state space methods by Durbin, J., & Koopman, S. J. (2012)
How to handle incomplete data in Kalman Filter? Durbin and Koopman (2012) have a useful paragraph when it comes to missing observations. They differentiate between two cases: where all observations at time $t$ are missing and, where a subset of ob
26,131
How to handle incomplete data in Kalman Filter?
The simplest solution is to just use any measurement value (the last good one is best), but set the corresponding measurement noise variance to an extremely large number. In effect, the fake measurement will be ignored. The Kalman filter is balancing measurement uncertainty against model uncertainty, and in this case, you're just estimating based on whatever the state model predicts plus other measurement corrections. As long as the measurement is unavailable, any states that would become unobservable without that measurement would have their uncertainty grow over time because of process noise. That's very realistic - your confidence in projections based on old measurements continually decreases over time. (This is true for this solution or for the case of temporarily changing the filter structure to eliminate the measurement). This formulation assumes you're using a Kalman filter that updates both the state and covariance matrix at each step, not the steady state version. This is the simplest approach if your software doesn't already have special handling for unavailable values. (And software that does have missing value handling might well handle it this way). This approach in theory should accomplish exactly the same thing as modifying the measurement matrix size and measurement covariance matrix size. A measurement with almost infinite variance contributes the same information as no measurement at all. But this way, there's no need to change the structure of the filter or store all the possibilities - it's just one parameter change (assuming the typical case of each measurement noise error being independent, so that the measurement covariance matrix is diagonal).
How to handle incomplete data in Kalman Filter?
The simplest solution is to just use any measurement value (the last good one is best), but set the corresponding measurement noise variance to an extremely large number. In effect, the fake measurem
How to handle incomplete data in Kalman Filter? The simplest solution is to just use any measurement value (the last good one is best), but set the corresponding measurement noise variance to an extremely large number. In effect, the fake measurement will be ignored. The Kalman filter is balancing measurement uncertainty against model uncertainty, and in this case, you're just estimating based on whatever the state model predicts plus other measurement corrections. As long as the measurement is unavailable, any states that would become unobservable without that measurement would have their uncertainty grow over time because of process noise. That's very realistic - your confidence in projections based on old measurements continually decreases over time. (This is true for this solution or for the case of temporarily changing the filter structure to eliminate the measurement). This formulation assumes you're using a Kalman filter that updates both the state and covariance matrix at each step, not the steady state version. This is the simplest approach if your software doesn't already have special handling for unavailable values. (And software that does have missing value handling might well handle it this way). This approach in theory should accomplish exactly the same thing as modifying the measurement matrix size and measurement covariance matrix size. A measurement with almost infinite variance contributes the same information as no measurement at all. But this way, there's no need to change the structure of the filter or store all the possibilities - it's just one parameter change (assuming the typical case of each measurement noise error being independent, so that the measurement covariance matrix is diagonal).
How to handle incomplete data in Kalman Filter? The simplest solution is to just use any measurement value (the last good one is best), but set the corresponding measurement noise variance to an extremely large number. In effect, the fake measurem
26,132
What is the RMSE of k-Fold Cross Validation?
To be correct, you should calculate the overall RMSE as $\sqrt{\frac{RMSE_1^2 + \dots + RMSE_k^2}{k}}$. Edit: I just got from your question that it may be necessary to explain my answer a bit. The $RMSE_j$ of the instance $j$ of the cross-validation is calculated as $\sqrt{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}$ where $\hat{y}_{ij}$ is the estimation of $y_{ij}$ and $N_j$ is the number of observations of CV instance $j$. Now the overall RMSE is something like $\sqrt{\frac{\sum_j{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}}{k}}$ and not what you propose $\frac{\sum_j{\sqrt{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}}}{\sum_j{N_j}}$.
What is the RMSE of k-Fold Cross Validation?
To be correct, you should calculate the overall RMSE as $\sqrt{\frac{RMSE_1^2 + \dots + RMSE_k^2}{k}}$. Edit: I just got from your question that it may be necessary to explain my answer a bit. The $RM
What is the RMSE of k-Fold Cross Validation? To be correct, you should calculate the overall RMSE as $\sqrt{\frac{RMSE_1^2 + \dots + RMSE_k^2}{k}}$. Edit: I just got from your question that it may be necessary to explain my answer a bit. The $RMSE_j$ of the instance $j$ of the cross-validation is calculated as $\sqrt{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}$ where $\hat{y}_{ij}$ is the estimation of $y_{ij}$ and $N_j$ is the number of observations of CV instance $j$. Now the overall RMSE is something like $\sqrt{\frac{\sum_j{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}}{k}}$ and not what you propose $\frac{\sum_j{\sqrt{\frac{\sum_i{(y_{ij} - \hat{y}_{ij})^2}}{N_j}}}}{\sum_j{N_j}}$.
What is the RMSE of k-Fold Cross Validation? To be correct, you should calculate the overall RMSE as $\sqrt{\frac{RMSE_1^2 + \dots + RMSE_k^2}{k}}$. Edit: I just got from your question that it may be necessary to explain my answer a bit. The $RM
26,133
What is the RMSE of k-Fold Cross Validation?
It's not a great reference, but in this notebook (look for cell starting with "Now let's compute RMSE using 10-fold x-validation") they add up the square errors (using a dot product) of all the predictions in all the cross validations, and then at the end divide by the number of predictions and square-root, i.e; $\sqrt{\frac{1}{n} \sum_k{\sum_j{(y_{jk} - \hat{y_{jk}})^2}}}$ This makes the most sense to me, in the answer given by user1449306 the size of the folds would have an effect, which doesn't make sense? To get to this from the list of RMSEs, they could each be squared and multiplied by the number of test points in each, then added together and divided by the total number of test points (and then squarerooted). Roland's comment is correct.
What is the RMSE of k-Fold Cross Validation?
It's not a great reference, but in this notebook (look for cell starting with "Now let's compute RMSE using 10-fold x-validation") they add up the square errors (using a dot product) of all the predic
What is the RMSE of k-Fold Cross Validation? It's not a great reference, but in this notebook (look for cell starting with "Now let's compute RMSE using 10-fold x-validation") they add up the square errors (using a dot product) of all the predictions in all the cross validations, and then at the end divide by the number of predictions and square-root, i.e; $\sqrt{\frac{1}{n} \sum_k{\sum_j{(y_{jk} - \hat{y_{jk}})^2}}}$ This makes the most sense to me, in the answer given by user1449306 the size of the folds would have an effect, which doesn't make sense? To get to this from the list of RMSEs, they could each be squared and multiplied by the number of test points in each, then added together and divided by the total number of test points (and then squarerooted). Roland's comment is correct.
What is the RMSE of k-Fold Cross Validation? It's not a great reference, but in this notebook (look for cell starting with "Now let's compute RMSE using 10-fold x-validation") they add up the square errors (using a dot product) of all the predic
26,134
What is the RMSE of k-Fold Cross Validation?
Here's my take. First we square the values, then we multiply with the counts, then we add them all up, divide by total count and take the square root. In pseudocode (Python), this could be implemented like # Overall RMSE from list of rmses new_list=[x*x for x in fold_wise_rmse] counts =[len(x) for x in val_sets] nldotcounts=np.dot(new_list,counts) overall_rmse=np.sqrt(nldotcounts/sum(counts)) where fold_wise_rmse and val_sets are both list structures
What is the RMSE of k-Fold Cross Validation?
Here's my take. First we square the values, then we multiply with the counts, then we add them all up, divide by total count and take the square root. In pseudocode (Python), this could be implemented
What is the RMSE of k-Fold Cross Validation? Here's my take. First we square the values, then we multiply with the counts, then we add them all up, divide by total count and take the square root. In pseudocode (Python), this could be implemented like # Overall RMSE from list of rmses new_list=[x*x for x in fold_wise_rmse] counts =[len(x) for x in val_sets] nldotcounts=np.dot(new_list,counts) overall_rmse=np.sqrt(nldotcounts/sum(counts)) where fold_wise_rmse and val_sets are both list structures
What is the RMSE of k-Fold Cross Validation? Here's my take. First we square the values, then we multiply with the counts, then we add them all up, divide by total count and take the square root. In pseudocode (Python), this could be implemented
26,135
The meaning of representing the simplex as a triangle surface in Dirichlet distribution?
I don't understand what is the role of the triangle here. What is it trying to communicate or visualize? All points in the triangle must satisfy the two constraints: between zero and one in each dimension ($0 \leq \theta \leq 1$) and all sum up to one ($\theta_0 + \theta_1 + \theta_2 = 1$). The way I finally understood it is the following: So (a) shows a 3-D space with $\theta_{1, 2, 3}$ as coordinates. They range only between 0 and 1. In (b), a triangle is shown, this is our simplex. (c) shows two example points that "lay" on the simplex which also fulfil the second criteria (sums up to one). (d) shows another example point on the simplex, the same constraints hold In (e), I tried to show a projection of the simplex to a 2-D triangle with all example points shown before. Hope it makes more sense now :)
The meaning of representing the simplex as a triangle surface in Dirichlet distribution?
I don't understand what is the role of the triangle here. What is it trying to communicate or visualize? All points in the triangle must satisfy the two constraints: between zero and one in each dime
The meaning of representing the simplex as a triangle surface in Dirichlet distribution? I don't understand what is the role of the triangle here. What is it trying to communicate or visualize? All points in the triangle must satisfy the two constraints: between zero and one in each dimension ($0 \leq \theta \leq 1$) and all sum up to one ($\theta_0 + \theta_1 + \theta_2 = 1$). The way I finally understood it is the following: So (a) shows a 3-D space with $\theta_{1, 2, 3}$ as coordinates. They range only between 0 and 1. In (b), a triangle is shown, this is our simplex. (c) shows two example points that "lay" on the simplex which also fulfil the second criteria (sums up to one). (d) shows another example point on the simplex, the same constraints hold In (e), I tried to show a projection of the simplex to a 2-D triangle with all example points shown before. Hope it makes more sense now :)
The meaning of representing the simplex as a triangle surface in Dirichlet distribution? I don't understand what is the role of the triangle here. What is it trying to communicate or visualize? All points in the triangle must satisfy the two constraints: between zero and one in each dime
26,136
The meaning of representing the simplex as a triangle surface in Dirichlet distribution?
Graph 2.14(a) shows a plane made by three vertices on each axis. The distance of a vertex from the origin is $\theta_i$, corresponding to one of the $k=3$ classes. The region enclosed by the pink plane and the planes of the axes is probability of (vector) $\theta$. Now suppose that you tilt that plane so that you have a pyramid with the pink plane, the face nearest to the reader, placed flat on the page. Then suppress the third dimension "popping out" of the page, and instead color the triangle so that the higher density region, with a longer distance from the base to a surface, is more red. That's what graphs 2.14(b) and 2.14(c) show. The more the red is concentrated near a vertex, the more probable the class associated with that vertex. Likewise, if the red region is not very near to any vertex, it is not especially likely that an event has higher probability of membership in any of the classes. This pyramid, though, only makes sense as a single realization of the Dirichlet distribution. Drawing again from the same distribution might yield a different pyramid with different lengths $\theta$ to each of the vertices. The key difference between (a) and (b)/(c) is that (a) graphically displays the probability of one draw of vector $\theta$. Graphs (b) and (c) show the probability density for values $\theta$ in the $k=3$ simplex, that is, they're attempting to present the probability density function for all values $\theta$ in the support. One way to think about (b) and (c) is as a point having additional red color according to the average height between the flat pink plane and the surface of the pyramid, averaged over many draws of $\theta\sim\text{Dir}(\alpha)$.
The meaning of representing the simplex as a triangle surface in Dirichlet distribution?
Graph 2.14(a) shows a plane made by three vertices on each axis. The distance of a vertex from the origin is $\theta_i$, corresponding to one of the $k=3$ classes. The region enclosed by the pink plan
The meaning of representing the simplex as a triangle surface in Dirichlet distribution? Graph 2.14(a) shows a plane made by three vertices on each axis. The distance of a vertex from the origin is $\theta_i$, corresponding to one of the $k=3$ classes. The region enclosed by the pink plane and the planes of the axes is probability of (vector) $\theta$. Now suppose that you tilt that plane so that you have a pyramid with the pink plane, the face nearest to the reader, placed flat on the page. Then suppress the third dimension "popping out" of the page, and instead color the triangle so that the higher density region, with a longer distance from the base to a surface, is more red. That's what graphs 2.14(b) and 2.14(c) show. The more the red is concentrated near a vertex, the more probable the class associated with that vertex. Likewise, if the red region is not very near to any vertex, it is not especially likely that an event has higher probability of membership in any of the classes. This pyramid, though, only makes sense as a single realization of the Dirichlet distribution. Drawing again from the same distribution might yield a different pyramid with different lengths $\theta$ to each of the vertices. The key difference between (a) and (b)/(c) is that (a) graphically displays the probability of one draw of vector $\theta$. Graphs (b) and (c) show the probability density for values $\theta$ in the $k=3$ simplex, that is, they're attempting to present the probability density function for all values $\theta$ in the support. One way to think about (b) and (c) is as a point having additional red color according to the average height between the flat pink plane and the surface of the pyramid, averaged over many draws of $\theta\sim\text{Dir}(\alpha)$.
The meaning of representing the simplex as a triangle surface in Dirichlet distribution? Graph 2.14(a) shows a plane made by three vertices on each axis. The distance of a vertex from the origin is $\theta_i$, corresponding to one of the $k=3$ classes. The region enclosed by the pink plan
26,137
What does it mean when all edges in a real-world network/graph are statistically just as likely to happen by chance?
The null hypothesis behind backbone methods is [The] normalized weights that correspond to the connections of a certain node of degree k are produced by a random assignment from a uniform distribution. If there aren't any "significant" edges, the null hypothesis holds for the entire graph, i.e., edge weights result from nodal propensities to send and receive ties. Depending on the relationships you're analyzing, the backbone method might not be appropriate. The method works best for networks that are conceptually one-mode weighted networks. Two-mode networks can be projected as a weighted one-mode network, but it often doesn't make sense to do so. Drawing upon your example in the Economist, it doesn't make sense to analyze Senate voting as a one-mode network weighted by the number of shared votes. Voting in the Senate is a signed, two-mode relationship. Senators (i) have relationships to a pieces of legislation (j) and they either abstain from voting (0) or they vote for (+1) or against (-1) the legislation. To transform the network into a weighted one-mode agreement network, then perform a backbone analysis on it would be a severe reduction of data. Some pieces of legislation are more politically divisive and some have more votes than others--backbone methods wouldn't capture these mechanisms. You may want to consider Conditional Uniform Graph (CUG) tests instead of backbone methods. The idea behind these tests is to determine if certain graph-level properties (e.g., clustering, average path length, centralization, homophily) result from chance. The process is as follows: Take measurement f from the observed graph Generate a random graph that controls for certain properties of the observed graph (e.g., size, number of edges, degree distribution, etc) Take measurement f from the random graph Repeat steps 2 and 3 many times (e.g., 1000) to produce a null distribution Compare the observed measurement to the null distribution For two-mode networks, it would make sense to create the random graph by permuting the observed graph (both tnet and statnet in R have routines for permuting two-mode networks). If measurement f requires a one-mode network, the randomization process should be done on the two-mode network before projecting it as a one-mode network.
What does it mean when all edges in a real-world network/graph are statistically just as likely to h
The null hypothesis behind backbone methods is [The] normalized weights that correspond to the connections of a certain node of degree k are produced by a random assignment from a uniform distributio
What does it mean when all edges in a real-world network/graph are statistically just as likely to happen by chance? The null hypothesis behind backbone methods is [The] normalized weights that correspond to the connections of a certain node of degree k are produced by a random assignment from a uniform distribution. If there aren't any "significant" edges, the null hypothesis holds for the entire graph, i.e., edge weights result from nodal propensities to send and receive ties. Depending on the relationships you're analyzing, the backbone method might not be appropriate. The method works best for networks that are conceptually one-mode weighted networks. Two-mode networks can be projected as a weighted one-mode network, but it often doesn't make sense to do so. Drawing upon your example in the Economist, it doesn't make sense to analyze Senate voting as a one-mode network weighted by the number of shared votes. Voting in the Senate is a signed, two-mode relationship. Senators (i) have relationships to a pieces of legislation (j) and they either abstain from voting (0) or they vote for (+1) or against (-1) the legislation. To transform the network into a weighted one-mode agreement network, then perform a backbone analysis on it would be a severe reduction of data. Some pieces of legislation are more politically divisive and some have more votes than others--backbone methods wouldn't capture these mechanisms. You may want to consider Conditional Uniform Graph (CUG) tests instead of backbone methods. The idea behind these tests is to determine if certain graph-level properties (e.g., clustering, average path length, centralization, homophily) result from chance. The process is as follows: Take measurement f from the observed graph Generate a random graph that controls for certain properties of the observed graph (e.g., size, number of edges, degree distribution, etc) Take measurement f from the random graph Repeat steps 2 and 3 many times (e.g., 1000) to produce a null distribution Compare the observed measurement to the null distribution For two-mode networks, it would make sense to create the random graph by permuting the observed graph (both tnet and statnet in R have routines for permuting two-mode networks). If measurement f requires a one-mode network, the randomization process should be done on the two-mode network before projecting it as a one-mode network.
What does it mean when all edges in a real-world network/graph are statistically just as likely to h The null hypothesis behind backbone methods is [The] normalized weights that correspond to the connections of a certain node of degree k are produced by a random assignment from a uniform distributio
26,138
What does it mean when all edges in a real-world network/graph are statistically just as likely to happen by chance?
In the article you cite, the authors consider that, in a complex network, "[the] nodes represent the elements of the [modeled] system and the weighted edges identify the presence of an interaction and its relative strength" (emphasis by me). In the network you study, if I understand correctly the Economist article, there's a link between 2 senators if they voted similarly at least 100 times. So, the links do not model interactions, but similarities (between the senators voting behavior). From my experience, similarity networks do not exhibit the same degree distribution than interaction networks, in the sense it is not as heterogeneous. Also, the threshold parameter used when extracting the network (here: 100) sometimes has a strong effect on the degree distribution. Moreover, I could not find the mention of any weights in the Economist article. Yet, the presence of weights seems to be an important point in the method described in the work of Ángeles Serrano et al. you cite in your question. From these two observations, it seems possible the method does not perform accurately on these data because it was not designed to process networks of this type. Maybe you can check the degree distribution: is it centred on a characteristic value, or heterogeneous? And what about the weights, are there any?
What does it mean when all edges in a real-world network/graph are statistically just as likely to h
In the article you cite, the authors consider that, in a complex network, "[the] nodes represent the elements of the [modeled] system and the weighted edges identify the presence of an interaction and
What does it mean when all edges in a real-world network/graph are statistically just as likely to happen by chance? In the article you cite, the authors consider that, in a complex network, "[the] nodes represent the elements of the [modeled] system and the weighted edges identify the presence of an interaction and its relative strength" (emphasis by me). In the network you study, if I understand correctly the Economist article, there's a link between 2 senators if they voted similarly at least 100 times. So, the links do not model interactions, but similarities (between the senators voting behavior). From my experience, similarity networks do not exhibit the same degree distribution than interaction networks, in the sense it is not as heterogeneous. Also, the threshold parameter used when extracting the network (here: 100) sometimes has a strong effect on the degree distribution. Moreover, I could not find the mention of any weights in the Economist article. Yet, the presence of weights seems to be an important point in the method described in the work of Ángeles Serrano et al. you cite in your question. From these two observations, it seems possible the method does not perform accurately on these data because it was not designed to process networks of this type. Maybe you can check the degree distribution: is it centred on a characteristic value, or heterogeneous? And what about the weights, are there any?
What does it mean when all edges in a real-world network/graph are statistically just as likely to h In the article you cite, the authors consider that, in a complex network, "[the] nodes represent the elements of the [modeled] system and the weighted edges identify the presence of an interaction and
26,139
How to check if my data fits log normal distribution?
... I've just noticed you have the 'regression' tag there. If you do have a regression problem you can't look at the univariate distribution of the response to assess the distributional shape, since it depends on the pattern of the x's. If you're asking about checking whether a response (y) variable in some kind of regression or GLM has a lognormal or a Pareto distribution where the means differ across observation, that's a very different question (but basically comes down to similar kinds of analysis on the residuals). Can you please clarify if it is a regression problem. My answer, at present, relates to assessing univariate lognormal or Pareto You have some quite different questions there. How to check if my data fits log normal distribution? Take logs and do a normal QQ plot. Look and see if the distribution is close enough for your purposes. I'd like to check in R if my data fits log-normal or Pareto distributions Accept from the start that none of the distributions you consider will be am exact description. You're looking for a reasonable model. This means that at small sample sizes, you won't reject any reasonable option, but with sufficient sample size you'll reject them all. Worse, with large sample size, you'll reject perfectly decent models, while at small sample sizes you won't reject bad ones. Such tests aren't really a useful basis for model selection. In short, your question of interest - something like "what's a good model for this data, one that is close enough that it will make subsequent inference useful?" is simply not answered by goodness of fit tests. However, in some cases goodness of fit statistics (rather than decisions coming out of rejection rules based on them) may in some cases provide a useful summary of particular kinds of lack of fit. Perhaps ks.test could help me do that No. First, there's the issue I just mentioned, and second, a Kolmogorov-Smirnov test is a test for a completely specified distribution. You don't have one of those. In many cases, I'd recommend Q-Q plots and similar displays. For right skew cases like this, I'd tend to work with logs (a lognormal will then look normal, while a Pareto will look exponential). At reasonable sample sizes it's not hard to distinguish visually whether data looks more nearly normal than exponential or vice versa. First, get some actual data from each and plot those - say half a dozen samples at least, so you know what they look like. See an example below how could I get the alpha and k parameters for pareto distribution for my data? If you need to estimate parameters, use MLE... but don't do that to decide between Pareto and lognormal. Can you tell which of these is lognormal and which is Pareto? Note that with the normal Q-Q plots (left column) we see the logs of data set 1 gives a fairly straight line, while data set 2 shows right skewness. With the exponential plots, the logs of data set 1 show a lighter right tail than exponential, while data set 2 shows a fairly straight line (the values in the right tail tend to wiggle about a bit even when the model is correct; this is not unusual with heavy-tails; it's one reason why you need to plot several samples of similar size to the one you're looking at to see what plots typically look like) Code used to do those four plots: qqnorm(log(y1)) qqnorm(log(y2)) qex <- function(x) qexp((rank(x)-.375)/(length(x)+.25)) plot(qex(y1),log(y1)) plot(qex(y2),log(y2)) If you have a regression type problem - one where the means change with other variables, you can really only assess the suitability of either distributional assumption in the presence of a suitable model for the mean.
How to check if my data fits log normal distribution?
... I've just noticed you have the 'regression' tag there. If you do have a regression problem you can't look at the univariate distribution of the response to assess the distributional shape, since i
How to check if my data fits log normal distribution? ... I've just noticed you have the 'regression' tag there. If you do have a regression problem you can't look at the univariate distribution of the response to assess the distributional shape, since it depends on the pattern of the x's. If you're asking about checking whether a response (y) variable in some kind of regression or GLM has a lognormal or a Pareto distribution where the means differ across observation, that's a very different question (but basically comes down to similar kinds of analysis on the residuals). Can you please clarify if it is a regression problem. My answer, at present, relates to assessing univariate lognormal or Pareto You have some quite different questions there. How to check if my data fits log normal distribution? Take logs and do a normal QQ plot. Look and see if the distribution is close enough for your purposes. I'd like to check in R if my data fits log-normal or Pareto distributions Accept from the start that none of the distributions you consider will be am exact description. You're looking for a reasonable model. This means that at small sample sizes, you won't reject any reasonable option, but with sufficient sample size you'll reject them all. Worse, with large sample size, you'll reject perfectly decent models, while at small sample sizes you won't reject bad ones. Such tests aren't really a useful basis for model selection. In short, your question of interest - something like "what's a good model for this data, one that is close enough that it will make subsequent inference useful?" is simply not answered by goodness of fit tests. However, in some cases goodness of fit statistics (rather than decisions coming out of rejection rules based on them) may in some cases provide a useful summary of particular kinds of lack of fit. Perhaps ks.test could help me do that No. First, there's the issue I just mentioned, and second, a Kolmogorov-Smirnov test is a test for a completely specified distribution. You don't have one of those. In many cases, I'd recommend Q-Q plots and similar displays. For right skew cases like this, I'd tend to work with logs (a lognormal will then look normal, while a Pareto will look exponential). At reasonable sample sizes it's not hard to distinguish visually whether data looks more nearly normal than exponential or vice versa. First, get some actual data from each and plot those - say half a dozen samples at least, so you know what they look like. See an example below how could I get the alpha and k parameters for pareto distribution for my data? If you need to estimate parameters, use MLE... but don't do that to decide between Pareto and lognormal. Can you tell which of these is lognormal and which is Pareto? Note that with the normal Q-Q plots (left column) we see the logs of data set 1 gives a fairly straight line, while data set 2 shows right skewness. With the exponential plots, the logs of data set 1 show a lighter right tail than exponential, while data set 2 shows a fairly straight line (the values in the right tail tend to wiggle about a bit even when the model is correct; this is not unusual with heavy-tails; it's one reason why you need to plot several samples of similar size to the one you're looking at to see what plots typically look like) Code used to do those four plots: qqnorm(log(y1)) qqnorm(log(y2)) qex <- function(x) qexp((rank(x)-.375)/(length(x)+.25)) plot(qex(y1),log(y1)) plot(qex(y2),log(y2)) If you have a regression type problem - one where the means change with other variables, you can really only assess the suitability of either distributional assumption in the presence of a suitable model for the mean.
How to check if my data fits log normal distribution? ... I've just noticed you have the 'regression' tag there. If you do have a regression problem you can't look at the univariate distribution of the response to assess the distributional shape, since i
26,140
How to check if my data fits log normal distribution?
This is a matter of model selection, of course, assuming that you just want to check whether your data comes from one model or the other and that your goal is not finding the right model among the infinite dimensional ocean of distributions. So, one option is to use AIC (which favours models with the lowest AIC value, and I will not attempt to describe here). Have a look at the following example with simulated data: rm(list=ls()) set.seed(123) x = rlnorm(100,0,1) hist(x) # Loglikelihood and AIC for lognormal model ll1 = function(param){ if(param[2]>0) return(-sum(dlnorm(x,param[1],param[2],log=T))) else return(Inf) } AIC1 = 2*optim(c(0,1),ll1)$value + 2*2 # Loglikelihood and AIC for Pareto model dpareto=function(x, shape=1, location=1) shape * location^shape / x^(shape + 1) ll2 = function(param){ if(param[1]>0 & min(x)> param[2]) return(-sum(log(dpareto(x,param[1],param[2])))) else return(Inf) } AIC2 = 2*optim(c(1,0.01),ll2)$value + 2*2 # Comparison using AIC, which in this case favours the lognormal model. c(AIC1,AIC2)
How to check if my data fits log normal distribution?
This is a matter of model selection, of course, assuming that you just want to check whether your data comes from one model or the other and that your goal is not finding the right model among the inf
How to check if my data fits log normal distribution? This is a matter of model selection, of course, assuming that you just want to check whether your data comes from one model or the other and that your goal is not finding the right model among the infinite dimensional ocean of distributions. So, one option is to use AIC (which favours models with the lowest AIC value, and I will not attempt to describe here). Have a look at the following example with simulated data: rm(list=ls()) set.seed(123) x = rlnorm(100,0,1) hist(x) # Loglikelihood and AIC for lognormal model ll1 = function(param){ if(param[2]>0) return(-sum(dlnorm(x,param[1],param[2],log=T))) else return(Inf) } AIC1 = 2*optim(c(0,1),ll1)$value + 2*2 # Loglikelihood and AIC for Pareto model dpareto=function(x, shape=1, location=1) shape * location^shape / x^(shape + 1) ll2 = function(param){ if(param[1]>0 & min(x)> param[2]) return(-sum(log(dpareto(x,param[1],param[2])))) else return(Inf) } AIC2 = 2*optim(c(1,0.01),ll2)$value + 2*2 # Comparison using AIC, which in this case favours the lognormal model. c(AIC1,AIC2)
How to check if my data fits log normal distribution? This is a matter of model selection, of course, assuming that you just want to check whether your data comes from one model or the other and that your goal is not finding the right model among the inf
26,141
How to check if my data fits log normal distribution?
Maybe fitdistr()? require(MASS) hist(x, freq=F) fit<-fitdistr(x,"log-normal")$estimate lines(dlnorm(0:max(x),fit[1],fit[2]), lwd=3) > fit meanlog sdlog 3.8181643 0.1871289 > dput(x) c(52.6866903145324, 39.7511298620398, 50.0577071855833, 33.8671245370402, 51.6325665911116, 41.1745418750494, 48.4259060939127, 67.0893697776377, 35.5355051232044, 44.6197404834786, 40.5620805256951, 39.4265590077884, 36.0718655240496, 56.0205581625823, 52.8039852992611, 46.2069383488226, 36.7324212941395, 44.7998046213554, 47.9727885542368, 36.3400338997286, 32.7514839453244, 50.6878893947656, 53.3756089181472, 39.4769689441593, 38.5432770167907, 62.350999487007, 44.5140171935881, 47.4026606915147, 57.3723511479393, 64.4041641945078, 51.2286815562554, 60.4921839777139, 71.6127652225805, 40.6395409719693, 48.681036613906, 52.3489622656967, 46.6219563536878, 55.6136160469819, 62.3003761050482, 42.7865905767138, 50.2413659137295, 45.6327941365187, 46.5621907725798, 48.9734785224035, 40.4828649022511, 59.4982559591637, 42.9450436744074, 66.8393386407167, 40.7248473206552, 45.9114242834839, 34.2671010054407, 45.7569869970351, 50.4358523486278, 44.7445606782492, 44.4173298921541, 41.7506552050873, 34.5657344132409, 47.7099864540652, 38.1680974794929, 42.2126680994737, 35.690599714042, 37.6748157160789, 35.0840798650981, 41.4775827114607, 36.6503753230464, 42.7539062488003, 39.2210050689652, 45.9364763482558, 35.3687017955285, 62.8299659875044, 38.1532612008011, 39.9183076516292, 59.0662388169057, 47.9032427690417, 42.4419580084314, 45.785859495192, 59.5254284342724, 47.9161476636566, 32.6868959277799, 30.1039453246766, 37.7606323857655, 35.754797368422, 35.5239777126187, 43.7874313667592, 53.0328404605954, 37.4550326357314, 42.7226751172495, 44.898430515261, 59.7229655935187, 41.0701258705001, 42.1672231656919, 60.9632847841197, 60.3690132883734, 45.6469334940722, 39.8300067022836, 51.8185235060234, 44.908828102875, 50.8200011497451, 53.7945569828737, 65.0432670527801, 49.0306734716282, 35.9442821219144, 46.8133296904456, 43.7514416949611, 43.7348972849838, 57.592040060118, 48.7913517211383, 38.5555058596449 )
How to check if my data fits log normal distribution?
Maybe fitdistr()? require(MASS) hist(x, freq=F) fit<-fitdistr(x,"log-normal")$estimate lines(dlnorm(0:max(x),fit[1],fit[2]), lwd=3) > fit meanlog sdlog 3.8181643 0.1871289 > dput(x) c(52.6
How to check if my data fits log normal distribution? Maybe fitdistr()? require(MASS) hist(x, freq=F) fit<-fitdistr(x,"log-normal")$estimate lines(dlnorm(0:max(x),fit[1],fit[2]), lwd=3) > fit meanlog sdlog 3.8181643 0.1871289 > dput(x) c(52.6866903145324, 39.7511298620398, 50.0577071855833, 33.8671245370402, 51.6325665911116, 41.1745418750494, 48.4259060939127, 67.0893697776377, 35.5355051232044, 44.6197404834786, 40.5620805256951, 39.4265590077884, 36.0718655240496, 56.0205581625823, 52.8039852992611, 46.2069383488226, 36.7324212941395, 44.7998046213554, 47.9727885542368, 36.3400338997286, 32.7514839453244, 50.6878893947656, 53.3756089181472, 39.4769689441593, 38.5432770167907, 62.350999487007, 44.5140171935881, 47.4026606915147, 57.3723511479393, 64.4041641945078, 51.2286815562554, 60.4921839777139, 71.6127652225805, 40.6395409719693, 48.681036613906, 52.3489622656967, 46.6219563536878, 55.6136160469819, 62.3003761050482, 42.7865905767138, 50.2413659137295, 45.6327941365187, 46.5621907725798, 48.9734785224035, 40.4828649022511, 59.4982559591637, 42.9450436744074, 66.8393386407167, 40.7248473206552, 45.9114242834839, 34.2671010054407, 45.7569869970351, 50.4358523486278, 44.7445606782492, 44.4173298921541, 41.7506552050873, 34.5657344132409, 47.7099864540652, 38.1680974794929, 42.2126680994737, 35.690599714042, 37.6748157160789, 35.0840798650981, 41.4775827114607, 36.6503753230464, 42.7539062488003, 39.2210050689652, 45.9364763482558, 35.3687017955285, 62.8299659875044, 38.1532612008011, 39.9183076516292, 59.0662388169057, 47.9032427690417, 42.4419580084314, 45.785859495192, 59.5254284342724, 47.9161476636566, 32.6868959277799, 30.1039453246766, 37.7606323857655, 35.754797368422, 35.5239777126187, 43.7874313667592, 53.0328404605954, 37.4550326357314, 42.7226751172495, 44.898430515261, 59.7229655935187, 41.0701258705001, 42.1672231656919, 60.9632847841197, 60.3690132883734, 45.6469334940722, 39.8300067022836, 51.8185235060234, 44.908828102875, 50.8200011497451, 53.7945569828737, 65.0432670527801, 49.0306734716282, 35.9442821219144, 46.8133296904456, 43.7514416949611, 43.7348972849838, 57.592040060118, 48.7913517211383, 38.5555058596449 )
How to check if my data fits log normal distribution? Maybe fitdistr()? require(MASS) hist(x, freq=F) fit<-fitdistr(x,"log-normal")$estimate lines(dlnorm(0:max(x),fit[1],fit[2]), lwd=3) > fit meanlog sdlog 3.8181643 0.1871289 > dput(x) c(52.6
26,142
Deviance vs Pearson goodness-of-fit
The goodness-of-fit test based on deviance is a likelihood-ratio test between the fitted model & the saturated one (one in which each observation gets its own parameter). Pearson's test is a score test; the expected value of the score (the first derivative of the log-likelihood function) is zero if the fitted model is correct, & you're taking a greater difference from zero as stronger evidence of lack of fit. The theory is discussed in Smyth (2003), "Pearson's goodness of fit statistic as a score test statistic", Statistics and science: a Festschrift for Terry Speed. In practice people usually rely on the asymptotic approximation of both to the chi-squared distribution - for a negative binomial model this means the expected counts shouldn't be too small. Smyth notes that the Pearson test is more robust against model mis-specification, as you're only considering the fitted model as a null without having to assume a particular form for a saturated model. I've never noticed much difference between them. You may want to reflect that a significant lack of fit with either tells you what you probably already know: that your model isn't a perfect representation of reality. You're more likely to be told this the larger your sample size. Perhaps a more germane question is whether or not you can improve your model, & what diagnostic methods can help you.
Deviance vs Pearson goodness-of-fit
The goodness-of-fit test based on deviance is a likelihood-ratio test between the fitted model & the saturated one (one in which each observation gets its own parameter). Pearson's test is a score tes
Deviance vs Pearson goodness-of-fit The goodness-of-fit test based on deviance is a likelihood-ratio test between the fitted model & the saturated one (one in which each observation gets its own parameter). Pearson's test is a score test; the expected value of the score (the first derivative of the log-likelihood function) is zero if the fitted model is correct, & you're taking a greater difference from zero as stronger evidence of lack of fit. The theory is discussed in Smyth (2003), "Pearson's goodness of fit statistic as a score test statistic", Statistics and science: a Festschrift for Terry Speed. In practice people usually rely on the asymptotic approximation of both to the chi-squared distribution - for a negative binomial model this means the expected counts shouldn't be too small. Smyth notes that the Pearson test is more robust against model mis-specification, as you're only considering the fitted model as a null without having to assume a particular form for a saturated model. I've never noticed much difference between them. You may want to reflect that a significant lack of fit with either tells you what you probably already know: that your model isn't a perfect representation of reality. You're more likely to be told this the larger your sample size. Perhaps a more germane question is whether or not you can improve your model, & what diagnostic methods can help you.
Deviance vs Pearson goodness-of-fit The goodness-of-fit test based on deviance is a likelihood-ratio test between the fitted model & the saturated one (one in which each observation gets its own parameter). Pearson's test is a score tes
26,143
What is the difference between probability and fuzzy logic?
Perhaps you're already aware of this, but Chapters 3, 7 and 9 of George J. Klir, and Bo Yuan's Fuzzy Sets and Fuzzy Logic: Theory and Applications (1995) provide in-depth discussions on the differences between the fuzzy and probabilistic versions of uncertainty, as well as several other types related to Evidence Theory, possibility distributions, etc. It is chock-full of formulas for measuring fuzziness (uncertainties in measurement scales) and probabilistic uncertainty (variants of Shannon's Entropy, etc.), plus a few for aggregating across these various types of uncertainty. There are also a few chapters on aggregating fuzzy numbers, fuzzy equations and fuzzy logic statements that you may find helpful. I translated a lot of these formulas into code, but am still learning the ropes as far as the math goes, so I'll let Klir and Yuan do the talking. :) I was able to pick up a used copy for $5 a few months back. Klir also wrote a follow-up book on Uncertainty around 2004, which I have yet to read. (My apologies if this thread is too old to respond to - I'm still learning the forum etiquette). Edited to add: I’m not sure which of the differences between fuzzy and probabilistic uncertainty the OP was already aware of and which he needed more info on, or what types of aggregations he meant, so I’ll just provide a list of some differences I gleaned from Klir and Yuan, off the top of my head. The gist is that yes, you can fuse fuzzy numbers, measures, etc. together, even with probabilities – but it quickly becomes very complex, albeit still quite useful. Fuzzy set uncertainty measures a completely different quantity than probability and its measures of uncertainty, like the Hartley Function (for nonspecificity) or Shannon's Entropy. Fuzziness and probabilistic uncertainty don't affect each other at all. There are a whole range of measures of fuzziness available, which quantify uncertainty in measurement boundaries (this is tangential to the measurement uncertainties normally discussed on CrossValidated, but not identical). The "fuzz" is added mainly in situations where it would be helpful to treat an ordinal variable as continuous, none of which has much to do with probabilities. Nevertheless, fuzzy sets and probabilities can be combined in myriad ways - such as adding fuzzy boundaries on probability values, or assessing the probability of a value or logical statement falling within a fuzzy range. This leads to a huge, wide-ranging taxonomy of combinations (which is one of the reasons I didn't include specifics before my first edit). As far as aggregation goes, the measures of fuzziness and entropic measures of probabilistic uncertainty can sometimes be summed together to give total measures of uncertainty. To add another level of complexity. fuzzy logic, numbers and sets can all be aggregated, which can affect the amount of resulting uncertainty. Klir and Yuan say the math can get really difficult for these tasks and since equation translations are one of my weak points (so far), I won't comment further. I just know these methods are presented in their book. Fuzzy logic, numbers, sets etc. are often chained together in a way probabilities aren't, which can complicate computation of the total uncertainty. For example, a computer programmer working in a Behavioral-Driven Development (BDD) system might translate a user's statement that "around half of these objects are black" into a fuzzy statement (around) about a fuzzy number (half). That would entail combining two different fuzzy objects to derive the measure of fuzziness for the whole thing. Sigma counts are more important in aggregating fuzzy objects than the kind of ordinary counts used in statistics. These are always less than the ordinary "crisp" count, because the membership functions that define fuzzy sets (which are always on the 0 to 1 scale) measure partial membership, so that a record with a score of 0.25 only counts as a quarter of a record. All of the above gives rise to a really complex set of fuzzy statistics, statistics on fuzzy sets, fuzzy statements about fuzzy sets, etc. If we're combining probabilities and fuzzy sets together, now we have to consider whether to use one of several different types of fuzzy variances, for example. Alpha cuts are a prominent feature of fuzzy set math, including the formulas for calculating uncertainties. They divide datasets into nested sets based on the values of the membership functions. I haven't yet encountered a similar concept with probabilities, but keep in mind that I’m still learning the ropes. Fuzzy sets can be interpreted in nuanced ways that produce the possibility distributions and belief scores used in fields like Evidence Theory, which includes the subtle concept of probability mass assignments. I liken it to the way in which conditional probabilities etc. can be reinterpreted as Bayesian priors and posteriors. This leads to separate definitions of fuzzy, nonspecificity and entropic uncertainty, although the formulas are obviously similar. They also give rise to strife, discord and conflict measures, which are additional forms of uncertainty that can be summed together with ordinary nonspecificity, fuzziness and entropy. Common probabilistic concepts like the Principle of Maximum Entropy are still operative, but sometimes require tweaking. I'm still trying to master the ordinary versions of them, so I can't say more than to point out that I know the tweaks exist. The long and the short of it is that these two distinct types of uncertainty can be aggregated, but that this quickly blows up into a whole taxonomy of fuzzy objects and stats based on them, all of which can affect the otherwise simple calculations. I don't even have room here to address the whole smorgasbord of fuzzy formulas for intersections and unions. These include T-norms and T-conorms that are sometimes used in the above calculations of uncertainty. I can't provide a simple answer, but that's not just due to inexperience - even 20 years after Klir and Yuan wrote, a lot of the math and use cases for things still don’t seem settled. For example, there I can’t find a clear, general guide on which T-conorms and T-norms to use in particular situations. Nevertheless, that will affect any aggregation of the uncertainties. I can look up specific formulas for some of these if you'd like; I coded some of them recently so they're still somewhat fresh. On the other hand, I’m an amateur with rusty math skills, so you’d probably be better off consulting these sources directly. I hope this edit is of use; if you need more clarification/info, let me know. 
What is the difference between probability and fuzzy logic?
Perhaps you're already aware of this, but Chapters 3, 7 and 9 of George J. Klir, and Bo Yuan's Fuzzy Sets and Fuzzy Logic: Theory and Applications (1995) provide in-depth discussions on the difference
What is the difference between probability and fuzzy logic? Perhaps you're already aware of this, but Chapters 3, 7 and 9 of George J. Klir, and Bo Yuan's Fuzzy Sets and Fuzzy Logic: Theory and Applications (1995) provide in-depth discussions on the differences between the fuzzy and probabilistic versions of uncertainty, as well as several other types related to Evidence Theory, possibility distributions, etc. It is chock-full of formulas for measuring fuzziness (uncertainties in measurement scales) and probabilistic uncertainty (variants of Shannon's Entropy, etc.), plus a few for aggregating across these various types of uncertainty. There are also a few chapters on aggregating fuzzy numbers, fuzzy equations and fuzzy logic statements that you may find helpful. I translated a lot of these formulas into code, but am still learning the ropes as far as the math goes, so I'll let Klir and Yuan do the talking. :) I was able to pick up a used copy for $5 a few months back. Klir also wrote a follow-up book on Uncertainty around 2004, which I have yet to read. (My apologies if this thread is too old to respond to - I'm still learning the forum etiquette). Edited to add: I’m not sure which of the differences between fuzzy and probabilistic uncertainty the OP was already aware of and which he needed more info on, or what types of aggregations he meant, so I’ll just provide a list of some differences I gleaned from Klir and Yuan, off the top of my head. The gist is that yes, you can fuse fuzzy numbers, measures, etc. together, even with probabilities – but it quickly becomes very complex, albeit still quite useful. Fuzzy set uncertainty measures a completely different quantity than probability and its measures of uncertainty, like the Hartley Function (for nonspecificity) or Shannon's Entropy. Fuzziness and probabilistic uncertainty don't affect each other at all. There are a whole range of measures of fuzziness available, which quantify uncertainty in measurement boundaries (this is tangential to the measurement uncertainties normally discussed on CrossValidated, but not identical). The "fuzz" is added mainly in situations where it would be helpful to treat an ordinal variable as continuous, none of which has much to do with probabilities. Nevertheless, fuzzy sets and probabilities can be combined in myriad ways - such as adding fuzzy boundaries on probability values, or assessing the probability of a value or logical statement falling within a fuzzy range. This leads to a huge, wide-ranging taxonomy of combinations (which is one of the reasons I didn't include specifics before my first edit). As far as aggregation goes, the measures of fuzziness and entropic measures of probabilistic uncertainty can sometimes be summed together to give total measures of uncertainty. To add another level of complexity. fuzzy logic, numbers and sets can all be aggregated, which can affect the amount of resulting uncertainty. Klir and Yuan say the math can get really difficult for these tasks and since equation translations are one of my weak points (so far), I won't comment further. I just know these methods are presented in their book. Fuzzy logic, numbers, sets etc. are often chained together in a way probabilities aren't, which can complicate computation of the total uncertainty. For example, a computer programmer working in a Behavioral-Driven Development (BDD) system might translate a user's statement that "around half of these objects are black" into a fuzzy statement (around) about a fuzzy number (half). That would entail combining two different fuzzy objects to derive the measure of fuzziness for the whole thing. Sigma counts are more important in aggregating fuzzy objects than the kind of ordinary counts used in statistics. These are always less than the ordinary "crisp" count, because the membership functions that define fuzzy sets (which are always on the 0 to 1 scale) measure partial membership, so that a record with a score of 0.25 only counts as a quarter of a record. All of the above gives rise to a really complex set of fuzzy statistics, statistics on fuzzy sets, fuzzy statements about fuzzy sets, etc. If we're combining probabilities and fuzzy sets together, now we have to consider whether to use one of several different types of fuzzy variances, for example. Alpha cuts are a prominent feature of fuzzy set math, including the formulas for calculating uncertainties. They divide datasets into nested sets based on the values of the membership functions. I haven't yet encountered a similar concept with probabilities, but keep in mind that I’m still learning the ropes. Fuzzy sets can be interpreted in nuanced ways that produce the possibility distributions and belief scores used in fields like Evidence Theory, which includes the subtle concept of probability mass assignments. I liken it to the way in which conditional probabilities etc. can be reinterpreted as Bayesian priors and posteriors. This leads to separate definitions of fuzzy, nonspecificity and entropic uncertainty, although the formulas are obviously similar. They also give rise to strife, discord and conflict measures, which are additional forms of uncertainty that can be summed together with ordinary nonspecificity, fuzziness and entropy. Common probabilistic concepts like the Principle of Maximum Entropy are still operative, but sometimes require tweaking. I'm still trying to master the ordinary versions of them, so I can't say more than to point out that I know the tweaks exist. The long and the short of it is that these two distinct types of uncertainty can be aggregated, but that this quickly blows up into a whole taxonomy of fuzzy objects and stats based on them, all of which can affect the otherwise simple calculations. I don't even have room here to address the whole smorgasbord of fuzzy formulas for intersections and unions. These include T-norms and T-conorms that are sometimes used in the above calculations of uncertainty. I can't provide a simple answer, but that's not just due to inexperience - even 20 years after Klir and Yuan wrote, a lot of the math and use cases for things still don’t seem settled. For example, there I can’t find a clear, general guide on which T-conorms and T-norms to use in particular situations. Nevertheless, that will affect any aggregation of the uncertainties. I can look up specific formulas for some of these if you'd like; I coded some of them recently so they're still somewhat fresh. On the other hand, I’m an amateur with rusty math skills, so you’d probably be better off consulting these sources directly. I hope this edit is of use; if you need more clarification/info, let me know. 
What is the difference between probability and fuzzy logic? Perhaps you're already aware of this, but Chapters 3, 7 and 9 of George J. Klir, and Bo Yuan's Fuzzy Sets and Fuzzy Logic: Theory and Applications (1995) provide in-depth discussions on the difference
26,144
What is the difference between probability and fuzzy logic?
Probability: you are given a beaker full of liquid. There's a 1% chance the liquid is acid, 99% chance it's beer. Fuzzy logic: you are given a beaker full of liquid. The liquid has 99% the characteristics of beer, 1% characteristics of acid. You want beer. Which breaker do you drink? courtesy of Prof. Jerry Mendel, University of Southern California, retired.
What is the difference between probability and fuzzy logic?
Probability: you are given a beaker full of liquid. There's a 1% chance the liquid is acid, 99% chance it's beer. Fuzzy logic: you are given a beaker full of liquid. The liquid has 99% the characteri
What is the difference between probability and fuzzy logic? Probability: you are given a beaker full of liquid. There's a 1% chance the liquid is acid, 99% chance it's beer. Fuzzy logic: you are given a beaker full of liquid. The liquid has 99% the characteristics of beer, 1% characteristics of acid. You want beer. Which breaker do you drink? courtesy of Prof. Jerry Mendel, University of Southern California, retired.
What is the difference between probability and fuzzy logic? Probability: you are given a beaker full of liquid. There's a 1% chance the liquid is acid, 99% chance it's beer. Fuzzy logic: you are given a beaker full of liquid. The liquid has 99% the characteri
26,145
Difference between null distribution and sampling distribution
'Null distribution' is short for the sampling distribution of a statistic under the null hypothesis. 'Sampling distribution' you have to understand from the context: in the context you describe it also means the sampling distribution of a statistic under the null hypothesis, but in another context it could refer to the sampling distribution of a statistic under an alternative hypothesis.
Difference between null distribution and sampling distribution
'Null distribution' is short for the sampling distribution of a statistic under the null hypothesis. 'Sampling distribution' you have to understand from the context: in the context you describe it als
Difference between null distribution and sampling distribution 'Null distribution' is short for the sampling distribution of a statistic under the null hypothesis. 'Sampling distribution' you have to understand from the context: in the context you describe it also means the sampling distribution of a statistic under the null hypothesis, but in another context it could refer to the sampling distribution of a statistic under an alternative hypothesis.
Difference between null distribution and sampling distribution 'Null distribution' is short for the sampling distribution of a statistic under the null hypothesis. 'Sampling distribution' you have to understand from the context: in the context you describe it als
26,146
Difference between null distribution and sampling distribution
The sampling distribution is the distribution of a statistic i.e., a data summary such as the sample mean whose value changes from sample to sample. In hypothesis testing, a test statistic compares the data to what is expected under the null hypothesis, and is defined in such a way that its value is larger under the alternative hypothesis. The null distribution is the distribution of the test statistic under the null hypothesis. Hypothesis testing is based on assessing the consistency of the observed value of the test statistic with the null distribution. If the observed value of the test statistic falls in the tail of the null distribution, the null hypothesis is rejected, otherwise it is maintained. As for your question, sampling distribution is not the same as null distribution, but the null distribution is a sampling distribution. More precisely, the null distribution is the sampling distribution of the test statistic under the null hypothesis.
Difference between null distribution and sampling distribution
The sampling distribution is the distribution of a statistic i.e., a data summary such as the sample mean whose value changes from sample to sample. In hypothesis testing, a test statistic compares th
Difference between null distribution and sampling distribution The sampling distribution is the distribution of a statistic i.e., a data summary such as the sample mean whose value changes from sample to sample. In hypothesis testing, a test statistic compares the data to what is expected under the null hypothesis, and is defined in such a way that its value is larger under the alternative hypothesis. The null distribution is the distribution of the test statistic under the null hypothesis. Hypothesis testing is based on assessing the consistency of the observed value of the test statistic with the null distribution. If the observed value of the test statistic falls in the tail of the null distribution, the null hypothesis is rejected, otherwise it is maintained. As for your question, sampling distribution is not the same as null distribution, but the null distribution is a sampling distribution. More precisely, the null distribution is the sampling distribution of the test statistic under the null hypothesis.
Difference between null distribution and sampling distribution The sampling distribution is the distribution of a statistic i.e., a data summary such as the sample mean whose value changes from sample to sample. In hypothesis testing, a test statistic compares th
26,147
Expected value of a Gaussian random variable transformed with a logistic function
The following is what I ended up using: Write $\sigma(N(\mu,s^2)) = \sigma(\mu + X)$ where $X \sim N(0,s^2)$. We can use a Taylor series expansion. $\sigma(\mu + X) = \sigma(\mu) + X \sigma'(\mu) + \frac{X^2}{2} \sigma''(\mu)+ ... + \frac{X^n}{n!}\sigma^{(n)}(\mu) + ...$ $\begin{eqnarray} E[\sigma(\mu + X)] & =& E[\sigma(\mu)] + E[X \sigma'(\mu)] + E[\frac{X^2}{2} \sigma''(\mu)] + ... \newline & = & \sigma(\mu) + 0 + \frac{s^2}{2}\sigma''(\mu) + 0 + \frac{3s^4}{24}\sigma^{(4)}(\mu)+ ... + \frac{s^{2k}}{2^k k!}\sigma^{(2k)}(\mu) ... \end{eqnarray}$ There are convergence issues. The logistic function has a pole where $\exp(-x) = -1$, so at $x = k \pi i$, $k$ odd. Divergence is not the same thing as the prefix being useless, but this series approximation may be unreliable when $P(|X| \gt \sqrt{\mu^2 + \pi^2})$ is significant. Since $\sigma'(x) = \sigma(x) (1-\sigma(x))$, we can write derivatives of $\sigma(x)$ as polynomials in $\sigma(x)$. For example, $\sigma'' = \sigma-3\sigma^2+2\sigma^3$ and $\sigma''' = \sigma - 7\sigma^2 + 12 \sigma^3 - 6\sigma^4$. The coefficients are related to OEIS A028246.
Expected value of a Gaussian random variable transformed with a logistic function
The following is what I ended up using: Write $\sigma(N(\mu,s^2)) = \sigma(\mu + X)$ where $X \sim N(0,s^2)$. We can use a Taylor series expansion. $\sigma(\mu + X) = \sigma(\mu) + X \sigma'(\mu) + \f
Expected value of a Gaussian random variable transformed with a logistic function The following is what I ended up using: Write $\sigma(N(\mu,s^2)) = \sigma(\mu + X)$ where $X \sim N(0,s^2)$. We can use a Taylor series expansion. $\sigma(\mu + X) = \sigma(\mu) + X \sigma'(\mu) + \frac{X^2}{2} \sigma''(\mu)+ ... + \frac{X^n}{n!}\sigma^{(n)}(\mu) + ...$ $\begin{eqnarray} E[\sigma(\mu + X)] & =& E[\sigma(\mu)] + E[X \sigma'(\mu)] + E[\frac{X^2}{2} \sigma''(\mu)] + ... \newline & = & \sigma(\mu) + 0 + \frac{s^2}{2}\sigma''(\mu) + 0 + \frac{3s^4}{24}\sigma^{(4)}(\mu)+ ... + \frac{s^{2k}}{2^k k!}\sigma^{(2k)}(\mu) ... \end{eqnarray}$ There are convergence issues. The logistic function has a pole where $\exp(-x) = -1$, so at $x = k \pi i$, $k$ odd. Divergence is not the same thing as the prefix being useless, but this series approximation may be unreliable when $P(|X| \gt \sqrt{\mu^2 + \pi^2})$ is significant. Since $\sigma'(x) = \sigma(x) (1-\sigma(x))$, we can write derivatives of $\sigma(x)$ as polynomials in $\sigma(x)$. For example, $\sigma'' = \sigma-3\sigma^2+2\sigma^3$ and $\sigma''' = \sigma - 7\sigma^2 + 12 \sigma^3 - 6\sigma^4$. The coefficients are related to OEIS A028246.
Expected value of a Gaussian random variable transformed with a logistic function The following is what I ended up using: Write $\sigma(N(\mu,s^2)) = \sigma(\mu + X)$ where $X \sim N(0,s^2)$. We can use a Taylor series expansion. $\sigma(\mu + X) = \sigma(\mu) + X \sigma'(\mu) + \f
26,148
Expected value of a Gaussian random variable transformed with a logistic function
What you have here is a random variable that follows a logit-normal (or logistic-normal) distribution (see wikipedia), that is, $\mbox{logit}[x] \sim N(\mu, s^2)$. The moments of the logit-normal distribution do not have analytical solutions. But of course one can get them via numerical integration. If you use R, there is the logitnorm package that has everything you need. An example: install.packages("logitnorm") library(logitnorm) momentsLogitnorm(mu=1, sigma=2) This yields: > momentsLogitnorm(mu=1, sigma=2) mean var 0.64772644 0.08767866 So, there is even a convenience function that will directly give you the mean and variance.
Expected value of a Gaussian random variable transformed with a logistic function
What you have here is a random variable that follows a logit-normal (or logistic-normal) distribution (see wikipedia), that is, $\mbox{logit}[x] \sim N(\mu, s^2)$. The moments of the logit-normal dist
Expected value of a Gaussian random variable transformed with a logistic function What you have here is a random variable that follows a logit-normal (or logistic-normal) distribution (see wikipedia), that is, $\mbox{logit}[x] \sim N(\mu, s^2)$. The moments of the logit-normal distribution do not have analytical solutions. But of course one can get them via numerical integration. If you use R, there is the logitnorm package that has everything you need. An example: install.packages("logitnorm") library(logitnorm) momentsLogitnorm(mu=1, sigma=2) This yields: > momentsLogitnorm(mu=1, sigma=2) mean var 0.64772644 0.08767866 So, there is even a convenience function that will directly give you the mean and variance.
Expected value of a Gaussian random variable transformed with a logistic function What you have here is a random variable that follows a logit-normal (or logistic-normal) distribution (see wikipedia), that is, $\mbox{logit}[x] \sim N(\mu, s^2)$. The moments of the logit-normal dist
26,149
Model suggestion for a Cox regression with time dependent covariates
What you need here is a time-varying covariate and not necessarily a time-varying coefficient. A known example that could help you with your analyses is the Stanford heart transplant data. To present your results you can use the classic Kaplan-Meier estimator that handles time-varying covariates with no problems (remember, though, that this is a crude - or unadjusted analysis with all its well-known limitations). As an example, the following graph shows the analysis of the Stanford HT data when correctly accounting for the time-varying transplant status (top panel) and without accounting for it (bottom panel).
Model suggestion for a Cox regression with time dependent covariates
What you need here is a time-varying covariate and not necessarily a time-varying coefficient. A known example that could help you with your analyses is the Stanford heart transplant data. To present
Model suggestion for a Cox regression with time dependent covariates What you need here is a time-varying covariate and not necessarily a time-varying coefficient. A known example that could help you with your analyses is the Stanford heart transplant data. To present your results you can use the classic Kaplan-Meier estimator that handles time-varying covariates with no problems (remember, though, that this is a crude - or unadjusted analysis with all its well-known limitations). As an example, the following graph shows the analysis of the Stanford HT data when correctly accounting for the time-varying transplant status (top panel) and without accounting for it (bottom panel).
Model suggestion for a Cox regression with time dependent covariates What you need here is a time-varying covariate and not necessarily a time-varying coefficient. A known example that could help you with your analyses is the Stanford heart transplant data. To present
26,150
Model suggestion for a Cox regression with time dependent covariates
In R, this can be addressed with the start/stop version of a Survival object, e.g. fit <- coxph(Surv(time1, time2, status) ~ is.pregnant + other.covariates, data=mydata) This paper discusses this in more detail: http://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf
Model suggestion for a Cox regression with time dependent covariates
In R, this can be addressed with the start/stop version of a Survival object, e.g. fit <- coxph(Surv(time1, time2, status) ~ is.pregnant + other.covariates, data=mydata) This paper discusses this in
Model suggestion for a Cox regression with time dependent covariates In R, this can be addressed with the start/stop version of a Survival object, e.g. fit <- coxph(Surv(time1, time2, status) ~ is.pregnant + other.covariates, data=mydata) This paper discusses this in more detail: http://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf
Model suggestion for a Cox regression with time dependent covariates In R, this can be addressed with the start/stop version of a Survival object, e.g. fit <- coxph(Surv(time1, time2, status) ~ is.pregnant + other.covariates, data=mydata) This paper discusses this in
26,151
Model suggestion for a Cox regression with time dependent covariates
Beware immortal time bias in this situation. Your pregnant group will inevitably have a better survival than the non-pregnant group since you can't become pregnant after you die (to the best of my knowledge!)
Model suggestion for a Cox regression with time dependent covariates
Beware immortal time bias in this situation. Your pregnant group will inevitably have a better survival than the non-pregnant group since you can't become pregnant after you die (to the best of my kno
Model suggestion for a Cox regression with time dependent covariates Beware immortal time bias in this situation. Your pregnant group will inevitably have a better survival than the non-pregnant group since you can't become pregnant after you die (to the best of my knowledge!)
Model suggestion for a Cox regression with time dependent covariates Beware immortal time bias in this situation. Your pregnant group will inevitably have a better survival than the non-pregnant group since you can't become pregnant after you die (to the best of my kno
26,152
Random assignment: why bother?
This follows up on gung's comment. Overall average treatment effect is not the point. Suppose you have $1000$ new diabetes cases where the subject is between the ages of $5$ and $15$, and $1000$ new diabetes patients over $30$. You want to assign half to treatment. Why not flip a coin, and on heads, treat all of the young patients, and on tails, treat all of the older patients? Each would have a $50\%$ chance to be selected fro treatment, so this would not bias the average result of the treatment, but it would throw away a lot of information. It would not be a surprise if juvenile diabetes or younger patients turned out to respond much better or worse than older patients with either type II or gestational diabetes. The observed treatment effect might be unbiased but, for example, it would have a much larger standard deviation than would occur through random assignment, and despite the large sample you would not be able to say much. If you use random assignment, then with high probability about $500$ cases in each age group would get the treatment, so you would be able to compare treatment with no treatment within each age group. You may be able to do better than to use random assignment. If you notice a factor you think might affect the response to treatment, you might want to ensure that subjects with that attribute are split more evenly than would occur through random assignment. Random assignment lets you do reasonably well with all factors simultaneously, so that you can analyze many possible patterns afterwards.
Random assignment: why bother?
This follows up on gung's comment. Overall average treatment effect is not the point. Suppose you have $1000$ new diabetes cases where the subject is between the ages of $5$ and $15$, and $1000$ new d
Random assignment: why bother? This follows up on gung's comment. Overall average treatment effect is not the point. Suppose you have $1000$ new diabetes cases where the subject is between the ages of $5$ and $15$, and $1000$ new diabetes patients over $30$. You want to assign half to treatment. Why not flip a coin, and on heads, treat all of the young patients, and on tails, treat all of the older patients? Each would have a $50\%$ chance to be selected fro treatment, so this would not bias the average result of the treatment, but it would throw away a lot of information. It would not be a surprise if juvenile diabetes or younger patients turned out to respond much better or worse than older patients with either type II or gestational diabetes. The observed treatment effect might be unbiased but, for example, it would have a much larger standard deviation than would occur through random assignment, and despite the large sample you would not be able to say much. If you use random assignment, then with high probability about $500$ cases in each age group would get the treatment, so you would be able to compare treatment with no treatment within each age group. You may be able to do better than to use random assignment. If you notice a factor you think might affect the response to treatment, you might want to ensure that subjects with that attribute are split more evenly than would occur through random assignment. Random assignment lets you do reasonably well with all factors simultaneously, so that you can analyze many possible patterns afterwards.
Random assignment: why bother? This follows up on gung's comment. Overall average treatment effect is not the point. Suppose you have $1000$ new diabetes cases where the subject is between the ages of $5$ and $15$, and $1000$ new d
26,153
Random assignment: why bother?
In your example you can leave 2 and 5 out as well and not contradict yourself. At an item level there's still an equal chance of being 1 or 0 when there's just a 1:1 odds of selecting 1 or 6. But, now what you did by removing 3 and 4 becomes more obvious.
Random assignment: why bother?
In your example you can leave 2 and 5 out as well and not contradict yourself. At an item level there's still an equal chance of being 1 or 0 when there's just a 1:1 odds of selecting 1 or 6. But, n
Random assignment: why bother? In your example you can leave 2 and 5 out as well and not contradict yourself. At an item level there's still an equal chance of being 1 or 0 when there's just a 1:1 odds of selecting 1 or 6. But, now what you did by removing 3 and 4 becomes more obvious.
Random assignment: why bother? In your example you can leave 2 and 5 out as well and not contradict yourself. At an item level there's still an equal chance of being 1 or 0 when there's just a 1:1 odds of selecting 1 or 6. But, n
26,154
Random assignment: why bother?
Here's another one of the lurking or confounding variables: time (or instrumental drift, effects of sample storage, etc.). So there are arguments against randomization (as Douglas says: you may do better than randomization). E.g. you can know beforehand that you want your cases to be balanced over time. Just as you can know beforehand that you want to have gender and age balanced. In other words, if you want to manually choose one of your 6 schemes, I'd say that 1100 (or 0011) is a decidedly bad choice. Note that the first possibilites you threw out are those that are most balanced in time... And the worst two are left in after John proposed to thow out also 2 and 5 (against which you did not protest). In other words, your intuition which schemes are "nice" unfortunately leads towards bad experimental design (IMHO this is quite common; maybe ordered things look nicer - and for sure it is easier to keep track of logical sequences during the experiment). You may be able to do better with non-randomized schemes, but you are also able to do much worse. IMHO, you should be able to give physical/chemical/biological/medical/... arguments for the particular non-random scheme you use, if you go for a non-random scheme.
Random assignment: why bother?
Here's another one of the lurking or confounding variables: time (or instrumental drift, effects of sample storage, etc.). So there are arguments against randomization (as Douglas says: you may do bet
Random assignment: why bother? Here's another one of the lurking or confounding variables: time (or instrumental drift, effects of sample storage, etc.). So there are arguments against randomization (as Douglas says: you may do better than randomization). E.g. you can know beforehand that you want your cases to be balanced over time. Just as you can know beforehand that you want to have gender and age balanced. In other words, if you want to manually choose one of your 6 schemes, I'd say that 1100 (or 0011) is a decidedly bad choice. Note that the first possibilites you threw out are those that are most balanced in time... And the worst two are left in after John proposed to thow out also 2 and 5 (against which you did not protest). In other words, your intuition which schemes are "nice" unfortunately leads towards bad experimental design (IMHO this is quite common; maybe ordered things look nicer - and for sure it is easier to keep track of logical sequences during the experiment). You may be able to do better with non-randomized schemes, but you are also able to do much worse. IMHO, you should be able to give physical/chemical/biological/medical/... arguments for the particular non-random scheme you use, if you go for a non-random scheme.
Random assignment: why bother? Here's another one of the lurking or confounding variables: time (or instrumental drift, effects of sample storage, etc.). So there are arguments against randomization (as Douglas says: you may do bet
26,155
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
According to the manifold hypothesis, the data is assumed to lie on a low-dimensional manifold, the implication being that the residual is noise, so if you do your dimensionality reduction correctly, you should improve performance by modeling the signal rather than the noise. It's not just a question of space and complexity.
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
According to the manifold hypothesis, the data is assumed to lie on a low-dimensional manifold, the implication being that the residual is noise, so if you do your dimensionality reduction correctly,
What is the advantage of reducing dimensionality of predictors for the purposes of regression? According to the manifold hypothesis, the data is assumed to lie on a low-dimensional manifold, the implication being that the residual is noise, so if you do your dimensionality reduction correctly, you should improve performance by modeling the signal rather than the noise. It's not just a question of space and complexity.
What is the advantage of reducing dimensionality of predictors for the purposes of regression? According to the manifold hypothesis, the data is assumed to lie on a low-dimensional manifold, the implication being that the residual is noise, so if you do your dimensionality reduction correctly,
26,156
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
The purpose of dimensionality reduction in regression is regularization. Most of the techniques that you listed are not very well known; I have not heard about any of them apart from principal components regression (PCR). So I will reply about PCR but expect that the same applies to the other techniques as well. The two key words here are overfitting and regularization. For a long treatment and discussion I refer you to The Elements of Statistical Learning, but very briefly, what happens if you have a lot of predictors ($p$) and not enough samples ($n$) is that standard regression will overfit the data and you will construct a model that seems to have good performance on the training set but actually has very poor performance on any test set. In an extreme example, when number of predictors exceeds number of samples (people refer to it as to $p>n$ problem), you can actually perfectly fit any response variable $y$, achieving seemingly $100\%$ performance. This is clearly nonsense. To deal with overfitting one has to use regularization, and there are plenty of different regularization strategies. In some approaches one tries to drastically reduce the number of predictors, reducing the problem to the $p\ll n$ situation, and then to use standard regression. This is exactly what principal components regression does. Please see The Elements, sections 3.4--3.6. PCR is usually suboptimal and in most cases some other regularization methods will perform better, but it is easy to understand and interpret. Note that PCR is not arbitrary either (e.g. randomly keeping $p$ dimensions is likely to perform much worse). The reason for this is that PCR is closely connected to ridge regression, which is a standard shrinkage regularizer that is known to work well in a large variety of cases. See my answer here for the comparison: Relationship between ridge regression and PCA regression. To see a performance increase compared to standard regression, you need a dataset with a lot of predictors and not so many samples, and you definitely need to use cross-validation or an independent test set. If you did not see any performance increase, then perhaps your dataset did not have enough dimensions. Related threads with good answers: Regression in $p\gg N$ setting (predicting drug efficiency from gene expression with 30k predictors and ~30 samples) Regression in $p>n$ setting: how to choose regularization method (Lasso, PLS, PCR, ridge)?
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
The purpose of dimensionality reduction in regression is regularization. Most of the techniques that you listed are not very well known; I have not heard about any of them apart from principal compone
What is the advantage of reducing dimensionality of predictors for the purposes of regression? The purpose of dimensionality reduction in regression is regularization. Most of the techniques that you listed are not very well known; I have not heard about any of them apart from principal components regression (PCR). So I will reply about PCR but expect that the same applies to the other techniques as well. The two key words here are overfitting and regularization. For a long treatment and discussion I refer you to The Elements of Statistical Learning, but very briefly, what happens if you have a lot of predictors ($p$) and not enough samples ($n$) is that standard regression will overfit the data and you will construct a model that seems to have good performance on the training set but actually has very poor performance on any test set. In an extreme example, when number of predictors exceeds number of samples (people refer to it as to $p>n$ problem), you can actually perfectly fit any response variable $y$, achieving seemingly $100\%$ performance. This is clearly nonsense. To deal with overfitting one has to use regularization, and there are plenty of different regularization strategies. In some approaches one tries to drastically reduce the number of predictors, reducing the problem to the $p\ll n$ situation, and then to use standard regression. This is exactly what principal components regression does. Please see The Elements, sections 3.4--3.6. PCR is usually suboptimal and in most cases some other regularization methods will perform better, but it is easy to understand and interpret. Note that PCR is not arbitrary either (e.g. randomly keeping $p$ dimensions is likely to perform much worse). The reason for this is that PCR is closely connected to ridge regression, which is a standard shrinkage regularizer that is known to work well in a large variety of cases. See my answer here for the comparison: Relationship between ridge regression and PCA regression. To see a performance increase compared to standard regression, you need a dataset with a lot of predictors and not so many samples, and you definitely need to use cross-validation or an independent test set. If you did not see any performance increase, then perhaps your dataset did not have enough dimensions. Related threads with good answers: Regression in $p\gg N$ setting (predicting drug efficiency from gene expression with 30k predictors and ~30 samples) Regression in $p>n$ setting: how to choose regularization method (Lasso, PLS, PCR, ridge)?
What is the advantage of reducing dimensionality of predictors for the purposes of regression? The purpose of dimensionality reduction in regression is regularization. Most of the techniques that you listed are not very well known; I have not heard about any of them apart from principal compone
26,157
Fitting multiple linear regression in R: autocorrelated residuals
Try library(forecast) fit <- auto.arima(rate, xreg=cbind(askings,questions)) That will fit the linear model as will as automatically identify an ARMA structure for the errors. It uses MLE rather than GLS, but they are asymptotically equivalent.
Fitting multiple linear regression in R: autocorrelated residuals
Try library(forecast) fit <- auto.arima(rate, xreg=cbind(askings,questions)) That will fit the linear model as will as automatically identify an ARMA structure for the errors. It uses MLE rather than
Fitting multiple linear regression in R: autocorrelated residuals Try library(forecast) fit <- auto.arima(rate, xreg=cbind(askings,questions)) That will fit the linear model as will as automatically identify an ARMA structure for the errors. It uses MLE rather than GLS, but they are asymptotically equivalent.
Fitting multiple linear regression in R: autocorrelated residuals Try library(forecast) fit <- auto.arima(rate, xreg=cbind(askings,questions)) That will fit the linear model as will as automatically identify an ARMA structure for the errors. It uses MLE rather than
26,158
Fitting multiple linear regression in R: autocorrelated residuals
If prediction is you purpose, you could fit a range of models over parameters: expand.grid(p = 1:P, q = 1:Q) where P and Q are the maximal AR(p) and MA(q) terms you wish to include and choose the best fitting model as determined by BIC. auto.arima() in package forecast will help with this, but it can be coded easily by hand using expand.grid() and loop and the arima() function that comes with R. The above is fitting on the residuals from a gls() with no correlation structure. You could also do the whole thing by hand directly with gls() by just fitting lots of models for combinations of p and q and the in built AIC() function. You could also plot the ACF (acf()) and partial ACF (pacf()) of the residuals from a linear model without correlation structure and use them to suggest the order of model required.
Fitting multiple linear regression in R: autocorrelated residuals
If prediction is you purpose, you could fit a range of models over parameters: expand.grid(p = 1:P, q = 1:Q) where P and Q are the maximal AR(p) and MA(q) terms you wish to include and choose the bes
Fitting multiple linear regression in R: autocorrelated residuals If prediction is you purpose, you could fit a range of models over parameters: expand.grid(p = 1:P, q = 1:Q) where P and Q are the maximal AR(p) and MA(q) terms you wish to include and choose the best fitting model as determined by BIC. auto.arima() in package forecast will help with this, but it can be coded easily by hand using expand.grid() and loop and the arima() function that comes with R. The above is fitting on the residuals from a gls() with no correlation structure. You could also do the whole thing by hand directly with gls() by just fitting lots of models for combinations of p and q and the in built AIC() function. You could also plot the ACF (acf()) and partial ACF (pacf()) of the residuals from a linear model without correlation structure and use them to suggest the order of model required.
Fitting multiple linear regression in R: autocorrelated residuals If prediction is you purpose, you could fit a range of models over parameters: expand.grid(p = 1:P, q = 1:Q) where P and Q are the maximal AR(p) and MA(q) terms you wish to include and choose the bes
26,159
Classification model for movie rating prediction
Hein, there are a lot of tools and libs with the functionality available. Which to choose depends whether you would like to use a gui for your work or if you would like to embed it in some other program. Standalone Data mining tools (there are ohters like WEKA with Java interface): Rapid Miner Orange Rattle gui for R KNIME Text based: GNU R Libs: Scikit for Python Mahout on Hadoop If you know a programming language well enough I would use a lib for that language or give R a try. If not you may try one of the tools with gui. A tree example in R: # we are using the iris dataset data(iris) # for our tree based model we use the rpart package # to download it type install.packages("rpart") library(rpart) # Building the tree fit <- rpart(Species ~ Petal.Length + Petal.Width, method="class", data=iris) # Plot the tree plot(fit) text(fit) As suggested the analysis with R requires you to code yourself, but you will find a package for most classification tasks which will work out of the box. An overview can be found here Machine Learning Task View To get started with RapidMinder you should have a look at Youtube. There are some screencasts, even for decision trees.
Classification model for movie rating prediction
Hein, there are a lot of tools and libs with the functionality available. Which to choose depends whether you would like to use a gui for your work or if you would like to embed it in some other prog
Classification model for movie rating prediction Hein, there are a lot of tools and libs with the functionality available. Which to choose depends whether you would like to use a gui for your work or if you would like to embed it in some other program. Standalone Data mining tools (there are ohters like WEKA with Java interface): Rapid Miner Orange Rattle gui for R KNIME Text based: GNU R Libs: Scikit for Python Mahout on Hadoop If you know a programming language well enough I would use a lib for that language or give R a try. If not you may try one of the tools with gui. A tree example in R: # we are using the iris dataset data(iris) # for our tree based model we use the rpart package # to download it type install.packages("rpart") library(rpart) # Building the tree fit <- rpart(Species ~ Petal.Length + Petal.Width, method="class", data=iris) # Plot the tree plot(fit) text(fit) As suggested the analysis with R requires you to code yourself, but you will find a package for most classification tasks which will work out of the box. An overview can be found here Machine Learning Task View To get started with RapidMinder you should have a look at Youtube. There are some screencasts, even for decision trees.
Classification model for movie rating prediction Hein, there are a lot of tools and libs with the functionality available. Which to choose depends whether you would like to use a gui for your work or if you would like to embed it in some other prog
26,160
Classification model for movie rating prediction
Weka is a free and open-source machine-learning suite of tools. They have a GUI as well as an API to call from your Java code if you want. They have many classification algorithms including several decision tree algorithms. These are available in the UI. Nearest neighbors are a bit more tricky and it seems you have to use the API directly. I think Rapid Miner probably supports this type of thing, but I haven't used it for such purposes before. You might also consider R, but that might require getting your hands a little dirtier. Note that Netflix has done a ton of work in movie rating classification. Several years ago they offered a $1 million prize to the group that could improve their classification the most. You might be interested in reading how various teams approached that problem.
Classification model for movie rating prediction
Weka is a free and open-source machine-learning suite of tools. They have a GUI as well as an API to call from your Java code if you want. They have many classification algorithms including several d
Classification model for movie rating prediction Weka is a free and open-source machine-learning suite of tools. They have a GUI as well as an API to call from your Java code if you want. They have many classification algorithms including several decision tree algorithms. These are available in the UI. Nearest neighbors are a bit more tricky and it seems you have to use the API directly. I think Rapid Miner probably supports this type of thing, but I haven't used it for such purposes before. You might also consider R, but that might require getting your hands a little dirtier. Note that Netflix has done a ton of work in movie rating classification. Several years ago they offered a $1 million prize to the group that could improve their classification the most. You might be interested in reading how various teams approached that problem.
Classification model for movie rating prediction Weka is a free and open-source machine-learning suite of tools. They have a GUI as well as an API to call from your Java code if you want. They have many classification algorithms including several d
26,161
Classification model for movie rating prediction
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. May be... WEKA? http://www.cs.waikato.ac.nz/ml/weka/
Classification model for movie rating prediction
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Classification model for movie rating prediction Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. May be... WEKA? http://www.cs.waikato.ac.nz/ml/weka/
Classification model for movie rating prediction Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
26,162
Power for two sample t test
You're close, some small changes are required though: The true difference in means is typically taken as $\mu_{2} - \mu_{1}$, not the other way around. G*Power uses $n_{1}+n_{2} - 2$ as degrees of freedom for the $t$-distribution in this case (different variances, same group sizes), following a suggestion from Cohen as explained here SAS might use Welch's formula or Satterthwaite's formula for the df given unequal variances (found in this pdf you cited) - with only 2 significant digits in the result one cannot tell (see below) With n1, n2, mu1, mu2, sd1, sd2 as defined in your question: > alpha <- 0.05 > dfGP <- n1+n2 - 2 # degrees of freedom (used by G*Power) > cvGP <- qt(1-alpha, dfGP) # crit. value for one-sided test (under the null) > muDiff <- mu2-mu1 # true difference in means > sigDiff <- sqrt((sd1^2/n1) + (sd2^2/n2)) # true SD for difference in empirical means > ncp <- muDiff / sigDiff # noncentrality parameter (under alternative) > 1-pt(cvGP, dfGP, ncp) # power [1] 0.3348385 This matches the result from G*Power which is a great program for these questions. It displays the df, critical value, ncp as well, so you can check all these calculations separately. Edit: Using Satterthwaite's formula or Welch's formula doesn't change much (still 0.33*): # Satterthwaite's formula > var1 <- sd1^2 > var2 <- sd2^2 > num <- (var1/n1 + var2/n2)^2 > denST <- var1^2/((n1-1)*n1^2) + var2^2/((n2-1)*n2^2) > (dfST <- num/denST) [1] 33.10309 > cvST <- qt(1-alpha, dfST) > 1-pt(cvST, dfST, ncp) [1] 0.3336495 # Welch's formula > denW <- var1^2/((n1+1)*n1^2) + var2^2/((n2+1)*n2^2) > (dfW <- (num/denW) - 2) [1] 34.58763 > cvW <- qt(1-alpha, dfW) > 1-pt(cvW, dfW, ncp) [1] 0.3340453 (note that I slightly changed some variable names as t, df, and diff are also names of built-in functions, also note that the numerator of your code for df is wrong, it has a misplaced ^2, and one ^2 too many, it should be ((sd1^2/n1) + (sd2^2/n2))^2)
Power for two sample t test
You're close, some small changes are required though: The true difference in means is typically taken as $\mu_{2} - \mu_{1}$, not the other way around. G*Power uses $n_{1}+n_{2} - 2$ as degrees of fr
Power for two sample t test You're close, some small changes are required though: The true difference in means is typically taken as $\mu_{2} - \mu_{1}$, not the other way around. G*Power uses $n_{1}+n_{2} - 2$ as degrees of freedom for the $t$-distribution in this case (different variances, same group sizes), following a suggestion from Cohen as explained here SAS might use Welch's formula or Satterthwaite's formula for the df given unequal variances (found in this pdf you cited) - with only 2 significant digits in the result one cannot tell (see below) With n1, n2, mu1, mu2, sd1, sd2 as defined in your question: > alpha <- 0.05 > dfGP <- n1+n2 - 2 # degrees of freedom (used by G*Power) > cvGP <- qt(1-alpha, dfGP) # crit. value for one-sided test (under the null) > muDiff <- mu2-mu1 # true difference in means > sigDiff <- sqrt((sd1^2/n1) + (sd2^2/n2)) # true SD for difference in empirical means > ncp <- muDiff / sigDiff # noncentrality parameter (under alternative) > 1-pt(cvGP, dfGP, ncp) # power [1] 0.3348385 This matches the result from G*Power which is a great program for these questions. It displays the df, critical value, ncp as well, so you can check all these calculations separately. Edit: Using Satterthwaite's formula or Welch's formula doesn't change much (still 0.33*): # Satterthwaite's formula > var1 <- sd1^2 > var2 <- sd2^2 > num <- (var1/n1 + var2/n2)^2 > denST <- var1^2/((n1-1)*n1^2) + var2^2/((n2-1)*n2^2) > (dfST <- num/denST) [1] 33.10309 > cvST <- qt(1-alpha, dfST) > 1-pt(cvST, dfST, ncp) [1] 0.3336495 # Welch's formula > denW <- var1^2/((n1+1)*n1^2) + var2^2/((n2+1)*n2^2) > (dfW <- (num/denW) - 2) [1] 34.58763 > cvW <- qt(1-alpha, dfW) > 1-pt(cvW, dfW, ncp) [1] 0.3340453 (note that I slightly changed some variable names as t, df, and diff are also names of built-in functions, also note that the numerator of your code for df is wrong, it has a misplaced ^2, and one ^2 too many, it should be ((sd1^2/n1) + (sd2^2/n2))^2)
Power for two sample t test You're close, some small changes are required though: The true difference in means is typically taken as $\mu_{2} - \mu_{1}$, not the other way around. G*Power uses $n_{1}+n_{2} - 2$ as degrees of fr
26,163
Power for two sample t test
If you are mainly interested in computing the power (rather than learning through doing it by hand) and you are already using R then look at the pwr package and either the pwr.t.test or pwr.t2n.test functions. (these can be good to verify your results even if you do it by hand to learn).
Power for two sample t test
If you are mainly interested in computing the power (rather than learning through doing it by hand) and you are already using R then look at the pwr package and either the pwr.t.test or pwr.t2n.test f
Power for two sample t test If you are mainly interested in computing the power (rather than learning through doing it by hand) and you are already using R then look at the pwr package and either the pwr.t.test or pwr.t2n.test functions. (these can be good to verify your results even if you do it by hand to learn).
Power for two sample t test If you are mainly interested in computing the power (rather than learning through doing it by hand) and you are already using R then look at the pwr package and either the pwr.t.test or pwr.t2n.test f
26,164
A mixed model with gamma distribution: handling zeros
I think you should consider a Poisson model instead. There was discussion of when it works and when it does not as an approximation to a continuous model on Stata blog. If the values are restricted to a range from 0 to 100, you can also do binomial regression with it.
A mixed model with gamma distribution: handling zeros
I think you should consider a Poisson model instead. There was discussion of when it works and when it does not as an approximation to a continuous model on Stata blog. If the values are restricted to
A mixed model with gamma distribution: handling zeros I think you should consider a Poisson model instead. There was discussion of when it works and when it does not as an approximation to a continuous model on Stata blog. If the values are restricted to a range from 0 to 100, you can also do binomial regression with it.
A mixed model with gamma distribution: handling zeros I think you should consider a Poisson model instead. There was discussion of when it works and when it does not as an approximation to a continuous model on Stata blog. If the values are restricted to
26,165
A mixed model with gamma distribution: handling zeros
If the zeros are a very small proportion of the data, I'd just move them to a small positive value (perhaps half the smallest positive observation). If the number of zeros is approaching 10% of the data, I'd want to do something more complicated, like treat the outcome as a mixture of a gamma and a point mass at 0.
A mixed model with gamma distribution: handling zeros
If the zeros are a very small proportion of the data, I'd just move them to a small positive value (perhaps half the smallest positive observation). If the number of zeros is approaching 10% of the da
A mixed model with gamma distribution: handling zeros If the zeros are a very small proportion of the data, I'd just move them to a small positive value (perhaps half the smallest positive observation). If the number of zeros is approaching 10% of the data, I'd want to do something more complicated, like treat the outcome as a mixture of a gamma and a point mass at 0.
A mixed model with gamma distribution: handling zeros If the zeros are a very small proportion of the data, I'd just move them to a small positive value (perhaps half the smallest positive observation). If the number of zeros is approaching 10% of the da
26,166
Definition of quantile
In theory (with $0 \lt p \lt 1$) it means the point a fraction $p$ up the cumulative distribution. In practice there are various definitions used, particularly in statistical computing. For example in R there are nine different definitions, the first three for a discrete interpretation and the rest for a variety of continuous interpolations. Here is an example: if your sample is $\{400, 1, 1000, 40\}$, and you are looking for the $0.6$ quantile ($60$th centile) then the different calculation methods give > x <- numeric() > for (t in 1:9) { x[t] <- quantile(c(400, 1, 1000, 40), probs=0.6, type = t ) } > x 60% 400 400 40 184 364 400 328 376 373 My personal view is that the correct figure is $400$ since $$Pr(X<400) = 0.5 < 0.6 \text{ and } Pr(X>400) = 0.25 < 1-0.6.$$ This comes from treating the sample as the population, and if the empirical CDF is drawn it will be a sequence of steps. There are opposing arguments for interpolating so the empirical CDF is continuous, as being likely to be a better or more useful approximation to the population, and the method of interpolation will affect the result.
Definition of quantile
In theory (with $0 \lt p \lt 1$) it means the point a fraction $p$ up the cumulative distribution. In practice there are various definitions used, particularly in statistical computing. For example
Definition of quantile In theory (with $0 \lt p \lt 1$) it means the point a fraction $p$ up the cumulative distribution. In practice there are various definitions used, particularly in statistical computing. For example in R there are nine different definitions, the first three for a discrete interpretation and the rest for a variety of continuous interpolations. Here is an example: if your sample is $\{400, 1, 1000, 40\}$, and you are looking for the $0.6$ quantile ($60$th centile) then the different calculation methods give > x <- numeric() > for (t in 1:9) { x[t] <- quantile(c(400, 1, 1000, 40), probs=0.6, type = t ) } > x 60% 400 400 40 184 364 400 328 376 373 My personal view is that the correct figure is $400$ since $$Pr(X<400) = 0.5 < 0.6 \text{ and } Pr(X>400) = 0.25 < 1-0.6.$$ This comes from treating the sample as the population, and if the empirical CDF is drawn it will be a sequence of steps. There are opposing arguments for interpolating so the empirical CDF is continuous, as being likely to be a better or more useful approximation to the population, and the method of interpolation will affect the result.
Definition of quantile In theory (with $0 \lt p \lt 1$) it means the point a fraction $p$ up the cumulative distribution. In practice there are various definitions used, particularly in statistical computing. For example
26,167
Determining if change in a time series is statistically significant
A very similar example is used in the tutorial of PyMC. If you assume that the daily amount of requests was constant until some point in time (maybe exactly Christmas) and after that it was constant again, all you need to do is substitute the numbers in the example: http://pymc.googlecode.com/svn/doc/tutorial.html As this is the Bayesian approach you won't (easily) get p values. However, the size of the step down and its credible interval (this is a Bayesian interval, similar to a confidence interval) may be equally useful.
Determining if change in a time series is statistically significant
A very similar example is used in the tutorial of PyMC. If you assume that the daily amount of requests was constant until some point in time (maybe exactly Christmas) and after that it was constant a
Determining if change in a time series is statistically significant A very similar example is used in the tutorial of PyMC. If you assume that the daily amount of requests was constant until some point in time (maybe exactly Christmas) and after that it was constant again, all you need to do is substitute the numbers in the example: http://pymc.googlecode.com/svn/doc/tutorial.html As this is the Bayesian approach you won't (easily) get p values. However, the size of the step down and its credible interval (this is a Bayesian interval, similar to a confidence interval) may be equally useful.
Determining if change in a time series is statistically significant A very similar example is used in the tutorial of PyMC. If you assume that the daily amount of requests was constant until some point in time (maybe exactly Christmas) and after that it was constant a
26,168
Detect circular patterns in point cloud data
A generalized Hough transform is exactly what you want. The difficulty is to do it efficiently, because the space of circles in 3D has six dimensions (three for the center, two to orient the plane, one for the radius). This seems to rule out a direct calculation. One possibility is to sneak up on the result through a sequence of simpler Hough transforms. For instance, you could start with the (usual) Hough transform to detect planar subsets: those require only a 3D grid for the computation. For each planar subset detected, slice the original points along that plane and perform a generalized Hough transform for circle detection. This should work well provided the original image does not have a lot of coplanar points (other than the ones formed by the circles) that could drown out the signal generated by the circles. If the circle sizes have a predetermined upper bound you can potentially save a lot of computation: rather than looking at all pairs or triples of points in the original image, you can focus on pairs or triples within a bounded neighborhood of each point.
Detect circular patterns in point cloud data
A generalized Hough transform is exactly what you want. The difficulty is to do it efficiently, because the space of circles in 3D has six dimensions (three for the center, two to orient the plane, o
Detect circular patterns in point cloud data A generalized Hough transform is exactly what you want. The difficulty is to do it efficiently, because the space of circles in 3D has six dimensions (three for the center, two to orient the plane, one for the radius). This seems to rule out a direct calculation. One possibility is to sneak up on the result through a sequence of simpler Hough transforms. For instance, you could start with the (usual) Hough transform to detect planar subsets: those require only a 3D grid for the computation. For each planar subset detected, slice the original points along that plane and perform a generalized Hough transform for circle detection. This should work well provided the original image does not have a lot of coplanar points (other than the ones formed by the circles) that could drown out the signal generated by the circles. If the circle sizes have a predetermined upper bound you can potentially save a lot of computation: rather than looking at all pairs or triples of points in the original image, you can focus on pairs or triples within a bounded neighborhood of each point.
Detect circular patterns in point cloud data A generalized Hough transform is exactly what you want. The difficulty is to do it efficiently, because the space of circles in 3D has six dimensions (three for the center, two to orient the plane, o
26,169
Detect circular patterns in point cloud data
Well, if the goal is to simply detect the $\textit{number}$ of circular patterns, and you have enough data, maybe try deep convolutional neural networks. Truly, one would need all that data labeled, yet DCNs can be used as a complementary method to the ones suggested above.
Detect circular patterns in point cloud data
Well, if the goal is to simply detect the $\textit{number}$ of circular patterns, and you have enough data, maybe try deep convolutional neural networks. Truly, one would need all that data labeled, y
Detect circular patterns in point cloud data Well, if the goal is to simply detect the $\textit{number}$ of circular patterns, and you have enough data, maybe try deep convolutional neural networks. Truly, one would need all that data labeled, yet DCNs can be used as a complementary method to the ones suggested above.
Detect circular patterns in point cloud data Well, if the goal is to simply detect the $\textit{number}$ of circular patterns, and you have enough data, maybe try deep convolutional neural networks. Truly, one would need all that data labeled, y
26,170
Meta-analysis in R using metafor package
Create a proper data.frame: df <- structure(list(study = structure(c(1L, 5L, 3L, 4L, 2L), .Label = c("Foo2000", "Pete2008", "Pric2005", "Rota2008", "Sun2003"), class = "factor"), mean1 = c(0.78, 0.74, 0.75, 0.62, 0.68), sd1 = c(0.05, 0.08, 0.12, 0.05, 0.03), n1 = c(20L, 30L, 20L, 24L, 10L), mean2 = c(0.82, 0.72, 0.74, 0.66, 0.68), sd2 = c(0.07, 0.05, 0.09, 0.03, 0.02), n2 = c(25L, 19L, 29L, 24L, 10L)), .Names = c("study", "mean1", "sd1", "n1", "mean2", "sd2", "n2"), class = "data.frame", row.names = c(NA, -5L)) Run the rma-function: library(metafor) rma(measure = "SMD", m1i = mean1, m2i = mean2, sd1i = sd1, sd2i = sd2, n1i = n1, n2i = n2, method = "REML", data = df) Please be aware that rma assumes (m1i-m2i). This results in the following univariate random effects model meta-analysis: > rma(measure = "SMD", m1i = mean1, m2i = mean2, + sd1i = sd1, sd2i = sd2, n1i = n1, n2i = n2, + method = "REML", data = df) Random-Effects Model (k = 5; tau^2 estimator: REML) tau^2 (estimate of total amount of heterogeneity): 0.1951 (SE = 0.2127) tau (sqrt of the estimate of total heterogeneity): 0.4416 I^2 (% of total variability due to heterogeneity): 65.61% H^2 (total variability / within-study variance): 2.91 Test for Heterogeneity: Q(df = 4) = 11.8763, p-val = 0.0183 Model Results: estimate se zval pval ci.lb ci.ub -0.2513 0.2456 -1.0233 0.3061 -0.7326 0.2300 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 You might want to change the estimation method, e.g. method = "DL" (but I would stick with REML).
Meta-analysis in R using metafor package
Create a proper data.frame: df <- structure(list(study = structure(c(1L, 5L, 3L, 4L, 2L), .Label = c("Foo2000", "Pete2008", "Pric2005", "Rota2008", "Sun2003"), class = "factor"), mean1 = c(0.78,
Meta-analysis in R using metafor package Create a proper data.frame: df <- structure(list(study = structure(c(1L, 5L, 3L, 4L, 2L), .Label = c("Foo2000", "Pete2008", "Pric2005", "Rota2008", "Sun2003"), class = "factor"), mean1 = c(0.78, 0.74, 0.75, 0.62, 0.68), sd1 = c(0.05, 0.08, 0.12, 0.05, 0.03), n1 = c(20L, 30L, 20L, 24L, 10L), mean2 = c(0.82, 0.72, 0.74, 0.66, 0.68), sd2 = c(0.07, 0.05, 0.09, 0.03, 0.02), n2 = c(25L, 19L, 29L, 24L, 10L)), .Names = c("study", "mean1", "sd1", "n1", "mean2", "sd2", "n2"), class = "data.frame", row.names = c(NA, -5L)) Run the rma-function: library(metafor) rma(measure = "SMD", m1i = mean1, m2i = mean2, sd1i = sd1, sd2i = sd2, n1i = n1, n2i = n2, method = "REML", data = df) Please be aware that rma assumes (m1i-m2i). This results in the following univariate random effects model meta-analysis: > rma(measure = "SMD", m1i = mean1, m2i = mean2, + sd1i = sd1, sd2i = sd2, n1i = n1, n2i = n2, + method = "REML", data = df) Random-Effects Model (k = 5; tau^2 estimator: REML) tau^2 (estimate of total amount of heterogeneity): 0.1951 (SE = 0.2127) tau (sqrt of the estimate of total heterogeneity): 0.4416 I^2 (% of total variability due to heterogeneity): 65.61% H^2 (total variability / within-study variance): 2.91 Test for Heterogeneity: Q(df = 4) = 11.8763, p-val = 0.0183 Model Results: estimate se zval pval ci.lb ci.ub -0.2513 0.2456 -1.0233 0.3061 -0.7326 0.2300 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 You might want to change the estimation method, e.g. method = "DL" (but I would stick with REML).
Meta-analysis in R using metafor package Create a proper data.frame: df <- structure(list(study = structure(c(1L, 5L, 3L, 4L, 2L), .Label = c("Foo2000", "Pete2008", "Pric2005", "Rota2008", "Sun2003"), class = "factor"), mean1 = c(0.78,
26,171
How to understand a convolutional deep belief network for audio classification?
The audio application is a one-dimensional simplification of the two-dimensional image classification problem. A phoneme (for example) is the audio analog of an image feature such as an edge or a circle. In either case such features have an essential locality: they are characterized by values within a relatively small neighborhood of an image location or moment of speech. Convolutions are a controlled, regular form of weighted averaging of values within local neighborhoods. From this originates the hope that a convolutional form of a DBN can be successful at identifying and discriminating features that are meaningful.
How to understand a convolutional deep belief network for audio classification?
The audio application is a one-dimensional simplification of the two-dimensional image classification problem. A phoneme (for example) is the audio analog of an image feature such as an edge or a cir
How to understand a convolutional deep belief network for audio classification? The audio application is a one-dimensional simplification of the two-dimensional image classification problem. A phoneme (for example) is the audio analog of an image feature such as an edge or a circle. In either case such features have an essential locality: they are characterized by values within a relatively small neighborhood of an image location or moment of speech. Convolutions are a controlled, regular form of weighted averaging of values within local neighborhoods. From this originates the hope that a convolutional form of a DBN can be successful at identifying and discriminating features that are meaningful.
How to understand a convolutional deep belief network for audio classification? The audio application is a one-dimensional simplification of the two-dimensional image classification problem. A phoneme (for example) is the audio analog of an image feature such as an edge or a cir
26,172
How to understand a convolutional deep belief network for audio classification?
In case of Convolutional RBM's applied to audio data, the authors have first taken Short Term Fourier Transform and then defined energy bands on the spectrum. Then they have applied convolutional RBM's on that transformed audio.
How to understand a convolutional deep belief network for audio classification?
In case of Convolutional RBM's applied to audio data, the authors have first taken Short Term Fourier Transform and then defined energy bands on the spectrum. Then they have applied convolutional RBM'
How to understand a convolutional deep belief network for audio classification? In case of Convolutional RBM's applied to audio data, the authors have first taken Short Term Fourier Transform and then defined energy bands on the spectrum. Then they have applied convolutional RBM's on that transformed audio.
How to understand a convolutional deep belief network for audio classification? In case of Convolutional RBM's applied to audio data, the authors have first taken Short Term Fourier Transform and then defined energy bands on the spectrum. Then they have applied convolutional RBM'
26,173
How to calibrate models if we don't have enough data?
I also found out that calibration model has to be fit using a different dataset. That's not strictly true. As Frank Harrell explains, with data sets of this size it's generally best to develop the model on the entire data set and then validate the modeling process by repeating the modeling on multiple bootstrap samples and evaluating performance on the full data set. (Repeated cross validation, as suggested by usεr11852, can also work for this.) That allows evaluation of and correction for bias, and production of calibration curves that are likely to represent the quality of the model when applied to new data samples from the population. This presentation outlines the procedure in the context of logistic regression, but the principles are general.
How to calibrate models if we don't have enough data?
I also found out that calibration model has to be fit using a different dataset. That's not strictly true. As Frank Harrell explains, with data sets of this size it's generally best to develop the mo
How to calibrate models if we don't have enough data? I also found out that calibration model has to be fit using a different dataset. That's not strictly true. As Frank Harrell explains, with data sets of this size it's generally best to develop the model on the entire data set and then validate the modeling process by repeating the modeling on multiple bootstrap samples and evaluating performance on the full data set. (Repeated cross validation, as suggested by usεr11852, can also work for this.) That allows evaluation of and correction for bias, and production of calibration curves that are likely to represent the quality of the model when applied to new data samples from the population. This presentation outlines the procedure in the context of logistic regression, but the principles are general.
How to calibrate models if we don't have enough data? I also found out that calibration model has to be fit using a different dataset. That's not strictly true. As Frank Harrell explains, with data sets of this size it's generally best to develop the mo
26,174
Is anything inherently random?
In some ways this may be a philosophical question. My view is that the randomness a statistician sees in data analysis is often real. Randomness might result from random sampling or from inherent randomness or instability. Either way, statistical procedures of estimation might be useful. Let's look at two entirely different situations. (1) We wonder whether the true average height of women high school seniors in a US state is 65 inches. At noon on a particular day, one might carefully measure each of them (thousands or hundreds of thousands, depending on the state), round to the nearest tenth of an inch, and take the mean. Even with perfectly accurate measuring and record keeping, the result would likely be different on another day. Some students might have grown just a bit. Also, there is some evidence that a person's height may depend (slightly) on how much sleep they got the previous night. Does it make sense to say that the true statewide average height fluctuates constantly in some random way? More realistically, one might take a random sample of $n = 400$ women for the measurements and averaging. In this case, random sampling has clearly induced randomness. It would not be surprising if another random sample of $400$ resulted in a different mean. Using such a random sample we could make a 95% confidence interval for heights of senior women. Perhaps this CI would be about $0.7$ inches wide, but we could be fairly sure that the interval contains the right answer for the heights of senior women in the state. For practical purposes that might be sufficiently close to the 'correct' answer. Perhaps some probability model such as $\mathsf{Norm}(\mu = 65, \sigma=3.5)$ is approximately correct. If so, then our two samples of size $400$ might (at random) have been $65.2$ and $65.0.$ round(rnorm(2, 65, 3.5/20) ,1) [1] 65.2 65.0 (2) You have a small specimen of some radioactive material with a long half-life (several thousand years). You use an appropriate counter to count particles emitted in one particular minute to be $746.$ Using exactly the same experimental set-up several minutes later the count is $721.$ Monitoring the specimen over several hours, you believe the hourly rate of particle emission in your experiment is distributed $\mathsf{Pois}(\lambda=750).$ As far as is known, the number of particles emitted into our counter per minute is truly random, and $\mathsf{Pois}(750)$ is a reasonable model. Both of our one-minute measurements could be exactly correct, but it would be wrong to expect them to be exactly the same. (But not often fewer than 697 or more than 804.) set.seed(1226); rpois(2, 750) [1] 746 721 qpois(c(.025,.975), 750) [1] 697 804
Is anything inherently random?
In some ways this may be a philosophical question. My view is that the randomness a statistician sees in data analysis is often real. Randomness might result from random sampling or from inherent rand
Is anything inherently random? In some ways this may be a philosophical question. My view is that the randomness a statistician sees in data analysis is often real. Randomness might result from random sampling or from inherent randomness or instability. Either way, statistical procedures of estimation might be useful. Let's look at two entirely different situations. (1) We wonder whether the true average height of women high school seniors in a US state is 65 inches. At noon on a particular day, one might carefully measure each of them (thousands or hundreds of thousands, depending on the state), round to the nearest tenth of an inch, and take the mean. Even with perfectly accurate measuring and record keeping, the result would likely be different on another day. Some students might have grown just a bit. Also, there is some evidence that a person's height may depend (slightly) on how much sleep they got the previous night. Does it make sense to say that the true statewide average height fluctuates constantly in some random way? More realistically, one might take a random sample of $n = 400$ women for the measurements and averaging. In this case, random sampling has clearly induced randomness. It would not be surprising if another random sample of $400$ resulted in a different mean. Using such a random sample we could make a 95% confidence interval for heights of senior women. Perhaps this CI would be about $0.7$ inches wide, but we could be fairly sure that the interval contains the right answer for the heights of senior women in the state. For practical purposes that might be sufficiently close to the 'correct' answer. Perhaps some probability model such as $\mathsf{Norm}(\mu = 65, \sigma=3.5)$ is approximately correct. If so, then our two samples of size $400$ might (at random) have been $65.2$ and $65.0.$ round(rnorm(2, 65, 3.5/20) ,1) [1] 65.2 65.0 (2) You have a small specimen of some radioactive material with a long half-life (several thousand years). You use an appropriate counter to count particles emitted in one particular minute to be $746.$ Using exactly the same experimental set-up several minutes later the count is $721.$ Monitoring the specimen over several hours, you believe the hourly rate of particle emission in your experiment is distributed $\mathsf{Pois}(\lambda=750).$ As far as is known, the number of particles emitted into our counter per minute is truly random, and $\mathsf{Pois}(750)$ is a reasonable model. Both of our one-minute measurements could be exactly correct, but it would be wrong to expect them to be exactly the same. (But not often fewer than 697 or more than 804.) set.seed(1226); rpois(2, 750) [1] 746 721 qpois(c(.025,.975), 750) [1] 697 804
Is anything inherently random? In some ways this may be a philosophical question. My view is that the randomness a statistician sees in data analysis is often real. Randomness might result from random sampling or from inherent rand
26,175
Is anything inherently random?
Independently of the question of existence of randomness, you simply cannot measure anything to arbitrarily high precision, because your measurement will necessarily disturb it by a greater amount if you wish to have greater precision. This is already true in classical mechanics and remains true in quantum mechanics. But your real question is whether there is anything inherently random in the world. Although this is not a mathematical question, it suffices to say that till today there is simply zero evidence for any truly random process. Quantum mechanics does not at all suggest, not to say imply, randomness in anything in the real world. Given this, it is reasonable to ask why so many real-world processes do appear to be probabilistic. Well, the answer is that purely deterministic processes can amplify very small perturbations, so if there is an amplification process followed by a folding process then the result can appear chaotic even if it is fully determined by the initial state. Furthermore, symmetries in the folding process may strongly dictate the limiting distribution of the result as the amplification is increased. For example, the logistic map has chaotic behaviour for certain parameters, for which just a slight perturbation in the input results in exponential divergence of the output. Essentially, the logistic map shows that repeated application of a continuous stretch-and-fold operation on a metric space can result in unpredictability in the limit. This has implications for the real-world, in that almost all measurements are of quantities arising from innumerable iterates of some physical process (e.g. particle-particle interactions).
Is anything inherently random?
Independently of the question of existence of randomness, you simply cannot measure anything to arbitrarily high precision, because your measurement will necessarily disturb it by a greater amount if
Is anything inherently random? Independently of the question of existence of randomness, you simply cannot measure anything to arbitrarily high precision, because your measurement will necessarily disturb it by a greater amount if you wish to have greater precision. This is already true in classical mechanics and remains true in quantum mechanics. But your real question is whether there is anything inherently random in the world. Although this is not a mathematical question, it suffices to say that till today there is simply zero evidence for any truly random process. Quantum mechanics does not at all suggest, not to say imply, randomness in anything in the real world. Given this, it is reasonable to ask why so many real-world processes do appear to be probabilistic. Well, the answer is that purely deterministic processes can amplify very small perturbations, so if there is an amplification process followed by a folding process then the result can appear chaotic even if it is fully determined by the initial state. Furthermore, symmetries in the folding process may strongly dictate the limiting distribution of the result as the amplification is increased. For example, the logistic map has chaotic behaviour for certain parameters, for which just a slight perturbation in the input results in exponential divergence of the output. Essentially, the logistic map shows that repeated application of a continuous stretch-and-fold operation on a metric space can result in unpredictability in the limit. This has implications for the real-world, in that almost all measurements are of quantities arising from innumerable iterates of some physical process (e.g. particle-particle interactions).
Is anything inherently random? Independently of the question of existence of randomness, you simply cannot measure anything to arbitrarily high precision, because your measurement will necessarily disturb it by a greater amount if
26,176
Is anything inherently random?
Yes, there are "inherently" random processes in the universe. As far as I know, it's impossible to determine in advance the collapse of a wave function. For example, which slit a particle will go through in the two slit experiment. This question should really be asked on physics.stackexchange.
Is anything inherently random?
Yes, there are "inherently" random processes in the universe. As far as I know, it's impossible to determine in advance the collapse of a wave function. For example, which slit a particle will go th
Is anything inherently random? Yes, there are "inherently" random processes in the universe. As far as I know, it's impossible to determine in advance the collapse of a wave function. For example, which slit a particle will go through in the two slit experiment. This question should really be asked on physics.stackexchange.
Is anything inherently random? Yes, there are "inherently" random processes in the universe. As far as I know, it's impossible to determine in advance the collapse of a wave function. For example, which slit a particle will go th
26,177
Is anything inherently random?
We do not know and may never know. (and possibly we can not know*) Statistics is not about the nature of reality. Statistics describes observations and these observations happen to have a random appearance due to unknown variable factors that are involved in the model descriptions. The question whether the reality is intrinsically non-deterministic is more like philosophy than statistics. *One may argue that the question about the deterministic nature of the world is actually not something that can be answered by a consciousness within this reality, and it may even not have any meaning at all. If the physical processes occur with some random nature, that means that the future state of the world can not be determined based on the present state, then still something makes the current state evolve into the future state and it is in some way determined. It is only not determined by an entity that can be known by the objects in the observable world. Whether or not something is deterministic is a matter of perspective.
Is anything inherently random?
We do not know and may never know. (and possibly we can not know*) Statistics is not about the nature of reality. Statistics describes observations and these observations happen to have a random appe
Is anything inherently random? We do not know and may never know. (and possibly we can not know*) Statistics is not about the nature of reality. Statistics describes observations and these observations happen to have a random appearance due to unknown variable factors that are involved in the model descriptions. The question whether the reality is intrinsically non-deterministic is more like philosophy than statistics. *One may argue that the question about the deterministic nature of the world is actually not something that can be answered by a consciousness within this reality, and it may even not have any meaning at all. If the physical processes occur with some random nature, that means that the future state of the world can not be determined based on the present state, then still something makes the current state evolve into the future state and it is in some way determined. It is only not determined by an entity that can be known by the objects in the observable world. Whether or not something is deterministic is a matter of perspective.
Is anything inherently random? We do not know and may never know. (and possibly we can not know*) Statistics is not about the nature of reality. Statistics describes observations and these observations happen to have a random appe
26,178
Is it wrong to compare multiple models on the same test set and choose the best model?
You could consider the model itself a hyperparameter as well. If you optimize the hyperparameter using the test set, and then choose the best model, you overfit with the human in the loop. I like the sklearn documentation on model selection which sports the following chart: And futher states: When evaluating different settings (“hyperparameters”) for estimators, such as the C setting that must be manually set for an SVM, there is still a risk of overfitting on the test set because the parameters can be tweaked until the estimator performs optimally. This way, knowledge about the test set can “leak” into the model and evaluation metrics no longer report on generalization performance. To solve this problem, yet another part of the dataset can be held out as a so-called “validation set”: training proceeds on the training set, after which evaluation is done on the validation set, and when the experiment seems to be successful, final evaluation can be done on the test set. Additionally, I recommend you to read: How is cross validation different from data snooping? Bonferroni Correction & machine learning Note that while you call your holdout set test, that is what others call evaluation set. In this context, have a look at MFML 069 - Model validation done right
Is it wrong to compare multiple models on the same test set and choose the best model?
You could consider the model itself a hyperparameter as well. If you optimize the hyperparameter using the test set, and then choose the best model, you overfit with the human in the loop. I like the
Is it wrong to compare multiple models on the same test set and choose the best model? You could consider the model itself a hyperparameter as well. If you optimize the hyperparameter using the test set, and then choose the best model, you overfit with the human in the loop. I like the sklearn documentation on model selection which sports the following chart: And futher states: When evaluating different settings (“hyperparameters”) for estimators, such as the C setting that must be manually set for an SVM, there is still a risk of overfitting on the test set because the parameters can be tweaked until the estimator performs optimally. This way, knowledge about the test set can “leak” into the model and evaluation metrics no longer report on generalization performance. To solve this problem, yet another part of the dataset can be held out as a so-called “validation set”: training proceeds on the training set, after which evaluation is done on the validation set, and when the experiment seems to be successful, final evaluation can be done on the test set. Additionally, I recommend you to read: How is cross validation different from data snooping? Bonferroni Correction & machine learning Note that while you call your holdout set test, that is what others call evaluation set. In this context, have a look at MFML 069 - Model validation done right
Is it wrong to compare multiple models on the same test set and choose the best model? You could consider the model itself a hyperparameter as well. If you optimize the hyperparameter using the test set, and then choose the best model, you overfit with the human in the loop. I like the
26,179
Is it wrong to compare multiple models on the same test set and choose the best model?
You are correct that the measurement of generalization error should happen after a final model has been selected, on data that has never been passed to any models yet. This is well explained in Aurelion Geron's book, Hands-on ML with Scikit-Learn, Keras, and Tensorflow. Here's a link to an accompanying Jupyter notebook. Excerpt (emphasis mine): Once you are confident about your final model, measure its performance on the test set to estimate the generalization error. Don't tweak your model after measuring the generalization error: you would just start overfitting the test set. Here, we can consider swapping Model 1 for Model 2 based on the test-set results as a heavy-handed way of "tweaking" the model.
Is it wrong to compare multiple models on the same test set and choose the best model?
You are correct that the measurement of generalization error should happen after a final model has been selected, on data that has never been passed to any models yet. This is well explained in Aureli
Is it wrong to compare multiple models on the same test set and choose the best model? You are correct that the measurement of generalization error should happen after a final model has been selected, on data that has never been passed to any models yet. This is well explained in Aurelion Geron's book, Hands-on ML with Scikit-Learn, Keras, and Tensorflow. Here's a link to an accompanying Jupyter notebook. Excerpt (emphasis mine): Once you are confident about your final model, measure its performance on the test set to estimate the generalization error. Don't tweak your model after measuring the generalization error: you would just start overfitting the test set. Here, we can consider swapping Model 1 for Model 2 based on the test-set results as a heavy-handed way of "tweaking" the model.
Is it wrong to compare multiple models on the same test set and choose the best model? You are correct that the measurement of generalization error should happen after a final model has been selected, on data that has never been passed to any models yet. This is well explained in Aureli
26,180
When calculating self-attention for Transformer ML architectures, why do we need both a key and a query weight matrix?
The weight matrices are $n$ by $m$ with $n >> m$. So $W_Q W_K^T$ is not just any matrix, it's $n$ by $n$ but with rank only $m$ -- there are fewer parameters, and computing $QK^T$ is much faster than $X W' X^T$ for some full rank $W'$
When calculating self-attention for Transformer ML architectures, why do we need both a key and a qu
The weight matrices are $n$ by $m$ with $n >> m$. So $W_Q W_K^T$ is not just any matrix, it's $n$ by $n$ but with rank only $m$ -- there are fewer parameters, and computing $QK^T$ is much faster than
When calculating self-attention for Transformer ML architectures, why do we need both a key and a query weight matrix? The weight matrices are $n$ by $m$ with $n >> m$. So $W_Q W_K^T$ is not just any matrix, it's $n$ by $n$ but with rank only $m$ -- there are fewer parameters, and computing $QK^T$ is much faster than $X W' X^T$ for some full rank $W'$
When calculating self-attention for Transformer ML architectures, why do we need both a key and a qu The weight matrices are $n$ by $m$ with $n >> m$. So $W_Q W_K^T$ is not just any matrix, it's $n$ by $n$ but with rank only $m$ -- there are fewer parameters, and computing $QK^T$ is much faster than
26,181
is it always "no causation without manipulation"?
This is a vast topic and your question could be nominated for closure for being too broad, but I will make a few extended comments. It is not intended as full answer. People write whole books on this topic. For example, see the work of Judea Pearl, Sander Greenland and Miguel Hernán for starters. Is it possible to use regression to check causality? Certainly a regression model can be used to test a causal hypothesis, and this is done very frequently indeed. However, it is impossible, to prove causality with any statistical model. A researcher may hypothesize a particular causal path, and then use a regression model to test their hypothesis. The problem here is that the causal hypothesis, for example, "Does X cause Y ?", cannot be directly tested in the sense of getting an answer "yes" or "no". In frequentist statistics, for example, the test will usually provide an answer to the question: "if there is no association between X and Y, then the probability of obtaining these data, or data more extreme, is x%" which obviously is not the real question that the researcher has. This is a very common misunderstanding. On the other hand, if this probability is very low, then it is consistent with the researcher's causal hypothesis. Directed Acyclic Graphs (DAGs), sometimes also known as causal diagrams are a very useful tool in causal inference, particularly in the context of regression analysis, and they can help to reduce a multitude of biases that may occur when trying to estimate a causal effect using regression. See this question and answers, for details: How do DAGs help to reduce bias in causal inference? Does this always hold "no causation without manipulation"? In other words, we can only talk about causation only after doing some sort of manipulation?? No. There is a large body of research on causal inference in observational data, where it is not possible to manipulate or perform an intervention. It is true that a manipulation, or intervention, is strongly preferable to a purely observational study, however this is often not ethical. For example, we might be interested in the causal effect of some potentially harmful exposure on some health outcome, and it would be unethical to devise an experiment where some of the study group were exposed and others were not. Another reason why we can't conduct an experiment might be practicality. For example, we might be interested the effect of certain "trajectories" of childhood bmi on later life bmi. It would not be practical to devise an intervention to manipulate BMI in one arm of a study. As mentioned above this is a vast area. Check this question and answers for further details about manipulations: Statistics and causal inference?
is it always "no causation without manipulation"?
This is a vast topic and your question could be nominated for closure for being too broad, but I will make a few extended comments. It is not intended as full answer. People write whole books on this
is it always "no causation without manipulation"? This is a vast topic and your question could be nominated for closure for being too broad, but I will make a few extended comments. It is not intended as full answer. People write whole books on this topic. For example, see the work of Judea Pearl, Sander Greenland and Miguel Hernán for starters. Is it possible to use regression to check causality? Certainly a regression model can be used to test a causal hypothesis, and this is done very frequently indeed. However, it is impossible, to prove causality with any statistical model. A researcher may hypothesize a particular causal path, and then use a regression model to test their hypothesis. The problem here is that the causal hypothesis, for example, "Does X cause Y ?", cannot be directly tested in the sense of getting an answer "yes" or "no". In frequentist statistics, for example, the test will usually provide an answer to the question: "if there is no association between X and Y, then the probability of obtaining these data, or data more extreme, is x%" which obviously is not the real question that the researcher has. This is a very common misunderstanding. On the other hand, if this probability is very low, then it is consistent with the researcher's causal hypothesis. Directed Acyclic Graphs (DAGs), sometimes also known as causal diagrams are a very useful tool in causal inference, particularly in the context of regression analysis, and they can help to reduce a multitude of biases that may occur when trying to estimate a causal effect using regression. See this question and answers, for details: How do DAGs help to reduce bias in causal inference? Does this always hold "no causation without manipulation"? In other words, we can only talk about causation only after doing some sort of manipulation?? No. There is a large body of research on causal inference in observational data, where it is not possible to manipulate or perform an intervention. It is true that a manipulation, or intervention, is strongly preferable to a purely observational study, however this is often not ethical. For example, we might be interested in the causal effect of some potentially harmful exposure on some health outcome, and it would be unethical to devise an experiment where some of the study group were exposed and others were not. Another reason why we can't conduct an experiment might be practicality. For example, we might be interested the effect of certain "trajectories" of childhood bmi on later life bmi. It would not be practical to devise an intervention to manipulate BMI in one arm of a study. As mentioned above this is a vast area. Check this question and answers for further details about manipulations: Statistics and causal inference?
is it always "no causation without manipulation"? This is a vast topic and your question could be nominated for closure for being too broad, but I will make a few extended comments. It is not intended as full answer. People write whole books on this
26,182
glm.fit: fitted probabilities numerically 0 or 1 occurred however culprit feature is numeric
I looked at your data and it is extremely skewed with outliers. Thus you do not have perfect separation but the warning is occurring because some of the extreme observations have predicted probabilities indistinguishable from 1. If you fit the model on the log of avg_load_time you will not get the error (I tested this on your sample data). This answer explains what's going on well: Issue with complete separation in logistic regression (in R)
glm.fit: fitted probabilities numerically 0 or 1 occurred however culprit feature is numeric
I looked at your data and it is extremely skewed with outliers. Thus you do not have perfect separation but the warning is occurring because some of the extreme observations have predicted probabilit
glm.fit: fitted probabilities numerically 0 or 1 occurred however culprit feature is numeric I looked at your data and it is extremely skewed with outliers. Thus you do not have perfect separation but the warning is occurring because some of the extreme observations have predicted probabilities indistinguishable from 1. If you fit the model on the log of avg_load_time you will not get the error (I tested this on your sample data). This answer explains what's going on well: Issue with complete separation in logistic regression (in R)
glm.fit: fitted probabilities numerically 0 or 1 occurred however culprit feature is numeric I looked at your data and it is extremely skewed with outliers. Thus you do not have perfect separation but the warning is occurring because some of the extreme observations have predicted probabilit
26,183
How does topic coherence score in LDA intuitively makes sense ?
The coherence score is for assessing the quality of the learned topics. For one topic, the words $i,j$ being scored in $\sum_{i<j} \text{Score}(w_i, w_j)$ have the highest probability of occurring for that topic. You need to specify how many words in the topic to consider for the overall score. For the "UMass" measure, the numerator $D(w_i, w_j)$ is the number of documents in which words $w_i$ and $w_j$ appear together. 1 is added to this term because we are taking logs and we need to avoid taking log of 0 when the two words never appear together. The denominator is the number of documents $D(w_i)$ appears in. So the score is higher if $w_i$ and $w_j$ appear together in documents a lot relative to how often $w_i$ alone appears in documents. This makes sense as a measure of topic coherence, since if two words in a topic really belong together you would expect them to show up together a lot. The denominator is just adjusting for the document frequency of the words you are considering, so that words like "the" don't get an artificially high score. You could use the topic coherence scores, $CS(t)$ for $t = 1, \ldots, K$, to determine the optimal number $K^*$ of topics by finding $\arg\max_K \frac{1}{K}\sum_{t=1}^K CS(t)$. That is take the average topic coherence score for various settings of $K$ and see which gives the highest average coherence.
How does topic coherence score in LDA intuitively makes sense ?
The coherence score is for assessing the quality of the learned topics. For one topic, the words $i,j$ being scored in $\sum_{i<j} \text{Score}(w_i, w_j)$ have the highest probability of occurring for
How does topic coherence score in LDA intuitively makes sense ? The coherence score is for assessing the quality of the learned topics. For one topic, the words $i,j$ being scored in $\sum_{i<j} \text{Score}(w_i, w_j)$ have the highest probability of occurring for that topic. You need to specify how many words in the topic to consider for the overall score. For the "UMass" measure, the numerator $D(w_i, w_j)$ is the number of documents in which words $w_i$ and $w_j$ appear together. 1 is added to this term because we are taking logs and we need to avoid taking log of 0 when the two words never appear together. The denominator is the number of documents $D(w_i)$ appears in. So the score is higher if $w_i$ and $w_j$ appear together in documents a lot relative to how often $w_i$ alone appears in documents. This makes sense as a measure of topic coherence, since if two words in a topic really belong together you would expect them to show up together a lot. The denominator is just adjusting for the document frequency of the words you are considering, so that words like "the" don't get an artificially high score. You could use the topic coherence scores, $CS(t)$ for $t = 1, \ldots, K$, to determine the optimal number $K^*$ of topics by finding $\arg\max_K \frac{1}{K}\sum_{t=1}^K CS(t)$. That is take the average topic coherence score for various settings of $K$ and see which gives the highest average coherence.
How does topic coherence score in LDA intuitively makes sense ? The coherence score is for assessing the quality of the learned topics. For one topic, the words $i,j$ being scored in $\sum_{i<j} \text{Score}(w_i, w_j)$ have the highest probability of occurring for
26,184
How to automatically cluster a U-Matrix?
Yes, I've seen clustering algorithms being run on a SOM's U-Matrix. It isn't much common however because SOMs are used to visualize high-dimensional data on 2 dimensions. An example you can look at this, where a DBSCAN is run on a U-matrix to cluster its neurons. This example is from the Python library 'somoclu'. Unfortunately, I'm not aware of any packages on R.
How to automatically cluster a U-Matrix?
Yes, I've seen clustering algorithms being run on a SOM's U-Matrix. It isn't much common however because SOMs are used to visualize high-dimensional data on 2 dimensions. An example you can look at th
How to automatically cluster a U-Matrix? Yes, I've seen clustering algorithms being run on a SOM's U-Matrix. It isn't much common however because SOMs are used to visualize high-dimensional data on 2 dimensions. An example you can look at this, where a DBSCAN is run on a U-matrix to cluster its neurons. This example is from the Python library 'somoclu'. Unfortunately, I'm not aware of any packages on R.
How to automatically cluster a U-Matrix? Yes, I've seen clustering algorithms being run on a SOM's U-Matrix. It isn't much common however because SOMs are used to visualize high-dimensional data on 2 dimensions. An example you can look at th
26,185
Why does $[0,1]$ scaling dramatically increase training time for feed forward ANN (1 hidden layer)?
We can find a reasonable explanation for this behavior in the Neural Network FAQ. TL;DR - try rescaling your data to lie in $[-1,1]$. But standardizing input variables can have far more important effects on initialization of the weights than simply avoiding saturation. Assume we have an MLP with one hidden layer applied to a classification problem and are therefore interested in the hyperplanes defined by each hidden unit. Each hyperplane is the locus of points where the net-input to the hidden unit is zero and is thus the classification boundary generated by that hidden unit considered in isolation. The connection weights from the inputs to a hidden unit determine the orientation of the hyperplane. The bias determines the distance of the hyperplane from the origin. If the bias terms are all small random numbers, then all the hyperplanes will pass close to the origin. Hence, if the data are not centered at the origin, the hyperplane may fail to pass through the data cloud. If all the inputs have a small coefficient of variation, it is quite possible that all the initial hyperplanes will miss the data entirely. With such a poor initialization, local minima are very likely to occur. It is therefore important to center the inputs to get good random initializations. In particular, scaling the inputs to [-1,1] will work better than [0,1], although any scaling that sets to zero the mean or median or other measure of central tendency is likely to be as good, and robust estimators of location and scale (Iglewicz, 1983) will be even better for input variables with extreme outliers. The key detail that makes me think that this is the answer is because you do not observe that it takes a long time to train the network when you use $z$-scores, which have negative and positive input values due to the mean-centering.
Why does $[0,1]$ scaling dramatically increase training time for feed forward ANN (1 hidden layer)?
We can find a reasonable explanation for this behavior in the Neural Network FAQ. TL;DR - try rescaling your data to lie in $[-1,1]$. But standardizing input variables can have far more important eff
Why does $[0,1]$ scaling dramatically increase training time for feed forward ANN (1 hidden layer)? We can find a reasonable explanation for this behavior in the Neural Network FAQ. TL;DR - try rescaling your data to lie in $[-1,1]$. But standardizing input variables can have far more important effects on initialization of the weights than simply avoiding saturation. Assume we have an MLP with one hidden layer applied to a classification problem and are therefore interested in the hyperplanes defined by each hidden unit. Each hyperplane is the locus of points where the net-input to the hidden unit is zero and is thus the classification boundary generated by that hidden unit considered in isolation. The connection weights from the inputs to a hidden unit determine the orientation of the hyperplane. The bias determines the distance of the hyperplane from the origin. If the bias terms are all small random numbers, then all the hyperplanes will pass close to the origin. Hence, if the data are not centered at the origin, the hyperplane may fail to pass through the data cloud. If all the inputs have a small coefficient of variation, it is quite possible that all the initial hyperplanes will miss the data entirely. With such a poor initialization, local minima are very likely to occur. It is therefore important to center the inputs to get good random initializations. In particular, scaling the inputs to [-1,1] will work better than [0,1], although any scaling that sets to zero the mean or median or other measure of central tendency is likely to be as good, and robust estimators of location and scale (Iglewicz, 1983) will be even better for input variables with extreme outliers. The key detail that makes me think that this is the answer is because you do not observe that it takes a long time to train the network when you use $z$-scores, which have negative and positive input values due to the mean-centering.
Why does $[0,1]$ scaling dramatically increase training time for feed forward ANN (1 hidden layer)? We can find a reasonable explanation for this behavior in the Neural Network FAQ. TL;DR - try rescaling your data to lie in $[-1,1]$. But standardizing input variables can have far more important eff
26,186
"Liberal" p-values?
According to this homepage it is common to use this terminology. Conservative in statistics has the same general meaning as in other areas: avoiding excess by erring on the side of caution. In statistics, “conservative” specifically refers to being cautious when it comes to hypothesis tests, test results, or confidence intervals. Reporting conservatively means that you’re less likely to be giving out the wrong information. which can be specified in the following sense: A conservative test always keep the probability of rejecting the null hypothesis well below the significance level. Let’s say you’re running a hypothesis test where you set the alpha level at 5%. That means that the test will (falsely) give you a significant result 1 out of 20 times. This is called the Type I error rate. A conservative test would always control the Type I error rate at a level much smaller than 5%, which means your chance of getting it wrong will be well below 5% (perhaps 2%).* However I recommend you to use other terminologies, e.g. the definition of power. If a hypothesis test is "liberal" in your terminology it has more power. If a hypothesis test is "conservative" in your terminology it has less power. In my experience the term "a liberal hypothesis" is barely used in practice and might sound uncommon to your audience even if your audience consists of statisticians. In the following paragraph I explain why "conservativ" and "liberal" are not always the exact difference in politics. Therefore I disrecommend using liberal as opposite of conservative in statistics. Feel free to ignore this part if it does not help you Note that also in political science liberal is not necessarily the opposite of conservative. In the US left-wing politicians like Bernie Sanders are called liberals, but in many parts of Europe, e.g. Germany, the Netherlands and Denmark it is different. In German Politics Liberalism is mainly understand as the maximum of political freedom, especially in economics. The German Liberal Party (FDP) is in many issues rather right-wing than socialist even though they endorse issues like LGBT Rights and the Legalisation of Cannabis. Some Germans might think of what is called Libertarian in the US when you mention "liberal politics". In Denmark and the Netherlands it is even more complicated. You have two big parties which consider themself as liberal- In the Netherlands "VVD" and "D66"; In Denmark the "Vestre" and the "Radicale Vestre". While "VVD" and "Vestre" are rather "right-wing" the "D66" and the "Radicale Vestre" are rather left wing. For this reason you should not use the terminology: "conservative statistical test" and "liberal statistical test" when speaking to a global, international audience. PS: I hope I kept my political stance out of this topic and explained it neutrally.
"Liberal" p-values?
According to this homepage it is common to use this terminology. Conservative in statistics has the same general meaning as in other areas: avoiding excess by erring on the side of caution. In statis
"Liberal" p-values? According to this homepage it is common to use this terminology. Conservative in statistics has the same general meaning as in other areas: avoiding excess by erring on the side of caution. In statistics, “conservative” specifically refers to being cautious when it comes to hypothesis tests, test results, or confidence intervals. Reporting conservatively means that you’re less likely to be giving out the wrong information. which can be specified in the following sense: A conservative test always keep the probability of rejecting the null hypothesis well below the significance level. Let’s say you’re running a hypothesis test where you set the alpha level at 5%. That means that the test will (falsely) give you a significant result 1 out of 20 times. This is called the Type I error rate. A conservative test would always control the Type I error rate at a level much smaller than 5%, which means your chance of getting it wrong will be well below 5% (perhaps 2%).* However I recommend you to use other terminologies, e.g. the definition of power. If a hypothesis test is "liberal" in your terminology it has more power. If a hypothesis test is "conservative" in your terminology it has less power. In my experience the term "a liberal hypothesis" is barely used in practice and might sound uncommon to your audience even if your audience consists of statisticians. In the following paragraph I explain why "conservativ" and "liberal" are not always the exact difference in politics. Therefore I disrecommend using liberal as opposite of conservative in statistics. Feel free to ignore this part if it does not help you Note that also in political science liberal is not necessarily the opposite of conservative. In the US left-wing politicians like Bernie Sanders are called liberals, but in many parts of Europe, e.g. Germany, the Netherlands and Denmark it is different. In German Politics Liberalism is mainly understand as the maximum of political freedom, especially in economics. The German Liberal Party (FDP) is in many issues rather right-wing than socialist even though they endorse issues like LGBT Rights and the Legalisation of Cannabis. Some Germans might think of what is called Libertarian in the US when you mention "liberal politics". In Denmark and the Netherlands it is even more complicated. You have two big parties which consider themself as liberal- In the Netherlands "VVD" and "D66"; In Denmark the "Vestre" and the "Radicale Vestre". While "VVD" and "Vestre" are rather "right-wing" the "D66" and the "Radicale Vestre" are rather left wing. For this reason you should not use the terminology: "conservative statistical test" and "liberal statistical test" when speaking to a global, international audience. PS: I hope I kept my political stance out of this topic and explained it neutrally.
"Liberal" p-values? According to this homepage it is common to use this terminology. Conservative in statistics has the same general meaning as in other areas: avoiding excess by erring on the side of caution. In statis
26,187
"Liberal" p-values?
The question claims "when a method routinely produces high p-values it is called conservative." As pointed out by @Acccumulation in the comments, a p-value has a precise definition. One does not have more or less conservative p-values. In practice, sometimes one has to estimate a p-value (e.g. by using the bootstrap), and I suppose one could describe such an estimator as "conservative". But I haven't seen this in practice, and I don't think that's what the question is getting at. Although I don't have a reference handy, it certainly seems natural to refer to one hypothesis test as being more conservative than another if it has a smaller type 1 error. Using liberal in the opposite sense seems possible, though I can't remembering seeing that anywhere. The term "conservative" is often used for confidence intervals. A 95% confidence interval procedure will have different coverage probabilities depending on what the true value of the parameter is. For example, in Brown et al.'s Interval Estimation for a Binomial Proportion, speaking about two different confidence intervals for a Bernoulli probability p, they say "the coverage probability of the [Agresti–Coull] interval is quite conservative for p very close to 0 or 1. In comparison to the Wilson interval it is more conservative, especially for small n." Saying it's conservative for p very close to 0 or 1 means that for p close to 0 or 1, the probability of the interval containing the true value of p will be very high -- higher than the nominal coverage of the interval (say 95%).
"Liberal" p-values?
The question claims "when a method routinely produces high p-values it is called conservative." As pointed out by @Acccumulation in the comments, a p-value has a precise definition. One does not hav
"Liberal" p-values? The question claims "when a method routinely produces high p-values it is called conservative." As pointed out by @Acccumulation in the comments, a p-value has a precise definition. One does not have more or less conservative p-values. In practice, sometimes one has to estimate a p-value (e.g. by using the bootstrap), and I suppose one could describe such an estimator as "conservative". But I haven't seen this in practice, and I don't think that's what the question is getting at. Although I don't have a reference handy, it certainly seems natural to refer to one hypothesis test as being more conservative than another if it has a smaller type 1 error. Using liberal in the opposite sense seems possible, though I can't remembering seeing that anywhere. The term "conservative" is often used for confidence intervals. A 95% confidence interval procedure will have different coverage probabilities depending on what the true value of the parameter is. For example, in Brown et al.'s Interval Estimation for a Binomial Proportion, speaking about two different confidence intervals for a Bernoulli probability p, they say "the coverage probability of the [Agresti–Coull] interval is quite conservative for p very close to 0 or 1. In comparison to the Wilson interval it is more conservative, especially for small n." Saying it's conservative for p very close to 0 or 1 means that for p close to 0 or 1, the probability of the interval containing the true value of p will be very high -- higher than the nominal coverage of the interval (say 95%).
"Liberal" p-values? The question claims "when a method routinely produces high p-values it is called conservative." As pointed out by @Acccumulation in the comments, a p-value has a precise definition. One does not hav
26,188
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences?
Here's my "Bayesian" slant on your question. I think you have described a situation where two people with different prior information should get a different answer/conclusion when given the same dataset. A more blunt/extreme example is suppose that we have a "researcher 1b" who just happens to guess the regression model parameters and conclusions from whatever hypothesis. Running $1000$ regressions is not conceptually too far away from guessing. What I think is happening...what do we learn about the researchers prior information from the above question? - researcher 1 probably has a flat prior for the models $P (M_k|I_1)=\frac {1}{1000} $ - researcher 2 has a sharp prior for the model of interest $P (M_1|I_2) =1$ (assume $M_1$ is the model they both fit) This is obviously a simplification, but you can see here, we already place a lot more weight on researcher 2's inferences without any data. But you see, once they both take account of the data, researcher 1's posterior probability for $M_1$ will increase... $P (M_1|DI)>>P (M_1|I) $ (...we know this because it was "better" than $999$ other models...). Researcher 2's posterior can't concentrate anymore, it is already equal to $1$. What we don't know is how much the data supported $M_1$ over the alternatives. What we also don't know is how the different models alter the substantive conclusions of researcher 1. For example, suppose all $1000$ models contain a common term, and all $1000$ regression parameters for that variable are significantly greater than $0$ (eg $p-value <10^{-8}$ for all models). Then there is no problem with concluding a significantly positive effect, even though many models were fit. You also don't say how big the dataset is, and this matters! If you're talking about a dataset with $100$ observations and $10$ covariates/predictors/independent variables, then researcher 1 will probably still be quite uncertain about the model. However, if researcher 1 is using $2,000,000$ observations, this may conclusively determine the model. There is nothing fundamentally wrong with two people that start with different information, and continue to have different conclusions after seeing the same data. However...seeing the same data will bring them closer together, provided their "model space" overlaps and the data supports this "overlapping region".
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m
Here's my "Bayesian" slant on your question. I think you have described a situation where two people with different prior information should get a different answer/conclusion when given the same datas
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences? Here's my "Bayesian" slant on your question. I think you have described a situation where two people with different prior information should get a different answer/conclusion when given the same dataset. A more blunt/extreme example is suppose that we have a "researcher 1b" who just happens to guess the regression model parameters and conclusions from whatever hypothesis. Running $1000$ regressions is not conceptually too far away from guessing. What I think is happening...what do we learn about the researchers prior information from the above question? - researcher 1 probably has a flat prior for the models $P (M_k|I_1)=\frac {1}{1000} $ - researcher 2 has a sharp prior for the model of interest $P (M_1|I_2) =1$ (assume $M_1$ is the model they both fit) This is obviously a simplification, but you can see here, we already place a lot more weight on researcher 2's inferences without any data. But you see, once they both take account of the data, researcher 1's posterior probability for $M_1$ will increase... $P (M_1|DI)>>P (M_1|I) $ (...we know this because it was "better" than $999$ other models...). Researcher 2's posterior can't concentrate anymore, it is already equal to $1$. What we don't know is how much the data supported $M_1$ over the alternatives. What we also don't know is how the different models alter the substantive conclusions of researcher 1. For example, suppose all $1000$ models contain a common term, and all $1000$ regression parameters for that variable are significantly greater than $0$ (eg $p-value <10^{-8}$ for all models). Then there is no problem with concluding a significantly positive effect, even though many models were fit. You also don't say how big the dataset is, and this matters! If you're talking about a dataset with $100$ observations and $10$ covariates/predictors/independent variables, then researcher 1 will probably still be quite uncertain about the model. However, if researcher 1 is using $2,000,000$ observations, this may conclusively determine the model. There is nothing fundamentally wrong with two people that start with different information, and continue to have different conclusions after seeing the same data. However...seeing the same data will bring them closer together, provided their "model space" overlaps and the data supports this "overlapping region".
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m Here's my "Bayesian" slant on your question. I think you have described a situation where two people with different prior information should get a different answer/conclusion when given the same datas
26,189
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences?
The statistical interpretation is much less clear than, what you are asking for, the mathematical treatment. Mathematics is about clearly defined problems. E.g. rolling a perfect dice, or drawing balls from an urn. Statistics is applied mathematics where the mathematics provides a guideline but is not the (exact) solution. In this case it is obvious that circumstances play an important role. If we perform a regression and then calculate (mathematics) some p value to express the strength then what is the interpretation (statistics) and value of the p value? In the case of the 1000 regressions performed by researcher 1 the result is much more weak since this type of situation occurs when we do not really have a clue and are just exploring the data. The p value is just an indication that there may be something. So the p value is obviously less worth in the regression performed by researcher 1. And if researcher 1 or somebody using the results of researcher 1 would like to do something with the regression then the p value needs to be corrected. (and if you thought the difference between researcher 1 and researcher 2 was not enough, just think about the multitude of ways that researcher 1 can to correct the p value for multiple comparisons) In the case of the single regression performed by researcher 2 the result is much stronger evidence. But that is because the regression does not stand on it's own. We have to include the reasons why researcher 2 did only one single regression. This could be because he had good (additional) reasons to already believe that the single regression is a good model for the data. The setting of the regressions performed by researcher 1 and 2 is much different, and it is not often that you encounter both at the same time for the same problem. If this is the case then either researcher 2 was very lucky This is not so uncommon, and we should better correct for this when interpreting literature, as well we should improve the publishing of the total picture of research. If there are a thousand researchers like researcher 2, and we will only see one of them publish a success, then because we did not see the failures of the other 999 researchers we might mistakingly believe we did not have a case like researcher 1 researcher 1 was not so smart and did an incredibly superfluous search for some regression while he might have possibly known from the start that it should have been that single one, and he could have performed a stronger test. For outsiders who are smarter than researcher 1 (do not care about the additional 999 regressions from the start) and read about the work, they might give more strength to the significance of the results, however still not as strong as he would do for the outcome of researcher 2. While researcher 1 may have been too conservative when correcting for 999 superfluous additional regressions, we can not ignore the fact that the research was done in a vacuum of knowledge and it is much more likely to find a lucky researcher of the type 1 than the type 2. An interesting related story: In astronomy, when they were planning a better instrument to measure the cosmic background with higher precision, there were researchers that argued to only release half the data. This because there is only one shot to gather data. Once all the regressions have been performed by the dozens of different researchers (and because of the incredible variation and creativity of the theorist, there is certainly some fit to every possible, random, bump in the data), there is no possibility to perform a new experiment to verify (that is, unless you are able to generate a whole new universe).
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m
The statistical interpretation is much less clear than, what you are asking for, the mathematical treatment. Mathematics is about clearly defined problems. E.g. rolling a perfect dice, or drawing ball
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences? The statistical interpretation is much less clear than, what you are asking for, the mathematical treatment. Mathematics is about clearly defined problems. E.g. rolling a perfect dice, or drawing balls from an urn. Statistics is applied mathematics where the mathematics provides a guideline but is not the (exact) solution. In this case it is obvious that circumstances play an important role. If we perform a regression and then calculate (mathematics) some p value to express the strength then what is the interpretation (statistics) and value of the p value? In the case of the 1000 regressions performed by researcher 1 the result is much more weak since this type of situation occurs when we do not really have a clue and are just exploring the data. The p value is just an indication that there may be something. So the p value is obviously less worth in the regression performed by researcher 1. And if researcher 1 or somebody using the results of researcher 1 would like to do something with the regression then the p value needs to be corrected. (and if you thought the difference between researcher 1 and researcher 2 was not enough, just think about the multitude of ways that researcher 1 can to correct the p value for multiple comparisons) In the case of the single regression performed by researcher 2 the result is much stronger evidence. But that is because the regression does not stand on it's own. We have to include the reasons why researcher 2 did only one single regression. This could be because he had good (additional) reasons to already believe that the single regression is a good model for the data. The setting of the regressions performed by researcher 1 and 2 is much different, and it is not often that you encounter both at the same time for the same problem. If this is the case then either researcher 2 was very lucky This is not so uncommon, and we should better correct for this when interpreting literature, as well we should improve the publishing of the total picture of research. If there are a thousand researchers like researcher 2, and we will only see one of them publish a success, then because we did not see the failures of the other 999 researchers we might mistakingly believe we did not have a case like researcher 1 researcher 1 was not so smart and did an incredibly superfluous search for some regression while he might have possibly known from the start that it should have been that single one, and he could have performed a stronger test. For outsiders who are smarter than researcher 1 (do not care about the additional 999 regressions from the start) and read about the work, they might give more strength to the significance of the results, however still not as strong as he would do for the outcome of researcher 2. While researcher 1 may have been too conservative when correcting for 999 superfluous additional regressions, we can not ignore the fact that the research was done in a vacuum of knowledge and it is much more likely to find a lucky researcher of the type 1 than the type 2. An interesting related story: In astronomy, when they were planning a better instrument to measure the cosmic background with higher precision, there were researchers that argued to only release half the data. This because there is only one shot to gather data. Once all the regressions have been performed by the dozens of different researchers (and because of the incredible variation and creativity of the theorist, there is certainly some fit to every possible, random, bump in the data), there is no possibility to perform a new experiment to verify (that is, unless you are able to generate a whole new universe).
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m The statistical interpretation is much less clear than, what you are asking for, the mathematical treatment. Mathematics is about clearly defined problems. E.g. rolling a perfect dice, or drawing ball
26,190
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences?
Short story: we don’t have enough information to answer your question because we don’t know anything about the methods used or the data collected. Long answer...The real question here is whether each researcher is doing: rigorous science rigorous pseudoscience exploration of data data dredging or p-hacking Their methods will determine the strength of the interpretation of their results. This is because some methods are less sound than others. In rigorous science we develop a hypothesis, identify confounding variables, develop controls for variables outside our hypothesis, plan test methods, plan our analytical methodology, perform tests / collect data, and then analyze data. (Note that the analytical methods are planned before the test occurs). This is the most rigorous because we must accept data and analysis that does not agree with the hypothesis. It isn’t acceptable to change methods after the fact to get something interesting. Any new hypothesis from the findings have to go through the same process again. In pseudoscience we often take data that is already collected. This is more difficult to use ethically because it is easier to add biases to the results. However, it is still possible to follow the scientific method for ethical analysts. It may be difficult to set up proper controls though and that needs to be researched and noted. Exploration of data is not based on science. There is no specific hypothesis. There is not a priori evaluation of confounding factors. Also, it is difficult to go back and re-do the analysis using the same data, because the results may be tainted by prior knowledge or modeling and there is no new data to use for validation. A rigorous scientific experiment is recommended to clarify possible relationships found from exploratory analysis. Data dredging or P-hacking is where an “analyst” performs multiple tests hoping for an unexpected or unknown answer or manipulates the data to get a result. The results may be simple coincidence, may be the result of confounding variable(s), or may not have have meaningful effect size or power. There are some remedies for each problem, but those remedies have to be carefully evaluated.
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m
Short story: we don’t have enough information to answer your question because we don’t know anything about the methods used or the data collected. Long answer...The real question here is whether each
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they make different inferences? Short story: we don’t have enough information to answer your question because we don’t know anything about the methods used or the data collected. Long answer...The real question here is whether each researcher is doing: rigorous science rigorous pseudoscience exploration of data data dredging or p-hacking Their methods will determine the strength of the interpretation of their results. This is because some methods are less sound than others. In rigorous science we develop a hypothesis, identify confounding variables, develop controls for variables outside our hypothesis, plan test methods, plan our analytical methodology, perform tests / collect data, and then analyze data. (Note that the analytical methods are planned before the test occurs). This is the most rigorous because we must accept data and analysis that does not agree with the hypothesis. It isn’t acceptable to change methods after the fact to get something interesting. Any new hypothesis from the findings have to go through the same process again. In pseudoscience we often take data that is already collected. This is more difficult to use ethically because it is easier to add biases to the results. However, it is still possible to follow the scientific method for ethical analysts. It may be difficult to set up proper controls though and that needs to be researched and noted. Exploration of data is not based on science. There is no specific hypothesis. There is not a priori evaluation of confounding factors. Also, it is difficult to go back and re-do the analysis using the same data, because the results may be tainted by prior knowledge or modeling and there is no new data to use for validation. A rigorous scientific experiment is recommended to clarify possible relationships found from exploratory analysis. Data dredging or P-hacking is where an “analyst” performs multiple tests hoping for an unexpected or unknown answer or manipulates the data to get a result. The results may be simple coincidence, may be the result of confounding variable(s), or may not have have meaningful effect size or power. There are some remedies for each problem, but those remedies have to be carefully evaluated.
Researcher 1 runs 1000 regressions, researcher 2 runs only 1, both get same results -- should they m Short story: we don’t have enough information to answer your question because we don’t know anything about the methods used or the data collected. Long answer...The real question here is whether each
26,191
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Metrics in High Dimensional Space" misleading?
No, the theorem is not misleading. It can certainly be applied incorrectly, but that's true for any theorem. Here's simple MATLAB script to demonstrate how it works: xd = randn(1e5,10000); %% cols = [1,10,100,1000,10000]; for c = cols xdt = table(xd(:,1:c)); res = table2array(rowfun(@norm,xdt)); mr = mean(res); res1 = var(res/mr); res2 = (max(res) - min(res))/min(res); fprintf('res1: %f, res2: %f\n',res1,res2) end The OUTPUT: res1: 0.568701, res2: 2562257.458668 res1: 0.051314, res2: 9.580602 res1: 0.005021, res2: 0.911065 res1: 0.000504, res2: 0.221981 res1: 0.000050, res2: 0.063720 In my code res1 and res2 are the two expressions in your equation from the paper: one for variance, and the second one for the contrast. You can see how both go to zero as supposed to when dimensions go from 1 to 10,000.
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Me
No, the theorem is not misleading. It can certainly be applied incorrectly, but that's true for any theorem. Here's simple MATLAB script to demonstrate how it works: xd = randn(1e5,10000); %% cols = [
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Metrics in High Dimensional Space" misleading? No, the theorem is not misleading. It can certainly be applied incorrectly, but that's true for any theorem. Here's simple MATLAB script to demonstrate how it works: xd = randn(1e5,10000); %% cols = [1,10,100,1000,10000]; for c = cols xdt = table(xd(:,1:c)); res = table2array(rowfun(@norm,xdt)); mr = mean(res); res1 = var(res/mr); res2 = (max(res) - min(res))/min(res); fprintf('res1: %f, res2: %f\n',res1,res2) end The OUTPUT: res1: 0.568701, res2: 2562257.458668 res1: 0.051314, res2: 9.580602 res1: 0.005021, res2: 0.911065 res1: 0.000504, res2: 0.221981 res1: 0.000050, res2: 0.063720 In my code res1 and res2 are the two expressions in your equation from the paper: one for variance, and the second one for the contrast. You can see how both go to zero as supposed to when dimensions go from 1 to 10,000.
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Me No, the theorem is not misleading. It can certainly be applied incorrectly, but that's true for any theorem. Here's simple MATLAB script to demonstrate how it works: xd = randn(1e5,10000); %% cols = [
26,192
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Metrics in High Dimensional Space" misleading?
First, the name of the paper is wrong in your question: you meant this paper by Beyer et al where the theorem was originally introduced, and not this paper by Aggarwal et al, which you wrongly named in your OP and was written after the paper by Beyer et. al. Next, what do you mean by "misleading"? It'd be misleading if: There existed a counterexample to this theorem by Beyer et al, and that's not possible since the proof in the first paper by them is correct. I see in the comments that people are asking for a concrete example, which is below. To quote you "this theorem is very often cited to support the statement that measuring proximity based on euclidean space is a poor strategy in a high dimensional space, the authors say so themselves, and yet the proposed behaviour does not actually take place, making me think this theorem has been used in a misleading fashion." Again, the bahavio(u)r does occur in high dimensions, as shown in the family of examples below: the key element is to have iid features/components of the random variable generating the iid random samples. A family of examples that satisfies the hypothesis of the theorem by Beyer et. al. (relative variance $Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right]$" goes to zero) and hence the statement also holds (relative contrast goes to zero), is given in this paper "Concentration of Fractional Distances (Wertz. et. al.)", which basically states that (see its Theorem 5, P. 878) Theorem 5: If $X^{(d)}=(X_1 \dots X_d) \in \mathbb{R}^d$ is a $d$ -dimensional random vector with iid components, then $\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||} \to_{p}1 \iff Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right] \to 0, d \to \infty.$ So this means that if your generated iid random sample by using a random vector whose components are iid (e.g. a normal $\mathcal{N}(0, I_d)$ random vector), then its "relative variance $Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right]$" will go to zero, and hence by Beyer's theorem the maximum norm (=distance to the query point as the origin) divided by minimum norm (=distance to the query point as origin) will converge in probability to $1,$ or equivalently the "relative contrast" (i.e. the ratio of the distances between the farthest and nearest point to the origin, minus one) wil go to zero as well. P.S. for application-minded people, you're welcome to take a look at my relevant question here, seeking practical applications of these theorems.
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Me
First, the name of the paper is wrong in your question: you meant this paper by Beyer et al where the theorem was originally introduced, and not this paper by Aggarwal et al, which you wrongly named i
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Metrics in High Dimensional Space" misleading? First, the name of the paper is wrong in your question: you meant this paper by Beyer et al where the theorem was originally introduced, and not this paper by Aggarwal et al, which you wrongly named in your OP and was written after the paper by Beyer et. al. Next, what do you mean by "misleading"? It'd be misleading if: There existed a counterexample to this theorem by Beyer et al, and that's not possible since the proof in the first paper by them is correct. I see in the comments that people are asking for a concrete example, which is below. To quote you "this theorem is very often cited to support the statement that measuring proximity based on euclidean space is a poor strategy in a high dimensional space, the authors say so themselves, and yet the proposed behaviour does not actually take place, making me think this theorem has been used in a misleading fashion." Again, the bahavio(u)r does occur in high dimensions, as shown in the family of examples below: the key element is to have iid features/components of the random variable generating the iid random samples. A family of examples that satisfies the hypothesis of the theorem by Beyer et. al. (relative variance $Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right]$" goes to zero) and hence the statement also holds (relative contrast goes to zero), is given in this paper "Concentration of Fractional Distances (Wertz. et. al.)", which basically states that (see its Theorem 5, P. 878) Theorem 5: If $X^{(d)}=(X_1 \dots X_d) \in \mathbb{R}^d$ is a $d$ -dimensional random vector with iid components, then $\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||} \to_{p}1 \iff Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right] \to 0, d \to \infty.$ So this means that if your generated iid random sample by using a random vector whose components are iid (e.g. a normal $\mathcal{N}(0, I_d)$ random vector), then its "relative variance $Var\left[\frac{||X^{(d)}||}{\mathbb{E}||X^{(d)}||}\right]$" will go to zero, and hence by Beyer's theorem the maximum norm (=distance to the query point as the origin) divided by minimum norm (=distance to the query point as origin) will converge in probability to $1,$ or equivalently the "relative contrast" (i.e. the ratio of the distances between the farthest and nearest point to the origin, minus one) wil go to zero as well. P.S. for application-minded people, you're welcome to take a look at my relevant question here, seeking practical applications of these theorems.
Is the relative contrast theorem from Beyer et al. paper: "On the Surprising Behavior of Distance Me First, the name of the paper is wrong in your question: you meant this paper by Beyer et al where the theorem was originally introduced, and not this paper by Aggarwal et al, which you wrongly named i
26,193
Zero inflated beta regression using gamlss for vegetation cover data
I have added preliminary support for gamlss to the emmeans package... > emmeans(m1, "site", type = "response") site response SE df asymp.LCL asymp.UCL A 0.02484787 0.01033381 NA 0.01092510 0.05551769 B 0.03821898 0.01775760 NA 0.01518276 0.09290972 C 0.07260824 0.03116918 NA 0.03063369 0.16245783 D 0.18820172 0.04509320 NA 0.11504471 0.29250294 E 0.03598930 0.02304948 NA 0.01005072 0.12070702 Confidence level used: 0.95 Intervals are back-transformed from the logit scale > pairs(.Last.value) contrast odds.ratio SE df z.ratio p.value A / B 0.6412302 0.36639164 NA -0.778 0.9371 A / C 0.3254574 0.18987682 NA -1.924 0.3044 A / D 0.1099111 0.05478393 NA -4.430 0.0001 A / E 0.6825356 0.49751299 NA -0.524 0.9850 B / C 0.5075516 0.32214846 NA -1.068 0.8228 B / D 0.1714066 0.09450455 NA -3.199 0.0120 B / E 1.0644159 0.82513475 NA 0.081 1.0000 C / D 0.3377125 0.18217951 NA -2.012 0.2599 C / E 2.0971579 1.63694350 NA 0.949 0.8777 D / E 6.2098905 4.44082214 NA 2.554 0.0792 P value adjustment: tukey method for comparing a family of 5 estimates Tests are performed on the log odds ratio scale A caution: The estimates and comparisons apply to the non-zero-inflated part of the model. You used a common zero inflation for all sites, so that doesn't mess-up the comparisons much, though the estimated means are too large because the model estimates that about 40% are zero. This does not (yet, if ever) support models that include smoothing components It is available on the emmeans github repository soon. No guarantee it is bug-free.
Zero inflated beta regression using gamlss for vegetation cover data
I have added preliminary support for gamlss to the emmeans package... > emmeans(m1, "site", type = "response") site response SE df asymp.LCL asymp.UCL A 0.02484787 0.01033381 NA 0.010
Zero inflated beta regression using gamlss for vegetation cover data I have added preliminary support for gamlss to the emmeans package... > emmeans(m1, "site", type = "response") site response SE df asymp.LCL asymp.UCL A 0.02484787 0.01033381 NA 0.01092510 0.05551769 B 0.03821898 0.01775760 NA 0.01518276 0.09290972 C 0.07260824 0.03116918 NA 0.03063369 0.16245783 D 0.18820172 0.04509320 NA 0.11504471 0.29250294 E 0.03598930 0.02304948 NA 0.01005072 0.12070702 Confidence level used: 0.95 Intervals are back-transformed from the logit scale > pairs(.Last.value) contrast odds.ratio SE df z.ratio p.value A / B 0.6412302 0.36639164 NA -0.778 0.9371 A / C 0.3254574 0.18987682 NA -1.924 0.3044 A / D 0.1099111 0.05478393 NA -4.430 0.0001 A / E 0.6825356 0.49751299 NA -0.524 0.9850 B / C 0.5075516 0.32214846 NA -1.068 0.8228 B / D 0.1714066 0.09450455 NA -3.199 0.0120 B / E 1.0644159 0.82513475 NA 0.081 1.0000 C / D 0.3377125 0.18217951 NA -2.012 0.2599 C / E 2.0971579 1.63694350 NA 0.949 0.8777 D / E 6.2098905 4.44082214 NA 2.554 0.0792 P value adjustment: tukey method for comparing a family of 5 estimates Tests are performed on the log odds ratio scale A caution: The estimates and comparisons apply to the non-zero-inflated part of the model. You used a common zero inflation for all sites, so that doesn't mess-up the comparisons much, though the estimated means are too large because the model estimates that about 40% are zero. This does not (yet, if ever) support models that include smoothing components It is available on the emmeans github repository soon. No guarantee it is bug-free.
Zero inflated beta regression using gamlss for vegetation cover data I have added preliminary support for gamlss to the emmeans package... > emmeans(m1, "site", type = "response") site response SE df asymp.LCL asymp.UCL A 0.02484787 0.01033381 NA 0.010
26,194
Variational Autoencoder - understanding the latent loss
To get the variational objective, begin with marginal likelihood: $p(x) = \int p(x, z) dz = \int \frac{q(z)}{q(z)} p(x,z) dz$ Recognise this as an expectation: $ = \mathbb E_q [\frac{p(x,z)}{q(z)}] $ Use Jensen's inequality $\ln p(x) \geq \mathbb E_q [\ln \frac{p(x,z)}{q(z)}] $ Use def of conditional probability and properties of logs: $ = \mathbb E_q [\ln p(x|z) + \ln p(z) - \ln q(z)] $ Use def of KL divergence: $ = \mathbb E_q [\ln p(x|z)] - KL(q||p)$ Sprinkle in some $\theta$ and $\phi$ as appropriate and we have the format required. The conditioning of $z$ on $x$ in their notation $q_\phi(z|x)$ is a little unnecessary & confusing IMHO since $q$ is selected to minimise divergence from the posterior (although I get they're flagging it's an approx to the posterior rather than the prior).
Variational Autoencoder - understanding the latent loss
To get the variational objective, begin with marginal likelihood: $p(x) = \int p(x, z) dz = \int \frac{q(z)}{q(z)} p(x,z) dz$ Recognise this as an expectation: $ = \mathbb E_q [\frac{p(x,z)}{q(z)}] $
Variational Autoencoder - understanding the latent loss To get the variational objective, begin with marginal likelihood: $p(x) = \int p(x, z) dz = \int \frac{q(z)}{q(z)} p(x,z) dz$ Recognise this as an expectation: $ = \mathbb E_q [\frac{p(x,z)}{q(z)}] $ Use Jensen's inequality $\ln p(x) \geq \mathbb E_q [\ln \frac{p(x,z)}{q(z)}] $ Use def of conditional probability and properties of logs: $ = \mathbb E_q [\ln p(x|z) + \ln p(z) - \ln q(z)] $ Use def of KL divergence: $ = \mathbb E_q [\ln p(x|z)] - KL(q||p)$ Sprinkle in some $\theta$ and $\phi$ as appropriate and we have the format required. The conditioning of $z$ on $x$ in their notation $q_\phi(z|x)$ is a little unnecessary & confusing IMHO since $q$ is selected to minimise divergence from the posterior (although I get they're flagging it's an approx to the posterior rather than the prior).
Variational Autoencoder - understanding the latent loss To get the variational objective, begin with marginal likelihood: $p(x) = \int p(x, z) dz = \int \frac{q(z)}{q(z)} p(x,z) dz$ Recognise this as an expectation: $ = \mathbb E_q [\frac{p(x,z)}{q(z)}] $
26,195
Variational Autoencoder - understanding the latent loss
Although the answer above is totally correct, you can reach the same conclusion by playing around with the KL divergence. See my detailed answer with some nice references on VI. As a side note, the joint $q(x,z)$ might not be defined but they use $q(z|x)$ to imply the dependence on the data. The example they choose in their original paper (Gaussian multivariate with the mean $\mu$ depending on $x$) might make a bit more sense on why they use the notation they use.
Variational Autoencoder - understanding the latent loss
Although the answer above is totally correct, you can reach the same conclusion by playing around with the KL divergence. See my detailed answer with some nice references on VI. As a side note, the j
Variational Autoencoder - understanding the latent loss Although the answer above is totally correct, you can reach the same conclusion by playing around with the KL divergence. See my detailed answer with some nice references on VI. As a side note, the joint $q(x,z)$ might not be defined but they use $q(z|x)$ to imply the dependence on the data. The example they choose in their original paper (Gaussian multivariate with the mean $\mu$ depending on $x$) might make a bit more sense on why they use the notation they use.
Variational Autoencoder - understanding the latent loss Although the answer above is totally correct, you can reach the same conclusion by playing around with the KL divergence. See my detailed answer with some nice references on VI. As a side note, the j
26,196
Is cross validation unnecessary for Random Forest?
Yes, out-of-bag performance for a random forest is very similar to cross validation. Essentially what you get is leave-one-out with the surrogate random forests using fewer trees. So if done correctly, you get a slight pessimistic bias. The exact bias and variance properties will be somewhat different from externally cross validating your random forest. Like for the cross validation, the crucial point for correctness (i.e. slight pessmistic bias, not large optistic bias) is the implicit assumption that each row of your data is an independent case. If this assumption is not met, the out-of-bag estimate will be overoptimistic (as would be a "plain" cross validation) - and in that situation it may be much easier to set up an outer cross validation that splits into independent groups than to make the random forest deal with such dependence structures. Assuming you have this independence between rows, you can use the random forest's out-of-bag performance estimate just like the corresponding cross validation estimate: either as estimate of generalization error or for model tuning (the parameters mentioned by @horaceT or e.g. boosting). If you use it for model tuning, as always, you need another independent estimate of the final model's generalization error. That being said, the no of trees and no of variables are reasonably easy to fix, so random forest is one of the models I consider with sample sizes that are too small for data-driven model tuning. Prediction error will not increase with higher number of trees - it just won't decrease any further at some point. So you can just throw in a bit more computation time and be OK. number of variates to consider in each tree will depend on your data, but IMHO isn't very critical, neither (in the sense that you can e.g. use experience on previous applications with similar data to fix it). leaf size (for classification) is again typically left at 1 - this again doesn't cost generalization performance, but just computation time and memory.
Is cross validation unnecessary for Random Forest?
Yes, out-of-bag performance for a random forest is very similar to cross validation. Essentially what you get is leave-one-out with the surrogate random forests using fewer trees. So if done correctl
Is cross validation unnecessary for Random Forest? Yes, out-of-bag performance for a random forest is very similar to cross validation. Essentially what you get is leave-one-out with the surrogate random forests using fewer trees. So if done correctly, you get a slight pessimistic bias. The exact bias and variance properties will be somewhat different from externally cross validating your random forest. Like for the cross validation, the crucial point for correctness (i.e. slight pessmistic bias, not large optistic bias) is the implicit assumption that each row of your data is an independent case. If this assumption is not met, the out-of-bag estimate will be overoptimistic (as would be a "plain" cross validation) - and in that situation it may be much easier to set up an outer cross validation that splits into independent groups than to make the random forest deal with such dependence structures. Assuming you have this independence between rows, you can use the random forest's out-of-bag performance estimate just like the corresponding cross validation estimate: either as estimate of generalization error or for model tuning (the parameters mentioned by @horaceT or e.g. boosting). If you use it for model tuning, as always, you need another independent estimate of the final model's generalization error. That being said, the no of trees and no of variables are reasonably easy to fix, so random forest is one of the models I consider with sample sizes that are too small for data-driven model tuning. Prediction error will not increase with higher number of trees - it just won't decrease any further at some point. So you can just throw in a bit more computation time and be OK. number of variates to consider in each tree will depend on your data, but IMHO isn't very critical, neither (in the sense that you can e.g. use experience on previous applications with similar data to fix it). leaf size (for classification) is again typically left at 1 - this again doesn't cost generalization performance, but just computation time and memory.
Is cross validation unnecessary for Random Forest? Yes, out-of-bag performance for a random forest is very similar to cross validation. Essentially what you get is leave-one-out with the surrogate random forests using fewer trees. So if done correctl
26,197
Is cross validation unnecessary for Random Forest?
Horace is right. When you think about OOB, you aren't exactly keeping it out of your model. Each tree may have different samples in-bag and out-of-bag but the forest uses them all. This allows information leakage. The aggregation has its weaknesses. My understanding is that aggregation is accomplished as "weighted average" or "weighted vote". If there are two trees with equal "true" predictive ability over the population of true data, but one of them has higher effective accuracy over the training sample, then it will be given higher weight. The problem with that is, all else being equal, if it has higher accuracy on the training sample then it will have lower accuracy on values outside that sample, that is to say, in what is left of the general population. In this case OOB will have added error by how the bias impacts tree-weight in the aggregation. For a single cross-validation then, imagine the same circumstance: two trees of equal "true" performance on the population, but one has better training results than the other. The holdback portion doesn't inform any of the trees, but it does allow unbiased estimation of performance. The testing error shows that the tree that had better "in-bag" performance will have equal to its counterpart on overall data, as long as the hold-out set is large enough. Classic OOB wouldn't show that. References: http://file.scirp.org/pdf/OJS20110300008_18086118.pdf <-- OOB over-estimates the true error http://kldavenport.com/wp-content/uploads/2014/05/random_forests.pdf http://appliedpredictivemodeling.com/blog/2014/11/27/08ks7leh0zof45zpf5vqe56d1sahb0 <-- oob vs. cv example
Is cross validation unnecessary for Random Forest?
Horace is right. When you think about OOB, you aren't exactly keeping it out of your model. Each tree may have different samples in-bag and out-of-bag but the forest uses them all. This allows info
Is cross validation unnecessary for Random Forest? Horace is right. When you think about OOB, you aren't exactly keeping it out of your model. Each tree may have different samples in-bag and out-of-bag but the forest uses them all. This allows information leakage. The aggregation has its weaknesses. My understanding is that aggregation is accomplished as "weighted average" or "weighted vote". If there are two trees with equal "true" predictive ability over the population of true data, but one of them has higher effective accuracy over the training sample, then it will be given higher weight. The problem with that is, all else being equal, if it has higher accuracy on the training sample then it will have lower accuracy on values outside that sample, that is to say, in what is left of the general population. In this case OOB will have added error by how the bias impacts tree-weight in the aggregation. For a single cross-validation then, imagine the same circumstance: two trees of equal "true" performance on the population, but one has better training results than the other. The holdback portion doesn't inform any of the trees, but it does allow unbiased estimation of performance. The testing error shows that the tree that had better "in-bag" performance will have equal to its counterpart on overall data, as long as the hold-out set is large enough. Classic OOB wouldn't show that. References: http://file.scirp.org/pdf/OJS20110300008_18086118.pdf <-- OOB over-estimates the true error http://kldavenport.com/wp-content/uploads/2014/05/random_forests.pdf http://appliedpredictivemodeling.com/blog/2014/11/27/08ks7leh0zof45zpf5vqe56d1sahb0 <-- oob vs. cv example
Is cross validation unnecessary for Random Forest? Horace is right. When you think about OOB, you aren't exactly keeping it out of your model. Each tree may have different samples in-bag and out-of-bag but the forest uses them all. This allows info
26,198
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference)
Since the parameters $(\mu,\beta)$ of the Gumbel distribution are location and scale, respectively, the problem simplifies into computing $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]= \frac{\int_{-\infty}^{+\infty} x F(x+c) f(x) \text{d}x}{\int_{-\infty}^{+\infty} F(x+c) f(x) \text{d}x}$$ where $f$ and $F$ are associated with $\mu=0$, $\beta=1$. The denominator is available in closed form \begin{align*} \int_{-\infty}^{+\infty} F(x+c) f(x) \text{d}x &= \int_{-\infty}^{+\infty} \exp\{-\exp[-x-c]\}\exp\{-x\}\exp\{-\exp[-x]\}\text{d}x\\&\stackrel{a=e^{-c}}{=}\int_{-\infty}^{+\infty} \exp\{-(1+a)\exp[-x]\}\exp\{-x\}\text{d}x\\&=\frac{1}{1+a}\left[ \exp\{-(1+a)e^{-x}\}\right]_{-\infty}^{+\infty}\\ &=\frac{1}{1+a} \end{align*} The numerator involves an exponential integral since (according to WolframAlpha integrator) \begin{align*} \int_{-\infty}^{+\infty} x F(x+c) f(x) \text{d}x &= \int_{-\infty}^{+\infty} x \exp\{-(1+a)\exp[-x]\}\exp\{-x\}\text{d}x\\ &\stackrel{z=e^{-x}}{=} \int_{0}^{+\infty} \log(z) \exp\{-(1+a)z\}\text{d}z\\ &= \frac{-1}{1+a}\left[\text{Ei}(-(1+a) z) -\log(z) e^{-(1+a) z}\right]_{0}^{\infty}\\ &= \frac{\gamma+\log(1+a)}{1+a} \end{align*} Hence $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]=\gamma+\log(1+e^{-c})$$ This result can easily be checked by simulation, since producing a Gumbel variate amounts to transforming a Uniform (0,1) variate, $U$, as $X=-\log\{-\log(U)\}$. Monte Carlo and theoretical means do agree: This figure demonstrates the adequation of Monte Carlo and theoretical means when $c$ varies from -2 to 2, with logarithmic axes, based on 10⁵ simulations
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference)
Since the parameters $(\mu,\beta)$ of the Gumbel distribution are location and scale, respectively, the problem simplifies into computing $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]= \frac{\int_{
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference) Since the parameters $(\mu,\beta)$ of the Gumbel distribution are location and scale, respectively, the problem simplifies into computing $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]= \frac{\int_{-\infty}^{+\infty} x F(x+c) f(x) \text{d}x}{\int_{-\infty}^{+\infty} F(x+c) f(x) \text{d}x}$$ where $f$ and $F$ are associated with $\mu=0$, $\beta=1$. The denominator is available in closed form \begin{align*} \int_{-\infty}^{+\infty} F(x+c) f(x) \text{d}x &= \int_{-\infty}^{+\infty} \exp\{-\exp[-x-c]\}\exp\{-x\}\exp\{-\exp[-x]\}\text{d}x\\&\stackrel{a=e^{-c}}{=}\int_{-\infty}^{+\infty} \exp\{-(1+a)\exp[-x]\}\exp\{-x\}\text{d}x\\&=\frac{1}{1+a}\left[ \exp\{-(1+a)e^{-x}\}\right]_{-\infty}^{+\infty}\\ &=\frac{1}{1+a} \end{align*} The numerator involves an exponential integral since (according to WolframAlpha integrator) \begin{align*} \int_{-\infty}^{+\infty} x F(x+c) f(x) \text{d}x &= \int_{-\infty}^{+\infty} x \exp\{-(1+a)\exp[-x]\}\exp\{-x\}\text{d}x\\ &\stackrel{z=e^{-x}}{=} \int_{0}^{+\infty} \log(z) \exp\{-(1+a)z\}\text{d}z\\ &= \frac{-1}{1+a}\left[\text{Ei}(-(1+a) z) -\log(z) e^{-(1+a) z}\right]_{0}^{\infty}\\ &= \frac{\gamma+\log(1+a)}{1+a} \end{align*} Hence $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]=\gamma+\log(1+e^{-c})$$ This result can easily be checked by simulation, since producing a Gumbel variate amounts to transforming a Uniform (0,1) variate, $U$, as $X=-\log\{-\log(U)\}$. Monte Carlo and theoretical means do agree: This figure demonstrates the adequation of Monte Carlo and theoretical means when $c$ varies from -2 to 2, with logarithmic axes, based on 10⁵ simulations
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference) Since the parameters $(\mu,\beta)$ of the Gumbel distribution are location and scale, respectively, the problem simplifies into computing $$\mathbb{E}[\epsilon_1|\epsilon_1+c>\epsilon_0]= \frac{\int_{
26,199
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference)
Xi'an computed the answer more directly by evaluating the integrals. We could also get to the answer by arguing that the conditional distribution, when scaled appropriately, is a type 1 Gumbel distribution. The distribution of $\epsilon_1$ conditional on $\epsilon_1 +c > \epsilon_0$, let's call it $\epsilon_2$, is proportional to the product of a pdf and cdf $$f_{\epsilon_2}(\epsilon_2) \propto f_{\epsilon_1}(\epsilon_2) \cdot F_{\epsilon_0}(\epsilon_2+c)$$ This will be (with $z =\frac{\epsilon_2-\mu}{\beta}$ and $d = c/\beta$) $$f_{\epsilon_2}(\epsilon_2) \propto e^{-(z+e^{-z})} \cdot e^{-e^{-z-d}} = e^{-(z+(1+e^{-d})e^{-z})} $$ This is like a type 1 Gumbel distribution or like the more general distribution function $$f(x) = \frac{b^a}{\Gamma(a)} e^{-(ax+be^{-x})}$$ the mean is for $a=1$ equal to $\mu_{x} = \log (b) +\gamma$ with $\gamma$ the Euler-Mascheroni constant (see below for more details). Then the mean of $z$ is $$\mu_{z} = \log (1+e^{-c/\beta}) + \gamma$$ and the mean of $\epsilon_2$ is $$\mu_{\epsilon_2} = \log(1+e^{-c/\beta})\beta + \gamma\beta + \mu$$ Generalized Gumbel distribution and it's mean This form $e^{-(ax+be^{-x})}$ occurs in Ahuja, J. C., and Stanley W. Nash. "The generalized Gompertz-Verhulst family of distributions." Sankhyā: The Indian Journal of Statistics, Series A (1967): 141-156. Although the more well known 'Gumbel distribution' is with $a=b=1$, Gumbel studied this type of distribution in 1935 (Les valeurs extrêmes des distributions statistiques) for the distribution of the m-th order observation in a sample, and he used $a=b=m$ with $m$ a positive integer. The moment generating function is given by Ahuja and Nash: $$M(t;a,b) = \frac{1}{\Gamma(a)}b^t\Gamma(a-t)$$ and the mean has a closed form expression when $a$ is a positive integer $$\mu_{X,a,b} = M^\prime(0;a,b) = \log (b) + \left( \gamma - \sum_{k=1}^{a-1} \frac{1}{k} \right)$$ in the case of $a=1$ this is $$\mu_{X,1,b} = \log (b) + \gamma $$
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference)
Xi'an computed the answer more directly by evaluating the integrals. We could also get to the answer by arguing that the conditional distribution, when scaled appropriately, is a type 1 Gumbel distrib
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference) Xi'an computed the answer more directly by evaluating the integrals. We could also get to the answer by arguing that the conditional distribution, when scaled appropriately, is a type 1 Gumbel distribution. The distribution of $\epsilon_1$ conditional on $\epsilon_1 +c > \epsilon_0$, let's call it $\epsilon_2$, is proportional to the product of a pdf and cdf $$f_{\epsilon_2}(\epsilon_2) \propto f_{\epsilon_1}(\epsilon_2) \cdot F_{\epsilon_0}(\epsilon_2+c)$$ This will be (with $z =\frac{\epsilon_2-\mu}{\beta}$ and $d = c/\beta$) $$f_{\epsilon_2}(\epsilon_2) \propto e^{-(z+e^{-z})} \cdot e^{-e^{-z-d}} = e^{-(z+(1+e^{-d})e^{-z})} $$ This is like a type 1 Gumbel distribution or like the more general distribution function $$f(x) = \frac{b^a}{\Gamma(a)} e^{-(ax+be^{-x})}$$ the mean is for $a=1$ equal to $\mu_{x} = \log (b) +\gamma$ with $\gamma$ the Euler-Mascheroni constant (see below for more details). Then the mean of $z$ is $$\mu_{z} = \log (1+e^{-c/\beta}) + \gamma$$ and the mean of $\epsilon_2$ is $$\mu_{\epsilon_2} = \log(1+e^{-c/\beta})\beta + \gamma\beta + \mu$$ Generalized Gumbel distribution and it's mean This form $e^{-(ax+be^{-x})}$ occurs in Ahuja, J. C., and Stanley W. Nash. "The generalized Gompertz-Verhulst family of distributions." Sankhyā: The Indian Journal of Statistics, Series A (1967): 141-156. Although the more well known 'Gumbel distribution' is with $a=b=1$, Gumbel studied this type of distribution in 1935 (Les valeurs extrêmes des distributions statistiques) for the distribution of the m-th order observation in a sample, and he used $a=b=m$ with $m$ a positive integer. The moment generating function is given by Ahuja and Nash: $$M(t;a,b) = \frac{1}{\Gamma(a)}b^t\Gamma(a-t)$$ and the mean has a closed form expression when $a$ is a positive integer $$\mu_{X,a,b} = M^\prime(0;a,b) = \log (b) + \left( \gamma - \sum_{k=1}^{a-1} \frac{1}{k} \right)$$ in the case of $a=1$ this is $$\mu_{X,1,b} = \log (b) + \gamma $$
Conditional expectation of a truncated RV derivation, gumbel distribution (logistic difference) Xi'an computed the answer more directly by evaluating the integrals. We could also get to the answer by arguing that the conditional distribution, when scaled appropriately, is a type 1 Gumbel distrib
26,200
If you can't do it orthogonally, do it raw (polynomial regression)
The variables $X$ and $X^2$ are not linearly independent. So even if there is no quadratic effect, adding $X^2$ to the model will modify the estimated effect of $X$. Let’s have a look with a very simple simulation. > x <- runif(1e3) > y <- x + rnorm(length(x)) > summary(lm(y~x)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.03486 0.06233 -0.559 0.576 x 1.05843 0.10755 9.841 <2e-16 *** Now with a quadratic term in the model to fit. > summary(lm(y~x+I(x^2))) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.03275 0.09528 0.344 0.731 x 0.65742 0.44068 1.492 0.136 I(x^2) 0.39914 0.42537 0.938 0.348 Of course the omnibus test is still significant, but I think the result we are looking is not this one. The solution is to use orthogonal polynomials. > summary(lm(y~poly(x,2))) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.49744 0.03098 16.059 <2e-16 *** poly(x, 2)1 9.63943 0.97954 9.841 <2e-16 *** poly(x, 2)2 0.91916 0.97954 0.938 0.348 Note that the coefficients of x in the first model and of poly(x,2)1 in the second model are not equal, and even the intercepts are different. This is because poly delivers orthonormal vectors, which are also orthogonal to the vector rep(1, length(x)). So poly(x,2)1 is not x but rather (x -mean(x))/sqrt(sum((x-mean(x))**2))... An important point is that the Wald tests, in this last model, are independent. You can use orthogonal polynomials to decide up to which degree you want to go, just by looking at the Wald test: here you decide to keep $X$ but not $X^2$. Of course you would find the same model by comparing the first two fitted models, but it is simpler this way — if you consider going up to higher degrees, it is really much simpler. Once you have decided which terms to keep, you may want to go back to raw polynomials $X$ and $X^2$ for interpretability or for prediction.
If you can't do it orthogonally, do it raw (polynomial regression)
The variables $X$ and $X^2$ are not linearly independent. So even if there is no quadratic effect, adding $X^2$ to the model will modify the estimated effect of $X$. Let’s have a look with a very simp
If you can't do it orthogonally, do it raw (polynomial regression) The variables $X$ and $X^2$ are not linearly independent. So even if there is no quadratic effect, adding $X^2$ to the model will modify the estimated effect of $X$. Let’s have a look with a very simple simulation. > x <- runif(1e3) > y <- x + rnorm(length(x)) > summary(lm(y~x)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.03486 0.06233 -0.559 0.576 x 1.05843 0.10755 9.841 <2e-16 *** Now with a quadratic term in the model to fit. > summary(lm(y~x+I(x^2))) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.03275 0.09528 0.344 0.731 x 0.65742 0.44068 1.492 0.136 I(x^2) 0.39914 0.42537 0.938 0.348 Of course the omnibus test is still significant, but I think the result we are looking is not this one. The solution is to use orthogonal polynomials. > summary(lm(y~poly(x,2))) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.49744 0.03098 16.059 <2e-16 *** poly(x, 2)1 9.63943 0.97954 9.841 <2e-16 *** poly(x, 2)2 0.91916 0.97954 0.938 0.348 Note that the coefficients of x in the first model and of poly(x,2)1 in the second model are not equal, and even the intercepts are different. This is because poly delivers orthonormal vectors, which are also orthogonal to the vector rep(1, length(x)). So poly(x,2)1 is not x but rather (x -mean(x))/sqrt(sum((x-mean(x))**2))... An important point is that the Wald tests, in this last model, are independent. You can use orthogonal polynomials to decide up to which degree you want to go, just by looking at the Wald test: here you decide to keep $X$ but not $X^2$. Of course you would find the same model by comparing the first two fitted models, but it is simpler this way — if you consider going up to higher degrees, it is really much simpler. Once you have decided which terms to keep, you may want to go back to raw polynomials $X$ and $X^2$ for interpretability or for prediction.
If you can't do it orthogonally, do it raw (polynomial regression) The variables $X$ and $X^2$ are not linearly independent. So even if there is no quadratic effect, adding $X^2$ to the model will modify the estimated effect of $X$. Let’s have a look with a very simp