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
42,101
Is this a problem for Survival analysis?
A few thoughts: As @PeterFlom mentioned, if you just want to find out whether or not they "make it", that's a 0/1 outcome that is amenable to logistic or binomial regression, and can be addressed outside the context of survival analysis if you don't much care about the time they took to fail. However…you said you do care, so turning to survival analysis: Yes, "time to event" questions are survival analysis questions, and this looks like a pretty clear one. Whether or not "Olympic censoring" is a problem really depends on the question you want to ask. Are you just talking about time until injury in a cohort of athletes training for the Olympics? If that's the case, I can see making an argument that those who do make it to the Olympics are censored - given infinite time and no other outcome they will injure themselves, we've just stopped following them. If, on the other hand, you are really interested in Injury while training for the Olympics then yes, treating them as censored is a problem. What you actually have now is a time until two mutually exclusive outcomes: 1) Injury before the Olympics and 2) Participation in the Olympics. You're now in the domain of competing risks survival analysis, of which the cure models suggested in the comments are a sub-set. A related set of models are "mixture models", which model, as the name suggests, a mixture of two outcomes. This paper: http://aje.oxfordjournals.org/content/170/2/244.short by Lau, Cole and Gange in AJE is an excellent review of mixture models for survival analysis. Be warned however that, coming from a place with nicely documented and implemented packages for conventional survival analysis that the mixture model universe is…somewhat less developed from the software side.
Is this a problem for Survival analysis?
A few thoughts: As @PeterFlom mentioned, if you just want to find out whether or not they "make it", that's a 0/1 outcome that is amenable to logistic or binomial regression, and can be addressed out
Is this a problem for Survival analysis? A few thoughts: As @PeterFlom mentioned, if you just want to find out whether or not they "make it", that's a 0/1 outcome that is amenable to logistic or binomial regression, and can be addressed outside the context of survival analysis if you don't much care about the time they took to fail. However…you said you do care, so turning to survival analysis: Yes, "time to event" questions are survival analysis questions, and this looks like a pretty clear one. Whether or not "Olympic censoring" is a problem really depends on the question you want to ask. Are you just talking about time until injury in a cohort of athletes training for the Olympics? If that's the case, I can see making an argument that those who do make it to the Olympics are censored - given infinite time and no other outcome they will injure themselves, we've just stopped following them. If, on the other hand, you are really interested in Injury while training for the Olympics then yes, treating them as censored is a problem. What you actually have now is a time until two mutually exclusive outcomes: 1) Injury before the Olympics and 2) Participation in the Olympics. You're now in the domain of competing risks survival analysis, of which the cure models suggested in the comments are a sub-set. A related set of models are "mixture models", which model, as the name suggests, a mixture of two outcomes. This paper: http://aje.oxfordjournals.org/content/170/2/244.short by Lau, Cole and Gange in AJE is an excellent review of mixture models for survival analysis. Be warned however that, coming from a place with nicely documented and implemented packages for conventional survival analysis that the mixture model universe is…somewhat less developed from the software side.
Is this a problem for Survival analysis? A few thoughts: As @PeterFlom mentioned, if you just want to find out whether or not they "make it", that's a 0/1 outcome that is amenable to logistic or binomial regression, and can be addressed out
42,102
Multi-variate normal distribution distance from vector sub-space
Let us generally assume $U$ is an affine subspace. Letting $\nu$ be a unit normal to $U$ and $\delta$ the distance from $U$ to the origin (in the $\nu$ direction), $$U = \{x\in \mathbb{R}^n \ |\ \nu \cdot x = \delta\}.$$ The vector $\nu$ can be completed to a basis $\{\nu, e_2, e_3, \ldots, e_n\}$ of $\mathbb{R}^n$ in which $\nu$ is orthogonal to all the $e_i.$ In this basis the distribution becomes the product of a Normal distribution in the $\nu$ direction with variance $\nu\prime C \nu$ and mean $\nu\cdot \mu$ and the distance between any $x$ and $U$ is $|\nu \cdot x - \delta|$. The question is thereby reduced to this one-dimensional context where the answer is readily obtained. Example Suppose $X$ is bivariate Normal with mean $(2,-3)$ and diagonal variance matrix $\Sigma$ having $4$ and $1$ on the diagonals. Let $U$ be the hyperplane given by normal vector $(1,1)$ and distance $1$ from the origin. Here are 10,000 simulated values along with $U$ (a line, shown in red). Simulated points within 0.05 of $U$ are highlighted. Using a million ($10^6$) simulated values, the limiting ratio of $P(d)/d$ is estimated as $0.1411 \pm 0.00035$. The correct value, computed as described above, is $0.14087,$ in satisfactory agreement. The R code to produce this simulation, draw the plot, and compute the correct value follows. # # Simulate from a multivariate normal distribution. # require(mvtnorm) set.seed(17) sigma <- diag(c(4, 1)) mu <- c(2, -3) N <- 10^6 x <- rmvnorm(N, mu, sigma) if (N <= 10^4) plot(x, cex=1/2, col="#00000040", asp=1) # # Describe and plot an affine hyperplane nu.x == d. # nu <- c(1,1)/sqrt(2) d <- 1 if (N <= 10^4) abline(1/nu[2], -nu[1]/nu[2], col="Red") # # Show values close to the hyperplane and estimate their probability. # eps <- 0.05 i <- abs(x %*% nu - d) < eps if (N <= 10^4) points(x[i, ], cex=1/2, col="Red") p <- mean(i) / (2*eps) n.dec <- ceiling(log(N, base=10)/2)+1 # # Perform an exact calculation. # s <- nu %*% sigma %*% nu z <- dnorm(d, mean=sum(nu*mu), sd=sqrt(s)) # # Display the results. # cat("Lim(P(d)/d) equals", round(z, n.dec+1)) cat("Lim(P(d)/d) is approximately", round(p, n.dec), "+-", round(sqrt(p*(1-p)/N), n.dec+1)) This code only computes the limiting probability to be at distance $0$ from $U$. When performing the calculation for nonzero distances, do not forget that there are two sides to the hyperplane: you must double the value of the normal PDF.
Multi-variate normal distribution distance from vector sub-space
Let us generally assume $U$ is an affine subspace. Letting $\nu$ be a unit normal to $U$ and $\delta$ the distance from $U$ to the origin (in the $\nu$ direction), $$U = \{x\in \mathbb{R}^n \ |\ \n
Multi-variate normal distribution distance from vector sub-space Let us generally assume $U$ is an affine subspace. Letting $\nu$ be a unit normal to $U$ and $\delta$ the distance from $U$ to the origin (in the $\nu$ direction), $$U = \{x\in \mathbb{R}^n \ |\ \nu \cdot x = \delta\}.$$ The vector $\nu$ can be completed to a basis $\{\nu, e_2, e_3, \ldots, e_n\}$ of $\mathbb{R}^n$ in which $\nu$ is orthogonal to all the $e_i.$ In this basis the distribution becomes the product of a Normal distribution in the $\nu$ direction with variance $\nu\prime C \nu$ and mean $\nu\cdot \mu$ and the distance between any $x$ and $U$ is $|\nu \cdot x - \delta|$. The question is thereby reduced to this one-dimensional context where the answer is readily obtained. Example Suppose $X$ is bivariate Normal with mean $(2,-3)$ and diagonal variance matrix $\Sigma$ having $4$ and $1$ on the diagonals. Let $U$ be the hyperplane given by normal vector $(1,1)$ and distance $1$ from the origin. Here are 10,000 simulated values along with $U$ (a line, shown in red). Simulated points within 0.05 of $U$ are highlighted. Using a million ($10^6$) simulated values, the limiting ratio of $P(d)/d$ is estimated as $0.1411 \pm 0.00035$. The correct value, computed as described above, is $0.14087,$ in satisfactory agreement. The R code to produce this simulation, draw the plot, and compute the correct value follows. # # Simulate from a multivariate normal distribution. # require(mvtnorm) set.seed(17) sigma <- diag(c(4, 1)) mu <- c(2, -3) N <- 10^6 x <- rmvnorm(N, mu, sigma) if (N <= 10^4) plot(x, cex=1/2, col="#00000040", asp=1) # # Describe and plot an affine hyperplane nu.x == d. # nu <- c(1,1)/sqrt(2) d <- 1 if (N <= 10^4) abline(1/nu[2], -nu[1]/nu[2], col="Red") # # Show values close to the hyperplane and estimate their probability. # eps <- 0.05 i <- abs(x %*% nu - d) < eps if (N <= 10^4) points(x[i, ], cex=1/2, col="Red") p <- mean(i) / (2*eps) n.dec <- ceiling(log(N, base=10)/2)+1 # # Perform an exact calculation. # s <- nu %*% sigma %*% nu z <- dnorm(d, mean=sum(nu*mu), sd=sqrt(s)) # # Display the results. # cat("Lim(P(d)/d) equals", round(z, n.dec+1)) cat("Lim(P(d)/d) is approximately", round(p, n.dec), "+-", round(sqrt(p*(1-p)/N), n.dec+1)) This code only computes the limiting probability to be at distance $0$ from $U$. When performing the calculation for nonzero distances, do not forget that there are two sides to the hyperplane: you must double the value of the normal PDF.
Multi-variate normal distribution distance from vector sub-space Let us generally assume $U$ is an affine subspace. Letting $\nu$ be a unit normal to $U$ and $\delta$ the distance from $U$ to the origin (in the $\nu$ direction), $$U = \{x\in \mathbb{R}^n \ |\ \n
42,103
Threshold in precision/recall curve
Short answer: Torgo describes the usual method of generating such curves. You can choose your threshold (= cut-off limit in the cited text) at any value. The cited text refers to one such choice as a working point. That is, for a given working point, you'll observe exactly one (precision; recall) pair, i.e. one point in your graph. The precision-recall-curve is obtained by varying the threshold over the whole range of the classifier's continuous output ("scores", posterior probabilities, "votes") thus generating a curve from many working points. Edit with respect to the comment: I think "varying the threshold" is the usual way to explain or define the curve. For the calculation, it is more efficient to sort the scores, and then see how precision and recall change when adding the next case: precision and recall can only change when the change in the threshold is large enough to cover the next score. Consider this example: case true class predicted score (high => class B) 1 A 0.2 3 B 0.5 2 A 0.6 4 B 0.9 threshold recall precision > 0.9 N/A 0.0 (0.6, 0.9] 0.5 1.0 (0.5, 0.6] 0.5 0.5 (0.2, 0.5] 1.0 0.67 < 0.2 1.0 0.5 That is, the precision-recall-curve acutally consists of points. It jumps from one point to the next when the threshold "crosses" an acutally predicted score. A smooth curve will result only for large numbers of test cases.
Threshold in precision/recall curve
Short answer: Torgo describes the usual method of generating such curves. You can choose your threshold (= cut-off limit in the cited text) at any value. The cited text refers to one such choice as a
Threshold in precision/recall curve Short answer: Torgo describes the usual method of generating such curves. You can choose your threshold (= cut-off limit in the cited text) at any value. The cited text refers to one such choice as a working point. That is, for a given working point, you'll observe exactly one (precision; recall) pair, i.e. one point in your graph. The precision-recall-curve is obtained by varying the threshold over the whole range of the classifier's continuous output ("scores", posterior probabilities, "votes") thus generating a curve from many working points. Edit with respect to the comment: I think "varying the threshold" is the usual way to explain or define the curve. For the calculation, it is more efficient to sort the scores, and then see how precision and recall change when adding the next case: precision and recall can only change when the change in the threshold is large enough to cover the next score. Consider this example: case true class predicted score (high => class B) 1 A 0.2 3 B 0.5 2 A 0.6 4 B 0.9 threshold recall precision > 0.9 N/A 0.0 (0.6, 0.9] 0.5 1.0 (0.5, 0.6] 0.5 0.5 (0.2, 0.5] 1.0 0.67 < 0.2 1.0 0.5 That is, the precision-recall-curve acutally consists of points. It jumps from one point to the next when the threshold "crosses" an acutally predicted score. A smooth curve will result only for large numbers of test cases.
Threshold in precision/recall curve Short answer: Torgo describes the usual method of generating such curves. You can choose your threshold (= cut-off limit in the cited text) at any value. The cited text refers to one such choice as a
42,104
Threshold in precision/recall curve
For your aim, precision/recall curves are not that relevant. Yours is a probability estimation problem, something that logistic regression and its many variations can do quite nicely. There is nothing magic about a probability threshold of 0.5 nor is it needed. You can choose $k$ based on cost and inspect the units with the $k$ highest predicted probabilities. Also, plot a lift curve. The estimated probabilities are also self-contained error rates. Always keep then handy during the inspection process as this will make the inspectors aware of "close calls."
Threshold in precision/recall curve
For your aim, precision/recall curves are not that relevant. Yours is a probability estimation problem, something that logistic regression and its many variations can do quite nicely. There is nothi
Threshold in precision/recall curve For your aim, precision/recall curves are not that relevant. Yours is a probability estimation problem, something that logistic regression and its many variations can do quite nicely. There is nothing magic about a probability threshold of 0.5 nor is it needed. You can choose $k$ based on cost and inspect the units with the $k$ highest predicted probabilities. Also, plot a lift curve. The estimated probabilities are also self-contained error rates. Always keep then handy during the inspection process as this will make the inspectors aware of "close calls."
Threshold in precision/recall curve For your aim, precision/recall curves are not that relevant. Yours is a probability estimation problem, something that logistic regression and its many variations can do quite nicely. There is nothi
42,105
Comparison of Kaplan-Meier curves across ordered groups
Function comp in survMisc may be close to what you're after. From the docs: Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group: $$S_1(t) \geq S_2(t) \geq ... \geq S_K(t) \quad t \leq \tau$$ where $\tau$ is the largest $t$ where all groups have at least one subject at risk. The null hypothesis is that $$S_1(t) = S_2(t) = ... = S_K(t) \quad t \leq \tau$$ Scores used to construct the test are typically $s = 1,2,...,K$, but may be given as a vector representing a numeric characteristic of the group. They are calculated by finding: $$Z_j(t_i) = \sum_{t_i \leq \tau} W(t_i)[e_{ji} - n_{ji} \frac{e_i}{n_i}], \quad j=1,2,...,K$$ The test statistic is: $$Z = \frac{ \sum_{j=1}^K s_jZ_j(\tau)}{\sqrt{\sum_{j=1}^K \sum_{g=1}^K s_js_g \sigma_{jg}}}$$ where $\sigma$ is the the appropriate element in the variance-covariance matrix (see COV). If ordering is present, the statistic $Z$ will be greater than the upper $\alpha$-th percentile of a standard normal distribution. For example: library(survMisc) data(larynx, package="KMsurv") s4 <- survfit(Surv(time, delta) ~ stage, data=larynx) comp(s4) This will give tests for trend with various weights (as are used with the standard log-rank test): $tests$trendTests Z p Log-rank 3.718959 0.00010 Gehan-Breslow (mod~ Wilcoxon) 4.224765 0.00001 Tarone-Ware 4.058010 0.00002 Peto-Peto 4.129343 0.00002 Mod~ Peto-Peto (Andersen) 4.136319 0.00002 Trend F-H with p=1, q=1 2.396992 0.00827 The package has been changed slightly, and instead of tests or trendtests, use tft, which stands for... tests for trend. Furthermore, when using the comp() function, type it like this: comp(ten(<whatever your survival-fit object is>)).
Comparison of Kaplan-Meier curves across ordered groups
Function comp in survMisc may be close to what you're after. From the docs: Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group: $$S_1(t) \g
Comparison of Kaplan-Meier curves across ordered groups Function comp in survMisc may be close to what you're after. From the docs: Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group: $$S_1(t) \geq S_2(t) \geq ... \geq S_K(t) \quad t \leq \tau$$ where $\tau$ is the largest $t$ where all groups have at least one subject at risk. The null hypothesis is that $$S_1(t) = S_2(t) = ... = S_K(t) \quad t \leq \tau$$ Scores used to construct the test are typically $s = 1,2,...,K$, but may be given as a vector representing a numeric characteristic of the group. They are calculated by finding: $$Z_j(t_i) = \sum_{t_i \leq \tau} W(t_i)[e_{ji} - n_{ji} \frac{e_i}{n_i}], \quad j=1,2,...,K$$ The test statistic is: $$Z = \frac{ \sum_{j=1}^K s_jZ_j(\tau)}{\sqrt{\sum_{j=1}^K \sum_{g=1}^K s_js_g \sigma_{jg}}}$$ where $\sigma$ is the the appropriate element in the variance-covariance matrix (see COV). If ordering is present, the statistic $Z$ will be greater than the upper $\alpha$-th percentile of a standard normal distribution. For example: library(survMisc) data(larynx, package="KMsurv") s4 <- survfit(Surv(time, delta) ~ stage, data=larynx) comp(s4) This will give tests for trend with various weights (as are used with the standard log-rank test): $tests$trendTests Z p Log-rank 3.718959 0.00010 Gehan-Breslow (mod~ Wilcoxon) 4.224765 0.00001 Tarone-Ware 4.058010 0.00002 Peto-Peto 4.129343 0.00002 Mod~ Peto-Peto (Andersen) 4.136319 0.00002 Trend F-H with p=1, q=1 2.396992 0.00827 The package has been changed slightly, and instead of tests or trendtests, use tft, which stands for... tests for trend. Furthermore, when using the comp() function, type it like this: comp(ten(<whatever your survival-fit object is>)).
Comparison of Kaplan-Meier curves across ordered groups Function comp in survMisc may be close to what you're after. From the docs: Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group: $$S_1(t) \g
42,106
Use a clustering as a segmentation
Have you looked at stream clustering algorithms? There has been some research on changing data sets, and related challenges such as concept drift. Also, get rid of thinking in k-means terms; more modern clustering algorithms do not have spherical clusters that can be summarized with just a centroid. Thinking of clusters as "centroids" limits your way of thinking.
Use a clustering as a segmentation
Have you looked at stream clustering algorithms? There has been some research on changing data sets, and related challenges such as concept drift. Also, get rid of thinking in k-means terms; more mode
Use a clustering as a segmentation Have you looked at stream clustering algorithms? There has been some research on changing data sets, and related challenges such as concept drift. Also, get rid of thinking in k-means terms; more modern clustering algorithms do not have spherical clusters that can be summarized with just a centroid. Thinking of clusters as "centroids" limits your way of thinking.
Use a clustering as a segmentation Have you looked at stream clustering algorithms? There has been some research on changing data sets, and related challenges such as concept drift. Also, get rid of thinking in k-means terms; more mode
42,107
Zero-inflated negative binomial
You remember it wrongly: a zero-inflated negative binomial (ZINB) is a mixture of a point mass at zero and a negative binomial(NB) distribution. $$ f_{ZINB}(Y;\pi, \mu, \theta) = \pi Z(Y) + (1-\pi)f_{NB}(Y;\mu, \theta) $$ with Z(Y) a point mass at zero. Zero observation can come from either distribution, non-zero ones only from the NB. The "logit-part" you refer to models the mixing parameter $\pi$ as a function on covariates, assuming a binomial distribution with succes probability $\pi$. To answer your question: yes if you set $\pi=0$ you're indeed back at the regular NB
Zero-inflated negative binomial
You remember it wrongly: a zero-inflated negative binomial (ZINB) is a mixture of a point mass at zero and a negative binomial(NB) distribution. $$ f_{ZINB}(Y;\pi, \mu, \theta) = \pi Z(Y) + (1-\pi)f_
Zero-inflated negative binomial You remember it wrongly: a zero-inflated negative binomial (ZINB) is a mixture of a point mass at zero and a negative binomial(NB) distribution. $$ f_{ZINB}(Y;\pi, \mu, \theta) = \pi Z(Y) + (1-\pi)f_{NB}(Y;\mu, \theta) $$ with Z(Y) a point mass at zero. Zero observation can come from either distribution, non-zero ones only from the NB. The "logit-part" you refer to models the mixing parameter $\pi$ as a function on covariates, assuming a binomial distribution with succes probability $\pi$. To answer your question: yes if you set $\pi=0$ you're indeed back at the regular NB
Zero-inflated negative binomial You remember it wrongly: a zero-inflated negative binomial (ZINB) is a mixture of a point mass at zero and a negative binomial(NB) distribution. $$ f_{ZINB}(Y;\pi, \mu, \theta) = \pi Z(Y) + (1-\pi)f_
42,108
What are the main differences between classical and Gibbs sampling Latent Dirichlet Allocations?
LDA is a probabilistic graphical model for a document generating process as explained in Blei et. al in JMLR 2003(For more intuition on generative process see http://videolectures.net/mlss09uk_blei_tm/). Now the main and obvious idea here is that we can generate documents if we knew the parameters, in a sense in which we have modeled our document. But the problem here is that we do not know the parameters. So we use our Bayes rule to invert the generative process. Now we want to model the uncertainty in the parameters given the data, in a sense in which we have our model. That is we need to infer the unknowns given the data. In both cases, the model is the same. But the way in which we are inferring is different. The method used by Blei et al is called variational inference and the one used by Griffiths is sampling based inference. Both are approximate inference methods, one being in MCMC class(Griffiths) and other being the variational class(Blei). In variational inference, say we have a complex multimodal distribution on which we cannot infer. What we want is to approximate that complex multimodal distribution with a simpler distribution(called Q in the literature see (3)). We do this by choosing a simpler family of distributions, either by explicitly choosing a simpler family in parametric form as in LDA by Blei 2003 or just deciding the factorized form as in (5) by Bishop for a normal distribution example(Here without explicitly choosing the parametric form, this is why it is also called free form optimization). Other important difference from gibbs sampling is that the simpler distribution(1) locks on to one of the modes(2) of the complex distribution which we could not handle but in Gibbs sampling we visit the modes all over. With respect to variational inference, it is easier to look at gibbs sampling. In Gibbs sampling, we form an integral of the statistics we are interested in(probabilities can also be expressed as integrals). Now we use monte carlo approximation to the integral we formed by using samples from the distribution. Again here also it is difficult to sample from the complex distribution(if applicable) and we turn to a familiar distribution from which we are capable of sampling. There are a lot of hacks and improvement to this basic description. For more details see (3) (4) (2)(which comes from the zero forcing nature of reverse KL divergence used as cost. Understanding zero forcing is subtle and nice. Suppose you want to lock the unnormalized unimodal distribution onto one of the modes of complex multimodal distribution. Now we need some imagination. What happens in zero forcing is that where the complex distribution is zero the simpler multimodal distribution is forced to be zero and because the simpler distribution's is mostly chosen to be unimodal so it has no choice but to slip into one of the modes(zero focing effect). If you think in terms of unnormalized distribution because we are interested in parameters, it seems cool that the unimodal slips into one of the modes of multimodal). (1)(which is unimodal in the case of mean field approximation) (3) Machine Learning a Probabilistic Perspective: Kevin Murphy chapter 21 Variational Inference chapter 22 More Variational Inference chapter 23 Monte Carlo Inference chapter 24 Markov Chain Monte Carlo Inference (4) Graphical Models, Exponential Families, and Variational Inference: Martin Wainwright and Michael Jordan (5) Pattern Recognition and Machine Learning : Bishop
What are the main differences between classical and Gibbs sampling Latent Dirichlet Allocations?
LDA is a probabilistic graphical model for a document generating process as explained in Blei et. al in JMLR 2003(For more intuition on generative process see http://videolectures.net/mlss09uk_blei_tm
What are the main differences between classical and Gibbs sampling Latent Dirichlet Allocations? LDA is a probabilistic graphical model for a document generating process as explained in Blei et. al in JMLR 2003(For more intuition on generative process see http://videolectures.net/mlss09uk_blei_tm/). Now the main and obvious idea here is that we can generate documents if we knew the parameters, in a sense in which we have modeled our document. But the problem here is that we do not know the parameters. So we use our Bayes rule to invert the generative process. Now we want to model the uncertainty in the parameters given the data, in a sense in which we have our model. That is we need to infer the unknowns given the data. In both cases, the model is the same. But the way in which we are inferring is different. The method used by Blei et al is called variational inference and the one used by Griffiths is sampling based inference. Both are approximate inference methods, one being in MCMC class(Griffiths) and other being the variational class(Blei). In variational inference, say we have a complex multimodal distribution on which we cannot infer. What we want is to approximate that complex multimodal distribution with a simpler distribution(called Q in the literature see (3)). We do this by choosing a simpler family of distributions, either by explicitly choosing a simpler family in parametric form as in LDA by Blei 2003 or just deciding the factorized form as in (5) by Bishop for a normal distribution example(Here without explicitly choosing the parametric form, this is why it is also called free form optimization). Other important difference from gibbs sampling is that the simpler distribution(1) locks on to one of the modes(2) of the complex distribution which we could not handle but in Gibbs sampling we visit the modes all over. With respect to variational inference, it is easier to look at gibbs sampling. In Gibbs sampling, we form an integral of the statistics we are interested in(probabilities can also be expressed as integrals). Now we use monte carlo approximation to the integral we formed by using samples from the distribution. Again here also it is difficult to sample from the complex distribution(if applicable) and we turn to a familiar distribution from which we are capable of sampling. There are a lot of hacks and improvement to this basic description. For more details see (3) (4) (2)(which comes from the zero forcing nature of reverse KL divergence used as cost. Understanding zero forcing is subtle and nice. Suppose you want to lock the unnormalized unimodal distribution onto one of the modes of complex multimodal distribution. Now we need some imagination. What happens in zero forcing is that where the complex distribution is zero the simpler multimodal distribution is forced to be zero and because the simpler distribution's is mostly chosen to be unimodal so it has no choice but to slip into one of the modes(zero focing effect). If you think in terms of unnormalized distribution because we are interested in parameters, it seems cool that the unimodal slips into one of the modes of multimodal). (1)(which is unimodal in the case of mean field approximation) (3) Machine Learning a Probabilistic Perspective: Kevin Murphy chapter 21 Variational Inference chapter 22 More Variational Inference chapter 23 Monte Carlo Inference chapter 24 Markov Chain Monte Carlo Inference (4) Graphical Models, Exponential Families, and Variational Inference: Martin Wainwright and Michael Jordan (5) Pattern Recognition and Machine Learning : Bishop
What are the main differences between classical and Gibbs sampling Latent Dirichlet Allocations? LDA is a probabilistic graphical model for a document generating process as explained in Blei et. al in JMLR 2003(For more intuition on generative process see http://videolectures.net/mlss09uk_blei_tm
42,109
Does zero correlation between 2 differenced series implies no cointegration between original series?
The existence or not of a linear relationship does not necessarily go hand-in-hand with co-integration. Variables co-integrated in levels won't necessarily exhibit correlation in first-differences. Assume that the following relation holds: $$y_t = a + b x_t + \varepsilon_t, \; \varepsilon_t=\text {i.i.d} $$ i.e. the variables are co-integrated. Then the relation $$\Delta y_t = b \Delta x_t + \Delta \varepsilon_t$$ also holds. Calculating the sample correlation of first-differences we will estimate the Covariance as $$ \begin{align}\operatorname{\hat Cov}(\Delta y_t,\Delta x_t)=& \frac 1{T-1} \sum_{t=2}^{T}\left(b \Delta x_t + \Delta \varepsilon_t\right)\Delta x_t \\-&\left(\frac 1{T-1} \sum_{t=2}^{T}\left(b \Delta x_t + \Delta \varepsilon_t\right)\right)\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta x_t\right)\end{align} $$ $$ \begin{align}=b\frac 1{T-1}& \sum_{t=2}^{T}\left(\Delta x_t \right)^2 + \frac 1{T-1} \sum_{t=2}^{T}\left(\Delta x_t \Delta \varepsilon_t\right) \\ -& b\left(\frac 1{T-1}\sum_{t=2}^{T} \Delta x_t\right)^2 -\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta \varepsilon_t\right)\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta x_t\right) \end{align}$$ To the degree that $x_t$ and $\varepsilon_t$ are independent, the terms involving the error will tend to vanish and so $$ \operatorname{\hat Cov}(\Delta y_t,\Delta x_t)\rightarrow bs^2_{\Delta x_t} $$ where $s^2$ is the sample variance (irrespective of whether the variance of $x_t$, or $\Delta x_t$ is constant or not). The sample variance of $\Delta y_t$ will be $$s^2_{\Delta s_t} \approx b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}$$ again, irrespective of whether these sample moments estimate anything meaningfull. So $$\operatorname {\hat Corr}(\Delta y_t,\Delta x_t) \approx \frac {bs^2_{\Delta x_t}}{\sqrt {\left(b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}\right)}\sqrt {s^2_{\Delta x_t} }} = \frac {bs_{\Delta x_t}}{\sqrt {\left(b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}\right)}}$$ So the magnitude of the empirically estimated correlation of first differences, will depend on the magnitude of the variance of the error term (which moreover enters the expression doubled since we consider first differences). If this (constant) variance is large compared to the variance of $x_t$, then the estimated correlation of first-differences may be small to non-existent, even though the variables are co-integrated in levels.
Does zero correlation between 2 differenced series implies no cointegration between original series?
The existence or not of a linear relationship does not necessarily go hand-in-hand with co-integration. Variables co-integrated in levels won't necessarily exhibit correlation in first-differences. As
Does zero correlation between 2 differenced series implies no cointegration between original series? The existence or not of a linear relationship does not necessarily go hand-in-hand with co-integration. Variables co-integrated in levels won't necessarily exhibit correlation in first-differences. Assume that the following relation holds: $$y_t = a + b x_t + \varepsilon_t, \; \varepsilon_t=\text {i.i.d} $$ i.e. the variables are co-integrated. Then the relation $$\Delta y_t = b \Delta x_t + \Delta \varepsilon_t$$ also holds. Calculating the sample correlation of first-differences we will estimate the Covariance as $$ \begin{align}\operatorname{\hat Cov}(\Delta y_t,\Delta x_t)=& \frac 1{T-1} \sum_{t=2}^{T}\left(b \Delta x_t + \Delta \varepsilon_t\right)\Delta x_t \\-&\left(\frac 1{T-1} \sum_{t=2}^{T}\left(b \Delta x_t + \Delta \varepsilon_t\right)\right)\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta x_t\right)\end{align} $$ $$ \begin{align}=b\frac 1{T-1}& \sum_{t=2}^{T}\left(\Delta x_t \right)^2 + \frac 1{T-1} \sum_{t=2}^{T}\left(\Delta x_t \Delta \varepsilon_t\right) \\ -& b\left(\frac 1{T-1}\sum_{t=2}^{T} \Delta x_t\right)^2 -\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta \varepsilon_t\right)\left(\frac 1{T-1} \sum_{t=2}^{T}\Delta x_t\right) \end{align}$$ To the degree that $x_t$ and $\varepsilon_t$ are independent, the terms involving the error will tend to vanish and so $$ \operatorname{\hat Cov}(\Delta y_t,\Delta x_t)\rightarrow bs^2_{\Delta x_t} $$ where $s^2$ is the sample variance (irrespective of whether the variance of $x_t$, or $\Delta x_t$ is constant or not). The sample variance of $\Delta y_t$ will be $$s^2_{\Delta s_t} \approx b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}$$ again, irrespective of whether these sample moments estimate anything meaningfull. So $$\operatorname {\hat Corr}(\Delta y_t,\Delta x_t) \approx \frac {bs^2_{\Delta x_t}}{\sqrt {\left(b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}\right)}\sqrt {s^2_{\Delta x_t} }} = \frac {bs_{\Delta x_t}}{\sqrt {\left(b^2s^2_{\Delta x_t} + s^2_{\Delta \varepsilon_t}\right)}}$$ So the magnitude of the empirically estimated correlation of first differences, will depend on the magnitude of the variance of the error term (which moreover enters the expression doubled since we consider first differences). If this (constant) variance is large compared to the variance of $x_t$, then the estimated correlation of first-differences may be small to non-existent, even though the variables are co-integrated in levels.
Does zero correlation between 2 differenced series implies no cointegration between original series? The existence or not of a linear relationship does not necessarily go hand-in-hand with co-integration. Variables co-integrated in levels won't necessarily exhibit correlation in first-differences. As
42,110
Does zero correlation between 2 differenced series implies no cointegration between original series?
Since correlation is a measure of the degree of linear dependence, first differences should tease this out. Now, I am assuming you check cointegration across multiple lags, not just contemporaneous values, since there could be something like $y_t = a + b x_{t-1} + \varepsilon_t$ going on, which may complicate matters. Alecos' observation that there may be not detectible cointegration is also important.
Does zero correlation between 2 differenced series implies no cointegration between original series?
Since correlation is a measure of the degree of linear dependence, first differences should tease this out. Now, I am assuming you check cointegration across multiple lags, not just contemporaneous va
Does zero correlation between 2 differenced series implies no cointegration between original series? Since correlation is a measure of the degree of linear dependence, first differences should tease this out. Now, I am assuming you check cointegration across multiple lags, not just contemporaneous values, since there could be something like $y_t = a + b x_{t-1} + \varepsilon_t$ going on, which may complicate matters. Alecos' observation that there may be not detectible cointegration is also important.
Does zero correlation between 2 differenced series implies no cointegration between original series? Since correlation is a measure of the degree of linear dependence, first differences should tease this out. Now, I am assuming you check cointegration across multiple lags, not just contemporaneous va
42,111
Does zero correlation between 2 differenced series implies no cointegration between original series?
So if my understanding of @Alecos very insightful analysis is correct, he has 2 points: even if returns are linearly related $\Delta y_t = b\cdot\Delta x_t + \Delta\varepsilon_t$ then true correlation between $\Delta y_t$ and $\Delta x_t$ can be anything between 0 and 1 depending on noise/signal ratio $var(\Delta \varepsilon_t)/ var(\Delta x_t)$ because we estimate above true correlation from a finite sample, our estimate can be something different from the true one. Now, for point 1 I can object that if noise/signal ratio is big then both correlation and original cointegration will be "weak" (not sure if there is a measure of cointegration strength - probably ADF-test p-value?). So if we know that true correlation between differenced series is ~0 due to high $var(\Delta \varepsilon)$, we probably still can conclude that cointegration between original series is very weak due to same high $var(\varepsilon)$. Now, the second point probably makes this conclusion less certain - if finite sample estimate of correlation is ~0 this doesn't mean true one is ~0 and thus cointegration may be in place. So the question is how far can sample correlation be from the true one given a sample size :)
Does zero correlation between 2 differenced series implies no cointegration between original series?
So if my understanding of @Alecos very insightful analysis is correct, he has 2 points: even if returns are linearly related $\Delta y_t = b\cdot\Delta x_t + \Delta\varepsilon_t$ then true correlatio
Does zero correlation between 2 differenced series implies no cointegration between original series? So if my understanding of @Alecos very insightful analysis is correct, he has 2 points: even if returns are linearly related $\Delta y_t = b\cdot\Delta x_t + \Delta\varepsilon_t$ then true correlation between $\Delta y_t$ and $\Delta x_t$ can be anything between 0 and 1 depending on noise/signal ratio $var(\Delta \varepsilon_t)/ var(\Delta x_t)$ because we estimate above true correlation from a finite sample, our estimate can be something different from the true one. Now, for point 1 I can object that if noise/signal ratio is big then both correlation and original cointegration will be "weak" (not sure if there is a measure of cointegration strength - probably ADF-test p-value?). So if we know that true correlation between differenced series is ~0 due to high $var(\Delta \varepsilon)$, we probably still can conclude that cointegration between original series is very weak due to same high $var(\varepsilon)$. Now, the second point probably makes this conclusion less certain - if finite sample estimate of correlation is ~0 this doesn't mean true one is ~0 and thus cointegration may be in place. So the question is how far can sample correlation be from the true one given a sample size :)
Does zero correlation between 2 differenced series implies no cointegration between original series? So if my understanding of @Alecos very insightful analysis is correct, he has 2 points: even if returns are linearly related $\Delta y_t = b\cdot\Delta x_t + \Delta\varepsilon_t$ then true correlatio
42,112
Outlier treatment in Vector Autoregression (VAR) Model
Why would you do VAR on product demand and rainfall? VAR assumes that the impact goes both ways, and I find it unusual to assume that demand for the product causes rainfall. It's not entire impossible, of course. After all our farming impacts weather according to global warming alarmists. However, me thinks in your case it's not what you are trying to say. That's why I'd start with ARIMAX models, here's MATLAB example. In R there's astsa package with similar functionality. In ARIMAX X stands for the exogenous time series, in your example it would rainfall. Your dependent variable would be the demand. This is a univariate set up, much simpler and makes more sense, in my opinion. The things you have to be aware of is the causality issues. It's often very difficult to establish causality. What if your product demand is not driven by rainfall, but by something else, which is linked to the annual cyclicality, which in turn is correlated with a rainfall? So, the fact that betas are significant doesn't automatically mean that rainfall causes or impacts the demand. There are statistical methods for testing causality in the sense of Granger, for instance. However, I would rely less on stats and more on your underlying theory or a domain knowledge. Let's say we're talking about umbrellas. Clearly, one would expect demand to depend on rainfall.
Outlier treatment in Vector Autoregression (VAR) Model
Why would you do VAR on product demand and rainfall? VAR assumes that the impact goes both ways, and I find it unusual to assume that demand for the product causes rainfall. It's not entire impossible
Outlier treatment in Vector Autoregression (VAR) Model Why would you do VAR on product demand and rainfall? VAR assumes that the impact goes both ways, and I find it unusual to assume that demand for the product causes rainfall. It's not entire impossible, of course. After all our farming impacts weather according to global warming alarmists. However, me thinks in your case it's not what you are trying to say. That's why I'd start with ARIMAX models, here's MATLAB example. In R there's astsa package with similar functionality. In ARIMAX X stands for the exogenous time series, in your example it would rainfall. Your dependent variable would be the demand. This is a univariate set up, much simpler and makes more sense, in my opinion. The things you have to be aware of is the causality issues. It's often very difficult to establish causality. What if your product demand is not driven by rainfall, but by something else, which is linked to the annual cyclicality, which in turn is correlated with a rainfall? So, the fact that betas are significant doesn't automatically mean that rainfall causes or impacts the demand. There are statistical methods for testing causality in the sense of Granger, for instance. However, I would rely less on stats and more on your underlying theory or a domain knowledge. Let's say we're talking about umbrellas. Clearly, one would expect demand to depend on rainfall.
Outlier treatment in Vector Autoregression (VAR) Model Why would you do VAR on product demand and rainfall? VAR assumes that the impact goes both ways, and I find it unusual to assume that demand for the product causes rainfall. It's not entire impossible
42,113
Outlier treatment in Vector Autoregression (VAR) Model
You could always try an estimator that is robust to outlying values, such as this one: Muler & Yohai (2013): Robust estimation for vector autoregressive models From a cursory Google search, it does seem that you might have to code this up yourself. Regardless, the literature discussion in the first two sections might help you understand the issues involved.
Outlier treatment in Vector Autoregression (VAR) Model
You could always try an estimator that is robust to outlying values, such as this one: Muler & Yohai (2013): Robust estimation for vector autoregressive models From a cursory Google search, it does s
Outlier treatment in Vector Autoregression (VAR) Model You could always try an estimator that is robust to outlying values, such as this one: Muler & Yohai (2013): Robust estimation for vector autoregressive models From a cursory Google search, it does seem that you might have to code this up yourself. Regardless, the literature discussion in the first two sections might help you understand the issues involved.
Outlier treatment in Vector Autoregression (VAR) Model You could always try an estimator that is robust to outlying values, such as this one: Muler & Yohai (2013): Robust estimation for vector autoregressive models From a cursory Google search, it does s
42,114
Outlier treatment in Vector Autoregression (VAR) Model
You can include dummy variables for the outliers, if they are caused by special events in the demand for the product. The dummy take the value of 1 on the outliers, and zero otherwise.
Outlier treatment in Vector Autoregression (VAR) Model
You can include dummy variables for the outliers, if they are caused by special events in the demand for the product. The dummy take the value of 1 on the outliers, and zero otherwise.
Outlier treatment in Vector Autoregression (VAR) Model You can include dummy variables for the outliers, if they are caused by special events in the demand for the product. The dummy take the value of 1 on the outliers, and zero otherwise.
Outlier treatment in Vector Autoregression (VAR) Model You can include dummy variables for the outliers, if they are caused by special events in the demand for the product. The dummy take the value of 1 on the outliers, and zero otherwise.
42,115
Relative variances of higher-order vs. lower-order random terms in mixed models
Blockquote In general, I agree with the original hypotheses that higher-order terms are often associated with smaller variances. But, this also depends on the type of data. In plant breeding, a rule of thumb (Gauch, 1996, page 90) for multi-environment trials is that the variation in the data is: 70% location, 20% location-by-variety, 10% variety Very approximate, but it is fairly consistent that the higher-order term "location-by-variety" variance is larger than the main-effect "variety" variance. Ref: H G Gauch and R W Zobel, 1996. Book: Genotype by Environment Interaction. Chapter: AMMI analysis of yield trials. CRC Press.
Relative variances of higher-order vs. lower-order random terms in mixed models
Blockquote In general, I agree with the original hypotheses that higher-order terms are often associated with smaller variances. But, this also depends on the type of data. In plant breeding, a rule
Relative variances of higher-order vs. lower-order random terms in mixed models Blockquote In general, I agree with the original hypotheses that higher-order terms are often associated with smaller variances. But, this also depends on the type of data. In plant breeding, a rule of thumb (Gauch, 1996, page 90) for multi-environment trials is that the variation in the data is: 70% location, 20% location-by-variety, 10% variety Very approximate, but it is fairly consistent that the higher-order term "location-by-variety" variance is larger than the main-effect "variety" variance. Ref: H G Gauch and R W Zobel, 1996. Book: Genotype by Environment Interaction. Chapter: AMMI analysis of yield trials. CRC Press.
Relative variances of higher-order vs. lower-order random terms in mixed models Blockquote In general, I agree with the original hypotheses that higher-order terms are often associated with smaller variances. But, this also depends on the type of data. In plant breeding, a rule
42,116
Relative variances of higher-order vs. lower-order random terms in mixed models
I have discovered that the regularity I described in my question has in fact been written about by several authors in the literature on Design of Experiments (DoE). It has been called the "hierarchical ordering principle" and also sometimes the "sparsity-of-effects principle." In the chapter on fractional factorial designs in Montgomery (2013, p. 290), he writes: The successful use of fractional factorial designs is based on three key ideas: The sparsity of effects principle. When there are several variables, the system or process is likely to be driven primarily by some of the main effects and low-order interactions. ... Wu & Hamada (2000, p. 143) instead call this the "hierarchical ordering principle", and use the phrase "sparsity of effects" to refer to a related but distinct observation: Three fundamental principles for factorial effects: Hierarchical ordering principle: (i) Lower order effects are more likely to be important than higher order effects, (ii) effects of the same order are likely to be equally important . Effect sparsity principle: The number of relatively important effects in a factorial experiment is small. ... Li, Sudarsanam, & Frey (2006, p. 34) give two possible explanations for why hierarchical ordering should tend to occur. First they suggest that it is "partly due to the range over which experimenters typically explore factors": In the limit that experimenters explore small changes in factors and to the degree that systems exhibit continuity of responses and their derivatives, linear effects of factors tend to dominate. Therefore, to the extent that hierarchical ordering is common in experimentation, it is due to the fact that many experiments are conducted for the purpose of minor refinement rather than broad-scale exploration They next suggest that it is "partly determined by the ability of experimenters to transform the inputs and outputs of the system to obtain a parsimonious description of system behavior": For example, it is well known to aeronautical engineers that the lift and drag of wings is more simply described as a function of wing area and aspect ratio than by wing span and chord. Therefore, when conducting experiments to guide wing design, engineers are likely to use the product of span and chord (wing area) and the ratio of span and chord (the aspect ratio) as the independent variables References Li, X., Sudarsanam, N., & Frey, D. D. (2006). Regularities in data from factorial experiments. Complexity, 11(5), 32-45. Montgomery, D. C. (2013). Design and analysis of experiments (Vol. 8). New York: Wiley. Wu, C. J., & Hamada, M. S. (2000). Experiments: planning, analysis, and optimization (Vol. 552). John Wiley & Sons.
Relative variances of higher-order vs. lower-order random terms in mixed models
I have discovered that the regularity I described in my question has in fact been written about by several authors in the literature on Design of Experiments (DoE). It has been called the "hierarchica
Relative variances of higher-order vs. lower-order random terms in mixed models I have discovered that the regularity I described in my question has in fact been written about by several authors in the literature on Design of Experiments (DoE). It has been called the "hierarchical ordering principle" and also sometimes the "sparsity-of-effects principle." In the chapter on fractional factorial designs in Montgomery (2013, p. 290), he writes: The successful use of fractional factorial designs is based on three key ideas: The sparsity of effects principle. When there are several variables, the system or process is likely to be driven primarily by some of the main effects and low-order interactions. ... Wu & Hamada (2000, p. 143) instead call this the "hierarchical ordering principle", and use the phrase "sparsity of effects" to refer to a related but distinct observation: Three fundamental principles for factorial effects: Hierarchical ordering principle: (i) Lower order effects are more likely to be important than higher order effects, (ii) effects of the same order are likely to be equally important . Effect sparsity principle: The number of relatively important effects in a factorial experiment is small. ... Li, Sudarsanam, & Frey (2006, p. 34) give two possible explanations for why hierarchical ordering should tend to occur. First they suggest that it is "partly due to the range over which experimenters typically explore factors": In the limit that experimenters explore small changes in factors and to the degree that systems exhibit continuity of responses and their derivatives, linear effects of factors tend to dominate. Therefore, to the extent that hierarchical ordering is common in experimentation, it is due to the fact that many experiments are conducted for the purpose of minor refinement rather than broad-scale exploration They next suggest that it is "partly determined by the ability of experimenters to transform the inputs and outputs of the system to obtain a parsimonious description of system behavior": For example, it is well known to aeronautical engineers that the lift and drag of wings is more simply described as a function of wing area and aspect ratio than by wing span and chord. Therefore, when conducting experiments to guide wing design, engineers are likely to use the product of span and chord (wing area) and the ratio of span and chord (the aspect ratio) as the independent variables References Li, X., Sudarsanam, N., & Frey, D. D. (2006). Regularities in data from factorial experiments. Complexity, 11(5), 32-45. Montgomery, D. C. (2013). Design and analysis of experiments (Vol. 8). New York: Wiley. Wu, C. J., & Hamada, M. S. (2000). Experiments: planning, analysis, and optimization (Vol. 552). John Wiley & Sons.
Relative variances of higher-order vs. lower-order random terms in mixed models I have discovered that the regularity I described in my question has in fact been written about by several authors in the literature on Design of Experiments (DoE). It has been called the "hierarchica
42,117
Measures of multidimensional spread or variance
It depends what you want to measure, exactly, but here are two suggestions. Let $\Sigma$ denote the covariance matrix, and note that the trace of $\Sigma$ is equal to the sum of the eigenvalues, while the determinant is equal to their product. This means that $$\text{Tr}(\Sigma)=\sum \lambda_i$$ will give you the "total variance", while $$\sqrt{|\Sigma|}=\prod\sqrt{\lambda_i}$$ will give you the volume of the hyperrectangle whose side lengths are determined by square roots of the eigenvalues (i.e. the standard deviation in each orthogonal direction). So, if you are looking for a measure of the volume covered by the distribution, then you should go with $\sqrt{|\Sigma|}$. Note that this also gives some intuition behind the fact that $\sqrt{|\Sigma|}$ appears in the denominator of the density function for the multivariate normal distribution: $$\frac{1}{\sqrt{(2\pi)^k|\Sigma|}}e^{-\frac{1}{2}(x-\mu)^t\Sigma^{-1}(x-\mu)}$$
Measures of multidimensional spread or variance
It depends what you want to measure, exactly, but here are two suggestions. Let $\Sigma$ denote the covariance matrix, and note that the trace of $\Sigma$ is equal to the sum of the eigenvalues, while
Measures of multidimensional spread or variance It depends what you want to measure, exactly, but here are two suggestions. Let $\Sigma$ denote the covariance matrix, and note that the trace of $\Sigma$ is equal to the sum of the eigenvalues, while the determinant is equal to their product. This means that $$\text{Tr}(\Sigma)=\sum \lambda_i$$ will give you the "total variance", while $$\sqrt{|\Sigma|}=\prod\sqrt{\lambda_i}$$ will give you the volume of the hyperrectangle whose side lengths are determined by square roots of the eigenvalues (i.e. the standard deviation in each orthogonal direction). So, if you are looking for a measure of the volume covered by the distribution, then you should go with $\sqrt{|\Sigma|}$. Note that this also gives some intuition behind the fact that $\sqrt{|\Sigma|}$ appears in the denominator of the density function for the multivariate normal distribution: $$\frac{1}{\sqrt{(2\pi)^k|\Sigma|}}e^{-\frac{1}{2}(x-\mu)^t\Sigma^{-1}(x-\mu)}$$
Measures of multidimensional spread or variance It depends what you want to measure, exactly, but here are two suggestions. Let $\Sigma$ denote the covariance matrix, and note that the trace of $\Sigma$ is equal to the sum of the eigenvalues, while
42,118
Can you use the paired t-test in what seems like an unpaired t-test situation?
The use of matching on other characteristics than that being tested, followed by a paired t-test is fine; there's a point to that (to control for the effect of other variables thought to be relevant to the outcome). The matching makes it paired, because - if the characteristics on which the matching was carried out* affect the outcome - the pair-members will tend to be more alike than two random observations. * or other characteristics which are related to them. See, for example, the discussion in the third paragraph ('A paired samples t-test based on a "matched-pairs sample"...') here. Henry's point that the pairs should be selected before deciding on which is to be the pilot (randomly) is a good one, though that problem won't necessarily invalidate the test - depending, for example, on how those pilots were chosen. However, unless Dimitriy's supposition was correct - that two lots of tests were done, one on the matching variables, and then a different test later for the effect of interest - then the way the matching was done, using the p-value of the test of interest as the matching criterion, renders the resulting p-value meaningless. It's certainly no longer uniformly distributed under the null. In that case, the hypothesis test is effectively useless as it stands.
Can you use the paired t-test in what seems like an unpaired t-test situation?
The use of matching on other characteristics than that being tested, followed by a paired t-test is fine; there's a point to that (to control for the effect of other variables thought to be relevant t
Can you use the paired t-test in what seems like an unpaired t-test situation? The use of matching on other characteristics than that being tested, followed by a paired t-test is fine; there's a point to that (to control for the effect of other variables thought to be relevant to the outcome). The matching makes it paired, because - if the characteristics on which the matching was carried out* affect the outcome - the pair-members will tend to be more alike than two random observations. * or other characteristics which are related to them. See, for example, the discussion in the third paragraph ('A paired samples t-test based on a "matched-pairs sample"...') here. Henry's point that the pairs should be selected before deciding on which is to be the pilot (randomly) is a good one, though that problem won't necessarily invalidate the test - depending, for example, on how those pilots were chosen. However, unless Dimitriy's supposition was correct - that two lots of tests were done, one on the matching variables, and then a different test later for the effect of interest - then the way the matching was done, using the p-value of the test of interest as the matching criterion, renders the resulting p-value meaningless. It's certainly no longer uniformly distributed under the null. In that case, the hypothesis test is effectively useless as it stands.
Can you use the paired t-test in what seems like an unpaired t-test situation? The use of matching on other characteristics than that being tested, followed by a paired t-test is fine; there's a point to that (to control for the effect of other variables thought to be relevant t
42,119
Testing for differences between a sample and a subsample
Your last thought is the right one. Test between two sub-samples, not between a sample and a sub-sample. In this, a t-test might be appropriate, if it's other assumptions are met. The only way I can think of to test between a sample and a subsample would be simulation, but that would wind up equivalent to testing between two sub-samples.
Testing for differences between a sample and a subsample
Your last thought is the right one. Test between two sub-samples, not between a sample and a sub-sample. In this, a t-test might be appropriate, if it's other assumptions are met. The only way I can
Testing for differences between a sample and a subsample Your last thought is the right one. Test between two sub-samples, not between a sample and a sub-sample. In this, a t-test might be appropriate, if it's other assumptions are met. The only way I can think of to test between a sample and a subsample would be simulation, but that would wind up equivalent to testing between two sub-samples.
Testing for differences between a sample and a subsample Your last thought is the right one. Test between two sub-samples, not between a sample and a sub-sample. In this, a t-test might be appropriate, if it's other assumptions are met. The only way I can
42,120
When does a distribution not have a mean or a variance?
The canonical example of a distribution with no mean (and hence no variance) is the Cauchy distribution. True, you could compute the sample mean for a sample of data from a Cauchy distribution, but you would have to interpret such a sample mean carefully; increasing the sample size would not correspond to getting a better estimate of the TRUE mean, because there is no true (i.e., large sample) mean.
When does a distribution not have a mean or a variance?
The canonical example of a distribution with no mean (and hence no variance) is the Cauchy distribution. True, you could compute the sample mean for a sample of data from a Cauchy distribution, but yo
When does a distribution not have a mean or a variance? The canonical example of a distribution with no mean (and hence no variance) is the Cauchy distribution. True, you could compute the sample mean for a sample of data from a Cauchy distribution, but you would have to interpret such a sample mean carefully; increasing the sample size would not correspond to getting a better estimate of the TRUE mean, because there is no true (i.e., large sample) mean.
When does a distribution not have a mean or a variance? The canonical example of a distribution with no mean (and hence no variance) is the Cauchy distribution. True, you could compute the sample mean for a sample of data from a Cauchy distribution, but yo
42,121
auto.arima and prediction
The reason is that ARIMA is auto-projective which uses the most recent data to compute essentially a weighted average of past values. When forecasting, the 1 step ahead is used to predict the second step etc. .This then leads to long term forecasts that approach an asymptote. When fitting , the actual history is used to predict the next point. What you should do is to build an integrated model that includes deterministic structure like day-of-the-week, changes in the day-of-the-week coefficients, monthly/weekly effects taking into account any events like holidays and include any needed level shifts or local time trends that can be detected and seamlessly incorporated. Additionally particular days of the month and particular weeks of the month may come into play. This is done by hour and by daily sums. Furthermore use the daily sums history and its forecasts as a possible predictor variable for each of the 24 hourly models. Make sure that you verify that the parameters of each of your 25 models are invariant over time and that the error variance for each of your 25 models doesn't change over time. Finally you may need to incorporate a parent-to-child or child-to-parent strategy to reconcile any differences. We have been very successful using these procedures and you should also be succesful.
auto.arima and prediction
The reason is that ARIMA is auto-projective which uses the most recent data to compute essentially a weighted average of past values. When forecasting, the 1 step ahead is used to predict the second s
auto.arima and prediction The reason is that ARIMA is auto-projective which uses the most recent data to compute essentially a weighted average of past values. When forecasting, the 1 step ahead is used to predict the second step etc. .This then leads to long term forecasts that approach an asymptote. When fitting , the actual history is used to predict the next point. What you should do is to build an integrated model that includes deterministic structure like day-of-the-week, changes in the day-of-the-week coefficients, monthly/weekly effects taking into account any events like holidays and include any needed level shifts or local time trends that can be detected and seamlessly incorporated. Additionally particular days of the month and particular weeks of the month may come into play. This is done by hour and by daily sums. Furthermore use the daily sums history and its forecasts as a possible predictor variable for each of the 24 hourly models. Make sure that you verify that the parameters of each of your 25 models are invariant over time and that the error variance for each of your 25 models doesn't change over time. Finally you may need to incorporate a parent-to-child or child-to-parent strategy to reconcile any differences. We have been very successful using these procedures and you should also be succesful.
auto.arima and prediction The reason is that ARIMA is auto-projective which uses the most recent data to compute essentially a weighted average of past values. When forecasting, the 1 step ahead is used to predict the second s
42,122
Equivalence between Elastic Net formulations
Starting from $$\hat{\beta} = \arg \min_\beta \|X\beta - y\|_2^2 \text{ s.t. } (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 \leq t,$$ we can write the dual Lagragian formulation of this optimization problem as $$ \begin{array}{rcl} L(\beta,\alpha,\lambda) & = & \|X\beta - y\|_2^2 + \lambda \left( (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 - t\right) \\ & = & \|X\beta - y\|_2^2 + \lambda (1-\alpha)\|\beta\|_1 + \lambda\alpha\|\beta\|_2^2 - \lambda t, \end{array} $$ and we see that this indeed looks like the first problem that you wrote, with parameters $\lambda_1=\lambda (1-\alpha)$ and $\lambda_2=\lambda \alpha$, which leads to the expression of the "elastic" parameter: $$\alpha = \frac{\lambda_2}{\lambda_1+\lambda_2}.$$ That being said, to go from this point to Zou and Hastie's assertion that both problems are equivalent, I admit that I miss a step or two...
Equivalence between Elastic Net formulations
Starting from $$\hat{\beta} = \arg \min_\beta \|X\beta - y\|_2^2 \text{ s.t. } (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 \leq t,$$ we can write the dual Lagragian formulation of this optimization pr
Equivalence between Elastic Net formulations Starting from $$\hat{\beta} = \arg \min_\beta \|X\beta - y\|_2^2 \text{ s.t. } (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 \leq t,$$ we can write the dual Lagragian formulation of this optimization problem as $$ \begin{array}{rcl} L(\beta,\alpha,\lambda) & = & \|X\beta - y\|_2^2 + \lambda \left( (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 - t\right) \\ & = & \|X\beta - y\|_2^2 + \lambda (1-\alpha)\|\beta\|_1 + \lambda\alpha\|\beta\|_2^2 - \lambda t, \end{array} $$ and we see that this indeed looks like the first problem that you wrote, with parameters $\lambda_1=\lambda (1-\alpha)$ and $\lambda_2=\lambda \alpha$, which leads to the expression of the "elastic" parameter: $$\alpha = \frac{\lambda_2}{\lambda_1+\lambda_2}.$$ That being said, to go from this point to Zou and Hastie's assertion that both problems are equivalent, I admit that I miss a step or two...
Equivalence between Elastic Net formulations Starting from $$\hat{\beta} = \arg \min_\beta \|X\beta - y\|_2^2 \text{ s.t. } (1-\alpha)\|\beta\|_1 + \alpha\|\beta\|_2^2 \leq t,$$ we can write the dual Lagragian formulation of this optimization pr
42,123
Two slopes between 0 and 1, neither different from 0, could they be different from each other?
It depends on how you do the testing. For instance, consider this model for the three variables $x$, $y_0$, and $y_1$: $$\cases{ \mathbb{E}[y_0] = \beta_{0} + \beta_{1}x \\ y_1 = y_0 + \gamma x }$$ where $\beta_0$, $\beta_1$, and $\gamma$ are parameters and $\gamma$ is the difference in slopes. Evidently $$ \mathbb{E}[y_1] = \mathbb{E}[y_0 + \gamma x] = (\beta_{0} + \beta_{1}x) + \gamma x = \beta_0 + \beta_2 x$$ with $\beta_2 = \beta_1 + \gamma$. Then it is possible for estimates $\widehat{\beta}_1$ and $\widehat{\beta}_2$ to be indistinguishable from zero while determining, via regressing $y_1-y_0 = \gamma x$ against $x$, that $\widehat{\gamma}$ differs significantly from zero. The key idea is that $y_1$ and $y_0$ are not independent. As an example here are simulated data in R: n <- 10 x <- 1:n delta <- x / n^2 y.0 <- residuals(lm(rnorm(n) ~ x)) + delta/2 y.1 <- y.0 + delta pairs(cbind(x, delta, y.0, y.1)) Neither of the regressions $y_i \sim x$ is significant ($\widehat{\beta}_0 = 1/200,$ $p=0.937$ and $\widehat{\beta}_1 = 3/200$, $p=0.812$): > summary(lm(y.0 ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 0.00000 0.37903 0.000 1.000 x 0.00500 0.06109 0.082 0.937 > summary(lm(y.1 ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 5.266e-17 3.790e-01 0.000 1.000 x 1.500e-02 6.109e-02 0.246 0.812 The regression of $y_1 - y_0 \sim x$ is extremely significant ($\widehat{\gamma} = 1/100,$ $p \lt 2\times 10^{-16}$): > summary(lm((y.1 - y.0) ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 2.633e-17 1.415e-17 1.860e+00 0.0999 . x 1.000e-02 2.281e-18 4.384e+15 <2e-16 ****
Two slopes between 0 and 1, neither different from 0, could they be different from each other?
It depends on how you do the testing. For instance, consider this model for the three variables $x$, $y_0$, and $y_1$: $$\cases{ \mathbb{E}[y_0] = \beta_{0} + \beta_{1}x \\ y_1 = y_0 + \gamma x }
Two slopes between 0 and 1, neither different from 0, could they be different from each other? It depends on how you do the testing. For instance, consider this model for the three variables $x$, $y_0$, and $y_1$: $$\cases{ \mathbb{E}[y_0] = \beta_{0} + \beta_{1}x \\ y_1 = y_0 + \gamma x }$$ where $\beta_0$, $\beta_1$, and $\gamma$ are parameters and $\gamma$ is the difference in slopes. Evidently $$ \mathbb{E}[y_1] = \mathbb{E}[y_0 + \gamma x] = (\beta_{0} + \beta_{1}x) + \gamma x = \beta_0 + \beta_2 x$$ with $\beta_2 = \beta_1 + \gamma$. Then it is possible for estimates $\widehat{\beta}_1$ and $\widehat{\beta}_2$ to be indistinguishable from zero while determining, via regressing $y_1-y_0 = \gamma x$ against $x$, that $\widehat{\gamma}$ differs significantly from zero. The key idea is that $y_1$ and $y_0$ are not independent. As an example here are simulated data in R: n <- 10 x <- 1:n delta <- x / n^2 y.0 <- residuals(lm(rnorm(n) ~ x)) + delta/2 y.1 <- y.0 + delta pairs(cbind(x, delta, y.0, y.1)) Neither of the regressions $y_i \sim x$ is significant ($\widehat{\beta}_0 = 1/200,$ $p=0.937$ and $\widehat{\beta}_1 = 3/200$, $p=0.812$): > summary(lm(y.0 ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 0.00000 0.37903 0.000 1.000 x 0.00500 0.06109 0.082 0.937 > summary(lm(y.1 ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 5.266e-17 3.790e-01 0.000 1.000 x 1.500e-02 6.109e-02 0.246 0.812 The regression of $y_1 - y_0 \sim x$ is extremely significant ($\widehat{\gamma} = 1/100,$ $p \lt 2\times 10^{-16}$): > summary(lm((y.1 - y.0) ~ x)) Estimate Std. Error t value Pr(>|t|) (Intercept) 2.633e-17 1.415e-17 1.860e+00 0.0999 . x 1.000e-02 2.281e-18 4.384e+15 <2e-16 ****
Two slopes between 0 and 1, neither different from 0, could they be different from each other? It depends on how you do the testing. For instance, consider this model for the three variables $x$, $y_0$, and $y_1$: $$\cases{ \mathbb{E}[y_0] = \beta_{0} + \beta_{1}x \\ y_1 = y_0 + \gamma x }
42,124
What is the sampling distribution of a sum of scores?
You suggest you're happy with assuming approximate normality. Then it's straightforward - a linear combination of multivariate normal variables is itself normal. The mean and variance follow from elementary properties of mean and variance. If $X\sim N(\mathbf{\mu},\Sigma)$ then $a'X \sim N(a'\mathbf{\mu},a'\Sigma a)$. In the case of a sum, $a = \bf 1$. That is, the sum is normal, where the mean of the sum is the sum of the means and the variance of the sum is the sum of all variances + twice the sum of all pairwise covariances. Additionally, if the series are no too dependent and are iid, or independent and none of them have too large a variance relative to all the others, the CLT definitely applies, so if there are enough terms, you should have that $\sqrt n \bar x$ is normal. Note that $\sqrt n \bar x = \frac{X_1+\dots+X_n}{\sqrt n} $. From there, if you think the $n$ is big enough to use the normal approximation at some point, you can back out one for the sum as well (the CLT - being about limits - doesn't apply to an unscaled sum, but the quality of the approximation of the cdf at some specific $n$ carries over to the sum). However the sample sizes required for these to kick in may be quite large. Beyond that, convergence to normality of appropriately scaled sums can occur in a wide variety of situations. Again, sample sizes may need to be large.
What is the sampling distribution of a sum of scores?
You suggest you're happy with assuming approximate normality. Then it's straightforward - a linear combination of multivariate normal variables is itself normal. The mean and variance follow from elem
What is the sampling distribution of a sum of scores? You suggest you're happy with assuming approximate normality. Then it's straightforward - a linear combination of multivariate normal variables is itself normal. The mean and variance follow from elementary properties of mean and variance. If $X\sim N(\mathbf{\mu},\Sigma)$ then $a'X \sim N(a'\mathbf{\mu},a'\Sigma a)$. In the case of a sum, $a = \bf 1$. That is, the sum is normal, where the mean of the sum is the sum of the means and the variance of the sum is the sum of all variances + twice the sum of all pairwise covariances. Additionally, if the series are no too dependent and are iid, or independent and none of them have too large a variance relative to all the others, the CLT definitely applies, so if there are enough terms, you should have that $\sqrt n \bar x$ is normal. Note that $\sqrt n \bar x = \frac{X_1+\dots+X_n}{\sqrt n} $. From there, if you think the $n$ is big enough to use the normal approximation at some point, you can back out one for the sum as well (the CLT - being about limits - doesn't apply to an unscaled sum, but the quality of the approximation of the cdf at some specific $n$ carries over to the sum). However the sample sizes required for these to kick in may be quite large. Beyond that, convergence to normality of appropriately scaled sums can occur in a wide variety of situations. Again, sample sizes may need to be large.
What is the sampling distribution of a sum of scores? You suggest you're happy with assuming approximate normality. Then it's straightforward - a linear combination of multivariate normal variables is itself normal. The mean and variance follow from elem
42,125
Fisher-type unit-root test for panel data. Results interpretation in Stata
The null hypothesis of this test is that all panels contain a unit root. Given your results we reject this hypothesis. If you look at your tests P, Z, L* and Pm, you get a value for these test statistics (77.8047, -7.2246, and so on) and in the next column you see the p-value. Since they are all smaller than 0.01, you can reject the null hypothesis at the 1% level of statistical significance. This means there are no unit roots in your panels under the given test conditions (included panel mean and time trend). This should also answer your second question because the p-value tells you at which level of statistical significance you can reject the null. If you would like some more details on p-values have a look at these notes (lecture1, lecture2).
Fisher-type unit-root test for panel data. Results interpretation in Stata
The null hypothesis of this test is that all panels contain a unit root. Given your results we reject this hypothesis. If you look at your tests P, Z, L* and Pm, you get a value for these test statist
Fisher-type unit-root test for panel data. Results interpretation in Stata The null hypothesis of this test is that all panels contain a unit root. Given your results we reject this hypothesis. If you look at your tests P, Z, L* and Pm, you get a value for these test statistics (77.8047, -7.2246, and so on) and in the next column you see the p-value. Since they are all smaller than 0.01, you can reject the null hypothesis at the 1% level of statistical significance. This means there are no unit roots in your panels under the given test conditions (included panel mean and time trend). This should also answer your second question because the p-value tells you at which level of statistical significance you can reject the null. If you would like some more details on p-values have a look at these notes (lecture1, lecture2).
Fisher-type unit-root test for panel data. Results interpretation in Stata The null hypothesis of this test is that all panels contain a unit root. Given your results we reject this hypothesis. If you look at your tests P, Z, L* and Pm, you get a value for these test statist
42,126
Generalizing results - what is the population?
I asked myself the very same question some time ago. In particular I was reading a paper of fellow researchers. They did a study with students and in their paper they said the population was people aged 0-99. So... Thinking about the problem, the population to which you can generalize depends largely on the experiment. You can find examples for both very special and very general questions yourself. The two ways of supporting generalization I can think of are as follows: Extent the experiment to cover the target population: Sound, empirical, expensive, and sometimes impossible. Argue. Argue means that you come up with a model (A) about which factors have the most influence on your hypothesis. Then you extend the population to those subjects that don't vary that much (B) from your sample in terms of these factors. E.g. if you think that age is an important factor in your question (and other factors don't matter that much), and you have an experiment with students of age 20-29, then you can very well generalize to a general population of people aged 20-29. But generalizing to all age groups is not well supported. You see, that this method contains two largely hypothetical components A and B that are usually not supported empirically or theoretically themselves. Also (not having read much, not to say almost none) publications with statistical content myself, I don't think authors explicitly argue along this way: providing A and B explicitly. But That's the way it goes. Apparently there is no other good way. So in the end, I think the best you can do is this: Descriptively state how your sample was obtained. This includes at least a description of your sample (e.g. students aged 21-37) along with all peculiarities that might matter (e.g. all were studying chemistry) and a description of your inclusion/exclusion guidelines (e.g. people aged 15-99). Optionally state to which population your data might generalize (e.g. people aged 15-99). Argue why you think this is the case. Disclaimer I have never done an experiment myself, nor did I learn how to do it, nor did I read many empirical works.
Generalizing results - what is the population?
I asked myself the very same question some time ago. In particular I was reading a paper of fellow researchers. They did a study with students and in their paper they said the population was people ag
Generalizing results - what is the population? I asked myself the very same question some time ago. In particular I was reading a paper of fellow researchers. They did a study with students and in their paper they said the population was people aged 0-99. So... Thinking about the problem, the population to which you can generalize depends largely on the experiment. You can find examples for both very special and very general questions yourself. The two ways of supporting generalization I can think of are as follows: Extent the experiment to cover the target population: Sound, empirical, expensive, and sometimes impossible. Argue. Argue means that you come up with a model (A) about which factors have the most influence on your hypothesis. Then you extend the population to those subjects that don't vary that much (B) from your sample in terms of these factors. E.g. if you think that age is an important factor in your question (and other factors don't matter that much), and you have an experiment with students of age 20-29, then you can very well generalize to a general population of people aged 20-29. But generalizing to all age groups is not well supported. You see, that this method contains two largely hypothetical components A and B that are usually not supported empirically or theoretically themselves. Also (not having read much, not to say almost none) publications with statistical content myself, I don't think authors explicitly argue along this way: providing A and B explicitly. But That's the way it goes. Apparently there is no other good way. So in the end, I think the best you can do is this: Descriptively state how your sample was obtained. This includes at least a description of your sample (e.g. students aged 21-37) along with all peculiarities that might matter (e.g. all were studying chemistry) and a description of your inclusion/exclusion guidelines (e.g. people aged 15-99). Optionally state to which population your data might generalize (e.g. people aged 15-99). Argue why you think this is the case. Disclaimer I have never done an experiment myself, nor did I learn how to do it, nor did I read many empirical works.
Generalizing results - what is the population? I asked myself the very same question some time ago. In particular I was reading a paper of fellow researchers. They did a study with students and in their paper they said the population was people ag
42,127
Get a desired percentage of censored observations in a simulation of Cox PH Model
I am not sure if this answers your question but please find below some R code which follows Bender et al. (2005). They describe an approach to simulate a Cox PH regression model with given properties like the proportion of censored events (see line "dat <- data.frame(T = T, X, event = rbinom(n, 1, 0.30))", i.e. 70% of all events are censored). Reference Bender, Ralf, Thomas Augustin, und Maria Blettner. 2005. Generating survival times to simulate Cox proportional hazards models. Statistics in Medicine 24: 1713–1723. ##' Generate survival data with $p$ (correlated) predictors ##' ##' ##' ##' @title Generate survival data ##' @param n Sample size ##' @param beta Vector of coefficients ##' @param r Correlation between predictors ##' @param id.iter ##' @param id.study ##' @return matrix with identification variables id.iter and id.study, ##' T (survival time), event (0: censored), ##' predictors X1 to X$p$ ##' @author Bernd Weiss ##' @references Bender et al. (2005) genSurvData <- function(n = 100000, beta = c(0.8, 2.2, -0.5, 1.1, -1.4), r = 0.1, id.iter = NA, id.study = NA){ ## Scale parameter (the smaller lambda, the greater becomes T) lambda <- 0.000001#1.7 ## Shape parameter nue <- 8.9#9.4 ## Sample size n <- n ## Number of predictors p <- length(beta) ## Generate column vector of coefficients beta <- matrix(beta, ncol = 1) ## Generate correlated covariate vectors using a multivariate normal ## distribution with X ~ N(mu, S) and a given correlation matrix R, with: ## R: A p x p correlation matrix ## mu: Vector of means ## SD: Vector of standard deviations ## S: Variance-covariance matrix R <- matrix(c(rep(r, p^2)), ncol = p) diag(R) <- 1 R mu <- rep(0, p) SD <- rep(1, p) S <- R * (SD %*% t(SD)) X <- mvrnorm(n, mu, S) cov(X) cor(X) sqrt(diag(cov(X))) ## Calculate survival times T <- (-log(runif(n)) / (lambda * exp(X %*% beta)))^(1/nue) ## 30% (0.30) of all marriages are getting divorced, i.e. 70% of all ## observations are censored ("event = rbinom(n, 1, 0.30)") dat <- data.frame(T = T, X, event = rbinom(n, 1, 0.30)) ## Also, all T's > 30 yrs are by definition censored and T is set to 30 yrs dat$event <- ifelse(dat$T >= 30, 0, dat$event) dat$T <- ifelse(dat$T >= 30, 30, dat$T) dat$id.iter <- id.iter dat$id.study <- id.study ## Reorder data frame: T, event, covariates tmp.names <- names(dat) dat <- dat[, c("id.iter", "id.study", "T", "event", tmp.names[grep("X", tmp.names)])] ## Returning a matrix speeds-up things a lot... lesson learned. dat <- as.matrix(dat) return(dat) } library(survival) library(MASS) dat <- genSurvData(n = 1000) dat <- as.data.frame(dat) survfit(Surv(time = T, event = event) ~ 1, data = dat) coxph(Surv(time = T, event = event) ~ X1 + X2 + X3 +X4 +X5, data = dat)
Get a desired percentage of censored observations in a simulation of Cox PH Model
I am not sure if this answers your question but please find below some R code which follows Bender et al. (2005). They describe an approach to simulate a Cox PH regression model with given properties
Get a desired percentage of censored observations in a simulation of Cox PH Model I am not sure if this answers your question but please find below some R code which follows Bender et al. (2005). They describe an approach to simulate a Cox PH regression model with given properties like the proportion of censored events (see line "dat <- data.frame(T = T, X, event = rbinom(n, 1, 0.30))", i.e. 70% of all events are censored). Reference Bender, Ralf, Thomas Augustin, und Maria Blettner. 2005. Generating survival times to simulate Cox proportional hazards models. Statistics in Medicine 24: 1713–1723. ##' Generate survival data with $p$ (correlated) predictors ##' ##' ##' ##' @title Generate survival data ##' @param n Sample size ##' @param beta Vector of coefficients ##' @param r Correlation between predictors ##' @param id.iter ##' @param id.study ##' @return matrix with identification variables id.iter and id.study, ##' T (survival time), event (0: censored), ##' predictors X1 to X$p$ ##' @author Bernd Weiss ##' @references Bender et al. (2005) genSurvData <- function(n = 100000, beta = c(0.8, 2.2, -0.5, 1.1, -1.4), r = 0.1, id.iter = NA, id.study = NA){ ## Scale parameter (the smaller lambda, the greater becomes T) lambda <- 0.000001#1.7 ## Shape parameter nue <- 8.9#9.4 ## Sample size n <- n ## Number of predictors p <- length(beta) ## Generate column vector of coefficients beta <- matrix(beta, ncol = 1) ## Generate correlated covariate vectors using a multivariate normal ## distribution with X ~ N(mu, S) and a given correlation matrix R, with: ## R: A p x p correlation matrix ## mu: Vector of means ## SD: Vector of standard deviations ## S: Variance-covariance matrix R <- matrix(c(rep(r, p^2)), ncol = p) diag(R) <- 1 R mu <- rep(0, p) SD <- rep(1, p) S <- R * (SD %*% t(SD)) X <- mvrnorm(n, mu, S) cov(X) cor(X) sqrt(diag(cov(X))) ## Calculate survival times T <- (-log(runif(n)) / (lambda * exp(X %*% beta)))^(1/nue) ## 30% (0.30) of all marriages are getting divorced, i.e. 70% of all ## observations are censored ("event = rbinom(n, 1, 0.30)") dat <- data.frame(T = T, X, event = rbinom(n, 1, 0.30)) ## Also, all T's > 30 yrs are by definition censored and T is set to 30 yrs dat$event <- ifelse(dat$T >= 30, 0, dat$event) dat$T <- ifelse(dat$T >= 30, 30, dat$T) dat$id.iter <- id.iter dat$id.study <- id.study ## Reorder data frame: T, event, covariates tmp.names <- names(dat) dat <- dat[, c("id.iter", "id.study", "T", "event", tmp.names[grep("X", tmp.names)])] ## Returning a matrix speeds-up things a lot... lesson learned. dat <- as.matrix(dat) return(dat) } library(survival) library(MASS) dat <- genSurvData(n = 1000) dat <- as.data.frame(dat) survfit(Surv(time = T, event = event) ~ 1, data = dat) coxph(Surv(time = T, event = event) ~ X1 + X2 + X3 +X4 +X5, data = dat)
Get a desired percentage of censored observations in a simulation of Cox PH Model I am not sure if this answers your question but please find below some R code which follows Bender et al. (2005). They describe an approach to simulate a Cox PH regression model with given properties
42,128
Two-sample location test when data is heavily skewed towards zero?
You might try a Heckman two-step model. If you don't have an exclusion restriction--a variable that changes whether a customer buys or not, but does not affect how much he spends directly--the identification will be fragile and you can get wacky results. But in some marketing examples, a two-step approach can make sense, though it's hard to tell without knowing what your two groups are. Take a look at the examples, formulas and references sections of the Stata manuals. You don't have to use Stata to estimate, but these manuals are pretty nice for explaining the idea. If your expenditure data has a long right tail, you can estimate this model in logs using $\ln(min\{y\}) -\varepsilon$ in place of $\ln(0)$. Play around with what $\varepsilon$ is to make sure your results are not very sensitive. Another approach would be to use the two-part model (tpm) command in Stata, which avoids the twin difficulties of exclusion restrictions and logarithmic transformations. It's the continuous outcome counterpart of the hurdle models for count data (like number of purchases rather than revenue). I am not aware of a non-Stata implementation.
Two-sample location test when data is heavily skewed towards zero?
You might try a Heckman two-step model. If you don't have an exclusion restriction--a variable that changes whether a customer buys or not, but does not affect how much he spends directly--the identif
Two-sample location test when data is heavily skewed towards zero? You might try a Heckman two-step model. If you don't have an exclusion restriction--a variable that changes whether a customer buys or not, but does not affect how much he spends directly--the identification will be fragile and you can get wacky results. But in some marketing examples, a two-step approach can make sense, though it's hard to tell without knowing what your two groups are. Take a look at the examples, formulas and references sections of the Stata manuals. You don't have to use Stata to estimate, but these manuals are pretty nice for explaining the idea. If your expenditure data has a long right tail, you can estimate this model in logs using $\ln(min\{y\}) -\varepsilon$ in place of $\ln(0)$. Play around with what $\varepsilon$ is to make sure your results are not very sensitive. Another approach would be to use the two-part model (tpm) command in Stata, which avoids the twin difficulties of exclusion restrictions and logarithmic transformations. It's the continuous outcome counterpart of the hurdle models for count data (like number of purchases rather than revenue). I am not aware of a non-Stata implementation.
Two-sample location test when data is heavily skewed towards zero? You might try a Heckman two-step model. If you don't have an exclusion restriction--a variable that changes whether a customer buys or not, but does not affect how much he spends directly--the identif
42,129
Two-sample location test when data is heavily skewed towards zero?
The Wilcoxon-Mann-Whitney 2-sample test may still work for this problem if you handle the excessive ties correctly when computing the $P$-value. Or use the fact that the Wilcoxon test is a special case of the proportional odds ordinal logistic model, and that model's likelihood ratio $\chi^2$ test accounts for excessive ties automatically. For a total sample size of 2,000,000, if the number of unique non-zero values exceeds around 100 the model will take a lot of computer time to run, so you might consider rounding the non-zero values a bit to have fewer intercepts in the model. The R rms package's orm function will efficiently handle thousands of unique $Y$ values if the sample size were not so large. For your case it will probably work OK with a hundred or so unique $Y$ values.
Two-sample location test when data is heavily skewed towards zero?
The Wilcoxon-Mann-Whitney 2-sample test may still work for this problem if you handle the excessive ties correctly when computing the $P$-value. Or use the fact that the Wilcoxon test is a special ca
Two-sample location test when data is heavily skewed towards zero? The Wilcoxon-Mann-Whitney 2-sample test may still work for this problem if you handle the excessive ties correctly when computing the $P$-value. Or use the fact that the Wilcoxon test is a special case of the proportional odds ordinal logistic model, and that model's likelihood ratio $\chi^2$ test accounts for excessive ties automatically. For a total sample size of 2,000,000, if the number of unique non-zero values exceeds around 100 the model will take a lot of computer time to run, so you might consider rounding the non-zero values a bit to have fewer intercepts in the model. The R rms package's orm function will efficiently handle thousands of unique $Y$ values if the sample size were not so large. For your case it will probably work OK with a hundred or so unique $Y$ values.
Two-sample location test when data is heavily skewed towards zero? The Wilcoxon-Mann-Whitney 2-sample test may still work for this problem if you handle the excessive ties correctly when computing the $P$-value. Or use the fact that the Wilcoxon test is a special ca
42,130
Is bootstrapping appropriate for estimating a multivariate normal covariance matrix using a small sample size?
Is the Bootstrap a good option to estimate $\Sigma$? No, the boostrap will help you infer about the uncertainty of your sample estimate. Specifically, it might be used to get confidence intervals on the elements of $\widehat{\Sigma}$. And how does the bootstrap work? The approach is to create $R$ replicate datasets from the original dataset by resampling the observations with replacement. Then you compute the estimate of interest on each of the $R$ replicates, in your case the covariance matrix, for each of the $R$ replicates, obtaining $\widehat{\Sigma}^1, \ldots, \widehat{\Sigma}^R$. Confidence intervals for $\widehat{\Sigma}$ can then be computed empiricaly from $\widehat{\Sigma}^1, \ldots, \widehat{\Sigma}^R$. For further information, you might want to have a look at the Wikipedia page. Edit Could I use $\widetilde{\Sigma}_R = R^{-1} \sum_{r=1}^R \widehat{\Sigma}^r$ instead of $\widehat{\Sigma}$? Actually, the matrix $\widetilde{\Sigma}_R$ is an estimate of ${\rm E} (\widehat{\Sigma}^r)$, where $\widehat{\Sigma}^r$ is the estimate of the covariance matrix based on a bootstrap replication of the initial sample. Bootstrapping comes down to sample from the empirical distribution $\widehat{F}$. Therefore, I think, but I don't have a formal proof, that $\widetilde{\Sigma}_R = {\rm E} (\widehat{\Sigma}^r) \to \widehat{\Sigma}$ as $R \to \infty$. So, I think you could use $\widetilde{\Sigma}_R$ instead of $\widehat{\Sigma}$, but that would be like using a sledgehammer to crack a nut. The R code below is a numerical investigation, which is by no means of proof of the above assertion about the convergence. The structure of dependence is a Gumbel copula, and the margins are two standard normal distribution. ## Initialization library(copula) set.seed(531) n <- 200 # Number of observations in the original sample R <- 10000 # Number of replications ## Specification for the dependence structure (Gumbel copula) spec.cl <- archmCopula("gumbel", 1.2) ## Create a fake original dataset pseudo <- rCopula(n, spec.cl) obs <- qnorm(pseudo) cov.obs <- cov(obs)[1, 2] ## Get an idea of the "true" covariance pseudo <- rCopula(10000, spec.cl) obs.big <- qnorm(pseudo) cov.true <- cov(obs.big)[1, 2] ## Get the bootstrap covariances cov.sim <- sapply(1:R, function(i, x, n){x.boot <- x[sample(1:n, size = n, replace = TRUE), ] cov(x.boot)[1, 2]}, x = obs, n = n) ## Visualization plot(1:R, cov.sim, xlab = "Replication", ylab = "", pch = 16, cex = 0.7, col ="grey", ylim = quantile(cov.sim, probs = c(0.1, 0.9))) lines(1:R, rep(cov.true, R), col = "green", lwd = 2) lines(1:R, rep(cov.obs, R), col = "red", lwd = 2) lines(1:R, cumsum(cov.sim)/(1:R), col = "blue", lwd = 2) legend("topright", legend = c("Boot cov", "True", "Initial", "Boot average"), col = c("grey", "green", "red", "blue"), bg = "white", pch = c(16, NA, NA, NA), lwd = c(NA, 2, 2, 2)) The blue line corresponds to $\widetilde{\Sigma}_R$ as a function of the number of replications, and the red line is $\widehat{\Sigma}$.
Is bootstrapping appropriate for estimating a multivariate normal covariance matrix using a small sa
Is the Bootstrap a good option to estimate $\Sigma$? No, the boostrap will help you infer about the uncertainty of your sample estimate. Specifically, it might be used to get confidence intervals on
Is bootstrapping appropriate for estimating a multivariate normal covariance matrix using a small sample size? Is the Bootstrap a good option to estimate $\Sigma$? No, the boostrap will help you infer about the uncertainty of your sample estimate. Specifically, it might be used to get confidence intervals on the elements of $\widehat{\Sigma}$. And how does the bootstrap work? The approach is to create $R$ replicate datasets from the original dataset by resampling the observations with replacement. Then you compute the estimate of interest on each of the $R$ replicates, in your case the covariance matrix, for each of the $R$ replicates, obtaining $\widehat{\Sigma}^1, \ldots, \widehat{\Sigma}^R$. Confidence intervals for $\widehat{\Sigma}$ can then be computed empiricaly from $\widehat{\Sigma}^1, \ldots, \widehat{\Sigma}^R$. For further information, you might want to have a look at the Wikipedia page. Edit Could I use $\widetilde{\Sigma}_R = R^{-1} \sum_{r=1}^R \widehat{\Sigma}^r$ instead of $\widehat{\Sigma}$? Actually, the matrix $\widetilde{\Sigma}_R$ is an estimate of ${\rm E} (\widehat{\Sigma}^r)$, where $\widehat{\Sigma}^r$ is the estimate of the covariance matrix based on a bootstrap replication of the initial sample. Bootstrapping comes down to sample from the empirical distribution $\widehat{F}$. Therefore, I think, but I don't have a formal proof, that $\widetilde{\Sigma}_R = {\rm E} (\widehat{\Sigma}^r) \to \widehat{\Sigma}$ as $R \to \infty$. So, I think you could use $\widetilde{\Sigma}_R$ instead of $\widehat{\Sigma}$, but that would be like using a sledgehammer to crack a nut. The R code below is a numerical investigation, which is by no means of proof of the above assertion about the convergence. The structure of dependence is a Gumbel copula, and the margins are two standard normal distribution. ## Initialization library(copula) set.seed(531) n <- 200 # Number of observations in the original sample R <- 10000 # Number of replications ## Specification for the dependence structure (Gumbel copula) spec.cl <- archmCopula("gumbel", 1.2) ## Create a fake original dataset pseudo <- rCopula(n, spec.cl) obs <- qnorm(pseudo) cov.obs <- cov(obs)[1, 2] ## Get an idea of the "true" covariance pseudo <- rCopula(10000, spec.cl) obs.big <- qnorm(pseudo) cov.true <- cov(obs.big)[1, 2] ## Get the bootstrap covariances cov.sim <- sapply(1:R, function(i, x, n){x.boot <- x[sample(1:n, size = n, replace = TRUE), ] cov(x.boot)[1, 2]}, x = obs, n = n) ## Visualization plot(1:R, cov.sim, xlab = "Replication", ylab = "", pch = 16, cex = 0.7, col ="grey", ylim = quantile(cov.sim, probs = c(0.1, 0.9))) lines(1:R, rep(cov.true, R), col = "green", lwd = 2) lines(1:R, rep(cov.obs, R), col = "red", lwd = 2) lines(1:R, cumsum(cov.sim)/(1:R), col = "blue", lwd = 2) legend("topright", legend = c("Boot cov", "True", "Initial", "Boot average"), col = c("grey", "green", "red", "blue"), bg = "white", pch = c(16, NA, NA, NA), lwd = c(NA, 2, 2, 2)) The blue line corresponds to $\widetilde{\Sigma}_R$ as a function of the number of replications, and the red line is $\widehat{\Sigma}$.
Is bootstrapping appropriate for estimating a multivariate normal covariance matrix using a small sa Is the Bootstrap a good option to estimate $\Sigma$? No, the boostrap will help you infer about the uncertainty of your sample estimate. Specifically, it might be used to get confidence intervals on
42,131
Implementing kernel logistic regression using IRWLS
I think this might help, although I'm still unsure myself on the relationship between kernel logistic regression and good old generalised additive models with locally weighted regression smooths. The NIPS paper suggests they're at least strongly related, if not the same. You can think of kernel logistic regression as fitting a weighted logistic regression for each data point $x_i$, based on its neighbours $x_j$. The weights are given by $K(||x_j - x_i||)$ with $K(*) \to 0$ as the distance between $x_j$ and $x_i$ increases. From this, you can use the standard IRLS algorithm to get the solution, by applying it in turn to each $x$. This is of course computationally inefficient, since you're applying an $O(N^2)$ algorithm to $N$ data points, making it $O(N^3)$ in all. This is the problem that the IVM is designed to solve.
Implementing kernel logistic regression using IRWLS
I think this might help, although I'm still unsure myself on the relationship between kernel logistic regression and good old generalised additive models with locally weighted regression smooths. The
Implementing kernel logistic regression using IRWLS I think this might help, although I'm still unsure myself on the relationship between kernel logistic regression and good old generalised additive models with locally weighted regression smooths. The NIPS paper suggests they're at least strongly related, if not the same. You can think of kernel logistic regression as fitting a weighted logistic regression for each data point $x_i$, based on its neighbours $x_j$. The weights are given by $K(||x_j - x_i||)$ with $K(*) \to 0$ as the distance between $x_j$ and $x_i$ increases. From this, you can use the standard IRLS algorithm to get the solution, by applying it in turn to each $x$. This is of course computationally inefficient, since you're applying an $O(N^2)$ algorithm to $N$ data points, making it $O(N^3)$ in all. This is the problem that the IVM is designed to solve.
Implementing kernel logistic regression using IRWLS I think this might help, although I'm still unsure myself on the relationship between kernel logistic regression and good old generalised additive models with locally weighted regression smooths. The
42,132
Implementing kernel logistic regression using IRWLS
I did some calculations by hand -- assuming that the bias term $b$ is the last value of the $\alpha$ vector, we get the following update equation: $$\alpha^{(k + 1)} \leftarrow (\phi^{T} W \phi + \lambda R)^{-1} ((\phi^{T} W \phi + \lambda R) \alpha^{(k)} - (\phi^{T}(\mu - y) + \lambda \phi \alpha^{(k)}_{0})),$$ with $\phi = \left( \begin{array}{cc} K & 1 \end{array} \right)$, $R = \left( \begin{array}{cc} K & 0 \\ 0 & 0 \end{array} \right)$ and $\alpha_{0}$ is like $\alpha$, but with the bias term set to $0$ (so it doesn't get regularized). This follows from the Newton-Raphson update: $$\alpha^{(k + 1)} \leftarrow \alpha^{(k)} - (\phi^{T} W \phi + \lambda R)^{-1} (\phi^{T} (\mu - y) + \lambda \phi \alpha^{(k)}_{0})$$ where the inverted term is the Hessian of the negative log-likelihood, and the other is its gradient, wrt. $\alpha$. The negative log-likelihood has the following form: $$NL(\alpha) = - \sum_{i = 1}^{n} (t_{i} \log \mu_{i} + (1 - t_{i}) \log (1 - \mu_{i})) + \alpha_{0}^{T} R \alpha_{0}.$$ Prediction boils down to the following (the bias term $b$ ended up in $\alpha$): $$logit(x) = \sum_{i = 1}^{n} K(x, x_{i}) \alpha_{i} + \alpha_{n + 1};$$ $$\mu(x) = \frac{\exp(logit(x))}{1 + \exp(logit(x))}.$$ Please tell me if you spot any error. I hope my last weekend could be useful to someone else too. Thank you Hong and Dougal again for your time (the hint about using solve() is being really useful =) I would overload you in +1's if I could.)
Implementing kernel logistic regression using IRWLS
I did some calculations by hand -- assuming that the bias term $b$ is the last value of the $\alpha$ vector, we get the following update equation: $$\alpha^{(k + 1)} \leftarrow (\phi^{T} W \phi + \lam
Implementing kernel logistic regression using IRWLS I did some calculations by hand -- assuming that the bias term $b$ is the last value of the $\alpha$ vector, we get the following update equation: $$\alpha^{(k + 1)} \leftarrow (\phi^{T} W \phi + \lambda R)^{-1} ((\phi^{T} W \phi + \lambda R) \alpha^{(k)} - (\phi^{T}(\mu - y) + \lambda \phi \alpha^{(k)}_{0})),$$ with $\phi = \left( \begin{array}{cc} K & 1 \end{array} \right)$, $R = \left( \begin{array}{cc} K & 0 \\ 0 & 0 \end{array} \right)$ and $\alpha_{0}$ is like $\alpha$, but with the bias term set to $0$ (so it doesn't get regularized). This follows from the Newton-Raphson update: $$\alpha^{(k + 1)} \leftarrow \alpha^{(k)} - (\phi^{T} W \phi + \lambda R)^{-1} (\phi^{T} (\mu - y) + \lambda \phi \alpha^{(k)}_{0})$$ where the inverted term is the Hessian of the negative log-likelihood, and the other is its gradient, wrt. $\alpha$. The negative log-likelihood has the following form: $$NL(\alpha) = - \sum_{i = 1}^{n} (t_{i} \log \mu_{i} + (1 - t_{i}) \log (1 - \mu_{i})) + \alpha_{0}^{T} R \alpha_{0}.$$ Prediction boils down to the following (the bias term $b$ ended up in $\alpha$): $$logit(x) = \sum_{i = 1}^{n} K(x, x_{i}) \alpha_{i} + \alpha_{n + 1};$$ $$\mu(x) = \frac{\exp(logit(x))}{1 + \exp(logit(x))}.$$ Please tell me if you spot any error. I hope my last weekend could be useful to someone else too. Thank you Hong and Dougal again for your time (the hint about using solve() is being really useful =) I would overload you in +1's if I could.)
Implementing kernel logistic regression using IRWLS I did some calculations by hand -- assuming that the bias term $b$ is the last value of the $\alpha$ vector, we get the following update equation: $$\alpha^{(k + 1)} \leftarrow (\phi^{T} W \phi + \lam
42,133
Implementing kernel logistic regression using IRWLS
There is a slightly better way of implementing IRWLS for kernel logistic regression that doesn't use the (weighted) normal equations and tends to have slightly better numerical properties. It basically fits the KLR model as a sequence of weighted Least-Squares Support Vector Machines (but with the logistic link function). There is a full derivation of this procedure in my paper (1) on approximate leave-one-out cross-validation for kernel logistic regression. If you use MATLAB, there is a toolbox that implements this approach. HTH (1) G. C. Cawley and N. L. C. Talbot, Efficient approximate leave-one-out cross-validation for kernel logistic regression, Machine Learning, vol, 71, no. 2-3, pp. 243--264, June 2008. (doi,pre-print)
Implementing kernel logistic regression using IRWLS
There is a slightly better way of implementing IRWLS for kernel logistic regression that doesn't use the (weighted) normal equations and tends to have slightly better numerical properties. It basical
Implementing kernel logistic regression using IRWLS There is a slightly better way of implementing IRWLS for kernel logistic regression that doesn't use the (weighted) normal equations and tends to have slightly better numerical properties. It basically fits the KLR model as a sequence of weighted Least-Squares Support Vector Machines (but with the logistic link function). There is a full derivation of this procedure in my paper (1) on approximate leave-one-out cross-validation for kernel logistic regression. If you use MATLAB, there is a toolbox that implements this approach. HTH (1) G. C. Cawley and N. L. C. Talbot, Efficient approximate leave-one-out cross-validation for kernel logistic regression, Machine Learning, vol, 71, no. 2-3, pp. 243--264, June 2008. (doi,pre-print)
Implementing kernel logistic regression using IRWLS There is a slightly better way of implementing IRWLS for kernel logistic regression that doesn't use the (weighted) normal equations and tends to have slightly better numerical properties. It basical
42,134
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate]
You can also think of regularization by norm penalization as conceptually similar to random effects (see for example, the beginning of section 2 of Koenker 2004 in particular the first proposition). Depending on your background, you may be more receptive/familiar to arguments supporting the use of random effects than those supporting the use of regularization. In any case, there is mapping between the type of regularization and the structure of the random effects and you can justify the use of any one of them by drawing on arguments from the other. *Quantile regression for longitudinal data; Koenker, R. (2004). Journal of Multivariate Analysis, Volume 91, Issue 1, Pages 74–89. Working paper version here
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d
You can also think of regularization by norm penalization as conceptually similar to random effects (see for example, the beginning of section 2 of Koenker 2004 in particular the first proposition).
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate] You can also think of regularization by norm penalization as conceptually similar to random effects (see for example, the beginning of section 2 of Koenker 2004 in particular the first proposition). Depending on your background, you may be more receptive/familiar to arguments supporting the use of random effects than those supporting the use of regularization. In any case, there is mapping between the type of regularization and the structure of the random effects and you can justify the use of any one of them by drawing on arguments from the other. *Quantile regression for longitudinal data; Koenker, R. (2004). Journal of Multivariate Analysis, Volume 91, Issue 1, Pages 74–89. Working paper version here
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d You can also think of regularization by norm penalization as conceptually similar to random effects (see for example, the beginning of section 2 of Koenker 2004 in particular the first proposition).
42,135
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate]
Generally, people use error on a holdout set as a proxy for generalization error. I think a fair response is to say if using an l1 or l2 penalty reduced error on the holdout test, then whatever you were doing was probably overfitting. Now, as to why it works: for regression, you can consider a l2 penalty as a normal prior on the parameters. That is, it's direct to show that $$ \underset{ \boldsymbol{w} }{\operatorname{argmax}} \sum_{i=1}^{N} \log \mathcal{N}( y_{i} | \boldsymbol{w^{T}x_{i}}, \sigma^2) + \sum_{i} \log \mathcal{N}(w_j | 0, \tau^2) $$ is a MAP estimate. So the improvement from an l2 norm can be considered as the win from going from a mle to a map estimate. There are also some deeper connections to pca that I don't want to try to type in this box, but essentially, this is a shrinkage estimator that shrinks the directions we are most uncertain about $ \boldsymbol{w}$ more. One intuition about why a lasso may improve a model is if you have groups of highly correlated explanatory variables, lasso may help you drop some of them.
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d
Generally, people use error on a holdout set as a proxy for generalization error. I think a fair response is to say if using an l1 or l2 penalty reduced error on the holdout test, then whatever you w
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate] Generally, people use error on a holdout set as a proxy for generalization error. I think a fair response is to say if using an l1 or l2 penalty reduced error on the holdout test, then whatever you were doing was probably overfitting. Now, as to why it works: for regression, you can consider a l2 penalty as a normal prior on the parameters. That is, it's direct to show that $$ \underset{ \boldsymbol{w} }{\operatorname{argmax}} \sum_{i=1}^{N} \log \mathcal{N}( y_{i} | \boldsymbol{w^{T}x_{i}}, \sigma^2) + \sum_{i} \log \mathcal{N}(w_j | 0, \tau^2) $$ is a MAP estimate. So the improvement from an l2 norm can be considered as the win from going from a mle to a map estimate. There are also some deeper connections to pca that I don't want to try to type in this box, but essentially, this is a shrinkage estimator that shrinks the directions we are most uncertain about $ \boldsymbol{w}$ more. One intuition about why a lasso may improve a model is if you have groups of highly correlated explanatory variables, lasso may help you drop some of them.
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d Generally, people use error on a holdout set as a proxy for generalization error. I think a fair response is to say if using an l1 or l2 penalty reduced error on the holdout test, then whatever you w
42,136
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate]
The norm is a smooth way to get some coefficients to zero. If more coefficients are zero, then the model is more parsimonious, hopefully allowing better generalization.
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d
The norm is a smooth way to get some coefficients to zero. If more coefficients are zero, then the model is more parsimonious, hopefully allowing better generalization.
Why does regularization of coefficient magnitude improve the generalization of linear regression? [duplicate] The norm is a smooth way to get some coefficients to zero. If more coefficients are zero, then the model is more parsimonious, hopefully allowing better generalization.
Why does regularization of coefficient magnitude improve the generalization of linear regression? [d The norm is a smooth way to get some coefficients to zero. If more coefficients are zero, then the model is more parsimonious, hopefully allowing better generalization.
42,137
How to find the level curves of a multivariate normal?
OK, scratching my own itch. We want the $1-\alpha$ level curve of $y \sim N_2(\mu,\Sigma)$ The $1-\alpha$ level curve of the $\mathcal N_2(0,I)$ distribution function is a circle of radius $\sigma = \sqrt{ \chi^2_{2,1-\alpha} }$ centred at the origin. This holds because if we consider some $x$ drawn from that distribution then $\mathbb P(x^T x \le \chi^2_{2,1-\alpha}) = 1-\alpha$. Using this to get the comparable curve for $y$ is a case of applying a standard linear transformation to $x$. Take some points on the unit circle by generating a sequence of angles, $\phi$, over $[0, 2\pi)$ and apply $(cos(\phi),sin(\phi))$, call the matrix formed by stacking these row vectors $R$. $\tilde Y = R \sigma \Sigma^{1/2} + \mu$. $\tilde Y$ is a set of points on the requisite level curve. EDIT: Tidied up the notation in response to @whuber's comment, hope it's less incoherent now.
How to find the level curves of a multivariate normal?
OK, scratching my own itch. We want the $1-\alpha$ level curve of $y \sim N_2(\mu,\Sigma)$ The $1-\alpha$ level curve of the $\mathcal N_2(0,I)$ distribution function is a circle of radius $\sigma = \
How to find the level curves of a multivariate normal? OK, scratching my own itch. We want the $1-\alpha$ level curve of $y \sim N_2(\mu,\Sigma)$ The $1-\alpha$ level curve of the $\mathcal N_2(0,I)$ distribution function is a circle of radius $\sigma = \sqrt{ \chi^2_{2,1-\alpha} }$ centred at the origin. This holds because if we consider some $x$ drawn from that distribution then $\mathbb P(x^T x \le \chi^2_{2,1-\alpha}) = 1-\alpha$. Using this to get the comparable curve for $y$ is a case of applying a standard linear transformation to $x$. Take some points on the unit circle by generating a sequence of angles, $\phi$, over $[0, 2\pi)$ and apply $(cos(\phi),sin(\phi))$, call the matrix formed by stacking these row vectors $R$. $\tilde Y = R \sigma \Sigma^{1/2} + \mu$. $\tilde Y$ is a set of points on the requisite level curve. EDIT: Tidied up the notation in response to @whuber's comment, hope it's less incoherent now.
How to find the level curves of a multivariate normal? OK, scratching my own itch. We want the $1-\alpha$ level curve of $y \sim N_2(\mu,\Sigma)$ The $1-\alpha$ level curve of the $\mathcal N_2(0,I)$ distribution function is a circle of radius $\sigma = \
42,138
Fitting mixture distributions and computing goodness-of-fit?
Mixture modelling in my experience can be tricky. Getting a good fit from a mixture model can be much more difficult than realising that a mixture may be a good approach. I have to say that I don't find the fit convincing here. Your graphics alone do not give much support to your summary of "decent". Kernel density estimates do give some support to the idea of two modes. (That is, using the default choice of your software, as the second mode disappears readily if you smooth enough.) The first mode is about log(x) = 6. The second is about log(x) = 12, but is however much weaker. The density at the first mode is higher by a factor of about 4 or 5, again at or near default choices of kernel type and width. On your graph, the kernel density is the dashed line, but as you show it it has been truncated: the density rises to more than 0.25 if smoothed similarly to what you did. (I used different software, but that should be immaterial.) In fact a complete curve can be seen at What distribution does my data follow? In contrast the mixture model yields two modes with more nearly equal density and the position of the second fitted mode does not correspond well to the observed secondary mode, being higher at about log(x) = 14. Furthermore, in each case the density of the other distribution is negligible at the position of the mode, so the ratio of densities at the two modes would be about the same in the combined distribution. (It isn't expected that modes of fitted components correspond exactly to modes in the data, but the mismatch here is disappointing.) The histogram here is a mystery. With this number of data (1567 observations) you could afford more bins than 9. But what is the histogram showing? If it's showing the combined fitted mixture model, that should be a smooth curve; if it's showing the original data, it's not doing a good job. That said, what is currently holding you up? The error message from the Kolmogorov-Smirnov test function indicates that it objects to ties, and as you do have ties in your data, that seems right. But, as I have discussed, the graphics alone tell you that the fit is not good. Wanting a P-value too would just be icing an unwelcome cake. A more convincing fit therefore might require the distribution with the higher mode to be a much smaller fraction of the total, but I don't have good ideas on how to move in that direction. Alternatively, many real distributions don't approximate theoretical distributions (or even mixtures of them) at all well. It's always welcome when that happens, but it can be fine just to present smoothed density estimates and say "This is what we have". Even in cases where we think we have two distinct sub-populations (say height or weight for males or females), it can be really hard to see that from a combined distribution. (Incidentally, for the sake of many readers, please do not use both red and green curves in a graph.)
Fitting mixture distributions and computing goodness-of-fit?
Mixture modelling in my experience can be tricky. Getting a good fit from a mixture model can be much more difficult than realising that a mixture may be a good approach. I have to say that I don't f
Fitting mixture distributions and computing goodness-of-fit? Mixture modelling in my experience can be tricky. Getting a good fit from a mixture model can be much more difficult than realising that a mixture may be a good approach. I have to say that I don't find the fit convincing here. Your graphics alone do not give much support to your summary of "decent". Kernel density estimates do give some support to the idea of two modes. (That is, using the default choice of your software, as the second mode disappears readily if you smooth enough.) The first mode is about log(x) = 6. The second is about log(x) = 12, but is however much weaker. The density at the first mode is higher by a factor of about 4 or 5, again at or near default choices of kernel type and width. On your graph, the kernel density is the dashed line, but as you show it it has been truncated: the density rises to more than 0.25 if smoothed similarly to what you did. (I used different software, but that should be immaterial.) In fact a complete curve can be seen at What distribution does my data follow? In contrast the mixture model yields two modes with more nearly equal density and the position of the second fitted mode does not correspond well to the observed secondary mode, being higher at about log(x) = 14. Furthermore, in each case the density of the other distribution is negligible at the position of the mode, so the ratio of densities at the two modes would be about the same in the combined distribution. (It isn't expected that modes of fitted components correspond exactly to modes in the data, but the mismatch here is disappointing.) The histogram here is a mystery. With this number of data (1567 observations) you could afford more bins than 9. But what is the histogram showing? If it's showing the combined fitted mixture model, that should be a smooth curve; if it's showing the original data, it's not doing a good job. That said, what is currently holding you up? The error message from the Kolmogorov-Smirnov test function indicates that it objects to ties, and as you do have ties in your data, that seems right. But, as I have discussed, the graphics alone tell you that the fit is not good. Wanting a P-value too would just be icing an unwelcome cake. A more convincing fit therefore might require the distribution with the higher mode to be a much smaller fraction of the total, but I don't have good ideas on how to move in that direction. Alternatively, many real distributions don't approximate theoretical distributions (or even mixtures of them) at all well. It's always welcome when that happens, but it can be fine just to present smoothed density estimates and say "This is what we have". Even in cases where we think we have two distinct sub-populations (say height or weight for males or females), it can be really hard to see that from a combined distribution. (Incidentally, for the sake of many readers, please do not use both red and green curves in a graph.)
Fitting mixture distributions and computing goodness-of-fit? Mixture modelling in my experience can be tricky. Getting a good fit from a mixture model can be much more difficult than realising that a mixture may be a good approach. I have to say that I don't f
42,139
Fitting mixture distributions and computing goodness-of-fit?
Assessing the goodness of a fit of a model requires specifying the cost of the model choice and the reward of the model fit. Usually, these decisions cannot be made from the data alone, and require more from the context of how the model is to be used. To see why cost the model choice is important, you could put a delta function with weight 1/n at each data point and get perfect recapitulation, but the model would be no more useful then just having the data in the first place. The point of the model is to somehow summarize the data into a more useful form. Once the cost has been specified, it is clear that the model can't (and shouldn't!) represent all aspects of the data. One way to think of the reward function for model fit is to indicate which aspects of the data are important to model. In general different choices will bring out different aspects of the data, so that a given set of models may be ranked differently under different reward functions. Here are a few popular reward functions for model fit: Kullback-Leibler divergence Anderson-Darling test (generally preferred over the K-S test) Energy Distance
Fitting mixture distributions and computing goodness-of-fit?
Assessing the goodness of a fit of a model requires specifying the cost of the model choice and the reward of the model fit. Usually, these decisions cannot be made from the data alone, and require mo
Fitting mixture distributions and computing goodness-of-fit? Assessing the goodness of a fit of a model requires specifying the cost of the model choice and the reward of the model fit. Usually, these decisions cannot be made from the data alone, and require more from the context of how the model is to be used. To see why cost the model choice is important, you could put a delta function with weight 1/n at each data point and get perfect recapitulation, but the model would be no more useful then just having the data in the first place. The point of the model is to somehow summarize the data into a more useful form. Once the cost has been specified, it is clear that the model can't (and shouldn't!) represent all aspects of the data. One way to think of the reward function for model fit is to indicate which aspects of the data are important to model. In general different choices will bring out different aspects of the data, so that a given set of models may be ranked differently under different reward functions. Here are a few popular reward functions for model fit: Kullback-Leibler divergence Anderson-Darling test (generally preferred over the K-S test) Energy Distance
Fitting mixture distributions and computing goodness-of-fit? Assessing the goodness of a fit of a model requires specifying the cost of the model choice and the reward of the model fit. Usually, these decisions cannot be made from the data alone, and require mo
42,140
Fitting mixture distributions and computing goodness-of-fit?
I'm not certain how the package you are using creates the fit, but if you have a closed form for the mixture (5 parameters, the mixing percentage $p$ and the meanlog and sdlog of the two lognormals) what you can do is generate $\lfloor{(\textrm{a large number like } 10^7)\cdot p}\rfloor$ samples from lognormal A and the remainder from the other, pool them together to create one huge sample, and use the pooled sample's empirical CDF as an estimate of the "theoretical" CDF of the mixed lognormal, and then run a K-S, Cramer-von-Mises (my poison of choice) or Anderson-Darling test on the data against it. As for the actual fitting, I tend to use maximum likelihood, where the likelihood of each data point is $p\cdot f_1(x) + (1-p)\cdot f_2(x)$.
Fitting mixture distributions and computing goodness-of-fit?
I'm not certain how the package you are using creates the fit, but if you have a closed form for the mixture (5 parameters, the mixing percentage $p$ and the meanlog and sdlog of the two lognormals) w
Fitting mixture distributions and computing goodness-of-fit? I'm not certain how the package you are using creates the fit, but if you have a closed form for the mixture (5 parameters, the mixing percentage $p$ and the meanlog and sdlog of the two lognormals) what you can do is generate $\lfloor{(\textrm{a large number like } 10^7)\cdot p}\rfloor$ samples from lognormal A and the remainder from the other, pool them together to create one huge sample, and use the pooled sample's empirical CDF as an estimate of the "theoretical" CDF of the mixed lognormal, and then run a K-S, Cramer-von-Mises (my poison of choice) or Anderson-Darling test on the data against it. As for the actual fitting, I tend to use maximum likelihood, where the likelihood of each data point is $p\cdot f_1(x) + (1-p)\cdot f_2(x)$.
Fitting mixture distributions and computing goodness-of-fit? I'm not certain how the package you are using creates the fit, but if you have a closed form for the mixture (5 parameters, the mixing percentage $p$ and the meanlog and sdlog of the two lognormals) w
42,141
How to handle samples that belong to multiple classes in supervised learning?
This looks like a classic Multi Label Classification. There are dozens of possible approaches, in particular sklearn python library implements such methods. In the most simple scenario, you can train classifiers on the "labels" basis. There won't be any problems with feature matrix, as you can simply divide your $m$ label problem, into $m$ single label problems, and train $m$ independent classifiers. Nice example can be found in sklearn documentation, where there are two binary labels (each sample can have label 1, label 2, both or none), and we simply convert it into two binary classification problems, working on the same input data, but with different labelings. What is @juampa suggesting is actually something more complex - predicting a structurized labeling makes many assumptions (first of all - that there is any reliable structure in the labels, and that you can model it "by hand"). This can also be a solution, but I would leave it for the later stage, if you find that more common, simplier approaches are not enough. In particular, there are models and methods for predicting structured labels without apriori knowledge of that structure.
How to handle samples that belong to multiple classes in supervised learning?
This looks like a classic Multi Label Classification. There are dozens of possible approaches, in particular sklearn python library implements such methods. In the most simple scenario, you can train
How to handle samples that belong to multiple classes in supervised learning? This looks like a classic Multi Label Classification. There are dozens of possible approaches, in particular sklearn python library implements such methods. In the most simple scenario, you can train classifiers on the "labels" basis. There won't be any problems with feature matrix, as you can simply divide your $m$ label problem, into $m$ single label problems, and train $m$ independent classifiers. Nice example can be found in sklearn documentation, where there are two binary labels (each sample can have label 1, label 2, both or none), and we simply convert it into two binary classification problems, working on the same input data, but with different labelings. What is @juampa suggesting is actually something more complex - predicting a structurized labeling makes many assumptions (first of all - that there is any reliable structure in the labels, and that you can model it "by hand"). This can also be a solution, but I would leave it for the later stage, if you find that more common, simplier approaches are not enough. In particular, there are models and methods for predicting structured labels without apriori knowledge of that structure.
How to handle samples that belong to multiple classes in supervised learning? This looks like a classic Multi Label Classification. There are dozens of possible approaches, in particular sklearn python library implements such methods. In the most simple scenario, you can train
42,142
How to handle samples that belong to multiple classes in supervised learning?
would a hierarchy of classifiers be a solution for you? on a first level you find the classifiers corresponding to clusters, and then have classifiers for the subclusters
How to handle samples that belong to multiple classes in supervised learning?
would a hierarchy of classifiers be a solution for you? on a first level you find the classifiers corresponding to clusters, and then have classifiers for the subclusters
How to handle samples that belong to multiple classes in supervised learning? would a hierarchy of classifiers be a solution for you? on a first level you find the classifiers corresponding to clusters, and then have classifiers for the subclusters
How to handle samples that belong to multiple classes in supervised learning? would a hierarchy of classifiers be a solution for you? on a first level you find the classifiers corresponding to clusters, and then have classifiers for the subclusters
42,143
A distribution similar to the Poisson one?
(got too long for a comment; hopefully it will become a more complete answer if you respond to some of these issues) Most important: when you say 'number of days' are you looking at intervals of time? Intervals of time, such as a count of days between some start event and some end event won't be Poisson. Poisson is for counts of (independent) events, not counts of the number of time intervals that have gone by between them. You might consider exponential or gamma GLMs for those. Secondly: Why do you think that you would need the residuals from a GLM to be normal? -- A potential answer: If your data are truly count data*, then you might consider the negative binomial. The negative binomial is often somewhat similar to the Poisson (the Poisson is indeed a special case), but has a larger variance. http://en.wikipedia.org/wiki/Negative_binomial_distribution * (though even so it would be good to have more details, because details will often tend to suggest which distributions to consider)
A distribution similar to the Poisson one?
(got too long for a comment; hopefully it will become a more complete answer if you respond to some of these issues) Most important: when you say 'number of days' are you looking at intervals of time?
A distribution similar to the Poisson one? (got too long for a comment; hopefully it will become a more complete answer if you respond to some of these issues) Most important: when you say 'number of days' are you looking at intervals of time? Intervals of time, such as a count of days between some start event and some end event won't be Poisson. Poisson is for counts of (independent) events, not counts of the number of time intervals that have gone by between them. You might consider exponential or gamma GLMs for those. Secondly: Why do you think that you would need the residuals from a GLM to be normal? -- A potential answer: If your data are truly count data*, then you might consider the negative binomial. The negative binomial is often somewhat similar to the Poisson (the Poisson is indeed a special case), but has a larger variance. http://en.wikipedia.org/wiki/Negative_binomial_distribution * (though even so it would be good to have more details, because details will often tend to suggest which distributions to consider)
A distribution similar to the Poisson one? (got too long for a comment; hopefully it will become a more complete answer if you respond to some of these issues) Most important: when you say 'number of days' are you looking at intervals of time?
42,144
Random Forests and data transformations
Random Forests are Decision Tree - based. So all they do is comparisons of your individual variables with some thresholds. Squaring your parameters simply will shift these thresholds, introducing no change to the actual output. So, in theory, RF's are not sensitive to rescaling.
Random Forests and data transformations
Random Forests are Decision Tree - based. So all they do is comparisons of your individual variables with some thresholds. Squaring your parameters simply will shift these thresholds, introducing no c
Random Forests and data transformations Random Forests are Decision Tree - based. So all they do is comparisons of your individual variables with some thresholds. Squaring your parameters simply will shift these thresholds, introducing no change to the actual output. So, in theory, RF's are not sensitive to rescaling.
Random Forests and data transformations Random Forests are Decision Tree - based. So all they do is comparisons of your individual variables with some thresholds. Squaring your parameters simply will shift these thresholds, introducing no c
42,145
For bootstrapping, why does a higher subsample size lead to lower variance?
First off, you should not resample a bootstrapped sample of size bigger than that of your original sample. So regardless of your population size, if your sample size is 200 you should not resample those values more than 200 times. In fact you should resample them precisely 200 times. So it's your friend who's got the correct results. As for why your variance is lower, well that's because random index arrays of size 3400 are going to more closely follow a uniform distribution than random indexes of size 200. And the more uniform the random index distribution the more the bootstrapped distribution is going to resemble the original sample distribution. This means the bootstrapped mean values are also going to be much closer to the original sample mean value and as a result reduce overall variance in your results.
For bootstrapping, why does a higher subsample size lead to lower variance?
First off, you should not resample a bootstrapped sample of size bigger than that of your original sample. So regardless of your population size, if your sample size is 200 you should not resample tho
For bootstrapping, why does a higher subsample size lead to lower variance? First off, you should not resample a bootstrapped sample of size bigger than that of your original sample. So regardless of your population size, if your sample size is 200 you should not resample those values more than 200 times. In fact you should resample them precisely 200 times. So it's your friend who's got the correct results. As for why your variance is lower, well that's because random index arrays of size 3400 are going to more closely follow a uniform distribution than random indexes of size 200. And the more uniform the random index distribution the more the bootstrapped distribution is going to resemble the original sample distribution. This means the bootstrapped mean values are also going to be much closer to the original sample mean value and as a result reduce overall variance in your results.
For bootstrapping, why does a higher subsample size lead to lower variance? First off, you should not resample a bootstrapped sample of size bigger than that of your original sample. So regardless of your population size, if your sample size is 200 you should not resample tho
42,146
Overdispersion parameter
You are right, the NB2 model should not have a worse fit than the poisson model, because the latter is a special case of the former, where $\alpha=0$. There is definitely a problem. It sounds to me like your numerical maximum likelihood maximizer had problems with your specification and therefore didn't really hit the global maximum. Now I don't use R, but in Stata the NB2 model often has convergence problems. Stata has an option "difficult", which uses a different algorithm to jump from nonconcave regions of the likelihood function. Using this often solves the problem. Maybe R too has different options for your maximizer; perhaps, you could try different starting values and see whether that makes a difference.
Overdispersion parameter
You are right, the NB2 model should not have a worse fit than the poisson model, because the latter is a special case of the former, where $\alpha=0$. There is definitely a problem. It sounds to me li
Overdispersion parameter You are right, the NB2 model should not have a worse fit than the poisson model, because the latter is a special case of the former, where $\alpha=0$. There is definitely a problem. It sounds to me like your numerical maximum likelihood maximizer had problems with your specification and therefore didn't really hit the global maximum. Now I don't use R, but in Stata the NB2 model often has convergence problems. Stata has an option "difficult", which uses a different algorithm to jump from nonconcave regions of the likelihood function. Using this often solves the problem. Maybe R too has different options for your maximizer; perhaps, you could try different starting values and see whether that makes a difference.
Overdispersion parameter You are right, the NB2 model should not have a worse fit than the poisson model, because the latter is a special case of the former, where $\alpha=0$. There is definitely a problem. It sounds to me li
42,147
Overlapping sets (3) - significance test
Let there be $n$ elements total with $a$, $b$, and $c$ in the subsets. Consider $N$ already partitioned into $A$ and $N-A$. The number of ways in which a $b$-element set can be drawn which has $l$ elements in common with $A$ is equal to the number of $l$-element subsets of $A$ times the number of $b-l$ element subsets of $N-A$: $$\binom{a}{l}\binom{n-a}{b-l}.$$ Ensuant to that, the number of ways in which a $c$-element set can be drawn which has $m$ elements in common with $A\cap B$ is the number of $m$-element subsets of $A\cap B$ times the number of $c-m$-element subsets of $N-(A\cap B)$: $$\binom{l}{m}\binom{n-l}{c-m}.$$ The total number of such choices of $B$ and $C$ is $$\binom{n}{b}\binom{n}{c}$$ and they are all equally likely. Summing over the possible values of $l$ gives the probability that the mutual intersection $A\cap B\cap C$ has exactly $m$ elements: $$\Pr(m) = \frac{1}{\binom{n}{b} \binom{n}{c}}\sum _{l}\binom{a}{l} \binom{n-a}{b-l} \binom{l}{m} \binom{n-l}{c-m}.$$ (The sum extends over all values of $l$ that make sense; by defining $\binom{u}{v}=0$ whenever $v\lt 0$ or $v \gt u$, we do not need to indicate explicit endpoints.) For instance, here is a plot of the central part of the probability distribution (comprising $99.99$% of the total) for $n=500, a=260, b=320, c=430$: By summing these values from a particular value $m_0$ on up, we obtain the probability that the cardinality of the triple intersection equals or exceeds $m_0$. In many practical applications, a Normal approximation to this sum works well. As a demonstration, here are the log ratios of the true probabilities to those obtained with a Normal approximation. (The Normal approximation uses the true mean $\mu$ and standard deviation $\sigma$ and estimates the probability of $m$ as $\Phi(\frac{m+1/2-\mu}{\sigma}) - \Phi(\frac{m-1/2-\mu}{\sigma})$ where $\Phi$ is the standard Normal CDF.) The mean is near $143$ and the SD is near $5.9$. (As usual, these are computed by summing $m$ and $m^2$, as weighted by the probabilities, to obtain the raw first and second moments, etc. I have not found a way to estimate either value a priori using simple formulas, but they can be estimated by computing probabilities for a small carefully-chosen selection of values of $m$ and fitting a Normal curve to them.) Evidently, the approximation is excellent (in this case) within one SD of the mean, after which it starts decreasing, but even at three SD from the mean (i.e., around $125$ or $161$) it is still within one or two percent of the correct value. For instance, the Normal approximation suggests the chance that $m \le 135$ is $0.939$ whereas the correct value is $0.928$. In cases where there is a narrow range of possibilities of $m$, the distribution is far from Normal--but fortunately then the summations are short. For instance, here is the distribution for $n=145, a=b=c=140$: A simulation of $10^5$ independent instances of this situation tallies closely:
Overlapping sets (3) - significance test
Let there be $n$ elements total with $a$, $b$, and $c$ in the subsets. Consider $N$ already partitioned into $A$ and $N-A$. The number of ways in which a $b$-element set can be drawn which has $l$ el
Overlapping sets (3) - significance test Let there be $n$ elements total with $a$, $b$, and $c$ in the subsets. Consider $N$ already partitioned into $A$ and $N-A$. The number of ways in which a $b$-element set can be drawn which has $l$ elements in common with $A$ is equal to the number of $l$-element subsets of $A$ times the number of $b-l$ element subsets of $N-A$: $$\binom{a}{l}\binom{n-a}{b-l}.$$ Ensuant to that, the number of ways in which a $c$-element set can be drawn which has $m$ elements in common with $A\cap B$ is the number of $m$-element subsets of $A\cap B$ times the number of $c-m$-element subsets of $N-(A\cap B)$: $$\binom{l}{m}\binom{n-l}{c-m}.$$ The total number of such choices of $B$ and $C$ is $$\binom{n}{b}\binom{n}{c}$$ and they are all equally likely. Summing over the possible values of $l$ gives the probability that the mutual intersection $A\cap B\cap C$ has exactly $m$ elements: $$\Pr(m) = \frac{1}{\binom{n}{b} \binom{n}{c}}\sum _{l}\binom{a}{l} \binom{n-a}{b-l} \binom{l}{m} \binom{n-l}{c-m}.$$ (The sum extends over all values of $l$ that make sense; by defining $\binom{u}{v}=0$ whenever $v\lt 0$ or $v \gt u$, we do not need to indicate explicit endpoints.) For instance, here is a plot of the central part of the probability distribution (comprising $99.99$% of the total) for $n=500, a=260, b=320, c=430$: By summing these values from a particular value $m_0$ on up, we obtain the probability that the cardinality of the triple intersection equals or exceeds $m_0$. In many practical applications, a Normal approximation to this sum works well. As a demonstration, here are the log ratios of the true probabilities to those obtained with a Normal approximation. (The Normal approximation uses the true mean $\mu$ and standard deviation $\sigma$ and estimates the probability of $m$ as $\Phi(\frac{m+1/2-\mu}{\sigma}) - \Phi(\frac{m-1/2-\mu}{\sigma})$ where $\Phi$ is the standard Normal CDF.) The mean is near $143$ and the SD is near $5.9$. (As usual, these are computed by summing $m$ and $m^2$, as weighted by the probabilities, to obtain the raw first and second moments, etc. I have not found a way to estimate either value a priori using simple formulas, but they can be estimated by computing probabilities for a small carefully-chosen selection of values of $m$ and fitting a Normal curve to them.) Evidently, the approximation is excellent (in this case) within one SD of the mean, after which it starts decreasing, but even at three SD from the mean (i.e., around $125$ or $161$) it is still within one or two percent of the correct value. For instance, the Normal approximation suggests the chance that $m \le 135$ is $0.939$ whereas the correct value is $0.928$. In cases where there is a narrow range of possibilities of $m$, the distribution is far from Normal--but fortunately then the summations are short. For instance, here is the distribution for $n=145, a=b=c=140$: A simulation of $10^5$ independent instances of this situation tallies closely:
Overlapping sets (3) - significance test Let there be $n$ elements total with $a$, $b$, and $c$ in the subsets. Consider $N$ already partitioned into $A$ and $N-A$. The number of ways in which a $b$-element set can be drawn which has $l$ el
42,148
Choosing the number of breakpoints for segmented regression (in R)
You're missing a really important caveat to the question: even if I pick 3 breakpoints, the location of those breakpoints will affect the model performance. So not only the number, but the location is important. I will assume for this problem that you have a prespecified list of possible breakpoints and the question is which ones to use and when. Since increasing the number of breakpoints increases the overall number of model parameters, this is actually a model or covariate selection problem. BIC and cross-validation are very amenable to this purpose. Basically, set-up an iterative procedure as follows: Simulate a dataset using k-fold cross validation. Fit all possible break-point models in your fixed/finite list of possible models Calculate the BIC for each model. Repeat 1-3 and calculate averages and error bars for the specific models and choose the one with lowest BIC. Example using cumulative link for probit regression with ordinally valued outcomes having quadratic trend. library(MASS) library(splines) set.seed(1234) x <- rnorm(1000) y <- rnorm(1000, -2 + .3 * x - .3*x^2, 0.3) cutpoint <- quantile(y, c(0, 0.1, 0.4, 0.7, 1)) ycut <- cut(y, cutpoint, include.lowest=T) ## example of model output model <- polr(ycut ~ x + I(x^2), method='probit') plot(x, ycut, main='Properly specified model') predicted <- apply(predict(model, type='prob'), 1, weighted.mean, x=1:4) lines(sort(x), predicted[order(x)], col='red') legend('topleft', pch=c(1, NA), lty=c(0, 1), col=1:2, c('Observed', 'Fitted')) ## use no quadratic effects, expect to find breakpoint at apex data <- data.frame('x'=x, 'y'=y, 'ycut'=ycut) breakpoints <- c(-2, 0, 2) ics <- replicate(1000, { data <- data[sample(1:nrow(data), nrow(data)*0.75), ] model1 <- polr(ycut ~ x, data=data, method='probit') model2 <- polr(ycut ~ ns(x, df=1, knots=0), data=data, method='probit') model3 <- polr(ycut ~ ns(x, df=1, knots=c(-1, 1)), data=data, method='probit') model4 <- polr(ycut ~ ns(x, df=1, knots=c(-1, 0, 1)), data=data, method='probit') ics <- c(BIC(model1), BIC(model2), BIC(model3), BIC(model4)) ics}) plot(rowMeans(ics), type='l', axes=F) axis(1, at=1:4, labels=c('Linear', 'At 0', 'At -1, 1', 'At -1, 0, 1')) plot(rowMeans(ics), type='l', axes=F, xlab='', ylab='BIC') axis(1, at=1:4, labels=c('Linear', 'At 0', 'At -1, 1', 'At -1, 0, 1')) axis(2) box() ## best model, albeit the "wrong" one best <- polr(formula = ycut ~ ns(x, df = 1, knots = 0), method = "probit") plot(x, ycut, main='Properly specified model') predicted <- apply(predict(best, type='prob'), 1, weighted.mean, x=1:4) lines(sort(x), predicted[order(x)], col='red') legend('topleft', pch=c(1, NA), lty=c(0, 1), col=1:2, c('Observed', 'Fitted')) This method arrives at a near 100% agreement between the true model and BIC best model for predicting ordinal category based on the mode. BIC optimal Truth [-6.8,-3] (-3,-2.32] (-2.32,-1.96] (-1.96,-1.22] [-6.8,-3] 81 2 0 0 (-3,-2.32] 1 284 1 0 (-2.32,-1.96] 0 1 209 16 (-1.96,-1.22] 0 0 10 395
Choosing the number of breakpoints for segmented regression (in R)
You're missing a really important caveat to the question: even if I pick 3 breakpoints, the location of those breakpoints will affect the model performance. So not only the number, but the location is
Choosing the number of breakpoints for segmented regression (in R) You're missing a really important caveat to the question: even if I pick 3 breakpoints, the location of those breakpoints will affect the model performance. So not only the number, but the location is important. I will assume for this problem that you have a prespecified list of possible breakpoints and the question is which ones to use and when. Since increasing the number of breakpoints increases the overall number of model parameters, this is actually a model or covariate selection problem. BIC and cross-validation are very amenable to this purpose. Basically, set-up an iterative procedure as follows: Simulate a dataset using k-fold cross validation. Fit all possible break-point models in your fixed/finite list of possible models Calculate the BIC for each model. Repeat 1-3 and calculate averages and error bars for the specific models and choose the one with lowest BIC. Example using cumulative link for probit regression with ordinally valued outcomes having quadratic trend. library(MASS) library(splines) set.seed(1234) x <- rnorm(1000) y <- rnorm(1000, -2 + .3 * x - .3*x^2, 0.3) cutpoint <- quantile(y, c(0, 0.1, 0.4, 0.7, 1)) ycut <- cut(y, cutpoint, include.lowest=T) ## example of model output model <- polr(ycut ~ x + I(x^2), method='probit') plot(x, ycut, main='Properly specified model') predicted <- apply(predict(model, type='prob'), 1, weighted.mean, x=1:4) lines(sort(x), predicted[order(x)], col='red') legend('topleft', pch=c(1, NA), lty=c(0, 1), col=1:2, c('Observed', 'Fitted')) ## use no quadratic effects, expect to find breakpoint at apex data <- data.frame('x'=x, 'y'=y, 'ycut'=ycut) breakpoints <- c(-2, 0, 2) ics <- replicate(1000, { data <- data[sample(1:nrow(data), nrow(data)*0.75), ] model1 <- polr(ycut ~ x, data=data, method='probit') model2 <- polr(ycut ~ ns(x, df=1, knots=0), data=data, method='probit') model3 <- polr(ycut ~ ns(x, df=1, knots=c(-1, 1)), data=data, method='probit') model4 <- polr(ycut ~ ns(x, df=1, knots=c(-1, 0, 1)), data=data, method='probit') ics <- c(BIC(model1), BIC(model2), BIC(model3), BIC(model4)) ics}) plot(rowMeans(ics), type='l', axes=F) axis(1, at=1:4, labels=c('Linear', 'At 0', 'At -1, 1', 'At -1, 0, 1')) plot(rowMeans(ics), type='l', axes=F, xlab='', ylab='BIC') axis(1, at=1:4, labels=c('Linear', 'At 0', 'At -1, 1', 'At -1, 0, 1')) axis(2) box() ## best model, albeit the "wrong" one best <- polr(formula = ycut ~ ns(x, df = 1, knots = 0), method = "probit") plot(x, ycut, main='Properly specified model') predicted <- apply(predict(best, type='prob'), 1, weighted.mean, x=1:4) lines(sort(x), predicted[order(x)], col='red') legend('topleft', pch=c(1, NA), lty=c(0, 1), col=1:2, c('Observed', 'Fitted')) This method arrives at a near 100% agreement between the true model and BIC best model for predicting ordinal category based on the mode. BIC optimal Truth [-6.8,-3] (-3,-2.32] (-2.32,-1.96] (-1.96,-1.22] [-6.8,-3] 81 2 0 0 (-3,-2.32] 1 284 1 0 (-2.32,-1.96] 0 1 209 16 (-1.96,-1.22] 0 0 10 395
Choosing the number of breakpoints for segmented regression (in R) You're missing a really important caveat to the question: even if I pick 3 breakpoints, the location of those breakpoints will affect the model performance. So not only the number, but the location is
42,149
Choosing the number of breakpoints for segmented regression (in R)
I recommend the efp(), Fstats(), and breakpoints() functions in the R strucchange package. The bfast package is nice too and provides wrappers for strucchange and segmented. You can read more about these functions here and in the works cited therein. Please note that these functions are slow on very large datasets. While segmented functions are very fast, I don't think they are as powerful.
Choosing the number of breakpoints for segmented regression (in R)
I recommend the efp(), Fstats(), and breakpoints() functions in the R strucchange package. The bfast package is nice too and provides wrappers for strucchange and segmented. You can read more about th
Choosing the number of breakpoints for segmented regression (in R) I recommend the efp(), Fstats(), and breakpoints() functions in the R strucchange package. The bfast package is nice too and provides wrappers for strucchange and segmented. You can read more about these functions here and in the works cited therein. Please note that these functions are slow on very large datasets. While segmented functions are very fast, I don't think they are as powerful.
Choosing the number of breakpoints for segmented regression (in R) I recommend the efp(), Fstats(), and breakpoints() functions in the R strucchange package. The bfast package is nice too and provides wrappers for strucchange and segmented. You can read more about th
42,150
Metropolis Sampling and invalid states
From your question: It is possible that the transition function can suggest a move to an invalid part of the state space, and the jump should be obviously rejected. The jump should not be rejected This is a great article on the problem with immediately rejecting an errant jump. As a consequence, your problem vanishes.
Metropolis Sampling and invalid states
From your question: It is possible that the transition function can suggest a move to an invalid part of the state space, and the jump should be obviously rejected. The jump should not be rejected
Metropolis Sampling and invalid states From your question: It is possible that the transition function can suggest a move to an invalid part of the state space, and the jump should be obviously rejected. The jump should not be rejected This is a great article on the problem with immediately rejecting an errant jump. As a consequence, your problem vanishes.
Metropolis Sampling and invalid states From your question: It is possible that the transition function can suggest a move to an invalid part of the state space, and the jump should be obviously rejected. The jump should not be rejected
42,151
Metropolis Sampling and invalid states
[Reproducing a blog entry I wrote a while ago:] It is indeed a popular belief that something needs to be done to counteract restricted supports. However, there is no mathematical reason for doing so! If we look at the Metropolis-Hastings acceptance probability $$\rho(x_t,y_{t+1})= \text{min} (1, \pi(y_{t+1})q(x_t|y_{t+1})\big/ \pi(x_t)q(y_{t+1}|x_{t}) )$$ (duplicated from the mcmc tag wiki), with $y_t\sim q(y_{t+1}|x_{t})$, if $y_t$ is outside the support of $\pi$, we can extend the support by defining $\pi(y)=0$ outside the original support. Hence, if $\pi(y_{t+1})=0$, $\rho(x_t,y_{t+1})=0$, which means the proposed value is rejected and $x_{t+1}=x_t$. Consider the following illustration. target=function(x) (x>0)*(x<1)*dnorm(x,mean=4) mcmc=rep(0.5,10^5) for (t in 2:10^5){ prop=mcmc[t-1]+rnorm(1,.1) if (runif(1)<target(prop)/target(mcmc[t-1])) mcmc[t]=prop else mcmc[t]=mcmc[t-1] } hist(mcmc,prob=TRUE,col="wheat",border=FALSE,main="",xlab="") curve(dnorm(x-4)/(pnorm(-3)-pnorm(-4)),add=TRUE) that is targeting a truncated normal distribution using a Gaussian random walk proposal with support the entire real line. Then the algorithm is properly converging as shown by the fit below:
Metropolis Sampling and invalid states
[Reproducing a blog entry I wrote a while ago:] It is indeed a popular belief that something needs to be done to counteract restricted supports. However, there is no mathematical reason for doing so!
Metropolis Sampling and invalid states [Reproducing a blog entry I wrote a while ago:] It is indeed a popular belief that something needs to be done to counteract restricted supports. However, there is no mathematical reason for doing so! If we look at the Metropolis-Hastings acceptance probability $$\rho(x_t,y_{t+1})= \text{min} (1, \pi(y_{t+1})q(x_t|y_{t+1})\big/ \pi(x_t)q(y_{t+1}|x_{t}) )$$ (duplicated from the mcmc tag wiki), with $y_t\sim q(y_{t+1}|x_{t})$, if $y_t$ is outside the support of $\pi$, we can extend the support by defining $\pi(y)=0$ outside the original support. Hence, if $\pi(y_{t+1})=0$, $\rho(x_t,y_{t+1})=0$, which means the proposed value is rejected and $x_{t+1}=x_t$. Consider the following illustration. target=function(x) (x>0)*(x<1)*dnorm(x,mean=4) mcmc=rep(0.5,10^5) for (t in 2:10^5){ prop=mcmc[t-1]+rnorm(1,.1) if (runif(1)<target(prop)/target(mcmc[t-1])) mcmc[t]=prop else mcmc[t]=mcmc[t-1] } hist(mcmc,prob=TRUE,col="wheat",border=FALSE,main="",xlab="") curve(dnorm(x-4)/(pnorm(-3)-pnorm(-4)),add=TRUE) that is targeting a truncated normal distribution using a Gaussian random walk proposal with support the entire real line. Then the algorithm is properly converging as shown by the fit below:
Metropolis Sampling and invalid states [Reproducing a blog entry I wrote a while ago:] It is indeed a popular belief that something needs to be done to counteract restricted supports. However, there is no mathematical reason for doing so!
42,152
On combining SVMs
You might find the following article helpful. Various techniques are outlined to get probability estimates for the outputs of SVM in Milgram. In combining the probability estimates a weighted or unweighted sum of probabilities, naive Bayes or various other techniques can be used. See Chapter 5 for a comprehensive study of fusing classifier outputs. Kittler argues theoretically that the sum rule (adding up the probabilities of various classifiers and choosing the class with the highest probability) is optimal. I don't know what type of improvement in accuracy you can expect from only two support vector machines. The argument behind ensemble is that the probability of a correct collective decision approach 1 if the number of classifiers in the ensemble approach infinity. Using only two classifiers, will either agree on the decision or disagree on the decision. I would think that the ensemble wont be any better than the best single classifier?
On combining SVMs
You might find the following article helpful. Various techniques are outlined to get probability estimates for the outputs of SVM in Milgram. In combining the probability estimates a weighted or unwei
On combining SVMs You might find the following article helpful. Various techniques are outlined to get probability estimates for the outputs of SVM in Milgram. In combining the probability estimates a weighted or unweighted sum of probabilities, naive Bayes or various other techniques can be used. See Chapter 5 for a comprehensive study of fusing classifier outputs. Kittler argues theoretically that the sum rule (adding up the probabilities of various classifiers and choosing the class with the highest probability) is optimal. I don't know what type of improvement in accuracy you can expect from only two support vector machines. The argument behind ensemble is that the probability of a correct collective decision approach 1 if the number of classifiers in the ensemble approach infinity. Using only two classifiers, will either agree on the decision or disagree on the decision. I would think that the ensemble wont be any better than the best single classifier?
On combining SVMs You might find the following article helpful. Various techniques are outlined to get probability estimates for the outputs of SVM in Milgram. In combining the probability estimates a weighted or unwei
42,153
On combining SVMs
Try A] Majority Voting B] Weighted Voting (Considering the distance to hyperplane as the weight or confidence of each hyperplane in their classification) C] AdaBoost [1] Algorithm. [1] http://en.wikipedia.org/wiki/AdaBoost
On combining SVMs
Try A] Majority Voting B] Weighted Voting (Considering the distance to hyperplane as the weight or confidence of each hyperplane in their classification) C] AdaBoost [1] Algorithm. [1] http://en.wi
On combining SVMs Try A] Majority Voting B] Weighted Voting (Considering the distance to hyperplane as the weight or confidence of each hyperplane in their classification) C] AdaBoost [1] Algorithm. [1] http://en.wikipedia.org/wiki/AdaBoost
On combining SVMs Try A] Majority Voting B] Weighted Voting (Considering the distance to hyperplane as the weight or confidence of each hyperplane in their classification) C] AdaBoost [1] Algorithm. [1] http://en.wi
42,154
Variables that do not converge in winbugs
5000? That's nothing :-) In papers it is usual to use like 200,000. Variance parameters are always the worse for estimation. You have a huge autocorrelation in the chains - you should increase your thin parameter at least 16 times. What is your thin parameter now? Anyway, I think the variables would converge quite well if you let the chains run longer. So set the thin and do at least 50,000 iterations.
Variables that do not converge in winbugs
5000? That's nothing :-) In papers it is usual to use like 200,000. Variance parameters are always the worse for estimation. You have a huge autocorrelation in the chains - you should increase your th
Variables that do not converge in winbugs 5000? That's nothing :-) In papers it is usual to use like 200,000. Variance parameters are always the worse for estimation. You have a huge autocorrelation in the chains - you should increase your thin parameter at least 16 times. What is your thin parameter now? Anyway, I think the variables would converge quite well if you let the chains run longer. So set the thin and do at least 50,000 iterations.
Variables that do not converge in winbugs 5000? That's nothing :-) In papers it is usual to use like 200,000. Variance parameters are always the worse for estimation. You have a huge autocorrelation in the chains - you should increase your th
42,155
Variables that do not converge in winbugs
The second and third picture don't seem to converge. You can look at Rhat value. If it is 1.0, then it is converged. If it is far away from that, say 1.5, probably it doesn't converge.
Variables that do not converge in winbugs
The second and third picture don't seem to converge. You can look at Rhat value. If it is 1.0, then it is converged. If it is far away from that, say 1.5, probably it doesn't converge.
Variables that do not converge in winbugs The second and third picture don't seem to converge. You can look at Rhat value. If it is 1.0, then it is converged. If it is far away from that, say 1.5, probably it doesn't converge.
Variables that do not converge in winbugs The second and third picture don't seem to converge. You can look at Rhat value. If it is 1.0, then it is converged. If it is far away from that, say 1.5, probably it doesn't converge.
42,156
Biased estimates when intercept is included in a linear regression
There is a mistake in my question: OLS doesn't give an unbiased estimator for the autoregressive coefficients of an $\mathrm{AR}(p)$ process! In fact the OLS estimator is biased toward zero as explained in this article: A. Maeshiro (2000), An Illustration of the Bias of OLS for $Y_t = \lambda Y_{t-1} + U_t$, J. Econ. Education, vol. 31, no. 1, 76–80. Then it appears that including an intercept makes things worse, since the estimates are even more biased. Also: the OLS is consistent, that's why the bias is disappearing as $N$ increases.
Biased estimates when intercept is included in a linear regression
There is a mistake in my question: OLS doesn't give an unbiased estimator for the autoregressive coefficients of an $\mathrm{AR}(p)$ process! In fact the OLS estimator is biased toward zero as explain
Biased estimates when intercept is included in a linear regression There is a mistake in my question: OLS doesn't give an unbiased estimator for the autoregressive coefficients of an $\mathrm{AR}(p)$ process! In fact the OLS estimator is biased toward zero as explained in this article: A. Maeshiro (2000), An Illustration of the Bias of OLS for $Y_t = \lambda Y_{t-1} + U_t$, J. Econ. Education, vol. 31, no. 1, 76–80. Then it appears that including an intercept makes things worse, since the estimates are even more biased. Also: the OLS is consistent, that's why the bias is disappearing as $N$ increases.
Biased estimates when intercept is included in a linear regression There is a mistake in my question: OLS doesn't give an unbiased estimator for the autoregressive coefficients of an $\mathrm{AR}(p)$ process! In fact the OLS estimator is biased toward zero as explain
42,157
Random walk or not?
Your data looks random-walk-y to me. Intuition is notoriously unreliable when it comes to random walks; witness technical chart analysis for stock markets. Let's put your data into context. Estimate the standard deviation of the differences, assuming a mean increment of zero: foo <- c(59, 334, 333, 402, 450, 461, 452, 468, 461, 463, 508, 573, 639, 567) stdev <- sqrt(mean(diff(foo)^2)) Next, simulate 20 bona fide random walks with this standard deviation. Plot their trajectories and add your data: n.sims <- 20 bar <- matrix(rnorm(n.sims*length(foo),mean=0,sd=stdev),nrow=n.sims) plot(seq(1,length(foo)),foo,type="o",pch=21,col="red",bg="red", ylim=c(-max(rowSums(bar)),max(rowSums(bar))),xlab="",ylab="") for ( ii in 1:n.sims ) points(seq(1,length(foo)),cumsum(bar[ii,]), type="o",pch=21,bg="black",cex=0.6) Your data do not look out of place in this set of random walks.
Random walk or not?
Your data looks random-walk-y to me. Intuition is notoriously unreliable when it comes to random walks; witness technical chart analysis for stock markets. Let's put your data into context. Estimate t
Random walk or not? Your data looks random-walk-y to me. Intuition is notoriously unreliable when it comes to random walks; witness technical chart analysis for stock markets. Let's put your data into context. Estimate the standard deviation of the differences, assuming a mean increment of zero: foo <- c(59, 334, 333, 402, 450, 461, 452, 468, 461, 463, 508, 573, 639, 567) stdev <- sqrt(mean(diff(foo)^2)) Next, simulate 20 bona fide random walks with this standard deviation. Plot their trajectories and add your data: n.sims <- 20 bar <- matrix(rnorm(n.sims*length(foo),mean=0,sd=stdev),nrow=n.sims) plot(seq(1,length(foo)),foo,type="o",pch=21,col="red",bg="red", ylim=c(-max(rowSums(bar)),max(rowSums(bar))),xlab="",ylab="") for ( ii in 1:n.sims ) points(seq(1,length(foo)),cumsum(bar[ii,]), type="o",pch=21,bg="black",cex=0.6) Your data do not look out of place in this set of random walks.
Random walk or not? Your data looks random-walk-y to me. Intuition is notoriously unreliable when it comes to random walks; witness technical chart analysis for stock markets. Let's put your data into context. Estimate t
42,158
Understanding the exponential distribution
Suppose you have some mildly radioactive substance so that you expect to wait $20$ seconds between decays. That is a rate of $1/20$ per second. The average number of decays in one second is $1/20$. One way to get an average count of $1/20$ would be if the count were $1$ with probability $1/20$ and $0$ with probability $19/20$. However, sometimes there are $2$ or more decays in that second. For the average count to be $1/20$, when it is sometimes $2$ or more, the probability that you get a count of $0$ must be greater than $19/20$. Therefore, the probability that you wait more than one second before the first decay is greater than $19/20$, and the probability that the first decay occurs within the first second is less than $1/20$.
Understanding the exponential distribution
Suppose you have some mildly radioactive substance so that you expect to wait $20$ seconds between decays. That is a rate of $1/20$ per second. The average number of decays in one second is $1/20$. O
Understanding the exponential distribution Suppose you have some mildly radioactive substance so that you expect to wait $20$ seconds between decays. That is a rate of $1/20$ per second. The average number of decays in one second is $1/20$. One way to get an average count of $1/20$ would be if the count were $1$ with probability $1/20$ and $0$ with probability $19/20$. However, sometimes there are $2$ or more decays in that second. For the average count to be $1/20$, when it is sometimes $2$ or more, the probability that you get a count of $0$ must be greater than $19/20$. Therefore, the probability that you wait more than one second before the first decay is greater than $19/20$, and the probability that the first decay occurs within the first second is less than $1/20$.
Understanding the exponential distribution Suppose you have some mildly radioactive substance so that you expect to wait $20$ seconds between decays. That is a rate of $1/20$ per second. The average number of decays in one second is $1/20$. O
42,159
Understanding the exponential distribution
There is a well known approximation for $e^x$ when $x$ is very close to zero: $$ e^x \approx 1 + x $$ If we take $ x = -0.05 $, we get $ e^{-0.05} \approx 1 - 0.05 = 0.95 $. So we can say: $$ 1 - e^{-0.05} \approx 1 - 0.95 = 0.05 $$ You make a mistake when you think that a good approximation is the same as the exact value: the approximation is close to the exact value but rarely is the same number. The exact value is: $$ 1 - e^{-0.05} = 1 - 0.951229 = 0.0487705 $$ The exact value of a calculus is difficult to reach. For an engineer or a scientific is better to use a good approximation.
Understanding the exponential distribution
There is a well known approximation for $e^x$ when $x$ is very close to zero: $$ e^x \approx 1 + x $$ If we take $ x = -0.05 $, we get $ e^{-0.05} \approx 1 - 0.05 = 0.95 $. So we can say: $$ 1 - e^{-
Understanding the exponential distribution There is a well known approximation for $e^x$ when $x$ is very close to zero: $$ e^x \approx 1 + x $$ If we take $ x = -0.05 $, we get $ e^{-0.05} \approx 1 - 0.05 = 0.95 $. So we can say: $$ 1 - e^{-0.05} \approx 1 - 0.95 = 0.05 $$ You make a mistake when you think that a good approximation is the same as the exact value: the approximation is close to the exact value but rarely is the same number. The exact value is: $$ 1 - e^{-0.05} = 1 - 0.951229 = 0.0487705 $$ The exact value of a calculus is difficult to reach. For an engineer or a scientific is better to use a good approximation.
Understanding the exponential distribution There is a well known approximation for $e^x$ when $x$ is very close to zero: $$ e^x \approx 1 + x $$ If we take $ x = -0.05 $, we get $ e^{-0.05} \approx 1 - 0.05 = 0.95 $. So we can say: $$ 1 - e^{-
42,160
Predicting time series with NNs: should the data set be shuffled?
Say you have a single time series you want to learn on. Then you can use the first half for the development of your model and the second half for testing. You now cut your two halves into windows individually and can shuffle those of the training set. From what I know, the shuffling is actually not done because of generalization, but because of optimization. It is sometimes more efficient to optimize a sum of functions (in this case, one loss function per time window) if you do not look at their sum, but estimate the gradient by looking at the gradients of a subset of the sum. Look at recent publications by Nicolas Le Roux and Marc Schmidt for this topic.
Predicting time series with NNs: should the data set be shuffled?
Say you have a single time series you want to learn on. Then you can use the first half for the development of your model and the second half for testing. You now cut your two halves into windows indi
Predicting time series with NNs: should the data set be shuffled? Say you have a single time series you want to learn on. Then you can use the first half for the development of your model and the second half for testing. You now cut your two halves into windows individually and can shuffle those of the training set. From what I know, the shuffling is actually not done because of generalization, but because of optimization. It is sometimes more efficient to optimize a sum of functions (in this case, one loss function per time window) if you do not look at their sum, but estimate the gradient by looking at the gradients of a subset of the sum. Look at recent publications by Nicolas Le Roux and Marc Schmidt for this topic.
Predicting time series with NNs: should the data set be shuffled? Say you have a single time series you want to learn on. Then you can use the first half for the development of your model and the second half for testing. You now cut your two halves into windows indi
42,161
Predicting time series with NNs: should the data set be shuffled?
If you are using a not-recurrent NN like a traditional MLP you don't NEED to shuffle dataset especially if you're using a batch learning algorithm. Anyway, in my experience it's a good idea to shuffle datasets for a faster training and more clear results. I can suggest you "Efficient BackProp" by LeCun et al., where you can find a useful set of tips & tricks on the use of NNs.
Predicting time series with NNs: should the data set be shuffled?
If you are using a not-recurrent NN like a traditional MLP you don't NEED to shuffle dataset especially if you're using a batch learning algorithm. Anyway, in my experience it's a good idea to shuffle
Predicting time series with NNs: should the data set be shuffled? If you are using a not-recurrent NN like a traditional MLP you don't NEED to shuffle dataset especially if you're using a batch learning algorithm. Anyway, in my experience it's a good idea to shuffle datasets for a faster training and more clear results. I can suggest you "Efficient BackProp" by LeCun et al., where you can find a useful set of tips & tricks on the use of NNs.
Predicting time series with NNs: should the data set be shuffled? If you are using a not-recurrent NN like a traditional MLP you don't NEED to shuffle dataset especially if you're using a batch learning algorithm. Anyway, in my experience it's a good idea to shuffle
42,162
How can I debug and check the consistency of a Kalman filter?
Generate your own measurements, in a known scenario, that fulfills the assumptions Test it in the known scenario. If you do it in 1 or 2 dimensions, you can even do it by hand. Look at the properties. The autocorrelation of the innovation must be white if I am not mistaken (in a linear scenario, not 100% sure, but I know that in non-linear scenarios it is not. If some), so if you take the autocorrelation it should look approximately like a delta function. There are implementations online, it won't tell you that yours is right but it can make you think about the differences if there are. Check if what you get is what you are expecting to get. What is this? Well, in 2D, you are expecting to get an estimation which balances the prediction and the measurement, right? So If the result is not sort of in the middle, it is probably wrong. Be suspicious about everything you can. And then if you have any particular point where you are not sure, post it. There is a very nice description here, at least I liked it very much. https://cs.adelaide.edu.au/~ianr/Teaching/Estimation/LectureNotes2.pdf And since the link can break at any point, it is the file Estimation II from Ian Reid, Hillary Term 2001
How can I debug and check the consistency of a Kalman filter?
Generate your own measurements, in a known scenario, that fulfills the assumptions Test it in the known scenario. If you do it in 1 or 2 dimensions, you can even do it by hand. Look at the properties.
How can I debug and check the consistency of a Kalman filter? Generate your own measurements, in a known scenario, that fulfills the assumptions Test it in the known scenario. If you do it in 1 or 2 dimensions, you can even do it by hand. Look at the properties. The autocorrelation of the innovation must be white if I am not mistaken (in a linear scenario, not 100% sure, but I know that in non-linear scenarios it is not. If some), so if you take the autocorrelation it should look approximately like a delta function. There are implementations online, it won't tell you that yours is right but it can make you think about the differences if there are. Check if what you get is what you are expecting to get. What is this? Well, in 2D, you are expecting to get an estimation which balances the prediction and the measurement, right? So If the result is not sort of in the middle, it is probably wrong. Be suspicious about everything you can. And then if you have any particular point where you are not sure, post it. There is a very nice description here, at least I liked it very much. https://cs.adelaide.edu.au/~ianr/Teaching/Estimation/LectureNotes2.pdf And since the link can break at any point, it is the file Estimation II from Ian Reid, Hillary Term 2001
How can I debug and check the consistency of a Kalman filter? Generate your own measurements, in a known scenario, that fulfills the assumptions Test it in the known scenario. If you do it in 1 or 2 dimensions, you can even do it by hand. Look at the properties.
42,163
How can I debug and check the consistency of a Kalman filter?
As a follow up to @Marcel's answer, here is a more detailed explanation of how to debug and check the consistency of a Kalman filter. This explanation is an expansion of the one from section 2.2.3, page 18, of the lecture notes titled Estimation II written by Ian Reid at Oxford in 2001, which is the same set of lecture notes that @Marcel links to in his answer. Overview Recall that the Kalman filter is an optimal observer for a linear, time-varying, and discrete-time system that evolves according to the following state equation $$ \begin{align} x_{k+1} &= A_k x_k + B_k u_k + w_k \end{align} $$ where $x_k \in \mathbb R^{d_x}$ is the state vector at time-step $k$, $A_k \in \mathbb R^{d_x \times d_x}$ is the state-transition matrix at time-step $k$, $u_k \in \mathbb R^{d_u}$ is the control input at time-step $k$, $B_k \in \mathbb R^{d_x \times d_u}$ is the control matrix at time-step $k$, $w_k \sim N(0,\Sigma_{w_k})$ is a multivariate Gaussian random vector with covariance matrix $\Sigma_{w_k} \in \mathbb R^{d_x \times d_x}$, and $\text{Cov}(w_k,w_\ell) = 0$ if $k \neq \ell$ and $\text{Cov}(w_k,w_\ell) = \Sigma_{w_k}$ if $k = \ell$. We assume that the states $x_k$, for $k \in \{0,\dots,N-1\}$, are not observed directly, but via measurements $y_k$, which are related to $x_k$ by the following observation equation $$ y_k = C_k x_k + v_k $$ where $y_k \in \mathbb R^{d_y}$ is the measurement of $x_k$ at time-step $k$, $C_k \in \mathbb R^{d_y \times d_x}$ is the observation matrix at time-step $k$, $v_k \sim N(0,\Sigma_{v_k})$ is a multivariate Gaussian random vector with covariance matrix $\Sigma_{v_k} \in \mathbb R^{d_y \times d_y}$, and $\text{Cov}(v_k,v_\ell) = 0$ if $k \neq \ell$ and $\text{Cov}(v_k,v_\ell) = \Sigma_{v_k}$ if $k = \ell$. The state of the Kalman filter, denoted $\hat x_{k/k-1}$, and the covariance of $\hat x_{k/k-1}$ conditioned on the observed measurements, denoted $\widehat \Sigma_{k/k-1}$, evolve according to the following measurement and time update equations $$ \begin{align} \text{Measurement update equations} \\ K_k &= \Sigma_{k/k-1} C_{k}^T (C_k \Sigma_{k/k-1} C_k^T + \Sigma_{v_{k}})^{-1} \\ \hat x_{k/k} &= \hat x_{k/k-1} + K_k (y_k - C_k \hat x_{k/k-1}) \label{eq:innov} \tag{1} \\ \widehat \Sigma_{k/k} &= (I - K_k C_k) \widehat \Sigma_{k/k-1} (I - K_k C_k)^T + K_k \Sigma_{v_{k}} K_k^T \\ \text{Time update equations} \\ \hat x_{k/k-1} &= A_k \hat x_{k-1/k-1} + B_k u_k \\ \widehat \Sigma_{k/k-1} &= A_k \widehat \Sigma_{k-1/k-1} A_k^T + \Sigma_{w_k} \end{align} $$ The Innovation Sequence The term $\nu_{k/k-1} = y_k - C_k \hat x_{k/k-1}$ in equation $\eqref{eq:innov}$ is known as the innovation at time-step $k$, which is the difference between the measurement $y_k$ and an estimate of $y_k$ obtained using previous measurements, which is denoted as $$ \begin{align} \hat y_{k/k-1} &= E[y_k \mid y_{k-1},\dots,y_0] \\ &= E[C_k x_k + v_k \mid y_{k-1},\dots,y_0] \\ &= E[C_k x_k \mid y_{k-1},\dots,y_0] + E[v_k \mid y_{k-1},\dots,y_0] \\ &= C_k E[x_k \mid y_{k-1},\dots,y_0] + E[v_k] \\ &= C_k \hat x_{k/k-1} \end{align} $$ Then, the innovation is $\nu_{k/k-1} = y_k - \hat y_{k/k-1}$. Intuitively, the innovation represents the amount of new information we get by observing $y_k$, since $\hat y_{k/k-1}$ was estimated using only previous measurements up to time-step $k-1$. Moreover, note that the innovation can also be re-written as $$ \begin{align} \nu_{k/k-1} &= y_k - C_k \hat x_{k/k-1} \\ &= C_kx_k + v_k - C_k \hat x_{k/k-1} \\ &= C_k (x_k - \hat x_{k/k-1}) + v_k \end{align} $$ We see that when $x_k = \hat x_{k/k-1}$, the only new information we obtain is the observation noise $v_k$. Ideally, this is what we want. The innovation sequence $\nu_{k/k-1}$, for $k \in \{0,\dots,N-1\}$, has several nice properties that can allow us to verify that a Kalman filter is operating as intended. One of the the properties of the innovation sequence $\nu_{k/k-1}$ is that it has zero mean conditioned on the previous measurements, since $$ \begin{align} E[\nu_{k/k-1} \mid y_{k-1},\dots,y_0] &= E[y_k - C_k \hat x_{k/k-1} \mid y_{k-1},\dots,y_0] \\ &= E[y_k \mid y_{k-1},\dots,y_0] - E[C_k \hat x_{k/k-1} \mid y_{k-1},\dots,y_0] \\ &= \hat y_{k/k-1} - C_k \hat x_{k/k-1} \\ &= 0 \end{align} $$ Another important property is that $\nu_{k/k-1}$ is uncorrelated, given previous measurements, from $\nu_{\ell/\ell-1}$ for $k \neq \ell$. To prove this, first suppose that $k < \ell$. Then, $$ \begin{align} \text{Cov}(\nu_{k/k-1},\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0) &= E[(\nu_{k/k-1} - E[\nu_{k/k-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0])(\nu_{\ell/\ell-1} - E[\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0])^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[(\nu_{k/k-1} - (y_k - C_k \hat x_{k/k-1}))\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T - y_k\nu_{\ell/\ell-1}^T + C_k \hat x_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - y_k E[\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + C_k \hat x_{k/k-1}E[\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[(y_k - \hat y_{k/k-1})(y_\ell - \hat y_{\ell/\ell-1})^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[y_k y_\ell^T - y_k \hat y_{\ell/\ell-1}^T - \hat y_{k/k-1} y_\ell^T + \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[y_k y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[y_k \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[\hat y_{k/k-1} y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + E[\hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= y_k E[y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - y_k E[\hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[\hat y_{k/k-1} y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + E[\hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= y_k \hat y_{\ell/\ell-1}^T - y_k \hat y_{\ell/\ell-1}^T - \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T + \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \\ &= 0 \end{align} $$ A similar proof can be obtained for the case when $k > \ell$. Therefore, $\text{Cov}(\nu_{k/k-1},\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0) = 0$ when $k \neq \ell$. To determine $\text{Cov}(\nu_{k/k-1},\nu_{k/k-1} \mid y_{k-1},\dots,y_0)$, first note that, as mentioned above, the innovation can be re-written as $$ \begin{align} \nu_{k/k-1} &= C_k (x_k - \hat x_{k/k-1}) + v_k \\ &= C_k e_k + v_k \end{align} $$ where $e_k = x_k - \hat x_{k/k-1}$, $E[e_k \mid y_{k-1},\dots,y_0] = 0$, and $E[e_k e_k^T \mid y_{k-1},\dots,y_0] = \widehat \Sigma_{k/k-1}$. Then, $$ \begin{align} \text{Cov}(\nu_{k/k-1},\nu_{k/k-1} \mid y_{k-1},\dots,y_0) &= E[\nu_{k/k-1} \nu_{k/k-1}^T\mid y_{k-1},\dots,y_0] \\ &= E[(C_k e_k + v_k) (C_k e_k + v_k)^T \mid y_{k-1},\dots,y_0] \\ &= E[C_k e_k e_k^T C_k^T + C_k e_k v_k^T + v_k e_k^T C_k^T + v_k v_k^T \mid y_{k-1},\dots,y_0] \\ &= C_k E[e_k e_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k v_k^T \mid y_{k-1},\dots,y_0] \\ &= C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k} %&= E[(y_k - \hat y_{k/k-1}) (y_k - \hat y_{k/k-1})^T\mid y_{k-1},\dots,y_0] \\ %&= E[y_k y_k^T - y_k \hat y_{k/k-1}^T - \hat y_{k/k-1} y_k^T + \hat y_{k/k-1} \hat y_{k/k-1}^T\mid y_{k-1},\dots,y_0] \\ %&= E[y_k y_k^T \mid y_{k-1},\dots,y_0] - E[y_k \hat y_{k/k-1}^T \mid y_{k-1},\dots,y_0] - E[\hat y_{k/k-1} y_k^T \mid y_{k-1},\dots,y_0] + E[\hat y_{k/k-1} \hat y_{k/k-1}^T \mid y_{k-1},\dots,y_0] \\ %&= E[(C_k x_k + v_k) (C_k x_k + v_k)^T \mid y_{k-1},\dots,y_0] - E[y_k \mid y_{k-1},\dots,y_0]\hat y_{k/k-1}^T - \hat y_{k/k-1} E[y_k^T \mid y_{k-1},\dots,y_0] + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= E[C_k x_k x_k^T C_k^T + C_k x_k v_k + v_k x_k^T C_k^T + v_k v_k^T \mid y_{k-1},\dots,y_0] - E[C_k x_k + v_k \mid y_{k-1},\dots,y_0]\hat y_{k/k-1}^T - \hat y_{k/k-1} E[x_k^T C_k^T + v_k^T \mid y_{k-1},\dots,y_0] + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= C_k E[x_k x_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k v_k^T] - (C_k E[x_k \mid y_{k-1},\dots,y_0] + E[v_k]) \hat y_{k/k-1}^T - \hat y_{k/k-1} (E[x_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k^T]) + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k} - C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T - C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T + C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T \\ \end{align} $$ Because $x_k$ is Gaussian, then the innovation $\nu_{k/k-1}$ is also Gaussian, with mean $0$ and covariance $C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k}$. Additionally, because each $\nu_{k/k-1}$ are uncorrelated, and because $a\nu_{k/k-1} + b\nu_{\ell/\ell-1}$ is Gaussian distributed for $a,b \in \mathbb R$ and $k \neq \ell$, then $\nu_{k/k-1}$ is independent of $\nu_{\ell/\ell-1}$ for $k \neq \ell$. Furthermore, if we let $$ q_{k/k-1} = \Sigma_{\nu_{k}}^{-\frac{1}{2}} \nu_{k/k-1} $$ where $\Sigma_{\nu_v} = C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k}$ is the covariance of $\nu_{k/k-1}$ and $\Sigma_{\nu_{k}}^{-\frac{1}{2}}$ is the inverse of its square root, then $q_{k/k-1}$ is Gaussian distributed with mean $0$ and covariance $$ \begin{align} E[q_{k/k-1} q_{k/k-1}^T] &= E\left[\Sigma_{\nu_{k}}^{-\frac{1}{2}} \nu_{k/k-1} \nu_{k/k-1}^T \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}}\right] \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} E[\nu_{k/k-1} \nu_{k/k-1}^T] \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} \Sigma_{\nu_k} \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} \Sigma_{\nu_{k}}^{\frac{1}{2}} \Sigma_{\nu_{k}}^{\frac{1}{2}^{T}} \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= I \end{align} $$ for each $k$. That is, $q_{k/k-1}$ is a sequence of independent and identically distributed (i.i.d) random vectors. Because of this, we can consider the entire sequence of $q_{k/k-1}$, for $k \in \{0,\dots,N-1\}$, to be i.i.d samples of a single random vector $q$. To summarize, the important properties of $\nu_{k/k-1}$ and $q_{k/k-1}$ are: $\nu_{k/k-1} \sim N(0,C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k})$ $\nu_{k/k-1}$ is independent of (and uncorrelated to) $\nu_{\ell/\ell-1}$ for $k \neq \ell$ $q_{k/k-1}$ is a sequence of independent (and uncorrelated) and identically distributed Gaussian random vectors with mean $0$ and covariance $I$. The Tests If a Kalman filter is implemented correctly, then the properties of $q_{k/k-1}$ mentioned above should be true. Equivalently, if the properties of $q_{k/k-1}$ mentioned above are not true, then the Kalman filter is not implemented correctly. Therefore, we need to check that: $q_{k/k-1}$ is independent of (or uncorrelated to) $q_{\ell/\ell-1}$ for $k \neq \ell$. That each $q_{k/k-1}$ has mean $0$ and covariance $I$. That each $q_{k/k-1}$ is Gaussian distributed. For steps on how to perform these tests, see section 2.2.3, page 18, of the lecture notes mentioned at the top of this answer.
How can I debug and check the consistency of a Kalman filter?
As a follow up to @Marcel's answer, here is a more detailed explanation of how to debug and check the consistency of a Kalman filter. This explanation is an expansion of the one from section 2.2.3, pa
How can I debug and check the consistency of a Kalman filter? As a follow up to @Marcel's answer, here is a more detailed explanation of how to debug and check the consistency of a Kalman filter. This explanation is an expansion of the one from section 2.2.3, page 18, of the lecture notes titled Estimation II written by Ian Reid at Oxford in 2001, which is the same set of lecture notes that @Marcel links to in his answer. Overview Recall that the Kalman filter is an optimal observer for a linear, time-varying, and discrete-time system that evolves according to the following state equation $$ \begin{align} x_{k+1} &= A_k x_k + B_k u_k + w_k \end{align} $$ where $x_k \in \mathbb R^{d_x}$ is the state vector at time-step $k$, $A_k \in \mathbb R^{d_x \times d_x}$ is the state-transition matrix at time-step $k$, $u_k \in \mathbb R^{d_u}$ is the control input at time-step $k$, $B_k \in \mathbb R^{d_x \times d_u}$ is the control matrix at time-step $k$, $w_k \sim N(0,\Sigma_{w_k})$ is a multivariate Gaussian random vector with covariance matrix $\Sigma_{w_k} \in \mathbb R^{d_x \times d_x}$, and $\text{Cov}(w_k,w_\ell) = 0$ if $k \neq \ell$ and $\text{Cov}(w_k,w_\ell) = \Sigma_{w_k}$ if $k = \ell$. We assume that the states $x_k$, for $k \in \{0,\dots,N-1\}$, are not observed directly, but via measurements $y_k$, which are related to $x_k$ by the following observation equation $$ y_k = C_k x_k + v_k $$ where $y_k \in \mathbb R^{d_y}$ is the measurement of $x_k$ at time-step $k$, $C_k \in \mathbb R^{d_y \times d_x}$ is the observation matrix at time-step $k$, $v_k \sim N(0,\Sigma_{v_k})$ is a multivariate Gaussian random vector with covariance matrix $\Sigma_{v_k} \in \mathbb R^{d_y \times d_y}$, and $\text{Cov}(v_k,v_\ell) = 0$ if $k \neq \ell$ and $\text{Cov}(v_k,v_\ell) = \Sigma_{v_k}$ if $k = \ell$. The state of the Kalman filter, denoted $\hat x_{k/k-1}$, and the covariance of $\hat x_{k/k-1}$ conditioned on the observed measurements, denoted $\widehat \Sigma_{k/k-1}$, evolve according to the following measurement and time update equations $$ \begin{align} \text{Measurement update equations} \\ K_k &= \Sigma_{k/k-1} C_{k}^T (C_k \Sigma_{k/k-1} C_k^T + \Sigma_{v_{k}})^{-1} \\ \hat x_{k/k} &= \hat x_{k/k-1} + K_k (y_k - C_k \hat x_{k/k-1}) \label{eq:innov} \tag{1} \\ \widehat \Sigma_{k/k} &= (I - K_k C_k) \widehat \Sigma_{k/k-1} (I - K_k C_k)^T + K_k \Sigma_{v_{k}} K_k^T \\ \text{Time update equations} \\ \hat x_{k/k-1} &= A_k \hat x_{k-1/k-1} + B_k u_k \\ \widehat \Sigma_{k/k-1} &= A_k \widehat \Sigma_{k-1/k-1} A_k^T + \Sigma_{w_k} \end{align} $$ The Innovation Sequence The term $\nu_{k/k-1} = y_k - C_k \hat x_{k/k-1}$ in equation $\eqref{eq:innov}$ is known as the innovation at time-step $k$, which is the difference between the measurement $y_k$ and an estimate of $y_k$ obtained using previous measurements, which is denoted as $$ \begin{align} \hat y_{k/k-1} &= E[y_k \mid y_{k-1},\dots,y_0] \\ &= E[C_k x_k + v_k \mid y_{k-1},\dots,y_0] \\ &= E[C_k x_k \mid y_{k-1},\dots,y_0] + E[v_k \mid y_{k-1},\dots,y_0] \\ &= C_k E[x_k \mid y_{k-1},\dots,y_0] + E[v_k] \\ &= C_k \hat x_{k/k-1} \end{align} $$ Then, the innovation is $\nu_{k/k-1} = y_k - \hat y_{k/k-1}$. Intuitively, the innovation represents the amount of new information we get by observing $y_k$, since $\hat y_{k/k-1}$ was estimated using only previous measurements up to time-step $k-1$. Moreover, note that the innovation can also be re-written as $$ \begin{align} \nu_{k/k-1} &= y_k - C_k \hat x_{k/k-1} \\ &= C_kx_k + v_k - C_k \hat x_{k/k-1} \\ &= C_k (x_k - \hat x_{k/k-1}) + v_k \end{align} $$ We see that when $x_k = \hat x_{k/k-1}$, the only new information we obtain is the observation noise $v_k$. Ideally, this is what we want. The innovation sequence $\nu_{k/k-1}$, for $k \in \{0,\dots,N-1\}$, has several nice properties that can allow us to verify that a Kalman filter is operating as intended. One of the the properties of the innovation sequence $\nu_{k/k-1}$ is that it has zero mean conditioned on the previous measurements, since $$ \begin{align} E[\nu_{k/k-1} \mid y_{k-1},\dots,y_0] &= E[y_k - C_k \hat x_{k/k-1} \mid y_{k-1},\dots,y_0] \\ &= E[y_k \mid y_{k-1},\dots,y_0] - E[C_k \hat x_{k/k-1} \mid y_{k-1},\dots,y_0] \\ &= \hat y_{k/k-1} - C_k \hat x_{k/k-1} \\ &= 0 \end{align} $$ Another important property is that $\nu_{k/k-1}$ is uncorrelated, given previous measurements, from $\nu_{\ell/\ell-1}$ for $k \neq \ell$. To prove this, first suppose that $k < \ell$. Then, $$ \begin{align} \text{Cov}(\nu_{k/k-1},\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0) &= E[(\nu_{k/k-1} - E[\nu_{k/k-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0])(\nu_{\ell/\ell-1} - E[\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0])^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[(\nu_{k/k-1} - (y_k - C_k \hat x_{k/k-1}))\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T - y_k\nu_{\ell/\ell-1}^T + C_k \hat x_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - y_k E[\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + C_k \hat x_{k/k-1}E[\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[\nu_{k/k-1}\nu_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[(y_k - \hat y_{k/k-1})(y_\ell - \hat y_{\ell/\ell-1})^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[y_k y_\ell^T - y_k \hat y_{\ell/\ell-1}^T - \hat y_{k/k-1} y_\ell^T + \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= E[y_k y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[y_k \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[\hat y_{k/k-1} y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + E[\hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= y_k E[y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - y_k E[\hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] - E[\hat y_{k/k-1} y_\ell^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] + E[\hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \mid y_{\ell-1},\dots,y_k,\dots,y_0] \\ &= y_k \hat y_{\ell/\ell-1}^T - y_k \hat y_{\ell/\ell-1}^T - \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T + \hat y_{k/k-1} \hat y_{\ell/\ell-1}^T \\ &= 0 \end{align} $$ A similar proof can be obtained for the case when $k > \ell$. Therefore, $\text{Cov}(\nu_{k/k-1},\nu_{\ell/\ell-1} \mid y_{\ell-1},\dots,y_k,\dots,y_0) = 0$ when $k \neq \ell$. To determine $\text{Cov}(\nu_{k/k-1},\nu_{k/k-1} \mid y_{k-1},\dots,y_0)$, first note that, as mentioned above, the innovation can be re-written as $$ \begin{align} \nu_{k/k-1} &= C_k (x_k - \hat x_{k/k-1}) + v_k \\ &= C_k e_k + v_k \end{align} $$ where $e_k = x_k - \hat x_{k/k-1}$, $E[e_k \mid y_{k-1},\dots,y_0] = 0$, and $E[e_k e_k^T \mid y_{k-1},\dots,y_0] = \widehat \Sigma_{k/k-1}$. Then, $$ \begin{align} \text{Cov}(\nu_{k/k-1},\nu_{k/k-1} \mid y_{k-1},\dots,y_0) &= E[\nu_{k/k-1} \nu_{k/k-1}^T\mid y_{k-1},\dots,y_0] \\ &= E[(C_k e_k + v_k) (C_k e_k + v_k)^T \mid y_{k-1},\dots,y_0] \\ &= E[C_k e_k e_k^T C_k^T + C_k e_k v_k^T + v_k e_k^T C_k^T + v_k v_k^T \mid y_{k-1},\dots,y_0] \\ &= C_k E[e_k e_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k v_k^T \mid y_{k-1},\dots,y_0] \\ &= C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k} %&= E[(y_k - \hat y_{k/k-1}) (y_k - \hat y_{k/k-1})^T\mid y_{k-1},\dots,y_0] \\ %&= E[y_k y_k^T - y_k \hat y_{k/k-1}^T - \hat y_{k/k-1} y_k^T + \hat y_{k/k-1} \hat y_{k/k-1}^T\mid y_{k-1},\dots,y_0] \\ %&= E[y_k y_k^T \mid y_{k-1},\dots,y_0] - E[y_k \hat y_{k/k-1}^T \mid y_{k-1},\dots,y_0] - E[\hat y_{k/k-1} y_k^T \mid y_{k-1},\dots,y_0] + E[\hat y_{k/k-1} \hat y_{k/k-1}^T \mid y_{k-1},\dots,y_0] \\ %&= E[(C_k x_k + v_k) (C_k x_k + v_k)^T \mid y_{k-1},\dots,y_0] - E[y_k \mid y_{k-1},\dots,y_0]\hat y_{k/k-1}^T - \hat y_{k/k-1} E[y_k^T \mid y_{k-1},\dots,y_0] + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= E[C_k x_k x_k^T C_k^T + C_k x_k v_k + v_k x_k^T C_k^T + v_k v_k^T \mid y_{k-1},\dots,y_0] - E[C_k x_k + v_k \mid y_{k-1},\dots,y_0]\hat y_{k/k-1}^T - \hat y_{k/k-1} E[x_k^T C_k^T + v_k^T \mid y_{k-1},\dots,y_0] + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= C_k E[x_k x_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k v_k^T] - (C_k E[x_k \mid y_{k-1},\dots,y_0] + E[v_k]) \hat y_{k/k-1}^T - \hat y_{k/k-1} (E[x_k^T \mid y_{k-1},\dots,y_0] C_k^T + E[v_k^T]) + \hat y_{k/k-1} \hat y_{k/k-1}^T \\ %&= C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k} - C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T - C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T + C_k \hat x_{k/k-1} \hat x_{k/k-1}^T C_k^T \\ \end{align} $$ Because $x_k$ is Gaussian, then the innovation $\nu_{k/k-1}$ is also Gaussian, with mean $0$ and covariance $C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k}$. Additionally, because each $\nu_{k/k-1}$ are uncorrelated, and because $a\nu_{k/k-1} + b\nu_{\ell/\ell-1}$ is Gaussian distributed for $a,b \in \mathbb R$ and $k \neq \ell$, then $\nu_{k/k-1}$ is independent of $\nu_{\ell/\ell-1}$ for $k \neq \ell$. Furthermore, if we let $$ q_{k/k-1} = \Sigma_{\nu_{k}}^{-\frac{1}{2}} \nu_{k/k-1} $$ where $\Sigma_{\nu_v} = C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k}$ is the covariance of $\nu_{k/k-1}$ and $\Sigma_{\nu_{k}}^{-\frac{1}{2}}$ is the inverse of its square root, then $q_{k/k-1}$ is Gaussian distributed with mean $0$ and covariance $$ \begin{align} E[q_{k/k-1} q_{k/k-1}^T] &= E\left[\Sigma_{\nu_{k}}^{-\frac{1}{2}} \nu_{k/k-1} \nu_{k/k-1}^T \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}}\right] \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} E[\nu_{k/k-1} \nu_{k/k-1}^T] \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} \Sigma_{\nu_k} \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= \Sigma_{\nu_{k}}^{-\frac{1}{2}} \Sigma_{\nu_{k}}^{\frac{1}{2}} \Sigma_{\nu_{k}}^{\frac{1}{2}^{T}} \Sigma_{\nu_{k}}^{-\frac{1}{2}^{T}} \\ &= I \end{align} $$ for each $k$. That is, $q_{k/k-1}$ is a sequence of independent and identically distributed (i.i.d) random vectors. Because of this, we can consider the entire sequence of $q_{k/k-1}$, for $k \in \{0,\dots,N-1\}$, to be i.i.d samples of a single random vector $q$. To summarize, the important properties of $\nu_{k/k-1}$ and $q_{k/k-1}$ are: $\nu_{k/k-1} \sim N(0,C_k \widehat \Sigma_{k/k-1} C_k^T + \Sigma_{v_k})$ $\nu_{k/k-1}$ is independent of (and uncorrelated to) $\nu_{\ell/\ell-1}$ for $k \neq \ell$ $q_{k/k-1}$ is a sequence of independent (and uncorrelated) and identically distributed Gaussian random vectors with mean $0$ and covariance $I$. The Tests If a Kalman filter is implemented correctly, then the properties of $q_{k/k-1}$ mentioned above should be true. Equivalently, if the properties of $q_{k/k-1}$ mentioned above are not true, then the Kalman filter is not implemented correctly. Therefore, we need to check that: $q_{k/k-1}$ is independent of (or uncorrelated to) $q_{\ell/\ell-1}$ for $k \neq \ell$. That each $q_{k/k-1}$ has mean $0$ and covariance $I$. That each $q_{k/k-1}$ is Gaussian distributed. For steps on how to perform these tests, see section 2.2.3, page 18, of the lecture notes mentioned at the top of this answer.
How can I debug and check the consistency of a Kalman filter? As a follow up to @Marcel's answer, here is a more detailed explanation of how to debug and check the consistency of a Kalman filter. This explanation is an expansion of the one from section 2.2.3, pa
42,164
How to assess overdispersion in Poisson GLMM, lmer( )
My general preference, when comparing a more complex model (here, NB) to a less complex one (here Poisson) is not to rely on any statistical test, but to run both and see if the predicted values are substantially different. (And what 'substantially' means is dependent on the field you are working in). If they are, then prefer the more complex model. If not, the simpler. This allows us not to rely on arbitrary cutoffs; it requires us to employ judgement. Those are, in my opinion, good things.
How to assess overdispersion in Poisson GLMM, lmer( )
My general preference, when comparing a more complex model (here, NB) to a less complex one (here Poisson) is not to rely on any statistical test, but to run both and see if the predicted values are s
How to assess overdispersion in Poisson GLMM, lmer( ) My general preference, when comparing a more complex model (here, NB) to a less complex one (here Poisson) is not to rely on any statistical test, but to run both and see if the predicted values are substantially different. (And what 'substantially' means is dependent on the field you are working in). If they are, then prefer the more complex model. If not, the simpler. This allows us not to rely on arbitrary cutoffs; it requires us to employ judgement. Those are, in my opinion, good things.
How to assess overdispersion in Poisson GLMM, lmer( ) My general preference, when comparing a more complex model (here, NB) to a less complex one (here Poisson) is not to rely on any statistical test, but to run both and see if the predicted values are s
42,165
Simulation of forecasted values in ARIMA (0,1,1)
There are a couple of problems with your code: The default prediction intervals are 80% and 95%, but you simulate 90% intervals. The forecasts should use the last residual in the first forecast. Your ma coefficient is applied to $e_t$ rather than $e_{t-1}$. Here is some corrected code: library(forecast) f4 <- Arima(WWWusage, order=c(0,1,1), include.drift=TRUE) f4.f <- forecast(f4, h=21, level=90) mean.exact.f <- f4.f$mean U.exact.f <- f4.f$upper L.exact.f <- f4.f$lower ff.sim <- function(m,h,N) { sigma.est <- m$sigma ma1.est <- coef(m)[1] drf.est <- coef(m)[2] ff <- matrix(0,ncol=N,nrow=(h+1)) for(j in 1:N) { ff[1,j] <- m$x[length(m$x)] e <- c(m$residuals[length(m$x)],rnorm(h,0,sqrt(sigma.est))) for(i in 2:(h+1)) ff[i,j] <- ff[i-1,j]+drf.est+ma1.est*e[i-1]+e[i] } return(list(ff=ff[-1,])) } f.sim <- ff.sim(f4,21,10000)$ff mean.sim <-apply(f.sim,1,mean) U.sim <-apply(f.sim,1,quantile, probs = c(.95)) L.sim <-apply(f.sim,1,quantile, probs = c(.05)) plot(1:21,mean.exact.f,type="l", ylim=range(mean.sim,U.sim,L.sim,mean.exact.f,U.exact.f,L.exact.f), xlab="t", col="blue", main="Simulated (green) & Exact (blue), forecasted mean and 95% C.I.") points(1:21,U.exact.f,type="l",col="blue") points(1:21,L.exact.f,type="l",col="blue") points(1:21,mean.sim,type="l",col="green") points(1:21,U.sim,type="l",col="green") points(1:21,L.sim,type="l",col="green") You should get the blue and green lines almost identical now.
Simulation of forecasted values in ARIMA (0,1,1)
There are a couple of problems with your code: The default prediction intervals are 80% and 95%, but you simulate 90% intervals. The forecasts should use the last residual in the first forecast. Your
Simulation of forecasted values in ARIMA (0,1,1) There are a couple of problems with your code: The default prediction intervals are 80% and 95%, but you simulate 90% intervals. The forecasts should use the last residual in the first forecast. Your ma coefficient is applied to $e_t$ rather than $e_{t-1}$. Here is some corrected code: library(forecast) f4 <- Arima(WWWusage, order=c(0,1,1), include.drift=TRUE) f4.f <- forecast(f4, h=21, level=90) mean.exact.f <- f4.f$mean U.exact.f <- f4.f$upper L.exact.f <- f4.f$lower ff.sim <- function(m,h,N) { sigma.est <- m$sigma ma1.est <- coef(m)[1] drf.est <- coef(m)[2] ff <- matrix(0,ncol=N,nrow=(h+1)) for(j in 1:N) { ff[1,j] <- m$x[length(m$x)] e <- c(m$residuals[length(m$x)],rnorm(h,0,sqrt(sigma.est))) for(i in 2:(h+1)) ff[i,j] <- ff[i-1,j]+drf.est+ma1.est*e[i-1]+e[i] } return(list(ff=ff[-1,])) } f.sim <- ff.sim(f4,21,10000)$ff mean.sim <-apply(f.sim,1,mean) U.sim <-apply(f.sim,1,quantile, probs = c(.95)) L.sim <-apply(f.sim,1,quantile, probs = c(.05)) plot(1:21,mean.exact.f,type="l", ylim=range(mean.sim,U.sim,L.sim,mean.exact.f,U.exact.f,L.exact.f), xlab="t", col="blue", main="Simulated (green) & Exact (blue), forecasted mean and 95% C.I.") points(1:21,U.exact.f,type="l",col="blue") points(1:21,L.exact.f,type="l",col="blue") points(1:21,mean.sim,type="l",col="green") points(1:21,U.sim,type="l",col="green") points(1:21,L.sim,type="l",col="green") You should get the blue and green lines almost identical now.
Simulation of forecasted values in ARIMA (0,1,1) There are a couple of problems with your code: The default prediction intervals are 80% and 95%, but you simulate 90% intervals. The forecasts should use the last residual in the first forecast. Your
42,166
Why do we take the absolute value in a hypothesis test?
The absolute value is taken merely to give a concise way to define extremes in both directions. So |T|>=|t$_0$| simply means T>=|t$_0$| or T<=-|t$_0$|.
Why do we take the absolute value in a hypothesis test?
The absolute value is taken merely to give a concise way to define extremes in both directions. So |T|>=|t$_0$| simply means T>=|t$_0$| or T<=-|t$_0$|.
Why do we take the absolute value in a hypothesis test? The absolute value is taken merely to give a concise way to define extremes in both directions. So |T|>=|t$_0$| simply means T>=|t$_0$| or T<=-|t$_0$|.
Why do we take the absolute value in a hypothesis test? The absolute value is taken merely to give a concise way to define extremes in both directions. So |T|>=|t$_0$| simply means T>=|t$_0$| or T<=-|t$_0$|.
42,167
Ranking randomly distributed variables based on decreasingness
Instead of approximating a really small probability, then rescaling it by something huge (like $44! \approx 2.7 \times 10^54$) you would do better to compute integer-valued statistics such as the count of values $i$ so that $O_i \gt O_{i+1}$. This will be a more efficient use of any MonteCarlo runs you perform. One idea which has been studied a lot by mathematicians is the number of inversions, pairs $i \lt j$ where $O_i \gt O_j$. For a uniformly random permutation, the number of inversions is a sum of independent discrete uniform distributions $$ \sum_{i=1}^n U[\lbrace 0, 1, ..., i-1 \rbrace] $$ and as $n \to \infty$ this is asymptotically normal with mean ${n \choose 2}/2$ and standard deviation $\sqrt{(2n^3 + 3n^2-5n)/72} = n^{3/2}/6 + O(n).$ I don't know of a closed form expression for the number of permutations of $n$ with exactly/at least $i$ inversions but there are recursions which are fast enough for much larger $n$ than you are using. Let $I(n,i)$ be the number of permutations of $n$ with exactly $i$ inversions. Then $$ I(n,i) = \sum_{j=0}^{i-1} I(n-1,i-j)$$ by conditioning on the last uniform random variable above.
Ranking randomly distributed variables based on decreasingness
Instead of approximating a really small probability, then rescaling it by something huge (like $44! \approx 2.7 \times 10^54$) you would do better to compute integer-valued statistics such as the coun
Ranking randomly distributed variables based on decreasingness Instead of approximating a really small probability, then rescaling it by something huge (like $44! \approx 2.7 \times 10^54$) you would do better to compute integer-valued statistics such as the count of values $i$ so that $O_i \gt O_{i+1}$. This will be a more efficient use of any MonteCarlo runs you perform. One idea which has been studied a lot by mathematicians is the number of inversions, pairs $i \lt j$ where $O_i \gt O_j$. For a uniformly random permutation, the number of inversions is a sum of independent discrete uniform distributions $$ \sum_{i=1}^n U[\lbrace 0, 1, ..., i-1 \rbrace] $$ and as $n \to \infty$ this is asymptotically normal with mean ${n \choose 2}/2$ and standard deviation $\sqrt{(2n^3 + 3n^2-5n)/72} = n^{3/2}/6 + O(n).$ I don't know of a closed form expression for the number of permutations of $n$ with exactly/at least $i$ inversions but there are recursions which are fast enough for much larger $n$ than you are using. Let $I(n,i)$ be the number of permutations of $n$ with exactly $i$ inversions. Then $$ I(n,i) = \sum_{j=0}^{i-1} I(n-1,i-j)$$ by conditioning on the last uniform random variable above.
Ranking randomly distributed variables based on decreasingness Instead of approximating a really small probability, then rescaling it by something huge (like $44! \approx 2.7 \times 10^54$) you would do better to compute integer-valued statistics such as the coun
42,168
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
I've seen the two terms are sometimes used synonymously, and they're both an attempt to control for a particular type of confounding, namely that some patients have a set of covariate risk factors the predispose them to the outcome. Generally speaking, I've found "case-mix" most often used in studies where the unit of comparison is the study site. For example, when comparing the incidence of surgical errors at Hospital A versus Hospital B, one might wish to control for the fact that Hospital A is a major regional teaching hospital that gets very complex cases. If you were exposed to any of the controversy regarding the Consumer Reports rating of hospitals based on their infection rates, and rating some very prestigious hospitals poorly while giving high marks to obscure local hospitals, this is essentially a working example of having failed to adjust for case mix. "Risk adjustment", in contrast, I find most often used when the unit of comparison is the patient. For example, if you want to compare the risk of death for patients given Drug A versus Drug B, there's the possibility that, because you aren't randomly assigning the drugs in this example, those on Drug A are somehow different. Say Drug B is known to be hard on the kidneys - you wouldn't give Drug B to patients on kidney dialysis. Which means the study subjects using Drug A are worse off generally, beyond the efficacy of the drug itself. In both cases, there are a number of ways to adjust for them. You can stratify with small numbers, match using something like a propensity score, include some measure of case-mix or risk (I prefer particular covariates, some people favor composite risk scores like APACHE II) as a covariate in a regression model, or ever more sophisticated techniques to try to arrive at an unbiased estimate. But what it comes down to is "Some people are sicker than others, and that may not be random".
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
I've seen the two terms are sometimes used synonymously, and they're both an attempt to control for a particular type of confounding, namely that some patients have a set of covariate risk factors the
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? I've seen the two terms are sometimes used synonymously, and they're both an attempt to control for a particular type of confounding, namely that some patients have a set of covariate risk factors the predispose them to the outcome. Generally speaking, I've found "case-mix" most often used in studies where the unit of comparison is the study site. For example, when comparing the incidence of surgical errors at Hospital A versus Hospital B, one might wish to control for the fact that Hospital A is a major regional teaching hospital that gets very complex cases. If you were exposed to any of the controversy regarding the Consumer Reports rating of hospitals based on their infection rates, and rating some very prestigious hospitals poorly while giving high marks to obscure local hospitals, this is essentially a working example of having failed to adjust for case mix. "Risk adjustment", in contrast, I find most often used when the unit of comparison is the patient. For example, if you want to compare the risk of death for patients given Drug A versus Drug B, there's the possibility that, because you aren't randomly assigning the drugs in this example, those on Drug A are somehow different. Say Drug B is known to be hard on the kidneys - you wouldn't give Drug B to patients on kidney dialysis. Which means the study subjects using Drug A are worse off generally, beyond the efficacy of the drug itself. In both cases, there are a number of ways to adjust for them. You can stratify with small numbers, match using something like a propensity score, include some measure of case-mix or risk (I prefer particular covariates, some people favor composite risk scores like APACHE II) as a covariate in a regression model, or ever more sophisticated techniques to try to arrive at an unbiased estimate. But what it comes down to is "Some people are sicker than others, and that may not be random".
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? I've seen the two terms are sometimes used synonymously, and they're both an attempt to control for a particular type of confounding, namely that some patients have a set of covariate risk factors the
42,169
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
I do not think there is any real difference between "case-mix adjustment" and "risk adjustment" in this context. I would say the terms are used interchangeably. They refer to adjusting for confounding due to patient ("case") mix, or the patients' risks of the outcome being examined. Funders often want to compare hospitals based on indicators such as 30-day mortality (proportion of patients who die within 30 days of discharge from the hospital). But the hospitals can have quite different types of patients. One hospital may have a nursing home down the road, and treat many older patients with multiple chronic conditions. Another may be located near a major highway and treat many emergency trauma patients from motor vehicle accidents. Any comparison of the hospitals needs to somehow adjust for these differences in case mix. In practice adjustment is usually through some form of logistic regression (generally hierarchical to account for clustering within hospitals), either directly including patient characteristics, or calculating and using a propensity score for how likely a patient is to be treated at a particular hospital.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
I do not think there is any real difference between "case-mix adjustment" and "risk adjustment" in this context. I would say the terms are used interchangeably. They refer to adjusting for confounding
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? I do not think there is any real difference between "case-mix adjustment" and "risk adjustment" in this context. I would say the terms are used interchangeably. They refer to adjusting for confounding due to patient ("case") mix, or the patients' risks of the outcome being examined. Funders often want to compare hospitals based on indicators such as 30-day mortality (proportion of patients who die within 30 days of discharge from the hospital). But the hospitals can have quite different types of patients. One hospital may have a nursing home down the road, and treat many older patients with multiple chronic conditions. Another may be located near a major highway and treat many emergency trauma patients from motor vehicle accidents. Any comparison of the hospitals needs to somehow adjust for these differences in case mix. In practice adjustment is usually through some form of logistic regression (generally hierarchical to account for clustering within hospitals), either directly including patient characteristics, or calculating and using a propensity score for how likely a patient is to be treated at a particular hospital.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? I do not think there is any real difference between "case-mix adjustment" and "risk adjustment" in this context. I would say the terms are used interchangeably. They refer to adjusting for confounding
42,170
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
http://www.rti.org/files/HHS-HCC_Risk_Adjustment_Model.pdf AdamO has asked how the terms case mix and risk adjustment are defined and used in research results posted in the medical literature, " their exact usage and motivation from a modeling perspective." My experience with case mix modeling is exclusively within health care, wherein the models seek to link patients, their diseases, and the cost of making them whole again. These are wholly operational definitions, and depend 100% on the objective of the model and the data available to the modelers, thus making "their exact usage" arguable. For instance, one might define one's population as all patients who billed Medicare in 2011, of which the Medicare Advantage portion might be 15M. One might define a case mix in terms of medical severity, eg SIRS, sepsis, septic shock, and septicemia in patients with neoplastic co-morbidities. One might define a unit of analysis as hospitals, with further control for trauma centers and community hospitals with <50 beds. One might then operationally define risk as money spent, in toto, by Medicare Advantage. The model thus far provides no method for linking our patients with our risk, so let us connect them by the bills that are paid for these patient's treatment and the diagnostic disease codes (ICD) contained therein. We are likely to discover that the community hospital has zero risk because it has transferred the risk from itself to the trauma center by transferring the patient. The community hospital provided no treatment, so it cannot bill for services. In order for our model to make more sense, let us remove the control of neoplastic co-morbidity, and focus upon blood diseases. Our patients at the trauma center are likely very different in their diagnostic code mix, their case mix, than at the community hospital. We are likely to find that the risk, the money spent, at the trauma center is less than the risk at the community hospital, mostly because the efficiencies at the trauma center far exceed the community hospital. Patients at the trauma center do not progress to more serious blood diseases, but at the community hospital, patients do get sicker, more often. For this reason, based upon the results of our case mix modeling extrapolated to our population described by the 2011 patients, Medicare might well require an adjustment in the community hospital's case mix by mandating a risk adjustment in the form of a transfer of certain diagnostic category (DRGs) patients to the trauma center. This simple example, although it has some obvious flaws, describes straight forward operational definitions of case mix, risk, and risk adjustment that have little to do with statistical analysis, and everything to do with "motivation from a modeling perspective." If you want a more sophisticated set of definitions, see the URL above. Simple rules of thumb: when you read "case mix", think disease classifications and reach for the nearest ICD-10-CM manual; when you read "risk adjustment", reach for your wallet and think money.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
http://www.rti.org/files/HHS-HCC_Risk_Adjustment_Model.pdf AdamO has asked how the terms case mix and risk adjustment are defined and used in research results posted in the medical literature, " their
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? http://www.rti.org/files/HHS-HCC_Risk_Adjustment_Model.pdf AdamO has asked how the terms case mix and risk adjustment are defined and used in research results posted in the medical literature, " their exact usage and motivation from a modeling perspective." My experience with case mix modeling is exclusively within health care, wherein the models seek to link patients, their diseases, and the cost of making them whole again. These are wholly operational definitions, and depend 100% on the objective of the model and the data available to the modelers, thus making "their exact usage" arguable. For instance, one might define one's population as all patients who billed Medicare in 2011, of which the Medicare Advantage portion might be 15M. One might define a case mix in terms of medical severity, eg SIRS, sepsis, septic shock, and septicemia in patients with neoplastic co-morbidities. One might define a unit of analysis as hospitals, with further control for trauma centers and community hospitals with <50 beds. One might then operationally define risk as money spent, in toto, by Medicare Advantage. The model thus far provides no method for linking our patients with our risk, so let us connect them by the bills that are paid for these patient's treatment and the diagnostic disease codes (ICD) contained therein. We are likely to discover that the community hospital has zero risk because it has transferred the risk from itself to the trauma center by transferring the patient. The community hospital provided no treatment, so it cannot bill for services. In order for our model to make more sense, let us remove the control of neoplastic co-morbidity, and focus upon blood diseases. Our patients at the trauma center are likely very different in their diagnostic code mix, their case mix, than at the community hospital. We are likely to find that the risk, the money spent, at the trauma center is less than the risk at the community hospital, mostly because the efficiencies at the trauma center far exceed the community hospital. Patients at the trauma center do not progress to more serious blood diseases, but at the community hospital, patients do get sicker, more often. For this reason, based upon the results of our case mix modeling extrapolated to our population described by the 2011 patients, Medicare might well require an adjustment in the community hospital's case mix by mandating a risk adjustment in the form of a transfer of certain diagnostic category (DRGs) patients to the trauma center. This simple example, although it has some obvious flaws, describes straight forward operational definitions of case mix, risk, and risk adjustment that have little to do with statistical analysis, and everything to do with "motivation from a modeling perspective." If you want a more sophisticated set of definitions, see the URL above. Simple rules of thumb: when you read "case mix", think disease classifications and reach for the nearest ICD-10-CM manual; when you read "risk adjustment", reach for your wallet and think money.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? http://www.rti.org/files/HHS-HCC_Risk_Adjustment_Model.pdf AdamO has asked how the terms case mix and risk adjustment are defined and used in research results posted in the medical literature, " their
42,171
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
In the specific context of hospital financial reporting, such as * average cost per admission, or * average revenue per admission "case-mix adjusted" is a term of art that means "DRG-adjusted". In other words, sum[of whatever] / sum[of DRG weights] for the group of patients being reported. And 99% of the time, unless specifically noted otherwise, the DRG weights used will be the Medicare weights for the appropriate time period, even if the patients aren't all Medicare. It's a simplistic adjustment, but ubiquitous in the industry. (It's been said that accountants express everything in dollars, because they can only think in one dimension. I'm not here to opine on that.) In other contexts, I agree with timbp that the terms "case-mix adjusted" and "risk adjusted" are used interchangeably, without clear distinctions. You have to look at the methodology detail to understand what's been done.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
In the specific context of hospital financial reporting, such as * average cost per admission, or * average revenue per admission "case-mix adjusted" is a term of art that means "DRG-adjusted". In o
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? In the specific context of hospital financial reporting, such as * average cost per admission, or * average revenue per admission "case-mix adjusted" is a term of art that means "DRG-adjusted". In other words, sum[of whatever] / sum[of DRG weights] for the group of patients being reported. And 99% of the time, unless specifically noted otherwise, the DRG weights used will be the Medicare weights for the appropriate time period, even if the patients aren't all Medicare. It's a simplistic adjustment, but ubiquitous in the industry. (It's been said that accountants express everything in dollars, because they can only think in one dimension. I'm not here to opine on that.) In other contexts, I agree with timbp that the terms "case-mix adjusted" and "risk adjusted" are used interchangeably, without clear distinctions. You have to look at the methodology detail to understand what's been done.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? In the specific context of hospital financial reporting, such as * average cost per admission, or * average revenue per admission "case-mix adjusted" is a term of art that means "DRG-adjusted". In o
42,172
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
http://www.nber.org/MedicareAdvtgSpecRateStats/risk-adjustment/2011/Evaluation2011/Evaluation_Risk_Adj_Model_2011.pdf This link explains risk adjustment scores and risk adjustment transfers in the CMS-HCC (hierarchical condition categories) methodology. HHS, the parent to CMS, has its own methodology, which is applied to Medicare Advantage plans under the Affordable Care Act of 2010. I can provide a link to the SAS v9 code and associated data (regression coefficients) which implements the HHS-HCC methodology. The SAS code is really (!) simple, as HHS has done all the heavy lifting in terms of analysis.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective?
http://www.nber.org/MedicareAdvtgSpecRateStats/risk-adjustment/2011/Evaluation2011/Evaluation_Risk_Adj_Model_2011.pdf This link explains risk adjustment scores and risk adjustment transfers in the CMS
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? http://www.nber.org/MedicareAdvtgSpecRateStats/risk-adjustment/2011/Evaluation2011/Evaluation_Risk_Adj_Model_2011.pdf This link explains risk adjustment scores and risk adjustment transfers in the CMS-HCC (hierarchical condition categories) methodology. HHS, the parent to CMS, has its own methodology, which is applied to Medicare Advantage plans under the Affordable Care Act of 2010. I can provide a link to the SAS v9 code and associated data (regression coefficients) which implements the HHS-HCC methodology. The SAS code is really (!) simple, as HHS has done all the heavy lifting in terms of analysis.
Case-mix adjustment versus risk adjustment, what are their differences in practice and objective? http://www.nber.org/MedicareAdvtgSpecRateStats/risk-adjustment/2011/Evaluation2011/Evaluation_Risk_Adj_Model_2011.pdf This link explains risk adjustment scores and risk adjustment transfers in the CMS
42,173
Whether to apply structural equation modelling separately to each of a set of heterogeneous correlation matrices in a meta-analysis context?
Cheung and Cheung (2010) gave a presentation discussing two appraoches to meta-analytic Structural Equation Modelling (SEM). They label the two approaches: Correlation matrices Meta-Analysis: An average correlation matrix is extracted from the primary studies and SEM is applied to this single correlation matrix. Model Parameters Meta-Analysis: Model fitting is applied separately to the correlation matrix of each primary study and the variation in parameters is modelled using random effects multivariate meta-analysis (Cheung and Cheung, 2010 cite Cheung 2009, and Kalaian & Raudenbush, 1996) Cheung and Cheung (2010) note that this is an area of research needing further development. They recommend trying both approaches especially where the full correlation matrix is available at least in a subset of studies. Discussions of how to perform meta-analysis SEM are also closely related with general discussions of multivariate meta-analysis (e.g., see the tutorial by Van Houwelingen et al 2002). I think that the standIndirect function in the metaSEM package in R (Cheung, 2011) implements a three variable test of mediation using the model parameters meta-analysis approach. References Becker, B.J. & Wu, M.J. (2007). The synthesis of regression slopes in meta-analysis. Statistical Science, 22, 414-429. PDF on arxiv Cheung, S. F., & Cheung, M. W.-L. (2010). Random effects models for meta-analytic structural equation modeling. Presented at The 7th Conference of the International Test Commission, July 19-21, 2010, Hong Kong. Cheung, M.W.L. (2011). metaSEM: Meta-Analysis using Structural Equation Modeling. Cheung, M.W.L. (2009). Comparison of methods for constructing confidence intervals of standardized indirect effects. Behavior Research Methods, 41, 425-438. Cheung, M.W.L. (2009). Constructing approximate confidence intervals for parameters with structural equation models. Structural Equation Modeling, 16, 267-294. Kalaian, H.A. & Raudenbush, S.W. (1996). A multivariate mixed linear model for meta-analysis.. Psychological methods, 1, 227. PDF Van Houwelingen, H.C., Arends, L.R. & Stijnen, T. (2002). Advanced methods in meta-analysis: multivariate approach and meta-regression. Statistics in medicine, 21, 589-624. PDF
Whether to apply structural equation modelling separately to each of a set of heterogeneous correlat
Cheung and Cheung (2010) gave a presentation discussing two appraoches to meta-analytic Structural Equation Modelling (SEM). They label the two approaches: Correlation matrices Meta-Analysis: An aver
Whether to apply structural equation modelling separately to each of a set of heterogeneous correlation matrices in a meta-analysis context? Cheung and Cheung (2010) gave a presentation discussing two appraoches to meta-analytic Structural Equation Modelling (SEM). They label the two approaches: Correlation matrices Meta-Analysis: An average correlation matrix is extracted from the primary studies and SEM is applied to this single correlation matrix. Model Parameters Meta-Analysis: Model fitting is applied separately to the correlation matrix of each primary study and the variation in parameters is modelled using random effects multivariate meta-analysis (Cheung and Cheung, 2010 cite Cheung 2009, and Kalaian & Raudenbush, 1996) Cheung and Cheung (2010) note that this is an area of research needing further development. They recommend trying both approaches especially where the full correlation matrix is available at least in a subset of studies. Discussions of how to perform meta-analysis SEM are also closely related with general discussions of multivariate meta-analysis (e.g., see the tutorial by Van Houwelingen et al 2002). I think that the standIndirect function in the metaSEM package in R (Cheung, 2011) implements a three variable test of mediation using the model parameters meta-analysis approach. References Becker, B.J. & Wu, M.J. (2007). The synthesis of regression slopes in meta-analysis. Statistical Science, 22, 414-429. PDF on arxiv Cheung, S. F., & Cheung, M. W.-L. (2010). Random effects models for meta-analytic structural equation modeling. Presented at The 7th Conference of the International Test Commission, July 19-21, 2010, Hong Kong. Cheung, M.W.L. (2011). metaSEM: Meta-Analysis using Structural Equation Modeling. Cheung, M.W.L. (2009). Comparison of methods for constructing confidence intervals of standardized indirect effects. Behavior Research Methods, 41, 425-438. Cheung, M.W.L. (2009). Constructing approximate confidence intervals for parameters with structural equation models. Structural Equation Modeling, 16, 267-294. Kalaian, H.A. & Raudenbush, S.W. (1996). A multivariate mixed linear model for meta-analysis.. Psychological methods, 1, 227. PDF Van Houwelingen, H.C., Arends, L.R. & Stijnen, T. (2002). Advanced methods in meta-analysis: multivariate approach and meta-regression. Statistics in medicine, 21, 589-624. PDF
Whether to apply structural equation modelling separately to each of a set of heterogeneous correlat Cheung and Cheung (2010) gave a presentation discussing two appraoches to meta-analytic Structural Equation Modelling (SEM). They label the two approaches: Correlation matrices Meta-Analysis: An aver
42,174
Optimizing regression coefficients to predict the largest outcomes
It seems that you either need to relax linearity assumptions for covariates (e.g., use restricted cubic splines, i.e., natural splines) or to define a new optimality criterion (other than maximum likelihood) and then to optimize the fit to that. I'm glad you clarified that you don't want to discard observations. The optimality criterion will define the effective weights; you don't have to. Least squares will give automatic emphasis to fitting more extreme $Y$ values at the expense of higher mean absolute error or median absolute error.
Optimizing regression coefficients to predict the largest outcomes
It seems that you either need to relax linearity assumptions for covariates (e.g., use restricted cubic splines, i.e., natural splines) or to define a new optimality criterion (other than maximum like
Optimizing regression coefficients to predict the largest outcomes It seems that you either need to relax linearity assumptions for covariates (e.g., use restricted cubic splines, i.e., natural splines) or to define a new optimality criterion (other than maximum likelihood) and then to optimize the fit to that. I'm glad you clarified that you don't want to discard observations. The optimality criterion will define the effective weights; you don't have to. Least squares will give automatic emphasis to fitting more extreme $Y$ values at the expense of higher mean absolute error or median absolute error.
Optimizing regression coefficients to predict the largest outcomes It seems that you either need to relax linearity assumptions for covariates (e.g., use restricted cubic splines, i.e., natural splines) or to define a new optimality criterion (other than maximum like
42,175
Optimizing regression coefficients to predict the largest outcomes
What you have written suggests that logistic regression, with attention to diagnostics and residuals, will be your best bet. It can help you take into account nonlinearity in the relationship between predictor and outcome You'll want to test multiplicative effects (interactions), as the thresholds you talk about may be joint thresholds involving multiple predictors. I am concerned, though, by your statement that "The vast majority of observations are not considered harmful and will be discarded from our analysis." In order to explain what causes the events of interest, it is absolutely necessary to know something about the conditions that do not produce it, just as it is to know about the ones that do.
Optimizing regression coefficients to predict the largest outcomes
What you have written suggests that logistic regression, with attention to diagnostics and residuals, will be your best bet. It can help you take into account nonlinearity in the relationship between
Optimizing regression coefficients to predict the largest outcomes What you have written suggests that logistic regression, with attention to diagnostics and residuals, will be your best bet. It can help you take into account nonlinearity in the relationship between predictor and outcome You'll want to test multiplicative effects (interactions), as the thresholds you talk about may be joint thresholds involving multiple predictors. I am concerned, though, by your statement that "The vast majority of observations are not considered harmful and will be discarded from our analysis." In order to explain what causes the events of interest, it is absolutely necessary to know something about the conditions that do not produce it, just as it is to know about the ones that do.
Optimizing regression coefficients to predict the largest outcomes What you have written suggests that logistic regression, with attention to diagnostics and residuals, will be your best bet. It can help you take into account nonlinearity in the relationship between
42,176
Model selection in a paper: what to say about the dropped variables?
It depends on your aim. Since A "really should" have an effect on Y but appears not to, I would definitely include the full model. As Procrastinator suggests, model selection might be useful to propose a parsimonious new model - if that's your objective. But if your objective is to estimate the relationships between your predictors and Y, then I don't think you need a model selection step at all - just present your full model results.
Model selection in a paper: what to say about the dropped variables?
It depends on your aim. Since A "really should" have an effect on Y but appears not to, I would definitely include the full model. As Procrastinator suggests, model selection might be useful to prop
Model selection in a paper: what to say about the dropped variables? It depends on your aim. Since A "really should" have an effect on Y but appears not to, I would definitely include the full model. As Procrastinator suggests, model selection might be useful to propose a parsimonious new model - if that's your objective. But if your objective is to estimate the relationships between your predictors and Y, then I don't think you need a model selection step at all - just present your full model results.
Model selection in a paper: what to say about the dropped variables? It depends on your aim. Since A "really should" have an effect on Y but appears not to, I would definitely include the full model. As Procrastinator suggests, model selection might be useful to prop
42,177
What does $\beta$ tell us in linear regression analysis?
I think your understanding of linear regression is fine. One thing that may interest you to know is that if both of your variables (e.g., A1 and B) are standardized, the $\beta$ from a simple regression will equal the r-score (i.e., the correlation coefficient, which when squared gives you the model's $R^2$), but this is not the issue here. I think what the book is talking about is the measure of volatility used in finance (which is also called 'beta', unfortunately). Although the name is the same, this is just not quite the same thing as the $\beta$ from a standard regression model. One other thing, neither of these is terribly closely related to beta regression, which is a form of the generalized linear model when the response variable is a proportion that is distributed as beta. I find it unfortunate, and very confusing, that there are terms (such as 'beta') that are used differently in different fields, or where different people use the same term to mean very different things (and that sometimes people use different terms to mean the same thing, as well), but these are just facts of life.
What does $\beta$ tell us in linear regression analysis?
I think your understanding of linear regression is fine. One thing that may interest you to know is that if both of your variables (e.g., A1 and B) are standardized, the $\beta$ from a simple regress
What does $\beta$ tell us in linear regression analysis? I think your understanding of linear regression is fine. One thing that may interest you to know is that if both of your variables (e.g., A1 and B) are standardized, the $\beta$ from a simple regression will equal the r-score (i.e., the correlation coefficient, which when squared gives you the model's $R^2$), but this is not the issue here. I think what the book is talking about is the measure of volatility used in finance (which is also called 'beta', unfortunately). Although the name is the same, this is just not quite the same thing as the $\beta$ from a standard regression model. One other thing, neither of these is terribly closely related to beta regression, which is a form of the generalized linear model when the response variable is a proportion that is distributed as beta. I find it unfortunate, and very confusing, that there are terms (such as 'beta') that are used differently in different fields, or where different people use the same term to mean very different things (and that sometimes people use different terms to mean the same thing, as well), but these are just facts of life.
What does $\beta$ tell us in linear regression analysis? I think your understanding of linear regression is fine. One thing that may interest you to know is that if both of your variables (e.g., A1 and B) are standardized, the $\beta$ from a simple regress
42,178
Expected value for discrete (nominal) variable?
There are several different measures of "location" or "central tendency". Expected value is the most popular one, but there are others -- median, mode, geometric mean, etc. While all measures of central tendency are, in some ways, similar, it is important to remember that they actually measure different things. Here are the interpretations. Expected value (or mean). Expected value is useful for calculating the total when you have a large number of observations. Say you own a company with a large number ($N$) of employees. The expected salary is $E[X]$. The total salary that you have to pay out is $N E[X]$. Median. Median tells you about the typical observation. If you want to know what the typical person earns, look at the median salary, not the expected salary. Mode. Mode tells you the most likely outcome. If you are applying for jobs in a particular field, the modal salary is what you will most probably earn, not the expected salary. There is confusion because, with symmetric distributions, which are common, mean, median, and mode are numerically equal. So people just think of the mean and not the median or mode. But, depending on the problem, what you are actually interested in could be the mode, even if it is numerically equal to the mean. Now, let's look at your specific questions. Suppose each time you throw a die, you earn the amount of money that comes up. After throwing it a lot of times, you will earn $N E[X]$. The "fair price" that someone could charge you for making these throws is $N E[X]$. If you assign head and tail to numbers (think: amounts that you will earn or pay), then there certainly is an expected value. For $H = 0$, $T = 1$, $E[X] = 0.5$.
Expected value for discrete (nominal) variable?
There are several different measures of "location" or "central tendency". Expected value is the most popular one, but there are others -- median, mode, geometric mean, etc. While all measures of centr
Expected value for discrete (nominal) variable? There are several different measures of "location" or "central tendency". Expected value is the most popular one, but there are others -- median, mode, geometric mean, etc. While all measures of central tendency are, in some ways, similar, it is important to remember that they actually measure different things. Here are the interpretations. Expected value (or mean). Expected value is useful for calculating the total when you have a large number of observations. Say you own a company with a large number ($N$) of employees. The expected salary is $E[X]$. The total salary that you have to pay out is $N E[X]$. Median. Median tells you about the typical observation. If you want to know what the typical person earns, look at the median salary, not the expected salary. Mode. Mode tells you the most likely outcome. If you are applying for jobs in a particular field, the modal salary is what you will most probably earn, not the expected salary. There is confusion because, with symmetric distributions, which are common, mean, median, and mode are numerically equal. So people just think of the mean and not the median or mode. But, depending on the problem, what you are actually interested in could be the mode, even if it is numerically equal to the mean. Now, let's look at your specific questions. Suppose each time you throw a die, you earn the amount of money that comes up. After throwing it a lot of times, you will earn $N E[X]$. The "fair price" that someone could charge you for making these throws is $N E[X]$. If you assign head and tail to numbers (think: amounts that you will earn or pay), then there certainly is an expected value. For $H = 0$, $T = 1$, $E[X] = 0.5$.
Expected value for discrete (nominal) variable? There are several different measures of "location" or "central tendency". Expected value is the most popular one, but there are others -- median, mode, geometric mean, etc. While all measures of centr
42,179
Pre-processing time series data for data mining / predictive modeling input
I agree with what user765195 said: there's no magic bullet here that will work for all your problems. You've got to come up with potentially-useful features based on your domain knowledge. I've never worked in a bank, so take these suggestions with a grain of salt, but how about "Volatility" When I've changed banks, I tend to use the new account for a while before I close the old one, since it takes a while for payroll/recurring charges to get moved over. Maybe the variance of the balance (or changes in the variance over shorter time windows) would capture this? Transaction Size Taking the derivative of the daily balances would give you an idea of the (net) daily transactions. Maybe people make anamolously large withdrawals before closing out their accounts (e.g., to set up a new account elsewhere). If I were you, I would start by making a long list of possible features. Carve your data up into a test set, a development set, and a training set. Test out new features on the training+development sets and see what works. Personally, I would throw them all in and see what happens first. There are lots of feature selection algorithms, ranging from the brain-dead but exhaustive (try all possible combinations!) to something like projection pursuit or hill-climbing, which might be more tractable for big data sets. Then, once you've settled on a model, use the previously-untouched test data to evaluate its performance.
Pre-processing time series data for data mining / predictive modeling input
I agree with what user765195 said: there's no magic bullet here that will work for all your problems. You've got to come up with potentially-useful features based on your domain knowledge. I've never
Pre-processing time series data for data mining / predictive modeling input I agree with what user765195 said: there's no magic bullet here that will work for all your problems. You've got to come up with potentially-useful features based on your domain knowledge. I've never worked in a bank, so take these suggestions with a grain of salt, but how about "Volatility" When I've changed banks, I tend to use the new account for a while before I close the old one, since it takes a while for payroll/recurring charges to get moved over. Maybe the variance of the balance (or changes in the variance over shorter time windows) would capture this? Transaction Size Taking the derivative of the daily balances would give you an idea of the (net) daily transactions. Maybe people make anamolously large withdrawals before closing out their accounts (e.g., to set up a new account elsewhere). If I were you, I would start by making a long list of possible features. Carve your data up into a test set, a development set, and a training set. Test out new features on the training+development sets and see what works. Personally, I would throw them all in and see what happens first. There are lots of feature selection algorithms, ranging from the brain-dead but exhaustive (try all possible combinations!) to something like projection pursuit or hill-climbing, which might be more tractable for big data sets. Then, once you've settled on a model, use the previously-untouched test data to evaluate its performance.
Pre-processing time series data for data mining / predictive modeling input I agree with what user765195 said: there's no magic bullet here that will work for all your problems. You've got to come up with potentially-useful features based on your domain knowledge. I've never
42,180
Pre-processing time series data for data mining / predictive modeling input
It all depends on how to plan to make predictions after you've finished pre-processing there data. For example, if you expect consecutive observations of a time series $y_t$ to be linearly related to previous measurements: $$ y_{t} = \beta_0 + \beta_1 y_{t-1} + \cdots $$ then you'd better choose a linear transformation. Or, if you expect consecutive measurements to be multiplicatively related to each other: $$ y_{t} = \eta_{0} \cdot y_{t-1}^{\eta_{1}} \cdot \cdot \cdot $$ then a log transformation (and subsequent linear model) would accomplish this since $$ \log(y_{t}) = \log(\eta_0) + \eta_{1} \log(y_{t-1}) + \cdot \cdot \cdot $$ You may investigate various transformations to see which one provides the best predictive power. But, the "best predictor" will depend on your measure of prediction accuracy. Regarding dimension reduction, your example only seems to involve 2 variables - dimension reduction often refers to the situation where you have a large number of predictors and want to lower the number in a principled way. If you have that situation, you may use standard techniques (e.g. PCA) for dimension reduction, which are not related to the fact that this is a time series. If you mean dimension reduction in the sense of reducing the number of timepoints, the only types of transformations that will accomplish this will be things like averaging over timepoints (e.g. to calculate weekly averages from daily data). It would be hard to justify doing something like this unless it is drastically easier to fit weekly data than daily data (for example, for rainfall data, it is easier to predict the average rainfall over the course of a week than it is to predict the daily rainfall values).
Pre-processing time series data for data mining / predictive modeling input
It all depends on how to plan to make predictions after you've finished pre-processing there data. For example, if you expect consecutive observations of a time series $y_t$ to be linearly related to
Pre-processing time series data for data mining / predictive modeling input It all depends on how to plan to make predictions after you've finished pre-processing there data. For example, if you expect consecutive observations of a time series $y_t$ to be linearly related to previous measurements: $$ y_{t} = \beta_0 + \beta_1 y_{t-1} + \cdots $$ then you'd better choose a linear transformation. Or, if you expect consecutive measurements to be multiplicatively related to each other: $$ y_{t} = \eta_{0} \cdot y_{t-1}^{\eta_{1}} \cdot \cdot \cdot $$ then a log transformation (and subsequent linear model) would accomplish this since $$ \log(y_{t}) = \log(\eta_0) + \eta_{1} \log(y_{t-1}) + \cdot \cdot \cdot $$ You may investigate various transformations to see which one provides the best predictive power. But, the "best predictor" will depend on your measure of prediction accuracy. Regarding dimension reduction, your example only seems to involve 2 variables - dimension reduction often refers to the situation where you have a large number of predictors and want to lower the number in a principled way. If you have that situation, you may use standard techniques (e.g. PCA) for dimension reduction, which are not related to the fact that this is a time series. If you mean dimension reduction in the sense of reducing the number of timepoints, the only types of transformations that will accomplish this will be things like averaging over timepoints (e.g. to calculate weekly averages from daily data). It would be hard to justify doing something like this unless it is drastically easier to fit weekly data than daily data (for example, for rainfall data, it is easier to predict the average rainfall over the course of a week than it is to predict the daily rainfall values).
Pre-processing time series data for data mining / predictive modeling input It all depends on how to plan to make predictions after you've finished pre-processing there data. For example, if you expect consecutive observations of a time series $y_t$ to be linearly related to
42,181
How to verify that the model is real?
The stability of your results depends on the number of data points you use to estimate your model's parameters, not so much on whether your model captures reality. Take, for example, a simple univariate Gaussian distribution with a fixed variance and varying mean (a statistical model). The variance of the estimated mean will go down as 1/N, where N is the number of data points in your training set. For statistical models, a distance measure of great interest is the Kullback-Leibler divergence between your model's distribution and the true distribution of the data. Unfortunately, the KL divergence requires knowledge of the true distribution and is therefore not very practical. An alternative would be the differential log-likelihood (see Mixture density modeling, Kullback–Leibler divergence, and differential log-likelihood, van Hulle, 2004). But there is an infinite number of possible distance measures which you could use. Which one you should choose depends on what you are going to use the model for.
How to verify that the model is real?
The stability of your results depends on the number of data points you use to estimate your model's parameters, not so much on whether your model captures reality. Take, for example, a simple univaria
How to verify that the model is real? The stability of your results depends on the number of data points you use to estimate your model's parameters, not so much on whether your model captures reality. Take, for example, a simple univariate Gaussian distribution with a fixed variance and varying mean (a statistical model). The variance of the estimated mean will go down as 1/N, where N is the number of data points in your training set. For statistical models, a distance measure of great interest is the Kullback-Leibler divergence between your model's distribution and the true distribution of the data. Unfortunately, the KL divergence requires knowledge of the true distribution and is therefore not very practical. An alternative would be the differential log-likelihood (see Mixture density modeling, Kullback–Leibler divergence, and differential log-likelihood, van Hulle, 2004). But there is an infinite number of possible distance measures which you could use. Which one you should choose depends on what you are going to use the model for.
How to verify that the model is real? The stability of your results depends on the number of data points you use to estimate your model's parameters, not so much on whether your model captures reality. Take, for example, a simple univaria
42,182
Cohen's d for 2x2 interaction
You can translate pretty much any of the effect sizes to Cohen's d, so start with omega and work your way over. Equations are available for them all online... the wikipedia page for effect size is good for this. In your particular case though you can get a numerator for cohen's d as (a1 - b1) - (a2 - b2). That's the simple effect of a 2x2 interaction with, a and b as the variables (e.g. sex and handedness) and the numbers are levels of the variables (e.g. male / female and left / right). Your denominator is just the square root of the MSE from the ANOVA*. *assuming homogeneity of variance
Cohen's d for 2x2 interaction
You can translate pretty much any of the effect sizes to Cohen's d, so start with omega and work your way over. Equations are available for them all online... the wikipedia page for effect size is go
Cohen's d for 2x2 interaction You can translate pretty much any of the effect sizes to Cohen's d, so start with omega and work your way over. Equations are available for them all online... the wikipedia page for effect size is good for this. In your particular case though you can get a numerator for cohen's d as (a1 - b1) - (a2 - b2). That's the simple effect of a 2x2 interaction with, a and b as the variables (e.g. sex and handedness) and the numbers are levels of the variables (e.g. male / female and left / right). Your denominator is just the square root of the MSE from the ANOVA*. *assuming homogeneity of variance
Cohen's d for 2x2 interaction You can translate pretty much any of the effect sizes to Cohen's d, so start with omega and work your way over. Equations are available for them all online... the wikipedia page for effect size is go
42,183
How to compute importance sampling?
In case your difficulty is with the simulation per se, here is my R code to compare simulations from $f$ (plain), $g$ equal to $$ \frac{1}{2} \frac{1}{\pi} \frac{1}{1+x^2} + \frac{1}{2}\frac{1}{4}\frac{\mathbb{I}_{[0,2]}(x)}{\sqrt{|1-x|}} $$ (mixture of Cauchy and power distributions) and $m$ equal to $$ \frac{1}{2}\frac{1}{\Gamma(1/2)}\frac{1}{\sqrt{|1-x|}}\exp\{-|1-x|\} $$ (folded Gamma). Simulating from $f$ is straightforward > sam1=matrix(rt(10^6,df=5),ncol=100) > fam1=h(sam1) where > h function(x){ sqrt(abs(x/{1-x}))} Simulating from $g$ requires simulating from the square-root part. If you integrate out $1/4{\sqrt{|1-x|}}$ over $[0,2]$, you get either $1-\sqrt{1-x}$ over $[0,1]$ or $\sqrt{x-1}$ over $[1,2]$, which means that this distribution can be represented as $$ 1\pm \mathcal{U}(0,1)^2. $$ (In the following, I force both subsamples to have the same size $5\cdot10^5$, which is a Rao-Blackwellisation trick to reduce the variance with no impact on the expectation.) > sam22=1+sample(c(-1,1),5*10^5,rep=TRUE)*runif(5*10^5)^2 > sam21=rcauchy(5*10^5) > sam2=matrix(sample(c(sam21,sam22)),ncol=100) > fam2=h(sam2)*dt(sam2,df=5)/g(sam2) where g=function(x){.5*dcauchy(x)+.125*((x>0)*(x<2))/sqrt(abs(1-x))} Simulating from $m$ follows from the folded representation: > sam3=matrix(1+sample(c(-1,1),10^6,rep=TRUE)*rgamma(10^6,.5),ncol=100) > fam3=h(sam3)*dt(sam3,df=5)/(.5*dgamma(abs(1-sam3),.5)) The comparison of the three simulation methods is illustrated in the following boxplot (that we should use in the next edition of Monte Carlo Statistical Methods!)
How to compute importance sampling?
In case your difficulty is with the simulation per se, here is my R code to compare simulations from $f$ (plain), $g$ equal to $$ \frac{1}{2} \frac{1}{\pi} \frac{1}{1+x^2} + \frac{1}{2}\frac{1}{4}\fra
How to compute importance sampling? In case your difficulty is with the simulation per se, here is my R code to compare simulations from $f$ (plain), $g$ equal to $$ \frac{1}{2} \frac{1}{\pi} \frac{1}{1+x^2} + \frac{1}{2}\frac{1}{4}\frac{\mathbb{I}_{[0,2]}(x)}{\sqrt{|1-x|}} $$ (mixture of Cauchy and power distributions) and $m$ equal to $$ \frac{1}{2}\frac{1}{\Gamma(1/2)}\frac{1}{\sqrt{|1-x|}}\exp\{-|1-x|\} $$ (folded Gamma). Simulating from $f$ is straightforward > sam1=matrix(rt(10^6,df=5),ncol=100) > fam1=h(sam1) where > h function(x){ sqrt(abs(x/{1-x}))} Simulating from $g$ requires simulating from the square-root part. If you integrate out $1/4{\sqrt{|1-x|}}$ over $[0,2]$, you get either $1-\sqrt{1-x}$ over $[0,1]$ or $\sqrt{x-1}$ over $[1,2]$, which means that this distribution can be represented as $$ 1\pm \mathcal{U}(0,1)^2. $$ (In the following, I force both subsamples to have the same size $5\cdot10^5$, which is a Rao-Blackwellisation trick to reduce the variance with no impact on the expectation.) > sam22=1+sample(c(-1,1),5*10^5,rep=TRUE)*runif(5*10^5)^2 > sam21=rcauchy(5*10^5) > sam2=matrix(sample(c(sam21,sam22)),ncol=100) > fam2=h(sam2)*dt(sam2,df=5)/g(sam2) where g=function(x){.5*dcauchy(x)+.125*((x>0)*(x<2))/sqrt(abs(1-x))} Simulating from $m$ follows from the folded representation: > sam3=matrix(1+sample(c(-1,1),10^6,rep=TRUE)*rgamma(10^6,.5),ncol=100) > fam3=h(sam3)*dt(sam3,df=5)/(.5*dgamma(abs(1-sam3),.5)) The comparison of the three simulation methods is illustrated in the following boxplot (that we should use in the next edition of Monte Carlo Statistical Methods!)
How to compute importance sampling? In case your difficulty is with the simulation per se, here is my R code to compare simulations from $f$ (plain), $g$ equal to $$ \frac{1}{2} \frac{1}{\pi} \frac{1}{1+x^2} + \frac{1}{2}\frac{1}{4}\fra
42,184
Robust logistic regression vs logistic regression
First I would ask what do you mean by robust logistic regression (it could mean a couple of different things ...). Nevertheless, assuming that you are using "robust" in the sense that you want to control for heteroscedasticity in binary outcome models what I know is the following: 1) You should read in detail the 15th chapter of the Wooldridge 2001 Econometrics of Cross Section and panel data book (or any other equivalent book that talks about binary outcome models in detail). 2) Heteroscedasticity in binary outcome models will affect both the "Betas" and their standard errors. 2a) BETAS: Heteroscedasticity in binary outcome models has functional form implications. Basically F(XB) != LOGISTIC( XB ) if you have it, then your estimation will be inconsistent regardless of what you do ... If you are absolutely sure about the type of heteroskedasticity you are having, this is, how your error changes as X changes, then you can correct your covariates accordingly to control for this. Since that is unlikely there is nothing you can do about it. Now the fact that the estimation of Betas is inconsistent might not be very relevant anyway since the partial effects may still be a good approximation of the real partial effects. The whole point here is that heteroscedasticity in binary outcome models implies functional form mispecification and should be treated accordingly. As an example think about probit vs logit. For your data, only one of these models can be the correct data generation process (if any). So when you estimate both of them you must know that at least one of the models will surely have inconsistent betas. But if go and look at their partial effects you won't see much of a difference ... Go and test for heteroscedasticity first to see if this can be an issue. There are several tests arround .... 2 b) Standard Errors: Under heteroscedasiticty your standard errors will also be miscalculated by the "normal" way of estimating these models. In R what i would suggest is that you use bootstrap since i am not sure if there are any packages available that correct for kinds of misspecification and/or that allow for intragroup correlation .... If this has nothing to do with what you asked and as Rolando2 pointed out in the comment you are trying to penalize outliers in the regression then you should know that your use of the lrm function is not correct: you are calling it with the default parameters in which case, quoting from the documentation: The default is penalty=0 implying that ordinary unpenalized maximum likelihood estimation is used Hope this helped somehow, Miguel
Robust logistic regression vs logistic regression
First I would ask what do you mean by robust logistic regression (it could mean a couple of different things ...). Nevertheless, assuming that you are using "robust" in the sense that you want to cont
Robust logistic regression vs logistic regression First I would ask what do you mean by robust logistic regression (it could mean a couple of different things ...). Nevertheless, assuming that you are using "robust" in the sense that you want to control for heteroscedasticity in binary outcome models what I know is the following: 1) You should read in detail the 15th chapter of the Wooldridge 2001 Econometrics of Cross Section and panel data book (or any other equivalent book that talks about binary outcome models in detail). 2) Heteroscedasticity in binary outcome models will affect both the "Betas" and their standard errors. 2a) BETAS: Heteroscedasticity in binary outcome models has functional form implications. Basically F(XB) != LOGISTIC( XB ) if you have it, then your estimation will be inconsistent regardless of what you do ... If you are absolutely sure about the type of heteroskedasticity you are having, this is, how your error changes as X changes, then you can correct your covariates accordingly to control for this. Since that is unlikely there is nothing you can do about it. Now the fact that the estimation of Betas is inconsistent might not be very relevant anyway since the partial effects may still be a good approximation of the real partial effects. The whole point here is that heteroscedasticity in binary outcome models implies functional form mispecification and should be treated accordingly. As an example think about probit vs logit. For your data, only one of these models can be the correct data generation process (if any). So when you estimate both of them you must know that at least one of the models will surely have inconsistent betas. But if go and look at their partial effects you won't see much of a difference ... Go and test for heteroscedasticity first to see if this can be an issue. There are several tests arround .... 2 b) Standard Errors: Under heteroscedasiticty your standard errors will also be miscalculated by the "normal" way of estimating these models. In R what i would suggest is that you use bootstrap since i am not sure if there are any packages available that correct for kinds of misspecification and/or that allow for intragroup correlation .... If this has nothing to do with what you asked and as Rolando2 pointed out in the comment you are trying to penalize outliers in the regression then you should know that your use of the lrm function is not correct: you are calling it with the default parameters in which case, quoting from the documentation: The default is penalty=0 implying that ordinary unpenalized maximum likelihood estimation is used Hope this helped somehow, Miguel
Robust logistic regression vs logistic regression First I would ask what do you mean by robust logistic regression (it could mean a couple of different things ...). Nevertheless, assuming that you are using "robust" in the sense that you want to cont
42,185
Truncated normal distribution with WinBUGS
In openbugs (so I would assume the same in winbugs, but could be wrong) you can do a truncated distribution using the T function, something like: y[i] ~ dnorm(x[i],tau)T(0,10)
Truncated normal distribution with WinBUGS
In openbugs (so I would assume the same in winbugs, but could be wrong) you can do a truncated distribution using the T function, something like: y[i] ~ dnorm(x[i],tau)T(0,10)
Truncated normal distribution with WinBUGS In openbugs (so I would assume the same in winbugs, but could be wrong) you can do a truncated distribution using the T function, something like: y[i] ~ dnorm(x[i],tau)T(0,10)
Truncated normal distribution with WinBUGS In openbugs (so I would assume the same in winbugs, but could be wrong) you can do a truncated distribution using the T function, something like: y[i] ~ dnorm(x[i],tau)T(0,10)
42,186
Truncated normal distribution with WinBUGS
I found the solution by consulting the WinBUGS User Manual (Page 47). I had to modify the initial parameters but I end up using the I() function with dnorm. undefined real result indicates numerical overflow. Possible reasons include: initial values generated from a 'vague' prior distribution may be numerically extreme - specify appropriate initial values; numerically impossible values such as log of a non-positive number - check, for example, that no zero expectations have been given when Poisson modelling; numerical difficulties in sampling. Possible solutions include: better initial values; more informative priors - uniform priors might still be used but with their range restricted to plausible values; better parameterisation to improve orthogonality; standardisation of covariates to have mean 0 and standard deviation 1. can happen if all initial values are equal. Probit models are particularly susceptible to this problem, i.e. generating undefined real results. If a probit is a stochastic node, it may help to put reasonable bounds on its distribution, e.g. probit(p[i]) <- delta[i] delta[i] ~ dnorm(mu[i], tau)I(-5, 5) This trap can sometimes be escaped from by simply clicking on the update button. The equivalent construction p[i] <- phi(delta[i]) may be more forgiving.
Truncated normal distribution with WinBUGS
I found the solution by consulting the WinBUGS User Manual (Page 47). I had to modify the initial parameters but I end up using the I() function with dnorm. undefined real result indicates numerical
Truncated normal distribution with WinBUGS I found the solution by consulting the WinBUGS User Manual (Page 47). I had to modify the initial parameters but I end up using the I() function with dnorm. undefined real result indicates numerical overflow. Possible reasons include: initial values generated from a 'vague' prior distribution may be numerically extreme - specify appropriate initial values; numerically impossible values such as log of a non-positive number - check, for example, that no zero expectations have been given when Poisson modelling; numerical difficulties in sampling. Possible solutions include: better initial values; more informative priors - uniform priors might still be used but with their range restricted to plausible values; better parameterisation to improve orthogonality; standardisation of covariates to have mean 0 and standard deviation 1. can happen if all initial values are equal. Probit models are particularly susceptible to this problem, i.e. generating undefined real results. If a probit is a stochastic node, it may help to put reasonable bounds on its distribution, e.g. probit(p[i]) <- delta[i] delta[i] ~ dnorm(mu[i], tau)I(-5, 5) This trap can sometimes be escaped from by simply clicking on the update button. The equivalent construction p[i] <- phi(delta[i]) may be more forgiving.
Truncated normal distribution with WinBUGS I found the solution by consulting the WinBUGS User Manual (Page 47). I had to modify the initial parameters but I end up using the I() function with dnorm. undefined real result indicates numerical
42,187
Truncated normal distribution with WinBUGS
According to http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign10.htm, two gotchas that may apply are that the upper truncation point may need to be adjusted (e.g., from 10 to 10.0001) initial values that seed the chains need to be specified explicitly, because WinBUGS may pick ones that lie outside of ($\alpha$,$\beta$).
Truncated normal distribution with WinBUGS
According to http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign10.htm, two gotchas that may apply are that the upper truncation point may need to be adjusted (e.g., from 10 to 10
Truncated normal distribution with WinBUGS According to http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign10.htm, two gotchas that may apply are that the upper truncation point may need to be adjusted (e.g., from 10 to 10.0001) initial values that seed the chains need to be specified explicitly, because WinBUGS may pick ones that lie outside of ($\alpha$,$\beta$).
Truncated normal distribution with WinBUGS According to http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign10.htm, two gotchas that may apply are that the upper truncation point may need to be adjusted (e.g., from 10 to 10
42,188
Automated parameter selection for a GARCH model, in a similar manner to the forecast package
My experience with equities suggested that if you are confined to garch(p,q), then garch(1,1) is what you will want. Using a components model (Lee and Engle) is better -- it is sort of like a garch(2,2) but not quite the same. When modeling multivariate garch (where there was a lot of choice in parameterization), it seemed to be that BIC was defnitely better than AIC. BIC has a larger penalty and so suggests smaller models. It looked like the penalty should be even bigger than in BIC -- that the BIC models were still too big.
Automated parameter selection for a GARCH model, in a similar manner to the forecast package
My experience with equities suggested that if you are confined to garch(p,q), then garch(1,1) is what you will want. Using a components model (Lee and Engle) is better -- it is sort of like a garch(2
Automated parameter selection for a GARCH model, in a similar manner to the forecast package My experience with equities suggested that if you are confined to garch(p,q), then garch(1,1) is what you will want. Using a components model (Lee and Engle) is better -- it is sort of like a garch(2,2) but not quite the same. When modeling multivariate garch (where there was a lot of choice in parameterization), it seemed to be that BIC was defnitely better than AIC. BIC has a larger penalty and so suggests smaller models. It looked like the penalty should be even bigger than in BIC -- that the BIC models were still too big.
Automated parameter selection for a GARCH model, in a similar manner to the forecast package My experience with equities suggested that if you are confined to garch(p,q), then garch(1,1) is what you will want. Using a components model (Lee and Engle) is better -- it is sort of like a garch(2
42,189
On error probability bounds in Bayesian hypothesis testing
It is known that the best strategy, that is the one that minimizes the probability of uncorrect guess, is to choose the hypothesis $H \in \{A,B\}$ that maximizes the $p(H|x)$, where $x$ is the observation. As a personal peeve, I dislike this particular statement because in my mind it hides what is really going on, and makes what should be obvious rather obscure. Unfortunately, such Olympian pronouncements are what lots of people take away from a course on Bayesian methods.... Suppose that the observation $X$ is a discrete random variable. We observe that the event $\{X = x\}$ has occurred and need to decide choose between $A$ or $B$. But the observed event can be partitioned into $\{X = x, A\}$ and $\{X = x, B\}$ and we have that $$p(x) = p(X=x, A) + p(X=x, B).$$ Now, one of the two events $\{X = x, A\}$ and $\{X = x, B\}$ has occurred. Clearly if we choose $A$ upon observing $\{X = x\}$, we are correct with probability $p(X=x, A)$ and incorrect with probability $p(X=x, B)$ while if we choose $B$ upon observing $\{X = x\}$, we are correct with probability $p(X=x, B)$ and incorrect with probability $p(X=x, A)$. So, the probability of being incorrect in this instance is minimized if we choose $A$ if $p(X=x, B) < p(X=x, A)$ and choose $B$ if $p(X=x, B) > p(X=x, A)$. So, if $E$ and $C$ denote the events of the decision being in error and being correct respectively, we have that if the optimal (minimum-error probability) decision is made upon observing $\{X=x\}$, such occurrences contribute $\max\{p(X=x, A), p(X=x, B)\}$ to $P(C)$, and $\min\{p(X=x, A), p(X=x, B)\}$ to $P(E)$. We have $$\begin{align*} P(E) &= \sum_x \min\{p(X=x, A), p(X=x, B)\}\\ &= 1 - P(C)\\ &= 1 - \sum_x \max\{p(X=x, A), p(X=x, B)\} \end{align*}$$ Since $p(X=x, A) = p(x|A)P(A)$ and $p(X=x, B) = p(x|B)P(B)$, we can write $$\begin{align*} P(E) &= 1 - \sum_x \max\{p(x|A)P(A), p(x|B)P(B)\}\\ &= 1 - \sum_x \max\left\{\frac{p(x|A)P(A)}{p(x)}, \frac{p(x|B)P(B)}{p(x)}\right\}p(x)\\ &= 1 - E_x\left[\max\{P(A|x),P(B|x)\}\right]\\ &= E_x\left[\min\{P(A|x),P(B|x)\}\right] \end{align*}$$ where $E_x$ denotes expectation with respect to $x$. Alternatively, since $$ \max\{p,q\} = \frac{p+q+|p-q|}{2}, $$ we have $$\begin{align*} P(E) &= 1 - \sum_x \max\{p(x,A), p(x,B)\}\\ &= 1 - \sum_x \frac{p(x,A) + p(x,B)+ |p(x,A) - p(x,B)|}{2}\\ &= 1 -\frac{P(A) + P(B)}{2} - \sum_x \frac{|p(x,A) - p(x,B)|}{2}\\ &= 1 - \frac{1 + \sum_x |p(x|A)P(A) - p(x|B)P(B)|}{2}\\ &= 1 - \frac{||p(\cdot|A)p(A) - p(\cdot|B)p(B)||_1 + 1}2 \end{align*}$$ as OP Michele writes it. Finally, for $p, q \in [0,1]$, $\min\{p, q\} \geq pq$ and so $$\begin{align*} P(E) &= E_x\left[\min\{P(A|x),P(B|x)\}\right]\\ &\geq E_x\left[P(A|x)P(B|x)\right]. \end{align*}$$ In summary, the three expressions for $P(E)$ appear different but are based on the same fundamental idea. All three require computation of an expectation with respect to $x$, and differ very little in computational complexity. Simplifications can be made if something specific is know about the variables, e.g. $X$ is a geometric random variable with different parameters under the two hypotheses in which case one could compute some sums analytically instead of numerically, but they would appear to apply equally in all three cases. I see very little difference in terms of computational tractability in (1)-(3) as exhibited in the OP's question.
On error probability bounds in Bayesian hypothesis testing
It is known that the best strategy, that is the one that minimizes the probability of uncorrect guess, is to choose the hypothesis $H \in \{A,B\}$ that maximizes the $p(H|x)$, where $x$ is the observa
On error probability bounds in Bayesian hypothesis testing It is known that the best strategy, that is the one that minimizes the probability of uncorrect guess, is to choose the hypothesis $H \in \{A,B\}$ that maximizes the $p(H|x)$, where $x$ is the observation. As a personal peeve, I dislike this particular statement because in my mind it hides what is really going on, and makes what should be obvious rather obscure. Unfortunately, such Olympian pronouncements are what lots of people take away from a course on Bayesian methods.... Suppose that the observation $X$ is a discrete random variable. We observe that the event $\{X = x\}$ has occurred and need to decide choose between $A$ or $B$. But the observed event can be partitioned into $\{X = x, A\}$ and $\{X = x, B\}$ and we have that $$p(x) = p(X=x, A) + p(X=x, B).$$ Now, one of the two events $\{X = x, A\}$ and $\{X = x, B\}$ has occurred. Clearly if we choose $A$ upon observing $\{X = x\}$, we are correct with probability $p(X=x, A)$ and incorrect with probability $p(X=x, B)$ while if we choose $B$ upon observing $\{X = x\}$, we are correct with probability $p(X=x, B)$ and incorrect with probability $p(X=x, A)$. So, the probability of being incorrect in this instance is minimized if we choose $A$ if $p(X=x, B) < p(X=x, A)$ and choose $B$ if $p(X=x, B) > p(X=x, A)$. So, if $E$ and $C$ denote the events of the decision being in error and being correct respectively, we have that if the optimal (minimum-error probability) decision is made upon observing $\{X=x\}$, such occurrences contribute $\max\{p(X=x, A), p(X=x, B)\}$ to $P(C)$, and $\min\{p(X=x, A), p(X=x, B)\}$ to $P(E)$. We have $$\begin{align*} P(E) &= \sum_x \min\{p(X=x, A), p(X=x, B)\}\\ &= 1 - P(C)\\ &= 1 - \sum_x \max\{p(X=x, A), p(X=x, B)\} \end{align*}$$ Since $p(X=x, A) = p(x|A)P(A)$ and $p(X=x, B) = p(x|B)P(B)$, we can write $$\begin{align*} P(E) &= 1 - \sum_x \max\{p(x|A)P(A), p(x|B)P(B)\}\\ &= 1 - \sum_x \max\left\{\frac{p(x|A)P(A)}{p(x)}, \frac{p(x|B)P(B)}{p(x)}\right\}p(x)\\ &= 1 - E_x\left[\max\{P(A|x),P(B|x)\}\right]\\ &= E_x\left[\min\{P(A|x),P(B|x)\}\right] \end{align*}$$ where $E_x$ denotes expectation with respect to $x$. Alternatively, since $$ \max\{p,q\} = \frac{p+q+|p-q|}{2}, $$ we have $$\begin{align*} P(E) &= 1 - \sum_x \max\{p(x,A), p(x,B)\}\\ &= 1 - \sum_x \frac{p(x,A) + p(x,B)+ |p(x,A) - p(x,B)|}{2}\\ &= 1 -\frac{P(A) + P(B)}{2} - \sum_x \frac{|p(x,A) - p(x,B)|}{2}\\ &= 1 - \frac{1 + \sum_x |p(x|A)P(A) - p(x|B)P(B)|}{2}\\ &= 1 - \frac{||p(\cdot|A)p(A) - p(\cdot|B)p(B)||_1 + 1}2 \end{align*}$$ as OP Michele writes it. Finally, for $p, q \in [0,1]$, $\min\{p, q\} \geq pq$ and so $$\begin{align*} P(E) &= E_x\left[\min\{P(A|x),P(B|x)\}\right]\\ &\geq E_x\left[P(A|x)P(B|x)\right]. \end{align*}$$ In summary, the three expressions for $P(E)$ appear different but are based on the same fundamental idea. All three require computation of an expectation with respect to $x$, and differ very little in computational complexity. Simplifications can be made if something specific is know about the variables, e.g. $X$ is a geometric random variable with different parameters under the two hypotheses in which case one could compute some sums analytically instead of numerically, but they would appear to apply equally in all three cases. I see very little difference in terms of computational tractability in (1)-(3) as exhibited in the OP's question.
On error probability bounds in Bayesian hypothesis testing It is known that the best strategy, that is the one that minimizes the probability of uncorrect guess, is to choose the hypothesis $H \in \{A,B\}$ that maximizes the $p(H|x)$, where $x$ is the observa
42,190
On error probability bounds in Bayesian hypothesis testing
When $p(A) = p(B) = 1/2$, equation $(3)$ is basically computing the total variation distance (also known as the variation distance, for short). The variation distance is an ${\cal L}_1$ distance between two probability measures, which is why the ${\cal L}_1$ norm appears in your equation $(3)$. It is well-known that the variation distance represents a lower bound on the sum $\Pr[\text{type I error}] + \Pr[\text{type II error}]$ for any hypothesis testing method, and this bound is tight for the hypothesis testing method you described. Therefore, the variation distance measures the minimum achievable error rate of hypothesis testing (again, when $p(A) = p(B) = 1/2$). However, as you indicated, the variation distance can be difficult to calculate with. It is particularly annoying to deal with, if we might have multiple independent observations from the underlying distribution. Imagine that a referee secretly flips a coin to decide whether to use $A$ or $B$; then gives you $n$ independent draws from $p(x|A)$ (if he is using $A$) or $n$ independent draws from $p(x|B)$ (if he is using $B$), without telling you which. Your job is to decide whether he is using $A$ or $B$. What's the error rate of the optimal decision procedure for $n>1$, and how does it relate to the error rate for the case where $n=1$? This question is difficult to answer. It is not easy to relate the variation distance for the $n$-observation problem (the product measure, where $n>1$) to the variation distance for the single-observation case. One way that people deal with this in practice is to look at some other distance metric, such as the KL divergence or $\chi^2$ or something, that is well-behaved with product measures: i.e., some distance metric where we can cleanly relate the distance for the $n$-observation case to the $1$-observation case (where we can cleanly relate the distance measure for a product measure to the distance for the underlying distribution). Then, we use some bound that relates that distance metric to the variation distance, and Bob's our uncle. For more on this theme, read Hypothesis testing and total variation distance vs. Kullback-Leibler divergence and What is the relationship of ${\cal L}_1$ (total variation) distance to hypothesis testing?
On error probability bounds in Bayesian hypothesis testing
When $p(A) = p(B) = 1/2$, equation $(3)$ is basically computing the total variation distance (also known as the variation distance, for short). The variation distance is an ${\cal L}_1$ distance betw
On error probability bounds in Bayesian hypothesis testing When $p(A) = p(B) = 1/2$, equation $(3)$ is basically computing the total variation distance (also known as the variation distance, for short). The variation distance is an ${\cal L}_1$ distance between two probability measures, which is why the ${\cal L}_1$ norm appears in your equation $(3)$. It is well-known that the variation distance represents a lower bound on the sum $\Pr[\text{type I error}] + \Pr[\text{type II error}]$ for any hypothesis testing method, and this bound is tight for the hypothesis testing method you described. Therefore, the variation distance measures the minimum achievable error rate of hypothesis testing (again, when $p(A) = p(B) = 1/2$). However, as you indicated, the variation distance can be difficult to calculate with. It is particularly annoying to deal with, if we might have multiple independent observations from the underlying distribution. Imagine that a referee secretly flips a coin to decide whether to use $A$ or $B$; then gives you $n$ independent draws from $p(x|A)$ (if he is using $A$) or $n$ independent draws from $p(x|B)$ (if he is using $B$), without telling you which. Your job is to decide whether he is using $A$ or $B$. What's the error rate of the optimal decision procedure for $n>1$, and how does it relate to the error rate for the case where $n=1$? This question is difficult to answer. It is not easy to relate the variation distance for the $n$-observation problem (the product measure, where $n>1$) to the variation distance for the single-observation case. One way that people deal with this in practice is to look at some other distance metric, such as the KL divergence or $\chi^2$ or something, that is well-behaved with product measures: i.e., some distance metric where we can cleanly relate the distance for the $n$-observation case to the $1$-observation case (where we can cleanly relate the distance measure for a product measure to the distance for the underlying distribution). Then, we use some bound that relates that distance metric to the variation distance, and Bob's our uncle. For more on this theme, read Hypothesis testing and total variation distance vs. Kullback-Leibler divergence and What is the relationship of ${\cal L}_1$ (total variation) distance to hypothesis testing?
On error probability bounds in Bayesian hypothesis testing When $p(A) = p(B) = 1/2$, equation $(3)$ is basically computing the total variation distance (also known as the variation distance, for short). The variation distance is an ${\cal L}_1$ distance betw
42,191
Are both of these generalized additive models?
With the lrm command using rcs() you are constructing a cubic spline which is then used in the logistic regression. However, no penalty is applied to the coefficients of the cubic spline, unlike in gam, where a penalty for "roughness" is applied and the appropriate magnitude of the penalty is estimated using generalized cross-validation. lrm and ols from the Design package do have options for penalized estimation, though. Also note that gam has options for other types of smooth functions than just cubic splines. Whether or not lrm with rcs is a "generalized additive model" depends, I suppose, on whether one thinks that not having a roughness penalty when fitting a spline takes you out of the spline-based gam framework or not.
Are both of these generalized additive models?
With the lrm command using rcs() you are constructing a cubic spline which is then used in the logistic regression. However, no penalty is applied to the coefficients of the cubic spline, unlike in g
Are both of these generalized additive models? With the lrm command using rcs() you are constructing a cubic spline which is then used in the logistic regression. However, no penalty is applied to the coefficients of the cubic spline, unlike in gam, where a penalty for "roughness" is applied and the appropriate magnitude of the penalty is estimated using generalized cross-validation. lrm and ols from the Design package do have options for penalized estimation, though. Also note that gam has options for other types of smooth functions than just cubic splines. Whether or not lrm with rcs is a "generalized additive model" depends, I suppose, on whether one thinks that not having a roughness penalty when fitting a spline takes you out of the spline-based gam framework or not.
Are both of these generalized additive models? With the lrm command using rcs() you are constructing a cubic spline which is then used in the logistic regression. However, no penalty is applied to the coefficients of the cubic spline, unlike in g
42,192
Estimating joint distributions using copula package in R
Check out A Short, Comprehensive, Practical Guide to Copulas by Atillio Meucci. The paper provides further references in case you'd like to learn more. Steps #3 and #5 are addressed by this paper. Step #4 is specific to this particular function which I am not too familiar. Since you have so many questions you'd probably have better success breaking down the problem into related parts. You will be in a better place to frame question #4 after some further background reading. As such you really can't answer the question without going into the background of copulas. There are parametric and non-parametric methods to estimating copulas. In my view, parametric copulas impose tight restrictions that are not respected by the data (non-stationarity, fat tails, etc.). More recent research on time-varying copulas and Meucci's non-parametric copulas I believe can better cope with these issues.
Estimating joint distributions using copula package in R
Check out A Short, Comprehensive, Practical Guide to Copulas by Atillio Meucci. The paper provides further references in case you'd like to learn more. Steps #3 and #5 are addressed by this paper. St
Estimating joint distributions using copula package in R Check out A Short, Comprehensive, Practical Guide to Copulas by Atillio Meucci. The paper provides further references in case you'd like to learn more. Steps #3 and #5 are addressed by this paper. Step #4 is specific to this particular function which I am not too familiar. Since you have so many questions you'd probably have better success breaking down the problem into related parts. You will be in a better place to frame question #4 after some further background reading. As such you really can't answer the question without going into the background of copulas. There are parametric and non-parametric methods to estimating copulas. In my view, parametric copulas impose tight restrictions that are not respected by the data (non-stationarity, fat tails, etc.). More recent research on time-varying copulas and Meucci's non-parametric copulas I believe can better cope with these issues.
Estimating joint distributions using copula package in R Check out A Short, Comprehensive, Practical Guide to Copulas by Atillio Meucci. The paper provides further references in case you'd like to learn more. Steps #3 and #5 are addressed by this paper. St
42,193
Transformation to fit gamma distribution for glm
A gamma distribution definitely doesn't make sense for you data. Gamma takes support on the entire real line and is always skewed right. The example data you provide in your code would be horrible data to try to fit a gamma to. It would definitely be nicer to know more about the data generation process. But one thing that comes to mind is you could scale and shift the data to be constrained between 0 and 1 and then attempt to use a Beta distribution to model that. Once again it would be better to know more about your data but a Beta is one of the few well known parametric distributions that is bounded below and above. However, it seems you want to do some sort of a regression. Have you tried to fit the regression assuming a normal error term and examining the residuals? A lot of people assume that the data itself needs to be normally distributed for a linear regression to work but typically we place the assumption on the error term and depending on the values your covariates take this can lead to a skewed distribution for your response variable.
Transformation to fit gamma distribution for glm
A gamma distribution definitely doesn't make sense for you data. Gamma takes support on the entire real line and is always skewed right. The example data you provide in your code would be horrible d
Transformation to fit gamma distribution for glm A gamma distribution definitely doesn't make sense for you data. Gamma takes support on the entire real line and is always skewed right. The example data you provide in your code would be horrible data to try to fit a gamma to. It would definitely be nicer to know more about the data generation process. But one thing that comes to mind is you could scale and shift the data to be constrained between 0 and 1 and then attempt to use a Beta distribution to model that. Once again it would be better to know more about your data but a Beta is one of the few well known parametric distributions that is bounded below and above. However, it seems you want to do some sort of a regression. Have you tried to fit the regression assuming a normal error term and examining the residuals? A lot of people assume that the data itself needs to be normally distributed for a linear regression to work but typically we place the assumption on the error term and depending on the values your covariates take this can lead to a skewed distribution for your response variable.
Transformation to fit gamma distribution for glm A gamma distribution definitely doesn't make sense for you data. Gamma takes support on the entire real line and is always skewed right. The example data you provide in your code would be horrible d
42,194
Transformation to fit gamma distribution for glm
I was going to suggest using binomial regression with a probit link on the original hit/false alarm counts, but before writing out the details I googled for this idea. Apparently, someone else thought of it already (there goes a publication :) Here is the reference (in case the link is restricted), there is also an R package sensR to go with it: PB Brockhoff, RH Bojesen Christensen (2010) Thurstonian models for sensory discrimination tests as generalized linear models, Food Quality and Preference, 21(3), 330-338.
Transformation to fit gamma distribution for glm
I was going to suggest using binomial regression with a probit link on the original hit/false alarm counts, but before writing out the details I googled for this idea. Apparently, someone else thought
Transformation to fit gamma distribution for glm I was going to suggest using binomial regression with a probit link on the original hit/false alarm counts, but before writing out the details I googled for this idea. Apparently, someone else thought of it already (there goes a publication :) Here is the reference (in case the link is restricted), there is also an R package sensR to go with it: PB Brockhoff, RH Bojesen Christensen (2010) Thurstonian models for sensory discrimination tests as generalized linear models, Food Quality and Preference, 21(3), 330-338.
Transformation to fit gamma distribution for glm I was going to suggest using binomial regression with a probit link on the original hit/false alarm counts, but before writing out the details I googled for this idea. Apparently, someone else thought
42,195
How many data points to fit an ex-Gaussian distribution?
If I recall correctly, as sample size decreases, mu will manifest positive bias while tau will manifest negative bias. Sigma will manifest either positive or negative bias depending on true values of the other parameters. This paper compares two methods of fitting ex-Gaussians, and from the figures I'd probably avoid going below 40 observations.
How many data points to fit an ex-Gaussian distribution?
If I recall correctly, as sample size decreases, mu will manifest positive bias while tau will manifest negative bias. Sigma will manifest either positive or negative bias depending on true values of
How many data points to fit an ex-Gaussian distribution? If I recall correctly, as sample size decreases, mu will manifest positive bias while tau will manifest negative bias. Sigma will manifest either positive or negative bias depending on true values of the other parameters. This paper compares two methods of fitting ex-Gaussians, and from the figures I'd probably avoid going below 40 observations.
How many data points to fit an ex-Gaussian distribution? If I recall correctly, as sample size decreases, mu will manifest positive bias while tau will manifest negative bias. Sigma will manifest either positive or negative bias depending on true values of
42,196
How many data points to fit an ex-Gaussian distribution?
Since the parameters are estimated using maximum-likelihood method you have that $$\sqrt{n}(\hat\theta -\theta)\to N(0,I_{\theta}^{-1}),$$ where $I_{\theta}$ is the Fisher information matrix, and $\theta$ is the vector of parameters in question. Hence $$Var(\hat\theta-\theta)\approx 1/nI_{\theta}^{-1}$$ If you have calculated $I_{\theta}^{-1}$ and you suspect the approximate values of true $\theta$, this will give you an idea of approximate variance. You can then work out what is the minimum number of points. This is not perfect solution, but as a rule of thumb it might work.
How many data points to fit an ex-Gaussian distribution?
Since the parameters are estimated using maximum-likelihood method you have that $$\sqrt{n}(\hat\theta -\theta)\to N(0,I_{\theta}^{-1}),$$ where $I_{\theta}$ is the Fisher information matrix, and $\th
How many data points to fit an ex-Gaussian distribution? Since the parameters are estimated using maximum-likelihood method you have that $$\sqrt{n}(\hat\theta -\theta)\to N(0,I_{\theta}^{-1}),$$ where $I_{\theta}$ is the Fisher information matrix, and $\theta$ is the vector of parameters in question. Hence $$Var(\hat\theta-\theta)\approx 1/nI_{\theta}^{-1}$$ If you have calculated $I_{\theta}^{-1}$ and you suspect the approximate values of true $\theta$, this will give you an idea of approximate variance. You can then work out what is the minimum number of points. This is not perfect solution, but as a rule of thumb it might work.
How many data points to fit an ex-Gaussian distribution? Since the parameters are estimated using maximum-likelihood method you have that $$\sqrt{n}(\hat\theta -\theta)\to N(0,I_{\theta}^{-1}),$$ where $I_{\theta}$ is the Fisher information matrix, and $\th
42,197
Bicubic/bilinear interpolation in R
Check out the akima package's interp. These functions implement bivariate interpolation onto a grid for irregularly spaced input data. Bilinear or bicubic spline interpolation is applied using different versions of algorithms from Akima. Usage interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FALSE, duplicate = "error", dupfun = NULL, ncp = NULL) I assume it will work if your data is regularly spaced as well.
Bicubic/bilinear interpolation in R
Check out the akima package's interp. These functions implement bivariate interpolation onto a grid for irregularly spaced input data. Bilinear or bicubic spline interpolation is applied using differ
Bicubic/bilinear interpolation in R Check out the akima package's interp. These functions implement bivariate interpolation onto a grid for irregularly spaced input data. Bilinear or bicubic spline interpolation is applied using different versions of algorithms from Akima. Usage interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FALSE, duplicate = "error", dupfun = NULL, ncp = NULL) I assume it will work if your data is regularly spaced as well.
Bicubic/bilinear interpolation in R Check out the akima package's interp. These functions implement bivariate interpolation onto a grid for irregularly spaced input data. Bilinear or bicubic spline interpolation is applied using differ
42,198
Bicubic/bilinear interpolation in R
You could use image.smooth in the fields package.
Bicubic/bilinear interpolation in R
You could use image.smooth in the fields package.
Bicubic/bilinear interpolation in R You could use image.smooth in the fields package.
Bicubic/bilinear interpolation in R You could use image.smooth in the fields package.
42,199
Bicubic/bilinear interpolation in R
To export the data you have interpolated , you could use the follow way: model <- interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FALSE, duplicate = "error", dupfun = NULL, ncp = NULL) interpData <- model$z Load the follow libraries library(rJava) library(xlsxjars) library(xlsx) Export your interpolated data in Excel with title multivariateInterp in your hard disc write.xlsx (interpData, "c:/multivariateInterp.xlsx")
Bicubic/bilinear interpolation in R
To export the data you have interpolated , you could use the follow way: model <- interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FA
Bicubic/bilinear interpolation in R To export the data you have interpolated , you could use the follow way: model <- interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FALSE, duplicate = "error", dupfun = NULL, ncp = NULL) interpData <- model$z Load the follow libraries library(rJava) library(xlsxjars) library(xlsx) Export your interpolated data in Excel with title multivariateInterp in your hard disc write.xlsx (interpData, "c:/multivariateInterp.xlsx")
Bicubic/bilinear interpolation in R To export the data you have interpolated , you could use the follow way: model <- interp(x, y, z, xo=seq(min(x), max(x), length = 40), yo=seq(min(y), max(y), length = 40), linear = TRUE, extrap=FA
42,200
Why the statistical model of sampling with replacement is incomplete?
I'm not sure what your model for sampling with replacement is, but I suspect (and hope) it will include the following simple example, a standard model of a Bernoulli experiment (such as a coin flip). The idea behind it is to make a random variable depend on the order in which outcomes are observed in the sample. We can change its value on one permutation and compensate for that by changing its values on other permutations so that its expectation remains unchanged, no matter what the underlying probability law may be. Here are the mathematical details. Let the sample space be the doubleton $\{\alpha, \beta\}$ having the entire power set for its sigma algebra. All probability measures can be parameterized by a single real value $p \in [0,1]$ determined by $p=\Pr[\beta]$. As an aside, this model is complete. Any real-valued function $X$ is automatically measurable. If $0 = E_p[X] = (1-p)X(\alpha) + pX(\beta)$ for all $p$, then (by choosing two distinct values of $p$) we easily deduce that $X$ vanishes everywhere: $X(\alpha)=X(\beta)=0$. Your statement is false for $n=1$. Let's therefore assume $n \gt 1$. Consider $n=2$. A sample with replacement yields one of $(\alpha, \alpha)$, $(\alpha,\beta)$, $(\beta, \alpha)$, or $(\beta, \beta)$, with probabilities $(1-p)^2$, $(1-p)p$, $p(1-p)$, and $p^2$, respectively. Consider a function of the form $X(\alpha,\alpha)$ $=X(\beta,\beta)=0$ and $X(\beta,\alpha)=-X(\alpha,\beta)\ne 0$. It is measurable (i.e., it is a random variable) and $$\eqalign{ E_p[X] &= (1-p)^2X(\alpha,\alpha) +(1-p)pX(\alpha,\beta) + p(1-p)X(\beta,\alpha) + p^2X(\beta,\beta) \\ &=(1-p)^2 0 + p(1-p)X(\alpha,\beta) + p(1-p)X(\beta,\alpha)+ p^2 0 \\ &=0 + p(1-p)\left(X(\alpha,\beta)-X(\alpha,\beta)\right) + 0 \\ &=0. }$$ This expectation is zero for all $p$. However, because $X(\alpha,\beta) \ne 0$, $X$ will be nonzero with positive probability whenever $p \notin \{0,1\}$, showing the model of sampling with replacement is incomplete. The point (intuitively) is that when $n \gt 1$, sampling with replacement is a multidimensional situation but you only have a one-dimensional family of probability laws available. You cannot represent all the possible multidimensional probability measures by means of the one-dimensional family you have.
Why the statistical model of sampling with replacement is incomplete?
I'm not sure what your model for sampling with replacement is, but I suspect (and hope) it will include the following simple example, a standard model of a Bernoulli experiment (such as a coin flip).
Why the statistical model of sampling with replacement is incomplete? I'm not sure what your model for sampling with replacement is, but I suspect (and hope) it will include the following simple example, a standard model of a Bernoulli experiment (such as a coin flip). The idea behind it is to make a random variable depend on the order in which outcomes are observed in the sample. We can change its value on one permutation and compensate for that by changing its values on other permutations so that its expectation remains unchanged, no matter what the underlying probability law may be. Here are the mathematical details. Let the sample space be the doubleton $\{\alpha, \beta\}$ having the entire power set for its sigma algebra. All probability measures can be parameterized by a single real value $p \in [0,1]$ determined by $p=\Pr[\beta]$. As an aside, this model is complete. Any real-valued function $X$ is automatically measurable. If $0 = E_p[X] = (1-p)X(\alpha) + pX(\beta)$ for all $p$, then (by choosing two distinct values of $p$) we easily deduce that $X$ vanishes everywhere: $X(\alpha)=X(\beta)=0$. Your statement is false for $n=1$. Let's therefore assume $n \gt 1$. Consider $n=2$. A sample with replacement yields one of $(\alpha, \alpha)$, $(\alpha,\beta)$, $(\beta, \alpha)$, or $(\beta, \beta)$, with probabilities $(1-p)^2$, $(1-p)p$, $p(1-p)$, and $p^2$, respectively. Consider a function of the form $X(\alpha,\alpha)$ $=X(\beta,\beta)=0$ and $X(\beta,\alpha)=-X(\alpha,\beta)\ne 0$. It is measurable (i.e., it is a random variable) and $$\eqalign{ E_p[X] &= (1-p)^2X(\alpha,\alpha) +(1-p)pX(\alpha,\beta) + p(1-p)X(\beta,\alpha) + p^2X(\beta,\beta) \\ &=(1-p)^2 0 + p(1-p)X(\alpha,\beta) + p(1-p)X(\beta,\alpha)+ p^2 0 \\ &=0 + p(1-p)\left(X(\alpha,\beta)-X(\alpha,\beta)\right) + 0 \\ &=0. }$$ This expectation is zero for all $p$. However, because $X(\alpha,\beta) \ne 0$, $X$ will be nonzero with positive probability whenever $p \notin \{0,1\}$, showing the model of sampling with replacement is incomplete. The point (intuitively) is that when $n \gt 1$, sampling with replacement is a multidimensional situation but you only have a one-dimensional family of probability laws available. You cannot represent all the possible multidimensional probability measures by means of the one-dimensional family you have.
Why the statistical model of sampling with replacement is incomplete? I'm not sure what your model for sampling with replacement is, but I suspect (and hope) it will include the following simple example, a standard model of a Bernoulli experiment (such as a coin flip).