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
29,001
Is it safe to run 2 or more RStudio sessions simultaneously? [closed]
Open up your process explorer, do you see two copies of R studio (or R itself) running? If so, than your operating system has allocated separate memory spaces for the two copies of R studio, in which case you are perfectly safe. In general, you have to do lots of work to share memory, and most well written programs will do their best to protect you from the risks of doing so.
Is it safe to run 2 or more RStudio sessions simultaneously? [closed]
Open up your process explorer, do you see two copies of R studio (or R itself) running? If so, than your operating system has allocated separate memory spaces for the two copies of R studio, in which
Is it safe to run 2 or more RStudio sessions simultaneously? [closed] Open up your process explorer, do you see two copies of R studio (or R itself) running? If so, than your operating system has allocated separate memory spaces for the two copies of R studio, in which case you are perfectly safe. In general, you have to do lots of work to share memory, and most well written programs will do their best to protect you from the risks of doing so.
Is it safe to run 2 or more RStudio sessions simultaneously? [closed] Open up your process explorer, do you see two copies of R studio (or R itself) running? If so, than your operating system has allocated separate memory spaces for the two copies of R studio, in which
29,002
Definition of complexity of a tree in xgboost
This makes sense to me. I'll focus on the Gaussian case. Here each tree $T_i$ is fit on the residuals of the current model, and the model update is $M_{i+1} = M_{i} + \alpha T_i$. The idea of a gradient booster is to carefully and slowly reduce the bias of the model by adding these trees one by one. In this case, a large value of $w_i$ would correspond to a terminal (leaf) node giving a very large and significant update to the prior model. The idea of the regularization term is to minimize these incidents of large single tree updates (only allowing them if the decrease in the model loss function is large enough to offset the regularization penalty). If such an update is regularized away for a single tree, but turns out to be justified, it will be baked in over multiple model updates, in accordance with the philosophy of boosting. This is in very close analogy to ridge regression.
Definition of complexity of a tree in xgboost
This makes sense to me. I'll focus on the Gaussian case. Here each tree $T_i$ is fit on the residuals of the current model, and the model update is $M_{i+1} = M_{i} + \alpha T_i$. The idea of a grad
Definition of complexity of a tree in xgboost This makes sense to me. I'll focus on the Gaussian case. Here each tree $T_i$ is fit on the residuals of the current model, and the model update is $M_{i+1} = M_{i} + \alpha T_i$. The idea of a gradient booster is to carefully and slowly reduce the bias of the model by adding these trees one by one. In this case, a large value of $w_i$ would correspond to a terminal (leaf) node giving a very large and significant update to the prior model. The idea of the regularization term is to minimize these incidents of large single tree updates (only allowing them if the decrease in the model loss function is large enough to offset the regularization penalty). If such an update is regularized away for a single tree, but turns out to be justified, it will be baked in over multiple model updates, in accordance with the philosophy of boosting. This is in very close analogy to ridge regression.
Definition of complexity of a tree in xgboost This makes sense to me. I'll focus on the Gaussian case. Here each tree $T_i$ is fit on the residuals of the current model, and the model update is $M_{i+1} = M_{i} + \alpha T_i$. The idea of a grad
29,003
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
The breakpoints in the domain make it somewhat messy. A simple but tedious approach is to build up to the final result. For $n=3,$ let $Y=X_2 + X_3,$ $W = {{X_2 + X_3} \over X_1},$ and $T = 1 + W.$ Then $Z = {{1} \over {T}}={{X_1} \over {X_1 + X_2 + X_3}}.$ The breakpoints are at 1 for $Y,$ 1 and 2 for $W,$ 2 and 3 for $T,$ and $1/3$ and $1/2$ for $Z.$ I found the complete pdf to be $$f(z) = \begin{cases} \ \ \ \ \ {{1} \over {(1-z)^2}} \ , & \text{if} \ {0} \leq z \leq {1/3} \\\\ {{3z^3-9z^2+6z-1} \over {3z^3(1-z)^2}} \ , & \text{if} \ {1/3} \leq z \leq {1/2} \\\\ \ \ \ \ \ \ \ {{1-z} \over {3z^3}} \ , & \text{if} \ {1/2} \leq z \leq {1} \end{cases}$$ The cdf can then be found as $$F(z) = \begin{cases} \ \ \ \ \ \ \ \ \ \ \ {{z} \over {(1-z)}} \ , & \text{if} \ {0} \leq z \leq {1/3} \\\\ {{1} \over {2}}+{{-18z^3+24z^2-9z+1} \over {6z^2(1-z)}} \ , & \text{if} \ {1/3} \leq z \leq {1/2} \\\\ \ \ \ \ \ \ \ \ {{5} \over {6}} + {{2z-1} \over {6z^2}} \ , & \text{if} \ {1/2} \leq z \leq {1} \end{cases}$$
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
The breakpoints in the domain make it somewhat messy. A simple but tedious approach is to build up to the final result. For $n=3,$ let $Y=X_2 + X_3,$ $W = {{X_2 + X_3} \over X_1},$ and $T = 1 + W.$ Th
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? The breakpoints in the domain make it somewhat messy. A simple but tedious approach is to build up to the final result. For $n=3,$ let $Y=X_2 + X_3,$ $W = {{X_2 + X_3} \over X_1},$ and $T = 1 + W.$ Then $Z = {{1} \over {T}}={{X_1} \over {X_1 + X_2 + X_3}}.$ The breakpoints are at 1 for $Y,$ 1 and 2 for $W,$ 2 and 3 for $T,$ and $1/3$ and $1/2$ for $Z.$ I found the complete pdf to be $$f(z) = \begin{cases} \ \ \ \ \ {{1} \over {(1-z)^2}} \ , & \text{if} \ {0} \leq z \leq {1/3} \\\\ {{3z^3-9z^2+6z-1} \over {3z^3(1-z)^2}} \ , & \text{if} \ {1/3} \leq z \leq {1/2} \\\\ \ \ \ \ \ \ \ {{1-z} \over {3z^3}} \ , & \text{if} \ {1/2} \leq z \leq {1} \end{cases}$$ The cdf can then be found as $$F(z) = \begin{cases} \ \ \ \ \ \ \ \ \ \ \ {{z} \over {(1-z)}} \ , & \text{if} \ {0} \leq z \leq {1/3} \\\\ {{1} \over {2}}+{{-18z^3+24z^2-9z+1} \over {6z^2(1-z)}} \ , & \text{if} \ {1/3} \leq z \leq {1/2} \\\\ \ \ \ \ \ \ \ \ {{5} \over {6}} + {{2z-1} \over {6z^2}} \ , & \text{if} \ {1/2} \leq z \leq {1} \end{cases}$$
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? The breakpoints in the domain make it somewhat messy. A simple but tedious approach is to build up to the final result. For $n=3,$ let $Y=X_2 + X_3,$ $W = {{X_2 + X_3} \over X_1},$ and $T = 1 + W.$ Th
29,004
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Let $Y=\sum_{i=2}^n X_i$. We can find the cdf of $X_1/\sum_{i=1}^n X_i$ by calculating \begin{align*} P(\frac{X_1}{\sum_{i=1}^n X_i} \leq t) &= P(X_1 \leq t\sum_{i=1}^n X_i) \\ &= P((1-t)X_1 \leq t\sum_{i=2}^n X_i) \\ &= P(X_1 \leq \frac t{1-t}Y)\\ &= \int_0^1 P(x_1 \leq \frac t{1-t}Y)\ dx_1\\ &= \int_0^1 (1-F_Y(\frac{1-t}{t}x_1))\ dx_1\\ &= 1-\int_0^1 F_Y(\frac{1-t}{t}x_1)\ dx_1\\ \end{align*} We then differentiate and substitute the Irwin-Hall pdf to obtain the desired pdf: \begin{align*} f(t) &= \int_0^1 f_Y(\frac{1-t}{t}x_1)\cdot \frac{x_1}{t^2}\ dx_1\\ &= \frac{1}{t^2}\int_0^{1\wedge \frac{(n-1)t}{1-t}} \sum_{k=0}^{\lfloor \frac{1-t}{t}x_1\rfloor}\frac1{(n-2)!}(-1)^k\binom{n-1}k(\frac{1-t}{t}x_1-k)^{n-1} x_1\ dx_1 \end{align*} From here it gets a little messy, but you should be able to interchange the integral and summation and then perform a substitution (e.g, $u=\frac{tx_1}{1-t}-k$) to evaluate the integral and hence obtain an explicit formula for the pdf.
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Let $Y=\sum_{i=2}^n X_i$. We can find the cdf of $X_1/\sum_{i=1}^n X_i$ by calculating \begin{align*} P(\frac{X_1}{\sum_{i=1}^n X_i} \leq t) &= P(X_1 \leq t\sum_{i=1}^n X_i) \\ &= P((1-t)X_1 \leq t\su
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Let $Y=\sum_{i=2}^n X_i$. We can find the cdf of $X_1/\sum_{i=1}^n X_i$ by calculating \begin{align*} P(\frac{X_1}{\sum_{i=1}^n X_i} \leq t) &= P(X_1 \leq t\sum_{i=1}^n X_i) \\ &= P((1-t)X_1 \leq t\sum_{i=2}^n X_i) \\ &= P(X_1 \leq \frac t{1-t}Y)\\ &= \int_0^1 P(x_1 \leq \frac t{1-t}Y)\ dx_1\\ &= \int_0^1 (1-F_Y(\frac{1-t}{t}x_1))\ dx_1\\ &= 1-\int_0^1 F_Y(\frac{1-t}{t}x_1)\ dx_1\\ \end{align*} We then differentiate and substitute the Irwin-Hall pdf to obtain the desired pdf: \begin{align*} f(t) &= \int_0^1 f_Y(\frac{1-t}{t}x_1)\cdot \frac{x_1}{t^2}\ dx_1\\ &= \frac{1}{t^2}\int_0^{1\wedge \frac{(n-1)t}{1-t}} \sum_{k=0}^{\lfloor \frac{1-t}{t}x_1\rfloor}\frac1{(n-2)!}(-1)^k\binom{n-1}k(\frac{1-t}{t}x_1-k)^{n-1} x_1\ dx_1 \end{align*} From here it gets a little messy, but you should be able to interchange the integral and summation and then perform a substitution (e.g, $u=\frac{tx_1}{1-t}-k$) to evaluate the integral and hence obtain an explicit formula for the pdf.
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Let $Y=\sum_{i=2}^n X_i$. We can find the cdf of $X_1/\sum_{i=1}^n X_i$ by calculating \begin{align*} P(\frac{X_1}{\sum_{i=1}^n X_i} \leq t) &= P(X_1 \leq t\sum_{i=1}^n X_i) \\ &= P((1-t)X_1 \leq t\su
29,005
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Assuming "the N uniform distributions don't sum to 1." This is how I started(it's incomplete): Consider $Y = \sum_{i=1}^n X_i$ and let $X=X_i$ by a slight abuse of notation. Consider, $U = \frac{X}{Y}$ and $V =Y$: $$ X=UV\\ Y=V $$ Then following transformation of variables: $$ J = \begin{bmatrix} V & U\\ 0 & 1 \end{bmatrix} $$ The joint probability function of $(U,V)$ is given by: $f_{U,V}(u,v) = f_{X,Y}(uv,v)|J|$ Where $X \sim U(0,1)$ and $Y \sim IrwinHall$ $$ f_X(x) = \begin{cases} 1 & 0 \leq x\leq 1\\ 0 & otherwise \end{cases} $$ And, $$ f_Y(y) = \frac{1}{2(n-1)!}\sum_{k=0}^n(-1)^k {n\choose k}(x-k)^{n-1} sign(x-k) $$ Thus, $$ f_{U,V}(u,v) = \begin{cases} \frac{1}{2(n-1)!}\sum_{k=0}^n(-1)^k {n\choose k}(uv-k)^{n-1} sign(uv-k) & 0 \leq uv \leq 1\\ 0 & otherwise \end{cases} $$ and $f_U(u) = \int f_{U,V}(u,v) dv$
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Assuming "the N uniform distributions don't sum to 1." This is how I started(it's incomplete): Consider $Y = \sum_{i=1}^n X_i$ and let $X=X_i$ by a slight abuse of notation. Consider, $U = \frac{X}
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Assuming "the N uniform distributions don't sum to 1." This is how I started(it's incomplete): Consider $Y = \sum_{i=1}^n X_i$ and let $X=X_i$ by a slight abuse of notation. Consider, $U = \frac{X}{Y}$ and $V =Y$: $$ X=UV\\ Y=V $$ Then following transformation of variables: $$ J = \begin{bmatrix} V & U\\ 0 & 1 \end{bmatrix} $$ The joint probability function of $(U,V)$ is given by: $f_{U,V}(u,v) = f_{X,Y}(uv,v)|J|$ Where $X \sim U(0,1)$ and $Y \sim IrwinHall$ $$ f_X(x) = \begin{cases} 1 & 0 \leq x\leq 1\\ 0 & otherwise \end{cases} $$ And, $$ f_Y(y) = \frac{1}{2(n-1)!}\sum_{k=0}^n(-1)^k {n\choose k}(x-k)^{n-1} sign(x-k) $$ Thus, $$ f_{U,V}(u,v) = \begin{cases} \frac{1}{2(n-1)!}\sum_{k=0}^n(-1)^k {n\choose k}(uv-k)^{n-1} sign(uv-k) & 0 \leq uv \leq 1\\ 0 & otherwise \end{cases} $$ and $f_U(u) = \int f_{U,V}(u,v) dv$
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Assuming "the N uniform distributions don't sum to 1." This is how I started(it's incomplete): Consider $Y = \sum_{i=1}^n X_i$ and let $X=X_i$ by a slight abuse of notation. Consider, $U = \frac{X}
29,006
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Suppose we already know sum of $U(0,1)$ has a Irwin-Hall distribution. Now your question changes to find the pdf (or CDF) of $\frac{X}{Y}$ when X had a $U(0,1)$ distribution and $Y$ has a Irwin-Hall distribution. First we need to find he joint pdf of $X$ and $Y$. Let $Y_1=X_1\\Y_2=X_1+X_2\\Y_3=X_1+X_2+X_3$ Then $X_1=Y_1\\X_2=Y_2-Y_1\\X_3=Y_3-Y_2-Y_1$ $\therefore$ $J=\begin{vmatrix} \frac{\partial X_1}{\partial Y_1} & \frac{\partial X_1}{\partial Y_2} &\frac{\partial X_1}{\partial Y_3} \\ \frac{\partial X_2}{\partial Y_1} & \frac{\partial X_2}{\partial Y_2} &\frac{\partial X_2}{\partial Y_3} \\ \frac{\partial X_3}{\partial Y_1} & \frac{\partial X_3}{\partial Y_2} &\frac{\partial X_3}{\partial Y_3} \end{vmatrix}=-1$ Since $X_1, X_2, X_3$ are i.i.d with $U(0,1),$ therefore, $f(x_1,x_2,x_3)=f(x_1)f(x_2)f(x_3)=1$ The joint distribution with $y_1,y_2,y_3$ is $g(y_1,y_2,y_3)=f(y_1,y_2,y_3)|J|=1$ Next let us integrate out the $Y_2$ and we can get the joint distribution of $Y_1$ and $Y_3$ i.e the joint distribution of $X_1$ and $X_1+X_2+X_3$ As suggested by whuber now I changed the the limits $$h(y_1,y_3)=\int_{y_1+1}^{y_3-1} g(y_1,y_2,y_3)dy_2=\int_{y_1+1}^{y_3-1} 1 dy_2=y_3-y_1-2 \tag{1}$$ Now, we know the joint pdf of $X,Y$ i.e joint pdf $X_1$ and $X_1+X_2+X_3$ is $y_3-y_1-2$. Next let find the pdf of $\frac{X}{Y}$ We need another transformation: Let $Y_1=X\\Y_2=\frac{X}{Y}$ Then $X=Y_1\\Y=\frac{Y_1}{Y_2}$ Then $J=\begin{vmatrix} \frac{\partial x}{\partial y_1} & \frac{\partial x}{\partial y_2}\\ \frac{\partial y}{\partial y_1} & \frac{\partial y}{\partial y_2} \end{vmatrix}= \begin{vmatrix} 1 & 0\\ \frac{1}{y_2} & -\frac{y_1}{y_2^2} \end{vmatrix}=-\frac{y_1}{y_2^2}$ we already the joint distribution of $X,Y$ from above steps ref (1). $\therefore$ $g_2(y_1,y_2)=h(y_1,y_3)|J|=(y_3-y_1-2)\frac{y_1}{y_2^2}$ Next, we integrate the $y_1$ out we get the pdf of $y_2$ then we get the pdf of $\frac{X}{Y}$ $$h_2(y_2)=\int_0^1(y_3-y_1-2)\frac{y_1}{y_2^2}dy_1=\frac{1}{y_2^2}(\frac{y_3}{2}-\frac{1}{3}-1)\tag{2}$$ This is the pdf of $X/Y$ i.e $\frac{X_1}{X1+X_2+X_3}$ We are not finish yet, what is $y_3$ in (2) then? We know that $Y_3=X_1+X_2+X_3$ from the first transformation. So at least we know $Y_3$ has a Irwin-Hall distribution. I wonder can we plug the Irwin-Hall for $n=3$ pdf to (2) to get a explicit formula? or can we do some simulations from here as Glen suggested?
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's?
Suppose we already know sum of $U(0,1)$ has a Irwin-Hall distribution. Now your question changes to find the pdf (or CDF) of $\frac{X}{Y}$ when X had a $U(0,1)$ distribution and $Y$ has a Irwin-Hall d
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Suppose we already know sum of $U(0,1)$ has a Irwin-Hall distribution. Now your question changes to find the pdf (or CDF) of $\frac{X}{Y}$ when X had a $U(0,1)$ distribution and $Y$ has a Irwin-Hall distribution. First we need to find he joint pdf of $X$ and $Y$. Let $Y_1=X_1\\Y_2=X_1+X_2\\Y_3=X_1+X_2+X_3$ Then $X_1=Y_1\\X_2=Y_2-Y_1\\X_3=Y_3-Y_2-Y_1$ $\therefore$ $J=\begin{vmatrix} \frac{\partial X_1}{\partial Y_1} & \frac{\partial X_1}{\partial Y_2} &\frac{\partial X_1}{\partial Y_3} \\ \frac{\partial X_2}{\partial Y_1} & \frac{\partial X_2}{\partial Y_2} &\frac{\partial X_2}{\partial Y_3} \\ \frac{\partial X_3}{\partial Y_1} & \frac{\partial X_3}{\partial Y_2} &\frac{\partial X_3}{\partial Y_3} \end{vmatrix}=-1$ Since $X_1, X_2, X_3$ are i.i.d with $U(0,1),$ therefore, $f(x_1,x_2,x_3)=f(x_1)f(x_2)f(x_3)=1$ The joint distribution with $y_1,y_2,y_3$ is $g(y_1,y_2,y_3)=f(y_1,y_2,y_3)|J|=1$ Next let us integrate out the $Y_2$ and we can get the joint distribution of $Y_1$ and $Y_3$ i.e the joint distribution of $X_1$ and $X_1+X_2+X_3$ As suggested by whuber now I changed the the limits $$h(y_1,y_3)=\int_{y_1+1}^{y_3-1} g(y_1,y_2,y_3)dy_2=\int_{y_1+1}^{y_3-1} 1 dy_2=y_3-y_1-2 \tag{1}$$ Now, we know the joint pdf of $X,Y$ i.e joint pdf $X_1$ and $X_1+X_2+X_3$ is $y_3-y_1-2$. Next let find the pdf of $\frac{X}{Y}$ We need another transformation: Let $Y_1=X\\Y_2=\frac{X}{Y}$ Then $X=Y_1\\Y=\frac{Y_1}{Y_2}$ Then $J=\begin{vmatrix} \frac{\partial x}{\partial y_1} & \frac{\partial x}{\partial y_2}\\ \frac{\partial y}{\partial y_1} & \frac{\partial y}{\partial y_2} \end{vmatrix}= \begin{vmatrix} 1 & 0\\ \frac{1}{y_2} & -\frac{y_1}{y_2^2} \end{vmatrix}=-\frac{y_1}{y_2^2}$ we already the joint distribution of $X,Y$ from above steps ref (1). $\therefore$ $g_2(y_1,y_2)=h(y_1,y_3)|J|=(y_3-y_1-2)\frac{y_1}{y_2^2}$ Next, we integrate the $y_1$ out we get the pdf of $y_2$ then we get the pdf of $\frac{X}{Y}$ $$h_2(y_2)=\int_0^1(y_3-y_1-2)\frac{y_1}{y_2^2}dy_1=\frac{1}{y_2^2}(\frac{y_3}{2}-\frac{1}{3}-1)\tag{2}$$ This is the pdf of $X/Y$ i.e $\frac{X_1}{X1+X_2+X_3}$ We are not finish yet, what is $y_3$ in (2) then? We know that $Y_3=X_1+X_2+X_3$ from the first transformation. So at least we know $Y_3$ has a Irwin-Hall distribution. I wonder can we plug the Irwin-Hall for $n=3$ pdf to (2) to get a explicit formula? or can we do some simulations from here as Glen suggested?
Given n uniformly distributed r.v's, what is the PDF for one r.v. divided by the sum of all n r.v's? Suppose we already know sum of $U(0,1)$ has a Irwin-Hall distribution. Now your question changes to find the pdf (or CDF) of $\frac{X}{Y}$ when X had a $U(0,1)$ distribution and $Y$ has a Irwin-Hall d
29,007
Number of nodes in hidden layers of neural network
There's an excellent writeup to this question (and to the question of 'how many hidden layers?' as well) at https://stackoverflow.com/questions/10565868/what-is-the-criteria-for-choosing-number-of-hidden-layers-and-nodes-in-hidden-la . It may be disappointing to find that there are few hard-and-fast rules, and if there are, they are often mathematically or logically suspect. Also, another answer in that thread referenced this webpage: ftp://ftp.sas.com/pub/neural/FAQ3.html#A_hu . Alternatively, depending on how computationally intensive it is to train your network, you can use various optimization algorithms to try to find it. As for the more general question of whether or not layer size should stay constant, I would suggest considering that as a dimensionality-reduction procedure. Would you want your data to be compressed into a lower dimensional form and lose some information? This can be a positive or negative thing. For image compression, it's a requirement. See http://cs.stanford.edu/people/eroberts/courses/soco/projects/neural-networks/Applications/imagecompression.html for references on 'bottleneck' layers with image compression. The type of problem which I would want to have big -> small -> big or some variety of that would probably involve a high dimensional source of data which I would like to compress and then learn features from. If you think that this describes your problem, then perhaps it is a valid approach to use more hidden units, feed into fewer units, then expand the layer out again.
Number of nodes in hidden layers of neural network
There's an excellent writeup to this question (and to the question of 'how many hidden layers?' as well) at https://stackoverflow.com/questions/10565868/what-is-the-criteria-for-choosing-number-of-hid
Number of nodes in hidden layers of neural network There's an excellent writeup to this question (and to the question of 'how many hidden layers?' as well) at https://stackoverflow.com/questions/10565868/what-is-the-criteria-for-choosing-number-of-hidden-layers-and-nodes-in-hidden-la . It may be disappointing to find that there are few hard-and-fast rules, and if there are, they are often mathematically or logically suspect. Also, another answer in that thread referenced this webpage: ftp://ftp.sas.com/pub/neural/FAQ3.html#A_hu . Alternatively, depending on how computationally intensive it is to train your network, you can use various optimization algorithms to try to find it. As for the more general question of whether or not layer size should stay constant, I would suggest considering that as a dimensionality-reduction procedure. Would you want your data to be compressed into a lower dimensional form and lose some information? This can be a positive or negative thing. For image compression, it's a requirement. See http://cs.stanford.edu/people/eroberts/courses/soco/projects/neural-networks/Applications/imagecompression.html for references on 'bottleneck' layers with image compression. The type of problem which I would want to have big -> small -> big or some variety of that would probably involve a high dimensional source of data which I would like to compress and then learn features from. If you think that this describes your problem, then perhaps it is a valid approach to use more hidden units, feed into fewer units, then expand the layer out again.
Number of nodes in hidden layers of neural network There's an excellent writeup to this question (and to the question of 'how many hidden layers?' as well) at https://stackoverflow.com/questions/10565868/what-is-the-criteria-for-choosing-number-of-hid
29,008
Convexity of Function of PDF and CDF of Standard Normal Random Variable
Let's show the second derivative of $Q$ is positive for $x \ge 0$. First, we need to know how to differentiate $\Phi$ and $\phi$. By definition, $$\frac{d}{dx}\Phi(x) = \phi(x) = \frac{1}{\sqrt{2\pi}} \exp(-x^2/2).$$ Differentiating once more gives $$\frac{d}{dx}\phi(x) = -x \phi(x).$$ Applying this result to another derivative yields $$\frac{d^2}{dx^2}\phi(x) = (-1 + x^2)\phi(x).$$ Using these results, along with the usual product and quotient rules of differentiation, we find the numerator of the second derivative is the sum of six terms. (This result was obtained around the middle of the question.) It is convenient to arrange the terms into three groups: $$\eqalign{ \Phi(x)^3\frac{d^2}{dx^2}Q(x)= &2 x \phi(x)^3 \\ &+\,3 x^2 \phi(x)^2 \Phi(x)+x^3 \phi(x) \Phi(x)^2 \\ &+\,\Phi(x) \left(-2 \phi(x)^2-3 x \phi(x) \Phi(x)+2 \Phi(x)^2\right). }$$ Because $\phi$ is a probability density, it is nonnegative and so is the distribution function $\Phi$. Thus only the third term could possibly be negative when $x\ge 0$. Its sign is the same as that of its second factor, $$R(x) = -2 \phi(x)^2-3 x \phi(x) \Phi(x)+2 \Phi(x)^2.$$ There are many ways to show this factor cannot be negative. One is to note that $$R(0) = -2\phi(0) + 2\Phi(0) = 1 - \sqrt{\frac{2}{\pi}} \gt 0.$$ Differentiation--using the same simple techniques as before--gives $$\frac{d}{dx} R(x) = \phi(x)(x \phi(x) + (1 + 3x^2)\Phi(x))$$ which is plainly positive for $x\ge 0$. Therefore $R(x)$ is an increasing function on the interval $[0, \infty)$. Its minimum must be at $R(0) \gt 0$, proving $R(x)\gt 0$ for all $x \ge 0$. We have shown $Q$ has positive second derivative for $x \ge 0$, QED.
Convexity of Function of PDF and CDF of Standard Normal Random Variable
Let's show the second derivative of $Q$ is positive for $x \ge 0$. First, we need to know how to differentiate $\Phi$ and $\phi$. By definition, $$\frac{d}{dx}\Phi(x) = \phi(x) = \frac{1}{\sqrt{2\pi
Convexity of Function of PDF and CDF of Standard Normal Random Variable Let's show the second derivative of $Q$ is positive for $x \ge 0$. First, we need to know how to differentiate $\Phi$ and $\phi$. By definition, $$\frac{d}{dx}\Phi(x) = \phi(x) = \frac{1}{\sqrt{2\pi}} \exp(-x^2/2).$$ Differentiating once more gives $$\frac{d}{dx}\phi(x) = -x \phi(x).$$ Applying this result to another derivative yields $$\frac{d^2}{dx^2}\phi(x) = (-1 + x^2)\phi(x).$$ Using these results, along with the usual product and quotient rules of differentiation, we find the numerator of the second derivative is the sum of six terms. (This result was obtained around the middle of the question.) It is convenient to arrange the terms into three groups: $$\eqalign{ \Phi(x)^3\frac{d^2}{dx^2}Q(x)= &2 x \phi(x)^3 \\ &+\,3 x^2 \phi(x)^2 \Phi(x)+x^3 \phi(x) \Phi(x)^2 \\ &+\,\Phi(x) \left(-2 \phi(x)^2-3 x \phi(x) \Phi(x)+2 \Phi(x)^2\right). }$$ Because $\phi$ is a probability density, it is nonnegative and so is the distribution function $\Phi$. Thus only the third term could possibly be negative when $x\ge 0$. Its sign is the same as that of its second factor, $$R(x) = -2 \phi(x)^2-3 x \phi(x) \Phi(x)+2 \Phi(x)^2.$$ There are many ways to show this factor cannot be negative. One is to note that $$R(0) = -2\phi(0) + 2\Phi(0) = 1 - \sqrt{\frac{2}{\pi}} \gt 0.$$ Differentiation--using the same simple techniques as before--gives $$\frac{d}{dx} R(x) = \phi(x)(x \phi(x) + (1 + 3x^2)\Phi(x))$$ which is plainly positive for $x\ge 0$. Therefore $R(x)$ is an increasing function on the interval $[0, \infty)$. Its minimum must be at $R(0) \gt 0$, proving $R(x)\gt 0$ for all $x \ge 0$. We have shown $Q$ has positive second derivative for $x \ge 0$, QED.
Convexity of Function of PDF and CDF of Standard Normal Random Variable Let's show the second derivative of $Q$ is positive for $x \ge 0$. First, we need to know how to differentiate $\Phi$ and $\phi$. By definition, $$\frac{d}{dx}\Phi(x) = \phi(x) = \frac{1}{\sqrt{2\pi
29,009
Looking for a robust, distribution-free/nonparametric distance between multivariate samples
First of all, I advise you to take a look at the Encyclopedia of Distances by Michel and Elena Deza. From quickly browsing through the pdf (e.g. pp. 327-330), you can already see a multitude of possible statistical measures for multivariate populations. Although simple, one of those might be good enough to approximate the statistical divergence between the various populations. Additionally, there are many more 'simplistic' statistical distances which you may want to consider. For example, you can Google the term Nonparametric multivariate distance and many distance measures will pop up. In a more complicated manner, a first intuition could be to first preserve the treatment classification in the data and then to estimate the distances between two possible hierarchies/classifications, as the problem concerns multivariate data that can be classified into different subgroups. One such a measure is the Split-Order distance as can be found in the following paper: Zhang et al. (2009), Split-Order Distance for Clustering and Classification Hierarchies, Lecture Notes in Computer Science, Vol. 5566, pp. 517-534. Download here This technique (and similar techniques) try to classify the data according to different possible hierarchies. I am not completely sure whether this is applicable to the subculture structure that you mentioned but it might be interesting to take a look. However, this way of estimating the statistical distance relies heavily on the implementation of algorithms (and therefore computer science). A more statistical way of looking at the problem would be to simply use the data as if categorized where you use the treatment classification as the split between different subpopulations. Therefore no specific hierarchy is assumed. The nonparametric measures which would then be useful are either based on bootstrapping or on the approximation of the moments of the underlying distribution, with the most famous being the method of moments. The distance measures based on this often rely on the simple assumption that the first and the second moment are finite. A good example of such a measure can be found in the following paper: Székely, G.J., Rizzo, M.L., (2004), Testing for equal distributions in high dimension, Interstat 2004. Download here Where the equality of two multivariate distributions is tested in a nonparametric way. Another interesting nonparametric test which is based on data depth can be found in: Chenouri, S., Farrar, T.J. (2012), A Two­sample Nonparametric Multivariate Scale Test based on Data Depth, Electronic Journal of Statistics, Vol. 6, pp. 760-782. Download here Now apart from testing for the disparity between two samples, you might just want to interpret a statistical difference between them. In that case, you might want to look into divergence measures such as the Bhattacharyya distance, or f-divergences such as the Hellinger distance. All these measures have different advantages and disadvantages and should be employed under specific conditions. Be sure to always mind the scale of your variables as large scales will contribute disproportionately to any measure. So if variables are measured on different scales, use standardized values before computing distances. So for $n$ samples (groups), variables should be standardized to zero mean and unit variance over all $n$ groups. Good luck! P.S. Note that robust statistics often use a different penalisation function such as the mean-absolute deviation instead of squaring the distance between the observation and the mean. This might help your search for a robust measure.
Looking for a robust, distribution-free/nonparametric distance between multivariate samples
First of all, I advise you to take a look at the Encyclopedia of Distances by Michel and Elena Deza. From quickly browsing through the pdf (e.g. pp. 327-330), you can already see a multitude of possib
Looking for a robust, distribution-free/nonparametric distance between multivariate samples First of all, I advise you to take a look at the Encyclopedia of Distances by Michel and Elena Deza. From quickly browsing through the pdf (e.g. pp. 327-330), you can already see a multitude of possible statistical measures for multivariate populations. Although simple, one of those might be good enough to approximate the statistical divergence between the various populations. Additionally, there are many more 'simplistic' statistical distances which you may want to consider. For example, you can Google the term Nonparametric multivariate distance and many distance measures will pop up. In a more complicated manner, a first intuition could be to first preserve the treatment classification in the data and then to estimate the distances between two possible hierarchies/classifications, as the problem concerns multivariate data that can be classified into different subgroups. One such a measure is the Split-Order distance as can be found in the following paper: Zhang et al. (2009), Split-Order Distance for Clustering and Classification Hierarchies, Lecture Notes in Computer Science, Vol. 5566, pp. 517-534. Download here This technique (and similar techniques) try to classify the data according to different possible hierarchies. I am not completely sure whether this is applicable to the subculture structure that you mentioned but it might be interesting to take a look. However, this way of estimating the statistical distance relies heavily on the implementation of algorithms (and therefore computer science). A more statistical way of looking at the problem would be to simply use the data as if categorized where you use the treatment classification as the split between different subpopulations. Therefore no specific hierarchy is assumed. The nonparametric measures which would then be useful are either based on bootstrapping or on the approximation of the moments of the underlying distribution, with the most famous being the method of moments. The distance measures based on this often rely on the simple assumption that the first and the second moment are finite. A good example of such a measure can be found in the following paper: Székely, G.J., Rizzo, M.L., (2004), Testing for equal distributions in high dimension, Interstat 2004. Download here Where the equality of two multivariate distributions is tested in a nonparametric way. Another interesting nonparametric test which is based on data depth can be found in: Chenouri, S., Farrar, T.J. (2012), A Two­sample Nonparametric Multivariate Scale Test based on Data Depth, Electronic Journal of Statistics, Vol. 6, pp. 760-782. Download here Now apart from testing for the disparity between two samples, you might just want to interpret a statistical difference between them. In that case, you might want to look into divergence measures such as the Bhattacharyya distance, or f-divergences such as the Hellinger distance. All these measures have different advantages and disadvantages and should be employed under specific conditions. Be sure to always mind the scale of your variables as large scales will contribute disproportionately to any measure. So if variables are measured on different scales, use standardized values before computing distances. So for $n$ samples (groups), variables should be standardized to zero mean and unit variance over all $n$ groups. Good luck! P.S. Note that robust statistics often use a different penalisation function such as the mean-absolute deviation instead of squaring the distance between the observation and the mean. This might help your search for a robust measure.
Looking for a robust, distribution-free/nonparametric distance between multivariate samples First of all, I advise you to take a look at the Encyclopedia of Distances by Michel and Elena Deza. From quickly browsing through the pdf (e.g. pp. 327-330), you can already see a multitude of possib
29,010
Looking for a robust, distribution-free/nonparametric distance between multivariate samples
Are you familiar with the T-SNE method? It's commonly used on just this sort of problem (cell markers) to do grouping. http://en.wikipedia.org/wiki/T-distributed_stochastic_neighbor_embedding http://lvdmaaten.github.io/tsne/
Looking for a robust, distribution-free/nonparametric distance between multivariate samples
Are you familiar with the T-SNE method? It's commonly used on just this sort of problem (cell markers) to do grouping. http://en.wikipedia.org/wiki/T-distributed_stochastic_neighbor_embedding http://l
Looking for a robust, distribution-free/nonparametric distance between multivariate samples Are you familiar with the T-SNE method? It's commonly used on just this sort of problem (cell markers) to do grouping. http://en.wikipedia.org/wiki/T-distributed_stochastic_neighbor_embedding http://lvdmaaten.github.io/tsne/
Looking for a robust, distribution-free/nonparametric distance between multivariate samples Are you familiar with the T-SNE method? It's commonly used on just this sort of problem (cell markers) to do grouping. http://en.wikipedia.org/wiki/T-distributed_stochastic_neighbor_embedding http://l
29,011
How to to find and evaluate optimal discretization for continuous variable with $\chi^2$ criterion?
There are many possible ways to discretise a continuous variable: see [Garcia 2013] On page 739 I could see at least 5 methods based on chi-square. The optimality of the discretization is actually dependent on the task you want to use the discretised variable in. In your case logistic regression. And as discussed in Garcia2013, finding the optimal discretization given a task is NP-complete. There are lots of heuristics though. In this paper they discuss at least 50 of them. Given my machine learning background (I guess people in statistics prefer other things) I am often biased toward the Fayyad and Irani's Minimum Description Length (MDL) method. I see it is available in the R package discretization As you said, Chi-square is biased towards high number of intervals and many other statistics (as the information gain used in the MDL method) are. However, MDL tries to find a good trade-off between the information gain of the discretized variable and the class and the complexity (number of intervals) of the discretised variable. Give it a try.
How to to find and evaluate optimal discretization for continuous variable with $\chi^2$ criterion?
There are many possible ways to discretise a continuous variable: see [Garcia 2013] On page 739 I could see at least 5 methods based on chi-square. The optimality of the discretization is actually de
How to to find and evaluate optimal discretization for continuous variable with $\chi^2$ criterion? There are many possible ways to discretise a continuous variable: see [Garcia 2013] On page 739 I could see at least 5 methods based on chi-square. The optimality of the discretization is actually dependent on the task you want to use the discretised variable in. In your case logistic regression. And as discussed in Garcia2013, finding the optimal discretization given a task is NP-complete. There are lots of heuristics though. In this paper they discuss at least 50 of them. Given my machine learning background (I guess people in statistics prefer other things) I am often biased toward the Fayyad and Irani's Minimum Description Length (MDL) method. I see it is available in the R package discretization As you said, Chi-square is biased towards high number of intervals and many other statistics (as the information gain used in the MDL method) are. However, MDL tries to find a good trade-off between the information gain of the discretized variable and the class and the complexity (number of intervals) of the discretised variable. Give it a try.
How to to find and evaluate optimal discretization for continuous variable with $\chi^2$ criterion? There are many possible ways to discretise a continuous variable: see [Garcia 2013] On page 739 I could see at least 5 methods based on chi-square. The optimality of the discretization is actually de
29,012
How to deal with factors with rare levels in cross-validation?
As a very first thought, this means that at least your training set is not representative for the application data. Whether the test set is representative is a question that you should IMHO think very carefully about. In this context, it is also important to find out whether these missing classes are a problem of the particular training set being too small, or whether this is a general characteristic of the problem/task/application. I.e., whether new classes that have never been encountered before will be appearing all the time. In principle, I see two possibilities of dealing with this situation: Say that the training set is for sure not representative and ask for more data, particularly for data of the missing classes. This does make sense in case you come to the conclusion that the problem lies with the particular training set, not with the general characteristics of the application. In any case, knowing that the training data misses classes, I'd consider using a one-class classifer. I.e. a classifier that treats each class independently of any possible other class. Ideally, a one-class classifier should return "unknown class" for the test cases of classes that have not been available for training. For one-class classifiers, testing this "rejection" of cases belonging to truly unknown classes does actually make sense. edit wrt @gung's comment: I assume that the train/test split is fixed for some hopefully good reason.
How to deal with factors with rare levels in cross-validation?
As a very first thought, this means that at least your training set is not representative for the application data. Whether the test set is representative is a question that you should IMHO think very
How to deal with factors with rare levels in cross-validation? As a very first thought, this means that at least your training set is not representative for the application data. Whether the test set is representative is a question that you should IMHO think very carefully about. In this context, it is also important to find out whether these missing classes are a problem of the particular training set being too small, or whether this is a general characteristic of the problem/task/application. I.e., whether new classes that have never been encountered before will be appearing all the time. In principle, I see two possibilities of dealing with this situation: Say that the training set is for sure not representative and ask for more data, particularly for data of the missing classes. This does make sense in case you come to the conclusion that the problem lies with the particular training set, not with the general characteristics of the application. In any case, knowing that the training data misses classes, I'd consider using a one-class classifer. I.e. a classifier that treats each class independently of any possible other class. Ideally, a one-class classifier should return "unknown class" for the test cases of classes that have not been available for training. For one-class classifiers, testing this "rejection" of cases belonging to truly unknown classes does actually make sense. edit wrt @gung's comment: I assume that the train/test split is fixed for some hopefully good reason.
How to deal with factors with rare levels in cross-validation? As a very first thought, this means that at least your training set is not representative for the application data. Whether the test set is representative is a question that you should IMHO think very
29,013
Does Monte Carlo == apply a random process?
I think I should first give you the simple answer, which is "YES, almost always." This was boring, so let's get into more interesting stuff, complications so to speak. Monte Carlo methods are often applied to absolutely non-stochastic problems. For instance, check out Monte Carlo integration. This is to take definite integrals, which are non-random at all. This was about the nature of the problems to which MC is applied, to Maarten's point. Another, aspect of Monte Carlo methods is that they usually do not employ random numbers, I'd even say almost never. MC methods most commonly use pseudo-random number generators. These are not random numbers at all. Think of this: if you set the seed, then every number in the generated sequence is absolutely defined by the seed. They look and smell like random numbers so we use them. Google for MC examples, you'll find infinite number of examples like this. This particular example has all these equations with probabilities etc., but then it goes on to use the function rgamma(.) in R. This function generates the sequence of psudo-random numbers, which looks awfully a lot like random numbers from Gamma distribution. Having said that, there are true random number sequences. Surprisingly small number of statisticians use them, and or even are aware of them. The reason is that psudo-random generators are so much more convenient and fast. True random numbers are expensive, you have to buy them or the hardware number generators (TRNG). They are used a lot in gambling applications. They are generated from physical sources usually, such as radioactive decay and noise in radio waves, heat etc. Thanks to @scruss for pointing out that recently TRNG became much more accessible. Finally, there's a family of methods called Quasi Monte Carlo. These use sequences of numbers which don't even pretend to look like random numbers, e.g. Sobol sequences of so called low-discrepancy numbers.
Does Monte Carlo == apply a random process?
I think I should first give you the simple answer, which is "YES, almost always." This was boring, so let's get into more interesting stuff, complications so to speak. Monte Carlo methods are often ap
Does Monte Carlo == apply a random process? I think I should first give you the simple answer, which is "YES, almost always." This was boring, so let's get into more interesting stuff, complications so to speak. Monte Carlo methods are often applied to absolutely non-stochastic problems. For instance, check out Monte Carlo integration. This is to take definite integrals, which are non-random at all. This was about the nature of the problems to which MC is applied, to Maarten's point. Another, aspect of Monte Carlo methods is that they usually do not employ random numbers, I'd even say almost never. MC methods most commonly use pseudo-random number generators. These are not random numbers at all. Think of this: if you set the seed, then every number in the generated sequence is absolutely defined by the seed. They look and smell like random numbers so we use them. Google for MC examples, you'll find infinite number of examples like this. This particular example has all these equations with probabilities etc., but then it goes on to use the function rgamma(.) in R. This function generates the sequence of psudo-random numbers, which looks awfully a lot like random numbers from Gamma distribution. Having said that, there are true random number sequences. Surprisingly small number of statisticians use them, and or even are aware of them. The reason is that psudo-random generators are so much more convenient and fast. True random numbers are expensive, you have to buy them or the hardware number generators (TRNG). They are used a lot in gambling applications. They are generated from physical sources usually, such as radioactive decay and noise in radio waves, heat etc. Thanks to @scruss for pointing out that recently TRNG became much more accessible. Finally, there's a family of methods called Quasi Monte Carlo. These use sequences of numbers which don't even pretend to look like random numbers, e.g. Sobol sequences of so called low-discrepancy numbers.
Does Monte Carlo == apply a random process? I think I should first give you the simple answer, which is "YES, almost always." This was boring, so let's get into more interesting stuff, complications so to speak. Monte Carlo methods are often ap
29,014
A valid distance metric for high dimensional data
For high-dimensional data, shared-nearest-neighbor distances have been reported to work in Houle et al., Can Shared-Neighbor Distances Defeat the Curse of Dimensionality? Scientific and Statistical Database Management. Lecture Notes in Computer Science 6187. p. 482. doi:10.1007/978-3-642-13818-8_34 Fractional distances are known to be not metric. $L_p$ is only a metric for $p\geq 1$, you'll find this restriction in every proof of the metric properties of Minkowski norms.
A valid distance metric for high dimensional data
For high-dimensional data, shared-nearest-neighbor distances have been reported to work in Houle et al., Can Shared-Neighbor Distances Defeat the Curse of Dimensionality? Scientific and Statistical D
A valid distance metric for high dimensional data For high-dimensional data, shared-nearest-neighbor distances have been reported to work in Houle et al., Can Shared-Neighbor Distances Defeat the Curse of Dimensionality? Scientific and Statistical Database Management. Lecture Notes in Computer Science 6187. p. 482. doi:10.1007/978-3-642-13818-8_34 Fractional distances are known to be not metric. $L_p$ is only a metric for $p\geq 1$, you'll find this restriction in every proof of the metric properties of Minkowski norms.
A valid distance metric for high dimensional data For high-dimensional data, shared-nearest-neighbor distances have been reported to work in Houle et al., Can Shared-Neighbor Distances Defeat the Curse of Dimensionality? Scientific and Statistical D
29,015
Getting cointegration vectors using Johansen method
I've found the answer. If it is helpful for somebody, can check the following notebook: http://nbviewer.ipython.org/github/mapsa/seminario-doc-2014/blob/master/cointegration-example.ipynb
Getting cointegration vectors using Johansen method
I've found the answer. If it is helpful for somebody, can check the following notebook: http://nbviewer.ipython.org/github/mapsa/seminario-doc-2014/blob/master/cointegration-example.ipynb
Getting cointegration vectors using Johansen method I've found the answer. If it is helpful for somebody, can check the following notebook: http://nbviewer.ipython.org/github/mapsa/seminario-doc-2014/blob/master/cointegration-example.ipynb
Getting cointegration vectors using Johansen method I've found the answer. If it is helpful for somebody, can check the following notebook: http://nbviewer.ipython.org/github/mapsa/seminario-doc-2014/blob/master/cointegration-example.ipynb
29,016
How to find optimal values for the tuning parameters in boosting trees ?
The caret package in R is tailor made for this. Its train function takes a grid of parameter values and evaluates the performance using various flavors of cross-validation or the bootstrap. The package author has written a book, Applied predictive modeling, which is highly recommended. 5 repeats of 10-fold cross-validation is used throughout the book. For choosing the tree depth, I would first go for subject matter knowledge about the problem, i.e. if you do not expect any interactions - restrict the depth to 1 or go for a flexible parametric model (which is much easier to understand and interpret). That being said, I often find myself tuning the tree depth as subject matter knowledge is often very limited. I think the gbm package tunes the number of trees for fixed values of the tree depth and shrinkage.
How to find optimal values for the tuning parameters in boosting trees ?
The caret package in R is tailor made for this. Its train function takes a grid of parameter values and evaluates the performance using various flavors of cross-validation or the bootstrap. The packa
How to find optimal values for the tuning parameters in boosting trees ? The caret package in R is tailor made for this. Its train function takes a grid of parameter values and evaluates the performance using various flavors of cross-validation or the bootstrap. The package author has written a book, Applied predictive modeling, which is highly recommended. 5 repeats of 10-fold cross-validation is used throughout the book. For choosing the tree depth, I would first go for subject matter knowledge about the problem, i.e. if you do not expect any interactions - restrict the depth to 1 or go for a flexible parametric model (which is much easier to understand and interpret). That being said, I often find myself tuning the tree depth as subject matter knowledge is often very limited. I think the gbm package tunes the number of trees for fixed values of the tree depth and shrinkage.
How to find optimal values for the tuning parameters in boosting trees ? The caret package in R is tailor made for this. Its train function takes a grid of parameter values and evaluates the performance using various flavors of cross-validation or the bootstrap. The packa
29,017
How to find optimal values for the tuning parameters in boosting trees ?
There are two good sources for the boosted regression trees and gbm package. For the explanation of BRT and the optimization of the number of trees (nt), learning rate (lr) and tree complexity (tc) see A working guide to boosted regression trees Although it is focusing on ecology I think you wilĺ not find a better introduction to BRT. For the implementation of BRT in the gbm package, see Boosted Regression Trees for ecological modeling In short, a rule of thumb is to select a learning rate that allows the BRT model to fit at least 1000 trees, so propably you will need a low learning rate, maybe 0.001 to accomplish that. But it depends on the size of your data, see fig. 2 and 3 in the Working guide to BRT. I think one possible way would be the set up different models in BRT according to you data size, for example combine different lr (0.1, 0.01, 0.001), tc (1, 3, 5, 7, 9, 20) with different bag.fractions(0.5, 0.7, 0.9) and choose the best one according to lowest deviance or highest ROC score. Maybe it helped.
How to find optimal values for the tuning parameters in boosting trees ?
There are two good sources for the boosted regression trees and gbm package. For the explanation of BRT and the optimization of the number of trees (nt), learning rate (lr) and tree complexity (tc) se
How to find optimal values for the tuning parameters in boosting trees ? There are two good sources for the boosted regression trees and gbm package. For the explanation of BRT and the optimization of the number of trees (nt), learning rate (lr) and tree complexity (tc) see A working guide to boosted regression trees Although it is focusing on ecology I think you wilĺ not find a better introduction to BRT. For the implementation of BRT in the gbm package, see Boosted Regression Trees for ecological modeling In short, a rule of thumb is to select a learning rate that allows the BRT model to fit at least 1000 trees, so propably you will need a low learning rate, maybe 0.001 to accomplish that. But it depends on the size of your data, see fig. 2 and 3 in the Working guide to BRT. I think one possible way would be the set up different models in BRT according to you data size, for example combine different lr (0.1, 0.01, 0.001), tc (1, 3, 5, 7, 9, 20) with different bag.fractions(0.5, 0.7, 0.9) and choose the best one according to lowest deviance or highest ROC score. Maybe it helped.
How to find optimal values for the tuning parameters in boosting trees ? There are two good sources for the boosted regression trees and gbm package. For the explanation of BRT and the optimization of the number of trees (nt), learning rate (lr) and tree complexity (tc) se
29,018
How can multiple regression be performed as a sequence of univariate regressions?
As per Bill Huber's comments and answer elsewhere, the trick is to remove the influence of the independent variables on each other whenever producing each sequential regression. In other words instead of: lm(lm(x ~ y1)$residuals ~ y2) We want: lm(lm(x ~ y1)$residuals ~ lm(y2 ~ y1)$residuals) In this case, we DO get back to the multiple regression: Moreover, we can show the coefficients are the same: > round(coef(lm(lm(it30 ~ itpc1)$residuals ~ lm(itpc2 ~ itpc1)$residuals)), 5) (Intercept) lm(itpc2 ~ itpc1)$residuals #$ 0.00000 -0.21846 > round(coef(lm(lm(it30 ~ itpc2)$residuals ~ lm(itpc1 ~ itpc2)$residuals)), 5) (Intercept) lm(itpc1 ~ itpc2)$residuals #$ 0.00000 0.29197 > round(coef(lm(it30 ~ itpc1 + itpc2)), 5) (Intercept) itpc1 itpc2 0.01186 0.29197 -0.21846 Interestingly, and as expected, if the independent variables are orthogonal as in PCA regression, then we do not need to take out the influence of each of the regressors against each other. In this case it is true that: lm(lm(x ~ y1)$residuals ~ y2)$residuals is perfectly correlated with: lm(x ~ y1 + y2)$residuals as can be seen here: This is because the orthogonal principal components have a zero-slope regression line and thus the residuals are equal to the dependent variable (with a vertical translation to mean=0).
How can multiple regression be performed as a sequence of univariate regressions?
As per Bill Huber's comments and answer elsewhere, the trick is to remove the influence of the independent variables on each other whenever producing each sequential regression. In other words instead
How can multiple regression be performed as a sequence of univariate regressions? As per Bill Huber's comments and answer elsewhere, the trick is to remove the influence of the independent variables on each other whenever producing each sequential regression. In other words instead of: lm(lm(x ~ y1)$residuals ~ y2) We want: lm(lm(x ~ y1)$residuals ~ lm(y2 ~ y1)$residuals) In this case, we DO get back to the multiple regression: Moreover, we can show the coefficients are the same: > round(coef(lm(lm(it30 ~ itpc1)$residuals ~ lm(itpc2 ~ itpc1)$residuals)), 5) (Intercept) lm(itpc2 ~ itpc1)$residuals #$ 0.00000 -0.21846 > round(coef(lm(lm(it30 ~ itpc2)$residuals ~ lm(itpc1 ~ itpc2)$residuals)), 5) (Intercept) lm(itpc1 ~ itpc2)$residuals #$ 0.00000 0.29197 > round(coef(lm(it30 ~ itpc1 + itpc2)), 5) (Intercept) itpc1 itpc2 0.01186 0.29197 -0.21846 Interestingly, and as expected, if the independent variables are orthogonal as in PCA regression, then we do not need to take out the influence of each of the regressors against each other. In this case it is true that: lm(lm(x ~ y1)$residuals ~ y2)$residuals is perfectly correlated with: lm(x ~ y1 + y2)$residuals as can be seen here: This is because the orthogonal principal components have a zero-slope regression line and thus the residuals are equal to the dependent variable (with a vertical translation to mean=0).
How can multiple regression be performed as a sequence of univariate regressions? As per Bill Huber's comments and answer elsewhere, the trick is to remove the influence of the independent variables on each other whenever producing each sequential regression. In other words instead
29,019
Intuitive explanation of differences between TOST and UMP tests for equivalence
First question: UMP is, nomen es omen, most powerful. If both the sample size and the equivalence region are small, it may happen to the TOST that confidence intervals will hardly ever fit into the equivalence region. This results in nearly zero power. Also, the TOST is generally conservative (even with an $1-2\alpha$ confidence interval). Whenever the UMP exists, it will always have power $> \alpha$. Second question: Sometimes an UMP doesn't exist. It is this strictly total positivity of order 3 that has to hold for the density, see the appendix of Wellek's textbook on equivalence and noninferiority tests. Intuitively, this condition guarantees that the power curve of the respective point hypothesis test has exactly one maximum. Then the critical values are the points where this power curve has level $\alpha$. That's why you find them with this $F_{1,n-1,\psi^2}$-distribution in this question: Obtaining $p$-values for UMP $t$ tests for equivalence. Also if your equivalence hypothesis is not standardized, i.e. $\mu \in ]-\epsilon, \epsilon[$ instead of $\mu \in ]-\frac{\epsilon}{\sigma}, \frac{\epsilon}{\sigma}[$, then even for normally distributed data an UMP has a strange rejection area in the $(\hat{\mu},\hat{\sigma}^2)$-space. See Brown, Hwang and Munk (1997) as an example. The most important is, as you mentioned, that confidence intervals on the observed scale are more instructive than $p$-values. So the ICH guidelines require confidence intervals. This leads automatically to the TOST, because if you supply a confidence interval to the $p$-value of the UMP, confidence interval and $p$-value may contradict each other. The UMP may be significant but the confidence interval still touches the hypothesis space. This is not desired. In conclusion, if you use the equivalence test "internally", i.e. not for direct scientific reporting but only as part of some data mining algorithm e.g., UMP may be preferable if it exists. Otherwise take the TOST.
Intuitive explanation of differences between TOST and UMP tests for equivalence
First question: UMP is, nomen es omen, most powerful. If both the sample size and the equivalence region are small, it may happen to the TOST that confidence intervals will hardly ever fit into the eq
Intuitive explanation of differences between TOST and UMP tests for equivalence First question: UMP is, nomen es omen, most powerful. If both the sample size and the equivalence region are small, it may happen to the TOST that confidence intervals will hardly ever fit into the equivalence region. This results in nearly zero power. Also, the TOST is generally conservative (even with an $1-2\alpha$ confidence interval). Whenever the UMP exists, it will always have power $> \alpha$. Second question: Sometimes an UMP doesn't exist. It is this strictly total positivity of order 3 that has to hold for the density, see the appendix of Wellek's textbook on equivalence and noninferiority tests. Intuitively, this condition guarantees that the power curve of the respective point hypothesis test has exactly one maximum. Then the critical values are the points where this power curve has level $\alpha$. That's why you find them with this $F_{1,n-1,\psi^2}$-distribution in this question: Obtaining $p$-values for UMP $t$ tests for equivalence. Also if your equivalence hypothesis is not standardized, i.e. $\mu \in ]-\epsilon, \epsilon[$ instead of $\mu \in ]-\frac{\epsilon}{\sigma}, \frac{\epsilon}{\sigma}[$, then even for normally distributed data an UMP has a strange rejection area in the $(\hat{\mu},\hat{\sigma}^2)$-space. See Brown, Hwang and Munk (1997) as an example. The most important is, as you mentioned, that confidence intervals on the observed scale are more instructive than $p$-values. So the ICH guidelines require confidence intervals. This leads automatically to the TOST, because if you supply a confidence interval to the $p$-value of the UMP, confidence interval and $p$-value may contradict each other. The UMP may be significant but the confidence interval still touches the hypothesis space. This is not desired. In conclusion, if you use the equivalence test "internally", i.e. not for direct scientific reporting but only as part of some data mining algorithm e.g., UMP may be preferable if it exists. Otherwise take the TOST.
Intuitive explanation of differences between TOST and UMP tests for equivalence First question: UMP is, nomen es omen, most powerful. If both the sample size and the equivalence region are small, it may happen to the TOST that confidence intervals will hardly ever fit into the eq
29,020
Determining sample size with a proportion and binomial distribution
That would be the probability of obtaining a false negative in 5 slides: (0.80)^5 = 0.32768 Ahhh, so in order to decrease the probability of false negatives below 1% you can do: > x <- matrix(c(0), nrow=25) > for(i in 1:25) x[i] = (0.8)^i > x [,1] [1,] 0.800000000 [2,] 0.640000000 [3,] 0.512000000 [4,] 0.409600000 [5,] 0.327680000 [6,] 0.262144000 [7,] 0.209715200 [8,] 0.167772160 [9,] 0.134217728 [10,] 0.107374182 [11,] 0.085899346 [12,] 0.068719477 [13,] 0.054975581 [14,] 0.043980465 [15,] 0.035184372 [16,] 0.028147498 [17,] 0.022517998 [18,] 0.018014399 [19,] 0.014411519 [20,] 0.011529215 [21,] 0.009223372 [22,] 0.007378698 [23,] 0.005902958 [24,] 0.004722366 [25,] 0.003777893 And find that the false positive rate is less than 1% at i = 21. Great! Thanks. I can't believe I didn't see that. I was trying all kinds of conditional probabilities and such for some reason. Keep it simple, stupid...
Determining sample size with a proportion and binomial distribution
That would be the probability of obtaining a false negative in 5 slides: (0.80)^5 = 0.32768 Ahhh, so in order to decrease the probability of false negatives below 1% you can do: > x <- matrix(c(0), nr
Determining sample size with a proportion and binomial distribution That would be the probability of obtaining a false negative in 5 slides: (0.80)^5 = 0.32768 Ahhh, so in order to decrease the probability of false negatives below 1% you can do: > x <- matrix(c(0), nrow=25) > for(i in 1:25) x[i] = (0.8)^i > x [,1] [1,] 0.800000000 [2,] 0.640000000 [3,] 0.512000000 [4,] 0.409600000 [5,] 0.327680000 [6,] 0.262144000 [7,] 0.209715200 [8,] 0.167772160 [9,] 0.134217728 [10,] 0.107374182 [11,] 0.085899346 [12,] 0.068719477 [13,] 0.054975581 [14,] 0.043980465 [15,] 0.035184372 [16,] 0.028147498 [17,] 0.022517998 [18,] 0.018014399 [19,] 0.014411519 [20,] 0.011529215 [21,] 0.009223372 [22,] 0.007378698 [23,] 0.005902958 [24,] 0.004722366 [25,] 0.003777893 And find that the false positive rate is less than 1% at i = 21. Great! Thanks. I can't believe I didn't see that. I was trying all kinds of conditional probabilities and such for some reason. Keep it simple, stupid...
Determining sample size with a proportion and binomial distribution That would be the probability of obtaining a false negative in 5 slides: (0.80)^5 = 0.32768 Ahhh, so in order to decrease the probability of false negatives below 1% you can do: > x <- matrix(c(0), nr
29,021
Locomotive problem with various size companies
I'm first outlining an approach for two companies in detail, the extension to even more companies then should be intuitive (at least for the likelihood, the prior could be more tricky). Imagine there are two companies A and B, where A has $N_A$ locomotives and B has $N_B$ locomotives. We assume $N_A \ge N_B$ (you can always switch A and B to make this hold). The total number for that hypothesis of locomotives is $N_{tot} = N_A + N_B$. Imagine you see a locomotive with the number $n$. There are three cases for the likelihood: $N_A < n$: This can't happen, so the likelihood is zero. $N_B < n \le N_A$: This locomotive must come from company A, so there is only one locomotive with this number. Thus the likelihood is $1/N_{tot}$ $n \le N_B$: This locomotive can be either from A or from B, so there are two locomotives with this number. The likelihood to see one of them is $2/N_{tot}$. As a quick sanity check: The likelihood to see any number at all is $$\sum_{i=1}^\infty L(i) = \sum_{i=1}^{N_B} \frac{2}{N_{tot}} + \sum_{i=N_B+1}^{N_A} \frac{1}{N_{tot}} \\ = \frac{2\cdot N_B}{N_{tot}} + \frac{N_A-N_B}{N_{tot}} = \frac{N_A+N_B}{N_{tot}} = 1$$. Generally, there will be (number of companies + 1) cases, one for each interval $N_i < n \le N_{i+1}$. Luckily, we can look at the problem from a different angle and see that what we need for the likelihood are actually just two numbers: $N_{tot}$, the total number of locomotives; and $N_n$, the number of locomotives that have the number $n$. How likely are we to see one of the $N_n$ locomotive, out of $N_{tot}$ locomotives? This will happen in $\frac{N_n}{N_{tot}}$ of all cases, so this fraction is the likelihood. In Python, you can calculate this with two sum generators (and you don't even have to order the companies by size). If Ns contains a list (or tuple) of company sizes according to your hypothesis, then this will give the likelihood for seeing a locomotive with number n: total_number_of_locomotives = sum(N for N in Ns) number_of_locomotives_with_that_number = sum(1 for N in Ns if n<=N) likelihood = (number_of_locomotives_with_that_number / total_number_of_locomotives) Note that the trivial case with one company is also handled by this code (the first sum just will be $N$, the second sum will be 0 or 1, depending on whether $n\le N$). For the priors, Zipf's law could be a good starting point for a realistic distribution of company sizes.
Locomotive problem with various size companies
I'm first outlining an approach for two companies in detail, the extension to even more companies then should be intuitive (at least for the likelihood, the prior could be more tricky). Imagine there
Locomotive problem with various size companies I'm first outlining an approach for two companies in detail, the extension to even more companies then should be intuitive (at least for the likelihood, the prior could be more tricky). Imagine there are two companies A and B, where A has $N_A$ locomotives and B has $N_B$ locomotives. We assume $N_A \ge N_B$ (you can always switch A and B to make this hold). The total number for that hypothesis of locomotives is $N_{tot} = N_A + N_B$. Imagine you see a locomotive with the number $n$. There are three cases for the likelihood: $N_A < n$: This can't happen, so the likelihood is zero. $N_B < n \le N_A$: This locomotive must come from company A, so there is only one locomotive with this number. Thus the likelihood is $1/N_{tot}$ $n \le N_B$: This locomotive can be either from A or from B, so there are two locomotives with this number. The likelihood to see one of them is $2/N_{tot}$. As a quick sanity check: The likelihood to see any number at all is $$\sum_{i=1}^\infty L(i) = \sum_{i=1}^{N_B} \frac{2}{N_{tot}} + \sum_{i=N_B+1}^{N_A} \frac{1}{N_{tot}} \\ = \frac{2\cdot N_B}{N_{tot}} + \frac{N_A-N_B}{N_{tot}} = \frac{N_A+N_B}{N_{tot}} = 1$$. Generally, there will be (number of companies + 1) cases, one for each interval $N_i < n \le N_{i+1}$. Luckily, we can look at the problem from a different angle and see that what we need for the likelihood are actually just two numbers: $N_{tot}$, the total number of locomotives; and $N_n$, the number of locomotives that have the number $n$. How likely are we to see one of the $N_n$ locomotive, out of $N_{tot}$ locomotives? This will happen in $\frac{N_n}{N_{tot}}$ of all cases, so this fraction is the likelihood. In Python, you can calculate this with two sum generators (and you don't even have to order the companies by size). If Ns contains a list (or tuple) of company sizes according to your hypothesis, then this will give the likelihood for seeing a locomotive with number n: total_number_of_locomotives = sum(N for N in Ns) number_of_locomotives_with_that_number = sum(1 for N in Ns if n<=N) likelihood = (number_of_locomotives_with_that_number / total_number_of_locomotives) Note that the trivial case with one company is also handled by this code (the first sum just will be $N$, the second sum will be 0 or 1, depending on whether $n\le N$). For the priors, Zipf's law could be a good starting point for a realistic distribution of company sizes.
Locomotive problem with various size companies I'm first outlining an approach for two companies in detail, the extension to even more companies then should be intuitive (at least for the likelihood, the prior could be more tricky). Imagine there
29,022
Locomotive problem with various size companies
I am not going to analyze the code, but below is the solution. Let P(loc60) be the probability that a random locomotive has number 60 P(N) be the prior probability that there are exactly N locomotives P(loc60|N) be the probability that a random locomotive has number 60, if the total number of locomotives is N, P(N|loc60) be the probability that there are exactly N locomotives, if a random locomotive has number 60 Then $$ P(N|\text{loc60}) = {P(\text{loc60}|N) P(N) \over P(\text{loc60})} = {P(\text{loc60}|N) P(N) \over \sum_M P(\text{loc60}|M)}$$ But $$ P(\text{loc60}|N) = \cases {1/N & if $N\ge 60$ \\ 0 & otherwise } $$ From now on, we assume that $N \ge 60$. $$ P(N|\text{loc60}) = {P(N)/N \over \sum_{M=60}^\infty P(M)/M} $$ Now we should select P(N), otherwise we are stuck. Since we don't know even the order of magnitude of P(N), it is reasonable to assume that $\log N$ is uniformly distributed between 0 and some $\log N_\max$ (i. e. the probability that $10^2\le N<10^3$ is the same as the probability that $10^3\le N<10^4$). Guestimating $N_\max$ is a tricky task, but from my prior knowledge about railroads and locomotives, I can assume that $N_\max \gg 60$ . The uniform distribution of $\log N$ means that $$P(N) = c(\log (N+1)-\log N) \approx c/N$$, where c is a constant independent on N. Substituting this to the previous formula, we have: $$ P(N|\text{loc60}) \approx {c/N^2 \over \sum_{M=60}^{N_\max} c/M^2} $$ But $$\sum_{M=60}^{N_\max} c/M^2 \approx \int_{60}^{N_\max} {c\over M^2}dM = {c \over 60} - {c \over N_\max} \approx {c\over60} $$ Now we have $$ P(N|\text{loc60}) \approx {60/N^2} $$ What is the median value of N? Let it be $N_\text{med}$ , then $$ \int_{60}^{N_\text{med}} {60 \over N^2} dN = 1/2 $$ $$ 60/N - {60 \over N_\text{med}} = 1/2 $$ $$ N_\text{med} = 120 $$ If what we need is mathematical expectation rather than median, then $$ E(N) = \int_{60}^{N_\max} {60\over N^2} N dN = 60 \log {N_\max \over 60} $$ From what I know about railroads, $N_\max$ should be between $10^3$ and $10^6$, so E(N) is somewhere between 170 and 600.
Locomotive problem with various size companies
I am not going to analyze the code, but below is the solution. Let P(loc60) be the probability that a random locomotive has number 60 P(N) be the prior probability that there are exactly N locomotive
Locomotive problem with various size companies I am not going to analyze the code, but below is the solution. Let P(loc60) be the probability that a random locomotive has number 60 P(N) be the prior probability that there are exactly N locomotives P(loc60|N) be the probability that a random locomotive has number 60, if the total number of locomotives is N, P(N|loc60) be the probability that there are exactly N locomotives, if a random locomotive has number 60 Then $$ P(N|\text{loc60}) = {P(\text{loc60}|N) P(N) \over P(\text{loc60})} = {P(\text{loc60}|N) P(N) \over \sum_M P(\text{loc60}|M)}$$ But $$ P(\text{loc60}|N) = \cases {1/N & if $N\ge 60$ \\ 0 & otherwise } $$ From now on, we assume that $N \ge 60$. $$ P(N|\text{loc60}) = {P(N)/N \over \sum_{M=60}^\infty P(M)/M} $$ Now we should select P(N), otherwise we are stuck. Since we don't know even the order of magnitude of P(N), it is reasonable to assume that $\log N$ is uniformly distributed between 0 and some $\log N_\max$ (i. e. the probability that $10^2\le N<10^3$ is the same as the probability that $10^3\le N<10^4$). Guestimating $N_\max$ is a tricky task, but from my prior knowledge about railroads and locomotives, I can assume that $N_\max \gg 60$ . The uniform distribution of $\log N$ means that $$P(N) = c(\log (N+1)-\log N) \approx c/N$$, where c is a constant independent on N. Substituting this to the previous formula, we have: $$ P(N|\text{loc60}) \approx {c/N^2 \over \sum_{M=60}^{N_\max} c/M^2} $$ But $$\sum_{M=60}^{N_\max} c/M^2 \approx \int_{60}^{N_\max} {c\over M^2}dM = {c \over 60} - {c \over N_\max} \approx {c\over60} $$ Now we have $$ P(N|\text{loc60}) \approx {60/N^2} $$ What is the median value of N? Let it be $N_\text{med}$ , then $$ \int_{60}^{N_\text{med}} {60 \over N^2} dN = 1/2 $$ $$ 60/N - {60 \over N_\text{med}} = 1/2 $$ $$ N_\text{med} = 120 $$ If what we need is mathematical expectation rather than median, then $$ E(N) = \int_{60}^{N_\max} {60\over N^2} N dN = 60 \log {N_\max \over 60} $$ From what I know about railroads, $N_\max$ should be between $10^3$ and $10^6$, so E(N) is somewhere between 170 and 600.
Locomotive problem with various size companies I am not going to analyze the code, but below is the solution. Let P(loc60) be the probability that a random locomotive has number 60 P(N) be the prior probability that there are exactly N locomotive
29,023
statistical test to see if relationship is linear or non-linear
This is basically a model selection problem. I encourage you to select a set of physically-plausible models (linear, exponential, maybe a discontinuous linear relationship) and uses Akaike Information Criterion or Bayesian Information Criterion to select the best - keeping in mind the heteroscedasticity issue that @whuber points out.
statistical test to see if relationship is linear or non-linear
This is basically a model selection problem. I encourage you to select a set of physically-plausible models (linear, exponential, maybe a discontinuous linear relationship) and uses Akaike Information
statistical test to see if relationship is linear or non-linear This is basically a model selection problem. I encourage you to select a set of physically-plausible models (linear, exponential, maybe a discontinuous linear relationship) and uses Akaike Information Criterion or Bayesian Information Criterion to select the best - keeping in mind the heteroscedasticity issue that @whuber points out.
statistical test to see if relationship is linear or non-linear This is basically a model selection problem. I encourage you to select a set of physically-plausible models (linear, exponential, maybe a discontinuous linear relationship) and uses Akaike Information
29,024
statistical test to see if relationship is linear or non-linear
Have you tried googling this!? One way to do this is to fit higher power or other non linear terms to your model and test if their coefficients are significantly different from 0. There's some examples here http://www.albany.edu/~po467/EPI553/Fall_2006/regression_assumptions.pdf In your case you might want to split your data set into two sections to test for non-linearity for volume < 5 and linearity for volume > 5. The other problem you have is that your data is heteroskedastic, which violates the normality assumption for regression data. The link provided also gives examples of testing for this.
statistical test to see if relationship is linear or non-linear
Have you tried googling this!? One way to do this is to fit higher power or other non linear terms to your model and test if their coefficients are significantly different from 0. There's some example
statistical test to see if relationship is linear or non-linear Have you tried googling this!? One way to do this is to fit higher power or other non linear terms to your model and test if their coefficients are significantly different from 0. There's some examples here http://www.albany.edu/~po467/EPI553/Fall_2006/regression_assumptions.pdf In your case you might want to split your data set into two sections to test for non-linearity for volume < 5 and linearity for volume > 5. The other problem you have is that your data is heteroskedastic, which violates the normality assumption for regression data. The link provided also gives examples of testing for this.
statistical test to see if relationship is linear or non-linear Have you tried googling this!? One way to do this is to fit higher power or other non linear terms to your model and test if their coefficients are significantly different from 0. There's some example
29,025
statistical test to see if relationship is linear or non-linear
I suggest using nonlinear regression to fit one model to all your data. What is the point of picking an arbitrary volume and fitting one model to volumes less than that and another model to larger volumes? Is there any reason, beyond the look of the figure, for using 5 as a sharp threshold? Do you really believe that after a particular volume threshold, the ideal curve is linear? Isn't it more likely that it approaches horizontal as volume increases, but is never quite linear? Of course, the selection of analysis tool has to depend on what scientific questions you are trying to answer and your prior knowledge of the system.
statistical test to see if relationship is linear or non-linear
I suggest using nonlinear regression to fit one model to all your data. What is the point of picking an arbitrary volume and fitting one model to volumes less than that and another model to larger vol
statistical test to see if relationship is linear or non-linear I suggest using nonlinear regression to fit one model to all your data. What is the point of picking an arbitrary volume and fitting one model to volumes less than that and another model to larger volumes? Is there any reason, beyond the look of the figure, for using 5 as a sharp threshold? Do you really believe that after a particular volume threshold, the ideal curve is linear? Isn't it more likely that it approaches horizontal as volume increases, but is never quite linear? Of course, the selection of analysis tool has to depend on what scientific questions you are trying to answer and your prior knowledge of the system.
statistical test to see if relationship is linear or non-linear I suggest using nonlinear regression to fit one model to all your data. What is the point of picking an arbitrary volume and fitting one model to volumes less than that and another model to larger vol
29,026
Confusion related to Gibbs sampling
When we use the Metropolis-Hastings algorithm we have to compute an acceptance ratio $$\alpha=\min(1,\frac{p(x^*)}{p(x)})$$ and let the random variable $U\sim\text{Uniform(0,1)}$ then we accept the random variable if $U<\alpha$. However, in Gibbs sampling we always accept the random variable because we do not have to calculate the acceptance ratio (well you actually do but when you plug things in you see that everything cancels out and your acceptance ratio is $\alpha=1$ and so clearly $U$ is always less than $\alpha$ and because of that you are always accepting). However, you can also think of it intuitively where in Gibbs sampling you are sampling from the full conditionals which is a closed form expression that we can sample from directly and so there is no need to reject samples like in the Metropolis-Hastings algorithm where we do not know how to sample from (or usually don't recognize the form of) $p(x)$. Hope that helps!
Confusion related to Gibbs sampling
When we use the Metropolis-Hastings algorithm we have to compute an acceptance ratio $$\alpha=\min(1,\frac{p(x^*)}{p(x)})$$ and let the random variable $U\sim\text{Uniform(0,1)}$ then we accept the ra
Confusion related to Gibbs sampling When we use the Metropolis-Hastings algorithm we have to compute an acceptance ratio $$\alpha=\min(1,\frac{p(x^*)}{p(x)})$$ and let the random variable $U\sim\text{Uniform(0,1)}$ then we accept the random variable if $U<\alpha$. However, in Gibbs sampling we always accept the random variable because we do not have to calculate the acceptance ratio (well you actually do but when you plug things in you see that everything cancels out and your acceptance ratio is $\alpha=1$ and so clearly $U$ is always less than $\alpha$ and because of that you are always accepting). However, you can also think of it intuitively where in Gibbs sampling you are sampling from the full conditionals which is a closed form expression that we can sample from directly and so there is no need to reject samples like in the Metropolis-Hastings algorithm where we do not know how to sample from (or usually don't recognize the form of) $p(x)$. Hope that helps!
Confusion related to Gibbs sampling When we use the Metropolis-Hastings algorithm we have to compute an acceptance ratio $$\alpha=\min(1,\frac{p(x^*)}{p(x)})$$ and let the random variable $U\sim\text{Uniform(0,1)}$ then we accept the ra
29,027
Confusion related to Gibbs sampling
The proof that the acceptance rate is equal to 1 as a typo i.e. in the denominator in the middle and third part the expression for q should have z_i prime, so that in the end you get P(z_i prime|z_i prime). Alex
Confusion related to Gibbs sampling
The proof that the acceptance rate is equal to 1 as a typo i.e. in the denominator in the middle and third part the expression for q should have z_i prime, so that in the end you get P(z_i prime|z_i p
Confusion related to Gibbs sampling The proof that the acceptance rate is equal to 1 as a typo i.e. in the denominator in the middle and third part the expression for q should have z_i prime, so that in the end you get P(z_i prime|z_i prime). Alex
Confusion related to Gibbs sampling The proof that the acceptance rate is equal to 1 as a typo i.e. in the denominator in the middle and third part the expression for q should have z_i prime, so that in the end you get P(z_i prime|z_i p
29,028
R/caret: train and test sets vs. cross-validation?
My general thoughts: So when you are evaluating different models, you may want to tune them, try different types of pre-processing etc until you find what you think is a good model. Resampling can help guide you in the right direction during that process. However, there is still the chance of over-fitting and the odds of this happening is greatly influenced by how much data (and predictors) you have. If you have a little bit of data, there are a few ways to think about this: Use all the data for training since every data point adds significantly to how well the model does. Set aside a small test set as a final check for gross errors due to over-fitting. The chances of over-fitting with a small samples size is not small and gets bigger with the number of samples. I fall into the second camp but the first isn't wrong at all. If you have a ton of data then it doesn't really matter much (unless you ave a small event rate). For you: You have a DOE. The type of design would help answer the question. Are you trying to interpolate between design points or predict design points that have not been tested so far? You have one replicate. I fell like random forest is hitting a nail with a sledge hammer and might result in over-fitting. I would try something smoother like an SVM or (gasp) neural network. Max
R/caret: train and test sets vs. cross-validation?
My general thoughts: So when you are evaluating different models, you may want to tune them, try different types of pre-processing etc until you find what you think is a good model. Resampling can hel
R/caret: train and test sets vs. cross-validation? My general thoughts: So when you are evaluating different models, you may want to tune them, try different types of pre-processing etc until you find what you think is a good model. Resampling can help guide you in the right direction during that process. However, there is still the chance of over-fitting and the odds of this happening is greatly influenced by how much data (and predictors) you have. If you have a little bit of data, there are a few ways to think about this: Use all the data for training since every data point adds significantly to how well the model does. Set aside a small test set as a final check for gross errors due to over-fitting. The chances of over-fitting with a small samples size is not small and gets bigger with the number of samples. I fall into the second camp but the first isn't wrong at all. If you have a ton of data then it doesn't really matter much (unless you ave a small event rate). For you: You have a DOE. The type of design would help answer the question. Are you trying to interpolate between design points or predict design points that have not been tested so far? You have one replicate. I fell like random forest is hitting a nail with a sledge hammer and might result in over-fitting. I would try something smoother like an SVM or (gasp) neural network. Max
R/caret: train and test sets vs. cross-validation? My general thoughts: So when you are evaluating different models, you may want to tune them, try different types of pre-processing etc until you find what you think is a good model. Resampling can hel
29,029
Exploring a scatter-plot matrix for many variables
Explore relations between variables is quite vague, but two of the more general goals of examining scatterplots like this I would guess are; Identify underlying latent groups (of variables or cases). Identify outliers (in univariate, bivariate or multivariate space). Both reduce the data into more manageble summaries, but have different goals. Identify latent groups one typically reduces the dimensions in the data (e.g. via PCA) and then explores whether variables or cases cluster together in this reduced space. See for example Friendly (2002) or Cook et al. (1995). Identifying outliers can either mean fitting a model and plotting the deviations from the model (e.g. plotting residuals from a regression model) or reducing the data into its main components and only highlight points that deviate from either the model or the main body of data. E.g. boxplots in one or two dimensions typically only show individual points that are outside of the hinges (Wickham & Stryjewski, 2013). Plotting residuals has the nice property that it should flatten plots (Tukey, 1977), so any evidence of relationships in the remaining point cloud is "interesting". This question on CV has some excellent suggestions of identifying multivariate outliers. A common way to explore such large SPLOMS is to not plot all of the individual points, but some type of simplified summary and then maybe points that deviate largely from this summary, e.g. confidence ellipses, scagnostic summaries (Wilkinson & Wills, 2008), bivariate box-plots, contour plots. Below is an example of plotting ellipses that define the covariance and superimposing a loess smoother to describe the linear association. (source: statmethods.net) Either way, a real sucessful, interactive plot with so many variables would likely need intelligent sorting (Wilkinson, 2005) and a simple way to filter out variables (in addition to brushing/linking capabilities). Also any realistic dataset would need to have the capabilities to transform axis (e.g. plot the data on logarithmic scale, transform the data by taking roots etc.). Good luck, and don't stick with only one plot! Citations Cook, Dianne, Andreas Buja, Javier Cabrera & Catherine Hurley. 1995. Grand tour and projection pursuit. Journal of Computational and Graphical Statistics 4(3):155-172. Friendly, Michael. 2002. Corrgrams: Exploratory displays for correlation matrices. The American Statistician 56(4): 316-324. PDF preprint. Tukey, John. 1977. Exploratory Data Analysis. Addison-Wesley. Reading, Mass. Wickham, Hadley & Lisa Stryjewski. 2013. 40 years of boxplots. Wilkinson, Leland & Graham Wills. 2008. Scagnostic Distributions. Journal of Computational and Graphical Statistics 17(2): 473-491. Wilkinson, Leland. 2005. The Grammar of Graphics. Springer. New York, NY.
Exploring a scatter-plot matrix for many variables
Explore relations between variables is quite vague, but two of the more general goals of examining scatterplots like this I would guess are; Identify underlying latent groups (of variables or cases).
Exploring a scatter-plot matrix for many variables Explore relations between variables is quite vague, but two of the more general goals of examining scatterplots like this I would guess are; Identify underlying latent groups (of variables or cases). Identify outliers (in univariate, bivariate or multivariate space). Both reduce the data into more manageble summaries, but have different goals. Identify latent groups one typically reduces the dimensions in the data (e.g. via PCA) and then explores whether variables or cases cluster together in this reduced space. See for example Friendly (2002) or Cook et al. (1995). Identifying outliers can either mean fitting a model and plotting the deviations from the model (e.g. plotting residuals from a regression model) or reducing the data into its main components and only highlight points that deviate from either the model or the main body of data. E.g. boxplots in one or two dimensions typically only show individual points that are outside of the hinges (Wickham & Stryjewski, 2013). Plotting residuals has the nice property that it should flatten plots (Tukey, 1977), so any evidence of relationships in the remaining point cloud is "interesting". This question on CV has some excellent suggestions of identifying multivariate outliers. A common way to explore such large SPLOMS is to not plot all of the individual points, but some type of simplified summary and then maybe points that deviate largely from this summary, e.g. confidence ellipses, scagnostic summaries (Wilkinson & Wills, 2008), bivariate box-plots, contour plots. Below is an example of plotting ellipses that define the covariance and superimposing a loess smoother to describe the linear association. (source: statmethods.net) Either way, a real sucessful, interactive plot with so many variables would likely need intelligent sorting (Wilkinson, 2005) and a simple way to filter out variables (in addition to brushing/linking capabilities). Also any realistic dataset would need to have the capabilities to transform axis (e.g. plot the data on logarithmic scale, transform the data by taking roots etc.). Good luck, and don't stick with only one plot! Citations Cook, Dianne, Andreas Buja, Javier Cabrera & Catherine Hurley. 1995. Grand tour and projection pursuit. Journal of Computational and Graphical Statistics 4(3):155-172. Friendly, Michael. 2002. Corrgrams: Exploratory displays for correlation matrices. The American Statistician 56(4): 316-324. PDF preprint. Tukey, John. 1977. Exploratory Data Analysis. Addison-Wesley. Reading, Mass. Wickham, Hadley & Lisa Stryjewski. 2013. 40 years of boxplots. Wilkinson, Leland & Graham Wills. 2008. Scagnostic Distributions. Journal of Computational and Graphical Statistics 17(2): 473-491. Wilkinson, Leland. 2005. The Grammar of Graphics. Springer. New York, NY.
Exploring a scatter-plot matrix for many variables Explore relations between variables is quite vague, but two of the more general goals of examining scatterplots like this I would guess are; Identify underlying latent groups (of variables or cases).
29,030
Exploring a scatter-plot matrix for many variables
You could consider using the shiny interface from the pairsD3 R package, which provides a way to interact with scatter plot matrices. An example with the iris data set: install.packages("pairsD3") require("pairsD3") shinypairs(iris) Source: https://github.com/garthtarr/pairsD3
Exploring a scatter-plot matrix for many variables
You could consider using the shiny interface from the pairsD3 R package, which provides a way to interact with scatter plot matrices. An example with the iris data set: install.packages("pairsD3") req
Exploring a scatter-plot matrix for many variables You could consider using the shiny interface from the pairsD3 R package, which provides a way to interact with scatter plot matrices. An example with the iris data set: install.packages("pairsD3") require("pairsD3") shinypairs(iris) Source: https://github.com/garthtarr/pairsD3
Exploring a scatter-plot matrix for many variables You could consider using the shiny interface from the pairsD3 R package, which provides a way to interact with scatter plot matrices. An example with the iris data set: install.packages("pairsD3") req
29,031
Estimating logistic regression coefficients in a case-control design when the outcome variable is not case/control status
This is a variation of the selection model in econometrics. The validity of the estimates using only the selected sample here depends on the condition that $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$. Here $D_i$ is $i$'s disease status. To give more details, define the following notations: $\pi_{1}=\Pr\left(D_{i}=1\right)$ and $\pi_{0}=\Pr\left(D_{i}=0\right)$; $S_{i}=1$ refers to the event that $i$ is in the sample. Moreover, assume $D_{i}$ is independent of $X_{i}$ for simplicity. The probability of $Y_{i}=1$ for a unit $i$ in the sample is \begin{eqnarray*} \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right) & = & \mathrm{{E}}\left(Y_{i}\mid X_{i},S_{i}=1\right)\\ & = & \mathrm{{E}}\left\{ \mathrm{{E}}\left(Y_{i}\mid X_{i},D_{i},S_{i}=1\right)\mid X_{i},S_{i}=1\right\} \\ & = & \Pr\left(D_{i}=1\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1,S_{i}=1\right)+\\ & & \Pr\left(D_{i}=0\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0,S_{i}=1\right), \end{eqnarray*} by the law of iterated expecation. Suppose conditional on the disease status $D_{i}$ and other covariates $X_{i}$, the outcome $Y_{i}$ is independent of $S_{i}$. As a result, we have \begin{eqnarray*} \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right) & = & \Pr\left(D_{i}=1\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)+\\ & & \Pr\left(D_{i}=0\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right). \end{eqnarray*} It is easy to see that $$ \Pr\left(D_{i}=1\mid S_{i}=1\right)=\frac{\pi_{1}p_{i1}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\mbox{ and }\Pr\left(D_{i}=0\mid S_{i}=1\right)=\frac{\pi_{0}p_{i0}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}. $$ Here $p_{i1}$ and $p_{i0}$ are as defined your sampling scheme. Thus, $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)=\frac{\pi_{1}p_{i1}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)+\frac{\pi_{0}p_{i0}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right). $$ If $ $$\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$, we have $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i}\right), $$ and you can omit the sample selection problem. On the other hand, if $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)\neq\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$, $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)\neq\Pr\left(Y_{i}=1\mid X_{i}\right) $$ in general. As a particular case, consider the logit model, $$ \Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\frac{e^{X_{i}'\alpha}}{1+e^{X_{i}'\alpha}}\mbox{ and }\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)=\frac{e^{X_{i}'\beta}}{1+e^{X_{i}'\beta}}. $$ Even when $p_{i1}$ and $p_{i0}$ are constant across $i$, the resulted distribution will not keep the logit formation. More importantly, the intepretations of the parameters would be totally different. Hopefully, the above arguments help to clarify your problem a little bit. It is tempted to include $D_{i}$ as an additional explanatory variable, and estimate the model based on $\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$. To justify the validity of using $\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$, we need to prove that $\Pr\left(Y_{i}\mid X_{i},D_{i},S_{i}=1\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$, which is equivalent to the condition that $D_{i}$ is a sufficient statistic of $S_{i}$. Without further information about your sampling process, I am not sure if it is true. Let's use an abstract notation. The observability variable $S_{i}$ can be viewed as random function of $D_{i}$ and the other random variables, say $\mathbf{Z}_{i}$. Denote $S_{i}=S\left(D_{i},\mathbf{Z}_{i}\right)$. If $\mathbf{Z}_{i}$ is independent of $Y_{i}$ conditional on $X_{i}$ and $D_{i}$, we have $\Pr\left(Y_{i}\mid X_{i},D_{i},S\left(D_{i},\mathbf{Z}_{i}\right)\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$ by the definition of independence. However, if $\mathbf{Z}_{i}$ is not independent of $Y_{i}$ after conditioning on $X_{i}$ and $D_{i}$, $\mathbf{Z}_{i}$ intuitively contains some relevant information about $Y_{i}$, and in general it is not expected that $\Pr\left(Y_{i}\mid X_{i},D_{i},S\left(D_{i},\mathbf{Z}_{i}\right)\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$. Thus, in the 'however' case, the ignorance of sample selection could be misleading for inference. I am not very familiar with the sample selection literature in econometrics. I would recommend Chapter 16 of Microeconometrics: methods and applications' by Cameron and Trivedi (especially the Roy model in that chapter). Also G. S. Maddala's classic bookLimited-dependent and qualitative variables in econometrics' is a systematic treatment of the issues about sample selection and discrete outcomes.
Estimating logistic regression coefficients in a case-control design when the outcome variable is no
This is a variation of the selection model in econometrics. The validity of the estimates using only the selected sample here depends on the condition that $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\
Estimating logistic regression coefficients in a case-control design when the outcome variable is not case/control status This is a variation of the selection model in econometrics. The validity of the estimates using only the selected sample here depends on the condition that $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$. Here $D_i$ is $i$'s disease status. To give more details, define the following notations: $\pi_{1}=\Pr\left(D_{i}=1\right)$ and $\pi_{0}=\Pr\left(D_{i}=0\right)$; $S_{i}=1$ refers to the event that $i$ is in the sample. Moreover, assume $D_{i}$ is independent of $X_{i}$ for simplicity. The probability of $Y_{i}=1$ for a unit $i$ in the sample is \begin{eqnarray*} \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right) & = & \mathrm{{E}}\left(Y_{i}\mid X_{i},S_{i}=1\right)\\ & = & \mathrm{{E}}\left\{ \mathrm{{E}}\left(Y_{i}\mid X_{i},D_{i},S_{i}=1\right)\mid X_{i},S_{i}=1\right\} \\ & = & \Pr\left(D_{i}=1\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1,S_{i}=1\right)+\\ & & \Pr\left(D_{i}=0\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0,S_{i}=1\right), \end{eqnarray*} by the law of iterated expecation. Suppose conditional on the disease status $D_{i}$ and other covariates $X_{i}$, the outcome $Y_{i}$ is independent of $S_{i}$. As a result, we have \begin{eqnarray*} \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right) & = & \Pr\left(D_{i}=1\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)+\\ & & \Pr\left(D_{i}=0\mid S_{i}=1\right)\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right). \end{eqnarray*} It is easy to see that $$ \Pr\left(D_{i}=1\mid S_{i}=1\right)=\frac{\pi_{1}p_{i1}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\mbox{ and }\Pr\left(D_{i}=0\mid S_{i}=1\right)=\frac{\pi_{0}p_{i0}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}. $$ Here $p_{i1}$ and $p_{i0}$ are as defined your sampling scheme. Thus, $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)=\frac{\pi_{1}p_{i1}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)+\frac{\pi_{0}p_{i0}}{\pi_{1}p_{i1}+\pi_{0}p_{i0}}\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right). $$ If $ $$\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$, we have $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)=\Pr\left(Y_{i}=1\mid X_{i}\right), $$ and you can omit the sample selection problem. On the other hand, if $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)\neq\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)$, $$ \Pr\left(Y_{i}=1\mid X_{i},S_{i}=1\right)\neq\Pr\left(Y_{i}=1\mid X_{i}\right) $$ in general. As a particular case, consider the logit model, $$ \Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\frac{e^{X_{i}'\alpha}}{1+e^{X_{i}'\alpha}}\mbox{ and }\Pr\left(Y_{i}=1\mid X_{i},D_{i}=0\right)=\frac{e^{X_{i}'\beta}}{1+e^{X_{i}'\beta}}. $$ Even when $p_{i1}$ and $p_{i0}$ are constant across $i$, the resulted distribution will not keep the logit formation. More importantly, the intepretations of the parameters would be totally different. Hopefully, the above arguments help to clarify your problem a little bit. It is tempted to include $D_{i}$ as an additional explanatory variable, and estimate the model based on $\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$. To justify the validity of using $\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$, we need to prove that $\Pr\left(Y_{i}\mid X_{i},D_{i},S_{i}=1\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$, which is equivalent to the condition that $D_{i}$ is a sufficient statistic of $S_{i}$. Without further information about your sampling process, I am not sure if it is true. Let's use an abstract notation. The observability variable $S_{i}$ can be viewed as random function of $D_{i}$ and the other random variables, say $\mathbf{Z}_{i}$. Denote $S_{i}=S\left(D_{i},\mathbf{Z}_{i}\right)$. If $\mathbf{Z}_{i}$ is independent of $Y_{i}$ conditional on $X_{i}$ and $D_{i}$, we have $\Pr\left(Y_{i}\mid X_{i},D_{i},S\left(D_{i},\mathbf{Z}_{i}\right)\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$ by the definition of independence. However, if $\mathbf{Z}_{i}$ is not independent of $Y_{i}$ after conditioning on $X_{i}$ and $D_{i}$, $\mathbf{Z}_{i}$ intuitively contains some relevant information about $Y_{i}$, and in general it is not expected that $\Pr\left(Y_{i}\mid X_{i},D_{i},S\left(D_{i},\mathbf{Z}_{i}\right)\right)=\Pr\left(Y_{i}\mid X_{i},D_{i}\right)$. Thus, in the 'however' case, the ignorance of sample selection could be misleading for inference. I am not very familiar with the sample selection literature in econometrics. I would recommend Chapter 16 of Microeconometrics: methods and applications' by Cameron and Trivedi (especially the Roy model in that chapter). Also G. S. Maddala's classic bookLimited-dependent and qualitative variables in econometrics' is a systematic treatment of the issues about sample selection and discrete outcomes.
Estimating logistic regression coefficients in a case-control design when the outcome variable is no This is a variation of the selection model in econometrics. The validity of the estimates using only the selected sample here depends on the condition that $\Pr\left(Y_{i}=1\mid X_{i},D_{i}=1\right)=\
29,032
Mahalanobis distance on non-normal data
You might want to check out Karlis and Meligkotsidou, "Multivariate poisson regression with covariance structure". 2005. This paper is about the authors' attempts to model multivariate Poisson variables, which they acknowledge to be a difficult task. Use of the Mahalanobis' distance implies that inference can be done through the mean and covariance matrix - and that is a property of the normal distribution alone. If you use the MD on your data, you are basically pretending that they are Normal.
Mahalanobis distance on non-normal data
You might want to check out Karlis and Meligkotsidou, "Multivariate poisson regression with covariance structure". 2005. This paper is about the authors' attempts to model multivariate Poisson variabl
Mahalanobis distance on non-normal data You might want to check out Karlis and Meligkotsidou, "Multivariate poisson regression with covariance structure". 2005. This paper is about the authors' attempts to model multivariate Poisson variables, which they acknowledge to be a difficult task. Use of the Mahalanobis' distance implies that inference can be done through the mean and covariance matrix - and that is a property of the normal distribution alone. If you use the MD on your data, you are basically pretending that they are Normal.
Mahalanobis distance on non-normal data You might want to check out Karlis and Meligkotsidou, "Multivariate poisson regression with covariance structure". 2005. This paper is about the authors' attempts to model multivariate Poisson variabl
29,033
Robust mean estimation with O(1) update efficiency
You might think of relating your problem to that of the recursive control chart. Such a control chart will evaluate whether a new observation is in control. If it is, this observation is included in the new estimate of the mean and variance (necessary to determine control limits). Some background on robust, recursive, univariate control charts can be found here. One of the classic texts on quality control and control charts appears to be available online here. Intuitively, using the a mean, $\mu_{t-1}$ and a variance $\sigma^2_{t-1}$ as inputs, you can determine whether a new observation at time $t$ is an outlier by a number of approaches. One would be to declare $x_t$ an outlier if it is outside of a certain number of standard deviations of $\mu_{t-1}$ (given $\sigma^2_{t-1})$, but this may run into problems if the data does not conform to certain distributional assumptions. If you want to go this road, then supposing you have determined if a new point is not an outlier, and would like to include it in your mean estimate with no special rate of forgetting. Then you can't do better than: $\mu_t = \frac{t-1}{t}\mu_{t-1}+\frac{1}{t}x_t$ Similarly, you will need to update the variance recursively: $\sigma^2_t = \frac{t-1}{t}\sigma^2_{t-1}+\frac{1}{t-1}(x_t-\mu_t)^2$ However, you might want to try some more conventional control charts. Other control charts which are more robust to the distribution of the data and can still handle non-stationarity (like the $\mu$ of your process slowly going higher) are the EWMA or CUSUM are recommended (see the textbook linked to above for more details on the charts and their control limits). These methods will typically be less computationally intensive than a robust because they have the advantage of simply needing to compare a single new observation to information derived from non-outlier observations. You can refine your estimates of the long term process $\mu$ and $\sigma^2$ used in the control limit calculations of these methods with the updating formulas given above if you like. Regarding a chart like the EWMA, which forgets old observations and gives more weight to new ones, if you think that your data is stationary (meaning the parameters of the generating distribution do not change) then there is no need to forget older observations exponentially. You can set the forgetting factor accordingly. However, if you think that it is non-stationarity you will need to select a good value for the forgetting factor (again see the textbook for a way to do this). I should also mention that before you begin monitoring and adding new observations online, you will need to obtain estimates of $\mu_0$ and $\sigma^2_0$ (the initial parameter values based on a training dataset) that are not influenced by outliers. If you suspect there are outliers in your training data, you can pay the one-time cost of using a robust method to estimate them. I think an approach along these lines will lead to the fastest updating for your problem.
Robust mean estimation with O(1) update efficiency
You might think of relating your problem to that of the recursive control chart. Such a control chart will evaluate whether a new observation is in control. If it is, this observation is included in t
Robust mean estimation with O(1) update efficiency You might think of relating your problem to that of the recursive control chart. Such a control chart will evaluate whether a new observation is in control. If it is, this observation is included in the new estimate of the mean and variance (necessary to determine control limits). Some background on robust, recursive, univariate control charts can be found here. One of the classic texts on quality control and control charts appears to be available online here. Intuitively, using the a mean, $\mu_{t-1}$ and a variance $\sigma^2_{t-1}$ as inputs, you can determine whether a new observation at time $t$ is an outlier by a number of approaches. One would be to declare $x_t$ an outlier if it is outside of a certain number of standard deviations of $\mu_{t-1}$ (given $\sigma^2_{t-1})$, but this may run into problems if the data does not conform to certain distributional assumptions. If you want to go this road, then supposing you have determined if a new point is not an outlier, and would like to include it in your mean estimate with no special rate of forgetting. Then you can't do better than: $\mu_t = \frac{t-1}{t}\mu_{t-1}+\frac{1}{t}x_t$ Similarly, you will need to update the variance recursively: $\sigma^2_t = \frac{t-1}{t}\sigma^2_{t-1}+\frac{1}{t-1}(x_t-\mu_t)^2$ However, you might want to try some more conventional control charts. Other control charts which are more robust to the distribution of the data and can still handle non-stationarity (like the $\mu$ of your process slowly going higher) are the EWMA or CUSUM are recommended (see the textbook linked to above for more details on the charts and their control limits). These methods will typically be less computationally intensive than a robust because they have the advantage of simply needing to compare a single new observation to information derived from non-outlier observations. You can refine your estimates of the long term process $\mu$ and $\sigma^2$ used in the control limit calculations of these methods with the updating formulas given above if you like. Regarding a chart like the EWMA, which forgets old observations and gives more weight to new ones, if you think that your data is stationary (meaning the parameters of the generating distribution do not change) then there is no need to forget older observations exponentially. You can set the forgetting factor accordingly. However, if you think that it is non-stationarity you will need to select a good value for the forgetting factor (again see the textbook for a way to do this). I should also mention that before you begin monitoring and adding new observations online, you will need to obtain estimates of $\mu_0$ and $\sigma^2_0$ (the initial parameter values based on a training dataset) that are not influenced by outliers. If you suspect there are outliers in your training data, you can pay the one-time cost of using a robust method to estimate them. I think an approach along these lines will lead to the fastest updating for your problem.
Robust mean estimation with O(1) update efficiency You might think of relating your problem to that of the recursive control chart. Such a control chart will evaluate whether a new observation is in control. If it is, this observation is included in t
29,034
Robust mean estimation with O(1) update efficiency
This solution implements a suggestion made by @Innuo in a comment to the question: You can maintain a uniformly sampled random subset of size 100 or 1000 from all the data seen thus far. This set and the associated "fences" can be updated in $O(1)$ time. Once we know how to maintain this subset, we may select any method we like to estimate the mean of a population from such a sample. This is a universal method, making no assumptions whatsoever, that will work with any input stream to within an accuracy that can be predicted using standard statistical sampling formulas. (The accuracy is inversely proportional to the square root of the sample size.) This algorithm accepts as input a stream of data $x(t),$ $t=1, 2, \ldots,$ a sample size $m$, and outputs a stream of samples $s(t)$ each of which represent the population $X(t) = (x(1),x(2), \ldots, x(t))$. Specifically, for $1\le i \le t$, $s(i)$ is a simple random sample of size $m$ from $X(t)$ (without replacement). For this to happen, it suffices that every $m$-element subset of $\{1,2,\ldots,t\}$ have equal chances of being the indexes of $x$ in $s(t)$. This implies the chance that $x(i),$ $1\le i\lt t,$ is in $s(t)$ equals $m/t$ provided $t \ge m$. At the beginning we just collect the stream until $m$ elements have been stored. At that point there is only one possible sample, so the probability condition is trivially satisfied. The algorithm takes over when $t=m+1$. Inductively suppose that $s(t)$ is a simple random sample of $X(t)$ for $t\gt m$. Provisionally set $s(t+1) = s(t)$. Let $U(t+1)$ be a uniform random variable (independent of any previous variables used to construct $s(t)$). If $U(t+1) \le m/(t+1)$ then replace a randomly chosen element of $s$ by $x(t+1)$. That's the entire procedure! Clearly $x(t+1)$ has probability $m/(t+1)$ of being in $s(t+1)$. Moreover, by the induction hypothesis, $x(i)$ had probability $m/t$ of being in $s(t)$ when $i\le t$. With probability $m/(t+1) \times 1/m$ = $1/(t+1)$ it will have been removed from $s(t+1)$, whence its probability of remaining equals $$\frac{m}{t}\left(1 - \frac{1}{t+1}\right) = \frac{m}{t+1},$$ exactly as needed. By induction, then, all the inclusion probabilities of the $x(i)$ in the $s(t)$ are correct and it's clear there is no special correlation among those inclusions. That proves the algorithm is correct. The algorithm efficiency is $O(1)$ because at each stage at most two random numbers are computed and at most one element of an array of $m$ values is replaced. The storage requirement is $O(m)$. The data structure for this algorithm consists of the sample $s$ together with the index $t$ of the population $X(t)$ that it samples. Initially we take $s = X(m)$ and proceed with the algorithm for $t=m+1, m+2, \ldots.$ Here is an R implementation to update $(s,t)$ with a value $x$ to produce $(s,t+1)$. (The argument n plays the role of $t$ and sample.size is $m$. The index $t$ will be maintained by the caller.) update <- function(s, x, n, sample.size) { if (length(s) < sample.size) { s <- c(s, x) } else if (runif(1) <= sample.size / n) { i <- sample.int(length(s), 1) s[i] <- x } return (s) } To illustrate and test this, I will use the usual (non-robust) estimator of the mean and compare the mean as estimated from $s(t)$ to the actual mean of $X(t)$ (the cumulative set of data seen at each step). I chose a somewhat difficult input stream that changes quite smoothly but periodically undergoes dramatic jumps. The sample size of $m=50$ is fairly small, allowing us to see sampling fluctuations in these plots. n <- 10^3 x <- sapply(1:(7*n), function(t) cos(pi*t/n) + 2*floor((1+t)/n)) n.sample <- 50 s <- x[1:(n.sample-1)] online <- sapply(n.sample:length(x), function(i) { s <<- update(s, x[i], i, n.sample) summary(s)}) actual <- sapply(n.sample:length(x), function(i) summary(x[1:i])) At this point online is the sequence of mean estimates produced by maintaining this running sample of $50$ values while actual is the sequence of mean estimates produced from all the data available at each moment. The plot shows the data (in gray), actual (in black), and two independent applications of this sampling procedure (in colors). The agreement is within expected sampling error: plot(x, pch=".", col="Gray") lines(1:dim(actual)[2], actual["Mean", ]) lines(1:dim(online)[2], online["Mean", ], col="Red") For robust estimators of the mean, please search our site for outlier and related terms. Among the possibilities worth considering are Winsorized means and M-estimators.
Robust mean estimation with O(1) update efficiency
This solution implements a suggestion made by @Innuo in a comment to the question: You can maintain a uniformly sampled random subset of size 100 or 1000 from all the data seen thus far. This set and
Robust mean estimation with O(1) update efficiency This solution implements a suggestion made by @Innuo in a comment to the question: You can maintain a uniformly sampled random subset of size 100 or 1000 from all the data seen thus far. This set and the associated "fences" can be updated in $O(1)$ time. Once we know how to maintain this subset, we may select any method we like to estimate the mean of a population from such a sample. This is a universal method, making no assumptions whatsoever, that will work with any input stream to within an accuracy that can be predicted using standard statistical sampling formulas. (The accuracy is inversely proportional to the square root of the sample size.) This algorithm accepts as input a stream of data $x(t),$ $t=1, 2, \ldots,$ a sample size $m$, and outputs a stream of samples $s(t)$ each of which represent the population $X(t) = (x(1),x(2), \ldots, x(t))$. Specifically, for $1\le i \le t$, $s(i)$ is a simple random sample of size $m$ from $X(t)$ (without replacement). For this to happen, it suffices that every $m$-element subset of $\{1,2,\ldots,t\}$ have equal chances of being the indexes of $x$ in $s(t)$. This implies the chance that $x(i),$ $1\le i\lt t,$ is in $s(t)$ equals $m/t$ provided $t \ge m$. At the beginning we just collect the stream until $m$ elements have been stored. At that point there is only one possible sample, so the probability condition is trivially satisfied. The algorithm takes over when $t=m+1$. Inductively suppose that $s(t)$ is a simple random sample of $X(t)$ for $t\gt m$. Provisionally set $s(t+1) = s(t)$. Let $U(t+1)$ be a uniform random variable (independent of any previous variables used to construct $s(t)$). If $U(t+1) \le m/(t+1)$ then replace a randomly chosen element of $s$ by $x(t+1)$. That's the entire procedure! Clearly $x(t+1)$ has probability $m/(t+1)$ of being in $s(t+1)$. Moreover, by the induction hypothesis, $x(i)$ had probability $m/t$ of being in $s(t)$ when $i\le t$. With probability $m/(t+1) \times 1/m$ = $1/(t+1)$ it will have been removed from $s(t+1)$, whence its probability of remaining equals $$\frac{m}{t}\left(1 - \frac{1}{t+1}\right) = \frac{m}{t+1},$$ exactly as needed. By induction, then, all the inclusion probabilities of the $x(i)$ in the $s(t)$ are correct and it's clear there is no special correlation among those inclusions. That proves the algorithm is correct. The algorithm efficiency is $O(1)$ because at each stage at most two random numbers are computed and at most one element of an array of $m$ values is replaced. The storage requirement is $O(m)$. The data structure for this algorithm consists of the sample $s$ together with the index $t$ of the population $X(t)$ that it samples. Initially we take $s = X(m)$ and proceed with the algorithm for $t=m+1, m+2, \ldots.$ Here is an R implementation to update $(s,t)$ with a value $x$ to produce $(s,t+1)$. (The argument n plays the role of $t$ and sample.size is $m$. The index $t$ will be maintained by the caller.) update <- function(s, x, n, sample.size) { if (length(s) < sample.size) { s <- c(s, x) } else if (runif(1) <= sample.size / n) { i <- sample.int(length(s), 1) s[i] <- x } return (s) } To illustrate and test this, I will use the usual (non-robust) estimator of the mean and compare the mean as estimated from $s(t)$ to the actual mean of $X(t)$ (the cumulative set of data seen at each step). I chose a somewhat difficult input stream that changes quite smoothly but periodically undergoes dramatic jumps. The sample size of $m=50$ is fairly small, allowing us to see sampling fluctuations in these plots. n <- 10^3 x <- sapply(1:(7*n), function(t) cos(pi*t/n) + 2*floor((1+t)/n)) n.sample <- 50 s <- x[1:(n.sample-1)] online <- sapply(n.sample:length(x), function(i) { s <<- update(s, x[i], i, n.sample) summary(s)}) actual <- sapply(n.sample:length(x), function(i) summary(x[1:i])) At this point online is the sequence of mean estimates produced by maintaining this running sample of $50$ values while actual is the sequence of mean estimates produced from all the data available at each moment. The plot shows the data (in gray), actual (in black), and two independent applications of this sampling procedure (in colors). The agreement is within expected sampling error: plot(x, pch=".", col="Gray") lines(1:dim(actual)[2], actual["Mean", ]) lines(1:dim(online)[2], online["Mean", ], col="Red") For robust estimators of the mean, please search our site for outlier and related terms. Among the possibilities worth considering are Winsorized means and M-estimators.
Robust mean estimation with O(1) update efficiency This solution implements a suggestion made by @Innuo in a comment to the question: You can maintain a uniformly sampled random subset of size 100 or 1000 from all the data seen thus far. This set and
29,035
Discrete time hazard models (cloglog) in R
Having several rows for each observation may seem redundant, but, likely, it's not. If there are any time-varying covariates in the model, then each observation-month will certainly need its own row. One particular example of a time-varying covariate is the elapsed time. Since this variable should almost certainly be included in the model, it makes sense to have a separate row for each observation-period. Thus, the first approach suggested is likely the best one. Note that this is different from a continuous time proportional hazards model with a Weibull distribution. There, the survival model can be simplified to a single line for each observation if time elapsed is the only time-varying covariate (see here, for example). A similar result holds for the Cox proportional hazard model.
Discrete time hazard models (cloglog) in R
Having several rows for each observation may seem redundant, but, likely, it's not. If there are any time-varying covariates in the model, then each observation-month will certainly need its own row.
Discrete time hazard models (cloglog) in R Having several rows for each observation may seem redundant, but, likely, it's not. If there are any time-varying covariates in the model, then each observation-month will certainly need its own row. One particular example of a time-varying covariate is the elapsed time. Since this variable should almost certainly be included in the model, it makes sense to have a separate row for each observation-period. Thus, the first approach suggested is likely the best one. Note that this is different from a continuous time proportional hazards model with a Weibull distribution. There, the survival model can be simplified to a single line for each observation if time elapsed is the only time-varying covariate (see here, for example). A similar result holds for the Cox proportional hazard model.
Discrete time hazard models (cloglog) in R Having several rows for each observation may seem redundant, but, likely, it's not. If there are any time-varying covariates in the model, then each observation-month will certainly need its own row.
29,036
Does stan do predictive posteriors?
According to the Stan User manual v2.2.0 (pages 361–362): In Stan, posterior simulations can be generated in two ways. The first approach is to treat the predicted variables as parameters and then define their distributions in the model block. The second approach, which also works for discrete variables, is to generate replicated data using random-number generators in the generated quantities block. I usually use the latter.
Does stan do predictive posteriors?
According to the Stan User manual v2.2.0 (pages 361–362): In Stan, posterior simulations can be generated in two ways. The first approach is to treat the predicted variables as parameters and then
Does stan do predictive posteriors? According to the Stan User manual v2.2.0 (pages 361–362): In Stan, posterior simulations can be generated in two ways. The first approach is to treat the predicted variables as parameters and then define their distributions in the model block. The second approach, which also works for discrete variables, is to generate replicated data using random-number generators in the generated quantities block. I usually use the latter.
Does stan do predictive posteriors? According to the Stan User manual v2.2.0 (pages 361–362): In Stan, posterior simulations can be generated in two ways. The first approach is to treat the predicted variables as parameters and then
29,037
Does stan do predictive posteriors?
The following is not a thorough answer, but hopefully it's better than no answer. In my own applications I apply posterior predictive checks to examine model predictions for a single dependent measure which has been generated from a linear model. This is simple in JAGS, but somewhat more opaque in Stan. data{ int<lower=1> N; // no. rows real x[N]; // predictor real y[N]; // dependent variable } parameters{ real alpha; // int. real beta; // slope real<lower=0> sigma_e; // resid. var. real y_tilde[N]; // post. pred. } model{ real mu[N]; for(i in 1:N){ mu[i] <- alpha + beta*x[i]; } y ~ normal(mu,sigma_e); //lik y_tilde ~ normal(mu,sigma_e); alpha ~ normal(0,5); beta ~ normal(0,5); sigma_e ~ cauchy(0,5); } generated quantities{ real minimum; real maximum; minimum <- min(y_tilde); maximum <- max(y_tilde); } There must be a better way to do this, so someone please post a better answer. But the above code generates N posterior predictive distributions, one for each observation. I do this so that the a predictive distribution of extrema can be found, but if you only are interested in the posterior predictive quantity y_tilde you may be able to do without all of them. For large data sets the above solution is obviously too space-intensive.
Does stan do predictive posteriors?
The following is not a thorough answer, but hopefully it's better than no answer. In my own applications I apply posterior predictive checks to examine model predictions for a single dependent measure
Does stan do predictive posteriors? The following is not a thorough answer, but hopefully it's better than no answer. In my own applications I apply posterior predictive checks to examine model predictions for a single dependent measure which has been generated from a linear model. This is simple in JAGS, but somewhat more opaque in Stan. data{ int<lower=1> N; // no. rows real x[N]; // predictor real y[N]; // dependent variable } parameters{ real alpha; // int. real beta; // slope real<lower=0> sigma_e; // resid. var. real y_tilde[N]; // post. pred. } model{ real mu[N]; for(i in 1:N){ mu[i] <- alpha + beta*x[i]; } y ~ normal(mu,sigma_e); //lik y_tilde ~ normal(mu,sigma_e); alpha ~ normal(0,5); beta ~ normal(0,5); sigma_e ~ cauchy(0,5); } generated quantities{ real minimum; real maximum; minimum <- min(y_tilde); maximum <- max(y_tilde); } There must be a better way to do this, so someone please post a better answer. But the above code generates N posterior predictive distributions, one for each observation. I do this so that the a predictive distribution of extrema can be found, but if you only are interested in the posterior predictive quantity y_tilde you may be able to do without all of them. For large data sets the above solution is obviously too space-intensive.
Does stan do predictive posteriors? The following is not a thorough answer, but hopefully it's better than no answer. In my own applications I apply posterior predictive checks to examine model predictions for a single dependent measure
29,038
Packages or libraries for multiple-output learning
I recommend the following resources (for some of those, you would need to do some detective work, obviously). I agree with @Innuo that PLS regression and pls R package are worth the look. For Python: This part of the curated list; also this part of the same list; this page from the documentation. For R: This part of the same list; CRAN Task View: Machine Learning & Statistical Learning. I think that the following resources might also be quite helpful: this relevant discussion on CV, this technical report on multi-output learning via spectral filtering, this page on Output Kernel Learning, and this excellent tutorial on multi-target prediction.
Packages or libraries for multiple-output learning
I recommend the following resources (for some of those, you would need to do some detective work, obviously). I agree with @Innuo that PLS regression and pls R package are worth the look. For Python:
Packages or libraries for multiple-output learning I recommend the following resources (for some of those, you would need to do some detective work, obviously). I agree with @Innuo that PLS regression and pls R package are worth the look. For Python: This part of the curated list; also this part of the same list; this page from the documentation. For R: This part of the same list; CRAN Task View: Machine Learning & Statistical Learning. I think that the following resources might also be quite helpful: this relevant discussion on CV, this technical report on multi-output learning via spectral filtering, this page on Output Kernel Learning, and this excellent tutorial on multi-target prediction.
Packages or libraries for multiple-output learning I recommend the following resources (for some of those, you would need to do some detective work, obviously). I agree with @Innuo that PLS regression and pls R package are worth the look. For Python:
29,039
Packages or libraries for multiple-output learning
I know of the PLS R-package, which support multi-response regression. See "The pls Package: Principal Component and Partial Least Squares Regression in R", Journal of Statistical Software, Vol. 18, Issue 2, Jan 2007 for more information. There is some more information at http://mevik.net/work/software/pls.html
Packages or libraries for multiple-output learning
I know of the PLS R-package, which support multi-response regression. See "The pls Package: Principal Component and Partial Least Squares Regression in R", Journal of Statistical Software, Vol. 18, Is
Packages or libraries for multiple-output learning I know of the PLS R-package, which support multi-response regression. See "The pls Package: Principal Component and Partial Least Squares Regression in R", Journal of Statistical Software, Vol. 18, Issue 2, Jan 2007 for more information. There is some more information at http://mevik.net/work/software/pls.html
Packages or libraries for multiple-output learning I know of the PLS R-package, which support multi-response regression. See "The pls Package: Principal Component and Partial Least Squares Regression in R", Journal of Statistical Software, Vol. 18, Is
29,040
Visualize survival analysis with time dependent covariates
I haven't been able to gain access to the Simon and Makuch article mentioned above, but having researched the topic I found: Steven M Snapinn, Qi Jiang & Boris Iglewicz (2005) Illustrating the Impact of a Time-Varying Covariate With an Extended Kaplan-Meier Estimator, The American Statistician, 59:4, 301-307. That article proposes a time-dependent Kaplan-Meier plot (KM) by simply updating the cohorts at all event times. It also cites the Simon and Makuch article for proposing a similar idea. The regular KM does not allow this, it only allows a fixed division into groups. The proposed method actually splits survival time according to covariate status - just like one could do when estimating a Cox model with piecewise constant covariates. For the Cox model this is a viable idea, and a standard one. It is, however, more intricate when doing a KM plot. Let me illustrate it with a simulation example. Let's assume that we have no censoring, but some event (e.g., giving birth) that might or might not occur before time of death. Let's also assume constant hazards for the sake of simplicity. We will also assume that giving birth does not alter the hazard of dying. We will now follow the procedure prescribed in the above article. The article clearly states how this is done in R, simply split your subjects on time of giving birth such that they're constant in your grouping variable. Then use the counting process formulation in the Surv function. In code library(survival) library(ggplot2) n <- 10000 data <- data.frame(id = seq(n), preg = rexp(n, 1), death = rexp(n, .5), enter = 0, per = NA, event = 1) data$exit <- data$death data0 <- data data0$exit <- with(data, pmin(preg, death)) data0$per <- 0 data0$event[with(data0, preg < death)] <- 0 data1 <- subset(data, preg < death) data1$enter <- data1$preg data1$per <- 1 data <- rbind(data0, data1) data <- data[order(data$id), ] Sfit <- survfit(Surv(time = enter, time2 = exit, event = event) ~ per, data = data) autoplot(Sfit, censSize = 0)$plot I'm more or less splitting it "by hand". We could use survSplit as well. The procedure actually gives me a very nice estimate. We get almost identical estimates for the two groups as we should. But actually, my simulation was perhaps a bit unrealistic. Let's say a woman cannot give birth in the first two time units for some reason. This is at least reasonable in your example: there'll be some time between two pregnancies corresponding to the same woman. Making a small addition to the code data <- data.frame(id = seq(n), preg = rexp(n, 1) + 2, death = rexp(n, .5), enter = 0, preg = NA, event = 1) we get the following plot: The same thing would be happening with your data. You will not see any 3rd pregnancies for at least some initial period of time, meaning that your estimate will be 1 for that group and that period of time. This is in my opinion a misrepresentation of your data. Consider my simulation. The hazards are identical, but for every time point the per1 estimate is greater than the per0 estimate. You could consider different remedies to this problem. You propose pasting them together at some point (let the per1-curve start from a certain point on the per0-curve). I like this idea. If I do it on the simulation data, we get: In our specific case, I think this represents data way better, but I don't know of any published results that support this approach. Heuristically, one can use the argument I presented in another answer: KM plot with time-varying coefficient
Visualize survival analysis with time dependent covariates
I haven't been able to gain access to the Simon and Makuch article mentioned above, but having researched the topic I found: Steven M Snapinn, Qi Jiang & Boris Iglewicz (2005) Illustrating the Impact
Visualize survival analysis with time dependent covariates I haven't been able to gain access to the Simon and Makuch article mentioned above, but having researched the topic I found: Steven M Snapinn, Qi Jiang & Boris Iglewicz (2005) Illustrating the Impact of a Time-Varying Covariate With an Extended Kaplan-Meier Estimator, The American Statistician, 59:4, 301-307. That article proposes a time-dependent Kaplan-Meier plot (KM) by simply updating the cohorts at all event times. It also cites the Simon and Makuch article for proposing a similar idea. The regular KM does not allow this, it only allows a fixed division into groups. The proposed method actually splits survival time according to covariate status - just like one could do when estimating a Cox model with piecewise constant covariates. For the Cox model this is a viable idea, and a standard one. It is, however, more intricate when doing a KM plot. Let me illustrate it with a simulation example. Let's assume that we have no censoring, but some event (e.g., giving birth) that might or might not occur before time of death. Let's also assume constant hazards for the sake of simplicity. We will also assume that giving birth does not alter the hazard of dying. We will now follow the procedure prescribed in the above article. The article clearly states how this is done in R, simply split your subjects on time of giving birth such that they're constant in your grouping variable. Then use the counting process formulation in the Surv function. In code library(survival) library(ggplot2) n <- 10000 data <- data.frame(id = seq(n), preg = rexp(n, 1), death = rexp(n, .5), enter = 0, per = NA, event = 1) data$exit <- data$death data0 <- data data0$exit <- with(data, pmin(preg, death)) data0$per <- 0 data0$event[with(data0, preg < death)] <- 0 data1 <- subset(data, preg < death) data1$enter <- data1$preg data1$per <- 1 data <- rbind(data0, data1) data <- data[order(data$id), ] Sfit <- survfit(Surv(time = enter, time2 = exit, event = event) ~ per, data = data) autoplot(Sfit, censSize = 0)$plot I'm more or less splitting it "by hand". We could use survSplit as well. The procedure actually gives me a very nice estimate. We get almost identical estimates for the two groups as we should. But actually, my simulation was perhaps a bit unrealistic. Let's say a woman cannot give birth in the first two time units for some reason. This is at least reasonable in your example: there'll be some time between two pregnancies corresponding to the same woman. Making a small addition to the code data <- data.frame(id = seq(n), preg = rexp(n, 1) + 2, death = rexp(n, .5), enter = 0, preg = NA, event = 1) we get the following plot: The same thing would be happening with your data. You will not see any 3rd pregnancies for at least some initial period of time, meaning that your estimate will be 1 for that group and that period of time. This is in my opinion a misrepresentation of your data. Consider my simulation. The hazards are identical, but for every time point the per1 estimate is greater than the per0 estimate. You could consider different remedies to this problem. You propose pasting them together at some point (let the per1-curve start from a certain point on the per0-curve). I like this idea. If I do it on the simulation data, we get: In our specific case, I think this represents data way better, but I don't know of any published results that support this approach. Heuristically, one can use the argument I presented in another answer: KM plot with time-varying coefficient
Visualize survival analysis with time dependent covariates I haven't been able to gain access to the Simon and Makuch article mentioned above, but having researched the topic I found: Steven M Snapinn, Qi Jiang & Boris Iglewicz (2005) Illustrating the Impact
29,041
Visualize survival analysis with time dependent covariates
There is a recent post on this issue at large in CV: Which is the best graph to describe a survival analysis with a time-dependent covariate? In addition, there is now the possibility to compute the Mantel-Byar test and accompanying Simon-Makuch plot in R, using the Rcmdr and the RcmdrPlugin.EZR packages. See the related SO post containing a detailed R code: https://stackoverflow.com/questions/40431559/mantel-byar-test-and-simon-makuch-plot-for-survival-analysis-with-time-dependent
Visualize survival analysis with time dependent covariates
There is a recent post on this issue at large in CV: Which is the best graph to describe a survival analysis with a time-dependent covariate? In addition, there is now the possibility to compute the M
Visualize survival analysis with time dependent covariates There is a recent post on this issue at large in CV: Which is the best graph to describe a survival analysis with a time-dependent covariate? In addition, there is now the possibility to compute the Mantel-Byar test and accompanying Simon-Makuch plot in R, using the Rcmdr and the RcmdrPlugin.EZR packages. See the related SO post containing a detailed R code: https://stackoverflow.com/questions/40431559/mantel-byar-test-and-simon-makuch-plot-for-survival-analysis-with-time-dependent
Visualize survival analysis with time dependent covariates There is a recent post on this issue at large in CV: Which is the best graph to describe a survival analysis with a time-dependent covariate? In addition, there is now the possibility to compute the M
29,042
Time series forecasting lookback windows -- sliding or growing?
The choice of window length involves a balance between two opposing factors. A shorter window implies a smaller data set on which to perform your estimations. A longer window implies an increase in the chance that the data-generating process has changed over the time period covered by the window, so that the oldest data are no longer representative of the system's current behavior. Suppose, for example, that you wished to estimate January mean temperature in New York. Due to climate change, data from 40 years ago are no longer representative of current conditions. However, if one uses only data from the past 5 years, your estimate will have a large uncertainty due to natural sampling variability. Analogously, if you were trying to model the behavior of the Dow Jones Industrial Average, you could pull in data going back over a century. But you may have legitimate reasons to believe that data from the 1920s will not be representative of the process that generates the DJIA values today. To put it in other terms, shorter windows increase your parameter risk while longer windows increase your model risk. A short data sample increases the chance that your parameter estimates are way off, conditional on your model specification. A longer data sample increases the chance that you are trying to stretch your model to cover more cases than it can accurately represent. A more "local" model may do a better job. Your selection of window size depends, therefore, on your specific application -- including the potential costs for different kinds of error. If you were certain that the underlying data-generating process was stable, then the more data you have, the better. If not, then maybe not. I'm afraid I can't offer more insight on how to strike this balance appropriately, without knowing more about the specifics of your application. Perhaps others can offer pointers to particular statistical tests. What most people do in practice (not necessarily the best practice) is to eyeball it, choosing the longest window for which one can be "reasonably comfortable" that the underlying data-generating process has, during that period, not changed "much". These judgements are based on the analyst's heuristic understanding of the data-generating process.
Time series forecasting lookback windows -- sliding or growing?
The choice of window length involves a balance between two opposing factors. A shorter window implies a smaller data set on which to perform your estimations. A longer window implies an increase in th
Time series forecasting lookback windows -- sliding or growing? The choice of window length involves a balance between two opposing factors. A shorter window implies a smaller data set on which to perform your estimations. A longer window implies an increase in the chance that the data-generating process has changed over the time period covered by the window, so that the oldest data are no longer representative of the system's current behavior. Suppose, for example, that you wished to estimate January mean temperature in New York. Due to climate change, data from 40 years ago are no longer representative of current conditions. However, if one uses only data from the past 5 years, your estimate will have a large uncertainty due to natural sampling variability. Analogously, if you were trying to model the behavior of the Dow Jones Industrial Average, you could pull in data going back over a century. But you may have legitimate reasons to believe that data from the 1920s will not be representative of the process that generates the DJIA values today. To put it in other terms, shorter windows increase your parameter risk while longer windows increase your model risk. A short data sample increases the chance that your parameter estimates are way off, conditional on your model specification. A longer data sample increases the chance that you are trying to stretch your model to cover more cases than it can accurately represent. A more "local" model may do a better job. Your selection of window size depends, therefore, on your specific application -- including the potential costs for different kinds of error. If you were certain that the underlying data-generating process was stable, then the more data you have, the better. If not, then maybe not. I'm afraid I can't offer more insight on how to strike this balance appropriately, without knowing more about the specifics of your application. Perhaps others can offer pointers to particular statistical tests. What most people do in practice (not necessarily the best practice) is to eyeball it, choosing the longest window for which one can be "reasonably comfortable" that the underlying data-generating process has, during that period, not changed "much". These judgements are based on the analyst's heuristic understanding of the data-generating process.
Time series forecasting lookback windows -- sliding or growing? The choice of window length involves a balance between two opposing factors. A shorter window implies a smaller data set on which to perform your estimations. A longer window implies an increase in th
29,043
Time series forecasting lookback windows -- sliding or growing?
I am a little bit confused by your language. Do you mean how do I weight the past to make a prediction e.g. a 12 period moving average ? An ARIMA model determines the number of observations to be used (window ? ) and how to optimally weight the values in the window. One example is to assign a weight of 1 to the last observation and zero elsewhere . Another example might be to equally weight the last k observations. An ARIMA model can be expressed in these terms (Pi Weights). Your first proposal: THe updating could be as simple as tuning the parameters or tuning paramnters and possibly changing the model. This approach would give you an honest estimate of out-of-sample performance. Your second proposal would be better if either the parameters were changing , or the model was changing or the error variance eas changing as only new data would be used. The problem with that is discarding/ignoring previous values comes at a price with respect to model formulation. Recently I suggested to a client that they take 1200 historical(daily values) and predict 30 days out at some 20 time points in the past and measure the weighted MAPE for a 30 day period. The forecasts at each point would be premised on data up to that point and care given to validating the the parameters/model had not changed up to that point and that the error variance had passed the variance constancy requirement. In this way they could have an empirical distrivution of the expected MAPE from any future origin to use as a benchmark or expected MAPE. In this way unusual mapes vould be identified. Unusual MAPE's can suggest a change in the DGP ( Data Generation Process) or a deficiciency in the Modelling Process. It appears to me that your primary concern is to sense/challenge hoe many points are actually used to form a model. Which by the way has been a primary focus of mine /
Time series forecasting lookback windows -- sliding or growing?
I am a little bit confused by your language. Do you mean how do I weight the past to make a prediction e.g. a 12 period moving average ? An ARIMA model determines the number of observations to be used
Time series forecasting lookback windows -- sliding or growing? I am a little bit confused by your language. Do you mean how do I weight the past to make a prediction e.g. a 12 period moving average ? An ARIMA model determines the number of observations to be used (window ? ) and how to optimally weight the values in the window. One example is to assign a weight of 1 to the last observation and zero elsewhere . Another example might be to equally weight the last k observations. An ARIMA model can be expressed in these terms (Pi Weights). Your first proposal: THe updating could be as simple as tuning the parameters or tuning paramnters and possibly changing the model. This approach would give you an honest estimate of out-of-sample performance. Your second proposal would be better if either the parameters were changing , or the model was changing or the error variance eas changing as only new data would be used. The problem with that is discarding/ignoring previous values comes at a price with respect to model formulation. Recently I suggested to a client that they take 1200 historical(daily values) and predict 30 days out at some 20 time points in the past and measure the weighted MAPE for a 30 day period. The forecasts at each point would be premised on data up to that point and care given to validating the the parameters/model had not changed up to that point and that the error variance had passed the variance constancy requirement. In this way they could have an empirical distrivution of the expected MAPE from any future origin to use as a benchmark or expected MAPE. In this way unusual mapes vould be identified. Unusual MAPE's can suggest a change in the DGP ( Data Generation Process) or a deficiciency in the Modelling Process. It appears to me that your primary concern is to sense/challenge hoe many points are actually used to form a model. Which by the way has been a primary focus of mine /
Time series forecasting lookback windows -- sliding or growing? I am a little bit confused by your language. Do you mean how do I weight the past to make a prediction e.g. a 12 period moving average ? An ARIMA model determines the number of observations to be used
29,044
conditional on the total, what is the distribution of negative binomials
Sorry for the late answer, but this bugged me as well and I found the answer. The distribution is indeed Dirichlet-Multinomial and the individual neg. binomial distributions don't even need to be identical, as long as their Fano factor (ratio of variance to mean) is identical. Long answer: If you parameterize NB as: $ p(X = x | \lambda, \theta) = NB(x | \lambda, \theta) = {{\theta^{-1} \lambda + x - 1} \choose {x}} \left ( \frac{1}{1 + \theta^{-1}} \right)^x \left ( \frac{\theta^{-1}}{1 + \theta^{-1}} \right)^{\theta^{-1} \lambda} $ Then $E(X) = \lambda$ and $Var(X) = \lambda (1 + \theta)$ and $\forall i: X_i \sim NB(\lambda_i, \theta)$ implies $\sum X_i \sim NB(\sum \lambda_i, \theta)$ Then taking the probability given the sum: $ \frac{\prod NB(x_i | \lambda_i, \theta)}{NB(\sum x_i | \sum \lambda_i, \theta)} = \frac{\left(\frac{1}{1+\theta^{-1} } \right) ^{\sum x_i} \left(\frac{\theta^{-1} }{1+\theta^{-1} } \right) ^{\theta^{-1} \sum \lambda_i} \prod {{\theta^{-1} \lambda_i + x_i - 1} \choose {x_i}}} { \left(\frac{1}{1+\theta^{-1} } \right) ^{\sum x_i} \left(\frac{\theta^{-1} }{1+\theta^{-1} } \right) ^{\theta^{-1} \sum \lambda_i} {{\theta^{-1} \sum\lambda_i + \sum x_i - 1} \choose {\sum x_i}}} = \\ = \frac{\Gamma(\sum x_i + 1) \Gamma(\theta^{-1} \sum\lambda_i) }{\Gamma(\theta^{-1} \sum\lambda_i + \sum x_i) } \prod \frac{ \Gamma(\theta^{-1}\lambda_i + x_i)}{\Gamma(x_i + 1) \Gamma(\theta^{-1}\lambda_i)} \\ =DM(x_1, ..., x_n| \theta^{-1}\lambda_1, ... , \theta^{-1} \lambda_n) $ where $DM$ is the Dirichlet-Multinomial likelihood. This results simply from the fact that except for the multinomial coefficients, a lot of the terms in the fraction on the left hand side cancel out, leaving you only with the gamma function terms that happen to be the same as in the DM likelihood. Also note that the parameters of this model are not identifiable as increase in $\theta$ with simultaneous decrease in all $\lambda_i$ results in exactly the same likelihood. The best reference I have for this is sections 2 to 3.1 of Guimarães & Lindrooth (2007): Controlling for overdispersion in grouped conditional logit models: A computationally simple application of Dirichlet-multinomial regression - it is unfortunately paywalled, but I was not able to find a non-paywalled reference.
conditional on the total, what is the distribution of negative binomials
Sorry for the late answer, but this bugged me as well and I found the answer. The distribution is indeed Dirichlet-Multinomial and the individual neg. binomial distributions don't even need to be iden
conditional on the total, what is the distribution of negative binomials Sorry for the late answer, but this bugged me as well and I found the answer. The distribution is indeed Dirichlet-Multinomial and the individual neg. binomial distributions don't even need to be identical, as long as their Fano factor (ratio of variance to mean) is identical. Long answer: If you parameterize NB as: $ p(X = x | \lambda, \theta) = NB(x | \lambda, \theta) = {{\theta^{-1} \lambda + x - 1} \choose {x}} \left ( \frac{1}{1 + \theta^{-1}} \right)^x \left ( \frac{\theta^{-1}}{1 + \theta^{-1}} \right)^{\theta^{-1} \lambda} $ Then $E(X) = \lambda$ and $Var(X) = \lambda (1 + \theta)$ and $\forall i: X_i \sim NB(\lambda_i, \theta)$ implies $\sum X_i \sim NB(\sum \lambda_i, \theta)$ Then taking the probability given the sum: $ \frac{\prod NB(x_i | \lambda_i, \theta)}{NB(\sum x_i | \sum \lambda_i, \theta)} = \frac{\left(\frac{1}{1+\theta^{-1} } \right) ^{\sum x_i} \left(\frac{\theta^{-1} }{1+\theta^{-1} } \right) ^{\theta^{-1} \sum \lambda_i} \prod {{\theta^{-1} \lambda_i + x_i - 1} \choose {x_i}}} { \left(\frac{1}{1+\theta^{-1} } \right) ^{\sum x_i} \left(\frac{\theta^{-1} }{1+\theta^{-1} } \right) ^{\theta^{-1} \sum \lambda_i} {{\theta^{-1} \sum\lambda_i + \sum x_i - 1} \choose {\sum x_i}}} = \\ = \frac{\Gamma(\sum x_i + 1) \Gamma(\theta^{-1} \sum\lambda_i) }{\Gamma(\theta^{-1} \sum\lambda_i + \sum x_i) } \prod \frac{ \Gamma(\theta^{-1}\lambda_i + x_i)}{\Gamma(x_i + 1) \Gamma(\theta^{-1}\lambda_i)} \\ =DM(x_1, ..., x_n| \theta^{-1}\lambda_1, ... , \theta^{-1} \lambda_n) $ where $DM$ is the Dirichlet-Multinomial likelihood. This results simply from the fact that except for the multinomial coefficients, a lot of the terms in the fraction on the left hand side cancel out, leaving you only with the gamma function terms that happen to be the same as in the DM likelihood. Also note that the parameters of this model are not identifiable as increase in $\theta$ with simultaneous decrease in all $\lambda_i$ results in exactly the same likelihood. The best reference I have for this is sections 2 to 3.1 of Guimarães & Lindrooth (2007): Controlling for overdispersion in grouped conditional logit models: A computationally simple application of Dirichlet-multinomial regression - it is unfortunately paywalled, but I was not able to find a non-paywalled reference.
conditional on the total, what is the distribution of negative binomials Sorry for the late answer, but this bugged me as well and I found the answer. The distribution is indeed Dirichlet-Multinomial and the individual neg. binomial distributions don't even need to be iden
29,045
Posterior Distribution for Bayesian Linear Regression
Your final formula is missing a left parenthesis. This is a standard problem that requires no difficult work. The wikipedia page on Bayesian regression solves a harder problem; you should be able to use the same trick (which is basically just a form of completing the square, since you want it in terms of $(\beta - m)' V^{-1} (\beta - m)$ for some $m$ and $V$), with fewer terms to worry about. That is, you get to something like this: \begin{align}(\mathbf{y}- \mathbf{X} \boldsymbol\beta)^{\rm T}(\mathbf{y}- \mathbf{X} \boldsymbol\beta)&= (\boldsymbol\beta - \hat{\boldsymbol\beta})^{\rm T}(\mathbf{X}^{\rm T}\mathbf{X})(\boldsymbol\beta - \hat{\boldsymbol\beta}) + \mathbf{S} \end{align} where \begin{align}\mathbf{S} = (\mathbf{y}- \mathbf{X} \hat{\boldsymbol\beta})^{\rm T}(\mathbf{y}- \mathbf{X} \hat{\boldsymbol\beta})\end{align} in the exponent. See also the references at the wikipedia article. If this is for some subject, please mark it as homework.
Posterior Distribution for Bayesian Linear Regression
Your final formula is missing a left parenthesis. This is a standard problem that requires no difficult work. The wikipedia page on Bayesian regression solves a harder problem; you should be able to u
Posterior Distribution for Bayesian Linear Regression Your final formula is missing a left parenthesis. This is a standard problem that requires no difficult work. The wikipedia page on Bayesian regression solves a harder problem; you should be able to use the same trick (which is basically just a form of completing the square, since you want it in terms of $(\beta - m)' V^{-1} (\beta - m)$ for some $m$ and $V$), with fewer terms to worry about. That is, you get to something like this: \begin{align}(\mathbf{y}- \mathbf{X} \boldsymbol\beta)^{\rm T}(\mathbf{y}- \mathbf{X} \boldsymbol\beta)&= (\boldsymbol\beta - \hat{\boldsymbol\beta})^{\rm T}(\mathbf{X}^{\rm T}\mathbf{X})(\boldsymbol\beta - \hat{\boldsymbol\beta}) + \mathbf{S} \end{align} where \begin{align}\mathbf{S} = (\mathbf{y}- \mathbf{X} \hat{\boldsymbol\beta})^{\rm T}(\mathbf{y}- \mathbf{X} \hat{\boldsymbol\beta})\end{align} in the exponent. See also the references at the wikipedia article. If this is for some subject, please mark it as homework.
Posterior Distribution for Bayesian Linear Regression Your final formula is missing a left parenthesis. This is a standard problem that requires no difficult work. The wikipedia page on Bayesian regression solves a harder problem; you should be able to u
29,046
Does preclustering help to build a better predictive model?
There is a method called clusterwise regression that solves similar problem (first clusters data and then builts predictive models). See for example this.
Does preclustering help to build a better predictive model?
There is a method called clusterwise regression that solves similar problem (first clusters data and then builts predictive models). See for example this.
Does preclustering help to build a better predictive model? There is a method called clusterwise regression that solves similar problem (first clusters data and then builts predictive models). See for example this.
Does preclustering help to build a better predictive model? There is a method called clusterwise regression that solves similar problem (first clusters data and then builts predictive models). See for example this.
29,047
Does preclustering help to build a better predictive model?
Two points that are too long to be a comment: pure clusters (i.e. containing cases of one class only) are no problem per se: so called one-class classifiers model each class independent of all others. They can perfectly deal with this. However, if the data clusters in a way that the classes are quite separated, i.e. the clusters are rather pure, this means that a very strong structure exists, a structure that cluster analysis is able to find without guidance by the class labels. This means that certain types of classifiers such as nearest neighbour methods based on the same distance measure used by the cluster analysis are appropriate for the data. The other possibility, situations where the clusters are not pure, but a combination of cluster and classification methods can do well is appropriate for trees. The tree will do the part of the clustering (and pure nodes are not considered a problem.) Here's an artificial example, a 2 cluster version of the XOR-problem: another way to include the cluster information without running the risk of having pure clusters would be to use the clustering as a feature generation step: add the outcome of the cluster analysis as new variates to the data matrix. You ask whether it is bad for some reason: one pitfall is that this appoach leads to models with many degrees of freedom. You'll have to be particularly careful not to overfit. Have a look at model-based-trees, e.g. mbq's answer here I think they implement a concept that is very close to whar you look for. They can be implemented as forest as well: e.g. R package mobForest.
Does preclustering help to build a better predictive model?
Two points that are too long to be a comment: pure clusters (i.e. containing cases of one class only) are no problem per se: so called one-class classifiers model each class independent of all others
Does preclustering help to build a better predictive model? Two points that are too long to be a comment: pure clusters (i.e. containing cases of one class only) are no problem per se: so called one-class classifiers model each class independent of all others. They can perfectly deal with this. However, if the data clusters in a way that the classes are quite separated, i.e. the clusters are rather pure, this means that a very strong structure exists, a structure that cluster analysis is able to find without guidance by the class labels. This means that certain types of classifiers such as nearest neighbour methods based on the same distance measure used by the cluster analysis are appropriate for the data. The other possibility, situations where the clusters are not pure, but a combination of cluster and classification methods can do well is appropriate for trees. The tree will do the part of the clustering (and pure nodes are not considered a problem.) Here's an artificial example, a 2 cluster version of the XOR-problem: another way to include the cluster information without running the risk of having pure clusters would be to use the clustering as a feature generation step: add the outcome of the cluster analysis as new variates to the data matrix. You ask whether it is bad for some reason: one pitfall is that this appoach leads to models with many degrees of freedom. You'll have to be particularly careful not to overfit. Have a look at model-based-trees, e.g. mbq's answer here I think they implement a concept that is very close to whar you look for. They can be implemented as forest as well: e.g. R package mobForest.
Does preclustering help to build a better predictive model? Two points that are too long to be a comment: pure clusters (i.e. containing cases of one class only) are no problem per se: so called one-class classifiers model each class independent of all others
29,048
Does preclustering help to build a better predictive model?
I'm dealing with similar problem these days. I have hundreds of feature to build classifier. After trying different models (ex: random forests, gradient boost, etc...), I still got low precision/recall. So I'm trying to do some clustering then build classifiers in different groups. My concern is, just like Anony-Mousse says, how can I gain more information from the classifier if I use all the information in clustering? So here's what I gonna do next: Use some features (less, according to prior knowledge) to do clustering. Use other features (more) to train classifiers. I think it may also helps to reduce complexity, wish it helps.
Does preclustering help to build a better predictive model?
I'm dealing with similar problem these days. I have hundreds of feature to build classifier. After trying different models (ex: random forests, gradient boost, etc...), I still got low precision/recal
Does preclustering help to build a better predictive model? I'm dealing with similar problem these days. I have hundreds of feature to build classifier. After trying different models (ex: random forests, gradient boost, etc...), I still got low precision/recall. So I'm trying to do some clustering then build classifiers in different groups. My concern is, just like Anony-Mousse says, how can I gain more information from the classifier if I use all the information in clustering? So here's what I gonna do next: Use some features (less, according to prior knowledge) to do clustering. Use other features (more) to train classifiers. I think it may also helps to reduce complexity, wish it helps.
Does preclustering help to build a better predictive model? I'm dealing with similar problem these days. I have hundreds of feature to build classifier. After trying different models (ex: random forests, gradient boost, etc...), I still got low precision/recal
29,049
Does preclustering help to build a better predictive model?
Building $k$ clusters and then $k$ corresponding models is absolutely feasible. The pathologic case noted in the comments wherein the clusters perfectly separate the outcome variables would pose difficulties for classifiers is a theoretical problem, but one which I think is unlikely (especially in a high dimensional case). Furthermore, if you could build such clusters, you could then just use those clusters for prediction! In addition, if the process begins with $N$ samples, the classifiers can only use $N/k$ samples. Thus, a more powerful approach would be to use the clusters in building a single classifier that incorporates the heterogeneity in the clusters using a mixture of regressions. In model-based clustering, one assumes the data are generated from a mixture distribution $Y_i \sim N(\mu_i, \sigma_i^2)$ where $i=1$ with probability $\pi$ and $i=2$ with probability $1-\pi$ and $\mu_1 \neq \ \mu_2$ and $\sigma_1^2 \neq \sigma_2^2$. A mixture regression is an extension that allows one to model the data as being dependent on co-variates; $\mu_i$ is replaced with $\beta_i X_i$, where the $\beta_i$ have to be estimated. While this example is for a univariate, Gaussian case, the framework can accommodate many data (multinomial-logit would be appropriate for categorical variables). The flexmix package for R provides a more detailed description and of course a relatively easy and extensible way to implement this approach. Alternatively, in a discriminative setting, one could try incorporating cluster assignments (hard or soft) as a feature for training the classification algorithm of choice (e.g. NB, ANN, SVM, RF, etc.)
Does preclustering help to build a better predictive model?
Building $k$ clusters and then $k$ corresponding models is absolutely feasible. The pathologic case noted in the comments wherein the clusters perfectly separate the outcome variables would pose diffi
Does preclustering help to build a better predictive model? Building $k$ clusters and then $k$ corresponding models is absolutely feasible. The pathologic case noted in the comments wherein the clusters perfectly separate the outcome variables would pose difficulties for classifiers is a theoretical problem, but one which I think is unlikely (especially in a high dimensional case). Furthermore, if you could build such clusters, you could then just use those clusters for prediction! In addition, if the process begins with $N$ samples, the classifiers can only use $N/k$ samples. Thus, a more powerful approach would be to use the clusters in building a single classifier that incorporates the heterogeneity in the clusters using a mixture of regressions. In model-based clustering, one assumes the data are generated from a mixture distribution $Y_i \sim N(\mu_i, \sigma_i^2)$ where $i=1$ with probability $\pi$ and $i=2$ with probability $1-\pi$ and $\mu_1 \neq \ \mu_2$ and $\sigma_1^2 \neq \sigma_2^2$. A mixture regression is an extension that allows one to model the data as being dependent on co-variates; $\mu_i$ is replaced with $\beta_i X_i$, where the $\beta_i$ have to be estimated. While this example is for a univariate, Gaussian case, the framework can accommodate many data (multinomial-logit would be appropriate for categorical variables). The flexmix package for R provides a more detailed description and of course a relatively easy and extensible way to implement this approach. Alternatively, in a discriminative setting, one could try incorporating cluster assignments (hard or soft) as a feature for training the classification algorithm of choice (e.g. NB, ANN, SVM, RF, etc.)
Does preclustering help to build a better predictive model? Building $k$ clusters and then $k$ corresponding models is absolutely feasible. The pathologic case noted in the comments wherein the clusters perfectly separate the outcome variables would pose diffi
29,050
Does preclustering help to build a better predictive model?
Well, if your clusters are really good, your classifiers will be crap. Because they have not enough diversion in their training data. Say your clusters are perfect i.e. pure. You can't even properly train a classifier there anymore. Classifiers need positive and negative examples! Random Forest are very successful in doing the exact opposite. They take a random sample of the data, train a classifier on that, and then use all of the trained classifiers. What might work is to use clustering, and then train a classifier on every pair of clusters, at least if they disagree enough (if a class is split into two clusters, you still cannot train a classifier there!)
Does preclustering help to build a better predictive model?
Well, if your clusters are really good, your classifiers will be crap. Because they have not enough diversion in their training data. Say your clusters are perfect i.e. pure. You can't even properly t
Does preclustering help to build a better predictive model? Well, if your clusters are really good, your classifiers will be crap. Because they have not enough diversion in their training data. Say your clusters are perfect i.e. pure. You can't even properly train a classifier there anymore. Classifiers need positive and negative examples! Random Forest are very successful in doing the exact opposite. They take a random sample of the data, train a classifier on that, and then use all of the trained classifiers. What might work is to use clustering, and then train a classifier on every pair of clusters, at least if they disagree enough (if a class is split into two clusters, you still cannot train a classifier there!)
Does preclustering help to build a better predictive model? Well, if your clusters are really good, your classifiers will be crap. Because they have not enough diversion in their training data. Say your clusters are perfect i.e. pure. You can't even properly t
29,051
Model selection and model performance in logistic regression
It's true that it is better to use a test set of data to validate your model. However, you can still say how well your model performed on your data, as long as you are honest about what you did. What you cannot really do is say that it will do this well on other data: It likely won't. Unfortunately, a lot of published articles at least hint at this incorrect notion. You ask is it ok to select the starting variables which I think explains the dependent best simply based on ecology? Not only is it OK, it is better than any automated scheme. Indeed, these could also be the final variables. It depends, somewhat, on the extent of knowledge in the field. If not much is known about what you are researching, then a more exploratory approach may be necessary. But if you have good reason to think that certain variables should be in the model, then by all means, put them in. And I would argue for leaving them there, even if not significant.
Model selection and model performance in logistic regression
It's true that it is better to use a test set of data to validate your model. However, you can still say how well your model performed on your data, as long as you are honest about what you did. What
Model selection and model performance in logistic regression It's true that it is better to use a test set of data to validate your model. However, you can still say how well your model performed on your data, as long as you are honest about what you did. What you cannot really do is say that it will do this well on other data: It likely won't. Unfortunately, a lot of published articles at least hint at this incorrect notion. You ask is it ok to select the starting variables which I think explains the dependent best simply based on ecology? Not only is it OK, it is better than any automated scheme. Indeed, these could also be the final variables. It depends, somewhat, on the extent of knowledge in the field. If not much is known about what you are researching, then a more exploratory approach may be necessary. But if you have good reason to think that certain variables should be in the model, then by all means, put them in. And I would argue for leaving them there, even if not significant.
Model selection and model performance in logistic regression It's true that it is better to use a test set of data to validate your model. However, you can still say how well your model performed on your data, as long as you are honest about what you did. What
29,052
Model selection and model performance in logistic regression
If you are going to do model selection then I think you're better doing an exhaustive search and weighting each model rather than cherry picking. You only have 14 variables, which is certainly feasible - 16384 different models is not prohibitively large, especially because the sample size is small. I would also look at normalised weights, defined by: $$w_m=\left[\sum_{l}\exp\left(-\frac{1}{2}[AIC_l - AIC_m]\right)\right]^{-1}$$ These weights assume AIC is negative twice the log likelihood plus two times the number of betas. If the best model has a weight close to $1$ then just use that. otherwise you should average your results aross models with total weight close to $1$. What usually happens is that a "core" group of variables should be always included, with uncertainty over a "non-core" set, and a third set of unimportant variables which never appear in models with high weight. You could also replace AIC with BIC or some other penalty based IC to see how much the weights depend on the specific complexity penalty used.
Model selection and model performance in logistic regression
If you are going to do model selection then I think you're better doing an exhaustive search and weighting each model rather than cherry picking. You only have 14 variables, which is certainly feasib
Model selection and model performance in logistic regression If you are going to do model selection then I think you're better doing an exhaustive search and weighting each model rather than cherry picking. You only have 14 variables, which is certainly feasible - 16384 different models is not prohibitively large, especially because the sample size is small. I would also look at normalised weights, defined by: $$w_m=\left[\sum_{l}\exp\left(-\frac{1}{2}[AIC_l - AIC_m]\right)\right]^{-1}$$ These weights assume AIC is negative twice the log likelihood plus two times the number of betas. If the best model has a weight close to $1$ then just use that. otherwise you should average your results aross models with total weight close to $1$. What usually happens is that a "core" group of variables should be always included, with uncertainty over a "non-core" set, and a third set of unimportant variables which never appear in models with high weight. You could also replace AIC with BIC or some other penalty based IC to see how much the weights depend on the specific complexity penalty used.
Model selection and model performance in logistic regression If you are going to do model selection then I think you're better doing an exhaustive search and weighting each model rather than cherry picking. You only have 14 variables, which is certainly feasib
29,053
Model selection and model performance in logistic regression
Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted. To answer "Could it be ok to test performance on a model trained on the full data set with cross-validation?" NO, I don't think this is OK. You should fit all the 3 models to the same subset of your dataset. Then do the cross-validation to see which one is better.
Model selection and model performance in logistic regression
Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted.
Model selection and model performance in logistic regression Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted. To answer "Could it be ok to test performance on a model trained on the full data set with cross-validation?" NO, I don't think this is OK. You should fit all the 3 models to the same subset of your dataset. Then do the cross-validation to see which one is better.
Model selection and model performance in logistic regression Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted.
29,054
Model selection and model performance in logistic regression
Could it be ok to test performance on a model trained on the full data set with cross-validation? I think not. Perhaps a better method would be to evaluate each of the three models using repeated cross validation. Given that you have chosen your features based on prior knowledge you do not need to worry about feature selection. This method allows you to evaluate the performance of the model. If not, how do I choose the final model when doing cross-validation? Once you have evaluated the performance of your model using repeated cross-validation you can then train the final model using all available data. How do I choose the starting variables so I want over-parameterize? If I understand correctly: As suggested by a contributor above you can either add in your features based on prior knowlegde of the area or else you need to perform feature selection within the cross-validation to avoid overfitting. This same feature selection procedure would then be applied to all data when training the final model. You cannot use this model to report the generalized performance of the model, this must come from the cross-validation estimate.
Model selection and model performance in logistic regression
Could it be ok to test performance on a model trained on the full data set with cross-validation? I think not. Perhaps a better method would be to evaluate each of the three models using repeated c
Model selection and model performance in logistic regression Could it be ok to test performance on a model trained on the full data set with cross-validation? I think not. Perhaps a better method would be to evaluate each of the three models using repeated cross validation. Given that you have chosen your features based on prior knowledge you do not need to worry about feature selection. This method allows you to evaluate the performance of the model. If not, how do I choose the final model when doing cross-validation? Once you have evaluated the performance of your model using repeated cross-validation you can then train the final model using all available data. How do I choose the starting variables so I want over-parameterize? If I understand correctly: As suggested by a contributor above you can either add in your features based on prior knowlegde of the area or else you need to perform feature selection within the cross-validation to avoid overfitting. This same feature selection procedure would then be applied to all data when training the final model. You cannot use this model to report the generalized performance of the model, this must come from the cross-validation estimate.
Model selection and model performance in logistic regression Could it be ok to test performance on a model trained on the full data set with cross-validation? I think not. Perhaps a better method would be to evaluate each of the three models using repeated c
29,055
Dynamically adjusting NN architecture: inventing the unnecessary?
Cascade-Correlation Neural Networks adjust their structure by adding hidden nodes during the training process, so this may be a place to start. Most of the other work I've seen that automatically adjusts the number of layers, number of hidden nodes, etc, of a neural network use evolutionary algorithms. Unfortunately, this work is out of my area so I can't recommend any particular papers or references to help you get started. I can tell you that I haven't seen any work which tries to jointly optimize network structure and parameters simultaneously within the deep learning community. In fact, most deep learning architectures are based on greedily learning a single layer at a time, thus making even online learning of deep neural networks a rather untouched area (the work of Martens et al. on Hessian Free Optimization being a notable exception).
Dynamically adjusting NN architecture: inventing the unnecessary?
Cascade-Correlation Neural Networks adjust their structure by adding hidden nodes during the training process, so this may be a place to start. Most of the other work I've seen that automatically adju
Dynamically adjusting NN architecture: inventing the unnecessary? Cascade-Correlation Neural Networks adjust their structure by adding hidden nodes during the training process, so this may be a place to start. Most of the other work I've seen that automatically adjusts the number of layers, number of hidden nodes, etc, of a neural network use evolutionary algorithms. Unfortunately, this work is out of my area so I can't recommend any particular papers or references to help you get started. I can tell you that I haven't seen any work which tries to jointly optimize network structure and parameters simultaneously within the deep learning community. In fact, most deep learning architectures are based on greedily learning a single layer at a time, thus making even online learning of deep neural networks a rather untouched area (the work of Martens et al. on Hessian Free Optimization being a notable exception).
Dynamically adjusting NN architecture: inventing the unnecessary? Cascade-Correlation Neural Networks adjust their structure by adding hidden nodes during the training process, so this may be a place to start. Most of the other work I've seen that automatically adju
29,056
Dynamically adjusting NN architecture: inventing the unnecessary?
Another reason to consider developing novel approaches to constructive neural networks (such as the CC algorithm @alto mentioned) is in applications outside of statistics. In particular, in theoretical neuroscience and cognitive science, constructive neural networks are often used because of a metaphorical similarity to development and neurogenesis. For an example of heavy use of cascade-correlation for this, take a look at publications of Thomas R. Shultz. Unfortunately, the cascade correlation approach is biological unrealistic and if you have a neuroscience bend it is worth to consider how new NNs with adjustable architecture could be used as better models of development and/or neurogenesis.
Dynamically adjusting NN architecture: inventing the unnecessary?
Another reason to consider developing novel approaches to constructive neural networks (such as the CC algorithm @alto mentioned) is in applications outside of statistics. In particular, in theoretica
Dynamically adjusting NN architecture: inventing the unnecessary? Another reason to consider developing novel approaches to constructive neural networks (such as the CC algorithm @alto mentioned) is in applications outside of statistics. In particular, in theoretical neuroscience and cognitive science, constructive neural networks are often used because of a metaphorical similarity to development and neurogenesis. For an example of heavy use of cascade-correlation for this, take a look at publications of Thomas R. Shultz. Unfortunately, the cascade correlation approach is biological unrealistic and if you have a neuroscience bend it is worth to consider how new NNs with adjustable architecture could be used as better models of development and/or neurogenesis.
Dynamically adjusting NN architecture: inventing the unnecessary? Another reason to consider developing novel approaches to constructive neural networks (such as the CC algorithm @alto mentioned) is in applications outside of statistics. In particular, in theoretica
29,057
How to interpret lower order interaction when higher order interaction is significant?
It's not that lower order interactions or main effects are completely uninterpretable when there's a higher order interaction. It's that their interpretation is qualified. For example, a main effect of A just means that overall, within the range of the IVs you have chosen, the levels of A differ; but that the magnitude, or possibly direction, of the difference really does vary across the other variables. So, not completely uninterpretable, just qualified. Upon a study of the data you may find you really do believe there is the main effect in general that's just varying in magnitude. Or, you may find that the main effect only exists for a limited range of conditions. In your case You have an AxB interaction and the magnitude of the interaction is dependent upon C. It's possible the direction is as well but that's relatively unlikely. The AxB interaction you have suggests how to examine the three way. Make 2 2x2 AxB interaction plots, one at each level of C. Your 3-way interaction tells you that the differences in these two interaction plots are worth noting.
How to interpret lower order interaction when higher order interaction is significant?
It's not that lower order interactions or main effects are completely uninterpretable when there's a higher order interaction. It's that their interpretation is qualified. For example, a main effect
How to interpret lower order interaction when higher order interaction is significant? It's not that lower order interactions or main effects are completely uninterpretable when there's a higher order interaction. It's that their interpretation is qualified. For example, a main effect of A just means that overall, within the range of the IVs you have chosen, the levels of A differ; but that the magnitude, or possibly direction, of the difference really does vary across the other variables. So, not completely uninterpretable, just qualified. Upon a study of the data you may find you really do believe there is the main effect in general that's just varying in magnitude. Or, you may find that the main effect only exists for a limited range of conditions. In your case You have an AxB interaction and the magnitude of the interaction is dependent upon C. It's possible the direction is as well but that's relatively unlikely. The AxB interaction you have suggests how to examine the three way. Make 2 2x2 AxB interaction plots, one at each level of C. Your 3-way interaction tells you that the differences in these two interaction plots are worth noting.
How to interpret lower order interaction when higher order interaction is significant? It's not that lower order interactions or main effects are completely uninterpretable when there's a higher order interaction. It's that their interpretation is qualified. For example, a main effect
29,058
How to interpret lower order interaction when higher order interaction is significant?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. You might want to run two 2-way, AxB ANOVAs, one for each level of the C variable. That approach will let you look at the "simple" two way interaction effects unaffected by the 3 way interaction. Since there was a statistically significant 3 way interaction, we expect that the two simple 2 way interactions will not look the same.
How to interpret lower order interaction when higher order interaction is significant?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
How to interpret lower order interaction when higher order interaction is significant? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. You might want to run two 2-way, AxB ANOVAs, one for each level of the C variable. That approach will let you look at the "simple" two way interaction effects unaffected by the 3 way interaction. Since there was a statistically significant 3 way interaction, we expect that the two simple 2 way interactions will not look the same.
How to interpret lower order interaction when higher order interaction is significant? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
29,059
Collapsing (combining) two variables into one for analysis
Building somewhat on previous answers: Yes, there would. In regression analysis, you suppose that your regressors $X$ are orthogonal to each other. If you consider $IQ$, income, number of years of schooling, race of the parents, you will end up with regressors that are strongly correlated. It will cause your estimates for both $x_1$ and $x_2$ to be imprecisely estimated (large standard errors.) and you may wrongly conclude that they are not significant. For a discussion on the effect of correlated regressors, see this link. Basically, in a choir, it is hard to know who sings what. Possible combinations: sum, average, first principal component of the two (or more) series. You would have to justify your choice here. In the case of years of schooling, you could add both numbers and declare it "parents' education." What exactly do you mean ? No, you can do it with any type of variables. See the example with years of schooling. Be advised that any aggregation of data leads to a loss of information. It is your job as a researcher to weigh the pros and cons of such choice.
Collapsing (combining) two variables into one for analysis
Building somewhat on previous answers: Yes, there would. In regression analysis, you suppose that your regressors $X$ are orthogonal to each other. If you consider $IQ$, income, number of years of sc
Collapsing (combining) two variables into one for analysis Building somewhat on previous answers: Yes, there would. In regression analysis, you suppose that your regressors $X$ are orthogonal to each other. If you consider $IQ$, income, number of years of schooling, race of the parents, you will end up with regressors that are strongly correlated. It will cause your estimates for both $x_1$ and $x_2$ to be imprecisely estimated (large standard errors.) and you may wrongly conclude that they are not significant. For a discussion on the effect of correlated regressors, see this link. Basically, in a choir, it is hard to know who sings what. Possible combinations: sum, average, first principal component of the two (or more) series. You would have to justify your choice here. In the case of years of schooling, you could add both numbers and declare it "parents' education." What exactly do you mean ? No, you can do it with any type of variables. See the example with years of schooling. Be advised that any aggregation of data leads to a loss of information. It is your job as a researcher to weigh the pros and cons of such choice.
Collapsing (combining) two variables into one for analysis Building somewhat on previous answers: Yes, there would. In regression analysis, you suppose that your regressors $X$ are orthogonal to each other. If you consider $IQ$, income, number of years of sc
29,060
Collapsing (combining) two variables into one for analysis
Yes, see (2) If the predictor variables affect your dependent variable in the same way, and you have a theoretical basis for collapsing the variables, it makes sense to merge them. An example of an association that would make you want to collapse variables: If you examine factors predicting individual income, parent's education stands out. Imagine you know the highest level of education of both the father and mother of the individual. It turns out that the key factor is highest level of income of either of the parents. If you do a regression analysis, you find that it doesn't matter which parent had a higher level of education, or whether both had the same level of education. Instead, what predicts almost all of the individual's income out of those two variables is simply the highest level of education between the two parents. So in this case, you would want to combine the two variables and call the variable "highest level of parental education."
Collapsing (combining) two variables into one for analysis
Yes, see (2) If the predictor variables affect your dependent variable in the same way, and you have a theoretical basis for collapsing the variables, it makes sense to merge them. An example of an
Collapsing (combining) two variables into one for analysis Yes, see (2) If the predictor variables affect your dependent variable in the same way, and you have a theoretical basis for collapsing the variables, it makes sense to merge them. An example of an association that would make you want to collapse variables: If you examine factors predicting individual income, parent's education stands out. Imagine you know the highest level of education of both the father and mother of the individual. It turns out that the key factor is highest level of income of either of the parents. If you do a regression analysis, you find that it doesn't matter which parent had a higher level of education, or whether both had the same level of education. Instead, what predicts almost all of the individual's income out of those two variables is simply the highest level of education between the two parents. So in this case, you would want to combine the two variables and call the variable "highest level of parental education."
Collapsing (combining) two variables into one for analysis Yes, see (2) If the predictor variables affect your dependent variable in the same way, and you have a theoretical basis for collapsing the variables, it makes sense to merge them. An example of an
29,061
Collapsing (combining) two variables into one for analysis
How does the association of the two variables (x1 and x2) relevant to the decision on whether or not to merge them? If variables x1 and x2 represent two different methods to measure the same element, combining the two can provide a more accurate description of the element you wish to measure. E.g. if you need a variable that indicates body size, one can combine variables x1 = height and x2 = weight, either by summing x1 + x2 or by peforming a principal compenents analysis and choosing only the first component. If variables x1 and x2 are repeated measures of the same variable, creating a variable which is the average of the two may give a more accurate measure of the variable in question. Is there any other issue to consider on this topic that I didn't mention? If the variables are repeated measures, or the variables measure the same element but from two different subjects (mother and father from above) or two different parts (e.g. wrist width from both the left and the right hand of same person): It is ill-advised to create an average between them if either x1 or x2 includes outliers, or the differences between the two variables (x1 - x2) are very large.
Collapsing (combining) two variables into one for analysis
How does the association of the two variables (x1 and x2) relevant to the decision on whether or not to merge them? If variables x1 and x2 represent two different methods to measure the same eleme
Collapsing (combining) two variables into one for analysis How does the association of the two variables (x1 and x2) relevant to the decision on whether or not to merge them? If variables x1 and x2 represent two different methods to measure the same element, combining the two can provide a more accurate description of the element you wish to measure. E.g. if you need a variable that indicates body size, one can combine variables x1 = height and x2 = weight, either by summing x1 + x2 or by peforming a principal compenents analysis and choosing only the first component. If variables x1 and x2 are repeated measures of the same variable, creating a variable which is the average of the two may give a more accurate measure of the variable in question. Is there any other issue to consider on this topic that I didn't mention? If the variables are repeated measures, or the variables measure the same element but from two different subjects (mother and father from above) or two different parts (e.g. wrist width from both the left and the right hand of same person): It is ill-advised to create an average between them if either x1 or x2 includes outliers, or the differences between the two variables (x1 - x2) are very large.
Collapsing (combining) two variables into one for analysis How does the association of the two variables (x1 and x2) relevant to the decision on whether or not to merge them? If variables x1 and x2 represent two different methods to measure the same eleme
29,062
Sample size for binomial confidence interval?
(1) Yes. (2) Yes. There are only $n+1$ possible outcomes for a binomial random variable, so it is possible to look at what happens for each possible outcome - in fact this is faster than simulating lots and lots of outcomes! Let $X$ be the number of "successes" among the $n$ customers and let $\hat{p}=X/n$. The confidence interval is $\hat{p}\pm z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}$, so the halfwidth is $z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}$. Thus we want to compute $P(z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}\leq 0.005)$. In R, we can do this as follows: target.halfWidth<-0.005 p<-0.016 #true proportion n.vec<-seq(from=1000, to=3000, by=100) #number of samples # Vector to store results prob.hw<-rep(NA,length(n.vec)) # Loop through desired sample size options for (i in 1: length(n.vec)) { n<-n.vec[i] # Look at all possible outcomes x<-0:n p.est<-x/n # Compute halfwidth for each option halfWidth<-qnorm(0.95)*sqrt(p.est*(1-p.est)/n) # What is the probability that the halfwidth is less than 0.005? prob.hw[i]<-sum({halfWidth<=target.halfWidth}*dbinom(x,n,p)) } # Plot results plot(n.vec,prob.hw,type="b") abline(0.95,0,col=2) # Get the minimal n required n.vec[min(which(prob.hw>=0.95))] The answer is $n=2200$ in this case as well. Finally, it is usually a good idea to verify that the asymptotic normal approximation interval actually gives the desired coverage. In R, we can compute the coverage probability (i.e. the actual confidence level) as: p<-0.016 n<-2200 x<-0:n p.est<-x/n halfWidth<-qnorm(0.95)*sqrt(p.est*(1-p.est)/n) # Coverage probability sum({abs(p-p.est)<=halfWidth}*dbinom(x,n,p)) Different $p$ give different coverages. For $p$ around $0.015$, the actual confidence level of the nominal $90\%$ interval seems to be about $89\%$ in general, which I presume is fine for your purposes. (3) When you sample from a finite population, the number of successes is not binomial but hypergeometric. If the population is large compared to your sample size, the binomial works just fine as an approximation. If you sample 1000 out of 5000, say, it does not. Have a look at confidence intervals for proportions based on the hypergeometric distribution! Answers to additional questions: Let $(p_L,p_U)$ be the confidence interval. 1) In that case you are no longer computing $P(p_L-p_U\leq0.01)$ but $$P\Big(p_L-p_U\leq0.01~\mbox{and}~p\in(p_L,p_U)\Big),$$ i.e. the probability that the length of intervals that actually contain $p$ is at most 0.01. This may be an interesting quantity, depending on what you're interested in... 2) Maybe, but probably not. If the population size is large compared to the sample size you don't need it, and if it's not then the binomial distribution is not appropriate to begin with! 3) Sprop seems to contain confidence intervals based on the hypergeometric intervals, so that should work just fine.
Sample size for binomial confidence interval?
(1) Yes. (2) Yes. There are only $n+1$ possible outcomes for a binomial random variable, so it is possible to look at what happens for each possible outcome - in fact this is faster than simulating lo
Sample size for binomial confidence interval? (1) Yes. (2) Yes. There are only $n+1$ possible outcomes for a binomial random variable, so it is possible to look at what happens for each possible outcome - in fact this is faster than simulating lots and lots of outcomes! Let $X$ be the number of "successes" among the $n$ customers and let $\hat{p}=X/n$. The confidence interval is $\hat{p}\pm z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}$, so the halfwidth is $z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}$. Thus we want to compute $P(z_{\alpha/2}\sqrt{\hat{p}(1-\hat{p})/n}\leq 0.005)$. In R, we can do this as follows: target.halfWidth<-0.005 p<-0.016 #true proportion n.vec<-seq(from=1000, to=3000, by=100) #number of samples # Vector to store results prob.hw<-rep(NA,length(n.vec)) # Loop through desired sample size options for (i in 1: length(n.vec)) { n<-n.vec[i] # Look at all possible outcomes x<-0:n p.est<-x/n # Compute halfwidth for each option halfWidth<-qnorm(0.95)*sqrt(p.est*(1-p.est)/n) # What is the probability that the halfwidth is less than 0.005? prob.hw[i]<-sum({halfWidth<=target.halfWidth}*dbinom(x,n,p)) } # Plot results plot(n.vec,prob.hw,type="b") abline(0.95,0,col=2) # Get the minimal n required n.vec[min(which(prob.hw>=0.95))] The answer is $n=2200$ in this case as well. Finally, it is usually a good idea to verify that the asymptotic normal approximation interval actually gives the desired coverage. In R, we can compute the coverage probability (i.e. the actual confidence level) as: p<-0.016 n<-2200 x<-0:n p.est<-x/n halfWidth<-qnorm(0.95)*sqrt(p.est*(1-p.est)/n) # Coverage probability sum({abs(p-p.est)<=halfWidth}*dbinom(x,n,p)) Different $p$ give different coverages. For $p$ around $0.015$, the actual confidence level of the nominal $90\%$ interval seems to be about $89\%$ in general, which I presume is fine for your purposes. (3) When you sample from a finite population, the number of successes is not binomial but hypergeometric. If the population is large compared to your sample size, the binomial works just fine as an approximation. If you sample 1000 out of 5000, say, it does not. Have a look at confidence intervals for proportions based on the hypergeometric distribution! Answers to additional questions: Let $(p_L,p_U)$ be the confidence interval. 1) In that case you are no longer computing $P(p_L-p_U\leq0.01)$ but $$P\Big(p_L-p_U\leq0.01~\mbox{and}~p\in(p_L,p_U)\Big),$$ i.e. the probability that the length of intervals that actually contain $p$ is at most 0.01. This may be an interesting quantity, depending on what you're interested in... 2) Maybe, but probably not. If the population size is large compared to the sample size you don't need it, and if it's not then the binomial distribution is not appropriate to begin with! 3) Sprop seems to contain confidence intervals based on the hypergeometric intervals, so that should work just fine.
Sample size for binomial confidence interval? (1) Yes. (2) Yes. There are only $n+1$ possible outcomes for a binomial random variable, so it is possible to look at what happens for each possible outcome - in fact this is faster than simulating lo
29,063
Sample size for binomial confidence interval?
You could use the normal approximation to the binomial to determine the width of the confidence interval. The variance is $p(1-p)/n$. The standard deviation is $\sqrt{p(1-p)/n}$. Since you expect $p=0.016$ apply $p=0.02$ in the formula. The interval with width 4 sigma from mean-2 sigma to mean + two sigma is approximately a 95% two-sided confidence interval. So let $4\sigma =0.01$ (half width 0.005). So $4 \sqrt{0.02(0.98)/n}=0.01$ or $16 \cdot0.0196/n=0.01$ or $n=16\cdot 0.01960/0.0001= 16\cdot 196=3136.$ So you need about 3100 to have a 95% confidence interval with width 0.01.
Sample size for binomial confidence interval?
You could use the normal approximation to the binomial to determine the width of the confidence interval. The variance is $p(1-p)/n$. The standard deviation is $\sqrt{p(1-p)/n}$. Since you expect $p
Sample size for binomial confidence interval? You could use the normal approximation to the binomial to determine the width of the confidence interval. The variance is $p(1-p)/n$. The standard deviation is $\sqrt{p(1-p)/n}$. Since you expect $p=0.016$ apply $p=0.02$ in the formula. The interval with width 4 sigma from mean-2 sigma to mean + two sigma is approximately a 95% two-sided confidence interval. So let $4\sigma =0.01$ (half width 0.005). So $4 \sqrt{0.02(0.98)/n}=0.01$ or $16 \cdot0.0196/n=0.01$ or $n=16\cdot 0.01960/0.0001= 16\cdot 196=3136.$ So you need about 3100 to have a 95% confidence interval with width 0.01.
Sample size for binomial confidence interval? You could use the normal approximation to the binomial to determine the width of the confidence interval. The variance is $p(1-p)/n$. The standard deviation is $\sqrt{p(1-p)/n}$. Since you expect $p
29,064
How can I group strings by common themes?
This is a fairly standard problem in NLP, and the magic Google words you're looking for are "topic modeling". Although your strings are quite short, you may have some success with Latent Dirichlet Allocation, or a similar method. There's a nice blog post by Edwin Chen here, which lays out the general idea behind the algorithm. The details of implementation are covered in this note by Yi Wang. If you're looking for an off-the-shelf solution, I recommend trying out the topicmodels package for R, as this provides a reasonably nice interface to both LDA and a more sophisticated Correlated Topic Model. There's also a good list of implementations maintained by David Mimno here.
How can I group strings by common themes?
This is a fairly standard problem in NLP, and the magic Google words you're looking for are "topic modeling". Although your strings are quite short, you may have some success with Latent Dirichlet All
How can I group strings by common themes? This is a fairly standard problem in NLP, and the magic Google words you're looking for are "topic modeling". Although your strings are quite short, you may have some success with Latent Dirichlet Allocation, or a similar method. There's a nice blog post by Edwin Chen here, which lays out the general idea behind the algorithm. The details of implementation are covered in this note by Yi Wang. If you're looking for an off-the-shelf solution, I recommend trying out the topicmodels package for R, as this provides a reasonably nice interface to both LDA and a more sophisticated Correlated Topic Model. There's also a good list of implementations maintained by David Mimno here.
How can I group strings by common themes? This is a fairly standard problem in NLP, and the magic Google words you're looking for are "topic modeling". Although your strings are quite short, you may have some success with Latent Dirichlet All
29,065
How can I group strings by common themes?
You are trying to solve two problems here. Problem 1: Categorize questions strings in the proper category. Problem 2: Create proper categories. The first problem could be done by so-called supervised algorithms, many classifiers can give very good accuracy and performance. However, problem 2, creating categories out of thin air (tons of data), is much more tricky. This is an unsupervised problem, given lots of data the computer autonomically decides categories given some criteria. Ideally, these criteria and the algorithm should neatly organize your data into clusters. These could then be labeled. However, as this is a much more difficult task, I'd say that there is no acceptable drop-in solution here that will give a good result without a lot of tuning effort which would most likely require experts. So, I'm afraid there's no magic button here just yet. What you can do however, is to help the machine out a bit. For instance, you can decide on the category set. When you have decided on categories, you can create training data. In this setup, the training data is just question and correct category pairs. The more training data the better. However, as the task still is to something automatically, it doesn't make sense at first start doing things manually. Now why would you want to have training data? Accuracy evaluation. If you want good results, it is vital that you can perform some sort of evaluation on how good a setup is doing. And the only way do to that somewhat systematically is to manually label up some questiosn yourself. Otherwise you're in the blind. Then, some new questions do arise. First: How much training data do I need? "It depends". Without having seen your data or categories I'm not sure i'd even take a guess; but I can take a "ballpark estimate" and say about 500 questions. Note that I could be off by an order of magnitude. Does this really mean that you'd have to tag 500 questions by hand? Yes and no. It is possible to use intermediate results and some cleverness to "bootstrap" classifiers. It is still manual work though, and when you think on it 500 questions will not take that long to tag. Being clever here can quickly give worse results than being industrious. When you have training data in a sufficient amount, take 75% of it and create a classifier using your favourite tool (e.g those mentioned here or whatnot). Now, let the classifier try to label the held out 25% of the data and meausre the resulting accuracry. If the result is good, then pop champagne. If not then make more training data or try another classifier. TL;DR To sum, here's how I would have done it. 0) Use a supervised learner. 1) Create a category set yourself. 2) Label manually about 500 questions 3) Use 75% of those to train a classifier. 4) Check performance. 5) If good then cheers else goto 2.
How can I group strings by common themes?
You are trying to solve two problems here. Problem 1: Categorize questions strings in the proper category. Problem 2: Create proper categories. The first problem could be done by so-called supervised
How can I group strings by common themes? You are trying to solve two problems here. Problem 1: Categorize questions strings in the proper category. Problem 2: Create proper categories. The first problem could be done by so-called supervised algorithms, many classifiers can give very good accuracy and performance. However, problem 2, creating categories out of thin air (tons of data), is much more tricky. This is an unsupervised problem, given lots of data the computer autonomically decides categories given some criteria. Ideally, these criteria and the algorithm should neatly organize your data into clusters. These could then be labeled. However, as this is a much more difficult task, I'd say that there is no acceptable drop-in solution here that will give a good result without a lot of tuning effort which would most likely require experts. So, I'm afraid there's no magic button here just yet. What you can do however, is to help the machine out a bit. For instance, you can decide on the category set. When you have decided on categories, you can create training data. In this setup, the training data is just question and correct category pairs. The more training data the better. However, as the task still is to something automatically, it doesn't make sense at first start doing things manually. Now why would you want to have training data? Accuracy evaluation. If you want good results, it is vital that you can perform some sort of evaluation on how good a setup is doing. And the only way do to that somewhat systematically is to manually label up some questiosn yourself. Otherwise you're in the blind. Then, some new questions do arise. First: How much training data do I need? "It depends". Without having seen your data or categories I'm not sure i'd even take a guess; but I can take a "ballpark estimate" and say about 500 questions. Note that I could be off by an order of magnitude. Does this really mean that you'd have to tag 500 questions by hand? Yes and no. It is possible to use intermediate results and some cleverness to "bootstrap" classifiers. It is still manual work though, and when you think on it 500 questions will not take that long to tag. Being clever here can quickly give worse results than being industrious. When you have training data in a sufficient amount, take 75% of it and create a classifier using your favourite tool (e.g those mentioned here or whatnot). Now, let the classifier try to label the held out 25% of the data and meausre the resulting accuracry. If the result is good, then pop champagne. If not then make more training data or try another classifier. TL;DR To sum, here's how I would have done it. 0) Use a supervised learner. 1) Create a category set yourself. 2) Label manually about 500 questions 3) Use 75% of those to train a classifier. 4) Check performance. 5) If good then cheers else goto 2.
How can I group strings by common themes? You are trying to solve two problems here. Problem 1: Categorize questions strings in the proper category. Problem 2: Create proper categories. The first problem could be done by so-called supervised
29,066
How can I check whether two signals are jointly normally distributed?
Apart from graphical examination, you could use a test for normality. For bivariate data, Mardia's tests are a good choice. They quantify the shape of your distributions in two different ways. If the shape looks non-normal, the tests gives low p-values. Matlab implementations can be found here.
How can I check whether two signals are jointly normally distributed?
Apart from graphical examination, you could use a test for normality. For bivariate data, Mardia's tests are a good choice. They quantify the shape of your distributions in two different ways. If the
How can I check whether two signals are jointly normally distributed? Apart from graphical examination, you could use a test for normality. For bivariate data, Mardia's tests are a good choice. They quantify the shape of your distributions in two different ways. If the shape looks non-normal, the tests gives low p-values. Matlab implementations can be found here.
How can I check whether two signals are jointly normally distributed? Apart from graphical examination, you could use a test for normality. For bivariate data, Mardia's tests are a good choice. They quantify the shape of your distributions in two different ways. If the
29,067
How can I check whether two signals are jointly normally distributed?
This is more an extended comment than an effort to improve on the specific suggestion of @MånsT: Statistical test by and large are not tests for what distribution produced data but rather which ones did NOT. There are a few tests which are "tuned" to give answers to the normality question: Is this NOT from a Normal Distribution. The one sample Kolmogorov-Smirnov test is fairly widely known. The Anderson Darling test is perhaps more powerful in the one-D case. You should seriously ask yourself, WHY is the answer important? Often people ask the question for the wrong statistical purposes. Your example has demonstrated that your graphics-eyeball test has low power against an alternative composed of a sawtooth-Gaussian alternative, but you have not shown how that failure affects you underlying question.
How can I check whether two signals are jointly normally distributed?
This is more an extended comment than an effort to improve on the specific suggestion of @MånsT: Statistical test by and large are not tests for what distribution produced data but rather which ones d
How can I check whether two signals are jointly normally distributed? This is more an extended comment than an effort to improve on the specific suggestion of @MånsT: Statistical test by and large are not tests for what distribution produced data but rather which ones did NOT. There are a few tests which are "tuned" to give answers to the normality question: Is this NOT from a Normal Distribution. The one sample Kolmogorov-Smirnov test is fairly widely known. The Anderson Darling test is perhaps more powerful in the one-D case. You should seriously ask yourself, WHY is the answer important? Often people ask the question for the wrong statistical purposes. Your example has demonstrated that your graphics-eyeball test has low power against an alternative composed of a sawtooth-Gaussian alternative, but you have not shown how that failure affects you underlying question.
How can I check whether two signals are jointly normally distributed? This is more an extended comment than an effort to improve on the specific suggestion of @MånsT: Statistical test by and large are not tests for what distribution produced data but rather which ones d
29,068
Markov models with conditional transition probabilities
You can always have a 2nd order or higher order markov chain. In that case your model all ready includes all probabilistic transition information in it. You can check Dynamic Bayesian Networks which is a graphical model generalization of Markov Chains that are utilized frequently in machine learning.
Markov models with conditional transition probabilities
You can always have a 2nd order or higher order markov chain. In that case your model all ready includes all probabilistic transition information in it. You can check Dynamic Bayesian Networks which i
Markov models with conditional transition probabilities You can always have a 2nd order or higher order markov chain. In that case your model all ready includes all probabilistic transition information in it. You can check Dynamic Bayesian Networks which is a graphical model generalization of Markov Chains that are utilized frequently in machine learning.
Markov models with conditional transition probabilities You can always have a 2nd order or higher order markov chain. In that case your model all ready includes all probabilistic transition information in it. You can check Dynamic Bayesian Networks which i
29,069
Markov models with conditional transition probabilities
I believe what you are looking for is Maxent Markov Models. Or you may used a generalisation (if I understand it right) of Maxent Markov models, which are called Conditional Random Fields.
Markov models with conditional transition probabilities
I believe what you are looking for is Maxent Markov Models. Or you may used a generalisation (if I understand it right) of Maxent Markov models, which are called Conditional Random Fields.
Markov models with conditional transition probabilities I believe what you are looking for is Maxent Markov Models. Or you may used a generalisation (if I understand it right) of Maxent Markov models, which are called Conditional Random Fields.
Markov models with conditional transition probabilities I believe what you are looking for is Maxent Markov Models. Or you may used a generalisation (if I understand it right) of Maxent Markov models, which are called Conditional Random Fields.
29,070
Markov models with conditional transition probabilities
I was asking myself the same question and if you really only need to model the outcome based on the state at $T_1$ and covariates, you may find the msm package in R helpful. This package seems to be a pretty good fit for modeling the effects of covariates on transitions between categorical outcomes over time. It wouldn't help if you really do need a higher order chain, but it doesn't seem like that's the case based on your original question.
Markov models with conditional transition probabilities
I was asking myself the same question and if you really only need to model the outcome based on the state at $T_1$ and covariates, you may find the msm package in R helpful. This package seems to be a
Markov models with conditional transition probabilities I was asking myself the same question and if you really only need to model the outcome based on the state at $T_1$ and covariates, you may find the msm package in R helpful. This package seems to be a pretty good fit for modeling the effects of covariates on transitions between categorical outcomes over time. It wouldn't help if you really do need a higher order chain, but it doesn't seem like that's the case based on your original question.
Markov models with conditional transition probabilities I was asking myself the same question and if you really only need to model the outcome based on the state at $T_1$ and covariates, you may find the msm package in R helpful. This package seems to be a
29,071
Is the binomial effect size display (BESD) a misleading representation of effect size?
I can demonstrate that it is biased (I think), but I cannot explain why. I'm hoping someone can see my answer and help explain it more. As in many meta-analyses and the image you posted, many people interpret the BESD as: If you were to median split both variables, you would accurately put people in the "right" cells of a 2 x 2 contingency table a given percent of the time. So if $.50 + r/2 = .70$, people might say, "Given this observed $r$, you can think of it like this: People above the median in X would also be above the median in Y 70% of the time." This is somewhat how Kraus (1995, p. 69) interprets it (he relies on a hypothetical situation where one variable is truly dichotomous, while the other is median split): People have often used medical metaphors, too: "This $r$ corresponds to a difference in 40 percentage point between people in a control and experimental condition." To see if the median-split-esque interpretation is biased, I simulated a population of 1,000,000 cases where the true population $r = .38$. I then drew 100 people from this population, calculated the BESD "correct rate" (i.e., $.50 + r/2$), and then calculated the actual median split cells for a 2 x 2 contingency table, like the one described above for categorizing people "correctly." I did this 10,000 times. I then took the mean and standard deviation of each of these vectors of 10,000 in length. The code: library(MASS) # set population params mu <- rep(0,2) Sigma <- matrix(.38, nrow=2, ncol=2) + diag(2)*.62 # set seed set.seed(1839) # generate population pop <- as.data.frame(mvrnorm(n=1000000, mu=mu, Sigma=Sigma)) # initialize vectors besd_correct <- c() actual_correct <- c() # actually break up raw data by median split, see how it works for (i in 1:10000) { samp <- pop[sample(1:1000000, 100),] besd_correct[i] <- round(100*(.50 + cor(samp)[1,2]/2),0) samp$V1_split <- ifelse(samp$V1 > median(samp$V1), 1, 0) samp$V2_split <- ifelse(samp$V2 > median(samp$V2), 1, 0) actual_correct[i] <- with(samp, table(V1_split==V2_split))[[2]] } # cells for BESD mean(besd_correct) 100 - mean(besd_correct) # cells for actual 2 x 2 table with median split mean(actual_correct) 100 - mean(actual_correct) Based on BESD, we get this table, where v1 and v2 refer to variables and low and high refer to below and above the median, respectively: +---------+--------+---------+ | | v2 low | v2 high | +---------+--------+---------+ | v1 low | 69 | 31 | +---------+--------+---------+ | v1 high | 31 | 69 | +---------+--------+---------+ Based on actually doing a median split with the raw data, we get this table: +---------+--------+---------+ | | v2 low | v2 high | +---------+--------+---------+ | v1 low | 62 | 38 | +---------+--------+---------+ | v1 high | 38 | 62 | +---------+--------+---------+ So while someone could argue, using BESD, that there is a "38 percentage point difference in control and experimental," the actual median split has this number at 24. I'm not sure why this happens, or if it depends on sample size and correlation (one could easily do more simulations to figure out), I think this shows it is biased. I would love if someone could chime in with a mathematical—rather than computational—explanation.
Is the binomial effect size display (BESD) a misleading representation of effect size?
I can demonstrate that it is biased (I think), but I cannot explain why. I'm hoping someone can see my answer and help explain it more. As in many meta-analyses and the image you posted, many people i
Is the binomial effect size display (BESD) a misleading representation of effect size? I can demonstrate that it is biased (I think), but I cannot explain why. I'm hoping someone can see my answer and help explain it more. As in many meta-analyses and the image you posted, many people interpret the BESD as: If you were to median split both variables, you would accurately put people in the "right" cells of a 2 x 2 contingency table a given percent of the time. So if $.50 + r/2 = .70$, people might say, "Given this observed $r$, you can think of it like this: People above the median in X would also be above the median in Y 70% of the time." This is somewhat how Kraus (1995, p. 69) interprets it (he relies on a hypothetical situation where one variable is truly dichotomous, while the other is median split): People have often used medical metaphors, too: "This $r$ corresponds to a difference in 40 percentage point between people in a control and experimental condition." To see if the median-split-esque interpretation is biased, I simulated a population of 1,000,000 cases where the true population $r = .38$. I then drew 100 people from this population, calculated the BESD "correct rate" (i.e., $.50 + r/2$), and then calculated the actual median split cells for a 2 x 2 contingency table, like the one described above for categorizing people "correctly." I did this 10,000 times. I then took the mean and standard deviation of each of these vectors of 10,000 in length. The code: library(MASS) # set population params mu <- rep(0,2) Sigma <- matrix(.38, nrow=2, ncol=2) + diag(2)*.62 # set seed set.seed(1839) # generate population pop <- as.data.frame(mvrnorm(n=1000000, mu=mu, Sigma=Sigma)) # initialize vectors besd_correct <- c() actual_correct <- c() # actually break up raw data by median split, see how it works for (i in 1:10000) { samp <- pop[sample(1:1000000, 100),] besd_correct[i] <- round(100*(.50 + cor(samp)[1,2]/2),0) samp$V1_split <- ifelse(samp$V1 > median(samp$V1), 1, 0) samp$V2_split <- ifelse(samp$V2 > median(samp$V2), 1, 0) actual_correct[i] <- with(samp, table(V1_split==V2_split))[[2]] } # cells for BESD mean(besd_correct) 100 - mean(besd_correct) # cells for actual 2 x 2 table with median split mean(actual_correct) 100 - mean(actual_correct) Based on BESD, we get this table, where v1 and v2 refer to variables and low and high refer to below and above the median, respectively: +---------+--------+---------+ | | v2 low | v2 high | +---------+--------+---------+ | v1 low | 69 | 31 | +---------+--------+---------+ | v1 high | 31 | 69 | +---------+--------+---------+ Based on actually doing a median split with the raw data, we get this table: +---------+--------+---------+ | | v2 low | v2 high | +---------+--------+---------+ | v1 low | 62 | 38 | +---------+--------+---------+ | v1 high | 38 | 62 | +---------+--------+---------+ So while someone could argue, using BESD, that there is a "38 percentage point difference in control and experimental," the actual median split has this number at 24. I'm not sure why this happens, or if it depends on sample size and correlation (one could easily do more simulations to figure out), I think this shows it is biased. I would love if someone could chime in with a mathematical—rather than computational—explanation.
Is the binomial effect size display (BESD) a misleading representation of effect size? I can demonstrate that it is biased (I think), but I cannot explain why. I'm hoping someone can see my answer and help explain it more. As in many meta-analyses and the image you posted, many people i
29,072
Is the binomial effect size display (BESD) a misleading representation of effect size?
Mark White's intuition is incorrect. The BESD is not actually modeling a median split. A median split is associated with real statistical information loss--it systematically attenuates relations (see http://psycnet.apa.org/record/1990-24322-001), which is why the median split values show a smaller accuracy than the BESD. The BESD is demonstrating classification accuracy as though the variables were truly dichotomous, not artificially dichotomized through a median split. To see this, compute the correlation on the median split data. You will see that it is smaller than the correlation for the original variables. If the variables were originally binary, the two methods would agree. By its nature, the BESD is displaying variables as though they were truly binary. When it is used for continuous variables, this necessarily represents an abstraction--there aren't really "success" and "failure" or "treatment" and "control" groups, but it is practically useful to show results in this way because it can be easier to understand two binary variables than two continuous variables. The BESD is not biased. It accurately reflects the impact of a particular treatment on classification accuracy if we were working with two binary variables. It is a useful display for demonstrating the potential practical value of a measure or treatment, and, yes, it does demonstrate that even effects with small variance accounted for statistics can be meaningfully important. The BESD is widely used in applied psychological and organizational practice, and it agrees strongly with other practical effect size displays (e.g., that top-down selecting a group using a measure with a validity correlation of r=.25 will lead to a .25 SD increase in outcome performance among the selected group versus an unselected group). Variance accounted for statistics consistently lead to misunderstandings and underestimates about the size of variable relations because the squaring operation is nonlinear. Many applied methodologists (e.g., https://us.sagepub.com/en-us/nam/methods-of-meta-analysis/book240589) strongly discourage their use in favor of their square roots (which more accurately convey the size of effects).
Is the binomial effect size display (BESD) a misleading representation of effect size?
Mark White's intuition is incorrect. The BESD is not actually modeling a median split. A median split is associated with real statistical information loss--it systematically attenuates relations (see
Is the binomial effect size display (BESD) a misleading representation of effect size? Mark White's intuition is incorrect. The BESD is not actually modeling a median split. A median split is associated with real statistical information loss--it systematically attenuates relations (see http://psycnet.apa.org/record/1990-24322-001), which is why the median split values show a smaller accuracy than the BESD. The BESD is demonstrating classification accuracy as though the variables were truly dichotomous, not artificially dichotomized through a median split. To see this, compute the correlation on the median split data. You will see that it is smaller than the correlation for the original variables. If the variables were originally binary, the two methods would agree. By its nature, the BESD is displaying variables as though they were truly binary. When it is used for continuous variables, this necessarily represents an abstraction--there aren't really "success" and "failure" or "treatment" and "control" groups, but it is practically useful to show results in this way because it can be easier to understand two binary variables than two continuous variables. The BESD is not biased. It accurately reflects the impact of a particular treatment on classification accuracy if we were working with two binary variables. It is a useful display for demonstrating the potential practical value of a measure or treatment, and, yes, it does demonstrate that even effects with small variance accounted for statistics can be meaningfully important. The BESD is widely used in applied psychological and organizational practice, and it agrees strongly with other practical effect size displays (e.g., that top-down selecting a group using a measure with a validity correlation of r=.25 will lead to a .25 SD increase in outcome performance among the selected group versus an unselected group). Variance accounted for statistics consistently lead to misunderstandings and underestimates about the size of variable relations because the squaring operation is nonlinear. Many applied methodologists (e.g., https://us.sagepub.com/en-us/nam/methods-of-meta-analysis/book240589) strongly discourage their use in favor of their square roots (which more accurately convey the size of effects).
Is the binomial effect size display (BESD) a misleading representation of effect size? Mark White's intuition is incorrect. The BESD is not actually modeling a median split. A median split is associated with real statistical information loss--it systematically attenuates relations (see
29,073
Is the binomial effect size display (BESD) a misleading representation of effect size?
For a detailed answer, an analysis of when it makes a difference, and a better solution, please see Exact Method for Computing Absolute Percentage Change in a Dichotomous Outcome from Meta-Analytic Effect Size: Improving Impact and Cost-Outcome Estimates, TR Miller, J Derzon, D Hendrie, Value in Health, 14:1, 144-151, 2011. Here's the summary answer in the abstract of that article. OBJECTIVES: Meta-analyses typically compute a treatment effect size (Cohen's d), which is readily converted to another common measure, the binomial effect size display (BESD). BESD is the correlation coefficient and represents a percentage difference in outcome attributable to an intervention. Both d and BESD are in arbitrary units; neither measures the absolute change resulting from intervention. The method used to estimate absolute change from BESD assumes both a 50-50 split of the outcome and a balanced design. Consequently, inaccurate assumptions underpin most meta-analytic estimates of the gain resulting from an intervention (and of its cost effectiveness). This article develops an exact formula without these assumptions. METHODS: The formula is developed algebraically from 1) the formula for the correlation coefficient represented as a 2-by-2 contingency table constructed from the relative size of the treatment and control groups and the percentage of people who would have the condition absent intervention, and 2) the BESD correlation coefficient formula showing change in success probability with treatment. RESULTS: Simulation reveals that BESD only approximates the reduction in the outcome an intervention might well achieve when the problem outcome occurs in 35%-65% of cases. For less common outcomes, BESD substantially overestimates the impact of an intervention. Even when BESD accurately estimates the likely percentage change in outcome, it paints a misleading picture of the proportion of cases that will achieve a positive outcome.
Is the binomial effect size display (BESD) a misleading representation of effect size?
For a detailed answer, an analysis of when it makes a difference, and a better solution, please see Exact Method for Computing Absolute Percentage Change in a Dichotomous Outcome from Meta-Analytic Ef
Is the binomial effect size display (BESD) a misleading representation of effect size? For a detailed answer, an analysis of when it makes a difference, and a better solution, please see Exact Method for Computing Absolute Percentage Change in a Dichotomous Outcome from Meta-Analytic Effect Size: Improving Impact and Cost-Outcome Estimates, TR Miller, J Derzon, D Hendrie, Value in Health, 14:1, 144-151, 2011. Here's the summary answer in the abstract of that article. OBJECTIVES: Meta-analyses typically compute a treatment effect size (Cohen's d), which is readily converted to another common measure, the binomial effect size display (BESD). BESD is the correlation coefficient and represents a percentage difference in outcome attributable to an intervention. Both d and BESD are in arbitrary units; neither measures the absolute change resulting from intervention. The method used to estimate absolute change from BESD assumes both a 50-50 split of the outcome and a balanced design. Consequently, inaccurate assumptions underpin most meta-analytic estimates of the gain resulting from an intervention (and of its cost effectiveness). This article develops an exact formula without these assumptions. METHODS: The formula is developed algebraically from 1) the formula for the correlation coefficient represented as a 2-by-2 contingency table constructed from the relative size of the treatment and control groups and the percentage of people who would have the condition absent intervention, and 2) the BESD correlation coefficient formula showing change in success probability with treatment. RESULTS: Simulation reveals that BESD only approximates the reduction in the outcome an intervention might well achieve when the problem outcome occurs in 35%-65% of cases. For less common outcomes, BESD substantially overestimates the impact of an intervention. Even when BESD accurately estimates the likely percentage change in outcome, it paints a misleading picture of the proportion of cases that will achieve a positive outcome.
Is the binomial effect size display (BESD) a misleading representation of effect size? For a detailed answer, an analysis of when it makes a difference, and a better solution, please see Exact Method for Computing Absolute Percentage Change in a Dichotomous Outcome from Meta-Analytic Ef
29,074
Are MFCCs the optimal method of representing music to a retrieval system?
We did a bit of work on this at one point. The set of features we extracted are given in this NIPS workshop paper. I have to admit we couldn't replicate the results of some other authors in the field, although there were some doubts about the datasets used in these (note that the datasets used by authors in this field tend to be hand-picked and not released to the public, for copyright reasons, although this not always the case). Essentially they were all short-term spectral features with Autoregression coefficients thrown in too. We were looking at classification of genre, which we know can be done by humans (although not with wonderful accuracy, and not with consistent agreement ....) in very short timespans (<1s), which validates the use of short term features. If you're interested in doing more complicated things than the typical genre/artist/album/producer classification then you might need more long-range features, otherwise these short-term spectral features tend to perform best.
Are MFCCs the optimal method of representing music to a retrieval system?
We did a bit of work on this at one point. The set of features we extracted are given in this NIPS workshop paper. I have to admit we couldn't replicate the results of some other authors in the field,
Are MFCCs the optimal method of representing music to a retrieval system? We did a bit of work on this at one point. The set of features we extracted are given in this NIPS workshop paper. I have to admit we couldn't replicate the results of some other authors in the field, although there were some doubts about the datasets used in these (note that the datasets used by authors in this field tend to be hand-picked and not released to the public, for copyright reasons, although this not always the case). Essentially they were all short-term spectral features with Autoregression coefficients thrown in too. We were looking at classification of genre, which we know can be done by humans (although not with wonderful accuracy, and not with consistent agreement ....) in very short timespans (<1s), which validates the use of short term features. If you're interested in doing more complicated things than the typical genre/artist/album/producer classification then you might need more long-range features, otherwise these short-term spectral features tend to perform best.
Are MFCCs the optimal method of representing music to a retrieval system? We did a bit of work on this at one point. The set of features we extracted are given in this NIPS workshop paper. I have to admit we couldn't replicate the results of some other authors in the field,
29,075
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient?
I am certainly not the greatest person to answer this, but here it goes! Wald test has only an asymptotic distribution that is known in general. In some specific cases, one can do much better than that. Let me give you a simple example. For instance, suppose that you are interested in estimating the model $y_i = \beta_0 + \beta_1 x_i + u_i, \; \; i = 1, \dots, N$, where $u_i \sim \mbox{N}(0, \sigma^2)$, so that the error terms are normally distributed. Using ordinary least squares (OLS), one can obtain estimates $\hat{\beta_0}$ and $\hat{\beta_1}$. If you want to test whether the estimate $\hat \beta_1$ is significantly different from some value, say, $\beta_{10}$, you can use a simple $t$-test, square of which is equal to the $F$ test on $\hat \beta_1$. In this perhaps slightly unrealistic setting, distribution of both of these tests is known exactly. That is to say that one knows the true distribution of the $t$ and $F$ statistics under the null hypothesis (incidentally, one can also find the distributions under the alternative). Hence, one does not need to resort to asymptotic distributions, which, in general, are only approximately true. As a corollary, for instance, confidence intervals constructed using the $F$ test will have better coverage. Hence, in this particular setting you would be better advised to use the $F$ test. If the error terms are not normally distributed, $t$ and $F$ statistics no longer have exact finite sample distributions. So the choice no longer seems clear-cut. However, it can be shown (e.g., Davidson & MacKinnon, "Econometric Theory and Methods", p. 244) that $F$ and Wald tests are asymptotically equivalent, so that the choice is not really that important. You may also be interested in taking a look at this reference.
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient?
I am certainly not the greatest person to answer this, but here it goes! Wald test has only an asymptotic distribution that is known in general. In some specific cases, one can do much better than tha
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient? I am certainly not the greatest person to answer this, but here it goes! Wald test has only an asymptotic distribution that is known in general. In some specific cases, one can do much better than that. Let me give you a simple example. For instance, suppose that you are interested in estimating the model $y_i = \beta_0 + \beta_1 x_i + u_i, \; \; i = 1, \dots, N$, where $u_i \sim \mbox{N}(0, \sigma^2)$, so that the error terms are normally distributed. Using ordinary least squares (OLS), one can obtain estimates $\hat{\beta_0}$ and $\hat{\beta_1}$. If you want to test whether the estimate $\hat \beta_1$ is significantly different from some value, say, $\beta_{10}$, you can use a simple $t$-test, square of which is equal to the $F$ test on $\hat \beta_1$. In this perhaps slightly unrealistic setting, distribution of both of these tests is known exactly. That is to say that one knows the true distribution of the $t$ and $F$ statistics under the null hypothesis (incidentally, one can also find the distributions under the alternative). Hence, one does not need to resort to asymptotic distributions, which, in general, are only approximately true. As a corollary, for instance, confidence intervals constructed using the $F$ test will have better coverage. Hence, in this particular setting you would be better advised to use the $F$ test. If the error terms are not normally distributed, $t$ and $F$ statistics no longer have exact finite sample distributions. So the choice no longer seems clear-cut. However, it can be shown (e.g., Davidson & MacKinnon, "Econometric Theory and Methods", p. 244) that $F$ and Wald tests are asymptotically equivalent, so that the choice is not really that important. You may also be interested in taking a look at this reference.
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient? I am certainly not the greatest person to answer this, but here it goes! Wald test has only an asymptotic distribution that is known in general. In some specific cases, one can do much better than tha
29,076
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient?
Best answer I have found is at Stata FAQ: Chi square vs F Essentially, as denominator degrees of freedom increase, the F distribution approaches a chi square distribution.
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient?
Best answer I have found is at Stata FAQ: Chi square vs F Essentially, as denominator degrees of freedom increase, the F distribution approaches a chi square distribution.
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient? Best answer I have found is at Stata FAQ: Chi square vs F Essentially, as denominator degrees of freedom increase, the F distribution approaches a chi square distribution.
How do I decide whether to use the Wald or F-test in testing the significance of slope coefficient? Best answer I have found is at Stata FAQ: Chi square vs F Essentially, as denominator degrees of freedom increase, the F distribution approaches a chi square distribution.
29,077
Statistics for online dating sites
I once spoke to someone who works for one of the online dating sites that uses statistical techniques (they'd probably rather I didn't say who). It was quite interesting - to begin with they used very simple things, such as nearest neighbours with euclidiean or L_1 (cityblock) distances between profile vectors, but there was a debate as to whether matching two people who were too similar was a good or bad thing. He then went on to say that now they have gathered a lot of data (who was interested in who, who dated who, who got married etc. etc.), they are using that to constantly retrain models. The work in an incremental-batch framework, where they update their models periodically using batches of data, and then recalculate the match probabilities on the database. Quite interesting stuff, but I'd hazard a guess that most dating websites use pretty simple heuristics.
Statistics for online dating sites
I once spoke to someone who works for one of the online dating sites that uses statistical techniques (they'd probably rather I didn't say who). It was quite interesting - to begin with they used very
Statistics for online dating sites I once spoke to someone who works for one of the online dating sites that uses statistical techniques (they'd probably rather I didn't say who). It was quite interesting - to begin with they used very simple things, such as nearest neighbours with euclidiean or L_1 (cityblock) distances between profile vectors, but there was a debate as to whether matching two people who were too similar was a good or bad thing. He then went on to say that now they have gathered a lot of data (who was interested in who, who dated who, who got married etc. etc.), they are using that to constantly retrain models. The work in an incremental-batch framework, where they update their models periodically using batches of data, and then recalculate the match probabilities on the database. Quite interesting stuff, but I'd hazard a guess that most dating websites use pretty simple heuristics.
Statistics for online dating sites I once spoke to someone who works for one of the online dating sites that uses statistical techniques (they'd probably rather I didn't say who). It was quite interesting - to begin with they used very
29,078
Statistics for online dating sites
You asked for a simple model. Here's how I would start with R code: glm(match ~ outdoorDif*outdoorImport + optimistDif*optimistImport, family=binomial(link="logit")) outdoorDif = the difference of the two people's answers about how much they enjoy outdoor activities. outdoorImport = the average of the two answers on the importance of a match regarding the answers on enjoyment of outdoor activities. The * indicates that the preceding and following terms are interacted and also included separately. You suggest that the match data is binary with the only two options being, "happily married" and "no second date," so that is what I assumed in choosing a logit model. This doesn't seem realistic. If you have more than two possible outcomes you'll need to switch to a multinomial or ordered logit or some such model. If, as you suggest, some people have multiple attempted matches then that would probably be a very important thing to try to account for in the model. One way to do it might be to have separate variables indicating the # of previous attempted matches for each person, and then interact the two.
Statistics for online dating sites
You asked for a simple model. Here's how I would start with R code: glm(match ~ outdoorDif*outdoorImport + optimistDif*optimistImport, family=binomial(link="logit")) outdoorDif = the differenc
Statistics for online dating sites You asked for a simple model. Here's how I would start with R code: glm(match ~ outdoorDif*outdoorImport + optimistDif*optimistImport, family=binomial(link="logit")) outdoorDif = the difference of the two people's answers about how much they enjoy outdoor activities. outdoorImport = the average of the two answers on the importance of a match regarding the answers on enjoyment of outdoor activities. The * indicates that the preceding and following terms are interacted and also included separately. You suggest that the match data is binary with the only two options being, "happily married" and "no second date," so that is what I assumed in choosing a logit model. This doesn't seem realistic. If you have more than two possible outcomes you'll need to switch to a multinomial or ordered logit or some such model. If, as you suggest, some people have multiple attempted matches then that would probably be a very important thing to try to account for in the model. One way to do it might be to have separate variables indicating the # of previous attempted matches for each person, and then interact the two.
Statistics for online dating sites You asked for a simple model. Here's how I would start with R code: glm(match ~ outdoorDif*outdoorImport + optimistDif*optimistImport, family=binomial(link="logit")) outdoorDif = the differenc
29,079
Statistics for online dating sites
One simple approach would be as follows. For the two preference questions, take the absolute difference between the two respondent's responses, giving two variables, say z1 and z2, instead of four. For the importance questions, I might create a score that combines the two responses. If the responses were, say, (1,1), I'd give a 1, a (1,2) or (2,1) gets a 2, a (1,3) or (3,1) gets a 3, a (2,3) or (3,2) gets a 4, and a (3,3) gets a 5. Let's call that the "importance score." An alternative would be just to use max(response), giving 3 categories instead of 5, but I think the 5 category version is better. I'd now create ten variables, x1 - x10 (for concreteness), all with default values of zero. For those observations with an importance score for the first question = 1, x1 = z1. If the importance score for the second question also = 1, x2 = z2. For those observations with an importance score for the first question = 2, x3 = z1 and if the importance score for the second question = 2, x4 = z2, and so on. For each observation, exactly one of x1, x3, x5, x7, x9 != 0, and similarly for x2, x4, x6, x8, x10. Having done all that, I'd run a logistic regression with the binary outcome as the target variable and x1 - x10 as the regressors. More sophisticated versions of this might create more importance scores by allowing male and female respondent's importance to be treated differently, e.g, a (1,2) != a (2,1), where we've ordered the responses by sex. One shortfall of this model is that you might have multiple observations of the same person, which would mean the "errors", loosely speaking, are not independent across observations. However, with a lot of people in the sample, I'd probably just ignore this, for a first pass, or construct a sample where there were no duplicates. Another shortfall is that it is plausible that as importance increases, the effect of a given difference between preferences on p(fail) would also increase, which implies a relationship between the coefficients of (x1, x3, x5, x7, x9) and also between the coefficients of (x2, x4, x6, x8, x10). (Probably not a complete ordering, as it's not a priori clear to me how a (2,2) importance score relates to a (1,3) importance score.) However, we have not imposed that in the model. I'd probably ignore that at first, and see if I'm surprised by the results. The advantage of this approach is it imposes no assumption about the functional form of the relationship between "importance" and the difference between preference responses. This contradicts the previous shortfall comment, but I think the lack of a functional form being imposed is likely more beneficial than the related failure to take into account the expected relationships between coefficients.
Statistics for online dating sites
One simple approach would be as follows. For the two preference questions, take the absolute difference between the two respondent's responses, giving two variables, say z1 and z2, instead of four.
Statistics for online dating sites One simple approach would be as follows. For the two preference questions, take the absolute difference between the two respondent's responses, giving two variables, say z1 and z2, instead of four. For the importance questions, I might create a score that combines the two responses. If the responses were, say, (1,1), I'd give a 1, a (1,2) or (2,1) gets a 2, a (1,3) or (3,1) gets a 3, a (2,3) or (3,2) gets a 4, and a (3,3) gets a 5. Let's call that the "importance score." An alternative would be just to use max(response), giving 3 categories instead of 5, but I think the 5 category version is better. I'd now create ten variables, x1 - x10 (for concreteness), all with default values of zero. For those observations with an importance score for the first question = 1, x1 = z1. If the importance score for the second question also = 1, x2 = z2. For those observations with an importance score for the first question = 2, x3 = z1 and if the importance score for the second question = 2, x4 = z2, and so on. For each observation, exactly one of x1, x3, x5, x7, x9 != 0, and similarly for x2, x4, x6, x8, x10. Having done all that, I'd run a logistic regression with the binary outcome as the target variable and x1 - x10 as the regressors. More sophisticated versions of this might create more importance scores by allowing male and female respondent's importance to be treated differently, e.g, a (1,2) != a (2,1), where we've ordered the responses by sex. One shortfall of this model is that you might have multiple observations of the same person, which would mean the "errors", loosely speaking, are not independent across observations. However, with a lot of people in the sample, I'd probably just ignore this, for a first pass, or construct a sample where there were no duplicates. Another shortfall is that it is plausible that as importance increases, the effect of a given difference between preferences on p(fail) would also increase, which implies a relationship between the coefficients of (x1, x3, x5, x7, x9) and also between the coefficients of (x2, x4, x6, x8, x10). (Probably not a complete ordering, as it's not a priori clear to me how a (2,2) importance score relates to a (1,3) importance score.) However, we have not imposed that in the model. I'd probably ignore that at first, and see if I'm surprised by the results. The advantage of this approach is it imposes no assumption about the functional form of the relationship between "importance" and the difference between preference responses. This contradicts the previous shortfall comment, but I think the lack of a functional form being imposed is likely more beneficial than the related failure to take into account the expected relationships between coefficients.
Statistics for online dating sites One simple approach would be as follows. For the two preference questions, take the absolute difference between the two respondent's responses, giving two variables, say z1 and z2, instead of four.
29,080
Dashed lines in ACF plot in R
The sample autocorrelation is negatively biased and the first sample autocorrelation coefficient has mean $-1/n$ where $n$ is the number of observations. But Metcalfe and Cowpertwait are incorrect in saying that all autocorrelation coefficients have that mean, and they are also incorrect in saying that R plots lines at $-1/n \pm 1.96/\sqrt{n}$. Asymptotically the mean is 0 and that is what R uses in plotting the lines at $\pm 1.96/\sqrt{n}$ .
Dashed lines in ACF plot in R
The sample autocorrelation is negatively biased and the first sample autocorrelation coefficient has mean $-1/n$ where $n$ is the number of observations. But Metcalfe and Cowpertwait are incorrect in
Dashed lines in ACF plot in R The sample autocorrelation is negatively biased and the first sample autocorrelation coefficient has mean $-1/n$ where $n$ is the number of observations. But Metcalfe and Cowpertwait are incorrect in saying that all autocorrelation coefficients have that mean, and they are also incorrect in saying that R plots lines at $-1/n \pm 1.96/\sqrt{n}$. Asymptotically the mean is 0 and that is what R uses in plotting the lines at $\pm 1.96/\sqrt{n}$ .
Dashed lines in ACF plot in R The sample autocorrelation is negatively biased and the first sample autocorrelation coefficient has mean $-1/n$ where $n$ is the number of observations. But Metcalfe and Cowpertwait are incorrect in
29,081
Literature on the algorithm for optimal splitting in the growing of classification trees
I will give a different answer, since is too much for a comment and it treats a more general approach. So, in ESL, they describe indeed the computation time for a branch-and-bound (more precisely it looks like a divide and conquer to me). We denote with $N$ the number of observations and with $K$ the number of children nodes, when we grow a tree. I assume we do not loose in generality if we consider $K$ to be fixed. Also, we can denote with $f(N)$ the processing time for computing split points at a given node. Thus, we can write recursively the formula for the execution time like: $$T(N) = f(N) + K * T(N/K) $$ we considered here that the child nodes split the input data set of size $N$ in $K$ subsets of equal size $N/K$. We know that tis is the best case. However, we can see that this is a well-know application of Master Theorem. This is well documented in CLRS book. I have the 3rd edition and the details are at section 4.5 and proof is at the next section. I do not remember well the details, but I remember is not too complicated if one expands the recursion and group some terms together. However, what is important for this case is than when $f(N)=O(N)$ - linear time, the resulting time of the algorithm is $T(N) = O(N logN)$. This time is computed for a single input variable, thus, our total time for $P$ variables would be $O(P N logN)$ This time is achievable for tree growing, if all the inputs are initially sorted in $O(P N logN)$, and finding the splitting value takes linear time on this sorted inputs. Here we can apply the on-line variance algorithm, as I mentioned in my previous answer for $L_2 = \frac{1}{N}(y-\hat{y})^2$ . For $L_1 = \frac{1}{N}|y-\hat{y}|$ is even easier to find median. I confess I never tried out some other loss function for trees. Note however that the Master Theorem applies for the best case if the splits are equal in size. The worst case is when the split is very unbalanced. There, one can apply a different case of Master Theorem and the time will become $O(P N^2)$. As a conclusion I assume that ESL authors use the term typically in a way that is used for describing the quick-sort algorithm. Typically quick sort gives $O(N logN)$ running time, having worst case $O(N^2)$, for some specific data setups. I hope it helps.
Literature on the algorithm for optimal splitting in the growing of classification trees
I will give a different answer, since is too much for a comment and it treats a more general approach. So, in ESL, they describe indeed the computation time for a branch-and-bound (more precisely it
Literature on the algorithm for optimal splitting in the growing of classification trees I will give a different answer, since is too much for a comment and it treats a more general approach. So, in ESL, they describe indeed the computation time for a branch-and-bound (more precisely it looks like a divide and conquer to me). We denote with $N$ the number of observations and with $K$ the number of children nodes, when we grow a tree. I assume we do not loose in generality if we consider $K$ to be fixed. Also, we can denote with $f(N)$ the processing time for computing split points at a given node. Thus, we can write recursively the formula for the execution time like: $$T(N) = f(N) + K * T(N/K) $$ we considered here that the child nodes split the input data set of size $N$ in $K$ subsets of equal size $N/K$. We know that tis is the best case. However, we can see that this is a well-know application of Master Theorem. This is well documented in CLRS book. I have the 3rd edition and the details are at section 4.5 and proof is at the next section. I do not remember well the details, but I remember is not too complicated if one expands the recursion and group some terms together. However, what is important for this case is than when $f(N)=O(N)$ - linear time, the resulting time of the algorithm is $T(N) = O(N logN)$. This time is computed for a single input variable, thus, our total time for $P$ variables would be $O(P N logN)$ This time is achievable for tree growing, if all the inputs are initially sorted in $O(P N logN)$, and finding the splitting value takes linear time on this sorted inputs. Here we can apply the on-line variance algorithm, as I mentioned in my previous answer for $L_2 = \frac{1}{N}(y-\hat{y})^2$ . For $L_1 = \frac{1}{N}|y-\hat{y}|$ is even easier to find median. I confess I never tried out some other loss function for trees. Note however that the Master Theorem applies for the best case if the splits are equal in size. The worst case is when the split is very unbalanced. There, one can apply a different case of Master Theorem and the time will become $O(P N^2)$. As a conclusion I assume that ESL authors use the term typically in a way that is used for describing the quick-sort algorithm. Typically quick sort gives $O(N logN)$ running time, having worst case $O(N^2)$, for some specific data setups. I hope it helps.
Literature on the algorithm for optimal splitting in the growing of classification trees I will give a different answer, since is too much for a comment and it treats a more general approach. So, in ESL, they describe indeed the computation time for a branch-and-bound (more precisely it
29,082
Literature on the algorithm for optimal splitting in the growing of classification trees
See my answer from another question here. While I do not have paper references, you can trivially find yourself that for $p$ numeric inputs of length $N$ you have to: iterate over all $p$ inputs - $O(p)$ sort ascending each input - $O(N log(N))$ compute 2 running variances one starting from left and one starting from right in linear time - $O(N)$ The dominant time for each attribute is the sorting time, thus we have $O(p N log(N))$.
Literature on the algorithm for optimal splitting in the growing of classification trees
See my answer from another question here. While I do not have paper references, you can trivially find yourself that for $p$ numeric inputs of length $N$ you have to: iterate over all $p$ inputs - $
Literature on the algorithm for optimal splitting in the growing of classification trees See my answer from another question here. While I do not have paper references, you can trivially find yourself that for $p$ numeric inputs of length $N$ you have to: iterate over all $p$ inputs - $O(p)$ sort ascending each input - $O(N log(N))$ compute 2 running variances one starting from left and one starting from right in linear time - $O(N)$ The dominant time for each attribute is the sorting time, thus we have $O(p N log(N))$.
Literature on the algorithm for optimal splitting in the growing of classification trees See my answer from another question here. While I do not have paper references, you can trivially find yourself that for $p$ numeric inputs of length $N$ you have to: iterate over all $p$ inputs - $
29,083
How to do ROC-analysis in R with a Cox model
@chl has pointed to a specific answer to your question. The 'rms' package's cph function will produce a Somers-D which can be transformed trivially into a c-index. However, Harrell (who introduced the c-index to biostatistical practice) thinks this is unwise as a general strategy for assessing prognostic measures, because it has low power for discrimination among alternatives. Instead of relying on the surgical literature for your methodological guidance, it would be wiser to seek out the accumulated wisdom in Harrell's text, "Regression Modeling Strategies" or Steyerberg's "Clinical Prediction Models".
How to do ROC-analysis in R with a Cox model
@chl has pointed to a specific answer to your question. The 'rms' package's cph function will produce a Somers-D which can be transformed trivially into a c-index. However, Harrell (who introduced the
How to do ROC-analysis in R with a Cox model @chl has pointed to a specific answer to your question. The 'rms' package's cph function will produce a Somers-D which can be transformed trivially into a c-index. However, Harrell (who introduced the c-index to biostatistical practice) thinks this is unwise as a general strategy for assessing prognostic measures, because it has low power for discrimination among alternatives. Instead of relying on the surgical literature for your methodological guidance, it would be wiser to seek out the accumulated wisdom in Harrell's text, "Regression Modeling Strategies" or Steyerberg's "Clinical Prediction Models".
How to do ROC-analysis in R with a Cox model @chl has pointed to a specific answer to your question. The 'rms' package's cph function will produce a Somers-D which can be transformed trivially into a c-index. However, Harrell (who introduced the
29,084
How to do ROC-analysis in R with a Cox model
Depending on your needs, embedding a model inside a bigger model and doing a "chunk" likelihood ratio $\chi^2$ test for the added value of the additional variables will give you a powerful test. My book talks about an index arising from this approach (the "adequacy index").
How to do ROC-analysis in R with a Cox model
Depending on your needs, embedding a model inside a bigger model and doing a "chunk" likelihood ratio $\chi^2$ test for the added value of the additional variables will give you a powerful test. My b
How to do ROC-analysis in R with a Cox model Depending on your needs, embedding a model inside a bigger model and doing a "chunk" likelihood ratio $\chi^2$ test for the added value of the additional variables will give you a powerful test. My book talks about an index arising from this approach (the "adequacy index").
How to do ROC-analysis in R with a Cox model Depending on your needs, embedding a model inside a bigger model and doing a "chunk" likelihood ratio $\chi^2$ test for the added value of the additional variables will give you a powerful test. My b
29,085
Comparison of time series sets
Fixed-effects ANOVA (or its linear regression equivalent) provides a powerful family of methods to analyze these data. To illustrate, here is a dataset consistent with the plots of mean HC per evening (one plot per color): | Color Day | B G R | Total -------+---------------------------------+---------- 1 | 117 176 91 | 384 2 | 208 193 156 | 557 3 | 287 218 257 | 762 4 | 256 267 271 | 794 5 | 169 143 163 | 475 6 | 166 163 163 | 492 7 | 237 214 279 | 730 8 | 588 455 457 | 1,500 9 | 443 428 397 | 1,268 10 | 464 408 441 | 1,313 11 | 470 473 464 | 1,407 12 | 171 185 196 | 552 -------+---------------------------------+---------- Total | 3,576 3,323 3,335 | 10,234 ANOVA of count against day and color produces this table: Number of obs = 36 R-squared = 0.9656 Root MSE = 31.301 Adj R-squared = 0.9454 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 605936.611 13 46610.5085 47.57 0.0000 | day | 602541.222 11 54776.4747 55.91 0.0000 colorcode | 3395.38889 2 1697.69444 1.73 0.2001 | Residual | 21554.6111 22 979.755051 -----------+---------------------------------------------------- Total | 627491.222 35 17928.3206 The model p-value of 0.0000 shows the fit is highly significant. The day p-value of 0.0000 is also highly significant: you can detect day to day changes. However, the color (semester) p-value of 0.2001 should not be considered significant: you cannot detect a systematic difference among the three semesters, even after controlling for day to day variation. Tukey's HSD ("honest significant difference") test identifies the following significant changes (among others) in day-to-day means (regardless of semester) at the 0.05 level: 1 increases to 2, 3 3 and 4 decrease to 5 5, 6, and 7 increase to 8,9,10,11 8, 9, 10, and 11 decrease to 12. This confirms what the eye can see in the graphs. Because the graphs jump around quite a bit, there's no way to detect day-to-day correlations (serial correlation), which is the whole point of time series analysis. In other words, don't bother with time series techniques: there's not enough data here for them to provide any greater insight. One should always wonder how much to believe the results of any statistical analysis. Various diagnostics for heteroscedasticity (such as the Breusch-Pagan test) don't show anything untoward. The residuals don't look very normal--they clump into some groups--so all the p-values have to be taken with a grain of salt. Nevertheless, they appear to provide reasonable guidance and help quantify the sense of the data we can get from looking at the graphs. You can carry out a parallel analysis on the daily minima or on the daily maxima. Make sure to start with a similar plot as a guide and to check the statistical output.
Comparison of time series sets
Fixed-effects ANOVA (or its linear regression equivalent) provides a powerful family of methods to analyze these data. To illustrate, here is a dataset consistent with the plots of mean HC per evenin
Comparison of time series sets Fixed-effects ANOVA (or its linear regression equivalent) provides a powerful family of methods to analyze these data. To illustrate, here is a dataset consistent with the plots of mean HC per evening (one plot per color): | Color Day | B G R | Total -------+---------------------------------+---------- 1 | 117 176 91 | 384 2 | 208 193 156 | 557 3 | 287 218 257 | 762 4 | 256 267 271 | 794 5 | 169 143 163 | 475 6 | 166 163 163 | 492 7 | 237 214 279 | 730 8 | 588 455 457 | 1,500 9 | 443 428 397 | 1,268 10 | 464 408 441 | 1,313 11 | 470 473 464 | 1,407 12 | 171 185 196 | 552 -------+---------------------------------+---------- Total | 3,576 3,323 3,335 | 10,234 ANOVA of count against day and color produces this table: Number of obs = 36 R-squared = 0.9656 Root MSE = 31.301 Adj R-squared = 0.9454 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 605936.611 13 46610.5085 47.57 0.0000 | day | 602541.222 11 54776.4747 55.91 0.0000 colorcode | 3395.38889 2 1697.69444 1.73 0.2001 | Residual | 21554.6111 22 979.755051 -----------+---------------------------------------------------- Total | 627491.222 35 17928.3206 The model p-value of 0.0000 shows the fit is highly significant. The day p-value of 0.0000 is also highly significant: you can detect day to day changes. However, the color (semester) p-value of 0.2001 should not be considered significant: you cannot detect a systematic difference among the three semesters, even after controlling for day to day variation. Tukey's HSD ("honest significant difference") test identifies the following significant changes (among others) in day-to-day means (regardless of semester) at the 0.05 level: 1 increases to 2, 3 3 and 4 decrease to 5 5, 6, and 7 increase to 8,9,10,11 8, 9, 10, and 11 decrease to 12. This confirms what the eye can see in the graphs. Because the graphs jump around quite a bit, there's no way to detect day-to-day correlations (serial correlation), which is the whole point of time series analysis. In other words, don't bother with time series techniques: there's not enough data here for them to provide any greater insight. One should always wonder how much to believe the results of any statistical analysis. Various diagnostics for heteroscedasticity (such as the Breusch-Pagan test) don't show anything untoward. The residuals don't look very normal--they clump into some groups--so all the p-values have to be taken with a grain of salt. Nevertheless, they appear to provide reasonable guidance and help quantify the sense of the data we can get from looking at the graphs. You can carry out a parallel analysis on the daily minima or on the daily maxima. Make sure to start with a similar plot as a guide and to check the statistical output.
Comparison of time series sets Fixed-effects ANOVA (or its linear regression equivalent) provides a powerful family of methods to analyze these data. To illustrate, here is a dataset consistent with the plots of mean HC per evenin
29,086
Comparison of time series sets
Sarah, Take your 36 numbers (12 values per cycle ; 3 cycles ) and construct a regression model with 11 indicators reflecting possible week-of-the-semester effect and then identify any necessary Intervention Series ( Pulses, Level Shifts ) necessary to render the mean of the residuals to be 0.0 everywhere or at least not statistically significantly different from 0.0. For example if you identify a level shift at period 13 this might be suggest a statistically significant difference between the mean of the first semester i.e. the first 12 values) versus the mean of the last two semesters (last 24 values ). You might be able to draw inference or test the hypothesis of no week of the semester effect. A good time series package might be useful to you in this regard. Failing that you might need to find somebody to provide help in this analytical arena.
Comparison of time series sets
Sarah, Take your 36 numbers (12 values per cycle ; 3 cycles ) and construct a regression model with 11 indicators reflecting possible week-of-the-semester effect and then identify any necessary Interv
Comparison of time series sets Sarah, Take your 36 numbers (12 values per cycle ; 3 cycles ) and construct a regression model with 11 indicators reflecting possible week-of-the-semester effect and then identify any necessary Intervention Series ( Pulses, Level Shifts ) necessary to render the mean of the residuals to be 0.0 everywhere or at least not statistically significantly different from 0.0. For example if you identify a level shift at period 13 this might be suggest a statistically significant difference between the mean of the first semester i.e. the first 12 values) versus the mean of the last two semesters (last 24 values ). You might be able to draw inference or test the hypothesis of no week of the semester effect. A good time series package might be useful to you in this regard. Failing that you might need to find somebody to provide help in this analytical arena.
Comparison of time series sets Sarah, Take your 36 numbers (12 values per cycle ; 3 cycles ) and construct a regression model with 11 indicators reflecting possible week-of-the-semester effect and then identify any necessary Interv
29,087
Good literature about cross validation
This website has great information. In particular, the fourth section of this PDF is what you're looking for
Good literature about cross validation
This website has great information. In particular, the fourth section of this PDF is what you're looking for
Good literature about cross validation This website has great information. In particular, the fourth section of this PDF is what you're looking for
Good literature about cross validation This website has great information. In particular, the fourth section of this PDF is what you're looking for
29,088
Good literature about cross validation
If cross-validation is to be used for model/feature selection, it is worth bearing in mind that it is possible to over-fit the cross-validation statistic and end up with a model that performs poorly, and the optimised cross-validation statistic can be a severly optimistic performance estimate. The effects of this can be surprisingly large. See Ambroise and McLachlan for an example of this in a feature selection setting and Cawley and Talbot for an example in a model selection setting.
Good literature about cross validation
If cross-validation is to be used for model/feature selection, it is worth bearing in mind that it is possible to over-fit the cross-validation statistic and end up with a model that performs poorly,
Good literature about cross validation If cross-validation is to be used for model/feature selection, it is worth bearing in mind that it is possible to over-fit the cross-validation statistic and end up with a model that performs poorly, and the optimised cross-validation statistic can be a severly optimistic performance estimate. The effects of this can be surprisingly large. See Ambroise and McLachlan for an example of this in a feature selection setting and Cawley and Talbot for an example in a model selection setting.
Good literature about cross validation If cross-validation is to be used for model/feature selection, it is worth bearing in mind that it is possible to over-fit the cross-validation statistic and end up with a model that performs poorly,
29,089
Good literature about cross validation
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I would also recommend Cross-Validation by Payam Refaeilzadeh, Lei Tang, and Huan Liu.
Good literature about cross validation
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Good literature about cross validation Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I would also recommend Cross-Validation by Payam Refaeilzadeh, Lei Tang, and Huan Liu.
Good literature about cross validation Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
29,090
Model comparison between an ARIMA model and a regression model
If we exclude the ARIMAX models, which are ARIMA with regressors, ARIMA and regression models are models with different approaches. ARIMA tries to model the variable only with information about the past values of the same variable. Regression models on the other hand model the variable with the values of other variables. Since these approaches are different, it is natural then that models are not directly comparable. On the other hand since both models try to model one variable, they both produce the modelled values of this variable. So the question of model comparison is identical to comparison of modelled values to true values. For more information how to do that the seventh chapter of Elements of Statistical Learning by Hastie et al. is an enlightening read. Update: Note that I do not advocate comparing only in sample fit, just that when models are different the natural way to compare models is to compare their outputs, disregarding how they were obtained.
Model comparison between an ARIMA model and a regression model
If we exclude the ARIMAX models, which are ARIMA with regressors, ARIMA and regression models are models with different approaches. ARIMA tries to model the variable only with information about the pa
Model comparison between an ARIMA model and a regression model If we exclude the ARIMAX models, which are ARIMA with regressors, ARIMA and regression models are models with different approaches. ARIMA tries to model the variable only with information about the past values of the same variable. Regression models on the other hand model the variable with the values of other variables. Since these approaches are different, it is natural then that models are not directly comparable. On the other hand since both models try to model one variable, they both produce the modelled values of this variable. So the question of model comparison is identical to comparison of modelled values to true values. For more information how to do that the seventh chapter of Elements of Statistical Learning by Hastie et al. is an enlightening read. Update: Note that I do not advocate comparing only in sample fit, just that when models are different the natural way to compare models is to compare their outputs, disregarding how they were obtained.
Model comparison between an ARIMA model and a regression model If we exclude the ARIMAX models, which are ARIMA with regressors, ARIMA and regression models are models with different approaches. ARIMA tries to model the variable only with information about the pa
29,091
Model comparison between an ARIMA model and a regression model
You could use the MSE/AIC/BIC of the arima model and compare it to the MSE/AIC/BIC of the regression model. Just make sure that the number of fitted values are the same otherwise you might be making a mistake. For example if the ARIMA model has a lag structure of say sp+p ( a seasonal difference of order sp and an autoregressive structure of order p , you lose the first sp+p datapoints and only NOB-SP-P values are actually fit. If the regression model has no lags then you have NOB fitted points or less depending upon your specification of the lagged values for the inputs. So one has to realize that the MSE's may not be on the same historical actual values. One approach would be to compute the MSE of the regression model on the last NOB-SP-P values to put the models on an equal footing. You might want to GOOGLE "regression vs box-jenkins" and get some pointers on this and more. In closing one would normally never just fit a regression model with time series as their may be information in the lags of the causals and the lags of the dependent variable justifying the STEP-UP from regression to a Transfer Function Model a.k.a ARMAX Model . If you didn't STEP-UP then one one or more of the Gauusian Assumptions would be voided making your F/T tests meaningless and irrevelant. Furthermore there may be violations of the constancy of the error term requiring the incorporation of level shifts/local time trends and either pulse or seasonal pulse variable to render the error process having a "mean of 0.0 everywhere"
Model comparison between an ARIMA model and a regression model
You could use the MSE/AIC/BIC of the arima model and compare it to the MSE/AIC/BIC of the regression model. Just make sure that the number of fitted values are the same otherwise you might be making
Model comparison between an ARIMA model and a regression model You could use the MSE/AIC/BIC of the arima model and compare it to the MSE/AIC/BIC of the regression model. Just make sure that the number of fitted values are the same otherwise you might be making a mistake. For example if the ARIMA model has a lag structure of say sp+p ( a seasonal difference of order sp and an autoregressive structure of order p , you lose the first sp+p datapoints and only NOB-SP-P values are actually fit. If the regression model has no lags then you have NOB fitted points or less depending upon your specification of the lagged values for the inputs. So one has to realize that the MSE's may not be on the same historical actual values. One approach would be to compute the MSE of the regression model on the last NOB-SP-P values to put the models on an equal footing. You might want to GOOGLE "regression vs box-jenkins" and get some pointers on this and more. In closing one would normally never just fit a regression model with time series as their may be information in the lags of the causals and the lags of the dependent variable justifying the STEP-UP from regression to a Transfer Function Model a.k.a ARMAX Model . If you didn't STEP-UP then one one or more of the Gauusian Assumptions would be voided making your F/T tests meaningless and irrevelant. Furthermore there may be violations of the constancy of the error term requiring the incorporation of level shifts/local time trends and either pulse or seasonal pulse variable to render the error process having a "mean of 0.0 everywhere"
Model comparison between an ARIMA model and a regression model You could use the MSE/AIC/BIC of the arima model and compare it to the MSE/AIC/BIC of the regression model. Just make sure that the number of fitted values are the same otherwise you might be making
29,092
Model comparison between an ARIMA model and a regression model
Cross validation would probably be good here. To do this you split your data set into 2 parts. You use the first part to fit both models, and then use the fitted model to predict the second part. This can be justified as an approximation to a fully Bayesian approach to model selection. We have the likelihood of a model $M_{i}$ $$p(d_{1}d_{2}...d_{N}|M_{i}I)=p(d_{1}|M_{i}I)\times p(d_{2}|d_{1}M_{i}I)\times p(d_{3}|d_{1}d_{2}M_{i}I)\times..$$ $$..\times p(d_{N}|d_{1}d_{2}...d_{N-1}M_{i}I)$$ Which can be seen heuristically as sequence of predictions, and then of learning from mistakes. You predict the first data point with no training. Then you predict the second data point after learning about the model with the first one. Then you predict the 3rd data point after using the first two to learn about the model, and so on. Now if you have a sufficiently large data set, then the parameters of the model will become well determined beyond a certain amount of data, and we will have, for some value $k$: $$p(d_{k+2}|d_{1}....d_{k}d_{k+1}M_{i}I)\approx p(d_{k+2}|d_{1}....d_{k}M_{i}I)$$ The model can't "learn" any more about the parameters, and is basically just predicting based on the first $k$ observations. So I would choose $k$ (the size of the first group) to be large enough so that you can accurately fit the model, $20$-$30$ data points per parameter is probably enough. You also want to choose $k$ large enough so that the dependence in the $d_{k+1}...d_{N}$ which is being ignored does not make the approximation useless. Then I would simply evaluate the likelihoods of each prediction, and take their ratio, interpreted as a likelihood ratio. If the ratio is about $1$, then neither model is particularly better than the other. If it is far away from $1$ then this indicates one of the models is outperforming the other. a ratio of under 5 is weak, 10 is strong, 20 very strong, and 100, decisive (corresponding reciprocal for small numbers).
Model comparison between an ARIMA model and a regression model
Cross validation would probably be good here. To do this you split your data set into 2 parts. You use the first part to fit both models, and then use the fitted model to predict the second part. T
Model comparison between an ARIMA model and a regression model Cross validation would probably be good here. To do this you split your data set into 2 parts. You use the first part to fit both models, and then use the fitted model to predict the second part. This can be justified as an approximation to a fully Bayesian approach to model selection. We have the likelihood of a model $M_{i}$ $$p(d_{1}d_{2}...d_{N}|M_{i}I)=p(d_{1}|M_{i}I)\times p(d_{2}|d_{1}M_{i}I)\times p(d_{3}|d_{1}d_{2}M_{i}I)\times..$$ $$..\times p(d_{N}|d_{1}d_{2}...d_{N-1}M_{i}I)$$ Which can be seen heuristically as sequence of predictions, and then of learning from mistakes. You predict the first data point with no training. Then you predict the second data point after learning about the model with the first one. Then you predict the 3rd data point after using the first two to learn about the model, and so on. Now if you have a sufficiently large data set, then the parameters of the model will become well determined beyond a certain amount of data, and we will have, for some value $k$: $$p(d_{k+2}|d_{1}....d_{k}d_{k+1}M_{i}I)\approx p(d_{k+2}|d_{1}....d_{k}M_{i}I)$$ The model can't "learn" any more about the parameters, and is basically just predicting based on the first $k$ observations. So I would choose $k$ (the size of the first group) to be large enough so that you can accurately fit the model, $20$-$30$ data points per parameter is probably enough. You also want to choose $k$ large enough so that the dependence in the $d_{k+1}...d_{N}$ which is being ignored does not make the approximation useless. Then I would simply evaluate the likelihoods of each prediction, and take their ratio, interpreted as a likelihood ratio. If the ratio is about $1$, then neither model is particularly better than the other. If it is far away from $1$ then this indicates one of the models is outperforming the other. a ratio of under 5 is weak, 10 is strong, 20 very strong, and 100, decisive (corresponding reciprocal for small numbers).
Model comparison between an ARIMA model and a regression model Cross validation would probably be good here. To do this you split your data set into 2 parts. You use the first part to fit both models, and then use the fitted model to predict the second part. T
29,093
Justification for using geometric weights in linear regression
"Linearly related" usually means $$y_t = a x_t + b + \varepsilon_t$$ for constant $a$, $b$ and iid random errors $\varepsilon_t$, $t=0,1,\ldots,T$. One reason one would make an exponentially weighted OLS estimate is the suspicion that $a$ and $b$ might themselves be (slowly) varying with time, too. Thus we really think the correct model is $$y_t = \alpha(t) x_t + \beta(t) + \varepsilon_t$$ for unknown functions $\alpha(t)$ and $\beta(t)$ which vary slowly (if at all) over time and we're interested in estimating their current values, $a = \alpha_T$ and $b = \beta_T$. Let's assume these functions are smooth, so we can apply Taylor's Theorem. This asserts that $$\alpha(t) = \alpha(T) + \alpha'(t_{\alpha,t})(t-T)$$ for some $t_{\alpha,t}, 0 \le t_{\alpha,t} \lt T$, and similarly for $\beta(t)$. We think of $a$ and $b$ as being the most recent values, $\alpha_T$ and $\beta_T$, respectively. Use this to re-express the residuals: $$y_t - (a x_t + b) = \alpha'(t_{\alpha,t})(t-T)x_t + \beta'(t_{\beta,t})(t-T) + \varepsilon_t\text{.}$$ Now a lot of hand-waving needs to occur. We will consider the entire right hand side to be random. Its variance is that of $\varepsilon_t$ plus $x_t^2(t-T)^2$ times the variance of $\alpha'(t_{\alpha,t})$ plus $(t-T)^2$ times the variance of $\beta'(t_{\beta,t})$. Those two variances are completely unknown, but (abracadabra) let's think of them as resulting from some kind of (stochastic) process in which possibly systematic (not random, but still unknown) "errors" or "variations" are accumulated from one time to the other. This would suggest an exponential change in those variances over time. Now just simplify the explicit (but essentially useless) expression for the right hand side, and absorb the quadratic terms $(t-T)^2$ into the exponential (since we're waving our hands so wildly about anyway), to obtain $$y_t - (a x_t + b) = \delta_t$$ with the variance of $\delta_t$ equal to $\exp(\kappa(t-T))$ for some constant $\kappa$. Ignoring possible temporal correlations among the $\delta_t$ and assuming they have Normal distributions gives a log likelihood for the data proportional to $$\sum_{t=0}^{T} k^{-t} (y_{T-t}- a x_{T-t}-b)^2$$ (plus an irrelevant constant depending only on $k$) with $k = \exp{\kappa}$. The exponentially weighted OLS procedure therefore maximizes the likelihood, assuming we know the value of $k$ (kind of like a profile likelihood procedure). Although this entire derivation clearly is fanciful, it does show how, and approximately to what degree, the exponential weighting attempts to cope with possible changes in the linear parameters over time. It relates the parameter $k$ to the temporal rate of change of those parameters.
Justification for using geometric weights in linear regression
"Linearly related" usually means $$y_t = a x_t + b + \varepsilon_t$$ for constant $a$, $b$ and iid random errors $\varepsilon_t$, $t=0,1,\ldots,T$. One reason one would make an exponentially weighte
Justification for using geometric weights in linear regression "Linearly related" usually means $$y_t = a x_t + b + \varepsilon_t$$ for constant $a$, $b$ and iid random errors $\varepsilon_t$, $t=0,1,\ldots,T$. One reason one would make an exponentially weighted OLS estimate is the suspicion that $a$ and $b$ might themselves be (slowly) varying with time, too. Thus we really think the correct model is $$y_t = \alpha(t) x_t + \beta(t) + \varepsilon_t$$ for unknown functions $\alpha(t)$ and $\beta(t)$ which vary slowly (if at all) over time and we're interested in estimating their current values, $a = \alpha_T$ and $b = \beta_T$. Let's assume these functions are smooth, so we can apply Taylor's Theorem. This asserts that $$\alpha(t) = \alpha(T) + \alpha'(t_{\alpha,t})(t-T)$$ for some $t_{\alpha,t}, 0 \le t_{\alpha,t} \lt T$, and similarly for $\beta(t)$. We think of $a$ and $b$ as being the most recent values, $\alpha_T$ and $\beta_T$, respectively. Use this to re-express the residuals: $$y_t - (a x_t + b) = \alpha'(t_{\alpha,t})(t-T)x_t + \beta'(t_{\beta,t})(t-T) + \varepsilon_t\text{.}$$ Now a lot of hand-waving needs to occur. We will consider the entire right hand side to be random. Its variance is that of $\varepsilon_t$ plus $x_t^2(t-T)^2$ times the variance of $\alpha'(t_{\alpha,t})$ plus $(t-T)^2$ times the variance of $\beta'(t_{\beta,t})$. Those two variances are completely unknown, but (abracadabra) let's think of them as resulting from some kind of (stochastic) process in which possibly systematic (not random, but still unknown) "errors" or "variations" are accumulated from one time to the other. This would suggest an exponential change in those variances over time. Now just simplify the explicit (but essentially useless) expression for the right hand side, and absorb the quadratic terms $(t-T)^2$ into the exponential (since we're waving our hands so wildly about anyway), to obtain $$y_t - (a x_t + b) = \delta_t$$ with the variance of $\delta_t$ equal to $\exp(\kappa(t-T))$ for some constant $\kappa$. Ignoring possible temporal correlations among the $\delta_t$ and assuming they have Normal distributions gives a log likelihood for the data proportional to $$\sum_{t=0}^{T} k^{-t} (y_{T-t}- a x_{T-t}-b)^2$$ (plus an irrelevant constant depending only on $k$) with $k = \exp{\kappa}$. The exponentially weighted OLS procedure therefore maximizes the likelihood, assuming we know the value of $k$ (kind of like a profile likelihood procedure). Although this entire derivation clearly is fanciful, it does show how, and approximately to what degree, the exponential weighting attempts to cope with possible changes in the linear parameters over time. It relates the parameter $k$ to the temporal rate of change of those parameters.
Justification for using geometric weights in linear regression "Linearly related" usually means $$y_t = a x_t + b + \varepsilon_t$$ for constant $a$, $b$ and iid random errors $\varepsilon_t$, $t=0,1,\ldots,T$. One reason one would make an exponentially weighte
29,094
Justification for using geometric weights in linear regression
I think in that you actually mean $k^{t}$ as your weight, or that $k>1$. If $0<k<1$ and we take $k^{-t}$ as the weight then $k^{-\infty}=\infty$. So this actually weights the present observation the least. For example, if we take $k=0.5$ then $k^{0}=1,\;k^{-1}=2,\;k^{-2}=4,\dots,k^{-20}\approx 10^{6}$, and so on. This is just stating something that you know about the how the variance changes with each observation (it gets bigger as you mover further backward in time from time $T$): $$(y_{T-t}|x_{T-t},a,b,k,s) \sim Normal(ax_{T-t}+b,s^{2}k^{-t})$$ Denoting $Y\equiv\{y_{T},y_{T-1},\dots,y_{1}\}$ and $X\equiv\{x_{T},x_{T-1},\dots,x_{1}\}$ we have a joint log-likelihood of: $$\log\left[p(Y|X,a,b,k,s)\right]=-\frac{1}{2}\left(T\log(2\pi s^{2} k^{-t})+\sum_{t=0}^{T-1}\frac{(y_{T-t}-ax_{T-t}-b)^{2}}{s^{2}k^{-t}}\right)$$ So in order to get the maximum likelihood estimates of $a$ and $b$ you have the following objective function: $$\sum_{t=0}^{T-1}k^{t}(y_{T-t}-ax_{T-t}-b)^{2}$$ Which is the one you seek
Justification for using geometric weights in linear regression
I think in that you actually mean $k^{t}$ as your weight, or that $k>1$. If $0<k<1$ and we take $k^{-t}$ as the weight then $k^{-\infty}=\infty$. So this actually weights the present observation the
Justification for using geometric weights in linear regression I think in that you actually mean $k^{t}$ as your weight, or that $k>1$. If $0<k<1$ and we take $k^{-t}$ as the weight then $k^{-\infty}=\infty$. So this actually weights the present observation the least. For example, if we take $k=0.5$ then $k^{0}=1,\;k^{-1}=2,\;k^{-2}=4,\dots,k^{-20}\approx 10^{6}$, and so on. This is just stating something that you know about the how the variance changes with each observation (it gets bigger as you mover further backward in time from time $T$): $$(y_{T-t}|x_{T-t},a,b,k,s) \sim Normal(ax_{T-t}+b,s^{2}k^{-t})$$ Denoting $Y\equiv\{y_{T},y_{T-1},\dots,y_{1}\}$ and $X\equiv\{x_{T},x_{T-1},\dots,x_{1}\}$ we have a joint log-likelihood of: $$\log\left[p(Y|X,a,b,k,s)\right]=-\frac{1}{2}\left(T\log(2\pi s^{2} k^{-t})+\sum_{t=0}^{T-1}\frac{(y_{T-t}-ax_{T-t}-b)^{2}}{s^{2}k^{-t}}\right)$$ So in order to get the maximum likelihood estimates of $a$ and $b$ you have the following objective function: $$\sum_{t=0}^{T-1}k^{t}(y_{T-t}-ax_{T-t}-b)^{2}$$ Which is the one you seek
Justification for using geometric weights in linear regression I think in that you actually mean $k^{t}$ as your weight, or that $k>1$. If $0<k<1$ and we take $k^{-t}$ as the weight then $k^{-\infty}=\infty$. So this actually weights the present observation the
29,095
Space-efficient clustering
K-Means and Mean-Shift use the raw sample descriptors (no need to pre-compute an affinity matrix). Otherwise, for spectral clustering or power iteration clustering, you can use a sparse matrix representation (e.g. Compressed Sparse Rows) of the k-nearest-neighbours affinity matrix (for some distance or affinity metric). If k is small (let say 5 or 10). You will get a very space efficient representation (2 * n_samples * k * 8 bytes for double precision floating point values).
Space-efficient clustering
K-Means and Mean-Shift use the raw sample descriptors (no need to pre-compute an affinity matrix). Otherwise, for spectral clustering or power iteration clustering, you can use a sparse matrix represe
Space-efficient clustering K-Means and Mean-Shift use the raw sample descriptors (no need to pre-compute an affinity matrix). Otherwise, for spectral clustering or power iteration clustering, you can use a sparse matrix representation (e.g. Compressed Sparse Rows) of the k-nearest-neighbours affinity matrix (for some distance or affinity metric). If k is small (let say 5 or 10). You will get a very space efficient representation (2 * n_samples * k * 8 bytes for double precision floating point values).
Space-efficient clustering K-Means and Mean-Shift use the raw sample descriptors (no need to pre-compute an affinity matrix). Otherwise, for spectral clustering or power iteration clustering, you can use a sparse matrix represe
29,096
Space-efficient clustering
Some clustering algorithms can use spatial index structures. This allows for example DBSCAN and OPTICS to run in $O(n\log n)$ time (as long as the index allows $O(\log n)$ queries). Obviously, an algorithm that runs in this complexity does not build a $O(n^2)$ distance matrix. For some algorithms, such as hierarchical clustering with single-linkage and complete-linkage, there are optimized algorithms available (SLINK, CLINK). It's just that most people use whatever they can get and whatever is easy to implement. And hierarchical clustering is easy to implement naively, using $n$ iterations over a $n^2$ distance matrix (resulting in an $O(n^3)$ algorithm ...). I'm not aware of a complete list comparing clustering algorithms. There probably are 100+ clustering algorithms, after all. There are at least a dozen k-means variants, for example. Plus, there is run-time complexity as well as memory complexity; there is average-case and worst-case. There are huge implementation differences (e.g. single-link mentioned above; and DBSCAN implementations that do not use an index, and thus are in $O(n^2)$, and while they do not need to store the full $n\times n$ distance matrix, they then still need to compute all pairwise distances). Plus there are tons of parameters. For k-means, $k$ is critical. For pretty much any algorithm, the distance function make a huge difference (any many implementations only allow Euclidean distance ...). And once you get to expensive distance functions (beyond trivial stuff like Euclidean), the number of distance computations may quickly be the main part. So you'd then need to differentiate between the number of operations in total, and the number of distance computations needed. So an algorithm that is in $O(n^2)$ operations but only $O(n)$ distance computations may easily outperform an algorithm that is $O(n \log n)$ in both, when the distance functions are really expensive (say, the distance function itself is $O(n)$).
Space-efficient clustering
Some clustering algorithms can use spatial index structures. This allows for example DBSCAN and OPTICS to run in $O(n\log n)$ time (as long as the index allows $O(\log n)$ queries). Obviously, an algo
Space-efficient clustering Some clustering algorithms can use spatial index structures. This allows for example DBSCAN and OPTICS to run in $O(n\log n)$ time (as long as the index allows $O(\log n)$ queries). Obviously, an algorithm that runs in this complexity does not build a $O(n^2)$ distance matrix. For some algorithms, such as hierarchical clustering with single-linkage and complete-linkage, there are optimized algorithms available (SLINK, CLINK). It's just that most people use whatever they can get and whatever is easy to implement. And hierarchical clustering is easy to implement naively, using $n$ iterations over a $n^2$ distance matrix (resulting in an $O(n^3)$ algorithm ...). I'm not aware of a complete list comparing clustering algorithms. There probably are 100+ clustering algorithms, after all. There are at least a dozen k-means variants, for example. Plus, there is run-time complexity as well as memory complexity; there is average-case and worst-case. There are huge implementation differences (e.g. single-link mentioned above; and DBSCAN implementations that do not use an index, and thus are in $O(n^2)$, and while they do not need to store the full $n\times n$ distance matrix, they then still need to compute all pairwise distances). Plus there are tons of parameters. For k-means, $k$ is critical. For pretty much any algorithm, the distance function make a huge difference (any many implementations only allow Euclidean distance ...). And once you get to expensive distance functions (beyond trivial stuff like Euclidean), the number of distance computations may quickly be the main part. So you'd then need to differentiate between the number of operations in total, and the number of distance computations needed. So an algorithm that is in $O(n^2)$ operations but only $O(n)$ distance computations may easily outperform an algorithm that is $O(n \log n)$ in both, when the distance functions are really expensive (say, the distance function itself is $O(n)$).
Space-efficient clustering Some clustering algorithms can use spatial index structures. This allows for example DBSCAN and OPTICS to run in $O(n\log n)$ time (as long as the index allows $O(\log n)$ queries). Obviously, an algo
29,097
Space-efficient clustering
Good question. A straw man method for say 3 nearest neighbors is to sample Nsample neighbors of each data point, keeping the nearest 3. While trivial, running this for a few values of Nsample will give you some idea of signal / noise ratio, near / background noise, easily plotted for your data. An additional trick is to then check neighbors of neighbors, to see if any of those ar nearer than direct neighbors. Also, if the input data is already well-shuffled, sample in blocks, otherwise cache will thrash. (Added): see fastcluster in R and I believe in SciPy v0.11. For text, see google-all-pairs-similarity-search. Repeat, "An appropriate dissimilarity measure is far more important in obtaining success with clustering than choice of clustering algorithm" — choosing-clustering-method.
Space-efficient clustering
Good question. A straw man method for say 3 nearest neighbors is to sample Nsample neighbors of each data point, keeping the nearest 3. While trivial, running this for a few values of Nsample will gi
Space-efficient clustering Good question. A straw man method for say 3 nearest neighbors is to sample Nsample neighbors of each data point, keeping the nearest 3. While trivial, running this for a few values of Nsample will give you some idea of signal / noise ratio, near / background noise, easily plotted for your data. An additional trick is to then check neighbors of neighbors, to see if any of those ar nearer than direct neighbors. Also, if the input data is already well-shuffled, sample in blocks, otherwise cache will thrash. (Added): see fastcluster in R and I believe in SciPy v0.11. For text, see google-all-pairs-similarity-search. Repeat, "An appropriate dissimilarity measure is far more important in obtaining success with clustering than choice of clustering algorithm" — choosing-clustering-method.
Space-efficient clustering Good question. A straw man method for say 3 nearest neighbors is to sample Nsample neighbors of each data point, keeping the nearest 3. While trivial, running this for a few values of Nsample will gi
29,098
What is a good introduction to statistical hypothesis testing for computer scientists?
http://greenteapress.com/thinkstats/ This seems like it would be useful for you. Full disclosure: I have not read it, but I am working my way through the Think Like a Computer Scientist in Java, and am finding that extremely useful.
What is a good introduction to statistical hypothesis testing for computer scientists?
http://greenteapress.com/thinkstats/ This seems like it would be useful for you. Full disclosure: I have not read it, but I am working my way through the Think Like a Computer Scientist in Java, and a
What is a good introduction to statistical hypothesis testing for computer scientists? http://greenteapress.com/thinkstats/ This seems like it would be useful for you. Full disclosure: I have not read it, but I am working my way through the Think Like a Computer Scientist in Java, and am finding that extremely useful.
What is a good introduction to statistical hypothesis testing for computer scientists? http://greenteapress.com/thinkstats/ This seems like it would be useful for you. Full disclosure: I have not read it, but I am working my way through the Think Like a Computer Scientist in Java, and a
29,099
What is a good introduction to statistical hypothesis testing for computer scientists?
I have found a decent introduction in "STATISTICS: AN INTRODUCTION USING R" by Michael J. Crawley. There is a site where you can download pdfs http://www.bio.ic.ac.uk/research/crawley/statistics/exercises.htm in particular http://www.bio.ic.ac.uk/research/crawley/statistics/exercises/R3Statistics.pdf explains t test and Wilcoxon test. But I am still looking for a better introduction...
What is a good introduction to statistical hypothesis testing for computer scientists?
I have found a decent introduction in "STATISTICS: AN INTRODUCTION USING R" by Michael J. Crawley. There is a site where you can download pdfs http://www.bio.ic.ac.uk/research/crawley/statistics/exer
What is a good introduction to statistical hypothesis testing for computer scientists? I have found a decent introduction in "STATISTICS: AN INTRODUCTION USING R" by Michael J. Crawley. There is a site where you can download pdfs http://www.bio.ic.ac.uk/research/crawley/statistics/exercises.htm in particular http://www.bio.ic.ac.uk/research/crawley/statistics/exercises/R3Statistics.pdf explains t test and Wilcoxon test. But I am still looking for a better introduction...
What is a good introduction to statistical hypothesis testing for computer scientists? I have found a decent introduction in "STATISTICS: AN INTRODUCTION USING R" by Michael J. Crawley. There is a site where you can download pdfs http://www.bio.ic.ac.uk/research/crawley/statistics/exer
29,100
What is a good introduction to statistical hypothesis testing for computer scientists?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. By far the best I think: Design of Experiments, Statistical Principles of Research Design and Analysis, 2nd Ed, by Robert O. Kuehl
What is a good introduction to statistical hypothesis testing for computer scientists?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
What is a good introduction to statistical hypothesis testing for computer scientists? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. By far the best I think: Design of Experiments, Statistical Principles of Research Design and Analysis, 2nd Ed, by Robert O. Kuehl
What is a good introduction to statistical hypothesis testing for computer scientists? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.