idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
16,701
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions?
In this answer I will explore two interesting and relevant papers that were brought up in the comments. Before doing so, I will attempt to formalize the problem and to shed some light on some of the assumptions and definitions. I begin with a 2016 paper by Lee et al. We seek to minimize a non-convex function $f: \mathbb{R}^d \to \mathbb{R}$ that is bounded below. We require it to be twice differentiable. We use a gradient descent algorithm of the form: $\pmb{x}_{t+1} = \pmb{x}_t - \alpha\nabla f(\pmb{x}_t)$. Additionally, we have the following requirement: $\| \nabla f(\pmb{x}_1)-\nabla f(\pmb{x}_2) \| \leq \ell \| \pmb{x}_1 - \pmb{x}_2 \|, \quad \text{for all } \pmb{x}_1, \pmb{x}_2$. That is, we require our function to be $\ell$-Lipschitz in its first derivative. In english this translates to the idea that our gradient can not change too rapidly anywhere in the domain. This assumption ensures that we can choose a step-size such that we never end up with steps that diverge. Recall that a point $\pmb{x}$ is said to be a strict saddle if $\nabla f(\pmb{x}) = 0$ and $\lambda_{\min}\left(\nabla^2 f(\pmb{x})\right) < 0$ and $\lambda_{\max}\left(\nabla^2 f(\pmb{x})\right) > 0$. If all of the eigenvalues of the Hessian have the same sign then the point is a minimum (if they're positive) or a maximum (if they're negative). If there are any 0 eigenvalues then it is said to be degenerate, and it is not a strict saddle. The paper shows that with the above assumptions, along with the assumption that all saddle points of the function are strict-saddle, gradient descent is guaranteed to converge to a minimum. The proof is quite technical, but the intuition is this: define a set $W^s(\pmb{x}^s) = \{\pmb{x} : \lim_k g^k(\pmb{x}) = \pmb{x}^s \}$, where $\pmb{x}^s$ is a saddle point. I don't like this notation at all. What they are trying to get at is that $W$ is the set of starting values for which the gradient map $g : \mathbb{R}^d \to \mathbb{R}^d$ sends $\pmb{x}_k$ to $\pmb{x}^s$. Put more plainly, it is the set of random initializations that will ultimately converge to a saddle. Their argument relies on the Stable Manifold Theorem. With the above assumptions and a bunch of esoteric math they conclude that the set $W^s$ must be measure zero, that is, there is zero probability of randomly initializing on a point that will converge to a saddle point. As we know that gradient descent on functions of the type outlined in the assumptions with suitably small step sizes will eventually reach a critical point, and we now know (almost surely) that it will never land on a saddle, we know that it converges to a minimizer. The second, more recent paper by Reddi et al. I will discuss in less detail. There are several differences. First, they are no longer working in a deterministic framework, instead opting for the more practically relevant stochastic approximation framework on a finite sum (think Stochastic Gradient Descent). The primary differences there are that the step-size requires some additional care, and the gradient becomes a random variable. Additionally, they relax the assumption that all saddles are strict, and look for a second-order stationary point. That is, a point such that, $ \|\nabla(f) \| \leq \epsilon, \quad \text{and}, \quad \lambda_{\min}\left(\nabla^2 f(\pmb{x})\right)\geq -\sqrt{\rho\epsilon}$ Where $\rho$ is the Lipschitz constant for the Hessian. (That is, in addition to the requirement that our gradient not vary too rapidly, we now have a similar requirement on our Hessian. Essentially, the authors are looking for a point which looks like a minimum in both the first and second derivative. The method by which they accomplish this is to use a variant (pick your favorite) of stochastic gradient descent most of the time. But wherever they encounter a point where $\lambda_{\min}\left(\nabla^2 f(\pmb{x})\right)\leq 0$, they use a suitably chosen second order method to escape the saddle. They show that by incorporating this second order information as-needed they will converge to a second-order stationary point. Technically this is a second order gradient method, which may or may not fall under the umbrella of algorithms you were interested in. This is a very active area of research and I've left out many important contributions (ex Ge et al.). I'm also new to the topic so this question has provided me an opportunity to look. I'm happy to continue the discussion if there is interest. *** Suitably chosen means one one that is shown to converge to a second-order stationary point. They use the Cubic regularized Newton method of Nesterov and Polyak.
When will gradient descent converge to a critical point or to a local/global minima) for non-convex
In this answer I will explore two interesting and relevant papers that were brought up in the comments. Before doing so, I will attempt to formalize the problem and to shed some light on some of the a
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions? In this answer I will explore two interesting and relevant papers that were brought up in the comments. Before doing so, I will attempt to formalize the problem and to shed some light on some of the assumptions and definitions. I begin with a 2016 paper by Lee et al. We seek to minimize a non-convex function $f: \mathbb{R}^d \to \mathbb{R}$ that is bounded below. We require it to be twice differentiable. We use a gradient descent algorithm of the form: $\pmb{x}_{t+1} = \pmb{x}_t - \alpha\nabla f(\pmb{x}_t)$. Additionally, we have the following requirement: $\| \nabla f(\pmb{x}_1)-\nabla f(\pmb{x}_2) \| \leq \ell \| \pmb{x}_1 - \pmb{x}_2 \|, \quad \text{for all } \pmb{x}_1, \pmb{x}_2$. That is, we require our function to be $\ell$-Lipschitz in its first derivative. In english this translates to the idea that our gradient can not change too rapidly anywhere in the domain. This assumption ensures that we can choose a step-size such that we never end up with steps that diverge. Recall that a point $\pmb{x}$ is said to be a strict saddle if $\nabla f(\pmb{x}) = 0$ and $\lambda_{\min}\left(\nabla^2 f(\pmb{x})\right) < 0$ and $\lambda_{\max}\left(\nabla^2 f(\pmb{x})\right) > 0$. If all of the eigenvalues of the Hessian have the same sign then the point is a minimum (if they're positive) or a maximum (if they're negative). If there are any 0 eigenvalues then it is said to be degenerate, and it is not a strict saddle. The paper shows that with the above assumptions, along with the assumption that all saddle points of the function are strict-saddle, gradient descent is guaranteed to converge to a minimum. The proof is quite technical, but the intuition is this: define a set $W^s(\pmb{x}^s) = \{\pmb{x} : \lim_k g^k(\pmb{x}) = \pmb{x}^s \}$, where $\pmb{x}^s$ is a saddle point. I don't like this notation at all. What they are trying to get at is that $W$ is the set of starting values for which the gradient map $g : \mathbb{R}^d \to \mathbb{R}^d$ sends $\pmb{x}_k$ to $\pmb{x}^s$. Put more plainly, it is the set of random initializations that will ultimately converge to a saddle. Their argument relies on the Stable Manifold Theorem. With the above assumptions and a bunch of esoteric math they conclude that the set $W^s$ must be measure zero, that is, there is zero probability of randomly initializing on a point that will converge to a saddle point. As we know that gradient descent on functions of the type outlined in the assumptions with suitably small step sizes will eventually reach a critical point, and we now know (almost surely) that it will never land on a saddle, we know that it converges to a minimizer. The second, more recent paper by Reddi et al. I will discuss in less detail. There are several differences. First, they are no longer working in a deterministic framework, instead opting for the more practically relevant stochastic approximation framework on a finite sum (think Stochastic Gradient Descent). The primary differences there are that the step-size requires some additional care, and the gradient becomes a random variable. Additionally, they relax the assumption that all saddles are strict, and look for a second-order stationary point. That is, a point such that, $ \|\nabla(f) \| \leq \epsilon, \quad \text{and}, \quad \lambda_{\min}\left(\nabla^2 f(\pmb{x})\right)\geq -\sqrt{\rho\epsilon}$ Where $\rho$ is the Lipschitz constant for the Hessian. (That is, in addition to the requirement that our gradient not vary too rapidly, we now have a similar requirement on our Hessian. Essentially, the authors are looking for a point which looks like a minimum in both the first and second derivative. The method by which they accomplish this is to use a variant (pick your favorite) of stochastic gradient descent most of the time. But wherever they encounter a point where $\lambda_{\min}\left(\nabla^2 f(\pmb{x})\right)\leq 0$, they use a suitably chosen second order method to escape the saddle. They show that by incorporating this second order information as-needed they will converge to a second-order stationary point. Technically this is a second order gradient method, which may or may not fall under the umbrella of algorithms you were interested in. This is a very active area of research and I've left out many important contributions (ex Ge et al.). I'm also new to the topic so this question has provided me an opportunity to look. I'm happy to continue the discussion if there is interest. *** Suitably chosen means one one that is shown to converge to a second-order stationary point. They use the Cubic regularized Newton method of Nesterov and Polyak.
When will gradient descent converge to a critical point or to a local/global minima) for non-convex In this answer I will explore two interesting and relevant papers that were brought up in the comments. Before doing so, I will attempt to formalize the problem and to shed some light on some of the a
16,702
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions?
I will try and answer the "when does Gradient Descent convergence to a critical point" part of the question. The paper "Convergence of descent methods for semi-algebraic and tame problems: proximal algorithms, forward-backward splitting, and regularized Gauss-Seidel methods" by Attouch, Bolte and Svaiter, shows that if the objective function satisfies the Kurdyka-Lojasiewicz (KL) inequality, then GD and other descent methods do in fact converge to a minimizer. Note that the KL condition is extremely general but hard to grasp. Functions which satisfy KL are for example given by semi-algebraic functions (again, very general but not a simple notion). In order to give some intuitions about these notions I'll try to be less vague but also not too technical, so bare with me. A function $f$ satisfies the KL condition at a critical point $\bar{x}$ if there exists a function $\phi$ (note that I'm leaving out some conditions) such that $$ || \nabla (\phi \circ f)(x)|| \ge 1 $$ for all $x$ such that $f(\bar{x}) < f(x) < r$ for some $r$. The intuition is that there exists a function $\phi$ which reparametrizes our function of interest $f$ in such a way that it is sharp around the critical point (the derivative is bounded away from zero). In some sense this means, that the function can't be too flat around $\bar{x}$. Semialgebricity on the other hand is a bit more difficult. The field studying it is also known as tame geometry. I think the name tame captures the essence very well. Functions belonging to this class can't be arbitrarily "wild".
When will gradient descent converge to a critical point or to a local/global minima) for non-convex
I will try and answer the "when does Gradient Descent convergence to a critical point" part of the question. The paper "Convergence of descent methods for semi-algebraic and tame problems: proximal a
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions? I will try and answer the "when does Gradient Descent convergence to a critical point" part of the question. The paper "Convergence of descent methods for semi-algebraic and tame problems: proximal algorithms, forward-backward splitting, and regularized Gauss-Seidel methods" by Attouch, Bolte and Svaiter, shows that if the objective function satisfies the Kurdyka-Lojasiewicz (KL) inequality, then GD and other descent methods do in fact converge to a minimizer. Note that the KL condition is extremely general but hard to grasp. Functions which satisfy KL are for example given by semi-algebraic functions (again, very general but not a simple notion). In order to give some intuitions about these notions I'll try to be less vague but also not too technical, so bare with me. A function $f$ satisfies the KL condition at a critical point $\bar{x}$ if there exists a function $\phi$ (note that I'm leaving out some conditions) such that $$ || \nabla (\phi \circ f)(x)|| \ge 1 $$ for all $x$ such that $f(\bar{x}) < f(x) < r$ for some $r$. The intuition is that there exists a function $\phi$ which reparametrizes our function of interest $f$ in such a way that it is sharp around the critical point (the derivative is bounded away from zero). In some sense this means, that the function can't be too flat around $\bar{x}$. Semialgebricity on the other hand is a bit more difficult. The field studying it is also known as tame geometry. I think the name tame captures the essence very well. Functions belonging to this class can't be arbitrarily "wild".
When will gradient descent converge to a critical point or to a local/global minima) for non-convex I will try and answer the "when does Gradient Descent convergence to a critical point" part of the question. The paper "Convergence of descent methods for semi-algebraic and tame problems: proximal a
16,703
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions?
See appendix B1 in https://web.stanford.edu/~boyd/cvxbook/. The function and the constraint can be non-convex in a Quadratically Constrained Quadratic Program, and you can still see strong duality (it is guaranteed if a technical condition known as Slater's constraint qualifier holds) Strong duality in weak terms means that we can solve the optimization problem. From the original problem which is called the primal, you can formulate an alternative problem called the dual problem. The solution of the dual problem provides a solution which in some sense is the "best lower bound" for your original problems In a lot of the optimization problems which are non-convex, there will be a gap between the primal and dual solutions i.e., the lower bound can be far below the true optimal value (even negative infinity). In some special cases, the bound is tight. These special cases are those in which we have strong duality. The algorithm is a TECHNIQUE used to arrive at the optimal point. The optimal solution and our ability to find it depends on the GEOMETRY of the problem (which is what duality tries to arrive at). Loosely put, the analysis says that if the optimization properly set up will converge to a minimum. In general, the gradient descent will converge to a stationary point. This point can be a local minimum/global minimum/saddle minimum. In only few non-convex cases we can guarantee what it converges to
When will gradient descent converge to a critical point or to a local/global minima) for non-convex
See appendix B1 in https://web.stanford.edu/~boyd/cvxbook/. The function and the constraint can be non-convex in a Quadratically Constrained Quadratic Program, and you can still see strong duality (i
When will gradient descent converge to a critical point or to a local/global minima) for non-convex functions? See appendix B1 in https://web.stanford.edu/~boyd/cvxbook/. The function and the constraint can be non-convex in a Quadratically Constrained Quadratic Program, and you can still see strong duality (it is guaranteed if a technical condition known as Slater's constraint qualifier holds) Strong duality in weak terms means that we can solve the optimization problem. From the original problem which is called the primal, you can formulate an alternative problem called the dual problem. The solution of the dual problem provides a solution which in some sense is the "best lower bound" for your original problems In a lot of the optimization problems which are non-convex, there will be a gap between the primal and dual solutions i.e., the lower bound can be far below the true optimal value (even negative infinity). In some special cases, the bound is tight. These special cases are those in which we have strong duality. The algorithm is a TECHNIQUE used to arrive at the optimal point. The optimal solution and our ability to find it depends on the GEOMETRY of the problem (which is what duality tries to arrive at). Loosely put, the analysis says that if the optimization properly set up will converge to a minimum. In general, the gradient descent will converge to a stationary point. This point can be a local minimum/global minimum/saddle minimum. In only few non-convex cases we can guarantee what it converges to
When will gradient descent converge to a critical point or to a local/global minima) for non-convex See appendix B1 in https://web.stanford.edu/~boyd/cvxbook/. The function and the constraint can be non-convex in a Quadratically Constrained Quadratic Program, and you can still see strong duality (i
16,704
Sampling from marginal distribution using conditional distribution?
Yes, this is correct. Basically, you have $$f_{X,Y}(x,y) = f_{X|Y}(x|y) f_Y(y),$$ and as you said, you can sample from the joint density. Picking up just the $x$s from the samples leads you to a sample from the marginal distribution. This is because the act of ignoring the $y$ is akin to integrating over it. Lets understand this with an example. Suppose $X$ = Height of mothers and $Y$ = Height of daughter. The goal is to get a sample from $(X,Y)$ to understand the relation between the heights of daughters and their mothers. (I am making the assumption that there is only one daughter in the family, and restricting the population to all daughters over age 18 to ensure full growth). You go out and get a representative sample $$(x_1, y_1), \dots, (x_N, y_N). $$ Thus for each mother, you have the height of their daughter. There should be a clear relationship between $X$ and $Y$. Now suppose from your dataset, you ignore all the data on the daughters (drop the $Y$), then what do you have? You have exactly heights of randomly chosen mothers which will be $N$ draws from the marginal of $X$.
Sampling from marginal distribution using conditional distribution?
Yes, this is correct. Basically, you have $$f_{X,Y}(x,y) = f_{X|Y}(x|y) f_Y(y),$$ and as you said, you can sample from the joint density. Picking up just the $x$s from the samples leads you to a sampl
Sampling from marginal distribution using conditional distribution? Yes, this is correct. Basically, you have $$f_{X,Y}(x,y) = f_{X|Y}(x|y) f_Y(y),$$ and as you said, you can sample from the joint density. Picking up just the $x$s from the samples leads you to a sample from the marginal distribution. This is because the act of ignoring the $y$ is akin to integrating over it. Lets understand this with an example. Suppose $X$ = Height of mothers and $Y$ = Height of daughter. The goal is to get a sample from $(X,Y)$ to understand the relation between the heights of daughters and their mothers. (I am making the assumption that there is only one daughter in the family, and restricting the population to all daughters over age 18 to ensure full growth). You go out and get a representative sample $$(x_1, y_1), \dots, (x_N, y_N). $$ Thus for each mother, you have the height of their daughter. There should be a clear relationship between $X$ and $Y$. Now suppose from your dataset, you ignore all the data on the daughters (drop the $Y$), then what do you have? You have exactly heights of randomly chosen mothers which will be $N$ draws from the marginal of $X$.
Sampling from marginal distribution using conditional distribution? Yes, this is correct. Basically, you have $$f_{X,Y}(x,y) = f_{X|Y}(x|y) f_Y(y),$$ and as you said, you can sample from the joint density. Picking up just the $x$s from the samples leads you to a sampl
16,705
What should a graduate course in experimental design cover?
Here is a list of some books that I like and which would be good material for such a course: David Cox: Planning of Experiments, Wiley classics, 1992. This is non-mathematical, but not easy! A profound discussion of basic concepts behind design. D. R. Cox & Nancy Reid: The Theory of the Design of Experiments, Chapman & Hall, 2000. More mathematical, but still with focus on basic concepts Rosemary A. Bailey: Design of Comparative Experiments, Cambridge UP, 2008. From the foreword: "My philosophy is that you should not choose an experimental design from a list of named designs. Rather, you should think about all aspects of the current experiment, and then decide on how to put them together appropriately ...". George Casella: Statistical Design, Springer, 2008. Another book looking at old topics with fresh eyes! You could do worse than look at George E. P. Box, J Stuart Hunter and William G. Hunter: Statistics for Experimenters: Design, Innovation and Discovery (second edition, Wiley, 2005) for inspiration. I would avoid older books looking like a catalog of named designs, and go for one of the above based on fundamental principles. One such book I would avoid is the popular (why?) Douglas C. Montgomery: Design and Analysis of Experiments. EDIT 2017 Another topic which could be included is optimal experimental design, with concepts such as D-optimal designs or A-optimal designs. There is now a plethora of books, so difficult to advice, some possibilities: Optimal Experimental Design with R Optimal Crossover Designs Optimal Experimental Design for Non-Linear Models: Theory and Applications Optimal Design of Experiments: A Case Study Approach There is a lot of development in this area in R, so have a look at https://CRAN.R-project.org/view=ExperimentalDesign
What should a graduate course in experimental design cover?
Here is a list of some books that I like and which would be good material for such a course: David Cox: Planning of Experiments, Wiley classics, 1992. This is non-mathematical, but not easy! A profo
What should a graduate course in experimental design cover? Here is a list of some books that I like and which would be good material for such a course: David Cox: Planning of Experiments, Wiley classics, 1992. This is non-mathematical, but not easy! A profound discussion of basic concepts behind design. D. R. Cox & Nancy Reid: The Theory of the Design of Experiments, Chapman & Hall, 2000. More mathematical, but still with focus on basic concepts Rosemary A. Bailey: Design of Comparative Experiments, Cambridge UP, 2008. From the foreword: "My philosophy is that you should not choose an experimental design from a list of named designs. Rather, you should think about all aspects of the current experiment, and then decide on how to put them together appropriately ...". George Casella: Statistical Design, Springer, 2008. Another book looking at old topics with fresh eyes! You could do worse than look at George E. P. Box, J Stuart Hunter and William G. Hunter: Statistics for Experimenters: Design, Innovation and Discovery (second edition, Wiley, 2005) for inspiration. I would avoid older books looking like a catalog of named designs, and go for one of the above based on fundamental principles. One such book I would avoid is the popular (why?) Douglas C. Montgomery: Design and Analysis of Experiments. EDIT 2017 Another topic which could be included is optimal experimental design, with concepts such as D-optimal designs or A-optimal designs. There is now a plethora of books, so difficult to advice, some possibilities: Optimal Experimental Design with R Optimal Crossover Designs Optimal Experimental Design for Non-Linear Models: Theory and Applications Optimal Design of Experiments: A Case Study Approach There is a lot of development in this area in R, so have a look at https://CRAN.R-project.org/view=ExperimentalDesign
What should a graduate course in experimental design cover? Here is a list of some books that I like and which would be good material for such a course: David Cox: Planning of Experiments, Wiley classics, 1992. This is non-mathematical, but not easy! A profo
16,706
significance of difference between two counts
If you're happy to assume each count follows a Poisson distribution (with its own mean under the alternative hypothesis; with a common mean under the null) there's no problem—it's just that you can't check that assumption without replicates. Overdispersion can be quite common with count data. An exact test given counts $x_1$ & $x_2$ is straightforward because the overall total of counts $n=x_1+x_2$ is ancillary; conditioning on it gives $X_1 \sim \mathrm{Bin}\left(\frac{1}{2},n\right)$ as the distribution of your test statistic under the null.† It's an intuitive result: the overall count, reflecting perhaps how much time you could be bothered to spend observing the two Poisson processes, carries no information about their relative rates, but affects the power of your test; & therefore other overall counts you might've got are irrelevant. See Likelihood-based hypothesis testing for the Wald test (an approximation). † Each count $x_i$ has a Poisson distribution with mean $\lambda_i$ $$\newcommand{\e}{\mathrm{e}} f{_X}(x_i)=\frac{\lambda_i^{x_i}\e^{-\lambda_i}}{x_i!}\qquad i=1,2$$ Reparametrize as $$\begin{align} \theta&=\frac{\lambda_1}{\lambda_1+\lambda_2}\\ \phi&=\lambda_1+\lambda_2 \end{align}$$ where $\theta$ is what you're interested in, & $\phi$ is a nuisance parameter. The joint mass function can then be re-written: $$\begin{align} f_{X_1,X_2}(x_1,x_2)&=\frac{\lambda_1^{x_1}\lambda_2^{x_2}\e^{-(\lambda_1+\lambda_2)}}{x_1!x_2!}\\ f_{X_1,N}(x_1,n)&=\frac{\theta^{x_1}(1-\theta)^{n-x_1}\cdot\phi^n\e^{-\phi}}{x_1!(n-x_1)!} \end{align}$$ The total count $n$ is ancillary for $\theta$, having a Poisson distribution with mean $\phi$ $$\begin{align} f_N(n)&= \sum_{x_1=0}^{\infty}f_{X_1,N}(x_1,n)\\ &=\frac{\phi^n\e^{-\phi}}{n!}\sum_{x_1=0}^{\infty}\frac{n!}{x_1!(n-x_1)!}\theta^{x_1}(1-\theta)^{n-x_1}\\ &=\frac{\phi^n\e^{-\phi}}{n!} \end{align}$$ while the conditional distribution of $X_1$ given $n$ is binomial with Bernoulli probability $\theta$ & no. trials $n$ $$\begin{align} f_{X_1|n}(x_1;n)&=\frac{f_{X_1,N}(x_1,n)}{f_N(n)}\\ &=\frac{\theta^{x_1}(1-\theta)^{n-x_1}\cdot\phi^n\e^{-\phi}}{x_1!(n-x_1)!}\cdot\frac{n!}{\phi^n\e^{-\phi}}\\ &=\frac{n!}{x_1!(n-x_1)!}\theta^{x_1}(1-\theta)^{n-x_1} \end{align}\\$$
significance of difference between two counts
If you're happy to assume each count follows a Poisson distribution (with its own mean under the alternative hypothesis; with a common mean under the null) there's no problem—it's just that you can't
significance of difference between two counts If you're happy to assume each count follows a Poisson distribution (with its own mean under the alternative hypothesis; with a common mean under the null) there's no problem—it's just that you can't check that assumption without replicates. Overdispersion can be quite common with count data. An exact test given counts $x_1$ & $x_2$ is straightforward because the overall total of counts $n=x_1+x_2$ is ancillary; conditioning on it gives $X_1 \sim \mathrm{Bin}\left(\frac{1}{2},n\right)$ as the distribution of your test statistic under the null.† It's an intuitive result: the overall count, reflecting perhaps how much time you could be bothered to spend observing the two Poisson processes, carries no information about their relative rates, but affects the power of your test; & therefore other overall counts you might've got are irrelevant. See Likelihood-based hypothesis testing for the Wald test (an approximation). † Each count $x_i$ has a Poisson distribution with mean $\lambda_i$ $$\newcommand{\e}{\mathrm{e}} f{_X}(x_i)=\frac{\lambda_i^{x_i}\e^{-\lambda_i}}{x_i!}\qquad i=1,2$$ Reparametrize as $$\begin{align} \theta&=\frac{\lambda_1}{\lambda_1+\lambda_2}\\ \phi&=\lambda_1+\lambda_2 \end{align}$$ where $\theta$ is what you're interested in, & $\phi$ is a nuisance parameter. The joint mass function can then be re-written: $$\begin{align} f_{X_1,X_2}(x_1,x_2)&=\frac{\lambda_1^{x_1}\lambda_2^{x_2}\e^{-(\lambda_1+\lambda_2)}}{x_1!x_2!}\\ f_{X_1,N}(x_1,n)&=\frac{\theta^{x_1}(1-\theta)^{n-x_1}\cdot\phi^n\e^{-\phi}}{x_1!(n-x_1)!} \end{align}$$ The total count $n$ is ancillary for $\theta$, having a Poisson distribution with mean $\phi$ $$\begin{align} f_N(n)&= \sum_{x_1=0}^{\infty}f_{X_1,N}(x_1,n)\\ &=\frac{\phi^n\e^{-\phi}}{n!}\sum_{x_1=0}^{\infty}\frac{n!}{x_1!(n-x_1)!}\theta^{x_1}(1-\theta)^{n-x_1}\\ &=\frac{\phi^n\e^{-\phi}}{n!} \end{align}$$ while the conditional distribution of $X_1$ given $n$ is binomial with Bernoulli probability $\theta$ & no. trials $n$ $$\begin{align} f_{X_1|n}(x_1;n)&=\frac{f_{X_1,N}(x_1,n)}{f_N(n)}\\ &=\frac{\theta^{x_1}(1-\theta)^{n-x_1}\cdot\phi^n\e^{-\phi}}{x_1!(n-x_1)!}\cdot\frac{n!}{\phi^n\e^{-\phi}}\\ &=\frac{n!}{x_1!(n-x_1)!}\theta^{x_1}(1-\theta)^{n-x_1} \end{align}\\$$
significance of difference between two counts If you're happy to assume each count follows a Poisson distribution (with its own mean under the alternative hypothesis; with a common mean under the null) there's no problem—it's just that you can't
16,707
Fitting multilevel models to complex survey data in R
As far as I know you can't really do this in R at the moment, if you actually need a mixed model (eg, if you care about the variance components) The weights argument to lme4::lmer() won't do what you want, because lmer() interprets the weights as precision weights not as sampling weights. In contrast to ordinary linear and generalised linear models you don't even get correct point estimates with code that treats the sampling weights as precision weights for a mixed model. If you don't need to estimate variance components and you just want the multilevel features of the model to get correct standard errors you can use survey::svyglm().
Fitting multilevel models to complex survey data in R
As far as I know you can't really do this in R at the moment, if you actually need a mixed model (eg, if you care about the variance components) The weights argument to lme4::lmer() won't do what you
Fitting multilevel models to complex survey data in R As far as I know you can't really do this in R at the moment, if you actually need a mixed model (eg, if you care about the variance components) The weights argument to lme4::lmer() won't do what you want, because lmer() interprets the weights as precision weights not as sampling weights. In contrast to ordinary linear and generalised linear models you don't even get correct point estimates with code that treats the sampling weights as precision weights for a mixed model. If you don't need to estimate variance components and you just want the multilevel features of the model to get correct standard errors you can use survey::svyglm().
Fitting multilevel models to complex survey data in R As far as I know you can't really do this in R at the moment, if you actually need a mixed model (eg, if you care about the variance components) The weights argument to lme4::lmer() won't do what you
16,708
Fitting multilevel models to complex survey data in R
The WeMix package is now an option, at least for linear and logistic multilevel models. Seems very slow though, compared to running these models in Stata or MPlus.
Fitting multilevel models to complex survey data in R
The WeMix package is now an option, at least for linear and logistic multilevel models. Seems very slow though, compared to running these models in Stata or MPlus.
Fitting multilevel models to complex survey data in R The WeMix package is now an option, at least for linear and logistic multilevel models. Seems very slow though, compared to running these models in Stata or MPlus.
Fitting multilevel models to complex survey data in R The WeMix package is now an option, at least for linear and logistic multilevel models. Seems very slow though, compared to running these models in Stata or MPlus.
16,709
Fitting multilevel models to complex survey data in R
I am also facing the same problem. Having searched a lot the past few days, I have found that the BIFIEsurvey package is the closest to analysing multilevel models with complex survey data with sample and replicate weights, and plausible values: https://cran.r-project.org/web/packages/BIFIEsurvey/index.html The package, however, is restricted to two-level models. I have also read that the author of "intsvy" package plans in the long-term to make "intsvy" to be able to analyse multilevel models but as of today it still cannot. If there is any progress regarding the solution to this problem that I might have accidentally missed, I would be happy if someone could share it.
Fitting multilevel models to complex survey data in R
I am also facing the same problem. Having searched a lot the past few days, I have found that the BIFIEsurvey package is the closest to analysing multilevel models with complex survey data with sample
Fitting multilevel models to complex survey data in R I am also facing the same problem. Having searched a lot the past few days, I have found that the BIFIEsurvey package is the closest to analysing multilevel models with complex survey data with sample and replicate weights, and plausible values: https://cran.r-project.org/web/packages/BIFIEsurvey/index.html The package, however, is restricted to two-level models. I have also read that the author of "intsvy" package plans in the long-term to make "intsvy" to be able to analyse multilevel models but as of today it still cannot. If there is any progress regarding the solution to this problem that I might have accidentally missed, I would be happy if someone could share it.
Fitting multilevel models to complex survey data in R I am also facing the same problem. Having searched a lot the past few days, I have found that the BIFIEsurvey package is the closest to analysing multilevel models with complex survey data with sample
16,710
Normal approximation to the Poisson distribution
Suppose $X$ is Poisson with parameter $\lambda$, and $Y$ is normal with mean and variance $\lambda$. It seems to me that the appropriate comparison is between $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n+\frac12])$. Here for simplicity I write $n = \lambda + \alpha \sqrt\lambda$, that is, we are interested when $n$ corresponds to $\alpha$ standard deviations from the mean. So I cheated. I used Mathematica. So both $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n+\frac12])$ are asymptotic to $$ \frac 1{\sqrt{2\pi \lambda}} e^{-\alpha^2/2} $$ as $\lambda \to \infty$. But their difference is asymptotic to $$ \frac{\alpha \left(\alpha ^2-3\right) e^{-\alpha ^2/{2}}}{6 \sqrt{2 \pi } \lambda } $$ If you plot this as a function of $\alpha$, you will get the same curve as is shown in the second to last figure in http://www.johndcook.com/blog/normal_approx_to_poisson/. Here are the commands I used: n = lambda + alpha Sqrt[lambda]; p1 = Exp[-lambda] lambda^n/n!; p2 = Integrate[1/Sqrt[2 Pi]/Sqrt[lambda] Exp[-(x-lambda)^2/2/lambda], {x, n-1/2, n+1/2}]; Series[p1, {lambda, Infinity, 1}] Series[p2, {lambda, Infinity, 1}] Also, with a bit of experimentation, it seems to me that a better asymptotic approximation to $\Pr(X = n)$ is $\Pr(Y \in [n-\alpha^2/6,n+1-\alpha^2/6])$. Then the error is $$ -\frac{\left(5 \alpha ^4-9 \alpha ^2-6\right) e^{-{\alpha ^2}/{2}} }{72 \sqrt{2 \pi } \lambda ^{3/2} } $$ which is about $\sqrt\lambda$ times smaller.
Normal approximation to the Poisson distribution
Suppose $X$ is Poisson with parameter $\lambda$, and $Y$ is normal with mean and variance $\lambda$. It seems to me that the appropriate comparison is between $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n
Normal approximation to the Poisson distribution Suppose $X$ is Poisson with parameter $\lambda$, and $Y$ is normal with mean and variance $\lambda$. It seems to me that the appropriate comparison is between $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n+\frac12])$. Here for simplicity I write $n = \lambda + \alpha \sqrt\lambda$, that is, we are interested when $n$ corresponds to $\alpha$ standard deviations from the mean. So I cheated. I used Mathematica. So both $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n+\frac12])$ are asymptotic to $$ \frac 1{\sqrt{2\pi \lambda}} e^{-\alpha^2/2} $$ as $\lambda \to \infty$. But their difference is asymptotic to $$ \frac{\alpha \left(\alpha ^2-3\right) e^{-\alpha ^2/{2}}}{6 \sqrt{2 \pi } \lambda } $$ If you plot this as a function of $\alpha$, you will get the same curve as is shown in the second to last figure in http://www.johndcook.com/blog/normal_approx_to_poisson/. Here are the commands I used: n = lambda + alpha Sqrt[lambda]; p1 = Exp[-lambda] lambda^n/n!; p2 = Integrate[1/Sqrt[2 Pi]/Sqrt[lambda] Exp[-(x-lambda)^2/2/lambda], {x, n-1/2, n+1/2}]; Series[p1, {lambda, Infinity, 1}] Series[p2, {lambda, Infinity, 1}] Also, with a bit of experimentation, it seems to me that a better asymptotic approximation to $\Pr(X = n)$ is $\Pr(Y \in [n-\alpha^2/6,n+1-\alpha^2/6])$. Then the error is $$ -\frac{\left(5 \alpha ^4-9 \alpha ^2-6\right) e^{-{\alpha ^2}/{2}} }{72 \sqrt{2 \pi } \lambda ^{3/2} } $$ which is about $\sqrt\lambda$ times smaller.
Normal approximation to the Poisson distribution Suppose $X$ is Poisson with parameter $\lambda$, and $Y$ is normal with mean and variance $\lambda$. It seems to me that the appropriate comparison is between $\Pr(X = n)$ and $\Pr(Y \in [n-\frac12,n
16,711
Normal approximation to the Poisson distribution
The derivation from the binomial distribution might gain you some insight. We have a binomial random variable; $$ p(x) = {n \choose x} p^x (1-p)^{n-x}$$ This can alternatively be computed recursively; $$ p(x) = \frac{(n-x+1)p}{x(1-p)}p(x-1)$$ If you keep the initial condition; $$ p(0) = (1-p)^n $$ Now let us assume that $n$ is large and $p$ is small but the average success of $p(x)$ is constant $(np = \lambda)$. Then we can do the following; $$ P( X = i ) = {n \choose i} p^x (1-p)^{n-x} $$ We use that $p = \lambda / n$. $$ P( X = i ) = \frac{n!}{(n-i)!i!} \left(\frac{\lambda}{n}\right)^i \left(1-\frac{\lambda}{n}\right)^{n-i} $$ We switch some variables around and evaluate; $$ P( X = i ) = \frac{n(n-1)(n-2)\cdots(n-i+1)}{n^i} \frac{\lambda^i}{i!} \frac{(1-\frac{\lambda}{n})^n}{(1-\frac{\lambda}{n})^i} $$ From calculus we know that $ \lim_{n\to\infty} (1 + x/n)^n = e^x $. We also know that $[n(n-1)(n-2)\cdots(n-i+1)]/n^i \approx 1 $ because both the top and bottom are polynomials of degree $i$. This leads to the conclusion that as $ n \to \infty$: $$ P(X=i) \to \frac{ e^{-\lambda}{\lambda^i}}{i!} $$ You can then verify that $E(X) = \lambda$ and $\operatorname{Var}(X) = \lambda$ via the definition. We know that the binomial distribution approximates the normal under the conditions of the De Moivre-Laplace Theorem as long as you correct for the continuity, which is why $P(X\le x)$ is replaced by $P(X\le x+0.5)$.
Normal approximation to the Poisson distribution
The derivation from the binomial distribution might gain you some insight. We have a binomial random variable; $$ p(x) = {n \choose x} p^x (1-p)^{n-x}$$ This can alternatively be computed recursivel
Normal approximation to the Poisson distribution The derivation from the binomial distribution might gain you some insight. We have a binomial random variable; $$ p(x) = {n \choose x} p^x (1-p)^{n-x}$$ This can alternatively be computed recursively; $$ p(x) = \frac{(n-x+1)p}{x(1-p)}p(x-1)$$ If you keep the initial condition; $$ p(0) = (1-p)^n $$ Now let us assume that $n$ is large and $p$ is small but the average success of $p(x)$ is constant $(np = \lambda)$. Then we can do the following; $$ P( X = i ) = {n \choose i} p^x (1-p)^{n-x} $$ We use that $p = \lambda / n$. $$ P( X = i ) = \frac{n!}{(n-i)!i!} \left(\frac{\lambda}{n}\right)^i \left(1-\frac{\lambda}{n}\right)^{n-i} $$ We switch some variables around and evaluate; $$ P( X = i ) = \frac{n(n-1)(n-2)\cdots(n-i+1)}{n^i} \frac{\lambda^i}{i!} \frac{(1-\frac{\lambda}{n})^n}{(1-\frac{\lambda}{n})^i} $$ From calculus we know that $ \lim_{n\to\infty} (1 + x/n)^n = e^x $. We also know that $[n(n-1)(n-2)\cdots(n-i+1)]/n^i \approx 1 $ because both the top and bottom are polynomials of degree $i$. This leads to the conclusion that as $ n \to \infty$: $$ P(X=i) \to \frac{ e^{-\lambda}{\lambda^i}}{i!} $$ You can then verify that $E(X) = \lambda$ and $\operatorname{Var}(X) = \lambda$ via the definition. We know that the binomial distribution approximates the normal under the conditions of the De Moivre-Laplace Theorem as long as you correct for the continuity, which is why $P(X\le x)$ is replaced by $P(X\le x+0.5)$.
Normal approximation to the Poisson distribution The derivation from the binomial distribution might gain you some insight. We have a binomial random variable; $$ p(x) = {n \choose x} p^x (1-p)^{n-x}$$ This can alternatively be computed recursivel
16,712
Normal approximation to the Poisson distribution
Glen_b is correct in that "good fit" is a very subjective notion. However, if you want to verify that your poisson distribution is reasonably normal, you can use a hypothetical Kolmorgov-Smirnov test with the null hypothesis being $H_{0}:$ The CDF came from a $N(\lambda,\lambda)$ distribution, assuming your sample will come from a poisson($\lambda$). Since you are not actually testing a sample, but one distribution against another, you need to think carefully about the sample size and significance level you assume for this hypothetial test (since we are not using the KS test in its typical fashion). That is: Pick a representative, hypothetical sample size, n, and adjust the significance level of the test to a typical value, e.g., 5% . Now, calculate the Type II error rate for this test assuming your data actually come from a poisson($\lambda$). Your degree of fit with a normal distribution will be this Type II error rate, in the sense that samples of size n from your particular poisson distribution will, on average, be accepted $\beta$% of the time by a KS normality test at your selected significance level. Anyway, that's just one way to go about getting a sense of "goodness of fit". However, all rely on some subjective notions of "goodness" that you will have to define for yourself.
Normal approximation to the Poisson distribution
Glen_b is correct in that "good fit" is a very subjective notion. However, if you want to verify that your poisson distribution is reasonably normal, you can use a hypothetical Kolmorgov-Smirnov test
Normal approximation to the Poisson distribution Glen_b is correct in that "good fit" is a very subjective notion. However, if you want to verify that your poisson distribution is reasonably normal, you can use a hypothetical Kolmorgov-Smirnov test with the null hypothesis being $H_{0}:$ The CDF came from a $N(\lambda,\lambda)$ distribution, assuming your sample will come from a poisson($\lambda$). Since you are not actually testing a sample, but one distribution against another, you need to think carefully about the sample size and significance level you assume for this hypothetial test (since we are not using the KS test in its typical fashion). That is: Pick a representative, hypothetical sample size, n, and adjust the significance level of the test to a typical value, e.g., 5% . Now, calculate the Type II error rate for this test assuming your data actually come from a poisson($\lambda$). Your degree of fit with a normal distribution will be this Type II error rate, in the sense that samples of size n from your particular poisson distribution will, on average, be accepted $\beta$% of the time by a KS normality test at your selected significance level. Anyway, that's just one way to go about getting a sense of "goodness of fit". However, all rely on some subjective notions of "goodness" that you will have to define for yourself.
Normal approximation to the Poisson distribution Glen_b is correct in that "good fit" is a very subjective notion. However, if you want to verify that your poisson distribution is reasonably normal, you can use a hypothetical Kolmorgov-Smirnov test
16,713
How would one graph the results of subjective rank order?
I've done something similar for visualizing similar rankings. The method I used gave me a quick snapshot of how the rankings related-nothing more. My solution used Excel 2010 sparklines to create a small-multiples view of the rankings (this can be done in other Excel versions, but it takes a bit more work). Also, I generally use Excel's Table functionality just to speed things along. Transpose your matrix so the rows hold all the values per rated item. If rank 1 is best, invert your ranks so 1=8,2=7... this just helps you visualize the chart's columns (rather than blank space) as better. Sum the results of each question's raters. Then sort by this total. This will put the item with the best overall scores first and worst overall scores last. This ranking will help you visually rank the charts when the overall pattern may not be obvious (as was the case in your sample data. Insert Sparklines using your ranking data (without the totals column) next to your data table. Visually, the more/bigger bars there are, the better the overall ranking. There's nothing particularly analytical about this approach, but it's a pretty quick way to visualize the data. Note, if you don't have Excel 2010, you can create stripped down, cell sized column charts for each row that look about the same. Or, you can use a third-party add-on to create them. EDIT: Table and Chart utilizing Gung's suggestion for average measure. As pointed out, since the scale is similar, it was added to the chart as an additional point of comparison (I used gray to help differeniate it from the raw data plots).
How would one graph the results of subjective rank order?
I've done something similar for visualizing similar rankings. The method I used gave me a quick snapshot of how the rankings related-nothing more. My solution used Excel 2010 sparklines to create a
How would one graph the results of subjective rank order? I've done something similar for visualizing similar rankings. The method I used gave me a quick snapshot of how the rankings related-nothing more. My solution used Excel 2010 sparklines to create a small-multiples view of the rankings (this can be done in other Excel versions, but it takes a bit more work). Also, I generally use Excel's Table functionality just to speed things along. Transpose your matrix so the rows hold all the values per rated item. If rank 1 is best, invert your ranks so 1=8,2=7... this just helps you visualize the chart's columns (rather than blank space) as better. Sum the results of each question's raters. Then sort by this total. This will put the item with the best overall scores first and worst overall scores last. This ranking will help you visually rank the charts when the overall pattern may not be obvious (as was the case in your sample data. Insert Sparklines using your ranking data (without the totals column) next to your data table. Visually, the more/bigger bars there are, the better the overall ranking. There's nothing particularly analytical about this approach, but it's a pretty quick way to visualize the data. Note, if you don't have Excel 2010, you can create stripped down, cell sized column charts for each row that look about the same. Or, you can use a third-party add-on to create them. EDIT: Table and Chart utilizing Gung's suggestion for average measure. As pointed out, since the scale is similar, it was added to the chart as an additional point of comparison (I used gray to help differeniate it from the raw data plots).
How would one graph the results of subjective rank order? I've done something similar for visualizing similar rankings. The method I used gave me a quick snapshot of how the rankings related-nothing more. My solution used Excel 2010 sparklines to create a
16,714
How would one graph the results of subjective rank order?
I would do this in the form of a bumps chart. It looks pretty cluttered, so I would work with the colors to try to help this out. The sparklines @dav suggested don't really allow a comparison between products.
How would one graph the results of subjective rank order?
I would do this in the form of a bumps chart. It looks pretty cluttered, so I would work with the colors to try to help this out. The sparklines @dav suggested don't really allow a comparison between
How would one graph the results of subjective rank order? I would do this in the form of a bumps chart. It looks pretty cluttered, so I would work with the colors to try to help this out. The sparklines @dav suggested don't really allow a comparison between products.
How would one graph the results of subjective rank order? I would do this in the form of a bumps chart. It looks pretty cluttered, so I would work with the colors to try to help this out. The sparklines @dav suggested don't really allow a comparison between
16,715
How would one graph the results of subjective rank order?
I know this question is seven years old and see the poster is AWOL, but I do appreciate a question that includes data... It sounds like product rating trends are the issue rather trends of the individual raters. In which case, you can get a sense of the high-level trends by plotting the means and confidence interval for each product. At least we can see that C and D seem worse than the others (assuming 8 is the worst ranking). Maybe A, B and C have more disagreement than the others. If individual raters are important in convey, you could use different marks and colors for each rater's dots.
How would one graph the results of subjective rank order?
I know this question is seven years old and see the poster is AWOL, but I do appreciate a question that includes data... It sounds like product rating trends are the issue rather trends of the individ
How would one graph the results of subjective rank order? I know this question is seven years old and see the poster is AWOL, but I do appreciate a question that includes data... It sounds like product rating trends are the issue rather trends of the individual raters. In which case, you can get a sense of the high-level trends by plotting the means and confidence interval for each product. At least we can see that C and D seem worse than the others (assuming 8 is the worst ranking). Maybe A, B and C have more disagreement than the others. If individual raters are important in convey, you could use different marks and colors for each rater's dots.
How would one graph the results of subjective rank order? I know this question is seven years old and see the poster is AWOL, but I do appreciate a question that includes data... It sounds like product rating trends are the issue rather trends of the individ
16,716
How would one graph the results of subjective rank order?
Dot plots can be very useful for this type of analysis. This is what I came up with your data. You can also add connecting lines. I would also think about adding a more prominent series to show the average for each option. Some links: http://peltiertech.com/Excel/Charts/DotPlot.html http://peltiertech.com/WordPress/charting-survey-results/
How would one graph the results of subjective rank order?
Dot plots can be very useful for this type of analysis. This is what I came up with your data. You can also add connecting lines. I would also think about adding a more prominent series to show the a
How would one graph the results of subjective rank order? Dot plots can be very useful for this type of analysis. This is what I came up with your data. You can also add connecting lines. I would also think about adding a more prominent series to show the average for each option. Some links: http://peltiertech.com/Excel/Charts/DotPlot.html http://peltiertech.com/WordPress/charting-survey-results/
How would one graph the results of subjective rank order? Dot plots can be very useful for this type of analysis. This is what I came up with your data. You can also add connecting lines. I would also think about adding a more prominent series to show the a
16,717
Scrambling and correlation in low discrepancy sequences (Halton/Sobol)
Scrambling is usually an operation applied to a $(t,m,s)$ digital net which uses some base $b$. Sobol' nets use $b = 2$, for example, while Faure nets use a prime number for $b$. The purpose of scrambling is to (hopefully) get an even more uniform distribution, especially if you can only use a small number of points. A good example to see why this works is to look at the Halton sequence in $d = 2$ and choose two "largish" primes, like 29 and 31. The square gets filled in very slowly using the standard Halton sequence. But, with scrambling, it is filled in more uniformly much more quickly. Here is a plot for the first couple hundred points using a deterministic scrambling approach. The most basic forms of scrambling essentially permute the base $b$ digit expansions of the original $n$ points among themselves. For more details, here is a clear exposition. The nice thing about scrambling is that if you start with a $(t,m,s)$ net and scramble it, you get a $(t,m,s)$ net back out. So, there is a closure property involved. Since you want to use the theoretical benefits of a $(t,m,s)$ net in the first place, this is very desirable. Regarding types of scrambling, the reverse-radix scramble is a deterministic scrambling. The Matousek scrambling algorithm is a random scramble, done, again, in a way to maintain the closure property. If you set the random seed before you make the call to the scrambling function, you should always get the same net back. You might also be interested in the MinT project.
Scrambling and correlation in low discrepancy sequences (Halton/Sobol)
Scrambling is usually an operation applied to a $(t,m,s)$ digital net which uses some base $b$. Sobol' nets use $b = 2$, for example, while Faure nets use a prime number for $b$. The purpose of scramb
Scrambling and correlation in low discrepancy sequences (Halton/Sobol) Scrambling is usually an operation applied to a $(t,m,s)$ digital net which uses some base $b$. Sobol' nets use $b = 2$, for example, while Faure nets use a prime number for $b$. The purpose of scrambling is to (hopefully) get an even more uniform distribution, especially if you can only use a small number of points. A good example to see why this works is to look at the Halton sequence in $d = 2$ and choose two "largish" primes, like 29 and 31. The square gets filled in very slowly using the standard Halton sequence. But, with scrambling, it is filled in more uniformly much more quickly. Here is a plot for the first couple hundred points using a deterministic scrambling approach. The most basic forms of scrambling essentially permute the base $b$ digit expansions of the original $n$ points among themselves. For more details, here is a clear exposition. The nice thing about scrambling is that if you start with a $(t,m,s)$ net and scramble it, you get a $(t,m,s)$ net back out. So, there is a closure property involved. Since you want to use the theoretical benefits of a $(t,m,s)$ net in the first place, this is very desirable. Regarding types of scrambling, the reverse-radix scramble is a deterministic scrambling. The Matousek scrambling algorithm is a random scramble, done, again, in a way to maintain the closure property. If you set the random seed before you make the call to the scrambling function, you should always get the same net back. You might also be interested in the MinT project.
Scrambling and correlation in low discrepancy sequences (Halton/Sobol) Scrambling is usually an operation applied to a $(t,m,s)$ digital net which uses some base $b$. Sobol' nets use $b = 2$, for example, while Faure nets use a prime number for $b$. The purpose of scramb
16,718
Oracle Inequality : In basic terms
I'll try to explain it in linear case. Consider the linear model $$Y_i=\sum_{j=1}^{p} \beta_jX_{i}^{(j)}+\epsilon_i, i=1,...,n. $$ When $p \leq n$ (number of independent variables less or equal then number of observation) and design matrix has full rank, the least squared estimator of $b$ is $$\hat{b}=(X^TX)^{-1}X^TY$$ and prediction error is $$ \dfrac{\| X(\hat{b}-\beta^0) \|_2^2}{\sigma^2} $$ from which we can deduce $$ \dfrac{ \mathbb{E} \| X(\hat{b}-\beta^0) \|_2^2}{n}=\dfrac{\sigma^2}{n}p. $$ It means that each parameter $\beta_j^0$ is estimated with squared accuracy $\sigma^2/n, j=1,...,p.$ So your overall squared accuracy is $(\sigma^2/n)p.$ Now what if the number of observations are less then number of independent variables $(p>n)$? We "believe" that not all of our independent variables play a role in explaining $Y$, so only a few, say $k$, of them are non-zero. If we would know which variables are non-zero, we could neglect all other variables and by above argument, overall squared accuracy would be $(\sigma^2/n)k.$ Because the set of nonzero variables are unknown, we need some regularization penalty(for example $l_1$) with regularization parameter $\lambda$ (which controls the number of variables). Now you want to get results similar to discussed above, you want to estimate squared accuracy. The problem is your optimal estimator $\hat{\beta}$ is now depend on $\lambda$. But the great fact is that with proper choice for $\lambda$ you can get an upper bound of prediction error with high probability, that is the "oracle inequality" $$\dfrac{\| X(\hat{\beta}-\beta^0) \|_2^2}{n} \leq const.\dfrac{\sigma^2\log p}{n}k. $$ Note an additional factor $\log p$, which is the price for not knowing set of non-zero variables. "$const.$" depend only on $p$ or $n$.
Oracle Inequality : In basic terms
I'll try to explain it in linear case. Consider the linear model $$Y_i=\sum_{j=1}^{p} \beta_jX_{i}^{(j)}+\epsilon_i, i=1,...,n. $$ When $p \leq n$ (number of independent variables less or equal then n
Oracle Inequality : In basic terms I'll try to explain it in linear case. Consider the linear model $$Y_i=\sum_{j=1}^{p} \beta_jX_{i}^{(j)}+\epsilon_i, i=1,...,n. $$ When $p \leq n$ (number of independent variables less or equal then number of observation) and design matrix has full rank, the least squared estimator of $b$ is $$\hat{b}=(X^TX)^{-1}X^TY$$ and prediction error is $$ \dfrac{\| X(\hat{b}-\beta^0) \|_2^2}{\sigma^2} $$ from which we can deduce $$ \dfrac{ \mathbb{E} \| X(\hat{b}-\beta^0) \|_2^2}{n}=\dfrac{\sigma^2}{n}p. $$ It means that each parameter $\beta_j^0$ is estimated with squared accuracy $\sigma^2/n, j=1,...,p.$ So your overall squared accuracy is $(\sigma^2/n)p.$ Now what if the number of observations are less then number of independent variables $(p>n)$? We "believe" that not all of our independent variables play a role in explaining $Y$, so only a few, say $k$, of them are non-zero. If we would know which variables are non-zero, we could neglect all other variables and by above argument, overall squared accuracy would be $(\sigma^2/n)k.$ Because the set of nonzero variables are unknown, we need some regularization penalty(for example $l_1$) with regularization parameter $\lambda$ (which controls the number of variables). Now you want to get results similar to discussed above, you want to estimate squared accuracy. The problem is your optimal estimator $\hat{\beta}$ is now depend on $\lambda$. But the great fact is that with proper choice for $\lambda$ you can get an upper bound of prediction error with high probability, that is the "oracle inequality" $$\dfrac{\| X(\hat{\beta}-\beta^0) \|_2^2}{n} \leq const.\dfrac{\sigma^2\log p}{n}k. $$ Note an additional factor $\log p$, which is the price for not knowing set of non-zero variables. "$const.$" depend only on $p$ or $n$.
Oracle Inequality : In basic terms I'll try to explain it in linear case. Consider the linear model $$Y_i=\sum_{j=1}^{p} \beta_jX_{i}^{(j)}+\epsilon_i, i=1,...,n. $$ When $p \leq n$ (number of independent variables less or equal then n
16,719
Why back propagate through time in a RNN?
Edit: I made a big mistake when comparing the two methods and have to change my answer. It turns out the way I was doing it, just back propagating on the current time step, actually starts out learning faster. The quick updates learn the most basic patterns very quickly. But on a larger data set and with longer training time, BPTT does in fact come out on top. I was testing a small sample for just a few epochs and assumed whoever starts out winning the race will be the winner. But this did lead me to an interesting find. If you start out your training back propagating just a single time step, then change to BPTT and slowly increase how far back you propagate, you get faster convergence.
Why back propagate through time in a RNN?
Edit: I made a big mistake when comparing the two methods and have to change my answer. It turns out the way I was doing it, just back propagating on the current time step, actually starts out learnin
Why back propagate through time in a RNN? Edit: I made a big mistake when comparing the two methods and have to change my answer. It turns out the way I was doing it, just back propagating on the current time step, actually starts out learning faster. The quick updates learn the most basic patterns very quickly. But on a larger data set and with longer training time, BPTT does in fact come out on top. I was testing a small sample for just a few epochs and assumed whoever starts out winning the race will be the winner. But this did lead me to an interesting find. If you start out your training back propagating just a single time step, then change to BPTT and slowly increase how far back you propagate, you get faster convergence.
Why back propagate through time in a RNN? Edit: I made a big mistake when comparing the two methods and have to change my answer. It turns out the way I was doing it, just back propagating on the current time step, actually starts out learnin
16,720
Why back propagate through time in a RNN?
"Unfolding through time" is simply an application of the chain rule, $$\frac{dF(g(x), h(x), m(x))}{dx} = \frac{\partial F}{\partial g}\frac{dg}{dx} + \frac{\partial F}{\partial h}\frac{dh}{dx} + \frac{\partial F}{\partial m}\frac{dm}{dx}$$ The output of an RNN at time step $t$, $H_t$ is a function of the parameters $\theta$, the input $x_t$ and the previous state, $H_{t-1}$ (note that instead $H_t$ may be transformed again at time step $t$ to obtain the output, that is not important here). Remember the goal of gradient descent: given some error function $L$, let's look at our error for the current example (or examples), and then let's adjust $\theta$ in such a way, that given the same example again, our error would be reduced. How exactly did $\theta$ contribute to our current error? We took a weighted sum with our current input, $x_t$, so we'll need to backpropagate through the input to find $\nabla_\theta a(x_t, \theta)$, to work out how to adjust $\theta$. But our error was also the result of some contribution from $H_{t-1}$, which was also a function of $\theta$, right? So we need to find out $\nabla_\theta H_{t-1}$, which was a function of $x_{t-1}$, $\theta$ and $H_{t-2}$. But $H_{t-2}$ was also a function a function of $\theta$. And so on.
Why back propagate through time in a RNN?
"Unfolding through time" is simply an application of the chain rule, $$\frac{dF(g(x), h(x), m(x))}{dx} = \frac{\partial F}{\partial g}\frac{dg}{dx} + \frac{\partial F}{\partial h}\frac{dh}{dx} + \frac
Why back propagate through time in a RNN? "Unfolding through time" is simply an application of the chain rule, $$\frac{dF(g(x), h(x), m(x))}{dx} = \frac{\partial F}{\partial g}\frac{dg}{dx} + \frac{\partial F}{\partial h}\frac{dh}{dx} + \frac{\partial F}{\partial m}\frac{dm}{dx}$$ The output of an RNN at time step $t$, $H_t$ is a function of the parameters $\theta$, the input $x_t$ and the previous state, $H_{t-1}$ (note that instead $H_t$ may be transformed again at time step $t$ to obtain the output, that is not important here). Remember the goal of gradient descent: given some error function $L$, let's look at our error for the current example (or examples), and then let's adjust $\theta$ in such a way, that given the same example again, our error would be reduced. How exactly did $\theta$ contribute to our current error? We took a weighted sum with our current input, $x_t$, so we'll need to backpropagate through the input to find $\nabla_\theta a(x_t, \theta)$, to work out how to adjust $\theta$. But our error was also the result of some contribution from $H_{t-1}$, which was also a function of $\theta$, right? So we need to find out $\nabla_\theta H_{t-1}$, which was a function of $x_{t-1}$, $\theta$ and $H_{t-2}$. But $H_{t-2}$ was also a function a function of $\theta$. And so on.
Why back propagate through time in a RNN? "Unfolding through time" is simply an application of the chain rule, $$\frac{dF(g(x), h(x), m(x))}{dx} = \frac{\partial F}{\partial g}\frac{dg}{dx} + \frac{\partial F}{\partial h}\frac{dh}{dx} + \frac
16,721
Why back propagate through time in a RNN?
A RNN is a Deep Neural Network (DNN) where each layer may take new input but have the same parameters. BPT is a fancy word for Back Propagation on such a network which itself is a fancy word for Gradient Descent. Say that the RNN outputs $\hat{y}_t$ in each step and \begin{equation} error_t=(y_t-\hat{y}_t)^2 \end{equation} In order to learn the weights we need gradients for the function to answer the question "how much does a change in parameter effect the loss function?" and move the parameters in the direction given by: \begin{equation} \nabla error_t=-2(y_t-\hat{y}_t)\nabla \hat{y}_t \end{equation} I.e we have a DNN where we get feedback on how good the prediction is at each layer. Since a change in parameter will change every layer in the DNN (timestep) and every layer contributes to the forthcoming outputs this needs to be accounted for. Take a simple one neuron-one layer network to see this semi-explicitly: \begin{align*} \hat{y}_{t+1} =& f(a+bx_t+c\hat{y}_t)\\ \frac{\partial}{\partial a}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot c\cdot \frac{\partial}{\partial a}\hat{y}_{t} \\ \frac{\partial}{\partial b}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot (x_t+c\cdot\frac{\partial}{\partial b}\hat{y}_{t})\\ \frac{\partial}{\partial c}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot (\hat{y}_t+c\cdot\frac{\partial}{\partial c}\hat{y}_{t})\\ \iff\\ \nabla \hat{y}_{t+1} =& f'(a+bx_t+c\hat{y}_t)\cdot \left(\begin{bmatrix}0\\x_t\\\hat{y}_t \end{bmatrix} + c \mathbin{\color{red}{\nabla \hat{y}_{t}}} \right) \end{align*} With $\delta$ the learning rate one training step is then: \begin{equation} \begin{bmatrix}\tilde{a}\\\tilde{b}\\\tilde{c}\end{bmatrix} \leftarrow \begin{bmatrix}a\\b\\c\end{bmatrix} + \delta (y_{t}-\hat{y}_{t})\nabla \hat{y}_t \end{equation} What we see is that in order to calculate $\nabla \hat{y}_{t+1}$ you need to calculate i.e roll out $\nabla \hat{y}_{t}$. What you propose is to simply disregard the red part calculate the red part for $t$ but not recurse further. I assume that your loss is something like \begin{equation} error=\sum_t(y_t-\hat{y}_t)^2 \end{equation} Maybe each step will then contribute a crude direction which is enough in aggregation? This could explain your results but I'd be really interested in hearing more about your method/loss function! Also would be interested in a comparison with a two timestep windowed ANN. edit4: After reading comments it seems like your architecture is not an RNN. RNN: Stateful - carry forward hidden state $h_t$ indefinitely This is your model but the training is different. Your model: Stateless - hidden state rebuilt in each step edit2 : added more refs to DNNs edit3 : fixed gradstep and some notation edit5 : Fixed the interpretation of your model after your answer/clarification.
Why back propagate through time in a RNN?
A RNN is a Deep Neural Network (DNN) where each layer may take new input but have the same parameters. BPT is a fancy word for Back Propagation on such a network which itself is a fancy word for Grad
Why back propagate through time in a RNN? A RNN is a Deep Neural Network (DNN) where each layer may take new input but have the same parameters. BPT is a fancy word for Back Propagation on such a network which itself is a fancy word for Gradient Descent. Say that the RNN outputs $\hat{y}_t$ in each step and \begin{equation} error_t=(y_t-\hat{y}_t)^2 \end{equation} In order to learn the weights we need gradients for the function to answer the question "how much does a change in parameter effect the loss function?" and move the parameters in the direction given by: \begin{equation} \nabla error_t=-2(y_t-\hat{y}_t)\nabla \hat{y}_t \end{equation} I.e we have a DNN where we get feedback on how good the prediction is at each layer. Since a change in parameter will change every layer in the DNN (timestep) and every layer contributes to the forthcoming outputs this needs to be accounted for. Take a simple one neuron-one layer network to see this semi-explicitly: \begin{align*} \hat{y}_{t+1} =& f(a+bx_t+c\hat{y}_t)\\ \frac{\partial}{\partial a}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot c\cdot \frac{\partial}{\partial a}\hat{y}_{t} \\ \frac{\partial}{\partial b}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot (x_t+c\cdot\frac{\partial}{\partial b}\hat{y}_{t})\\ \frac{\partial}{\partial c}\hat{y}_{t+1} = & f'(a+bx_t+c\hat{y}_t)\cdot (\hat{y}_t+c\cdot\frac{\partial}{\partial c}\hat{y}_{t})\\ \iff\\ \nabla \hat{y}_{t+1} =& f'(a+bx_t+c\hat{y}_t)\cdot \left(\begin{bmatrix}0\\x_t\\\hat{y}_t \end{bmatrix} + c \mathbin{\color{red}{\nabla \hat{y}_{t}}} \right) \end{align*} With $\delta$ the learning rate one training step is then: \begin{equation} \begin{bmatrix}\tilde{a}\\\tilde{b}\\\tilde{c}\end{bmatrix} \leftarrow \begin{bmatrix}a\\b\\c\end{bmatrix} + \delta (y_{t}-\hat{y}_{t})\nabla \hat{y}_t \end{equation} What we see is that in order to calculate $\nabla \hat{y}_{t+1}$ you need to calculate i.e roll out $\nabla \hat{y}_{t}$. What you propose is to simply disregard the red part calculate the red part for $t$ but not recurse further. I assume that your loss is something like \begin{equation} error=\sum_t(y_t-\hat{y}_t)^2 \end{equation} Maybe each step will then contribute a crude direction which is enough in aggregation? This could explain your results but I'd be really interested in hearing more about your method/loss function! Also would be interested in a comparison with a two timestep windowed ANN. edit4: After reading comments it seems like your architecture is not an RNN. RNN: Stateful - carry forward hidden state $h_t$ indefinitely This is your model but the training is different. Your model: Stateless - hidden state rebuilt in each step edit2 : added more refs to DNNs edit3 : fixed gradstep and some notation edit5 : Fixed the interpretation of your model after your answer/clarification.
Why back propagate through time in a RNN? A RNN is a Deep Neural Network (DNN) where each layer may take new input but have the same parameters. BPT is a fancy word for Back Propagation on such a network which itself is a fancy word for Grad
16,722
The Pros and Cons of Smoothing spline
The terminology of splines can be confusing (at least I find it so) as exactly what people mean when they use "cubic spline", for example, depends on the type of cubic spline; we can have, for example, both cubic smoothing splines and cubic (penalised) regression splines. What I sketch below is taken from sections 5.1.2 and 5.2 of Wood (2017). An interpolating spline $g(x_i)$ say would set $g(x_i) = y_i$ as it interpolates the observations $y_i$ via a function composed of sections of cubic polynomials joined such that the spline is continuous to the second derivative. A cubic smoothing spline aims to balance fit to the data with producing a smooth function; the aim is not to interpolate the data which arises in interpolating splines. Rather than set $g(x_i) = y_i$, a cubic smoothing spline acts as $n$ free parameters to be estimated so as to minimise (Wood, 2017) $$\sum_{i=1}^{n}\{y_i - g(x_i)\}^2 + \lambda \int g^{\prime\prime}(x)^2dx$$ where the first part is a measure of the fit to the data, whilst the second part is a penalty against wiggliness (it the integral sums up the squared second derivative of the spline as a measure of the curvature or wiggliness, how fast the curve is changing slope). We can think of wiggliness as complexity so the function includes a penalty against overly complex smooths. It can be shown that a cubic smoothing spline $g(x)$, of all possible functions $f$, is the functions that minimises the above criterion (a proof is given in Wood, 2017, section 5.1.2 pp. 198). As with an interpolating spline, a cubic smoothing spline has knots located at each observation pair $x_i$, $y_i$. Earlier I mentioned that a smoothing spline has $n$ free parameters; there are as many parameters as data. Yet the effect of $\lambda$, the penalty against over wiggly smooths, is to produce a spline that is much smoother than implied if it used $n$ degrees of freedom (Wood 2017). This is the major negative on the side of smoothing splines. You have to estimate as many parameters as you have data and yet the effect of many of those parameters will in general be low because of the penalty against overly complex (wiggly) fits. Balancing this is the fact that the choice of knots in the smoothing spline is taken care of, because there is no choice. Moving to the penalized regression spline setting, we now have the choice of where to place the knots but we get to choose how many knots to use. How might we decide if this is a useful trade-off, that it is beneficial to fit the spline with a reduced number of knots even if we have to decide how many and where to put them? In a penalised regression spline, rather than think of knots per se, think of the spline as being made up of basis functions; these are little functions, which each have a coefficient, whose linear combination gives the value of the spline for a given $x_i$. The choice now is how many basis functions to use to model the response with the number $k$ being much fewer than the number of data $n$. The theory underlying this choice is a little limited or restricted to special cases or approaches to estimating the value for $\lambda$ but the general idea is that the number of basis functions required grows only slowly with $n$ in order to achieve close to the optimal performance represented by smoothing splines (summarised from Wood 2017). In general, where the knots are actually distributed through the data for a cubic regression spline does not have much of an effect on the fitted spline. Typical choices are to place $k-1$ knots evenly over the interval of $x$, or to place knots at the quantiles of the distribution of $x$. If you have a very uneven spread of observations over range of $x$, it would be wasteful to place knots evenly over $x$ so you could concentrate them where you have data. Alternatively, transforming $x$ in some way may even out the distribution such that placing knots evenly is possible again. When fitting a spline model in high dimensions, say a spline of two variables, knot placement is more problematic if the pairs of $x_{1i}, x_{2i}$ are limited to some region of the space spanned by $x_1$ and $x_2$; if the data do not originate in large parts of the space, then placing knots evenly will result in many of the knots being located away from the support of the data. Which is wasteful. Strategies for dealing with are available, such as space-filling algorithms, or using P-splines and sparse derivative-based penalties that allow for efficient estimation even in unevenly-distributed data (e.g. Wood 2016) References Wood, S. N. 2016. P-splines with derivative based penalties and tensor product smoothing of unevenly distributed data. Stat. Comput. 1–5. doi:10.1007/s11222-016-9666-x (Open Access) Wood, S. N. 2017. Generalized Additive Models: An Introduction with R, Second Edition, CRC Press.
The Pros and Cons of Smoothing spline
The terminology of splines can be confusing (at least I find it so) as exactly what people mean when they use "cubic spline", for example, depends on the type of cubic spline; we can have, for example
The Pros and Cons of Smoothing spline The terminology of splines can be confusing (at least I find it so) as exactly what people mean when they use "cubic spline", for example, depends on the type of cubic spline; we can have, for example, both cubic smoothing splines and cubic (penalised) regression splines. What I sketch below is taken from sections 5.1.2 and 5.2 of Wood (2017). An interpolating spline $g(x_i)$ say would set $g(x_i) = y_i$ as it interpolates the observations $y_i$ via a function composed of sections of cubic polynomials joined such that the spline is continuous to the second derivative. A cubic smoothing spline aims to balance fit to the data with producing a smooth function; the aim is not to interpolate the data which arises in interpolating splines. Rather than set $g(x_i) = y_i$, a cubic smoothing spline acts as $n$ free parameters to be estimated so as to minimise (Wood, 2017) $$\sum_{i=1}^{n}\{y_i - g(x_i)\}^2 + \lambda \int g^{\prime\prime}(x)^2dx$$ where the first part is a measure of the fit to the data, whilst the second part is a penalty against wiggliness (it the integral sums up the squared second derivative of the spline as a measure of the curvature or wiggliness, how fast the curve is changing slope). We can think of wiggliness as complexity so the function includes a penalty against overly complex smooths. It can be shown that a cubic smoothing spline $g(x)$, of all possible functions $f$, is the functions that minimises the above criterion (a proof is given in Wood, 2017, section 5.1.2 pp. 198). As with an interpolating spline, a cubic smoothing spline has knots located at each observation pair $x_i$, $y_i$. Earlier I mentioned that a smoothing spline has $n$ free parameters; there are as many parameters as data. Yet the effect of $\lambda$, the penalty against over wiggly smooths, is to produce a spline that is much smoother than implied if it used $n$ degrees of freedom (Wood 2017). This is the major negative on the side of smoothing splines. You have to estimate as many parameters as you have data and yet the effect of many of those parameters will in general be low because of the penalty against overly complex (wiggly) fits. Balancing this is the fact that the choice of knots in the smoothing spline is taken care of, because there is no choice. Moving to the penalized regression spline setting, we now have the choice of where to place the knots but we get to choose how many knots to use. How might we decide if this is a useful trade-off, that it is beneficial to fit the spline with a reduced number of knots even if we have to decide how many and where to put them? In a penalised regression spline, rather than think of knots per se, think of the spline as being made up of basis functions; these are little functions, which each have a coefficient, whose linear combination gives the value of the spline for a given $x_i$. The choice now is how many basis functions to use to model the response with the number $k$ being much fewer than the number of data $n$. The theory underlying this choice is a little limited or restricted to special cases or approaches to estimating the value for $\lambda$ but the general idea is that the number of basis functions required grows only slowly with $n$ in order to achieve close to the optimal performance represented by smoothing splines (summarised from Wood 2017). In general, where the knots are actually distributed through the data for a cubic regression spline does not have much of an effect on the fitted spline. Typical choices are to place $k-1$ knots evenly over the interval of $x$, or to place knots at the quantiles of the distribution of $x$. If you have a very uneven spread of observations over range of $x$, it would be wasteful to place knots evenly over $x$ so you could concentrate them where you have data. Alternatively, transforming $x$ in some way may even out the distribution such that placing knots evenly is possible again. When fitting a spline model in high dimensions, say a spline of two variables, knot placement is more problematic if the pairs of $x_{1i}, x_{2i}$ are limited to some region of the space spanned by $x_1$ and $x_2$; if the data do not originate in large parts of the space, then placing knots evenly will result in many of the knots being located away from the support of the data. Which is wasteful. Strategies for dealing with are available, such as space-filling algorithms, or using P-splines and sparse derivative-based penalties that allow for efficient estimation even in unevenly-distributed data (e.g. Wood 2016) References Wood, S. N. 2016. P-splines with derivative based penalties and tensor product smoothing of unevenly distributed data. Stat. Comput. 1–5. doi:10.1007/s11222-016-9666-x (Open Access) Wood, S. N. 2017. Generalized Additive Models: An Introduction with R, Second Edition, CRC Press.
The Pros and Cons of Smoothing spline The terminology of splines can be confusing (at least I find it so) as exactly what people mean when they use "cubic spline", for example, depends on the type of cubic spline; we can have, for example
16,723
Interpretation of confidence interval
I think lots of conventional accounts of this matter are not clear. Lets say you take a sample of size $100$ and get a $95\%$ confidence interval for $p$. Then you take another sample of $100$, independent of the first, and get another $95\%$ confidence interval for $p$. What changes is the confidence interval; what does not change is $p$. That means that in frequentist methods, one says the confidence interval is "random" but $p$ is "fixed" or "constant", i.e. not random. In frequentist methods, such as the method of confidence intervals, one assigns probabilities only to things that are random. So $\Pr(L<p<U)=0.95$ and $(L,U)$ is a confidence interval. ($L=$ "lower" and $U=$ "upper".) Take a new sample and $L$ and $U$ change but $p$ does not. Let's say in a particular instance you have $L=40.53$ and $U=43.61$. In frequentist methods one would not assign a probability to the statement $40.53<p<43.61$, other than a probability of $0$ or $1$, becuase nothing here is random: $40.53$ is not random, $p$ is not random (since it won't change if we take a new sample), and $43.61$ is not random. In practice, people do behave as if they're $95\%$ sure that $p$ is between $40.53$ and $43.61$. And as a practical matter, that may often make sense. But sometimes it doesn't. One such case is if numbers as large as $40$ or more are known in advance to be improbable, or if they are known to be highly probable. If one can assign some prior probability distribution to $p$, one uses Bayes theorem to get a credible interval, which may differ from the confidence interval because of prior knowledge of which ranges of values of $p$ are probable or improbable. It can also actually happen that the data themselves --- the things that change if a new sample is taken, can tell you that $p$ is unlikely to be, or even certain not to be, as big as $40$. That can happen even in cases in which the pair $(L,U)$ is a sufficient statistic for $p$. That phenomenon can be dealt with in some instances by Fisher's method of conditioning on an ancillary statistic. An example of this last phenomenon is when the sample consists of just two independent observations that are uniformly distributed in the interval $\theta\pm1/2$. Then the interval from the smaller of the two observations to the larger is a $50\%$ confidence interval. But if the distance between them is $0.001$, it would be absurd to be anywhere near $50\%$ sure that $\theta$ is between them, and if the distance is $0.999$, one would reasonably be almost $100\%$ sure $\theta$ is between them. The distance between them would be the ancillary statistic on which one would condition.
Interpretation of confidence interval
I think lots of conventional accounts of this matter are not clear. Lets say you take a sample of size $100$ and get a $95\%$ confidence interval for $p$. Then you take another sample of $100$, indepe
Interpretation of confidence interval I think lots of conventional accounts of this matter are not clear. Lets say you take a sample of size $100$ and get a $95\%$ confidence interval for $p$. Then you take another sample of $100$, independent of the first, and get another $95\%$ confidence interval for $p$. What changes is the confidence interval; what does not change is $p$. That means that in frequentist methods, one says the confidence interval is "random" but $p$ is "fixed" or "constant", i.e. not random. In frequentist methods, such as the method of confidence intervals, one assigns probabilities only to things that are random. So $\Pr(L<p<U)=0.95$ and $(L,U)$ is a confidence interval. ($L=$ "lower" and $U=$ "upper".) Take a new sample and $L$ and $U$ change but $p$ does not. Let's say in a particular instance you have $L=40.53$ and $U=43.61$. In frequentist methods one would not assign a probability to the statement $40.53<p<43.61$, other than a probability of $0$ or $1$, becuase nothing here is random: $40.53$ is not random, $p$ is not random (since it won't change if we take a new sample), and $43.61$ is not random. In practice, people do behave as if they're $95\%$ sure that $p$ is between $40.53$ and $43.61$. And as a practical matter, that may often make sense. But sometimes it doesn't. One such case is if numbers as large as $40$ or more are known in advance to be improbable, or if they are known to be highly probable. If one can assign some prior probability distribution to $p$, one uses Bayes theorem to get a credible interval, which may differ from the confidence interval because of prior knowledge of which ranges of values of $p$ are probable or improbable. It can also actually happen that the data themselves --- the things that change if a new sample is taken, can tell you that $p$ is unlikely to be, or even certain not to be, as big as $40$. That can happen even in cases in which the pair $(L,U)$ is a sufficient statistic for $p$. That phenomenon can be dealt with in some instances by Fisher's method of conditioning on an ancillary statistic. An example of this last phenomenon is when the sample consists of just two independent observations that are uniformly distributed in the interval $\theta\pm1/2$. Then the interval from the smaller of the two observations to the larger is a $50\%$ confidence interval. But if the distance between them is $0.001$, it would be absurd to be anywhere near $50\%$ sure that $\theta$ is between them, and if the distance is $0.999$, one would reasonably be almost $100\%$ sure $\theta$ is between them. The distance between them would be the ancillary statistic on which one would condition.
Interpretation of confidence interval I think lots of conventional accounts of this matter are not clear. Lets say you take a sample of size $100$ and get a $95\%$ confidence interval for $p$. Then you take another sample of $100$, indepe
16,724
Interpretation of confidence interval
The textbook definition of a $100 \times (1-\alpha)$% confidence interval is: An interval which, under many independent replications of the study under ideal conditions, captures the replicated effect measurement $100 \times (1-\alpha)$% of the time. Probability, to frequentists, comes from the notion of "rewinding time and space" to replicate findings, as if an infinite number of copies of the world were created to assess a scientific finding again and again and again. So a probability is a frequency exactly. For scientists, this is a very convenient way to discuss findings, since the first principle of science is that studies must be replicable. In your card example, the confusion for Bayesians and Frequentists is that the frequentist does not assign a probability to the face value of the particular card you have flipped from the deck whereas a Bayesian would. The frequentist would assign the probability to a card, flipped from the top of randomly shuffled deck. A Bayesian is not concerned with replicating the study, once the card is flipped, you now have 100% belief about what the card is and 0% belief that it could take any other value. For Bayesians, probability is a measure of belief. Note that Bayesians do not have confidence intervals for this reason, they summarize uncertainty with credibility intervals.
Interpretation of confidence interval
The textbook definition of a $100 \times (1-\alpha)$% confidence interval is: An interval which, under many independent replications of the study under ideal conditions, captures the replicated eff
Interpretation of confidence interval The textbook definition of a $100 \times (1-\alpha)$% confidence interval is: An interval which, under many independent replications of the study under ideal conditions, captures the replicated effect measurement $100 \times (1-\alpha)$% of the time. Probability, to frequentists, comes from the notion of "rewinding time and space" to replicate findings, as if an infinite number of copies of the world were created to assess a scientific finding again and again and again. So a probability is a frequency exactly. For scientists, this is a very convenient way to discuss findings, since the first principle of science is that studies must be replicable. In your card example, the confusion for Bayesians and Frequentists is that the frequentist does not assign a probability to the face value of the particular card you have flipped from the deck whereas a Bayesian would. The frequentist would assign the probability to a card, flipped from the top of randomly shuffled deck. A Bayesian is not concerned with replicating the study, once the card is flipped, you now have 100% belief about what the card is and 0% belief that it could take any other value. For Bayesians, probability is a measure of belief. Note that Bayesians do not have confidence intervals for this reason, they summarize uncertainty with credibility intervals.
Interpretation of confidence interval The textbook definition of a $100 \times (1-\alpha)$% confidence interval is: An interval which, under many independent replications of the study under ideal conditions, captures the replicated eff
16,725
Random forest on multi-level/hierarchical-structured data
In a single classification tree, these groups are coded the same as any other categorical variable. This is often done as either binary coding or just using an integer. There are different arguments for using either. In random forests if you are using binary coding, some groups will be included/excluded for any given tree. So you may have an indicator for country_2 but not country_3. If you leave the group variable as an integer then the ordering can affect the outcome as well. What does it mean for country > 5 and country < 12? How does that change if you randomly re-label the countries with new integers? At each step in growing a tree, the algorithm is looking for the split that optimizing the criteria. If there are large differences between groups then the grouping variable will be important, but if it is only moderately important and you prune a tree, then the variable may essentially excluded. Like most other machine learning algorithms, CART and random forests do not necessarily account for dependency between observations within groups the way you would expect in a hierarchical regression model. If there is dependency between observations, it should be captured by the random forest algorithm through the generation of many trees that use the grouping variable. However if other variables demonstrate greater discrimination then the grouping variable may be ignored. In your case, country and population are perfectly collinear. There is no information gained by using both variables in your model. So you can think about how a random forest model would treat these variables in your data.
Random forest on multi-level/hierarchical-structured data
In a single classification tree, these groups are coded the same as any other categorical variable. This is often done as either binary coding or just using an integer. There are different arguments f
Random forest on multi-level/hierarchical-structured data In a single classification tree, these groups are coded the same as any other categorical variable. This is often done as either binary coding or just using an integer. There are different arguments for using either. In random forests if you are using binary coding, some groups will be included/excluded for any given tree. So you may have an indicator for country_2 but not country_3. If you leave the group variable as an integer then the ordering can affect the outcome as well. What does it mean for country > 5 and country < 12? How does that change if you randomly re-label the countries with new integers? At each step in growing a tree, the algorithm is looking for the split that optimizing the criteria. If there are large differences between groups then the grouping variable will be important, but if it is only moderately important and you prune a tree, then the variable may essentially excluded. Like most other machine learning algorithms, CART and random forests do not necessarily account for dependency between observations within groups the way you would expect in a hierarchical regression model. If there is dependency between observations, it should be captured by the random forest algorithm through the generation of many trees that use the grouping variable. However if other variables demonstrate greater discrimination then the grouping variable may be ignored. In your case, country and population are perfectly collinear. There is no information gained by using both variables in your model. So you can think about how a random forest model would treat these variables in your data.
Random forest on multi-level/hierarchical-structured data In a single classification tree, these groups are coded the same as any other categorical variable. This is often done as either binary coding or just using an integer. There are different arguments f
16,726
Random forest on multi-level/hierarchical-structured data
Random Forests would work fine, but you have to be very careful when you tune the hyperparameters (especially if you want a realistic measure of generalization performance). The traditional OOB error estimates will be way optimistic since there is rampant "twinning" in your data. To get proper tuning and generalization estimates you need to understand what are the characteristics of any new data you expect to encounter. If you want to extrapolate to new countries, then you'll need to set up some manner of re-sample based tuning (such as k-fold cross validation) that does stratified sampling by country. You also need to be careful how you encode the data into a Random Forest. It appears that country is a categorical variable. Feeding it in as a numeric would be a bit rough, but not hopeless (especially if you ordered the IDs by something useful).
Random forest on multi-level/hierarchical-structured data
Random Forests would work fine, but you have to be very careful when you tune the hyperparameters (especially if you want a realistic measure of generalization performance). The traditional OOB error
Random forest on multi-level/hierarchical-structured data Random Forests would work fine, but you have to be very careful when you tune the hyperparameters (especially if you want a realistic measure of generalization performance). The traditional OOB error estimates will be way optimistic since there is rampant "twinning" in your data. To get proper tuning and generalization estimates you need to understand what are the characteristics of any new data you expect to encounter. If you want to extrapolate to new countries, then you'll need to set up some manner of re-sample based tuning (such as k-fold cross validation) that does stratified sampling by country. You also need to be careful how you encode the data into a Random Forest. It appears that country is a categorical variable. Feeding it in as a numeric would be a bit rough, but not hopeless (especially if you ordered the IDs by something useful).
Random forest on multi-level/hierarchical-structured data Random Forests would work fine, but you have to be very careful when you tune the hyperparameters (especially if you want a realistic measure of generalization performance). The traditional OOB error
16,727
Random forest on multi-level/hierarchical-structured data
I'm actually working on a R package that runs randomForest as the local classifier along a pre-defined class hierarchy. The package can be found in R Forge under 'hie-ran-forest'. The package is already operational, although it is failing one of the cran test (for MAC), I'm not sure exactly why. In addition to actually running randomForest for each parent node down the hierarchy, the package also contains predict functions and performance functions. One of the performance measures actually accounts for the hierarchical class structure. The package addresses cross level interaction by first running random forest as the local classifier at each parent node of the class hierarchy. Next the predict function retrieves the proportion of out of bag votes that each case received in each local classifier. Then there are two ways to turn the proportion of votes to crisp classification: 1. a stepwise majority rule- Start with the local classifier closest to the tree root and select the child of this classifier that received the highest proportion of votes. Next, look at all the children of the selected node and again select the child that received the highest proportion of votes in the relevant local classifier. Continue until a terminal node is reached. 2. a multiplicative majority rule- multiply the proportion of votes along each path from the tree root to any of the terminal modes and select the node that received the highest multiplicative proportion of votes. The multiplicative proportion of votes are comparable to the proportion of votes produced by a regular randomForest
Random forest on multi-level/hierarchical-structured data
I'm actually working on a R package that runs randomForest as the local classifier along a pre-defined class hierarchy. The package can be found in R Forge under 'hie-ran-forest'. The package is alrea
Random forest on multi-level/hierarchical-structured data I'm actually working on a R package that runs randomForest as the local classifier along a pre-defined class hierarchy. The package can be found in R Forge under 'hie-ran-forest'. The package is already operational, although it is failing one of the cran test (for MAC), I'm not sure exactly why. In addition to actually running randomForest for each parent node down the hierarchy, the package also contains predict functions and performance functions. One of the performance measures actually accounts for the hierarchical class structure. The package addresses cross level interaction by first running random forest as the local classifier at each parent node of the class hierarchy. Next the predict function retrieves the proportion of out of bag votes that each case received in each local classifier. Then there are two ways to turn the proportion of votes to crisp classification: 1. a stepwise majority rule- Start with the local classifier closest to the tree root and select the child of this classifier that received the highest proportion of votes. Next, look at all the children of the selected node and again select the child that received the highest proportion of votes in the relevant local classifier. Continue until a terminal node is reached. 2. a multiplicative majority rule- multiply the proportion of votes along each path from the tree root to any of the terminal modes and select the node that received the highest multiplicative proportion of votes. The multiplicative proportion of votes are comparable to the proportion of votes produced by a regular randomForest
Random forest on multi-level/hierarchical-structured data I'm actually working on a R package that runs randomForest as the local classifier along a pre-defined class hierarchy. The package can be found in R Forge under 'hie-ran-forest'. The package is alrea
16,728
Questions about Likelihood Principle
The likelihood principle has been stated in many different ways, with variable meaning and intelligibility. A.W.F. Edwards's book Likelihood is both an excellent introduction to many aspects of likelihood and still in print. This is how Edwards defines the likelihood principle: "Within the framework of a statistical model, all of the information which the data provide concerning the relative merits of two hypotheses is contained in the likelihood ratio of those hypotheses." (Edwards 1972, 1992 p. 30) So now to answers. "All of the information in the sample", as you quote, is simply an inadequate expression of the relevant part of the likelihood principle. Edwards says it much better: the model matters and the relevant information is the information relating to the relative merits of hypotheses. It is useful to note that the likelihood ratio only makes sense where the hypotheses in question come from the same statistical model and are mutually exclusive. In effect, they have to be points on the same likelihood function for the ratio to be useful. The likelihood principle is related to Bayes theorem, as you can see, but it is provable without reference to Bayes theorem. Yes, p(x|y) is (proportional to) a likelihood as long as x is data and y is a hypothesis (which might just be a hypothesised parameter value). The likelihood principle is controversial because its proof has been contested. In my opinion the disproofs are faulty, but nonetheless it is controversial. (At a different level, it can be said that the likelihood principle is controversial because it implies that frequentist methods for inference are in some ways faulty. Some people don't like that.) The likelihood principle has been proved, but its scope of relevance may be more constrained than its critics imagine. The likelihood principle is important for Bayesian methods because the data enter into Bayes equation by way of the likelihoods. Most Bayesian methods are compliant with the likelihood principle, but not all. Some people, like Edwards and Royall, contend that inferences can be made on the basis of likelihood functions without use of Bayes theorem, "pure likelihood inference". That is controversial as well. In fact, it is probably more controversial than the likelihood principle because Bayesians tend to agree with frequentists that pure likelihood methods are inappropriate. (My enemy's enemy...)
Questions about Likelihood Principle
The likelihood principle has been stated in many different ways, with variable meaning and intelligibility. A.W.F. Edwards's book Likelihood is both an excellent introduction to many aspects of likeli
Questions about Likelihood Principle The likelihood principle has been stated in many different ways, with variable meaning and intelligibility. A.W.F. Edwards's book Likelihood is both an excellent introduction to many aspects of likelihood and still in print. This is how Edwards defines the likelihood principle: "Within the framework of a statistical model, all of the information which the data provide concerning the relative merits of two hypotheses is contained in the likelihood ratio of those hypotheses." (Edwards 1972, 1992 p. 30) So now to answers. "All of the information in the sample", as you quote, is simply an inadequate expression of the relevant part of the likelihood principle. Edwards says it much better: the model matters and the relevant information is the information relating to the relative merits of hypotheses. It is useful to note that the likelihood ratio only makes sense where the hypotheses in question come from the same statistical model and are mutually exclusive. In effect, they have to be points on the same likelihood function for the ratio to be useful. The likelihood principle is related to Bayes theorem, as you can see, but it is provable without reference to Bayes theorem. Yes, p(x|y) is (proportional to) a likelihood as long as x is data and y is a hypothesis (which might just be a hypothesised parameter value). The likelihood principle is controversial because its proof has been contested. In my opinion the disproofs are faulty, but nonetheless it is controversial. (At a different level, it can be said that the likelihood principle is controversial because it implies that frequentist methods for inference are in some ways faulty. Some people don't like that.) The likelihood principle has been proved, but its scope of relevance may be more constrained than its critics imagine. The likelihood principle is important for Bayesian methods because the data enter into Bayes equation by way of the likelihoods. Most Bayesian methods are compliant with the likelihood principle, but not all. Some people, like Edwards and Royall, contend that inferences can be made on the basis of likelihood functions without use of Bayes theorem, "pure likelihood inference". That is controversial as well. In fact, it is probably more controversial than the likelihood principle because Bayesians tend to agree with frequentists that pure likelihood methods are inappropriate. (My enemy's enemy...)
Questions about Likelihood Principle The likelihood principle has been stated in many different ways, with variable meaning and intelligibility. A.W.F. Edwards's book Likelihood is both an excellent introduction to many aspects of likeli
16,729
Understanding MCMC and the Metropolis-Hastings algorithm
There seem to be some misconceptions about what the Metropolis-Hastings (MH) algorithm is in your description of the algorithm. First of all, one has to understand that MH is a sampling algorithm. As stated in wikipedia In statistics and in statistical physics, the Metropolis–Hastings algorithm is a Markov chain Monte Carlo (MCMC) method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. In order to implement the MH algorithm you need a proposal density or jumping distribution $Q(\cdot\vert\cdot)$, from which it is easy to sample. If you want to sample from a distribution $f(\cdot)$, the MH algorithm can be implemented as follows: Pick a initial random state $x_0$. Generate a candidate $x^{\star}$ from $Q(\cdot\vert x_0)$. Calculate the ratio $\alpha=f(x^{\star})/f(x_0)$. Accept $x^{\star}$ as a realisation of $f$ with probability $\alpha$. Take $x^{\star}$ as the new initial state and continue sampling until you get the desired sample size. Once you get the sample you still need to burn it and thin it: given that the sampler works asymptotically, you need to remove the first $N$ samples (burn-in), and given that the samples are dependent you need to subsample each $k$ iterations (thinning). An example in R can be found in the following link: http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/metrop/metrop.html This method is largely employed in Bayesian statistics for sampling from the posterior distribution of the model parameters. The example that you are using seems unclear to me given that $f(x)=ax$ is not a density unless you restrict $x$ on a bounded set. My impression is that you are interested on fitting a straight line to a set of points for which I would recommend you to check the use of the Metropolis-Hastings algorithm in the context of linear regression. The following link presents some ideas on how MH can be used in this context (Example 6.8): Robert & Casella (2010), Introducing Monte Carlo Methods with R, Ch. 6, "Metropolis–Hastings Algorithms" There are also lots of questions, with pointers to interesting references, in this site discussing about the meaning of likelihood function. Another pointer of possible interest is the R package mcmc, which implements the MH algorithm with Gaussian proposals in the command metrop().
Understanding MCMC and the Metropolis-Hastings algorithm
There seem to be some misconceptions about what the Metropolis-Hastings (MH) algorithm is in your description of the algorithm. First of all, one has to understand that MH is a sampling algorithm. As
Understanding MCMC and the Metropolis-Hastings algorithm There seem to be some misconceptions about what the Metropolis-Hastings (MH) algorithm is in your description of the algorithm. First of all, one has to understand that MH is a sampling algorithm. As stated in wikipedia In statistics and in statistical physics, the Metropolis–Hastings algorithm is a Markov chain Monte Carlo (MCMC) method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. In order to implement the MH algorithm you need a proposal density or jumping distribution $Q(\cdot\vert\cdot)$, from which it is easy to sample. If you want to sample from a distribution $f(\cdot)$, the MH algorithm can be implemented as follows: Pick a initial random state $x_0$. Generate a candidate $x^{\star}$ from $Q(\cdot\vert x_0)$. Calculate the ratio $\alpha=f(x^{\star})/f(x_0)$. Accept $x^{\star}$ as a realisation of $f$ with probability $\alpha$. Take $x^{\star}$ as the new initial state and continue sampling until you get the desired sample size. Once you get the sample you still need to burn it and thin it: given that the sampler works asymptotically, you need to remove the first $N$ samples (burn-in), and given that the samples are dependent you need to subsample each $k$ iterations (thinning). An example in R can be found in the following link: http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/metrop/metrop.html This method is largely employed in Bayesian statistics for sampling from the posterior distribution of the model parameters. The example that you are using seems unclear to me given that $f(x)=ax$ is not a density unless you restrict $x$ on a bounded set. My impression is that you are interested on fitting a straight line to a set of points for which I would recommend you to check the use of the Metropolis-Hastings algorithm in the context of linear regression. The following link presents some ideas on how MH can be used in this context (Example 6.8): Robert & Casella (2010), Introducing Monte Carlo Methods with R, Ch. 6, "Metropolis–Hastings Algorithms" There are also lots of questions, with pointers to interesting references, in this site discussing about the meaning of likelihood function. Another pointer of possible interest is the R package mcmc, which implements the MH algorithm with Gaussian proposals in the command metrop().
Understanding MCMC and the Metropolis-Hastings algorithm There seem to be some misconceptions about what the Metropolis-Hastings (MH) algorithm is in your description of the algorithm. First of all, one has to understand that MH is a sampling algorithm. As
16,730
How to get an R-squared for a loess fit?
My first thought was to compute a pseudo $R^2$ measure as follows: ss.dist <- sum(scale(cars$dist, scale=FALSE)^2) ss.resid <- sum(resid(cars.lo)^2) 1-ss.resid/ss.dist Here, we get a value of 0.6814984 ($\approx$ cor(cars$dist, predict(cars.lo))^2), close to what would be obtained from a GAM: library(mgcv) summary(gam(dist ~ speed, data=cars)) This also seems to be in agreement with what S loess function would return (I don't have S so I can't check by myself) as Multiple R-squared. For example, using the airquality R dataset, which looks like the air data Chambers and Hastie used in the 'white book' (the one that is being referenced in the on-line help for loess; but that's not the exact same dataset), I got an $R^2$ of 0.8101377 using the above formula. That's pretty in agreement with what Chambers and Hastie reported. I should note that I didn't find any paper dealing specifically with that (ok, that was just a quick googling), and William Cleveland doesn't speak about $R^2$-like measure in his paper. However, I wonder if the liberty with which you can choose the degree of smoothing (or window span) does not preclude any use of $R^2$-based measure.
How to get an R-squared for a loess fit?
My first thought was to compute a pseudo $R^2$ measure as follows: ss.dist <- sum(scale(cars$dist, scale=FALSE)^2) ss.resid <- sum(resid(cars.lo)^2) 1-ss.resid/ss.dist Here, we get a value of 0.68149
How to get an R-squared for a loess fit? My first thought was to compute a pseudo $R^2$ measure as follows: ss.dist <- sum(scale(cars$dist, scale=FALSE)^2) ss.resid <- sum(resid(cars.lo)^2) 1-ss.resid/ss.dist Here, we get a value of 0.6814984 ($\approx$ cor(cars$dist, predict(cars.lo))^2), close to what would be obtained from a GAM: library(mgcv) summary(gam(dist ~ speed, data=cars)) This also seems to be in agreement with what S loess function would return (I don't have S so I can't check by myself) as Multiple R-squared. For example, using the airquality R dataset, which looks like the air data Chambers and Hastie used in the 'white book' (the one that is being referenced in the on-line help for loess; but that's not the exact same dataset), I got an $R^2$ of 0.8101377 using the above formula. That's pretty in agreement with what Chambers and Hastie reported. I should note that I didn't find any paper dealing specifically with that (ok, that was just a quick googling), and William Cleveland doesn't speak about $R^2$-like measure in his paper. However, I wonder if the liberty with which you can choose the degree of smoothing (or window span) does not preclude any use of $R^2$-based measure.
How to get an R-squared for a loess fit? My first thought was to compute a pseudo $R^2$ measure as follows: ss.dist <- sum(scale(cars$dist, scale=FALSE)^2) ss.resid <- sum(resid(cars.lo)^2) 1-ss.resid/ss.dist Here, we get a value of 0.68149
16,731
Intuition behind power law distribution
This is an heavy tailed distribution, since the cdf is $$ F(x) = 1 - \left( \dfrac{x}{x_\min} \right)^{1-\alpha} $$ So the probability to exceed $x$, $(x/x_\min)^{1-\alpha}$ can be made arbitrarily close to $1$ by the proper choice of $\alpha$. For instance, if one wants the probability to exceed $10^u x_\min$ to be at least $0.9$, one should pick $\alpha$ to be at most $$ 1-\log_{10}(0.9)/u $$ a curve represented below, with the first axis being scaled by $u$, not by $10^u x_\min$...
Intuition behind power law distribution
This is an heavy tailed distribution, since the cdf is $$ F(x) = 1 - \left( \dfrac{x}{x_\min} \right)^{1-\alpha} $$ So the probability to exceed $x$, $(x/x_\min)^{1-\alpha}$ can be made arbitrarily cl
Intuition behind power law distribution This is an heavy tailed distribution, since the cdf is $$ F(x) = 1 - \left( \dfrac{x}{x_\min} \right)^{1-\alpha} $$ So the probability to exceed $x$, $(x/x_\min)^{1-\alpha}$ can be made arbitrarily close to $1$ by the proper choice of $\alpha$. For instance, if one wants the probability to exceed $10^u x_\min$ to be at least $0.9$, one should pick $\alpha$ to be at most $$ 1-\log_{10}(0.9)/u $$ a curve represented below, with the first axis being scaled by $u$, not by $10^u x_\min$...
Intuition behind power law distribution This is an heavy tailed distribution, since the cdf is $$ F(x) = 1 - \left( \dfrac{x}{x_\min} \right)^{1-\alpha} $$ So the probability to exceed $x$, $(x/x_\min)^{1-\alpha}$ can be made arbitrarily cl
16,732
Intuition behind power law distribution
It's not a peer-reviewed source, but I like this note by CMU stats professor Cosma Shalizi. He's also an author on this article, about estimating such things from data.
Intuition behind power law distribution
It's not a peer-reviewed source, but I like this note by CMU stats professor Cosma Shalizi. He's also an author on this article, about estimating such things from data.
Intuition behind power law distribution It's not a peer-reviewed source, but I like this note by CMU stats professor Cosma Shalizi. He's also an author on this article, about estimating such things from data.
Intuition behind power law distribution It's not a peer-reviewed source, but I like this note by CMU stats professor Cosma Shalizi. He's also an author on this article, about estimating such things from data.
16,733
Intuition behind power law distribution
The paper Power Laws in Economics and Finance may help gaining intuition about power laws. Xavier Gabaix states that power law (PL) is the form taken by a large number of surprising empirical regularities in economics and finance. His review surveys well-documented empirical PLs regarding income and wealth, the size of cities and firms, stock market returns, trading volume, international trade, and executive pay. Intuition for the Pareto distribution Pareto (wikipedia) originally described the allocation of wealth among individuals: a large portion of the wealth of any society is owned by a small percentage of people. His idea expressed more simply as the Pareto principle or the "80-20 rule" says that 20% of the population controls 80% of the wealth. The right tail of income and wealth distributions often resemble Pareto If income distribution is Pareto, then one can derive simple expressions for the share of top 1%, or top 10%. Then the top qth percentile's share of total income can be derived as: $$\left(\frac{q}{100}\right)^{\frac{\alpha-1}{\alpha}},$$ where $\alpha \geq 1$ is the shape parameter. This expression implies that a lower $\alpha$ corresponds to a thicker tail of the Pareto distribution and thus to a greater share of total income being captured by individuals at higher percentiles of the distribution. For example, with $\alpha=2$, the top 1% share is 10%, and with $\alpha=3$, it is 4%.
Intuition behind power law distribution
The paper Power Laws in Economics and Finance may help gaining intuition about power laws. Xavier Gabaix states that power law (PL) is the form taken by a large number of surprising empirical regulari
Intuition behind power law distribution The paper Power Laws in Economics and Finance may help gaining intuition about power laws. Xavier Gabaix states that power law (PL) is the form taken by a large number of surprising empirical regularities in economics and finance. His review surveys well-documented empirical PLs regarding income and wealth, the size of cities and firms, stock market returns, trading volume, international trade, and executive pay. Intuition for the Pareto distribution Pareto (wikipedia) originally described the allocation of wealth among individuals: a large portion of the wealth of any society is owned by a small percentage of people. His idea expressed more simply as the Pareto principle or the "80-20 rule" says that 20% of the population controls 80% of the wealth. The right tail of income and wealth distributions often resemble Pareto If income distribution is Pareto, then one can derive simple expressions for the share of top 1%, or top 10%. Then the top qth percentile's share of total income can be derived as: $$\left(\frac{q}{100}\right)^{\frac{\alpha-1}{\alpha}},$$ where $\alpha \geq 1$ is the shape parameter. This expression implies that a lower $\alpha$ corresponds to a thicker tail of the Pareto distribution and thus to a greater share of total income being captured by individuals at higher percentiles of the distribution. For example, with $\alpha=2$, the top 1% share is 10%, and with $\alpha=3$, it is 4%.
Intuition behind power law distribution The paper Power Laws in Economics and Finance may help gaining intuition about power laws. Xavier Gabaix states that power law (PL) is the form taken by a large number of surprising empirical regulari
16,734
Intuition behind power law distribution
One interesting property of the power-law distribution comes from looking at it on a log-scale. If we have $X \sim \text{Power}(x_\min, \alpha)$ then the logarithmic transformation $Y = \ln(x/x_\min) \sim \text{Exp}(\alpha-1)$. That is, the values of $X$ have an exponential distribution on the logarithmic scale. Now, one important property of the exponential distribution is that it has a constant hazard rate. Writing out the hazard rate for $Y$ via first-principles (as a conditional density in its limit form), and adjusting it to frame it in terms of $X$ we obtain: $$\begin{equation} \begin{aligned} \alpha -1 = \lambda_Y(y) &= \lim_{\epsilon \downarrow 0} \frac{1}{\epsilon} \cdot \mathbb{P}(y \leqslant Y \leqslant y + \epsilon| Y \geqslant y) \\[6pt] &= \lim_{\epsilon \downarrow 0} \frac{1}{\epsilon} \cdot \mathbb{P}(\ln(x) \leqslant \ln(X) \leqslant \ln(x) + \epsilon| X \geqslant x) \\[6pt] &= \lim_{\epsilon \downarrow 0} \frac{\mathbb{P}(x \leqslant X \leqslant x e^\epsilon | X \geqslant x)}{\epsilon} \\[6pt] &= \lim_{\delta \downarrow 1} \frac{ \mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x)}{\ln \delta}. \\[6pt] \end{aligned} \end{equation}$$ We can see from this hazard characterisation that $\mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x) \approx (\alpha-1) \ln \delta $ for any small values of $\ln \delta$. Notice that this probability does not depend on the conditioning value $x$, which is the result of the constant-hazard property. Hence, for any conditioning values $x, x' > x_\min$, and any small value $\ln \delta$, we have: $$\mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x) \approx \mathbb{P}(x' \leqslant X \leqslant \delta x' | X \geqslant x').$$ Hence, we see that the power-law can be characterised by the fact that this conditional probability is approximately the same regardless of the conditioning point. In the context of stock prices, if these follow a power-law then we can say that, the probability that the stock will "rise" by some proportion is not dependent on its present value$^\dagger$. $^\dagger$ We use "rise" loosely here, since we are talking about a single random variable, and we have not modelled a time-series of stock prices. Within out present context we refer to the probability of a "rise" in the stock price in the sense of a conditional probability that the price is within some interval above a lower bound, conditional on this lower bound.
Intuition behind power law distribution
One interesting property of the power-law distribution comes from looking at it on a log-scale. If we have $X \sim \text{Power}(x_\min, \alpha)$ then the logarithmic transformation $Y = \ln(x/x_\min)
Intuition behind power law distribution One interesting property of the power-law distribution comes from looking at it on a log-scale. If we have $X \sim \text{Power}(x_\min, \alpha)$ then the logarithmic transformation $Y = \ln(x/x_\min) \sim \text{Exp}(\alpha-1)$. That is, the values of $X$ have an exponential distribution on the logarithmic scale. Now, one important property of the exponential distribution is that it has a constant hazard rate. Writing out the hazard rate for $Y$ via first-principles (as a conditional density in its limit form), and adjusting it to frame it in terms of $X$ we obtain: $$\begin{equation} \begin{aligned} \alpha -1 = \lambda_Y(y) &= \lim_{\epsilon \downarrow 0} \frac{1}{\epsilon} \cdot \mathbb{P}(y \leqslant Y \leqslant y + \epsilon| Y \geqslant y) \\[6pt] &= \lim_{\epsilon \downarrow 0} \frac{1}{\epsilon} \cdot \mathbb{P}(\ln(x) \leqslant \ln(X) \leqslant \ln(x) + \epsilon| X \geqslant x) \\[6pt] &= \lim_{\epsilon \downarrow 0} \frac{\mathbb{P}(x \leqslant X \leqslant x e^\epsilon | X \geqslant x)}{\epsilon} \\[6pt] &= \lim_{\delta \downarrow 1} \frac{ \mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x)}{\ln \delta}. \\[6pt] \end{aligned} \end{equation}$$ We can see from this hazard characterisation that $\mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x) \approx (\alpha-1) \ln \delta $ for any small values of $\ln \delta$. Notice that this probability does not depend on the conditioning value $x$, which is the result of the constant-hazard property. Hence, for any conditioning values $x, x' > x_\min$, and any small value $\ln \delta$, we have: $$\mathbb{P}(x \leqslant X \leqslant \delta x | X \geqslant x) \approx \mathbb{P}(x' \leqslant X \leqslant \delta x' | X \geqslant x').$$ Hence, we see that the power-law can be characterised by the fact that this conditional probability is approximately the same regardless of the conditioning point. In the context of stock prices, if these follow a power-law then we can say that, the probability that the stock will "rise" by some proportion is not dependent on its present value$^\dagger$. $^\dagger$ We use "rise" loosely here, since we are talking about a single random variable, and we have not modelled a time-series of stock prices. Within out present context we refer to the probability of a "rise" in the stock price in the sense of a conditional probability that the price is within some interval above a lower bound, conditional on this lower bound.
Intuition behind power law distribution One interesting property of the power-law distribution comes from looking at it on a log-scale. If we have $X \sim \text{Power}(x_\min, \alpha)$ then the logarithmic transformation $Y = \ln(x/x_\min)
16,735
When do we combine dimensionality reduction with clustering?
This is by no means a complete answer, the question you should be asking is "what kind of distances are preserved when doing dimensionality reduction?". Since clustering algorithms such as K-means operate only on distances, the right distance metric to use (theoretically) is the distance metric which is preserved by the dimensionality reduction. This way, the dimensionality reduction step can be seen as a computational shortcut to cluster the data in a lower dimensional space. (also to avoid local minima, etc) There are many subtleties here which I will not pretend to understand, (local distances vs global distances, how relative distances are distorted, etc) but I think this is the right direction to to think about these things theoretically.
When do we combine dimensionality reduction with clustering?
This is by no means a complete answer, the question you should be asking is "what kind of distances are preserved when doing dimensionality reduction?". Since clustering algorithms such as K-means ope
When do we combine dimensionality reduction with clustering? This is by no means a complete answer, the question you should be asking is "what kind of distances are preserved when doing dimensionality reduction?". Since clustering algorithms such as K-means operate only on distances, the right distance metric to use (theoretically) is the distance metric which is preserved by the dimensionality reduction. This way, the dimensionality reduction step can be seen as a computational shortcut to cluster the data in a lower dimensional space. (also to avoid local minima, etc) There are many subtleties here which I will not pretend to understand, (local distances vs global distances, how relative distances are distorted, etc) but I think this is the right direction to to think about these things theoretically.
When do we combine dimensionality reduction with clustering? This is by no means a complete answer, the question you should be asking is "what kind of distances are preserved when doing dimensionality reduction?". Since clustering algorithms such as K-means ope
16,736
When do we combine dimensionality reduction with clustering?
In reply to your title "When do we combine dimensionality reduction with clustering?" rather than the full question. One possible reason is obvious: when we want to secure agaist outliers. K-means algo, if without initial centers hint, takes k most apart points in the cloud as initial centers, and right these are likely to be outliers. Preacting by PCA neutralizes outliers which lie along junior components - by projecting them onto the few senior components which are retained in PCA.
When do we combine dimensionality reduction with clustering?
In reply to your title "When do we combine dimensionality reduction with clustering?" rather than the full question. One possible reason is obvious: when we want to secure agaist outliers. K-means alg
When do we combine dimensionality reduction with clustering? In reply to your title "When do we combine dimensionality reduction with clustering?" rather than the full question. One possible reason is obvious: when we want to secure agaist outliers. K-means algo, if without initial centers hint, takes k most apart points in the cloud as initial centers, and right these are likely to be outliers. Preacting by PCA neutralizes outliers which lie along junior components - by projecting them onto the few senior components which are retained in PCA.
When do we combine dimensionality reduction with clustering? In reply to your title "When do we combine dimensionality reduction with clustering?" rather than the full question. One possible reason is obvious: when we want to secure agaist outliers. K-means alg
16,737
Statistical landscape
Here's one I found via a Google Image search, but maybe it's too brief, and the diagram too simple: http://labstats.net/articles/overview.html
Statistical landscape
Here's one I found via a Google Image search, but maybe it's too brief, and the diagram too simple: http://labstats.net/articles/overview.html
Statistical landscape Here's one I found via a Google Image search, but maybe it's too brief, and the diagram too simple: http://labstats.net/articles/overview.html
Statistical landscape Here's one I found via a Google Image search, but maybe it's too brief, and the diagram too simple: http://labstats.net/articles/overview.html
16,738
Statistical landscape
Here's a longer article. No diagram and isn't exactly a survey, more, as the abstract puts it, of 'an idiosyncratic walk through some of these issues': M. J. Bayarri and J. O. Berger (2004). "The Interplay of Bayesian and Frequentist Analysis". Statistical Science 19 (1):58-80. (access requires a JSTOR subscription)
Statistical landscape
Here's a longer article. No diagram and isn't exactly a survey, more, as the abstract puts it, of 'an idiosyncratic walk through some of these issues': M. J. Bayarri and J. O. Berger (2004). "The Inte
Statistical landscape Here's a longer article. No diagram and isn't exactly a survey, more, as the abstract puts it, of 'an idiosyncratic walk through some of these issues': M. J. Bayarri and J. O. Berger (2004). "The Interplay of Bayesian and Frequentist Analysis". Statistical Science 19 (1):58-80. (access requires a JSTOR subscription)
Statistical landscape Here's a longer article. No diagram and isn't exactly a survey, more, as the abstract puts it, of 'an idiosyncratic walk through some of these issues': M. J. Bayarri and J. O. Berger (2004). "The Inte
16,739
Does a cointegration model exist for irregularly spaced time series?
You could start with the following references: Comte (1999) "Discrete and continuous time cointegration", Journal of Econometrics. Ferstl (2009) "Cointegration in discrete and continuous time". Thesis. Citations of Comte may also be useful.
Does a cointegration model exist for irregularly spaced time series?
You could start with the following references: Comte (1999) "Discrete and continuous time cointegration", Journal of Econometrics. Ferstl (2009) "Cointegration in discrete and continuous time". Thesi
Does a cointegration model exist for irregularly spaced time series? You could start with the following references: Comte (1999) "Discrete and continuous time cointegration", Journal of Econometrics. Ferstl (2009) "Cointegration in discrete and continuous time". Thesis. Citations of Comte may also be useful.
Does a cointegration model exist for irregularly spaced time series? You could start with the following references: Comte (1999) "Discrete and continuous time cointegration", Journal of Econometrics. Ferstl (2009) "Cointegration in discrete and continuous time". Thesi
16,740
Does a cointegration model exist for irregularly spaced time series?
Although it may only be of little help, the problem you present to me is synonymous with the "Change of Support" problem encountered when using areal units. Although this work just presents a framework for what you describe as "reglarize and interpolate" using a method referred to as "kriging". I don't think any of this work will help answer your question of whether estimating your missing values in the series in such a manner will bias error correction estimates, although if some of your samples are in clustered time intervals for both series you may be able to check for yourself. You may also be interested in the technique of "co-kriging" from this field, which uses information from one source to estimate the value for another (if your interested I would suggest you check out the work being done by Pierre Goovaerts). Again I'm not sure how helpful this will be though. It may be substantially simpler to just use current time-series forecasting techniques to estimate your missing data. It won't help you decide what to estimate either. Good luck, and keep the thread updated if you find any pertinent material. I would be interested, and you would think with the proliferation of data sources online this would become an pertinent issue for at least some research projects.
Does a cointegration model exist for irregularly spaced time series?
Although it may only be of little help, the problem you present to me is synonymous with the "Change of Support" problem encountered when using areal units. Although this work just presents a framewor
Does a cointegration model exist for irregularly spaced time series? Although it may only be of little help, the problem you present to me is synonymous with the "Change of Support" problem encountered when using areal units. Although this work just presents a framework for what you describe as "reglarize and interpolate" using a method referred to as "kriging". I don't think any of this work will help answer your question of whether estimating your missing values in the series in such a manner will bias error correction estimates, although if some of your samples are in clustered time intervals for both series you may be able to check for yourself. You may also be interested in the technique of "co-kriging" from this field, which uses information from one source to estimate the value for another (if your interested I would suggest you check out the work being done by Pierre Goovaerts). Again I'm not sure how helpful this will be though. It may be substantially simpler to just use current time-series forecasting techniques to estimate your missing data. It won't help you decide what to estimate either. Good luck, and keep the thread updated if you find any pertinent material. I would be interested, and you would think with the proliferation of data sources online this would become an pertinent issue for at least some research projects.
Does a cointegration model exist for irregularly spaced time series? Although it may only be of little help, the problem you present to me is synonymous with the "Change of Support" problem encountered when using areal units. Although this work just presents a framewor
16,741
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
rstan provides you with all the tools you need to solve this problem with Bayesian inference. In addition to the usual regression model of response $y$ in terms of predictors $x$, you should include a model of $x$ in the Stan code. This model should include the left-censoring. The Stan user manual chapter on censoring explains two different ways to do this in the Stan language. The first way is easier to incorporate into a regression model. The model for $x$ would look something like this (omitting the definition of N_obs and such): data { real x_obs[N_obs]; } parameters { real<upper=DL> x_cens[N_cens]; real x[N]; } model { x_obs ~ normal(mu, sigma); x_cens ~ normal(mu, sigma); x = append_array(x_obs, x_cens); } The key idea is that the censored data is represented by parameters whose upper limit is the detection limit. The censored data will be sampled alongside the other parameters in the model, so the posteriors you get will automatically integrate out the censored data.
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
rstan provides you with all the tools you need to solve this problem with Bayesian inference. In addition to the usual regression model of response $y$ in terms of predictors $x$, you should include
How best to deal with a left-censored predictor (because of detection limits) in a linear model? rstan provides you with all the tools you need to solve this problem with Bayesian inference. In addition to the usual regression model of response $y$ in terms of predictors $x$, you should include a model of $x$ in the Stan code. This model should include the left-censoring. The Stan user manual chapter on censoring explains two different ways to do this in the Stan language. The first way is easier to incorporate into a regression model. The model for $x$ would look something like this (omitting the definition of N_obs and such): data { real x_obs[N_obs]; } parameters { real<upper=DL> x_cens[N_cens]; real x[N]; } model { x_obs ~ normal(mu, sigma); x_cens ~ normal(mu, sigma); x = append_array(x_obs, x_cens); } The key idea is that the censored data is represented by parameters whose upper limit is the detection limit. The censored data will be sampled alongside the other parameters in the model, so the posteriors you get will automatically integrate out the censored data.
How best to deal with a left-censored predictor (because of detection limits) in a linear model? rstan provides you with all the tools you need to solve this problem with Bayesian inference. In addition to the usual regression model of response $y$ in terms of predictors $x$, you should include
16,742
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
In McElreath's Statistical Rethinking (2020) he gives an example almost exactly like what you are describing, where in chemical analyses there is a threshold below which something (e.g. the concentration of a specific compound) cannot be measured. In this case he discusses the use of a hurdle model. From what I'm reading on them, they could be applicable to your analysis, and they can also be fit relatively easily using Stan. https://mc-stan.org/docs/2_20/stan-users-guide/zero-inflated-section.html McElreath, R. (2020). Statistical rethinking: A Bayesian course with examples in R and Stan. CRC press.
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
In McElreath's Statistical Rethinking (2020) he gives an example almost exactly like what you are describing, where in chemical analyses there is a threshold below which something (e.g. the concentrat
How best to deal with a left-censored predictor (because of detection limits) in a linear model? In McElreath's Statistical Rethinking (2020) he gives an example almost exactly like what you are describing, where in chemical analyses there is a threshold below which something (e.g. the concentration of a specific compound) cannot be measured. In this case he discusses the use of a hurdle model. From what I'm reading on them, they could be applicable to your analysis, and they can also be fit relatively easily using Stan. https://mc-stan.org/docs/2_20/stan-users-guide/zero-inflated-section.html McElreath, R. (2020). Statistical rethinking: A Bayesian course with examples in R and Stan. CRC press.
How best to deal with a left-censored predictor (because of detection limits) in a linear model? In McElreath's Statistical Rethinking (2020) he gives an example almost exactly like what you are describing, where in chemical analyses there is a threshold below which something (e.g. the concentrat
16,743
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
Multiple imputation plays reasonably nicely with Bayesian inference. You just fit the Bayesian model on each imputation (making sure there's not too few, e.g. do at least 100 imputations or so) and then put the posterior samples together (=you use the mixture of the posteriors as the overall posterior). However, doing a good multiple imputation requires a multiple imputation tool that is aware of the left-censoring (if you ignore that, MI would more likely impute values like the non-censored observations). Technically, I think it would be valid to do multiple imputation and only select the imputation, for which values are below the limit of detection, but you very quickly get to where none of 1000s of imputations fulfill the criterion. The substitution rule you mention apparently does not do too badly, if the censored quantity is the dependent variable in a model (see e.g. this paper for a list of references on the topic). How does it do for a covariate? No idea. I'd speculate it might be okay, if there's very few censored values. However, you have quite a few values that are censored. The other obvious approach mentioned by Tom Minka is joint modeling of the covariate and the outcome of interest. I tried to really spell this out in Stan for an example like yours with a bit of made up data. I suspect that as usual my Stan program is not as efficiently written as it could be, but at least I hope it is reasonably clear. library(rstan) stancode = " data { int<lower=0> N_obs; // Number of observation real y[N_obs]; // Observed y-values real x[N_obs]; // observed value or limit below which x is left-censored when x_censored=1 int x_censored[N_obs]; // 1=left-censored, 0=not censored, 2=right-censored real measurement_error[N_obs]; // measurement error we know for the covariates } parameters { real mu; // intercept for the regression model for y real<lower=0> sigma; // residual SD for the regression model for y real beta; // regression coefficient for x in the regression model for y real x_randomeff[N_obs]; // A random effect we use to capture the underlying true value // (obtained by multiplying by sigmax and adding mux - for more on the rationale for this parameterization look "non-centralized parameterization") real mux; // True population mean of the covariate values real<lower=0> sigmax; // True population SD of the covariate values } transformed parameters { real x_imputed[N_obs]; // Imputed values for x (or rather log(x)) for (r in 1:N_obs){ x_imputed[r] = mux + x_randomeff[r] * sigmax; } } model { // Specifying some wide weakly informative priors mu ~ normal(0, 100); sigma ~ normal(0, 100); beta ~ normal(0, 100); mux ~ normal(0, 10); sigmax ~ normal(0, 10); x_randomeff ~ normal(0,1); for (r in 1:N_obs){ // Dealing with the covariate model if (x_censored[r]==1){ target += normal_lcdf(x[r] | x_imputed[r], measurement_error[r]); } else if (x_censored[r]==2){ target += normal_lccdf(x[r] | x_imputed[r], measurement_error[r]); } else { x[r] ~ normal(x_imputed[r], measurement_error[r]); } // fitting the regression model for y y[r] ~ normal(mu + x_imputed[r]*beta, sigma); } } " sfit = stan(model_code = stancode, data=list(N_obs=12, y=c(44, 40, 37, 33, 31, 27, 24, 19, 16, 13, 9, 6), x=log( c(15, 7, 5, 3, 0.9, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5) ), x_censored = c(rep(0,5), rep(1, 7)), measurement_error=rep(0.1, 12)), control=list(adapt_delta=0.95)) summary(sfit)$summary As you can see the model even outputs what it imputed for the missing values. There's probably other ways of doing this, but this seemed reasonably intuitive to me. At the moment, I am using $log(x)\times \beta$ in the regression equation, but you could change that by exponentiating x_imputed[r]. Update: this paper just popped up in my Twitter feed.
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
Multiple imputation plays reasonably nicely with Bayesian inference. You just fit the Bayesian model on each imputation (making sure there's not too few, e.g. do at least 100 imputations or so) and th
How best to deal with a left-censored predictor (because of detection limits) in a linear model? Multiple imputation plays reasonably nicely with Bayesian inference. You just fit the Bayesian model on each imputation (making sure there's not too few, e.g. do at least 100 imputations or so) and then put the posterior samples together (=you use the mixture of the posteriors as the overall posterior). However, doing a good multiple imputation requires a multiple imputation tool that is aware of the left-censoring (if you ignore that, MI would more likely impute values like the non-censored observations). Technically, I think it would be valid to do multiple imputation and only select the imputation, for which values are below the limit of detection, but you very quickly get to where none of 1000s of imputations fulfill the criterion. The substitution rule you mention apparently does not do too badly, if the censored quantity is the dependent variable in a model (see e.g. this paper for a list of references on the topic). How does it do for a covariate? No idea. I'd speculate it might be okay, if there's very few censored values. However, you have quite a few values that are censored. The other obvious approach mentioned by Tom Minka is joint modeling of the covariate and the outcome of interest. I tried to really spell this out in Stan for an example like yours with a bit of made up data. I suspect that as usual my Stan program is not as efficiently written as it could be, but at least I hope it is reasonably clear. library(rstan) stancode = " data { int<lower=0> N_obs; // Number of observation real y[N_obs]; // Observed y-values real x[N_obs]; // observed value or limit below which x is left-censored when x_censored=1 int x_censored[N_obs]; // 1=left-censored, 0=not censored, 2=right-censored real measurement_error[N_obs]; // measurement error we know for the covariates } parameters { real mu; // intercept for the regression model for y real<lower=0> sigma; // residual SD for the regression model for y real beta; // regression coefficient for x in the regression model for y real x_randomeff[N_obs]; // A random effect we use to capture the underlying true value // (obtained by multiplying by sigmax and adding mux - for more on the rationale for this parameterization look "non-centralized parameterization") real mux; // True population mean of the covariate values real<lower=0> sigmax; // True population SD of the covariate values } transformed parameters { real x_imputed[N_obs]; // Imputed values for x (or rather log(x)) for (r in 1:N_obs){ x_imputed[r] = mux + x_randomeff[r] * sigmax; } } model { // Specifying some wide weakly informative priors mu ~ normal(0, 100); sigma ~ normal(0, 100); beta ~ normal(0, 100); mux ~ normal(0, 10); sigmax ~ normal(0, 10); x_randomeff ~ normal(0,1); for (r in 1:N_obs){ // Dealing with the covariate model if (x_censored[r]==1){ target += normal_lcdf(x[r] | x_imputed[r], measurement_error[r]); } else if (x_censored[r]==2){ target += normal_lccdf(x[r] | x_imputed[r], measurement_error[r]); } else { x[r] ~ normal(x_imputed[r], measurement_error[r]); } // fitting the regression model for y y[r] ~ normal(mu + x_imputed[r]*beta, sigma); } } " sfit = stan(model_code = stancode, data=list(N_obs=12, y=c(44, 40, 37, 33, 31, 27, 24, 19, 16, 13, 9, 6), x=log( c(15, 7, 5, 3, 0.9, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5) ), x_censored = c(rep(0,5), rep(1, 7)), measurement_error=rep(0.1, 12)), control=list(adapt_delta=0.95)) summary(sfit)$summary As you can see the model even outputs what it imputed for the missing values. There's probably other ways of doing this, but this seemed reasonably intuitive to me. At the moment, I am using $log(x)\times \beta$ in the regression equation, but you could change that by exponentiating x_imputed[r]. Update: this paper just popped up in my Twitter feed.
How best to deal with a left-censored predictor (because of detection limits) in a linear model? Multiple imputation plays reasonably nicely with Bayesian inference. You just fit the Bayesian model on each imputation (making sure there's not too few, e.g. do at least 100 imputations or so) and th
16,744
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
Here's a somewhat related question: How small a quantity should be added to x to avoid taking the log of zero? This looks like a very relevant paper that uses Bayesian regression with LOD censored predictors: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6241297/ One simple and maybe less than ideal option is to add an indicator variable for whether an observation is below the LOD or not.
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
Here's a somewhat related question: How small a quantity should be added to x to avoid taking the log of zero? This looks like a very relevant paper that uses Bayesian regression with LOD censored pre
How best to deal with a left-censored predictor (because of detection limits) in a linear model? Here's a somewhat related question: How small a quantity should be added to x to avoid taking the log of zero? This looks like a very relevant paper that uses Bayesian regression with LOD censored predictors: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6241297/ One simple and maybe less than ideal option is to add an indicator variable for whether an observation is below the LOD or not.
How best to deal with a left-censored predictor (because of detection limits) in a linear model? Here's a somewhat related question: How small a quantity should be added to x to avoid taking the log of zero? This looks like a very relevant paper that uses Bayesian regression with LOD censored pre
16,745
How to Compute the Brier Score for more than Two Classes
Wikipedia's version of the Brier score for multiple categories is correct. Compare the original publication by Brier (1950), or any number of academic publications, e.g. Czado et al. (2009) (equation (6), though you would need to do some simple arithmetic and drop a constant 1 to arrive at Brier's formulation). If sklearn calculates a binary "one against all" Brier score and averages over all choices of a focal class, then it can certainly do so. However, it is simply not the Brier score. Passing it off as such is misleading and wrong. The misconception lies entirely with sklearn. Just use your brier_multi, it's completely correct.
How to Compute the Brier Score for more than Two Classes
Wikipedia's version of the Brier score for multiple categories is correct. Compare the original publication by Brier (1950), or any number of academic publications, e.g. Czado et al. (2009) (equation
How to Compute the Brier Score for more than Two Classes Wikipedia's version of the Brier score for multiple categories is correct. Compare the original publication by Brier (1950), or any number of academic publications, e.g. Czado et al. (2009) (equation (6), though you would need to do some simple arithmetic and drop a constant 1 to arrive at Brier's formulation). If sklearn calculates a binary "one against all" Brier score and averages over all choices of a focal class, then it can certainly do so. However, it is simply not the Brier score. Passing it off as such is misleading and wrong. The misconception lies entirely with sklearn. Just use your brier_multi, it's completely correct.
How to Compute the Brier Score for more than Two Classes Wikipedia's version of the Brier score for multiple categories is correct. Compare the original publication by Brier (1950), or any number of academic publications, e.g. Czado et al. (2009) (equation
16,746
Are there mathematical reasons for convolution in neural networks beyond expediency?
There are no differences in what neural networks can do when they use convolution or correlation. This is because the filters are learned and if a CNN can learn to do a particular task using convolution operation, it can also learn to do the same task using correlation operation (It would learn the rotated version of each filter). To find more details about the reasons that people sometimes find it more intuitive to think about convolution than correlation, this post may be useful. There remains this question that if there is no difference between convolution and cross-correlation, what is the point of flipping the weights into the kernel matrix? I would like to include some sentences from the Deep learning book by Ian Goodfellow et al. to answer this question: The only reason to flip the kernel is to obtain the commutative property. While the commutative property is useful for writing proofs, it is not usually an important property of a neural network implementation... Many machine learning libraries implement cross-correlation but call it convolution. The takeaway is that although convolution is a favorite operation in classic machine vision applications, it is replaced by correlation in many of the implementations of the convolutional neural networks.
Are there mathematical reasons for convolution in neural networks beyond expediency?
There are no differences in what neural networks can do when they use convolution or correlation. This is because the filters are learned and if a CNN can learn to do a particular task using convoluti
Are there mathematical reasons for convolution in neural networks beyond expediency? There are no differences in what neural networks can do when they use convolution or correlation. This is because the filters are learned and if a CNN can learn to do a particular task using convolution operation, it can also learn to do the same task using correlation operation (It would learn the rotated version of each filter). To find more details about the reasons that people sometimes find it more intuitive to think about convolution than correlation, this post may be useful. There remains this question that if there is no difference between convolution and cross-correlation, what is the point of flipping the weights into the kernel matrix? I would like to include some sentences from the Deep learning book by Ian Goodfellow et al. to answer this question: The only reason to flip the kernel is to obtain the commutative property. While the commutative property is useful for writing proofs, it is not usually an important property of a neural network implementation... Many machine learning libraries implement cross-correlation but call it convolution. The takeaway is that although convolution is a favorite operation in classic machine vision applications, it is replaced by correlation in many of the implementations of the convolutional neural networks.
Are there mathematical reasons for convolution in neural networks beyond expediency? There are no differences in what neural networks can do when they use convolution or correlation. This is because the filters are learned and if a CNN can learn to do a particular task using convoluti
16,747
Are there mathematical reasons for convolution in neural networks beyond expediency?
There's a practical reason for the link between FFTs and convolution. Convolution is slow in the time/image domain. Applying an $n \times n$ filter to one pixel requires $O(n^2)$ multiplications and additions. Applying it to every pixel in an $N \times N$ image thus requires $n^2N^2$ operations. This grows quickly, and the large number of operations not only requires extra time, but also introduces more numerical error. The Convolution Theorem says that convolution in the time domain is equivalent to pointwise multiplication in the frequency domain. FFTs are fast: they have good asymptotic performance $O(N^2 \log N^2)$ and the actual implementations are often highly optimized. Switching to the Fourier domain thus lets you perform a convolution in $O(N^2)$ time (which is dominated by the pointwise multiplication), instead of $O(n^2N^2)$. This can provide a considerable speedup, even though it seems much more complicated to go down the FFT -> multiplication -> inverse FFT route. More here
Are there mathematical reasons for convolution in neural networks beyond expediency?
There's a practical reason for the link between FFTs and convolution. Convolution is slow in the time/image domain. Applying an $n \times n$ filter to one pixel requires $O(n^2)$ multiplications and a
Are there mathematical reasons for convolution in neural networks beyond expediency? There's a practical reason for the link between FFTs and convolution. Convolution is slow in the time/image domain. Applying an $n \times n$ filter to one pixel requires $O(n^2)$ multiplications and additions. Applying it to every pixel in an $N \times N$ image thus requires $n^2N^2$ operations. This grows quickly, and the large number of operations not only requires extra time, but also introduces more numerical error. The Convolution Theorem says that convolution in the time domain is equivalent to pointwise multiplication in the frequency domain. FFTs are fast: they have good asymptotic performance $O(N^2 \log N^2)$ and the actual implementations are often highly optimized. Switching to the Fourier domain thus lets you perform a convolution in $O(N^2)$ time (which is dominated by the pointwise multiplication), instead of $O(n^2N^2)$. This can provide a considerable speedup, even though it seems much more complicated to go down the FFT -> multiplication -> inverse FFT route. More here
Are there mathematical reasons for convolution in neural networks beyond expediency? There's a practical reason for the link between FFTs and convolution. Convolution is slow in the time/image domain. Applying an $n \times n$ filter to one pixel requires $O(n^2)$ multiplications and a
16,748
Maximum gap between samples drawn without replacement from a discrete uniform distribution
Let $f(g;n,m)$ be the chance that the minimum, $a_{(1)}$, equals $g$; that is, the sample consists of $g$ and an $n-1$-subset of $\{g+1,g+2,\ldots,m\}$. There are $\binom{m-g}{n-1}$ such subsets out of the $\binom{m}{n}$ equally likely subsets, whence $$\Pr(a_{(1)}=g = f(g;n,m) = \frac{\binom{m-g}{n-1}}{\binom{m}{n}}.$$ Adding $f(k;n,m)$ for all possible values of $k$ greater than $g$ yields the survival function $$\Pr(a_{(1)} \gt g) = Q(g;n,m)= \frac{(m-g)\binom{m-g-1}{n-1}}{n \binom{m}{n}}.$$ Let $G_{n,m}$ be the random variable given by the largest gap: $$G_{n,m} = \max\left(a_{(1)}, a_{(2)}-a_{(1)}, \ldots, a_{(n)}-a_{(n-1)}\right).$$ (This responds to the question as originally framed, before it was modified to include a gap between $a_{(n)}$ and $m$.) We will compute its survival function $$P(g;n,m)=\Pr(G_{n,m}\gt g),$$ from which the entire distribution of $G_{n,m}$ is readily derived. The method is a dynamic program beginning with $n=1$, for which it is obvious that $$P(g;1,m) = \Pr(G_{1,m} \gt 1) = \frac{m-g}{m},\ g=0, 1, \ldots, m.\tag{1}$$ For larger $n\gt 1$, note that the event $G_{n,m}\gt g$ is the disjoint union of the event $$a_{1} \gt g,$$ for which the very first gap exceeds $g$, and the $g$ separate events $$a_{1}=k\text{ and } G_{n-1,m-k} \gt g, \ k=1, 2, \ldots, g$$ for which the first gap equals $k$ and a gap greater than $g$ occurs later in the sample. The Law of Total Probability asserts the probabilities of these events add, whence $$P(g;n,m) = Q(g;n,m) + \sum_{k=1}^g f(k;n,m) P(g;n-1,m-k).\tag{2}$$ Fixing $g$ and laying out a two-way array indexed by $i=1,2,\ldots,n$ and $j=1,2,\ldots,m$, we may compute $P(g;n,m)$ by using $(1)$ to fill in its first row and $(2)$ to fill in each successive row using $O(gm)$ operations per row. Consequently the table can be completed in $O(gmn)$ operations and all tables for $g=1$ through $g=m-n+1$ can be constructed in $O(m^3n)$ operations. These graphs show the survival function $g\to P(g;n,64)$ for $n=1,2,4,8,16,32,64$. As $n$ increases, the graph moves to the left, corresponding to the decreasing chances of large gaps. Closed formulas for $P(g;n,m)$ can be obtained in many special cases, especially for large $n$, but I have not been able to obtain a closed formula that applies to all $g,n,m$. Good approximations are readily available by replacing this problem with the analogous problem for continuous uniform variables. Finally, the expectation of $G_{n,m}$ is obtained by summing its survival function starting at $g=0$: $$\mathbb{E}(G_{n,m}) = \sum_{g=0}^{m-n+1} P(g;n,m).$$ This contour plot of the expectation shows contours at $2, 4, 6, \ldots, 32$, graduating from dark to light.
Maximum gap between samples drawn without replacement from a discrete uniform distribution
Let $f(g;n,m)$ be the chance that the minimum, $a_{(1)}$, equals $g$; that is, the sample consists of $g$ and an $n-1$-subset of $\{g+1,g+2,\ldots,m\}$. There are $\binom{m-g}{n-1}$ such subsets out
Maximum gap between samples drawn without replacement from a discrete uniform distribution Let $f(g;n,m)$ be the chance that the minimum, $a_{(1)}$, equals $g$; that is, the sample consists of $g$ and an $n-1$-subset of $\{g+1,g+2,\ldots,m\}$. There are $\binom{m-g}{n-1}$ such subsets out of the $\binom{m}{n}$ equally likely subsets, whence $$\Pr(a_{(1)}=g = f(g;n,m) = \frac{\binom{m-g}{n-1}}{\binom{m}{n}}.$$ Adding $f(k;n,m)$ for all possible values of $k$ greater than $g$ yields the survival function $$\Pr(a_{(1)} \gt g) = Q(g;n,m)= \frac{(m-g)\binom{m-g-1}{n-1}}{n \binom{m}{n}}.$$ Let $G_{n,m}$ be the random variable given by the largest gap: $$G_{n,m} = \max\left(a_{(1)}, a_{(2)}-a_{(1)}, \ldots, a_{(n)}-a_{(n-1)}\right).$$ (This responds to the question as originally framed, before it was modified to include a gap between $a_{(n)}$ and $m$.) We will compute its survival function $$P(g;n,m)=\Pr(G_{n,m}\gt g),$$ from which the entire distribution of $G_{n,m}$ is readily derived. The method is a dynamic program beginning with $n=1$, for which it is obvious that $$P(g;1,m) = \Pr(G_{1,m} \gt 1) = \frac{m-g}{m},\ g=0, 1, \ldots, m.\tag{1}$$ For larger $n\gt 1$, note that the event $G_{n,m}\gt g$ is the disjoint union of the event $$a_{1} \gt g,$$ for which the very first gap exceeds $g$, and the $g$ separate events $$a_{1}=k\text{ and } G_{n-1,m-k} \gt g, \ k=1, 2, \ldots, g$$ for which the first gap equals $k$ and a gap greater than $g$ occurs later in the sample. The Law of Total Probability asserts the probabilities of these events add, whence $$P(g;n,m) = Q(g;n,m) + \sum_{k=1}^g f(k;n,m) P(g;n-1,m-k).\tag{2}$$ Fixing $g$ and laying out a two-way array indexed by $i=1,2,\ldots,n$ and $j=1,2,\ldots,m$, we may compute $P(g;n,m)$ by using $(1)$ to fill in its first row and $(2)$ to fill in each successive row using $O(gm)$ operations per row. Consequently the table can be completed in $O(gmn)$ operations and all tables for $g=1$ through $g=m-n+1$ can be constructed in $O(m^3n)$ operations. These graphs show the survival function $g\to P(g;n,64)$ for $n=1,2,4,8,16,32,64$. As $n$ increases, the graph moves to the left, corresponding to the decreasing chances of large gaps. Closed formulas for $P(g;n,m)$ can be obtained in many special cases, especially for large $n$, but I have not been able to obtain a closed formula that applies to all $g,n,m$. Good approximations are readily available by replacing this problem with the analogous problem for continuous uniform variables. Finally, the expectation of $G_{n,m}$ is obtained by summing its survival function starting at $g=0$: $$\mathbb{E}(G_{n,m}) = \sum_{g=0}^{m-n+1} P(g;n,m).$$ This contour plot of the expectation shows contours at $2, 4, 6, \ldots, 32$, graduating from dark to light.
Maximum gap between samples drawn without replacement from a discrete uniform distribution Let $f(g;n,m)$ be the chance that the minimum, $a_{(1)}$, equals $g$; that is, the sample consists of $g$ and an $n-1$-subset of $\{g+1,g+2,\ldots,m\}$. There are $\binom{m-g}{n-1}$ such subsets out
16,749
Maximum gap between samples drawn without replacement from a discrete uniform distribution
Using the notation in the question, this answer provides a closed-form solution for the number of $(n+1)$-compositions of $m+1$ constrained by $\max(g)\leq k$: $$\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\binom{m-jk}{n}$$ and $\big\lceil{\frac{m+1}{n+1}}\big\rceil\leq{k}\leq{m-n+1}$ The CDF of $k$ is then $$\frac{\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\binom{m-jk}{n}}{\binom{m}{n}}$$ The PDF implemented as an R function: dmaxgap <- function(m, n) { w <- ceiling((m + 1)/(n + 1)):(m - n + 1L) j <- 0:(n + 1L) setNames(diff(c(0L, colSums(rep(c(1, -1), length.out = n + 2L)*choose(n + 1L, j)*choose(pmax(m - outer(j, w), 0L), n))))/choose(m, n), w) } Compare the results to $10^6$ simulation replications: library(Rfast) m <- 1e3L n <- 6L kprobs <- dmaxgap(m, n) k <- colMaxs(diff(colSort(rbind(0L, replicate(1e6, sample(m, n)), m + 1L))), TRUE) plot(x <- sort(unique(k)), ecdf(k)(x), type = "l", col = "blue", xlab = "w", ylab = "CDF") lines(as.integer(names(kprobs)), cumsum(kprobs), col = "orange") The two lines are nearly indistinguishable.
Maximum gap between samples drawn without replacement from a discrete uniform distribution
Using the notation in the question, this answer provides a closed-form solution for the number of $(n+1)$-compositions of $m+1$ constrained by $\max(g)\leq k$: $$\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\b
Maximum gap between samples drawn without replacement from a discrete uniform distribution Using the notation in the question, this answer provides a closed-form solution for the number of $(n+1)$-compositions of $m+1$ constrained by $\max(g)\leq k$: $$\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\binom{m-jk}{n}$$ and $\big\lceil{\frac{m+1}{n+1}}\big\rceil\leq{k}\leq{m-n+1}$ The CDF of $k$ is then $$\frac{\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\binom{m-jk}{n}}{\binom{m}{n}}$$ The PDF implemented as an R function: dmaxgap <- function(m, n) { w <- ceiling((m + 1)/(n + 1)):(m - n + 1L) j <- 0:(n + 1L) setNames(diff(c(0L, colSums(rep(c(1, -1), length.out = n + 2L)*choose(n + 1L, j)*choose(pmax(m - outer(j, w), 0L), n))))/choose(m, n), w) } Compare the results to $10^6$ simulation replications: library(Rfast) m <- 1e3L n <- 6L kprobs <- dmaxgap(m, n) k <- colMaxs(diff(colSort(rbind(0L, replicate(1e6, sample(m, n)), m + 1L))), TRUE) plot(x <- sort(unique(k)), ecdf(k)(x), type = "l", col = "blue", xlab = "w", ylab = "CDF") lines(as.integer(names(kprobs)), cumsum(kprobs), col = "orange") The two lines are nearly indistinguishable.
Maximum gap between samples drawn without replacement from a discrete uniform distribution Using the notation in the question, this answer provides a closed-form solution for the number of $(n+1)$-compositions of $m+1$ constrained by $\max(g)\leq k$: $$\sum_{j=0}^{n+1}(-1)^j\binom{n+1}{j}\b
16,750
Has anyone besides Egon Pearson accessed Gosset's 1904 paper?
Stephen Ziliak, an Economics professor at Roosevelt University in Chicago, has published a number of papers (and a book) on Gosset and related topics. See, for example, this paper, which quotes the 1904 report you mention. In the references section, he cites 15 volumes of Laboratory Reports, which include Gosset's 1904 paper. The Guinness web site says the archives are open to researchers by appointment; I wasn't able to find a digital copy of that particular paper.
Has anyone besides Egon Pearson accessed Gosset's 1904 paper?
Stephen Ziliak, an Economics professor at Roosevelt University in Chicago, has published a number of papers (and a book) on Gosset and related topics. See, for example, this paper, which quotes the 19
Has anyone besides Egon Pearson accessed Gosset's 1904 paper? Stephen Ziliak, an Economics professor at Roosevelt University in Chicago, has published a number of papers (and a book) on Gosset and related topics. See, for example, this paper, which quotes the 1904 report you mention. In the references section, he cites 15 volumes of Laboratory Reports, which include Gosset's 1904 paper. The Guinness web site says the archives are open to researchers by appointment; I wasn't able to find a digital copy of that particular paper.
Has anyone besides Egon Pearson accessed Gosset's 1904 paper? Stephen Ziliak, an Economics professor at Roosevelt University in Chicago, has published a number of papers (and a book) on Gosset and related topics. See, for example, this paper, which quotes the 19
16,751
Has anyone besides Egon Pearson accessed Gosset's 1904 paper?
I just emailed them through their contact form https://www.guinness-storehouse.com/en/archives/archives-contact and I received a PDF copy. It's a very interesting read.
Has anyone besides Egon Pearson accessed Gosset's 1904 paper?
I just emailed them through their contact form https://www.guinness-storehouse.com/en/archives/archives-contact and I received a PDF copy. It's a very interesting read.
Has anyone besides Egon Pearson accessed Gosset's 1904 paper? I just emailed them through their contact form https://www.guinness-storehouse.com/en/archives/archives-contact and I received a PDF copy. It's a very interesting read.
Has anyone besides Egon Pearson accessed Gosset's 1904 paper? I just emailed them through their contact form https://www.guinness-storehouse.com/en/archives/archives-contact and I received a PDF copy. It's a very interesting read.
16,752
Checking whether accuracy improvement is significant
In short, yes. Statistical significance is relevant here. You are looking at the classification error (or, as you give it here accuracy = 1- classification error). If you compare the classificators on different 1000 samples you can simply use the binomial test, if it is the same 1000 samples you need to use McNemar's test. Note that simply testing the classification error in this way is suboptimal because you either assume the classification error is independent of the true class or that the proportion of the true classes is the same across your potential applications. This means you should take a look at measures like true positive rate, false positive rate or AUC. What measure to use and how to test it, depends on the output of your classicator. It might just be a class or it might be a continous number giving the probability of belonging to a certain class.
Checking whether accuracy improvement is significant
In short, yes. Statistical significance is relevant here. You are looking at the classification error (or, as you give it here accuracy = 1- classification error). If you compare the classificators on
Checking whether accuracy improvement is significant In short, yes. Statistical significance is relevant here. You are looking at the classification error (or, as you give it here accuracy = 1- classification error). If you compare the classificators on different 1000 samples you can simply use the binomial test, if it is the same 1000 samples you need to use McNemar's test. Note that simply testing the classification error in this way is suboptimal because you either assume the classification error is independent of the true class or that the proportion of the true classes is the same across your potential applications. This means you should take a look at measures like true positive rate, false positive rate or AUC. What measure to use and how to test it, depends on the output of your classicator. It might just be a class or it might be a continous number giving the probability of belonging to a certain class.
Checking whether accuracy improvement is significant In short, yes. Statistical significance is relevant here. You are looking at the classification error (or, as you give it here accuracy = 1- classification error). If you compare the classificators on
16,753
Checking whether accuracy improvement is significant
As Erik said, yes you can check this for statistical significance. However, think for a moment exactly what it is you want to check. I think a more interesting question might be to ask how likely it is that the allegedly "improved" algorithm is better (or meaningfully better) than the original, given the data of an observed 1% difference. Asking questions in terms of "statistical significance" tends to lead to the opposite type of question: Given that the two algorithms are the same, is there less than a 5% chance observing an improvement of at least this much? To me, the latter question is backwards, but it has somehow become the standard. You can check out Wikipedia on the controversy in statistical hypothesis testing. You might subsequently be interested in Bayesian inference. If you really want to get into Bayesian data analysis, you can check out Gelman et al's "Bayesian Data Analysis" or check out this question.
Checking whether accuracy improvement is significant
As Erik said, yes you can check this for statistical significance. However, think for a moment exactly what it is you want to check. I think a more interesting question might be to ask how likely it
Checking whether accuracy improvement is significant As Erik said, yes you can check this for statistical significance. However, think for a moment exactly what it is you want to check. I think a more interesting question might be to ask how likely it is that the allegedly "improved" algorithm is better (or meaningfully better) than the original, given the data of an observed 1% difference. Asking questions in terms of "statistical significance" tends to lead to the opposite type of question: Given that the two algorithms are the same, is there less than a 5% chance observing an improvement of at least this much? To me, the latter question is backwards, but it has somehow become the standard. You can check out Wikipedia on the controversy in statistical hypothesis testing. You might subsequently be interested in Bayesian inference. If you really want to get into Bayesian data analysis, you can check out Gelman et al's "Bayesian Data Analysis" or check out this question.
Checking whether accuracy improvement is significant As Erik said, yes you can check this for statistical significance. However, think for a moment exactly what it is you want to check. I think a more interesting question might be to ask how likely it
16,754
Checking whether accuracy improvement is significant
Applying Erik's answer to Michael's: You can do the same kind of thinking Erik refers to when choosing the performance measure. I find it helpful to refer to different such measures by the questions they answer (here in the medical diagnostics language which I'm most familiar with - but maybe you can just replace patient by text and disease by spam ;-) ): Sensitivity: given the patient truly has the disease, how likely is the classifier to realize that? Specificity: given the patient truly does not have the disease, how likely is the classifier to realize that? Positive predictive value: given the classifier claims the patient to be diseased, how likely does the patient really have the disease? Negative predictive value: given the classifier claims the patient not to be diseased, how likely does the patient really doesn't have the disease? As you see, the predicitive values are what doctors and patients are really interested in. However, almost everyone characterizes his classifier by sensitivity and specificity. The reason is that the predictive values need to take the prevalence of the disease into account, and that can vary hugely (orders of magnitude!) for different kinds of patients. More on topic for your question: I bet you are right in worrying. Taking both of Erik's scenarios into an example: Here are the independent test samples: > binom.test (x = 810, n = 1000, p = 0.8) Exact binomial test data: 810 and 1000 number of successes = 810, number of trials = 1000, p-value = 0.4526 alternative hypothesis: true probability of success is not equal to 0.8 95 percent confidence interval: 0.7842863 0.8338735 sample estimates: probability of success 0.81 (note that this test was two-sided, assuming the two classifiers would have been published even if the results had been the other way round...) Here's the best possible situation: paired test, and the new classifier is right for all samples the old one is right, too plus 10 more: > ## mc.nemar: best possible case > oldclassif <- c (rep ("correct", 800), rep ("wrong", 200)) > newclassif <- c (rep ("correct", 810), rep ("wrong", 190)) > table (oldclassif, newclassif) newclassif oldclassif correct wrong correct 800 0 wrong 10 190 > mcnemar.test (oldclassif, newclassif) McNemar's Chi-squared test with continuity correction data: oldclassif and newclassif McNemar's chi-squared = 8.1, df = 1, p-value = 0.004427 (the p-value stays below the magical 0.05 as long as not more than 10 samples out of the 1000 were predicted differently by the two classifiers). Even if p-values are the right answer to the wrong question, there's indication that it's kind of a tight place. However, taking into account the usual scientific practice i.e. an unknown (unpublished) number of new features was tested, and only the one that worked slightly better was published, the place gets even more tight. And then, the 80 % classifier may just be the successor of some 79 % classifer... If you enjoy reading German, there are some really nice books by Beck-Bornhold and Dubben. If I remember correctly, Mit an Wahrscheinlichkeit grenzender Sicherheit has a very nice discussion of these problems. (I don't know whether there is an English edition, a rather literal translation of the title is "With a certainty bordering on probability")
Checking whether accuracy improvement is significant
Applying Erik's answer to Michael's: You can do the same kind of thinking Erik refers to when choosing the performance measure. I find it helpful to refer to different such measures by the question
Checking whether accuracy improvement is significant Applying Erik's answer to Michael's: You can do the same kind of thinking Erik refers to when choosing the performance measure. I find it helpful to refer to different such measures by the questions they answer (here in the medical diagnostics language which I'm most familiar with - but maybe you can just replace patient by text and disease by spam ;-) ): Sensitivity: given the patient truly has the disease, how likely is the classifier to realize that? Specificity: given the patient truly does not have the disease, how likely is the classifier to realize that? Positive predictive value: given the classifier claims the patient to be diseased, how likely does the patient really have the disease? Negative predictive value: given the classifier claims the patient not to be diseased, how likely does the patient really doesn't have the disease? As you see, the predicitive values are what doctors and patients are really interested in. However, almost everyone characterizes his classifier by sensitivity and specificity. The reason is that the predictive values need to take the prevalence of the disease into account, and that can vary hugely (orders of magnitude!) for different kinds of patients. More on topic for your question: I bet you are right in worrying. Taking both of Erik's scenarios into an example: Here are the independent test samples: > binom.test (x = 810, n = 1000, p = 0.8) Exact binomial test data: 810 and 1000 number of successes = 810, number of trials = 1000, p-value = 0.4526 alternative hypothesis: true probability of success is not equal to 0.8 95 percent confidence interval: 0.7842863 0.8338735 sample estimates: probability of success 0.81 (note that this test was two-sided, assuming the two classifiers would have been published even if the results had been the other way round...) Here's the best possible situation: paired test, and the new classifier is right for all samples the old one is right, too plus 10 more: > ## mc.nemar: best possible case > oldclassif <- c (rep ("correct", 800), rep ("wrong", 200)) > newclassif <- c (rep ("correct", 810), rep ("wrong", 190)) > table (oldclassif, newclassif) newclassif oldclassif correct wrong correct 800 0 wrong 10 190 > mcnemar.test (oldclassif, newclassif) McNemar's Chi-squared test with continuity correction data: oldclassif and newclassif McNemar's chi-squared = 8.1, df = 1, p-value = 0.004427 (the p-value stays below the magical 0.05 as long as not more than 10 samples out of the 1000 were predicted differently by the two classifiers). Even if p-values are the right answer to the wrong question, there's indication that it's kind of a tight place. However, taking into account the usual scientific practice i.e. an unknown (unpublished) number of new features was tested, and only the one that worked slightly better was published, the place gets even more tight. And then, the 80 % classifier may just be the successor of some 79 % classifer... If you enjoy reading German, there are some really nice books by Beck-Bornhold and Dubben. If I remember correctly, Mit an Wahrscheinlichkeit grenzender Sicherheit has a very nice discussion of these problems. (I don't know whether there is an English edition, a rather literal translation of the title is "With a certainty bordering on probability")
Checking whether accuracy improvement is significant Applying Erik's answer to Michael's: You can do the same kind of thinking Erik refers to when choosing the performance measure. I find it helpful to refer to different such measures by the question
16,755
Checking whether accuracy improvement is significant
I would highly discourage the use of any discontinuous improper scoring rule (an accuracy score such as sensitivity, specificity, proportion classified correct that when optimized results in a bogus model) and instead use likelihood ratio tests or partial F tests for added value of the new variables. One of several ways to see the problems with proportion classified correctly is that if the overall proportion in one category is 0.9 you will be correct 0.9 of the time by ignoring the data and classifying every observation as being in that category.
Checking whether accuracy improvement is significant
I would highly discourage the use of any discontinuous improper scoring rule (an accuracy score such as sensitivity, specificity, proportion classified correct that when optimized results in a bogus m
Checking whether accuracy improvement is significant I would highly discourage the use of any discontinuous improper scoring rule (an accuracy score such as sensitivity, specificity, proportion classified correct that when optimized results in a bogus model) and instead use likelihood ratio tests or partial F tests for added value of the new variables. One of several ways to see the problems with proportion classified correctly is that if the overall proportion in one category is 0.9 you will be correct 0.9 of the time by ignoring the data and classifying every observation as being in that category.
Checking whether accuracy improvement is significant I would highly discourage the use of any discontinuous improper scoring rule (an accuracy score such as sensitivity, specificity, proportion classified correct that when optimized results in a bogus m
16,756
How should decision tree splits be implemented when predicting continuous variables?
One potential issue with trees is that they tend to fit poorly in the tails. Think of a terminal node that captures the low range of the training set. It will predict using the mean of those training set points, which will always under-predict the outcome (since it is the mean). You might try model trees [1]. These will fit linear models in the terminal nodes and (I think) do a better job than regression trees. Better yet, use a more evolved version called Cubist that combines different approaches ([1] and [2] below). These models also handle continuous and discrete predictors differently. They can do multi-way splits for categorical variables. The splitting criterion is very similar to CART trees. Model trees can be found in R in the RWeka package (called 'M5P') and Cubist is in the Cubist package. Of course, you can use Weka too and Cubist has a C version available at the RuleQuest website. [1] Quinlan, J. (1992). Learning with continuous classes. Proceedings of the 5th Australian Joint Conference On Artificial Intelligence, 343–348. [2] Quinlan, J. (1993). Combining instance-based and model-based learning. Proceedings of the Tenth International Conference on Machine Learning, 236–243.
How should decision tree splits be implemented when predicting continuous variables?
One potential issue with trees is that they tend to fit poorly in the tails. Think of a terminal node that captures the low range of the training set. It will predict using the mean of those training
How should decision tree splits be implemented when predicting continuous variables? One potential issue with trees is that they tend to fit poorly in the tails. Think of a terminal node that captures the low range of the training set. It will predict using the mean of those training set points, which will always under-predict the outcome (since it is the mean). You might try model trees [1]. These will fit linear models in the terminal nodes and (I think) do a better job than regression trees. Better yet, use a more evolved version called Cubist that combines different approaches ([1] and [2] below). These models also handle continuous and discrete predictors differently. They can do multi-way splits for categorical variables. The splitting criterion is very similar to CART trees. Model trees can be found in R in the RWeka package (called 'M5P') and Cubist is in the Cubist package. Of course, you can use Weka too and Cubist has a C version available at the RuleQuest website. [1] Quinlan, J. (1992). Learning with continuous classes. Proceedings of the 5th Australian Joint Conference On Artificial Intelligence, 343–348. [2] Quinlan, J. (1993). Combining instance-based and model-based learning. Proceedings of the Tenth International Conference on Machine Learning, 236–243.
How should decision tree splits be implemented when predicting continuous variables? One potential issue with trees is that they tend to fit poorly in the tails. Think of a terminal node that captures the low range of the training set. It will predict using the mean of those training
16,757
Usage of HMM in quantitative finance. Examples of HMM that works to detect trend / turning points?
I think a few methods that can be used, but not designed specifically for you, are as follows: Modeling approaches: Topic Models (used to find patters in a set of documents and/or information retrieval) a. Simplest one is LDA b. Dynamic topic models (IMHO, most suited for your case, without much domain knowledge) c. Correlated topic models (IMHO, if 2. is not good, it makes sense to try this) These approaches are not used in finance (I am not aware, as I don't work in specifically in finance), but they have very general applicability. They use the latent variable formulation, which is very similar to that of HMM. They have shown to be state-of-the-art in topic modeling. You can watch a nice presentation by David Blei (great presenter, apart from his awesome!! research) here. The specific references, the slides for the presentation, and more complicated models can be accessed from his website. He is doing some great work which is very general, so it might not be surprising if he has already done something in finance. Another great reference in the same field is his advisor, Michael Jordan's, website. Its hard to find specific references there as he publishes so much! Time series and sequential data models (HMM specifically) Apart from Jordan and Blei, the other prolific research is Zoubin Ghahramani (and his coauthor Beal). You can find here the specific HMM models that you require. A few impressive ones are: The infinite hidden markov models, Time sensitive Dirichlet Process Mixture Models. Software There is a R package called lda and topicmodels for most of the "good" models. Blei and Ghahramani maintain C, Matlab codes on their website as well. Good Luck!
Usage of HMM in quantitative finance. Examples of HMM that works to detect trend / turning points?
I think a few methods that can be used, but not designed specifically for you, are as follows: Modeling approaches: Topic Models (used to find patters in a set of documents and/or information retriev
Usage of HMM in quantitative finance. Examples of HMM that works to detect trend / turning points? I think a few methods that can be used, but not designed specifically for you, are as follows: Modeling approaches: Topic Models (used to find patters in a set of documents and/or information retrieval) a. Simplest one is LDA b. Dynamic topic models (IMHO, most suited for your case, without much domain knowledge) c. Correlated topic models (IMHO, if 2. is not good, it makes sense to try this) These approaches are not used in finance (I am not aware, as I don't work in specifically in finance), but they have very general applicability. They use the latent variable formulation, which is very similar to that of HMM. They have shown to be state-of-the-art in topic modeling. You can watch a nice presentation by David Blei (great presenter, apart from his awesome!! research) here. The specific references, the slides for the presentation, and more complicated models can be accessed from his website. He is doing some great work which is very general, so it might not be surprising if he has already done something in finance. Another great reference in the same field is his advisor, Michael Jordan's, website. Its hard to find specific references there as he publishes so much! Time series and sequential data models (HMM specifically) Apart from Jordan and Blei, the other prolific research is Zoubin Ghahramani (and his coauthor Beal). You can find here the specific HMM models that you require. A few impressive ones are: The infinite hidden markov models, Time sensitive Dirichlet Process Mixture Models. Software There is a R package called lda and topicmodels for most of the "good" models. Blei and Ghahramani maintain C, Matlab codes on their website as well. Good Luck!
Usage of HMM in quantitative finance. Examples of HMM that works to detect trend / turning points? I think a few methods that can be used, but not designed specifically for you, are as follows: Modeling approaches: Topic Models (used to find patters in a set of documents and/or information retriev
16,758
Why do we need both cell state and hidden value in LSTM networks?
Regarding question (2), vanishing/exploding gradients happen in LSTMs too. In vanilla RNNs, the gradient is a term that depends on a factor exponentiated to $T$ ($T$ is the number of steps you perform backpropagation) [1]. This means that values greater than 1 explode and values less than 1 shrink very fast. On the other hand, gradients in LSTMs, do not have a term that is exponentiated to $T$ [2]. Therefore, the gradient still shrinks/explodes, but at a lower rate than vanilla RNNs. [1]: Pascanu, R., Mikolov, T., Bengio, Y., On the difficulty of training Recurrent Neural Networks, Feb. 2013 - https://arxiv.org/pdf/1211.5063.pdf [2]: Bayer, Justin Simon. Learning Sequence Representations. Diss. München, Technische Universität München, Diss., 2015, 2015 - mentioned in https://stats.stackexchange.com/a/263956/191233
Why do we need both cell state and hidden value in LSTM networks?
Regarding question (2), vanishing/exploding gradients happen in LSTMs too. In vanilla RNNs, the gradient is a term that depends on a factor exponentiated to $T$ ($T$ is the number of steps you perform
Why do we need both cell state and hidden value in LSTM networks? Regarding question (2), vanishing/exploding gradients happen in LSTMs too. In vanilla RNNs, the gradient is a term that depends on a factor exponentiated to $T$ ($T$ is the number of steps you perform backpropagation) [1]. This means that values greater than 1 explode and values less than 1 shrink very fast. On the other hand, gradients in LSTMs, do not have a term that is exponentiated to $T$ [2]. Therefore, the gradient still shrinks/explodes, but at a lower rate than vanilla RNNs. [1]: Pascanu, R., Mikolov, T., Bengio, Y., On the difficulty of training Recurrent Neural Networks, Feb. 2013 - https://arxiv.org/pdf/1211.5063.pdf [2]: Bayer, Justin Simon. Learning Sequence Representations. Diss. München, Technische Universität München, Diss., 2015, 2015 - mentioned in https://stats.stackexchange.com/a/263956/191233
Why do we need both cell state and hidden value in LSTM networks? Regarding question (2), vanishing/exploding gradients happen in LSTMs too. In vanilla RNNs, the gradient is a term that depends on a factor exponentiated to $T$ ($T$ is the number of steps you perform
16,759
Why do we need both cell state and hidden value in LSTM networks?
Basic units of LSTM networks are LSTM layers that have multiple LSTM cells. Cells do have internal cell state, often abbreviated as "c", and cells output is what is called a "hidden state", abbreviated as "h". Regular RNNs do have just the hidden state and no cell state. It turns out that RNNs have difficulty of accessing information from a long time ago. For instance, check these two long sentences: Cows, that eat green green ... green grass are OK. Cow, that eat green green ... green grass is OK. It would be very hard for RNN to learn the singular/plural dependency, but LSTM are capable of doing that.
Why do we need both cell state and hidden value in LSTM networks?
Basic units of LSTM networks are LSTM layers that have multiple LSTM cells. Cells do have internal cell state, often abbreviated as "c", and cells output is what is called a "hidden state", abbreviate
Why do we need both cell state and hidden value in LSTM networks? Basic units of LSTM networks are LSTM layers that have multiple LSTM cells. Cells do have internal cell state, often abbreviated as "c", and cells output is what is called a "hidden state", abbreviated as "h". Regular RNNs do have just the hidden state and no cell state. It turns out that RNNs have difficulty of accessing information from a long time ago. For instance, check these two long sentences: Cows, that eat green green ... green grass are OK. Cow, that eat green green ... green grass is OK. It would be very hard for RNN to learn the singular/plural dependency, but LSTM are capable of doing that.
Why do we need both cell state and hidden value in LSTM networks? Basic units of LSTM networks are LSTM layers that have multiple LSTM cells. Cells do have internal cell state, often abbreviated as "c", and cells output is what is called a "hidden state", abbreviate
16,760
Comparison between Newey-West (1987) and Hansen-Hodrick (1980)
Consider a class of long-run variance estimators $$ \hat{J_T}\equiv\hat{\gamma}_0+2\sum_{j=1}^{T-1}k\left(\frac{j}{\ell_T}\right)\hat{\gamma}_j $$ $k$ is a kernel or weighting function, the $\hat\gamma_j$ are sample autocovariances. $k$, among other things must be symmetric and have $k(0)=1$. $\ell_T$ is a bandwidth parameter. Newey & West (Econometrica 1987) propose the Bartlett kernel $$k\left(\frac{j}{\ell_T}\right) = \begin{cases} \bigl(1 - \frac{j}{\ell_T}\bigr) \qquad &\mbox{for} \qquad 0 \leqslant j \leqslant \ell_T-1 \\ 0 &\mbox{for} \qquad j > \ell_T-1 \end{cases} $$ Hansen & Hodrick's (Journal of Political Economy 1980) estimator amounts to taking a truncated kernal, i.e., $k=1$ for $j\leq M$ for some $M$, and $k=0$ otherwise. This estimator is, as discussed by Newey & West, consistent, but not guaranteed to be positive semi-definite (when estimating matrices), while Newey & West's kernel estimator is. Try $M=1$ for an MA(1)-process with a strongly negative coefficient $\theta$. The population quantity is known to be $J = \sigma^2(1 + \theta)^2>0$, but the Hansen-Hodrick estimator may not be: set.seed(2) y <- arima.sim(model = list(ma = -0.95), n = 10) acf.MA1 <- acf(y, type = "covariance", plot = FALSE)$acf acf.MA1[1] + 2 * acf.MA1[2] ## [1] -0.4056092 which is not a convincing estimate for a long-run variance. This would be avoided with the Newey-West estimator: acf.MA1[1] + acf.MA1[2] ## [1] 0.8634806 Using the sandwich package this can also be computed as: library("sandwich") m <- lm(y ~ 1) kernHAC(m, kernel = "Bartlett", bw = 2, prewhite = FALSE, adjust = FALSE, sandwich = FALSE) ## (Intercept) ## (Intercept) 0.8634806 And the Hansen-Hodrick estimate can be obtained as: kernHAC(m, kernel = "Truncated", bw = 1, prewhite = FALSE, adjust = FALSE, sandwich = FALSE) ## (Intercept) ## (Intercept) -0.4056092 See also NeweyWest() and lrvar() from sandwich for convenience interfaces to obtain Newey-West estimators of linear models and long-run variances of time series, respectively. Andrews (Econometrica 1991) provides an analysis under more general conditions. As to your subquestion regarding overlapping data, I would not be aware of a subject-matter reason. I suspect tradition is at the roots of this common practice.
Comparison between Newey-West (1987) and Hansen-Hodrick (1980)
Consider a class of long-run variance estimators $$ \hat{J_T}\equiv\hat{\gamma}_0+2\sum_{j=1}^{T-1}k\left(\frac{j}{\ell_T}\right)\hat{\gamma}_j $$ $k$ is a kernel or weighting function, the $\hat\gamm
Comparison between Newey-West (1987) and Hansen-Hodrick (1980) Consider a class of long-run variance estimators $$ \hat{J_T}\equiv\hat{\gamma}_0+2\sum_{j=1}^{T-1}k\left(\frac{j}{\ell_T}\right)\hat{\gamma}_j $$ $k$ is a kernel or weighting function, the $\hat\gamma_j$ are sample autocovariances. $k$, among other things must be symmetric and have $k(0)=1$. $\ell_T$ is a bandwidth parameter. Newey & West (Econometrica 1987) propose the Bartlett kernel $$k\left(\frac{j}{\ell_T}\right) = \begin{cases} \bigl(1 - \frac{j}{\ell_T}\bigr) \qquad &\mbox{for} \qquad 0 \leqslant j \leqslant \ell_T-1 \\ 0 &\mbox{for} \qquad j > \ell_T-1 \end{cases} $$ Hansen & Hodrick's (Journal of Political Economy 1980) estimator amounts to taking a truncated kernal, i.e., $k=1$ for $j\leq M$ for some $M$, and $k=0$ otherwise. This estimator is, as discussed by Newey & West, consistent, but not guaranteed to be positive semi-definite (when estimating matrices), while Newey & West's kernel estimator is. Try $M=1$ for an MA(1)-process with a strongly negative coefficient $\theta$. The population quantity is known to be $J = \sigma^2(1 + \theta)^2>0$, but the Hansen-Hodrick estimator may not be: set.seed(2) y <- arima.sim(model = list(ma = -0.95), n = 10) acf.MA1 <- acf(y, type = "covariance", plot = FALSE)$acf acf.MA1[1] + 2 * acf.MA1[2] ## [1] -0.4056092 which is not a convincing estimate for a long-run variance. This would be avoided with the Newey-West estimator: acf.MA1[1] + acf.MA1[2] ## [1] 0.8634806 Using the sandwich package this can also be computed as: library("sandwich") m <- lm(y ~ 1) kernHAC(m, kernel = "Bartlett", bw = 2, prewhite = FALSE, adjust = FALSE, sandwich = FALSE) ## (Intercept) ## (Intercept) 0.8634806 And the Hansen-Hodrick estimate can be obtained as: kernHAC(m, kernel = "Truncated", bw = 1, prewhite = FALSE, adjust = FALSE, sandwich = FALSE) ## (Intercept) ## (Intercept) -0.4056092 See also NeweyWest() and lrvar() from sandwich for convenience interfaces to obtain Newey-West estimators of linear models and long-run variances of time series, respectively. Andrews (Econometrica 1991) provides an analysis under more general conditions. As to your subquestion regarding overlapping data, I would not be aware of a subject-matter reason. I suspect tradition is at the roots of this common practice.
Comparison between Newey-West (1987) and Hansen-Hodrick (1980) Consider a class of long-run variance estimators $$ \hat{J_T}\equiv\hat{\gamma}_0+2\sum_{j=1}^{T-1}k\left(\frac{j}{\ell_T}\right)\hat{\gamma}_j $$ $k$ is a kernel or weighting function, the $\hat\gamm
16,761
When can I stop looking for a better model?
You might be interested in a formal science domain called "computational mechanics." In an article by James Crutchfield and David Feldman, they lay out the program of computational mechanics—as far as I understand it—as parsing out the boundaries between (1) deterministic uncertainty and the information cost of inferring deterministic relationships, (2) stochastic uncertainty and the information cost of inferring probability distributions, and (3) entropic uncertainty and the consequences of being information poor. To answer your question directly (albeit also quite broadly, since you asked a broad question), how we know when we have learned either "enough," or "all we can" from data is an open domain of research. The former will necessarily be contingent upon one's needs as a researcher and actor in the world (e.g., given how much time? how much processing power? how much memory, how much urgency, etc.). I'm not up on this field, or even deep with this particular article, but they're some cool thinkers. :) Crutchfield, J. P. and Feldman, D. P. (2003). Regularities unseen, randomness observed: Levels of entropy convergence. Chaos, 13(1):25–54.
When can I stop looking for a better model?
You might be interested in a formal science domain called "computational mechanics." In an article by James Crutchfield and David Feldman, they lay out the program of computational mechanics—as far as
When can I stop looking for a better model? You might be interested in a formal science domain called "computational mechanics." In an article by James Crutchfield and David Feldman, they lay out the program of computational mechanics—as far as I understand it—as parsing out the boundaries between (1) deterministic uncertainty and the information cost of inferring deterministic relationships, (2) stochastic uncertainty and the information cost of inferring probability distributions, and (3) entropic uncertainty and the consequences of being information poor. To answer your question directly (albeit also quite broadly, since you asked a broad question), how we know when we have learned either "enough," or "all we can" from data is an open domain of research. The former will necessarily be contingent upon one's needs as a researcher and actor in the world (e.g., given how much time? how much processing power? how much memory, how much urgency, etc.). I'm not up on this field, or even deep with this particular article, but they're some cool thinkers. :) Crutchfield, J. P. and Feldman, D. P. (2003). Regularities unseen, randomness observed: Levels of entropy convergence. Chaos, 13(1):25–54.
When can I stop looking for a better model? You might be interested in a formal science domain called "computational mechanics." In an article by James Crutchfield and David Feldman, they lay out the program of computational mechanics—as far as
16,762
How to model longitudinal big data?
If you only have a few variables, like in the example, then you should have no problem with some variant of lme4. Where machine learning techniques really shine is when you've got a lot of variables and you wish to model nonlinearities and interactions between your variables. Few ML approaches have been developed that can do this with longitudinal data. RNNs are one option, though these are generally optimized for time series problems, rather than panel data. In principle, a feed-forward neural network is a (generalized) linear model, with regressors that are nonlinear functions of the input data. If the derived regressors -- the top layer of the model before the output -- are considered the nonparametric part, then there is nothing stopping you from adding parametric structure along with it -- perhaps in the form of random effects. This hasn't been implemented however for classification problems, which I assume that you're doing because you're interested in SVM as a candidate.
How to model longitudinal big data?
If you only have a few variables, like in the example, then you should have no problem with some variant of lme4. Where machine learning techniques really shine is when you've got a lot of variables a
How to model longitudinal big data? If you only have a few variables, like in the example, then you should have no problem with some variant of lme4. Where machine learning techniques really shine is when you've got a lot of variables and you wish to model nonlinearities and interactions between your variables. Few ML approaches have been developed that can do this with longitudinal data. RNNs are one option, though these are generally optimized for time series problems, rather than panel data. In principle, a feed-forward neural network is a (generalized) linear model, with regressors that are nonlinear functions of the input data. If the derived regressors -- the top layer of the model before the output -- are considered the nonparametric part, then there is nothing stopping you from adding parametric structure along with it -- perhaps in the form of random effects. This hasn't been implemented however for classification problems, which I assume that you're doing because you're interested in SVM as a candidate.
How to model longitudinal big data? If you only have a few variables, like in the example, then you should have no problem with some variant of lme4. Where machine learning techniques really shine is when you've got a lot of variables a
16,763
How to model longitudinal big data?
Repeating from machine learning techniques for longitudinal data: the cross-validation sklearn documentation has cross-validation iterators for grouped data! See GroupKFold, LeaveOneGroupOut, and LeavePGroupsOut. If you're interested in pure prediction, the best option is probably to use Recurrent Neural Networks. Another option is Hidden Markov Models.
How to model longitudinal big data?
Repeating from machine learning techniques for longitudinal data: the cross-validation sklearn documentation has cross-validation iterators for grouped data! See GroupKFold, LeaveOneGroupOut, and Lea
How to model longitudinal big data? Repeating from machine learning techniques for longitudinal data: the cross-validation sklearn documentation has cross-validation iterators for grouped data! See GroupKFold, LeaveOneGroupOut, and LeavePGroupsOut. If you're interested in pure prediction, the best option is probably to use Recurrent Neural Networks. Another option is Hidden Markov Models.
How to model longitudinal big data? Repeating from machine learning techniques for longitudinal data: the cross-validation sklearn documentation has cross-validation iterators for grouped data! See GroupKFold, LeaveOneGroupOut, and Lea
16,764
How to model longitudinal big data?
Do you really need Random Forests, NNs, etc.for your longitudinal data? lme4 is able to handle millions of individuals: https://cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf It can easily deal with linear mixed models, and as you can see from the link, it has also support for nonlinear mixed models (though I wouldn't expect it to be lightning quick also for the nonlinear models).
How to model longitudinal big data?
Do you really need Random Forests, NNs, etc.for your longitudinal data? lme4 is able to handle millions of individuals: https://cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf It can easily
How to model longitudinal big data? Do you really need Random Forests, NNs, etc.for your longitudinal data? lme4 is able to handle millions of individuals: https://cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf It can easily deal with linear mixed models, and as you can see from the link, it has also support for nonlinear mixed models (though I wouldn't expect it to be lightning quick also for the nonlinear models).
How to model longitudinal big data? Do you really need Random Forests, NNs, etc.for your longitudinal data? lme4 is able to handle millions of individuals: https://cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf It can easily
16,765
Quantifying similarity between two data sets
Area between 2 curves may give you the difference. Hence sum(nr-nf) (sum of all differences) will be an approximation of the area between 2 curves. If you want to make it relative, sum(nr-nf)/sum(nf) can be used. These will give you a single value indicating similarity between 2 curves for each graph. Edit: Above method of sum of differences will be useful even if these are separate points or observations and not connected lines or curves, but in that case, mean of differences can also be an indicator and may be better since it would take into account the number of observations.
Quantifying similarity between two data sets
Area between 2 curves may give you the difference. Hence sum(nr-nf) (sum of all differences) will be an approximation of the area between 2 curves. If you want to make it relative, sum(nr-nf)/sum(nf)
Quantifying similarity between two data sets Area between 2 curves may give you the difference. Hence sum(nr-nf) (sum of all differences) will be an approximation of the area between 2 curves. If you want to make it relative, sum(nr-nf)/sum(nf) can be used. These will give you a single value indicating similarity between 2 curves for each graph. Edit: Above method of sum of differences will be useful even if these are separate points or observations and not connected lines or curves, but in that case, mean of differences can also be an indicator and may be better since it would take into account the number of observations.
Quantifying similarity between two data sets Area between 2 curves may give you the difference. Hence sum(nr-nf) (sum of all differences) will be an approximation of the area between 2 curves. If you want to make it relative, sum(nr-nf)/sum(nf)
16,766
Quantifying similarity between two data sets
You need to define more what you mean by 'similarity'. Does magnitude matter? Or only shape? If only shape matters, you'll want to normalize both time series by their max value ( so they are both from 0 to 1). If you are looking for a linear correlation, a simple pearson correlation will work fine - which essentially measures the covariance. There are other techniques, for instance, that could fit a line or polynomial to the time series (essentially smoothing it), and then comparing the smooth polynomials. If you are looking for periodic similarity (i.e. the time series has a certain sinusoidal component or seasonality), consider using a time series decomposition into the trend, and seasons components first. Or using something like FFT to compare the data in the frequency domain. Thats about all I know without more definition of what 'similar' should be. Hope it helps.
Quantifying similarity between two data sets
You need to define more what you mean by 'similarity'. Does magnitude matter? Or only shape? If only shape matters, you'll want to normalize both time series by their max value ( so they are both from
Quantifying similarity between two data sets You need to define more what you mean by 'similarity'. Does magnitude matter? Or only shape? If only shape matters, you'll want to normalize both time series by their max value ( so they are both from 0 to 1). If you are looking for a linear correlation, a simple pearson correlation will work fine - which essentially measures the covariance. There are other techniques, for instance, that could fit a line or polynomial to the time series (essentially smoothing it), and then comparing the smooth polynomials. If you are looking for periodic similarity (i.e. the time series has a certain sinusoidal component or seasonality), consider using a time series decomposition into the trend, and seasons components first. Or using something like FFT to compare the data in the frequency domain. Thats about all I know without more definition of what 'similar' should be. Hope it helps.
Quantifying similarity between two data sets You need to define more what you mean by 'similarity'. Does magnitude matter? Or only shape? If only shape matters, you'll want to normalize both time series by their max value ( so they are both from
16,767
Quantifying similarity between two data sets
You could use (nr-nf) for every measurement point, the smaller the number (absolute value) the more similar the value. Not exactly the most scientific approach, please forgive me, I have no real formal training in this stuff. If you are just looking for a numerical representation of the visual, that ought to do it.
Quantifying similarity between two data sets
You could use (nr-nf) for every measurement point, the smaller the number (absolute value) the more similar the value. Not exactly the most scientific approach, please forgive me, I have no real forma
Quantifying similarity between two data sets You could use (nr-nf) for every measurement point, the smaller the number (absolute value) the more similar the value. Not exactly the most scientific approach, please forgive me, I have no real formal training in this stuff. If you are just looking for a numerical representation of the visual, that ought to do it.
Quantifying similarity between two data sets You could use (nr-nf) for every measurement point, the smaller the number (absolute value) the more similar the value. Not exactly the most scientific approach, please forgive me, I have no real forma
16,768
How to estimate training time prior to training? (Machine Learning & Neural Networks)
This question does not really depend on what type of an algorithm you run, it deals with computational complexity of algorithms and as such, it would be better suited for StackOverflow. The computer science guys live for these questions and they are very good at them... In either case, the complexity of an algorithm is reported using the big-O notation. Usually, if you look at the wikipedia description of the algo, you can find the information if the bound is known. Alternatively, it is usually reported by the authors of the algorithm, when they publish it. For example for SVM, the complexity bound is between $\mathit{O}(dn^2)$ and $\mathit{O}(dn^3)$, where n is the number of your data points and d is the number of your features, or dimensionality of the data. (see libSVM implementation in Python Scikit) The scenario you describe above would occur if an algorithm has $O(n)$ time complexity. (Complexity of algorithms is measured separately for both time and storage). It means that the run-time scales with the number of examples $\textit{n}$. Example (starting with $\textit{n}$ inputs for your algorithm): Algorithm A time complexity $O(n)$: old input size $\textit{n}$ old run time $\textit{t}$ new input size $\textit{3n}$, new run time will be $\textit{3t}$ Algorithm B time complexity $O(n^2)$: old input size $\textit{n}$ old run time $\textit{t}$ new input size $\textit{3n}$, new run time will be $\mathit{9t}$ You can apply the same rule for $\mathit{O}(n^3)$, $\mathit{O}(n\log(n))$, or $\mathit{O}(n!)$. Using these rules, you can make a rough (worst-case) estimation of your run-time. Now, things are a bit more tricky than that, as the $\mathit{O}$ is an upper bound, but not necessarily a tight upper bound (see this StackOverflow thread). That means that the $\mathit{O}$ will tell you the worst case run-time, which, depending on your application might prove useless to you, as it will be too large for any sensible planning and you will notice that your average run-times are in fact much lower. In that case you might want to look whether there is a ${\Theta}$ for your algorithm (see Bachman-Landau notation), which is the asymptotically tight upper bound. For many algorithms, the best, worst and average time complexity is reported. For many others, we have only a very loose upper bound. Many machine learning algorithms involve a costly operation such as matrix inversion, or the SVD at some point, which will effectively determine their complexity. The other issue is that complexity ignores constant factors, so complexity $\mathit{O}(kn)$ is in fact $\mathit{O}(n)$ as long as $\mathit{k}$ doesn't depend on $\mathit{n}$. But obviously, in practice it can make a difference whether $k=2$ or $k=1e6$. EDIT 1: Fixed a mistake in runtime based on comment from @H_R EDIT 2: Re-reading this reply after some years of working with neural networks, it seems quite educational, but unfortunately, utterly useless given the question. Yes, we can quantify the complexity of an algorithm. In the case of a neural networks it is the number of operations required for a forward and backward pass. However, the question asks about the total training time and not how much longer a forward pass will take if we increase the input. The training time depends on how long it takes to approximate the relationship between your inputs and outputs sufficiently, i.e. the number of gradient descent iterations you need to make to achieve a sufficiently small loss. This depends completely on how complex is the function you are trying to approximate and how useful and noisy is the sample data you have. The long and short of it is: a. I don't believe it is possible to tell in advance how long it will take to train a neural network, particularly a deep neural network (though I'm sure there is existing research trying to do this). b. It is not even possible to extrapolate reliably the training duration after some training steps. c. It is usually not possible to use a reduced set of inputs to train the network and extrapolate from this reduced training time to the full dataset as the network will typically fail to perform well when trained with few data. This is why people either manually oversee their training loss when training neural networks (tensorflow-board), or use different heuristics to detect when the loss minimization starts to plateau out (early stopping).
How to estimate training time prior to training? (Machine Learning & Neural Networks)
This question does not really depend on what type of an algorithm you run, it deals with computational complexity of algorithms and as such, it would be better suited for StackOverflow. The computer s
How to estimate training time prior to training? (Machine Learning & Neural Networks) This question does not really depend on what type of an algorithm you run, it deals with computational complexity of algorithms and as such, it would be better suited for StackOverflow. The computer science guys live for these questions and they are very good at them... In either case, the complexity of an algorithm is reported using the big-O notation. Usually, if you look at the wikipedia description of the algo, you can find the information if the bound is known. Alternatively, it is usually reported by the authors of the algorithm, when they publish it. For example for SVM, the complexity bound is between $\mathit{O}(dn^2)$ and $\mathit{O}(dn^3)$, where n is the number of your data points and d is the number of your features, or dimensionality of the data. (see libSVM implementation in Python Scikit) The scenario you describe above would occur if an algorithm has $O(n)$ time complexity. (Complexity of algorithms is measured separately for both time and storage). It means that the run-time scales with the number of examples $\textit{n}$. Example (starting with $\textit{n}$ inputs for your algorithm): Algorithm A time complexity $O(n)$: old input size $\textit{n}$ old run time $\textit{t}$ new input size $\textit{3n}$, new run time will be $\textit{3t}$ Algorithm B time complexity $O(n^2)$: old input size $\textit{n}$ old run time $\textit{t}$ new input size $\textit{3n}$, new run time will be $\mathit{9t}$ You can apply the same rule for $\mathit{O}(n^3)$, $\mathit{O}(n\log(n))$, or $\mathit{O}(n!)$. Using these rules, you can make a rough (worst-case) estimation of your run-time. Now, things are a bit more tricky than that, as the $\mathit{O}$ is an upper bound, but not necessarily a tight upper bound (see this StackOverflow thread). That means that the $\mathit{O}$ will tell you the worst case run-time, which, depending on your application might prove useless to you, as it will be too large for any sensible planning and you will notice that your average run-times are in fact much lower. In that case you might want to look whether there is a ${\Theta}$ for your algorithm (see Bachman-Landau notation), which is the asymptotically tight upper bound. For many algorithms, the best, worst and average time complexity is reported. For many others, we have only a very loose upper bound. Many machine learning algorithms involve a costly operation such as matrix inversion, or the SVD at some point, which will effectively determine their complexity. The other issue is that complexity ignores constant factors, so complexity $\mathit{O}(kn)$ is in fact $\mathit{O}(n)$ as long as $\mathit{k}$ doesn't depend on $\mathit{n}$. But obviously, in practice it can make a difference whether $k=2$ or $k=1e6$. EDIT 1: Fixed a mistake in runtime based on comment from @H_R EDIT 2: Re-reading this reply after some years of working with neural networks, it seems quite educational, but unfortunately, utterly useless given the question. Yes, we can quantify the complexity of an algorithm. In the case of a neural networks it is the number of operations required for a forward and backward pass. However, the question asks about the total training time and not how much longer a forward pass will take if we increase the input. The training time depends on how long it takes to approximate the relationship between your inputs and outputs sufficiently, i.e. the number of gradient descent iterations you need to make to achieve a sufficiently small loss. This depends completely on how complex is the function you are trying to approximate and how useful and noisy is the sample data you have. The long and short of it is: a. I don't believe it is possible to tell in advance how long it will take to train a neural network, particularly a deep neural network (though I'm sure there is existing research trying to do this). b. It is not even possible to extrapolate reliably the training duration after some training steps. c. It is usually not possible to use a reduced set of inputs to train the network and extrapolate from this reduced training time to the full dataset as the network will typically fail to perform well when trained with few data. This is why people either manually oversee their training loss when training neural networks (tensorflow-board), or use different heuristics to detect when the loss minimization starts to plateau out (early stopping).
How to estimate training time prior to training? (Machine Learning & Neural Networks) This question does not really depend on what type of an algorithm you run, it deals with computational complexity of algorithms and as such, it would be better suited for StackOverflow. The computer s
16,769
How to estimate training time prior to training? (Machine Learning & Neural Networks)
It depends on the complexity of the algorithm. If it is a linear algorithm, i.e. $O(n)$, then it is straight forward: If $n$ samples needed $t$ time for training, then $2n$ sample will need $2t$ time. If complexity is higher e.g. square $O(n^2)$ then you need to take the square of the time: for double size of samples you will need four times the time it took for n samples. So find out the complexity of your algorithm (google it), run on a small sample to get an estimate, and finally do your calculation to estimate how much time you need. Depending on the algorithm except size of samples, number of dimensions may also be important.
How to estimate training time prior to training? (Machine Learning & Neural Networks)
It depends on the complexity of the algorithm. If it is a linear algorithm, i.e. $O(n)$, then it is straight forward: If $n$ samples needed $t$ time for training, then $2n$ sample will need $2t$ time.
How to estimate training time prior to training? (Machine Learning & Neural Networks) It depends on the complexity of the algorithm. If it is a linear algorithm, i.e. $O(n)$, then it is straight forward: If $n$ samples needed $t$ time for training, then $2n$ sample will need $2t$ time. If complexity is higher e.g. square $O(n^2)$ then you need to take the square of the time: for double size of samples you will need four times the time it took for n samples. So find out the complexity of your algorithm (google it), run on a small sample to get an estimate, and finally do your calculation to estimate how much time you need. Depending on the algorithm except size of samples, number of dimensions may also be important.
How to estimate training time prior to training? (Machine Learning & Neural Networks) It depends on the complexity of the algorithm. If it is a linear algorithm, i.e. $O(n)$, then it is straight forward: If $n$ samples needed $t$ time for training, then $2n$ sample will need $2t$ time.
16,770
How to estimate training time prior to training? (Machine Learning & Neural Networks)
Some thoughts additional to @iliasfl's point: If I think it's going to take long, I do some test runs, which basically allows me to check like @iliasfl suggests. In addition, I also look at memory, because for my data that often limits the parallelization I can ask for. I use resampling validation for my models, I typically calculate in the order of magnitude $10^3$ surrogate models during this. That leaves me with a calculation that is embarassingly paralles and linear in both runtime and memory at the outermost level. The other way round: this means that a single model needs to have a calculation time that is well in the range of what one can try out. If I'd have no idea how long calculations will take (on a scale covering 2 orders of magnitude), I'd start asking myself whether I know enough about the method to sucessfully apply it. Of course there are exceptions to this, e.g. during my Diplom (= Master's) thesis, the method I was to use was fixed. The other question is: how much do weeks 2 - 8 of calculation time add to the quality of model and performance evaluation? If we are talking about that order of magnitude, I'd really do some preliminary calculations, e.g. of the learning curve. I'd also make doubly sure that all parameters are as they should be before starting the calculation. And I may give a second thought on whether I cannot use a faster method. (Depending on your skills, tasks, and the algorithm you use:) If you find that the calculation is much slower than you expected, you may want to follow the saying that a better algorithm can speed up things by orders of magnitude or even reduce the complexity, while paralelization will only help linearly. Sometimes even just a better implementaion of the same algorithm can yield one or two orders of magnitude. I often start the resampling calculation, and fetch preliminary results after a few iterations are through. That allows me to go on working (e.g. setting up the code that summarizes the results, draws the figures etc.), while the final results are refined. That way, it doesn't bother me that much if the whole resampling takes a week. tweak parameters ahead of time Just make sure then that your validation is independent of the parameter tweaking.
How to estimate training time prior to training? (Machine Learning & Neural Networks)
Some thoughts additional to @iliasfl's point: If I think it's going to take long, I do some test runs, which basically allows me to check like @iliasfl suggests. In addition, I also look at memory, b
How to estimate training time prior to training? (Machine Learning & Neural Networks) Some thoughts additional to @iliasfl's point: If I think it's going to take long, I do some test runs, which basically allows me to check like @iliasfl suggests. In addition, I also look at memory, because for my data that often limits the parallelization I can ask for. I use resampling validation for my models, I typically calculate in the order of magnitude $10^3$ surrogate models during this. That leaves me with a calculation that is embarassingly paralles and linear in both runtime and memory at the outermost level. The other way round: this means that a single model needs to have a calculation time that is well in the range of what one can try out. If I'd have no idea how long calculations will take (on a scale covering 2 orders of magnitude), I'd start asking myself whether I know enough about the method to sucessfully apply it. Of course there are exceptions to this, e.g. during my Diplom (= Master's) thesis, the method I was to use was fixed. The other question is: how much do weeks 2 - 8 of calculation time add to the quality of model and performance evaluation? If we are talking about that order of magnitude, I'd really do some preliminary calculations, e.g. of the learning curve. I'd also make doubly sure that all parameters are as they should be before starting the calculation. And I may give a second thought on whether I cannot use a faster method. (Depending on your skills, tasks, and the algorithm you use:) If you find that the calculation is much slower than you expected, you may want to follow the saying that a better algorithm can speed up things by orders of magnitude or even reduce the complexity, while paralelization will only help linearly. Sometimes even just a better implementaion of the same algorithm can yield one or two orders of magnitude. I often start the resampling calculation, and fetch preliminary results after a few iterations are through. That allows me to go on working (e.g. setting up the code that summarizes the results, draws the figures etc.), while the final results are refined. That way, it doesn't bother me that much if the whole resampling takes a week. tweak parameters ahead of time Just make sure then that your validation is independent of the parameter tweaking.
How to estimate training time prior to training? (Machine Learning & Neural Networks) Some thoughts additional to @iliasfl's point: If I think it's going to take long, I do some test runs, which basically allows me to check like @iliasfl suggests. In addition, I also look at memory, b
16,771
Is it good practice to standardize your data in a regression with panel/longitudinal data?
I can't see that standardization is a good idea in ordinary regression or with a longitudinal model. It makes predictions harder to obtain and doesn't solve a problem that needs solving, usually. And what if you have $x$ and $x^2$ in the model. How do you standardize $x^2$? What if you have a continuous variable and a binary variable in the model? How do you standardize the binary variable? Certainly not by its standard deviation, which would cause low prevalence variables to have greater importance. In general it's best to interpret model effects on the original scale of $x$.
Is it good practice to standardize your data in a regression with panel/longitudinal data?
I can't see that standardization is a good idea in ordinary regression or with a longitudinal model. It makes predictions harder to obtain and doesn't solve a problem that needs solving, usually. An
Is it good practice to standardize your data in a regression with panel/longitudinal data? I can't see that standardization is a good idea in ordinary regression or with a longitudinal model. It makes predictions harder to obtain and doesn't solve a problem that needs solving, usually. And what if you have $x$ and $x^2$ in the model. How do you standardize $x^2$? What if you have a continuous variable and a binary variable in the model? How do you standardize the binary variable? Certainly not by its standard deviation, which would cause low prevalence variables to have greater importance. In general it's best to interpret model effects on the original scale of $x$.
Is it good practice to standardize your data in a regression with panel/longitudinal data? I can't see that standardization is a good idea in ordinary regression or with a longitudinal model. It makes predictions harder to obtain and doesn't solve a problem that needs solving, usually. An
16,772
Is it good practice to standardize your data in a regression with panel/longitudinal data?
There is an alternative to standardization to bring variables measured with different scales to the same metric. It's called Proportion of Maximum Scaling (POMS), and it dies not mess with the multivariate distributions as z-transformation tends to do. Todd Little explicitly recommends POMS over z-standardization in his book on longitudinal structural equation modeling. Z-transformation comes with additional problems when dealing with longitudinal data, see here: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4569815/
Is it good practice to standardize your data in a regression with panel/longitudinal data?
There is an alternative to standardization to bring variables measured with different scales to the same metric. It's called Proportion of Maximum Scaling (POMS), and it dies not mess with the multiva
Is it good practice to standardize your data in a regression with panel/longitudinal data? There is an alternative to standardization to bring variables measured with different scales to the same metric. It's called Proportion of Maximum Scaling (POMS), and it dies not mess with the multivariate distributions as z-transformation tends to do. Todd Little explicitly recommends POMS over z-standardization in his book on longitudinal structural equation modeling. Z-transformation comes with additional problems when dealing with longitudinal data, see here: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4569815/
Is it good practice to standardize your data in a regression with panel/longitudinal data? There is an alternative to standardization to bring variables measured with different scales to the same metric. It's called Proportion of Maximum Scaling (POMS), and it dies not mess with the multiva
16,773
VIF, condition Index and eigenvalues
Multicollinearity problem is well studied in actually most econometric textbooks. Moreover there is a good article in wikipedia which actually summarizes most of the key issues. In practice one starts to bear in mind the multicollinearity problem if it causes some visual signs of parameter instability (most of them are implied by non (poor) invertability of $X^TX$ matrix): large changes in parameter estimates while performing rolling regressions or estimates on smaller sub-samples of the data averaging of parameter estimates, the latter may fall to be insignificant (by $t$ tests) even though junk-regression $F$ test shows high joint significance of the results VIF statistic (average value of auxiliary regressions) merely depends on your requirements to tolerance level, most practical suggestions put an acceptable tolerance to be lower than 0.2 or 0.1 meaning that corresponding averages of auxiliary regressions $R^2$ should be higher than 0.9 or 0.8 to detect the problem. Thus VIF should be larger than rule-of-thumb's 10 and 5 values. In small samples (less than 50 points) 5 is preferable, in larger you can go to larger values. Condition index is an alternative to VIF in your case neither VIF nor CI show the problem is left, so you may be satisfied statistically on this result, but... probably not theoretically, since it may happen (and usually is the case) that you need all variables to be present in the model. Excluding relevant variables (omitted variable problem) will make biased and inconsistent parameter estimates anyway. On the other hand you may be forced to include all focus variables simply because your analysis is based on it. In data-mining approach though you are more technical in searching for the best fit. So keep in mind the alternatives (that I would use myself): obtain more data points (recall that VIF requirements are smaller for larger data set and the explanatory variables if they are slowly varying, may change for some crucial points in time or cross-section) search for lattent factors through principal components (the latter are orthogonal combinations so not multi-collinear by the construction, more over involve all explanatory variables) ridge-regression (it introduces small bias in parameter estimates, but makes them highly stable) Some other tricks are in the wiki article noted above.
VIF, condition Index and eigenvalues
Multicollinearity problem is well studied in actually most econometric textbooks. Moreover there is a good article in wikipedia which actually summarizes most of the key issues. In practice one starts
VIF, condition Index and eigenvalues Multicollinearity problem is well studied in actually most econometric textbooks. Moreover there is a good article in wikipedia which actually summarizes most of the key issues. In practice one starts to bear in mind the multicollinearity problem if it causes some visual signs of parameter instability (most of them are implied by non (poor) invertability of $X^TX$ matrix): large changes in parameter estimates while performing rolling regressions or estimates on smaller sub-samples of the data averaging of parameter estimates, the latter may fall to be insignificant (by $t$ tests) even though junk-regression $F$ test shows high joint significance of the results VIF statistic (average value of auxiliary regressions) merely depends on your requirements to tolerance level, most practical suggestions put an acceptable tolerance to be lower than 0.2 or 0.1 meaning that corresponding averages of auxiliary regressions $R^2$ should be higher than 0.9 or 0.8 to detect the problem. Thus VIF should be larger than rule-of-thumb's 10 and 5 values. In small samples (less than 50 points) 5 is preferable, in larger you can go to larger values. Condition index is an alternative to VIF in your case neither VIF nor CI show the problem is left, so you may be satisfied statistically on this result, but... probably not theoretically, since it may happen (and usually is the case) that you need all variables to be present in the model. Excluding relevant variables (omitted variable problem) will make biased and inconsistent parameter estimates anyway. On the other hand you may be forced to include all focus variables simply because your analysis is based on it. In data-mining approach though you are more technical in searching for the best fit. So keep in mind the alternatives (that I would use myself): obtain more data points (recall that VIF requirements are smaller for larger data set and the explanatory variables if they are slowly varying, may change for some crucial points in time or cross-section) search for lattent factors through principal components (the latter are orthogonal combinations so not multi-collinear by the construction, more over involve all explanatory variables) ridge-regression (it introduces small bias in parameter estimates, but makes them highly stable) Some other tricks are in the wiki article noted above.
VIF, condition Index and eigenvalues Multicollinearity problem is well studied in actually most econometric textbooks. Moreover there is a good article in wikipedia which actually summarizes most of the key issues. In practice one starts
16,774
VIF, condition Index and eigenvalues
I believe Belsely said that CI over 10 is indicative of a possible moderate problem, while over 30 is more severe. In addition, though, you should look at the variance shared by sets of variables in the high condition indices. There is debate (or was, last time I read this literature) on whether collinearity that involved one variable and the intercept was problematic or not, and whether centering the offending variable got rid of the problem, or simply moved it elsewhere.
VIF, condition Index and eigenvalues
I believe Belsely said that CI over 10 is indicative of a possible moderate problem, while over 30 is more severe. In addition, though, you should look at the variance shared by sets of variables in
VIF, condition Index and eigenvalues I believe Belsely said that CI over 10 is indicative of a possible moderate problem, while over 30 is more severe. In addition, though, you should look at the variance shared by sets of variables in the high condition indices. There is debate (or was, last time I read this literature) on whether collinearity that involved one variable and the intercept was problematic or not, and whether centering the offending variable got rid of the problem, or simply moved it elsewhere.
VIF, condition Index and eigenvalues I believe Belsely said that CI over 10 is indicative of a possible moderate problem, while over 30 is more severe. In addition, though, you should look at the variance shared by sets of variables in
16,775
Is Kaggle's private leaderboard a good predictor of out-of-sample performance of the winning model?
Well the points you present are fair, however I think that there is a far more real issue with people overfitting on the public leaderboard. This may happen when you do 100 or so submissions, the public test set will eventually bleed out on to your hyperparameter selection and thus overfit. I think that the private leaderboard is necessary in that respect.
Is Kaggle's private leaderboard a good predictor of out-of-sample performance of the winning model?
Well the points you present are fair, however I think that there is a far more real issue with people overfitting on the public leaderboard. This may happen when you do 100 or so submissions, the publ
Is Kaggle's private leaderboard a good predictor of out-of-sample performance of the winning model? Well the points you present are fair, however I think that there is a far more real issue with people overfitting on the public leaderboard. This may happen when you do 100 or so submissions, the public test set will eventually bleed out on to your hyperparameter selection and thus overfit. I think that the private leaderboard is necessary in that respect.
Is Kaggle's private leaderboard a good predictor of out-of-sample performance of the winning model? Well the points you present are fair, however I think that there is a far more real issue with people overfitting on the public leaderboard. This may happen when you do 100 or so submissions, the publ
16,776
Pros and Cons of Log Link Versus Identity Link for Poisson Regression
Cons of an identity link in the case of the Poisson regression are: As you have mentioned, it can produce out-of-range predictions. You may get weird errors and warnings when attempting to fit the model, because the link permits lambda to be less than 0, but the Poisson distribution is not defined for such values. As Poisson regression assumes that the mean and variance are the same, when you change the link you are also changing assumptions about the variance. My experience has been that this last point is most telling. But, ultimately this is an empirical question. Fit both models. Perform whatever checks you like. If the identity link has a lower AIC, and does as well or better on all your other checks, then run with the identity link. In the case of the logit model vs the linear probability model (i.e., what you refer to as the identity link), the situation is a lot more straightforward. Except for some very exotic cases in econometrics (which you will find if you do a search), the logit model is better: it makes fewer assumptions and is what most people use. Using the linear probability model in its place would verge on being perverse. As regards interpreting the models, if you are using R, there are two great packages that will do all the heavy lifting: effects, which is super easy to use, and zelig, which is harder to use but great if you want to make predictions.
Pros and Cons of Log Link Versus Identity Link for Poisson Regression
Cons of an identity link in the case of the Poisson regression are: As you have mentioned, it can produce out-of-range predictions. You may get weird errors and warnings when attempting to fit the m
Pros and Cons of Log Link Versus Identity Link for Poisson Regression Cons of an identity link in the case of the Poisson regression are: As you have mentioned, it can produce out-of-range predictions. You may get weird errors and warnings when attempting to fit the model, because the link permits lambda to be less than 0, but the Poisson distribution is not defined for such values. As Poisson regression assumes that the mean and variance are the same, when you change the link you are also changing assumptions about the variance. My experience has been that this last point is most telling. But, ultimately this is an empirical question. Fit both models. Perform whatever checks you like. If the identity link has a lower AIC, and does as well or better on all your other checks, then run with the identity link. In the case of the logit model vs the linear probability model (i.e., what you refer to as the identity link), the situation is a lot more straightforward. Except for some very exotic cases in econometrics (which you will find if you do a search), the logit model is better: it makes fewer assumptions and is what most people use. Using the linear probability model in its place would verge on being perverse. As regards interpreting the models, if you are using R, there are two great packages that will do all the heavy lifting: effects, which is super easy to use, and zelig, which is harder to use but great if you want to make predictions.
Pros and Cons of Log Link Versus Identity Link for Poisson Regression Cons of an identity link in the case of the Poisson regression are: As you have mentioned, it can produce out-of-range predictions. You may get weird errors and warnings when attempting to fit the m
16,777
Pros and Cons of Log Link Versus Identity Link for Poisson Regression
In the case of Poisson models I would also say that the application often dictates whether your covariates would act additively (which would then imply an identity link) or multiplicatively on a linear scale (which would then imply a log link). But Poisson models with an identity link also normally only make sense and can only stably be fit if one imposes nonnegativity constraints on the fitted coefficients - this can be done using the nnpois function in the R addreg package or using the nnlm function in the NNLM package. So I don't agree that one should fit Poisson models with both an identity and log link and see which one ends up having the best AIC and infer the best model based on purely statistical grounds - rather, in most cases it is dictated by the underlying structure of the problem that one tries to solve or the data at hand. For example, in chromatography (GC/MS analysis) one would often measure the superimposed signal of several approx Gaussian shaped peaks and this superimposed signal is measured with an electron multiplier, which means that the measured signal are ion counts and therefore Poisson distributed. Since each of the peaks have by definition a positive height and act additively and the noise is Poisson, a nonnegative Poisson model with identity link would be appropriate here, and a log link Poisson model would be plain wrong. In engineering Kullback-Leibler loss is often used as a loss function for such models, and minimizing this loss is equivalent to optimizing the likelihood of a nonnegative identity-link Poisson model (there is also other divergence/loss measures like alpha or beta divergence that have Poisson as a special case). Below is a numerical example, including a demonstration that a regular unconstrained identity link Poisson GLM does not fit (because of the lack of nonnegativity constraints) and some details on how to fit nonnegative identity-link Poisson models using nnpois, here in the context of deconvoluting a measured superposition of chromatographic peaks with Poisson noise on them using a banded covariate matrix that contains shifted copies of the measured shape of a single peak. Nonnegativity here is important for several reasons: (1) it is the only realistic model for the data at hand (peaks here cannot have negative heights), (2) it is the only way to stably fit a Poisson model with identity link (as otherwise predictions could for some covariate values go negative, which wouldn't make sense and would give numerical problems when one would try to evaluate the likelihood), (3) nonnegativity acts to regularize the regression problem and greatly helps to obtain stable estimates (e.g. you typically don't get the overfitting problems as with ordinary unconstrained regression, where overfitting typically results in coefficients with very large absolute magnitude and opposite signs - you see this effect in the OLS estimate below) and (4) nonnegativity constraints result in sparser estimates that are frequently closer to the ground truth; for the deconvolution problem below e.g. performance is about as good as LASSO regularization, but without requiring one to tune any regularization parameter. (L0-pseudonorm penalized regression still performs slightly better but at a greater computational cost) # we first simulate some data require(Matrix) n = 200 x = 1:n npeaks = 20 set.seed(123) u = sample(x, npeaks, replace=FALSE) # unkown peak locations peakhrange = c(10,1E3) # peak height range h = 10^runif(npeaks, min=log10(min(peakhrange)), max=log10(max(peakhrange))) # unknown peak heights a = rep(0, n) # locations of spikes of simulated spike train, which are assumed to be unknown here, and which needs to be estimated from the measured total signal a[u] = h gauspeak = function(x, u, w, h=1) h*exp(((x-u)^2)/(-2*(w^2))) # peak shape function bM = do.call(cbind, lapply(1:n, function (u) gauspeak(x, u=u, w=5, h=1) )) # banded matrix with peak shape measured beforehand y_nonoise = as.vector(bM %*% a) # noiseless simulated signal = linear convolution of spike train with peak shape function y = rpois(n, y_nonoise) # simulated signal with random poisson noise on it - this is the actual signal as it is recorded par(mfrow=c(1,1)) plot(y, type="l", ylab="Signal", xlab="x", main="Simulated spike train (red) to be estimated given known blur kernel & with Poisson noise") lines(a, type="h", col="red") # let's now deconvolute the measured signal y with the banded covariate matrix containing shifted copied of the known blur kernel/peak shape bM # first observe that regular OLS regression without nonnegativity constraints would return very bad nonsensical estimates weights <- 1/(y+1) # let's use 1/variance = 1/(y+eps) observation weights to take into heteroscedasticity caused by Poisson noise a_ols <- lm.fit(x=bM*sqrt(weights), y=y*sqrt(weights))$coefficients # weighted OLS plot(x, y, type="l", main="Ground truth (red), unconstrained OLS estimate (blue)", ylab="Peak shape", xlab="x", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_ols, type="h", col="blue", lwd=2) # now we use weighted nonnegative least squares with 1/variance obs weights as an approximation of nonnegative Poisson regression # this gives very good estimates & is very fast library(nnls) library(microbenchmark) microbenchmark(a_wnnls <- nnls(A=bM*sqrt(weights),b=y*sqrt(weights))$x) # 7 ms plot(x, y, type="l", main="Ground truth (red), weighted nnls estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_wnnls, type="h", col="blue", lwd=2) # note that this weighted least square estimate in almost identical to the nonnegative Poisson estimate below and that it fits way faster!!! # an unconstrained identity-link Poisson GLM will not fit: glmfit = glm.fit(x=as.matrix(bM), y=y, family=poisson(link=identity), intercept=FALSE) # returns Error: no valid set of coefficients has been found: please supply starting values # so let's try a nonnegativity constrained identity-link Poisson GLM, fit using bbmle (using port algo, ie Quasi Newton BFGS): library(bbmle) XM=as.matrix(bM) colnames(XM)=paste0("v",as.character(1:n)) yv=as.vector(y) LL_poisidlink <- function(beta, X=XM, y=yv){ # neg log-likelihood function -sum(stats::dpois(y, lambda = X %*% beta, log = TRUE)) # PS regular log-link Poisson would have exp(X %*% beta) } parnames(LL_poisidlink) <- colnames(XM) system.time(fit <- mle2( minuslogl = LL_poisidlink , start = setNames(a_wnnls+1E-10, colnames(XM)), # we initialise with weighted nnls estimates, with approx 1/variance obs weights lower = rep(0,n), vecpar = TRUE, optimizer = "nlminb" )) # very slow though - takes 145s summary(fit) a_nnpoisbbmle = coef(fit) plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson bbmle ML estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpoisbbmle, type="h", col="blue", lwd=2) # much faster is to fit nonnegative Poisson regression using nnpois using an accelerated EM algorithm: library(addreg) microbenchmark(a_nnpois <- nnpois(y=y, x=as.matrix(bM), standard=rep(1,n), offset=0, start=a_wnnls+1.1E-4, # we start from weighted nnls estimates control = addreg.control(bound.tol = 1e-04, epsilon = 1e-5), accelerate="squarem")$coefficients) # 100 ms plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson nnpois estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpois, type="h", col="blue", lwd=2) # or to fit nonnegative Poisson regression using nnlm with Kullback-Leibler loss using a coordinate descent algorithm: library(NNLM) system.time(a_nnpoisnnlm <- nnlm(x=as.matrix(rbind(bM)), y=as.matrix(y, ncol=1), loss="mkl", method="scd", init=as.matrix(a_wnnls, ncol=1), check.x=FALSE, rel.tol=1E-4)$coefficients) # 3s plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson nnlm estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpoisnnlm, type="h", col="blue", lwd=2)
Pros and Cons of Log Link Versus Identity Link for Poisson Regression
In the case of Poisson models I would also say that the application often dictates whether your covariates would act additively (which would then imply an identity link) or multiplicatively on a linea
Pros and Cons of Log Link Versus Identity Link for Poisson Regression In the case of Poisson models I would also say that the application often dictates whether your covariates would act additively (which would then imply an identity link) or multiplicatively on a linear scale (which would then imply a log link). But Poisson models with an identity link also normally only make sense and can only stably be fit if one imposes nonnegativity constraints on the fitted coefficients - this can be done using the nnpois function in the R addreg package or using the nnlm function in the NNLM package. So I don't agree that one should fit Poisson models with both an identity and log link and see which one ends up having the best AIC and infer the best model based on purely statistical grounds - rather, in most cases it is dictated by the underlying structure of the problem that one tries to solve or the data at hand. For example, in chromatography (GC/MS analysis) one would often measure the superimposed signal of several approx Gaussian shaped peaks and this superimposed signal is measured with an electron multiplier, which means that the measured signal are ion counts and therefore Poisson distributed. Since each of the peaks have by definition a positive height and act additively and the noise is Poisson, a nonnegative Poisson model with identity link would be appropriate here, and a log link Poisson model would be plain wrong. In engineering Kullback-Leibler loss is often used as a loss function for such models, and minimizing this loss is equivalent to optimizing the likelihood of a nonnegative identity-link Poisson model (there is also other divergence/loss measures like alpha or beta divergence that have Poisson as a special case). Below is a numerical example, including a demonstration that a regular unconstrained identity link Poisson GLM does not fit (because of the lack of nonnegativity constraints) and some details on how to fit nonnegative identity-link Poisson models using nnpois, here in the context of deconvoluting a measured superposition of chromatographic peaks with Poisson noise on them using a banded covariate matrix that contains shifted copies of the measured shape of a single peak. Nonnegativity here is important for several reasons: (1) it is the only realistic model for the data at hand (peaks here cannot have negative heights), (2) it is the only way to stably fit a Poisson model with identity link (as otherwise predictions could for some covariate values go negative, which wouldn't make sense and would give numerical problems when one would try to evaluate the likelihood), (3) nonnegativity acts to regularize the regression problem and greatly helps to obtain stable estimates (e.g. you typically don't get the overfitting problems as with ordinary unconstrained regression, where overfitting typically results in coefficients with very large absolute magnitude and opposite signs - you see this effect in the OLS estimate below) and (4) nonnegativity constraints result in sparser estimates that are frequently closer to the ground truth; for the deconvolution problem below e.g. performance is about as good as LASSO regularization, but without requiring one to tune any regularization parameter. (L0-pseudonorm penalized regression still performs slightly better but at a greater computational cost) # we first simulate some data require(Matrix) n = 200 x = 1:n npeaks = 20 set.seed(123) u = sample(x, npeaks, replace=FALSE) # unkown peak locations peakhrange = c(10,1E3) # peak height range h = 10^runif(npeaks, min=log10(min(peakhrange)), max=log10(max(peakhrange))) # unknown peak heights a = rep(0, n) # locations of spikes of simulated spike train, which are assumed to be unknown here, and which needs to be estimated from the measured total signal a[u] = h gauspeak = function(x, u, w, h=1) h*exp(((x-u)^2)/(-2*(w^2))) # peak shape function bM = do.call(cbind, lapply(1:n, function (u) gauspeak(x, u=u, w=5, h=1) )) # banded matrix with peak shape measured beforehand y_nonoise = as.vector(bM %*% a) # noiseless simulated signal = linear convolution of spike train with peak shape function y = rpois(n, y_nonoise) # simulated signal with random poisson noise on it - this is the actual signal as it is recorded par(mfrow=c(1,1)) plot(y, type="l", ylab="Signal", xlab="x", main="Simulated spike train (red) to be estimated given known blur kernel & with Poisson noise") lines(a, type="h", col="red") # let's now deconvolute the measured signal y with the banded covariate matrix containing shifted copied of the known blur kernel/peak shape bM # first observe that regular OLS regression without nonnegativity constraints would return very bad nonsensical estimates weights <- 1/(y+1) # let's use 1/variance = 1/(y+eps) observation weights to take into heteroscedasticity caused by Poisson noise a_ols <- lm.fit(x=bM*sqrt(weights), y=y*sqrt(weights))$coefficients # weighted OLS plot(x, y, type="l", main="Ground truth (red), unconstrained OLS estimate (blue)", ylab="Peak shape", xlab="x", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_ols, type="h", col="blue", lwd=2) # now we use weighted nonnegative least squares with 1/variance obs weights as an approximation of nonnegative Poisson regression # this gives very good estimates & is very fast library(nnls) library(microbenchmark) microbenchmark(a_wnnls <- nnls(A=bM*sqrt(weights),b=y*sqrt(weights))$x) # 7 ms plot(x, y, type="l", main="Ground truth (red), weighted nnls estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_wnnls, type="h", col="blue", lwd=2) # note that this weighted least square estimate in almost identical to the nonnegative Poisson estimate below and that it fits way faster!!! # an unconstrained identity-link Poisson GLM will not fit: glmfit = glm.fit(x=as.matrix(bM), y=y, family=poisson(link=identity), intercept=FALSE) # returns Error: no valid set of coefficients has been found: please supply starting values # so let's try a nonnegativity constrained identity-link Poisson GLM, fit using bbmle (using port algo, ie Quasi Newton BFGS): library(bbmle) XM=as.matrix(bM) colnames(XM)=paste0("v",as.character(1:n)) yv=as.vector(y) LL_poisidlink <- function(beta, X=XM, y=yv){ # neg log-likelihood function -sum(stats::dpois(y, lambda = X %*% beta, log = TRUE)) # PS regular log-link Poisson would have exp(X %*% beta) } parnames(LL_poisidlink) <- colnames(XM) system.time(fit <- mle2( minuslogl = LL_poisidlink , start = setNames(a_wnnls+1E-10, colnames(XM)), # we initialise with weighted nnls estimates, with approx 1/variance obs weights lower = rep(0,n), vecpar = TRUE, optimizer = "nlminb" )) # very slow though - takes 145s summary(fit) a_nnpoisbbmle = coef(fit) plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson bbmle ML estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpoisbbmle, type="h", col="blue", lwd=2) # much faster is to fit nonnegative Poisson regression using nnpois using an accelerated EM algorithm: library(addreg) microbenchmark(a_nnpois <- nnpois(y=y, x=as.matrix(bM), standard=rep(1,n), offset=0, start=a_wnnls+1.1E-4, # we start from weighted nnls estimates control = addreg.control(bound.tol = 1e-04, epsilon = 1e-5), accelerate="squarem")$coefficients) # 100 ms plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson nnpois estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpois, type="h", col="blue", lwd=2) # or to fit nonnegative Poisson regression using nnlm with Kullback-Leibler loss using a coordinate descent algorithm: library(NNLM) system.time(a_nnpoisnnlm <- nnlm(x=as.matrix(rbind(bM)), y=as.matrix(y, ncol=1), loss="mkl", method="scd", init=as.matrix(a_wnnls, ncol=1), check.x=FALSE, rel.tol=1E-4)$coefficients) # 3s plot(x, y, type="l", main="Ground truth (red), nonnegative Poisson nnlm estimate (blue)", ylab="Signal (black) & peaks (red & blue)", xlab="Time", ylim=c(-max(y),max(y))) lines(x,-y) lines(a, type="h", col="red", lwd=2) lines(-a_nnpoisnnlm, type="h", col="blue", lwd=2)
Pros and Cons of Log Link Versus Identity Link for Poisson Regression In the case of Poisson models I would also say that the application often dictates whether your covariates would act additively (which would then imply an identity link) or multiplicatively on a linea
16,778
Statistical Inference Under Misspecification
Let $y_1, \ldots, y_n$ be the observed data which is presumed to be a realization of a sequence of i.i.d. random variables $Y_1, \ldots, Y_n$ with common probability density function $p_e$ defined with respect to a sigma-finite measure $\nu$. The density $p_e$ is called Data Generating Process (DGP) density. In the researcher's probability model ${\cal M} \equiv \{ p(y ; \theta) : \theta \in \Theta \}$ is a collection of probability density functions which are indexed by a parameter vector $\theta$. Assume each density in ${\cal M}$ is a defined with respect to a common sigma-finite measure $\nu$ (e.g., each density could be a probability mass function with the same sample space $S$). It is important to keep the density $p_e$ which actually generated the data conceptually distinct from the probability model of the data. In classic statistical treatments a careful separaration of these concepts is either ignored, not made, or it is assumed right from the beginning that the probability model is correctly specified. A correctly specified model ${\cal M}$ with respect to $p_e$ is defined as a model where $p_e \in {\cal M}$ $\nu$-almost everywhere. When ${\cal M}$ is misspecified with respect to $p_e$ this corresponds to the case where the probability model is not correctly specified. If the probability model is correctly specified, then there exists a $\theta^*$ in the parameter space $\Theta$ such that $p_e(y) = p(y ; \theta^*)$ $\nu$-almost everywhere. Such a parameter vector is called the "true parameter vector". If the probability model is misspecified, then the true parameter vector does not exist. Within White's model misspecification framework the goal is to find the parameter estimate $\hat{\theta}_n$ that minimizes $\hat{\ell}_n({\theta}) \equiv (1/n) \sum_{i=1}^n \log p(y_i ; { \theta})$ over some compact parameter space $\Theta$. It is assumed that a unique strict global minimizer, $\theta^*$, of the expected value of $\hat{\ell}_n$ on $\Theta$ is located in the interior of $\Theta$. In the lucky case where the probability model is correctly specified, $\theta^*$ may be interpreted as the "true parameter value". In the special case where the probability model is correctly specified, then $\hat{\theta}_n$ is the familiar maximum likelihood estimate. If we don't know have absolute knowledge that the probability model is correctly specified, then $\hat{\theta}_n$ is called a quasi-maximum likelihood estimate and the goal is to estimate $\theta^*$. If we get lucky and the probability model is correctly specified, then the quasi-maximum likelihood estimate reduces as a special case to the familiar maximum likelihood estimate and $\theta^*$ becomes the true parameter value. Consistency within White's (1982) framework corresponds to convergence to $\theta^*$ without requiring that $\theta^*$ is necessarily the true parameter vector. Within White's framework, we would never estimate the probability of the event that the sets produced by δ include the TRUE distribution P*. Instead, we would always estimate the probability distribution P** which is the probability of the event that the sets produced by δ include the distribution specified by the density $p(y ; \theta^*)$. Finally, a few comments about model misspecification. It is easy to find examples where a misspecified model is extremely useful and very predictive. For example, consider a nonlinear (or even a linear) regression model with a Gaussian residual error term whose variance is extremely small yet the actual residual error in the environment is not Gaussian. It is also easy to find examples where a correctly specified model is not useful and not predictive. For example, consider a random walk model for predicting stock prices which predicts tomorrow's closing price is a weighted sum of today's closing priced and some Gaussian noise with an extremely large variance. The purpose of the model misspecification framework is not to ensure model validity but rather to ensure reliability. That is, ensure that the sampling error associated with your parameter estimates, confidence intervals, hypothesis tests, and so on are correctly estimated despite the presence of either a small or large amount of model misspecification. The quasi-maximum likelihood estimates are asymptotically normal centered at $\theta^*$ with a covariance matrix estimator which depends upon both the first and second derivatives of the negative log-likelihood function. In the special case where you get lucky and the model is correct then all of the formulas reduce to the familiar classical statistical framework where the goal is to estimate the "true" parameter values.
Statistical Inference Under Misspecification
Let $y_1, \ldots, y_n$ be the observed data which is presumed to be a realization of a sequence of i.i.d. random variables $Y_1, \ldots, Y_n$ with common probability density function $p_e$ defined wit
Statistical Inference Under Misspecification Let $y_1, \ldots, y_n$ be the observed data which is presumed to be a realization of a sequence of i.i.d. random variables $Y_1, \ldots, Y_n$ with common probability density function $p_e$ defined with respect to a sigma-finite measure $\nu$. The density $p_e$ is called Data Generating Process (DGP) density. In the researcher's probability model ${\cal M} \equiv \{ p(y ; \theta) : \theta \in \Theta \}$ is a collection of probability density functions which are indexed by a parameter vector $\theta$. Assume each density in ${\cal M}$ is a defined with respect to a common sigma-finite measure $\nu$ (e.g., each density could be a probability mass function with the same sample space $S$). It is important to keep the density $p_e$ which actually generated the data conceptually distinct from the probability model of the data. In classic statistical treatments a careful separaration of these concepts is either ignored, not made, or it is assumed right from the beginning that the probability model is correctly specified. A correctly specified model ${\cal M}$ with respect to $p_e$ is defined as a model where $p_e \in {\cal M}$ $\nu$-almost everywhere. When ${\cal M}$ is misspecified with respect to $p_e$ this corresponds to the case where the probability model is not correctly specified. If the probability model is correctly specified, then there exists a $\theta^*$ in the parameter space $\Theta$ such that $p_e(y) = p(y ; \theta^*)$ $\nu$-almost everywhere. Such a parameter vector is called the "true parameter vector". If the probability model is misspecified, then the true parameter vector does not exist. Within White's model misspecification framework the goal is to find the parameter estimate $\hat{\theta}_n$ that minimizes $\hat{\ell}_n({\theta}) \equiv (1/n) \sum_{i=1}^n \log p(y_i ; { \theta})$ over some compact parameter space $\Theta$. It is assumed that a unique strict global minimizer, $\theta^*$, of the expected value of $\hat{\ell}_n$ on $\Theta$ is located in the interior of $\Theta$. In the lucky case where the probability model is correctly specified, $\theta^*$ may be interpreted as the "true parameter value". In the special case where the probability model is correctly specified, then $\hat{\theta}_n$ is the familiar maximum likelihood estimate. If we don't know have absolute knowledge that the probability model is correctly specified, then $\hat{\theta}_n$ is called a quasi-maximum likelihood estimate and the goal is to estimate $\theta^*$. If we get lucky and the probability model is correctly specified, then the quasi-maximum likelihood estimate reduces as a special case to the familiar maximum likelihood estimate and $\theta^*$ becomes the true parameter value. Consistency within White's (1982) framework corresponds to convergence to $\theta^*$ without requiring that $\theta^*$ is necessarily the true parameter vector. Within White's framework, we would never estimate the probability of the event that the sets produced by δ include the TRUE distribution P*. Instead, we would always estimate the probability distribution P** which is the probability of the event that the sets produced by δ include the distribution specified by the density $p(y ; \theta^*)$. Finally, a few comments about model misspecification. It is easy to find examples where a misspecified model is extremely useful and very predictive. For example, consider a nonlinear (or even a linear) regression model with a Gaussian residual error term whose variance is extremely small yet the actual residual error in the environment is not Gaussian. It is also easy to find examples where a correctly specified model is not useful and not predictive. For example, consider a random walk model for predicting stock prices which predicts tomorrow's closing price is a weighted sum of today's closing priced and some Gaussian noise with an extremely large variance. The purpose of the model misspecification framework is not to ensure model validity but rather to ensure reliability. That is, ensure that the sampling error associated with your parameter estimates, confidence intervals, hypothesis tests, and so on are correctly estimated despite the presence of either a small or large amount of model misspecification. The quasi-maximum likelihood estimates are asymptotically normal centered at $\theta^*$ with a covariance matrix estimator which depends upon both the first and second derivatives of the negative log-likelihood function. In the special case where you get lucky and the model is correct then all of the formulas reduce to the familiar classical statistical framework where the goal is to estimate the "true" parameter values.
Statistical Inference Under Misspecification Let $y_1, \ldots, y_n$ be the observed data which is presumed to be a realization of a sequence of i.i.d. random variables $Y_1, \ldots, Y_n$ with common probability density function $p_e$ defined wit
16,779
Statistical Inference Under Misspecification
Firstly, let me say that this is a really fascinating question; kudos to Julian for posting it. As I see it, the fundamental problem you face in this kind of analysis is that any inference of any subset of $\Theta$ is an inference over the restricted class of probability measures in the model $\mathcal{M}$, so when you start asking about probabilities of inferring the true model, under the model, this degenerates down to a trivial question of whether or not there is misspecification to begin with. White gets around this by looking at how close the model gets to the true probability measure, using an appropriate distance metric. This leads him to the probability measure $\mathbb{P}_{\theta_1}$, which is the closest proxy for $\mathbb{P}^*$ in $\mathcal{M}$. This method of looking at $\mathbb{P}_{\theta_1}$ can be extended to give interesting quantities relating to your question about the confidence sets. Before getting to this, it is worth pointing out that the values $A$ and $B$ are mathematically well-defined in your analysis (i.e., they exist), and they still have a meaning; it is just not necessarily a very useful meaning. The value $A$ in your analysis is well-defined; it is the true probability that the inferred set of probability measures includes the true probability measure. You are correct that $\mathbb{P}^* \notin \mathcal{M}$ implies $A = 0$, which means that this quantity is trivial in the case of misspecification. Following White's lead, it is perhaps more interesting to look at the quantity: $$A^* \equiv A^*(Y) \equiv \mathbb{P}^* (\mathbb{P}_{\theta_1} \in \{P_\theta | \theta \in \delta(Y) \} ).$$ Here we have replaced the inner occurrence of $\mathbb{P}^*$ with its closest proxy in the model $\mathcal{M}$, so that the quantity is no longer rendered trivial when $\mathbb{P}^* \notin \mathcal{M}$. Now we are asking for the true probability that the inferred set of probability measures includes the closest proxy for the true probability measure in the model. Misspecification of the model no longer trivialises this quantity, since we have $\mathbb{P}_{\theta_1} \in \mathcal{M}$ by construction. White analyses misspecification by showing that the MLE is a consistent estimator of $\mathbb{P}_{\theta_1}$. This is valuable because it tells you that even if there is misspecification, you still correctly estimate the closest proxy to the true probability measure in the model. A natural follow-up question concerning confidence sets is whether or not a particular inference method $\delta$ imposes any lower bound on the quantity $A^*$ or any convergence result in the limit as $n \rightarrow \infty$. If you can establish a (positive) lower bound or a (positive) convergence result, this gives you some value in guaranteeing that even if there is misspecification, you still correctly estimate the closest proxy with some probability level. I would recommend that you explore those issues, following the kind of analysis done by White.
Statistical Inference Under Misspecification
Firstly, let me say that this is a really fascinating question; kudos to Julian for posting it. As I see it, the fundamental problem you face in this kind of analysis is that any inference of any sub
Statistical Inference Under Misspecification Firstly, let me say that this is a really fascinating question; kudos to Julian for posting it. As I see it, the fundamental problem you face in this kind of analysis is that any inference of any subset of $\Theta$ is an inference over the restricted class of probability measures in the model $\mathcal{M}$, so when you start asking about probabilities of inferring the true model, under the model, this degenerates down to a trivial question of whether or not there is misspecification to begin with. White gets around this by looking at how close the model gets to the true probability measure, using an appropriate distance metric. This leads him to the probability measure $\mathbb{P}_{\theta_1}$, which is the closest proxy for $\mathbb{P}^*$ in $\mathcal{M}$. This method of looking at $\mathbb{P}_{\theta_1}$ can be extended to give interesting quantities relating to your question about the confidence sets. Before getting to this, it is worth pointing out that the values $A$ and $B$ are mathematically well-defined in your analysis (i.e., they exist), and they still have a meaning; it is just not necessarily a very useful meaning. The value $A$ in your analysis is well-defined; it is the true probability that the inferred set of probability measures includes the true probability measure. You are correct that $\mathbb{P}^* \notin \mathcal{M}$ implies $A = 0$, which means that this quantity is trivial in the case of misspecification. Following White's lead, it is perhaps more interesting to look at the quantity: $$A^* \equiv A^*(Y) \equiv \mathbb{P}^* (\mathbb{P}_{\theta_1} \in \{P_\theta | \theta \in \delta(Y) \} ).$$ Here we have replaced the inner occurrence of $\mathbb{P}^*$ with its closest proxy in the model $\mathcal{M}$, so that the quantity is no longer rendered trivial when $\mathbb{P}^* \notin \mathcal{M}$. Now we are asking for the true probability that the inferred set of probability measures includes the closest proxy for the true probability measure in the model. Misspecification of the model no longer trivialises this quantity, since we have $\mathbb{P}_{\theta_1} \in \mathcal{M}$ by construction. White analyses misspecification by showing that the MLE is a consistent estimator of $\mathbb{P}_{\theta_1}$. This is valuable because it tells you that even if there is misspecification, you still correctly estimate the closest proxy to the true probability measure in the model. A natural follow-up question concerning confidence sets is whether or not a particular inference method $\delta$ imposes any lower bound on the quantity $A^*$ or any convergence result in the limit as $n \rightarrow \infty$. If you can establish a (positive) lower bound or a (positive) convergence result, this gives you some value in guaranteeing that even if there is misspecification, you still correctly estimate the closest proxy with some probability level. I would recommend that you explore those issues, following the kind of analysis done by White.
Statistical Inference Under Misspecification Firstly, let me say that this is a really fascinating question; kudos to Julian for posting it. As I see it, the fundamental problem you face in this kind of analysis is that any inference of any sub
16,780
How to choose a kernel for kernel PCA?
The general approach to select an optimal kernel (either the type of kernel, or kernel parameters) in any kernel-based method is cross-validation. See here for the discussion of kernel selection for support vector machines: How to select kernel for SVM? The idea behind cross-validation is that we leave out some "test" data, run our algorithm to fit the model on the remaining "training" data, and then check how well the resulting model describes the test data (and how big the error is). This is repeated for different left-out data, errors are averaged to form an average cross-validated error, and then different algorithms can be compared in order to choose one yielding the lowest error. In SVM one can use e.g. classification accuracy (or related measures) as the measure of model performance. Then one would select a kernel that yields the best classification of the test data. The question then becomes: what measure of model performance can one use in kPCA? If you want to achieve "good data separation" (presumably good class separation), then you can somehow measure it on the training data and use that to find the best kernel. Note, however, that PCA/kPCA are not designed to yield good data separation (they do not take class labels into account at all). So generally speaking, one would want another, class-unrelated, measure of model performance. In standard PCA one can use reconstruction error as the performance measure on the test set. In kernel PCA one can also compute reconstruction error, but the problem is that it is not comparable between different kernels: reconstruction error is the distance measured in the target feature space; and different kernels correspond to different target spaces... So we have a problem. One way to tackle this problem is to somehow compute the reconstruction error in the original space, not in the target space. Obviously the left-out test data point lives in the original space. But its kPCA reconstruction lives in the [low-dimensional subspace of] the target space. What one can do, though, is to find a point ("pre-image") in the original space that would be mapped as close as possible to this reconstruction point, and then measure the distance between the test point and this pre-image as reconstruction error. I will not give all the formulas here, but instead refer you to some papers and only insert here several figures. The idea of "pre-image" in kPCA was apparently introduced in this paper: Mika, S., Schölkopf, B., Smola, A. J., Müller, K. R., Scholz, M., & Rätsch, G. (1998). Kernel PCA and De-Noising in Feature Spaces. In NIPS (Vol. 11, pp. 536-542). Mika et al. are not doing cross-validation, but they need pre-images for de-noising purposes, see this figure: Denoised (thick) points are pre-images of kPCA projections (there is no test and training here). It is not a trivial task to find these pre-images: one needs to use gradient descent, and the loss function will depend on the kernel. And here is a very recent paper that used pre-images for cross-validation purposes and kernel/hyperparameter selection: Alam, M. A., & Fukumizu, K. (2014). Hyperparameter selection in kernel principal component analysis. Journal of Computer Science, 10(7), 1139-1150. This is their algorithm: And here are some results (that I think are pretty much self-explanatory):
How to choose a kernel for kernel PCA?
The general approach to select an optimal kernel (either the type of kernel, or kernel parameters) in any kernel-based method is cross-validation. See here for the discussion of kernel selection for s
How to choose a kernel for kernel PCA? The general approach to select an optimal kernel (either the type of kernel, or kernel parameters) in any kernel-based method is cross-validation. See here for the discussion of kernel selection for support vector machines: How to select kernel for SVM? The idea behind cross-validation is that we leave out some "test" data, run our algorithm to fit the model on the remaining "training" data, and then check how well the resulting model describes the test data (and how big the error is). This is repeated for different left-out data, errors are averaged to form an average cross-validated error, and then different algorithms can be compared in order to choose one yielding the lowest error. In SVM one can use e.g. classification accuracy (or related measures) as the measure of model performance. Then one would select a kernel that yields the best classification of the test data. The question then becomes: what measure of model performance can one use in kPCA? If you want to achieve "good data separation" (presumably good class separation), then you can somehow measure it on the training data and use that to find the best kernel. Note, however, that PCA/kPCA are not designed to yield good data separation (they do not take class labels into account at all). So generally speaking, one would want another, class-unrelated, measure of model performance. In standard PCA one can use reconstruction error as the performance measure on the test set. In kernel PCA one can also compute reconstruction error, but the problem is that it is not comparable between different kernels: reconstruction error is the distance measured in the target feature space; and different kernels correspond to different target spaces... So we have a problem. One way to tackle this problem is to somehow compute the reconstruction error in the original space, not in the target space. Obviously the left-out test data point lives in the original space. But its kPCA reconstruction lives in the [low-dimensional subspace of] the target space. What one can do, though, is to find a point ("pre-image") in the original space that would be mapped as close as possible to this reconstruction point, and then measure the distance between the test point and this pre-image as reconstruction error. I will not give all the formulas here, but instead refer you to some papers and only insert here several figures. The idea of "pre-image" in kPCA was apparently introduced in this paper: Mika, S., Schölkopf, B., Smola, A. J., Müller, K. R., Scholz, M., & Rätsch, G. (1998). Kernel PCA and De-Noising in Feature Spaces. In NIPS (Vol. 11, pp. 536-542). Mika et al. are not doing cross-validation, but they need pre-images for de-noising purposes, see this figure: Denoised (thick) points are pre-images of kPCA projections (there is no test and training here). It is not a trivial task to find these pre-images: one needs to use gradient descent, and the loss function will depend on the kernel. And here is a very recent paper that used pre-images for cross-validation purposes and kernel/hyperparameter selection: Alam, M. A., & Fukumizu, K. (2014). Hyperparameter selection in kernel principal component analysis. Journal of Computer Science, 10(7), 1139-1150. This is their algorithm: And here are some results (that I think are pretty much self-explanatory):
How to choose a kernel for kernel PCA? The general approach to select an optimal kernel (either the type of kernel, or kernel parameters) in any kernel-based method is cross-validation. See here for the discussion of kernel selection for s
16,781
How to choose a kernel for kernel PCA?
a bit more hands on answer one way to evaluate is input the kpca output into a supervised model and see if the performance increases, from sklearn.model_selection import GridSearchCV from sklearn.linear_model import LogisticRegression from sklearn.pipeline import Pipeline clf = Pipeline([ ("kpca", KernelPCA(n_components=2)), ("log_reg", LogisticRegression()) ]) param_grid = [{ "kpca__gamma": np.linspace(0.03, 0.05, 10), "kpca__kernel": ["rbf", "sigmoid"] }] grid_search = GridSearchCV(clf, param_grid, cv=3) grid_search.fit(X, y) if you print the best result print(grid_search.best_params_) {'kpca__gamma': 0.043333333333333335, 'kpca__kernel': 'rbf'} another approach would be too look at the reconstruction error meaning you go into lower dimension and then try to reconstruct and calculate the error from the original space rbf_pca = KernelPCA(n_components = 2, kernel="rbf", gamma=0.0433, fit_inverse_transform=True) #make sure fit_inverse_transform is true X_reduced = rbf_pca.fit_transform(X) X_preimage = rbf_pca.inverse_transform(X_reduced) from sklearn.metrics import mean_squared_error mean_squared_error(X, X_preimage) 32.786308795766132 you can use grid search to find the best hyperparameter.
How to choose a kernel for kernel PCA?
a bit more hands on answer one way to evaluate is input the kpca output into a supervised model and see if the performance increases, from sklearn.model_selection import GridSearchCV from sklearn.lin
How to choose a kernel for kernel PCA? a bit more hands on answer one way to evaluate is input the kpca output into a supervised model and see if the performance increases, from sklearn.model_selection import GridSearchCV from sklearn.linear_model import LogisticRegression from sklearn.pipeline import Pipeline clf = Pipeline([ ("kpca", KernelPCA(n_components=2)), ("log_reg", LogisticRegression()) ]) param_grid = [{ "kpca__gamma": np.linspace(0.03, 0.05, 10), "kpca__kernel": ["rbf", "sigmoid"] }] grid_search = GridSearchCV(clf, param_grid, cv=3) grid_search.fit(X, y) if you print the best result print(grid_search.best_params_) {'kpca__gamma': 0.043333333333333335, 'kpca__kernel': 'rbf'} another approach would be too look at the reconstruction error meaning you go into lower dimension and then try to reconstruct and calculate the error from the original space rbf_pca = KernelPCA(n_components = 2, kernel="rbf", gamma=0.0433, fit_inverse_transform=True) #make sure fit_inverse_transform is true X_reduced = rbf_pca.fit_transform(X) X_preimage = rbf_pca.inverse_transform(X_reduced) from sklearn.metrics import mean_squared_error mean_squared_error(X, X_preimage) 32.786308795766132 you can use grid search to find the best hyperparameter.
How to choose a kernel for kernel PCA? a bit more hands on answer one way to evaluate is input the kpca output into a supervised model and see if the performance increases, from sklearn.model_selection import GridSearchCV from sklearn.lin
16,782
Confusion related to difference of kriging and gaussian processes
There are some subtle differences between ordinary and simple kriging, maybe that confuses you. GP regression in the way it is usually presented is analogous to simple kriging. In the Gaussian process Wikipedia entry it says that the article refers explicitly to a "zero-meaned distribution"; that is the same assumption found in simple kriging. Also generally speaking kriging is usually performed in a 2 or 3 dimensional spaces, (eg. pollutant concentration along some given area) while most GPR toy examples are one dimensional (eg. $CO_2$ concentration in the atmosphere against time). Ultimately kriging/GPR is an interpolation technique and most (not all) of the difference among the variants of it lays on the assumption about the mean trend $\mu(X)$ (or E[$X_t$] if you like this notation better).
Confusion related to difference of kriging and gaussian processes
There are some subtle differences between ordinary and simple kriging, maybe that confuses you. GP regression in the way it is usually presented is analogous to simple kriging. In the Gaussian proces
Confusion related to difference of kriging and gaussian processes There are some subtle differences between ordinary and simple kriging, maybe that confuses you. GP regression in the way it is usually presented is analogous to simple kriging. In the Gaussian process Wikipedia entry it says that the article refers explicitly to a "zero-meaned distribution"; that is the same assumption found in simple kriging. Also generally speaking kriging is usually performed in a 2 or 3 dimensional spaces, (eg. pollutant concentration along some given area) while most GPR toy examples are one dimensional (eg. $CO_2$ concentration in the atmosphere against time). Ultimately kriging/GPR is an interpolation technique and most (not all) of the difference among the variants of it lays on the assumption about the mean trend $\mu(X)$ (or E[$X_t$] if you like this notation better).
Confusion related to difference of kriging and gaussian processes There are some subtle differences between ordinary and simple kriging, maybe that confuses you. GP regression in the way it is usually presented is analogous to simple kriging. In the Gaussian proces
16,783
Confusion related to difference of kriging and gaussian processes
GPs are known as kriging in geostatistics. To learn about the history of Gaussian Processes watch this video http://youtu.be/4r463NLq0jU?t=26s
Confusion related to difference of kriging and gaussian processes
GPs are known as kriging in geostatistics. To learn about the history of Gaussian Processes watch this video http://youtu.be/4r463NLq0jU?t=26s
Confusion related to difference of kriging and gaussian processes GPs are known as kriging in geostatistics. To learn about the history of Gaussian Processes watch this video http://youtu.be/4r463NLq0jU?t=26s
Confusion related to difference of kriging and gaussian processes GPs are known as kriging in geostatistics. To learn about the history of Gaussian Processes watch this video http://youtu.be/4r463NLq0jU?t=26s
16,784
Confusion related to difference of kriging and gaussian processes
Kriging is a type of Gaussian process that uses a spatial covariance function or kernel. These are some helpful resources : https://arxiv.org/pdf/1708.02663.pdf - talks about gradient enhanced Kriging with PLS but the formulas are the same as Kriging. https://distill.pub/2019/visual-exploration-gaussian-processes/ - explains Gaussian processes and shows effect of various kernels on the covariance matrix.
Confusion related to difference of kriging and gaussian processes
Kriging is a type of Gaussian process that uses a spatial covariance function or kernel. These are some helpful resources : https://arxiv.org/pdf/1708.02663.pdf - talks about gradient enhanced Kriging
Confusion related to difference of kriging and gaussian processes Kriging is a type of Gaussian process that uses a spatial covariance function or kernel. These are some helpful resources : https://arxiv.org/pdf/1708.02663.pdf - talks about gradient enhanced Kriging with PLS but the formulas are the same as Kriging. https://distill.pub/2019/visual-exploration-gaussian-processes/ - explains Gaussian processes and shows effect of various kernels on the covariance matrix.
Confusion related to difference of kriging and gaussian processes Kriging is a type of Gaussian process that uses a spatial covariance function or kernel. These are some helpful resources : https://arxiv.org/pdf/1708.02663.pdf - talks about gradient enhanced Kriging
16,785
How does quantile normalization work?
A comparison of normalization methods for high density oligonucleotide array data based on variance and bias by Bolstad et al. introduces quantile normalization for array data and compares it to other methods. It has a pretty clear description of the algorithm. The conceptual understanding is that it is a transformation of array $j$ using a function $\hat{F}^{-1} \circ \hat{G}_j$ where $\hat{G}_j$ is an estimated distribution function and $\hat{F}^{-1}$ is the inverse of an estimated distribution function. It has the consequence that the normalized distributions become identical for all the arrays. For quantile normalization $\hat{G}_j$ is the empirical distribution of array $j$ and $\hat{F}$ is the empirical distribution for the averaged quantiles across arrays. At the end of the day it is a method for transforming all the arrays to have a common distribution of intensities.
How does quantile normalization work?
A comparison of normalization methods for high density oligonucleotide array data based on variance and bias by Bolstad et al. introduces quantile normalization for array data and compares it to other
How does quantile normalization work? A comparison of normalization methods for high density oligonucleotide array data based on variance and bias by Bolstad et al. introduces quantile normalization for array data and compares it to other methods. It has a pretty clear description of the algorithm. The conceptual understanding is that it is a transformation of array $j$ using a function $\hat{F}^{-1} \circ \hat{G}_j$ where $\hat{G}_j$ is an estimated distribution function and $\hat{F}^{-1}$ is the inverse of an estimated distribution function. It has the consequence that the normalized distributions become identical for all the arrays. For quantile normalization $\hat{G}_j$ is the empirical distribution of array $j$ and $\hat{F}$ is the empirical distribution for the averaged quantiles across arrays. At the end of the day it is a method for transforming all the arrays to have a common distribution of intensities.
How does quantile normalization work? A comparison of normalization methods for high density oligonucleotide array data based on variance and bias by Bolstad et al. introduces quantile normalization for array data and compares it to other
16,786
Why use Normalized Gini Score instead of AUC as evaluation?
I believe that the Gini score is merely a reformulation of the AUC: $$gini = 2 \times AUC -1$$ As for why use this instead of the commonly used AUC, the only reason I can think of is that a random prediction will yield a Gini score of 0 as opposed to the AUC which will be 0.5.
Why use Normalized Gini Score instead of AUC as evaluation?
I believe that the Gini score is merely a reformulation of the AUC: $$gini = 2 \times AUC -1$$ As for why use this instead of the commonly used AUC, the only reason I can think of is that a random pre
Why use Normalized Gini Score instead of AUC as evaluation? I believe that the Gini score is merely a reformulation of the AUC: $$gini = 2 \times AUC -1$$ As for why use this instead of the commonly used AUC, the only reason I can think of is that a random prediction will yield a Gini score of 0 as opposed to the AUC which will be 0.5.
Why use Normalized Gini Score instead of AUC as evaluation? I believe that the Gini score is merely a reformulation of the AUC: $$gini = 2 \times AUC -1$$ As for why use this instead of the commonly used AUC, the only reason I can think of is that a random pre
16,787
Why use Normalized Gini Score instead of AUC as evaluation?
The relationship only holds for classification tasks because obviously, you cannot calculate AUC for a continuous target. However, we also use normalized Gini in regression tasks, like predicting insurance losses.
Why use Normalized Gini Score instead of AUC as evaluation?
The relationship only holds for classification tasks because obviously, you cannot calculate AUC for a continuous target. However, we also use normalized Gini in regression tasks, like predicting insu
Why use Normalized Gini Score instead of AUC as evaluation? The relationship only holds for classification tasks because obviously, you cannot calculate AUC for a continuous target. However, we also use normalized Gini in regression tasks, like predicting insurance losses.
Why use Normalized Gini Score instead of AUC as evaluation? The relationship only holds for classification tasks because obviously, you cannot calculate AUC for a continuous target. However, we also use normalized Gini in regression tasks, like predicting insu
16,788
Why would you predict from a mixed effect model without including random effects for the prediction?
Simple thought experiment: You have measured weight and height of 5 infants after birth. And you measured it from the same babies again after two years. Meanwhile you measured weight and height of your baby daughter almost every week resulting in 100 value pairs for her. If you use a mixed effects model, there is no problem. If you use a fixed effects model you put undue weight on the measurements from your daughter, to a point where you would get almost the same model fit if you used only data from her. So, it's not only important for inference to model repeated measures or uncertainty structures correctly, but also for prediction. In general, you don't get the same predictions from a mixed effects model and from a fixed effects model (with violated assumptions). and I can either include a column for (new) subjects in newdf You can't predict for subjects which were not part of the original (training) data. Again a thought experiment: the new subject is obese. How could the model know that it is at the upper end of the random effects distribution? will the by-subject variance captured in the model simply be ignored (averaged over) for the prediction If I understand you correctly then yes. The model gives you an estimate of the expected value for the population (note that this estimate is still conditional on the original subjects).
Why would you predict from a mixed effect model without including random effects for the prediction?
Simple thought experiment: You have measured weight and height of 5 infants after birth. And you measured it from the same babies again after two years. Meanwhile you measured weight and height of you
Why would you predict from a mixed effect model without including random effects for the prediction? Simple thought experiment: You have measured weight and height of 5 infants after birth. And you measured it from the same babies again after two years. Meanwhile you measured weight and height of your baby daughter almost every week resulting in 100 value pairs for her. If you use a mixed effects model, there is no problem. If you use a fixed effects model you put undue weight on the measurements from your daughter, to a point where you would get almost the same model fit if you used only data from her. So, it's not only important for inference to model repeated measures or uncertainty structures correctly, but also for prediction. In general, you don't get the same predictions from a mixed effects model and from a fixed effects model (with violated assumptions). and I can either include a column for (new) subjects in newdf You can't predict for subjects which were not part of the original (training) data. Again a thought experiment: the new subject is obese. How could the model know that it is at the upper end of the random effects distribution? will the by-subject variance captured in the model simply be ignored (averaged over) for the prediction If I understand you correctly then yes. The model gives you an estimate of the expected value for the population (note that this estimate is still conditional on the original subjects).
Why would you predict from a mixed effect model without including random effects for the prediction? Simple thought experiment: You have measured weight and height of 5 infants after birth. And you measured it from the same babies again after two years. Meanwhile you measured weight and height of you
16,789
Bound on moment generating function
I can't answer the first part of your question, but as for extending it to random variables with nonzero means... First, note that any r.v. $Z$ with finite range $[a+\mu,b+\mu]$ and (necessarily finite) mean $\mu$ can be transformed into an r.v. $X = Z-\mu$ that is, of course, zero mean with range $[a,b]$ (thus satisfying the conditions in your problem statement). The transformed variate has m.g.f. $\phi_X(t) = \exp\{-\mu t\}\phi_Z(t)$ (by basic properties of the m.g.f.) Multiplying both sides by $\exp\{\mu t\}$ and applying the inequality gives: $\phi_Z(t) = \exp\{\mu t\}\phi_X(t) \leq \exp\{\mu t\}\exp\{t^2\sigma^2_\text{max}/2\} = \exp\{\mu t + t^2\sigma^2_\text{max}/2\} $ Not surprisingly, the m.g.f. of a Normal random variable with the same mean and standard deviation equal to $\sigma_\text{max}$.
Bound on moment generating function
I can't answer the first part of your question, but as for extending it to random variables with nonzero means... First, note that any r.v. $Z$ with finite range $[a+\mu,b+\mu]$ and (necessarily finit
Bound on moment generating function I can't answer the first part of your question, but as for extending it to random variables with nonzero means... First, note that any r.v. $Z$ with finite range $[a+\mu,b+\mu]$ and (necessarily finite) mean $\mu$ can be transformed into an r.v. $X = Z-\mu$ that is, of course, zero mean with range $[a,b]$ (thus satisfying the conditions in your problem statement). The transformed variate has m.g.f. $\phi_X(t) = \exp\{-\mu t\}\phi_Z(t)$ (by basic properties of the m.g.f.) Multiplying both sides by $\exp\{\mu t\}$ and applying the inequality gives: $\phi_Z(t) = \exp\{\mu t\}\phi_X(t) \leq \exp\{\mu t\}\exp\{t^2\sigma^2_\text{max}/2\} = \exp\{\mu t + t^2\sigma^2_\text{max}/2\} $ Not surprisingly, the m.g.f. of a Normal random variable with the same mean and standard deviation equal to $\sigma_\text{max}$.
Bound on moment generating function I can't answer the first part of your question, but as for extending it to random variables with nonzero means... First, note that any r.v. $Z$ with finite range $[a+\mu,b+\mu]$ and (necessarily finit
16,790
Bound on moment generating function
Since $e^{ t x}$ is a convex function, by Jensen's inequality, we have $$e^{t X} \le \frac{\sigma+X}{2\sigma}e^{-t\sigma}+ \frac{\sigma-X}{2\sigma}e^{t\sigma}$$ Taking expectation of both sides of above inequality we get $$E[ e^{t X}] \le \frac{1}{2}e^{-t\sigma} + \frac{1}{2}e^{t\sigma}$$ where we used the zero-mean assumption on $X$. It remains to prove that $\frac{1}{2}(e^y+e^{-y})\le e^{y^2/2}$. (Then, replacing $y=t\sigma$ we arrive at $E[ e^{t X}] \le e^{t^2\sigma^2/2}$.) Here is my proof for $$\quad \quad e^y+e^{-y}\le 2 e^{y^2/2} \quad \quad \text{for }y \in \mathbb{R} \quad (1)$$. By Taylor expansion of $e^y$ we have $$e^y + e^{-y} = \sum_{n=0}^{\infty} \frac{y^n}{n!} + \sum_{n=0}^{\infty} \frac{(-1)^ny^n}{n!} =2\sum_{k=0}^{\infty} \frac{y^{2k}}{(2k)!} $$ $$2e^{y^2/2} = 2\sum_{k=0}^{\infty} \frac{y^{2k}}{2^k k!}$$ from which we get (1) since $(2k)! \ge 2^k k!$ (this can be shown by induction or Stirling bounds on k!). س
Bound on moment generating function
Since $e^{ t x}$ is a convex function, by Jensen's inequality, we have $$e^{t X} \le \frac{\sigma+X}{2\sigma}e^{-t\sigma}+ \frac{\sigma-X}{2\sigma}e^{t\sigma}$$ Taking expectation of both side
Bound on moment generating function Since $e^{ t x}$ is a convex function, by Jensen's inequality, we have $$e^{t X} \le \frac{\sigma+X}{2\sigma}e^{-t\sigma}+ \frac{\sigma-X}{2\sigma}e^{t\sigma}$$ Taking expectation of both sides of above inequality we get $$E[ e^{t X}] \le \frac{1}{2}e^{-t\sigma} + \frac{1}{2}e^{t\sigma}$$ where we used the zero-mean assumption on $X$. It remains to prove that $\frac{1}{2}(e^y+e^{-y})\le e^{y^2/2}$. (Then, replacing $y=t\sigma$ we arrive at $E[ e^{t X}] \le e^{t^2\sigma^2/2}$.) Here is my proof for $$\quad \quad e^y+e^{-y}\le 2 e^{y^2/2} \quad \quad \text{for }y \in \mathbb{R} \quad (1)$$. By Taylor expansion of $e^y$ we have $$e^y + e^{-y} = \sum_{n=0}^{\infty} \frac{y^n}{n!} + \sum_{n=0}^{\infty} \frac{(-1)^ny^n}{n!} =2\sum_{k=0}^{\infty} \frac{y^{2k}}{(2k)!} $$ $$2e^{y^2/2} = 2\sum_{k=0}^{\infty} \frac{y^{2k}}{2^k k!}$$ from which we get (1) since $(2k)! \ge 2^k k!$ (this can be shown by induction or Stirling bounds on k!). س
Bound on moment generating function Since $e^{ t x}$ is a convex function, by Jensen's inequality, we have $$e^{t X} \le \frac{\sigma+X}{2\sigma}e^{-t\sigma}+ \frac{\sigma-X}{2\sigma}e^{t\sigma}$$ Taking expectation of both side
16,791
What is the support vector machine?
At the outset, I think it is worth noting that there is a lot of variation in terminology, not only in the referent of the term "support vector machine", but also in the more general term "machine". Usually the term "machine" is used to refer to the algorithm that performs a particular optimisation. However, as you can see from the various quotes in your question, it is often used more loosely to refer either to the optimisation problem, the solution, or the algorithm that computes that solution (or even the combination of all three of these elements). This is somewhat natural, since all three of these things are aspects of the same statistical prediction problem, and it is simple to differentiate these aspects of the problem directly by description. Bearing that caveat in mind, in deciding the proper referent of the term "support vector machine", it is worth tracing the term back through the initial literature. A good starting point for this is Moguerza and Munoz (2006), which gives an overview of support vector machines and their applications. According to this source, the term "support vector" was first used in Cortez and Vapnik (1995), where the authors referred to the "support vector network" as a "learning machine". On p. 275 of the latter paper, the authors explain that the "support vectors" refer to a small number of vectors in the training data that determine the boundaries of the optimal hyperplane in the method. The description of the "support vector network" (a type of "learning machine") is given on p. 276, and this clearly refers to a method ---i.e., an algorithm--- for computing the optimal hyperplane. Moreover, the substantive contribution of the paper is clearly related to the construction of an algorithm to solve a long-standing optimisation problem. This terminology is consistent with the more general practice of using the term "machine" (or "learning machine") to refer to the algorithm that solves a particular learning/optimisation problem. This goes all the way back to Turing machines and other types of conceptual computing machines, which have always been regarded as tools for computing outputs of a problem. Later literature on "support vector machines" appears to have adopted a shortened version of the nomenclature of Cortez and Vapnik (1995), where the terminology of a "support vector network" that is a "learning machine" is concatenated simply to "support vector machine". This historical evolution of the terminology, and the substantive analysis done in that paper, suggest that the "support vector machine" refers to the algorithm that performs the optimisation. Of course, as you have observed, there are some authors who use this terminology loosely, either to refer to the optimisation problem itself, its solution point, or even the whole triumvirate of problem/solution/algorithm.
What is the support vector machine?
At the outset, I think it is worth noting that there is a lot of variation in terminology, not only in the referent of the term "support vector machine", but also in the more general term "machine".
What is the support vector machine? At the outset, I think it is worth noting that there is a lot of variation in terminology, not only in the referent of the term "support vector machine", but also in the more general term "machine". Usually the term "machine" is used to refer to the algorithm that performs a particular optimisation. However, as you can see from the various quotes in your question, it is often used more loosely to refer either to the optimisation problem, the solution, or the algorithm that computes that solution (or even the combination of all three of these elements). This is somewhat natural, since all three of these things are aspects of the same statistical prediction problem, and it is simple to differentiate these aspects of the problem directly by description. Bearing that caveat in mind, in deciding the proper referent of the term "support vector machine", it is worth tracing the term back through the initial literature. A good starting point for this is Moguerza and Munoz (2006), which gives an overview of support vector machines and their applications. According to this source, the term "support vector" was first used in Cortez and Vapnik (1995), where the authors referred to the "support vector network" as a "learning machine". On p. 275 of the latter paper, the authors explain that the "support vectors" refer to a small number of vectors in the training data that determine the boundaries of the optimal hyperplane in the method. The description of the "support vector network" (a type of "learning machine") is given on p. 276, and this clearly refers to a method ---i.e., an algorithm--- for computing the optimal hyperplane. Moreover, the substantive contribution of the paper is clearly related to the construction of an algorithm to solve a long-standing optimisation problem. This terminology is consistent with the more general practice of using the term "machine" (or "learning machine") to refer to the algorithm that solves a particular learning/optimisation problem. This goes all the way back to Turing machines and other types of conceptual computing machines, which have always been regarded as tools for computing outputs of a problem. Later literature on "support vector machines" appears to have adopted a shortened version of the nomenclature of Cortez and Vapnik (1995), where the terminology of a "support vector network" that is a "learning machine" is concatenated simply to "support vector machine". This historical evolution of the terminology, and the substantive analysis done in that paper, suggest that the "support vector machine" refers to the algorithm that performs the optimisation. Of course, as you have observed, there are some authors who use this terminology loosely, either to refer to the optimisation problem itself, its solution point, or even the whole triumvirate of problem/solution/algorithm.
What is the support vector machine? At the outset, I think it is worth noting that there is a lot of variation in terminology, not only in the referent of the term "support vector machine", but also in the more general term "machine".
16,792
What is the support vector machine?
Here is another nice tutorial with python code and mathematical derivations from scratch... http://www.adeveloperdiary.com/data-science/machine-learning/support-vector-machines-for-beginners-linear-svm/
What is the support vector machine?
Here is another nice tutorial with python code and mathematical derivations from scratch... http://www.adeveloperdiary.com/data-science/machine-learning/support-vector-machines-for-beginners-linear-s
What is the support vector machine? Here is another nice tutorial with python code and mathematical derivations from scratch... http://www.adeveloperdiary.com/data-science/machine-learning/support-vector-machines-for-beginners-linear-svm/
What is the support vector machine? Here is another nice tutorial with python code and mathematical derivations from scratch... http://www.adeveloperdiary.com/data-science/machine-learning/support-vector-machines-for-beginners-linear-s
16,793
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
It sounds to me like you're on the right track, but maybe I can help clarify. Single output Let's imagine a traditional neural network layer with $n$ input units and 1 output (let's also assume no bias). This layer has a vector of weights $w\in\mathbb{R}^n$ that can be learned using various methods (backprop, genetic algorithms, etc.), but we'll ignore the learning and just focus on the forward propagation. The layer takes an input $x\in\mathbb{R}^n$ and maps it to an activation $a\in\mathbb{R}$ by computing the dot product of $x$ with $w$ and then applying a nonlinearity $\sigma$: $$ a = \sigma(x\cdot w) $$ Here, the elements of $w$ specify how much to weight the corresponding elements of $x$ to compute the overall activation of the output unit. You could even think of this like a "convolution" where the input signal ($x$) is the same length as the filter ($w$). In a convolutional setting, there are more values in $x$ than in $w$; suppose now our input $x\in\mathbb{R}^m$ for $m>n$. We can compute the activation of the output unit in this setting by computing the dot product of $w$ with contiguous subsets of $x$: $$\begin{eqnarray*} a_1 &=& \sigma(x_{1:n} \cdot w) \\ a_2 &=& \sigma(x_{2:n+1} \cdot w) \\ a_3 &=& \sigma(x_{3:n+2} \cdot w) \\ \dots \\ a_{m-n+1} &=& \sigma(x_{m-n+1:m} \cdot w) \end{eqnarray*}$$ (Here I'm repeating the same annoying confusion between cross-correlation and convolution that many neural nets authors make; if we were to make these proper convolutions, we'd flip the elements of $w$. I'm also assuming a "valid" convolution which only retains computed elements where the input signal and the filter overlap completely, i.e., without any padding.) You already put this in your question basically, but I'm trying to walk through the connection with vanilla neural network layers using the dot product to make a point. The main difference with vanilla network layers is that if the input vector is longer than the weight vector, a convolution turns the output of the network layer into a vector -- in convolution networks, it's vectors all the way down! This output vector is called a "feature map" for the output unit in this layer. Multiple outputs Ok, so let's imagine that we add a new output to our network layer, so that it has $n$ inputs and 2 outputs. There will be a vector $w^1\in\mathbb{R}^n$ for the first output, and a vector $w^2\in\mathbb{R}^n$ for the second output. (I'm using superscripts to denote layer outputs.) For a vanilla layer, these are normally stacked together into a matrix $W = [w^1 w^2]$ where the individual weight vectors are the columns of the matrix. Then when computing the output of this layer, we compute $$\begin{eqnarray*} a^1 &=& \sigma(x \cdot w^1) \\ a^2 &=& \sigma(x \cdot w^2) \end{eqnarray*}$$ or in shorter matrix notation, $$a = [a^1 a^2] = \sigma(x \cdot W)$$ where the nonlinearity is applied elementwise. In the convolutional case, the outputs of our layer are still associated with the same parameter vectors $w^1$ and $w^2$. Just like in the single-output case, the convolution layer generates vector-valued outputs for each layer output, so there's $a^1 = [a^1_1 a^1_2 \dots a^1_{m-n+1}]$ and $a^2 = [a^2_1 a^2_2 \dots a^2_{m-n+1}]$ (again assuming "valid" convolutions). These filter maps, one for each layer output, are commonly stacked together into a matrix $A = [a^1 a^2]$. If you think of it, the input in the convolutional case could also be thought of as a matrix, containing just one column ("one input channel"). So we could write the transformation for this layer as $$A = \sigma(X * W)$$ where the "convolution" is actually a cross-correlation and happens only along the columns of $X$ and $W$. These notation shortcuts are actually quite helpful, because now it's easy to see that to add another output to the layer, we just add another column of weights to $W$. Hopefully that's helpful!
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
It sounds to me like you're on the right track, but maybe I can help clarify. Single output Let's imagine a traditional neural network layer with $n$ input units and 1 output (let's also assume no bia
How exactly do convolutional neural networks use convolution in place of matrix multiplication? It sounds to me like you're on the right track, but maybe I can help clarify. Single output Let's imagine a traditional neural network layer with $n$ input units and 1 output (let's also assume no bias). This layer has a vector of weights $w\in\mathbb{R}^n$ that can be learned using various methods (backprop, genetic algorithms, etc.), but we'll ignore the learning and just focus on the forward propagation. The layer takes an input $x\in\mathbb{R}^n$ and maps it to an activation $a\in\mathbb{R}$ by computing the dot product of $x$ with $w$ and then applying a nonlinearity $\sigma$: $$ a = \sigma(x\cdot w) $$ Here, the elements of $w$ specify how much to weight the corresponding elements of $x$ to compute the overall activation of the output unit. You could even think of this like a "convolution" where the input signal ($x$) is the same length as the filter ($w$). In a convolutional setting, there are more values in $x$ than in $w$; suppose now our input $x\in\mathbb{R}^m$ for $m>n$. We can compute the activation of the output unit in this setting by computing the dot product of $w$ with contiguous subsets of $x$: $$\begin{eqnarray*} a_1 &=& \sigma(x_{1:n} \cdot w) \\ a_2 &=& \sigma(x_{2:n+1} \cdot w) \\ a_3 &=& \sigma(x_{3:n+2} \cdot w) \\ \dots \\ a_{m-n+1} &=& \sigma(x_{m-n+1:m} \cdot w) \end{eqnarray*}$$ (Here I'm repeating the same annoying confusion between cross-correlation and convolution that many neural nets authors make; if we were to make these proper convolutions, we'd flip the elements of $w$. I'm also assuming a "valid" convolution which only retains computed elements where the input signal and the filter overlap completely, i.e., without any padding.) You already put this in your question basically, but I'm trying to walk through the connection with vanilla neural network layers using the dot product to make a point. The main difference with vanilla network layers is that if the input vector is longer than the weight vector, a convolution turns the output of the network layer into a vector -- in convolution networks, it's vectors all the way down! This output vector is called a "feature map" for the output unit in this layer. Multiple outputs Ok, so let's imagine that we add a new output to our network layer, so that it has $n$ inputs and 2 outputs. There will be a vector $w^1\in\mathbb{R}^n$ for the first output, and a vector $w^2\in\mathbb{R}^n$ for the second output. (I'm using superscripts to denote layer outputs.) For a vanilla layer, these are normally stacked together into a matrix $W = [w^1 w^2]$ where the individual weight vectors are the columns of the matrix. Then when computing the output of this layer, we compute $$\begin{eqnarray*} a^1 &=& \sigma(x \cdot w^1) \\ a^2 &=& \sigma(x \cdot w^2) \end{eqnarray*}$$ or in shorter matrix notation, $$a = [a^1 a^2] = \sigma(x \cdot W)$$ where the nonlinearity is applied elementwise. In the convolutional case, the outputs of our layer are still associated with the same parameter vectors $w^1$ and $w^2$. Just like in the single-output case, the convolution layer generates vector-valued outputs for each layer output, so there's $a^1 = [a^1_1 a^1_2 \dots a^1_{m-n+1}]$ and $a^2 = [a^2_1 a^2_2 \dots a^2_{m-n+1}]$ (again assuming "valid" convolutions). These filter maps, one for each layer output, are commonly stacked together into a matrix $A = [a^1 a^2]$. If you think of it, the input in the convolutional case could also be thought of as a matrix, containing just one column ("one input channel"). So we could write the transformation for this layer as $$A = \sigma(X * W)$$ where the "convolution" is actually a cross-correlation and happens only along the columns of $X$ and $W$. These notation shortcuts are actually quite helpful, because now it's easy to see that to add another output to the layer, we just add another column of weights to $W$. Hopefully that's helpful!
How exactly do convolutional neural networks use convolution in place of matrix multiplication? It sounds to me like you're on the right track, but maybe I can help clarify. Single output Let's imagine a traditional neural network layer with $n$ input units and 1 output (let's also assume no bia
16,794
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
A convolutional layer is a strict subset of a fully connected network, ie a matrix multiplication. A convolutional layer in the forward pass is in fact equivalent to a matrix multiplication where: some weights are tied/shared some weights are zero In the backward pass, the weights will be updated in accordance with which weights have contributed how much in the forward pass. ie, the weights which were zero are still zero. The weights which were tied across multiple outputs will receive gradient from all of those outputs (which gradients are summed together, to produce the final gradient update for that weight).
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
A convolutional layer is a strict subset of a fully connected network, ie a matrix multiplication. A convolutional layer in the forward pass is in fact equivalent to a matrix multiplication where: so
How exactly do convolutional neural networks use convolution in place of matrix multiplication? A convolutional layer is a strict subset of a fully connected network, ie a matrix multiplication. A convolutional layer in the forward pass is in fact equivalent to a matrix multiplication where: some weights are tied/shared some weights are zero In the backward pass, the weights will be updated in accordance with which weights have contributed how much in the forward pass. ie, the weights which were zero are still zero. The weights which were tied across multiple outputs will receive gradient from all of those outputs (which gradients are summed together, to produce the final gradient update for that weight).
How exactly do convolutional neural networks use convolution in place of matrix multiplication? A convolutional layer is a strict subset of a fully connected network, ie a matrix multiplication. A convolutional layer in the forward pass is in fact equivalent to a matrix multiplication where: so
16,795
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
No, that is not how it is supposed to work. The convolution operation always make the input smaller (for filters with size > 1), not larger as in your example. It is simply an elementwise multiplication. When doing convolution on the first 3 elements of the input, the output would be $1∗5+2∗6+3∗7=38$. (see deeplearning.stanford.edu for an example)
How exactly do convolutional neural networks use convolution in place of matrix multiplication?
No, that is not how it is supposed to work. The convolution operation always make the input smaller (for filters with size > 1), not larger as in your example. It is simply an elementwise multiplicati
How exactly do convolutional neural networks use convolution in place of matrix multiplication? No, that is not how it is supposed to work. The convolution operation always make the input smaller (for filters with size > 1), not larger as in your example. It is simply an elementwise multiplication. When doing convolution on the first 3 elements of the input, the output would be $1∗5+2∗6+3∗7=38$. (see deeplearning.stanford.edu for an example)
How exactly do convolutional neural networks use convolution in place of matrix multiplication? No, that is not how it is supposed to work. The convolution operation always make the input smaller (for filters with size > 1), not larger as in your example. It is simply an elementwise multiplicati
16,796
Machine learning algorithms for panel data
When you have panel data, there are a different tasks that you can try to solve, e.g. time series classification/regression or panel forecasting. And for each task, there are numerous approaches to solve it. When you want to use machine learning methods to solve panel forecasting, there are a number of approaches: Regarding your input data (X), treating units (e.g. countries, individuals, etc) as i.i.d. samples, you can bin the time series and treat each bin as a separate column, ignoring any temporal ordering, with equal bins for all units, the bin size could of course simply be the observed time series measurement, or you could upsample and aggregate into larger bins, then use standard machine learning algorithms for tabular data, or extract features from the time series for each unit, and use each extracted feature as a separate columns, again combined with standard tabular algorithms, or use specialised time series regression/classification algorithms depending on whether you observe continuous or categorical time series data, this includes support vector machines with special kernels that compare time series with time series. Regarding your output data (y), if you want to forecast multiple time points in the future, you can fit an estimator for each step ahead that you want to forecast, always using the same input data, or fit a single estimator for the first step ahead and in prediction, roll the input data in time, using the first step predictions to append to the observed input data to make the second step predictions and so on. All of the approaches above basically reduce the panel forecasting problem to a time series regression or tabular regression problem. Once your data is in the time series or tabular regression format, you can also append any time-invariant features for users. Of course there are other options to solve the panel forecasting problem, like for example using classical forecasting methods like ARIMA adapted to panel data or deep learning methods that allow you to directly make sequence to sequence predictions.
Machine learning algorithms for panel data
When you have panel data, there are a different tasks that you can try to solve, e.g. time series classification/regression or panel forecasting. And for each task, there are numerous approaches to so
Machine learning algorithms for panel data When you have panel data, there are a different tasks that you can try to solve, e.g. time series classification/regression or panel forecasting. And for each task, there are numerous approaches to solve it. When you want to use machine learning methods to solve panel forecasting, there are a number of approaches: Regarding your input data (X), treating units (e.g. countries, individuals, etc) as i.i.d. samples, you can bin the time series and treat each bin as a separate column, ignoring any temporal ordering, with equal bins for all units, the bin size could of course simply be the observed time series measurement, or you could upsample and aggregate into larger bins, then use standard machine learning algorithms for tabular data, or extract features from the time series for each unit, and use each extracted feature as a separate columns, again combined with standard tabular algorithms, or use specialised time series regression/classification algorithms depending on whether you observe continuous or categorical time series data, this includes support vector machines with special kernels that compare time series with time series. Regarding your output data (y), if you want to forecast multiple time points in the future, you can fit an estimator for each step ahead that you want to forecast, always using the same input data, or fit a single estimator for the first step ahead and in prediction, roll the input data in time, using the first step predictions to append to the observed input data to make the second step predictions and so on. All of the approaches above basically reduce the panel forecasting problem to a time series regression or tabular regression problem. Once your data is in the time series or tabular regression format, you can also append any time-invariant features for users. Of course there are other options to solve the panel forecasting problem, like for example using classical forecasting methods like ARIMA adapted to panel data or deep learning methods that allow you to directly make sequence to sequence predictions.
Machine learning algorithms for panel data When you have panel data, there are a different tasks that you can try to solve, e.g. time series classification/regression or panel forecasting. And for each task, there are numerous approaches to so
16,797
Machine learning algorithms for panel data
LSTM (Long Short Term Memory) might be relevant for you. This type of model can handle multiple features in multiple points in time, which should fit panel data. Here is a very nice explanation on the concept of LSTM, and here is a package that implements an R version of LSTM.
Machine learning algorithms for panel data
LSTM (Long Short Term Memory) might be relevant for you. This type of model can handle multiple features in multiple points in time, which should fit panel data. Here is a very nice explanation on the
Machine learning algorithms for panel data LSTM (Long Short Term Memory) might be relevant for you. This type of model can handle multiple features in multiple points in time, which should fit panel data. Here is a very nice explanation on the concept of LSTM, and here is a package that implements an R version of LSTM.
Machine learning algorithms for panel data LSTM (Long Short Term Memory) might be relevant for you. This type of model can handle multiple features in multiple points in time, which should fit panel data. Here is a very nice explanation on the
16,798
Why does the scikit-learn bootstrap function resample the test set?
Bootstrap samples are used to evaluate the performance of the algorithm by many iterations. While doing so, the performance on randomly changed sets is evaluated. In contrast when doing for example 10 Fold Cross Validation you are performing only 10 iterations on different train and test data sets. Now when your sample size is small, lets say $n=20$ and the number of bootstrap iterations is high, lets choose $i=10,000$, and you do not resample your test data as you do with your train data set you will have situations where your algorithm sees the same or very similar test more than one time. A situation you originally wanted to avoid by using bootstrap. The link you postet is down, so I added the description of the function in the current (0.14) version of sklearn Description of the method Random sampling with replacement cross-validation iterator Provides train/test indices to split data in train test sets while resampling the input n_iter times: each time a new random split of the data is performed and then samples are drawn (with replacement) on each side of the split to build the training and test sets. Note: contrary to other cross-validation strategies, bootstrapping will allow some samples to occur several times in each splits. However a sample that occurs in the train split will never occur in the test split and vice-versa. If you want each sample to occur at most once you should probably use ShuffleSplit cross validation instead.
Why does the scikit-learn bootstrap function resample the test set?
Bootstrap samples are used to evaluate the performance of the algorithm by many iterations. While doing so, the performance on randomly changed sets is evaluated. In contrast when doing for example 10
Why does the scikit-learn bootstrap function resample the test set? Bootstrap samples are used to evaluate the performance of the algorithm by many iterations. While doing so, the performance on randomly changed sets is evaluated. In contrast when doing for example 10 Fold Cross Validation you are performing only 10 iterations on different train and test data sets. Now when your sample size is small, lets say $n=20$ and the number of bootstrap iterations is high, lets choose $i=10,000$, and you do not resample your test data as you do with your train data set you will have situations where your algorithm sees the same or very similar test more than one time. A situation you originally wanted to avoid by using bootstrap. The link you postet is down, so I added the description of the function in the current (0.14) version of sklearn Description of the method Random sampling with replacement cross-validation iterator Provides train/test indices to split data in train test sets while resampling the input n_iter times: each time a new random split of the data is performed and then samples are drawn (with replacement) on each side of the split to build the training and test sets. Note: contrary to other cross-validation strategies, bootstrapping will allow some samples to occur several times in each splits. However a sample that occurs in the train split will never occur in the test split and vice-versa. If you want each sample to occur at most once you should probably use ShuffleSplit cross validation instead.
Why does the scikit-learn bootstrap function resample the test set? Bootstrap samples are used to evaluate the performance of the algorithm by many iterations. While doing so, the performance on randomly changed sets is evaluated. In contrast when doing for example 10
16,799
Why does the scikit-learn bootstrap function resample the test set?
Perhaps you were onto something. It seems others pulled at that same thread and Bootstrap was deprecated in favor of more intentional use of the resample method with the tried and true sklearn.cross_validation approaches like StratifiedKFold.
Why does the scikit-learn bootstrap function resample the test set?
Perhaps you were onto something. It seems others pulled at that same thread and Bootstrap was deprecated in favor of more intentional use of the resample method with the tried and true sklearn.cross_v
Why does the scikit-learn bootstrap function resample the test set? Perhaps you were onto something. It seems others pulled at that same thread and Bootstrap was deprecated in favor of more intentional use of the resample method with the tried and true sklearn.cross_validation approaches like StratifiedKFold.
Why does the scikit-learn bootstrap function resample the test set? Perhaps you were onto something. It seems others pulled at that same thread and Bootstrap was deprecated in favor of more intentional use of the resample method with the tried and true sklearn.cross_v
16,800
Statistics is a machine ... quote
Title Statistical Design Springer Texts in Statistics Author George Casella Edition illustrated Publisher Springer, 2008 ISBN 0387759654, 9780387759654 ... makes reference to this simile in the first page of the Preface. He cites Fisher, 1947. I only have google books access, and the reference section is excluded from the Casella reference above. So, I was not able to track down which Fisher, 1947 but one imagines it is in The design of experiments.
Statistics is a machine ... quote
Title Statistical Design Springer Texts in Statistics Author George Casella Edition illustrated Publisher Springer, 2008 ISBN 0387759654, 9780387759654 ... makes reference to this simile in t
Statistics is a machine ... quote Title Statistical Design Springer Texts in Statistics Author George Casella Edition illustrated Publisher Springer, 2008 ISBN 0387759654, 9780387759654 ... makes reference to this simile in the first page of the Preface. He cites Fisher, 1947. I only have google books access, and the reference section is excluded from the Casella reference above. So, I was not able to track down which Fisher, 1947 but one imagines it is in The design of experiments.
Statistics is a machine ... quote Title Statistical Design Springer Texts in Statistics Author George Casella Edition illustrated Publisher Springer, 2008 ISBN 0387759654, 9780387759654 ... makes reference to this simile in t