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
46,501
Multi-armed bandit vs AB testing
The Difference I'm going to assume you are interested in this topic from a website design perspective. In an A/B test, you choose layout A half the time and layout B the other half. You record how much revenue is collected under each layout for $n$ visitors. Then you do a statistical test to determine if layout A or layout B had a statistically significantly higher revenue, and then deploy that layout. In bandit language, you had pure exploration period (trying out each option and seeing the revenue) for $n$ time steps and then a pure exploitation period afterwards (deploying the layout estimated to be the best). In a multi-armed bandit setting, the decision of when to show layout A or layout B is chosen by the algorithm. Instead of a pure exploration period followed by a pure exploitation period, you can continually balance exploration and exploitation. The algorithm will continually adjust its display percentages based on: An estimate for how much revenue the layout will get, based on the data collected so far. The higher the estimate the more the algorithm wants to display that layout. How confident we are in that estimate, based on how much data we've collected so far and its variability. The less confidence in the estimate, the more the algorithm wants to display that layout in order to collect more data about it. So the main difference comes down to: A/B tests tries out each option a constant % of the time, then at some point it's decided which one is best and that option is deployed Bandit algorithms can continually adjust how often to display each option based on how they're performing. How exactly this works is dependent on the bandit algorithm that you choose. Something to take note of is that multi-armed bandit is the name of the problem of sequential decision making under uncertainty and there are various algorithms that provide provably good solutions to this problem. A/B testing is actually the same thing as the explore-then-commit bandit algorithm. It doesn't necessarily make sense to look at "A/B Test vs. Multi-armed Bandits" since A/B tests are also a multi-armed bandit algorithm. Which one to choose? I don't think there's a good answer to this. Since A/B tests are a bandit algorithm, your question reduces to "Which multi-armed bandit algorithm should I choose?" and this is dependent on the problem you are trying to solve. What do your rewards look like? Is your problem stationary? Is context important? Will you be adding new options all the time? The bandit setting is general enough that you can probably find a bandit algorithm to fit your specific problem. This includes non-stationarity, contextual bandits, ranking bandits, cascading bandits, etc. TL;DR: A/B Testing is also a bandit algorithm. There's no good rule of thumb (that I'm aware of) for choosing which algorithm to use in this setting. I suggest formalizing your problem and deciding what's important from a time and business perspective, then seeing which algorithms match up with your needs. If it's a simple scenario it's probably most reasonable to go with a simple A/B test or $\epsilon$-greedy bandit algorithm. For something intricate, high-volume or high-value, I'd go with a fancier bandit algorithm that's tailored to your situation.
Multi-armed bandit vs AB testing
The Difference I'm going to assume you are interested in this topic from a website design perspective. In an A/B test, you choose layout A half the time and layout B the other half. You record how mu
Multi-armed bandit vs AB testing The Difference I'm going to assume you are interested in this topic from a website design perspective. In an A/B test, you choose layout A half the time and layout B the other half. You record how much revenue is collected under each layout for $n$ visitors. Then you do a statistical test to determine if layout A or layout B had a statistically significantly higher revenue, and then deploy that layout. In bandit language, you had pure exploration period (trying out each option and seeing the revenue) for $n$ time steps and then a pure exploitation period afterwards (deploying the layout estimated to be the best). In a multi-armed bandit setting, the decision of when to show layout A or layout B is chosen by the algorithm. Instead of a pure exploration period followed by a pure exploitation period, you can continually balance exploration and exploitation. The algorithm will continually adjust its display percentages based on: An estimate for how much revenue the layout will get, based on the data collected so far. The higher the estimate the more the algorithm wants to display that layout. How confident we are in that estimate, based on how much data we've collected so far and its variability. The less confidence in the estimate, the more the algorithm wants to display that layout in order to collect more data about it. So the main difference comes down to: A/B tests tries out each option a constant % of the time, then at some point it's decided which one is best and that option is deployed Bandit algorithms can continually adjust how often to display each option based on how they're performing. How exactly this works is dependent on the bandit algorithm that you choose. Something to take note of is that multi-armed bandit is the name of the problem of sequential decision making under uncertainty and there are various algorithms that provide provably good solutions to this problem. A/B testing is actually the same thing as the explore-then-commit bandit algorithm. It doesn't necessarily make sense to look at "A/B Test vs. Multi-armed Bandits" since A/B tests are also a multi-armed bandit algorithm. Which one to choose? I don't think there's a good answer to this. Since A/B tests are a bandit algorithm, your question reduces to "Which multi-armed bandit algorithm should I choose?" and this is dependent on the problem you are trying to solve. What do your rewards look like? Is your problem stationary? Is context important? Will you be adding new options all the time? The bandit setting is general enough that you can probably find a bandit algorithm to fit your specific problem. This includes non-stationarity, contextual bandits, ranking bandits, cascading bandits, etc. TL;DR: A/B Testing is also a bandit algorithm. There's no good rule of thumb (that I'm aware of) for choosing which algorithm to use in this setting. I suggest formalizing your problem and deciding what's important from a time and business perspective, then seeing which algorithms match up with your needs. If it's a simple scenario it's probably most reasonable to go with a simple A/B test or $\epsilon$-greedy bandit algorithm. For something intricate, high-volume or high-value, I'd go with a fancier bandit algorithm that's tailored to your situation.
Multi-armed bandit vs AB testing The Difference I'm going to assume you are interested in this topic from a website design perspective. In an A/B test, you choose layout A half the time and layout B the other half. You record how mu
46,502
Multi-armed bandit vs AB testing
Assuming we are talking about traffic to a website, AB testing refers the method whereby traffic is split 50/50 between two different pages (or options, images, or whatever you are studying). So exactly half of your users would see, say, Page A and the other half would see Page B. You then use the results (e.g. purchases) to run your statistical tests. In multi-armed bandit, for a small percentage of the time (usually 10%), you'd split your traffic evenly between Page A and Page B just as you would in AB Testing. For the other 90% of the traffic, you'd divert users to the best performing page (if pages are tied, you'd randomly select a page to direct the user to). AB testing has a potentially high performance loss because you are not directing users to the best performing Page most of the time. On the other hand, it takes very little time to gather enough data points (visitors) to both pages to be able to perform statistical tests for differences in performance more quickly compared to the multi-bandit approach. Under the multi-bandit approach, only 10% of the time are you randomly sending traffic randomly to Page A or Page B, and within that 10%, roughly only 50% (or 5% of your total traffic) is going to the initially under-performing page. As a result, multi-bandit methods are best suited in those cases where you can wait longer periods before knowing which page is better performing. Multi-bandit approach is usually reserved for continuous optimization of existing pages, whereas AB is best suited for brand new pages that require experimentation. You will find a nice simulation study that should help you understand the differences between the two methods here.
Multi-armed bandit vs AB testing
Assuming we are talking about traffic to a website, AB testing refers the method whereby traffic is split 50/50 between two different pages (or options, images, or whatever you are studying). So exac
Multi-armed bandit vs AB testing Assuming we are talking about traffic to a website, AB testing refers the method whereby traffic is split 50/50 between two different pages (or options, images, or whatever you are studying). So exactly half of your users would see, say, Page A and the other half would see Page B. You then use the results (e.g. purchases) to run your statistical tests. In multi-armed bandit, for a small percentage of the time (usually 10%), you'd split your traffic evenly between Page A and Page B just as you would in AB Testing. For the other 90% of the traffic, you'd divert users to the best performing page (if pages are tied, you'd randomly select a page to direct the user to). AB testing has a potentially high performance loss because you are not directing users to the best performing Page most of the time. On the other hand, it takes very little time to gather enough data points (visitors) to both pages to be able to perform statistical tests for differences in performance more quickly compared to the multi-bandit approach. Under the multi-bandit approach, only 10% of the time are you randomly sending traffic randomly to Page A or Page B, and within that 10%, roughly only 50% (or 5% of your total traffic) is going to the initially under-performing page. As a result, multi-bandit methods are best suited in those cases where you can wait longer periods before knowing which page is better performing. Multi-bandit approach is usually reserved for continuous optimization of existing pages, whereas AB is best suited for brand new pages that require experimentation. You will find a nice simulation study that should help you understand the differences between the two methods here.
Multi-armed bandit vs AB testing Assuming we are talking about traffic to a website, AB testing refers the method whereby traffic is split 50/50 between two different pages (or options, images, or whatever you are studying). So exac
46,503
ELI5: The Logic Behind Coefficient Estimation in OLS Regression
Suppose you have a model of the form: $$X \beta= Y$$ where X is a normal 2-D matrix, for ease of visualisation. Now, if the matrix $X$ is square and invertible, then getting $\beta$ is trivial: $$\beta= X^{-1}Y$$ And that would be the end of it. If this is not the case, to get $\beta$ you’ll have to find a way to “approximate” the result of an inverse matrix. $X^\dagger = (X'X)^{-1}X'$ is called the (left)-pseudoinverse, and it has some nice properties that make it useful for this application. In particular, it is unique, and $XX^\dagger X=X$, so it kind of works like an inverse matrix would $(XX^{-1}X = XI = X)$. Also, for an invertible and square matrix (i.e. if the inverse matrix exists), it is equal to $X^{-1}$. Also it gets the shape of the matrix right: If $X$ has order $n \times m$, our pseudoinverse should be $m \times n$ so we can multiply it with $Y$. This is achieved by multiplying $(X'X)^{-1}$, which is square $(m \times m)$, with X' $(m \times n)$.
ELI5: The Logic Behind Coefficient Estimation in OLS Regression
Suppose you have a model of the form: $$X \beta= Y$$ where X is a normal 2-D matrix, for ease of visualisation. Now, if the matrix $X$ is square and invertible, then getting $\beta$ is trivial: $$\be
ELI5: The Logic Behind Coefficient Estimation in OLS Regression Suppose you have a model of the form: $$X \beta= Y$$ where X is a normal 2-D matrix, for ease of visualisation. Now, if the matrix $X$ is square and invertible, then getting $\beta$ is trivial: $$\beta= X^{-1}Y$$ And that would be the end of it. If this is not the case, to get $\beta$ you’ll have to find a way to “approximate” the result of an inverse matrix. $X^\dagger = (X'X)^{-1}X'$ is called the (left)-pseudoinverse, and it has some nice properties that make it useful for this application. In particular, it is unique, and $XX^\dagger X=X$, so it kind of works like an inverse matrix would $(XX^{-1}X = XI = X)$. Also, for an invertible and square matrix (i.e. if the inverse matrix exists), it is equal to $X^{-1}$. Also it gets the shape of the matrix right: If $X$ has order $n \times m$, our pseudoinverse should be $m \times n$ so we can multiply it with $Y$. This is achieved by multiplying $(X'X)^{-1}$, which is square $(m \times m)$, with X' $(m \times n)$.
ELI5: The Logic Behind Coefficient Estimation in OLS Regression Suppose you have a model of the form: $$X \beta= Y$$ where X is a normal 2-D matrix, for ease of visualisation. Now, if the matrix $X$ is square and invertible, then getting $\beta$ is trivial: $$\be
46,504
ELI5: The Logic Behind Coefficient Estimation in OLS Regression
If you look at sources such as wikipedia, there are some good explanations for where this comes from. Here are some cores ideas: OLS is aiming to minimize the error $||y-X\beta||$. The norm of a vector is minimized when its derivative is perpendicular to the vector. (Since you asked for ELI5, I won't go into a rigorous formulation of "derivative" in this context.) The error is given in terms of $y$, $X$, and $\beta$. The first two are constants; we're varying only $\beta$. Thus, the derivative can be treated as being $X\beta'$, so we're looking for $(X\beta')^T(y-X\beta)=0$. This is equivalent to $(\beta')^TX^Ty=(\beta')^TX^TX\beta$. If we cancel the $(\beta')^T$ from both sides (normally in linear algebra, you can't just go around canceling things, but I'm not aiming for perfect rigor here, so I won't get into the justification), we're left with $X^Ty=X^TX\beta$. Now, $X^T$ isn't invertible (it isn't even square), so we can't cancel it out, but it does turn out that $X^TX$ must be invertible (assuming that the features are linearly independent). So we can get $\beta = (X^TX)^{-1}X^Ty$. Going back to $X^Ty=X^TX\beta$, recall that $X\beta$ is the the estimate $\hat y$ that is calculated from a given $\beta$. $X^Ty$ is a vector in which each entry is the dot product of one of the features with the response. So we have that $X^Ty=X^T\hat y$, i.e., for each feature, the dot product between that feature and the actual response is equal to the dot product between that feature and the estimated response. $\forall i, x_i^Ty=x_i^T\hat y$. We can view OLS, then, as solving $n$ equations $x_i^Ty=x_i^T\hat y$, where $n$ is the number of features. So to see why this works, we just need to show that a solution exists, and that any estimate of the response other than this solution will have larger squared error.
ELI5: The Logic Behind Coefficient Estimation in OLS Regression
If you look at sources such as wikipedia, there are some good explanations for where this comes from. Here are some cores ideas: OLS is aiming to minimize the error $||y-X\beta||$. The norm of a vect
ELI5: The Logic Behind Coefficient Estimation in OLS Regression If you look at sources such as wikipedia, there are some good explanations for where this comes from. Here are some cores ideas: OLS is aiming to minimize the error $||y-X\beta||$. The norm of a vector is minimized when its derivative is perpendicular to the vector. (Since you asked for ELI5, I won't go into a rigorous formulation of "derivative" in this context.) The error is given in terms of $y$, $X$, and $\beta$. The first two are constants; we're varying only $\beta$. Thus, the derivative can be treated as being $X\beta'$, so we're looking for $(X\beta')^T(y-X\beta)=0$. This is equivalent to $(\beta')^TX^Ty=(\beta')^TX^TX\beta$. If we cancel the $(\beta')^T$ from both sides (normally in linear algebra, you can't just go around canceling things, but I'm not aiming for perfect rigor here, so I won't get into the justification), we're left with $X^Ty=X^TX\beta$. Now, $X^T$ isn't invertible (it isn't even square), so we can't cancel it out, but it does turn out that $X^TX$ must be invertible (assuming that the features are linearly independent). So we can get $\beta = (X^TX)^{-1}X^Ty$. Going back to $X^Ty=X^TX\beta$, recall that $X\beta$ is the the estimate $\hat y$ that is calculated from a given $\beta$. $X^Ty$ is a vector in which each entry is the dot product of one of the features with the response. So we have that $X^Ty=X^T\hat y$, i.e., for each feature, the dot product between that feature and the actual response is equal to the dot product between that feature and the estimated response. $\forall i, x_i^Ty=x_i^T\hat y$. We can view OLS, then, as solving $n$ equations $x_i^Ty=x_i^T\hat y$, where $n$ is the number of features. So to see why this works, we just need to show that a solution exists, and that any estimate of the response other than this solution will have larger squared error.
ELI5: The Logic Behind Coefficient Estimation in OLS Regression If you look at sources such as wikipedia, there are some good explanations for where this comes from. Here are some cores ideas: OLS is aiming to minimize the error $||y-X\beta||$. The norm of a vect
46,505
Understanding the shifted log-normal distribution
By definition, a random variable X has a shifted log-normal distribution with shift $\theta$ if log(X + $\theta$) ~ N($\mu$,$\sigma$). In the more usual notation, that would correspond to a lognormal with shift $-\theta$. However, if X + $\theta$ ~logN($\mu$,$\sigma$), then also X has a log-normal distribution X ~logN($\mu'$,$\sigma'$). This is not the case, as we'll see. To keep things clear, let us distinguish between the two parameter lognormal (with parameters $\mu$ and $\sigma^2$) and a shifted (i.e. three parameter) lognormal ($\delta,\mu,\sigma^2$); if $\delta=0$ we get the two-parameter lognormal as a special case. The density for the three parameter lognormal is: $$\frac {_1}{^{(x-\delta)\sigma {\sqrt {2\pi }}}}\, e^{-{\frac{1}{2\sigma ^{2}} {\left(\ln (x-\delta)-\mu \right)^{2}}}},\quad x>\delta, \:\delta,\mu\in \mathbb{R},\,\sigma>0$$ [Here a positive $\delta$ shifts up by $\delta$, corresponding to the negative of your $\theta$; a positive $\theta$ corresponds to a shift down by $\theta$. I'll stick with the more common convention.] It is the case that if you already have a shift (location-parameter) in the model, then adding a shift parameter would do nothing. For example, $\mu$ plays this role in the normal distribution, so there would be no point in adding a shift parameter to a normal distribution; it would simply be combined with the $\mu$ term. However, in the lognormal, $\mu$ is not a shift parameter. It is a scale parameter; it stretches and compresses rather than shifts. Meanwhile $\sigma$ is a shape parameter, controlling how skewed/heavy tailed the lognormal distribution is. One quick way to see that the shift parameter does something different to the two parameters already there (assuming you don't wish to follow through the algebraic manipulations on the density), is to use the fact that the log of any two parameter lognormal variate is itself distributed as a normal (the three parameter lognormal doesn't share this property in general, as we'll see). With the normal, if we apply a shift we move the density up or down along the x-axis, which simply alters its $\mu$ parameter and leaves us with another normal. With the two parameter lognormal, altering the $\mu$ parameter leaves us with another two parameter lognormal but does not simply shift the values. It does have the property that if we then take logs, we get back to a normal. Shifting the normal and then exponentiating to a two parameter lognormal is different from shifting the two parameter lognormal. [The issue boils down to the fact that addition and exponentiation are not commutative, so shifting the lognormal doesn't work like shifting the normal.] We can immediately see that if we supply a negative shift ($\delta<0$ in a three parameter lognormal) that we can't take logs to get back to a normal -- some of the density applies to negative values of $x$. We might briefly entertain the notion that positive arguments might somehow work but we can readily determine that it cannot be the case via simulation, or more directly, even just by considering the lower limit: The log of a three-parameter lognormal variate with $\delta>0$ will have a smallest possible value of $\ln \delta$; therefore it cannot be normal, since all normal variates range over the whole real line. Alternatively, in a simulation, the steps are: generate data from a normal distribution with some $\mu,\sigma$ exponentiate, to a corresponding two-paramater lognormal with the same parameters shift the distribution up by a substantial amount (say, twice the mean of the lognormal), so that it has a clear impact on the location take logs and note that the result is clearly not normal. For a large sample from a standard normal and a shift parameter of $\delta=2e^\frac12\approx 3.3$, we obtain: These histograms are what we get at step 1 and 4 respectively. We can clearly see we don't get a normal back out (it's skewed, for starters), so the shift parameter is not doing the same thing as changing $\mu$ would*. The lowest value in the $\log(x)$ sample displayed on the right, is $1.19498$, just above the lower limit of $\frac12+\log(2)\approx 1.19315$ * we can actually see that back in the formula for the density, where $\delta$ is inside the $\log(x..)$ part but $\mu$ is outside it, so they clearly don't just add together. Appendix: #R code for the above (fewer simulations than I did, but enough) # z <- rnorm(1000000,0,1) # 1 million normals delta <- 2*exp(1/2) y <- exp(z) # 2-parameter lognormal x <- y + delta # shifted (i.e. 3-parameter) lognormal par(mfrow=c(1,2)) hist(z,n=200,col="skyblue",bord="skyblue",freq=FALSE) hist(log(x),n=200,col="lightgreen",bord="lightgreen",xlim=c(1,5),freq=FALSE)
Understanding the shifted log-normal distribution
By definition, a random variable X has a shifted log-normal distribution with shift $\theta$ if log(X + $\theta$) ~ N($\mu$,$\sigma$). In the more usual notation, that would correspond to a lognormal
Understanding the shifted log-normal distribution By definition, a random variable X has a shifted log-normal distribution with shift $\theta$ if log(X + $\theta$) ~ N($\mu$,$\sigma$). In the more usual notation, that would correspond to a lognormal with shift $-\theta$. However, if X + $\theta$ ~logN($\mu$,$\sigma$), then also X has a log-normal distribution X ~logN($\mu'$,$\sigma'$). This is not the case, as we'll see. To keep things clear, let us distinguish between the two parameter lognormal (with parameters $\mu$ and $\sigma^2$) and a shifted (i.e. three parameter) lognormal ($\delta,\mu,\sigma^2$); if $\delta=0$ we get the two-parameter lognormal as a special case. The density for the three parameter lognormal is: $$\frac {_1}{^{(x-\delta)\sigma {\sqrt {2\pi }}}}\, e^{-{\frac{1}{2\sigma ^{2}} {\left(\ln (x-\delta)-\mu \right)^{2}}}},\quad x>\delta, \:\delta,\mu\in \mathbb{R},\,\sigma>0$$ [Here a positive $\delta$ shifts up by $\delta$, corresponding to the negative of your $\theta$; a positive $\theta$ corresponds to a shift down by $\theta$. I'll stick with the more common convention.] It is the case that if you already have a shift (location-parameter) in the model, then adding a shift parameter would do nothing. For example, $\mu$ plays this role in the normal distribution, so there would be no point in adding a shift parameter to a normal distribution; it would simply be combined with the $\mu$ term. However, in the lognormal, $\mu$ is not a shift parameter. It is a scale parameter; it stretches and compresses rather than shifts. Meanwhile $\sigma$ is a shape parameter, controlling how skewed/heavy tailed the lognormal distribution is. One quick way to see that the shift parameter does something different to the two parameters already there (assuming you don't wish to follow through the algebraic manipulations on the density), is to use the fact that the log of any two parameter lognormal variate is itself distributed as a normal (the three parameter lognormal doesn't share this property in general, as we'll see). With the normal, if we apply a shift we move the density up or down along the x-axis, which simply alters its $\mu$ parameter and leaves us with another normal. With the two parameter lognormal, altering the $\mu$ parameter leaves us with another two parameter lognormal but does not simply shift the values. It does have the property that if we then take logs, we get back to a normal. Shifting the normal and then exponentiating to a two parameter lognormal is different from shifting the two parameter lognormal. [The issue boils down to the fact that addition and exponentiation are not commutative, so shifting the lognormal doesn't work like shifting the normal.] We can immediately see that if we supply a negative shift ($\delta<0$ in a three parameter lognormal) that we can't take logs to get back to a normal -- some of the density applies to negative values of $x$. We might briefly entertain the notion that positive arguments might somehow work but we can readily determine that it cannot be the case via simulation, or more directly, even just by considering the lower limit: The log of a three-parameter lognormal variate with $\delta>0$ will have a smallest possible value of $\ln \delta$; therefore it cannot be normal, since all normal variates range over the whole real line. Alternatively, in a simulation, the steps are: generate data from a normal distribution with some $\mu,\sigma$ exponentiate, to a corresponding two-paramater lognormal with the same parameters shift the distribution up by a substantial amount (say, twice the mean of the lognormal), so that it has a clear impact on the location take logs and note that the result is clearly not normal. For a large sample from a standard normal and a shift parameter of $\delta=2e^\frac12\approx 3.3$, we obtain: These histograms are what we get at step 1 and 4 respectively. We can clearly see we don't get a normal back out (it's skewed, for starters), so the shift parameter is not doing the same thing as changing $\mu$ would*. The lowest value in the $\log(x)$ sample displayed on the right, is $1.19498$, just above the lower limit of $\frac12+\log(2)\approx 1.19315$ * we can actually see that back in the formula for the density, where $\delta$ is inside the $\log(x..)$ part but $\mu$ is outside it, so they clearly don't just add together. Appendix: #R code for the above (fewer simulations than I did, but enough) # z <- rnorm(1000000,0,1) # 1 million normals delta <- 2*exp(1/2) y <- exp(z) # 2-parameter lognormal x <- y + delta # shifted (i.e. 3-parameter) lognormal par(mfrow=c(1,2)) hist(z,n=200,col="skyblue",bord="skyblue",freq=FALSE) hist(log(x),n=200,col="lightgreen",bord="lightgreen",xlim=c(1,5),freq=FALSE)
Understanding the shifted log-normal distribution By definition, a random variable X has a shifted log-normal distribution with shift $\theta$ if log(X + $\theta$) ~ N($\mu$,$\sigma$). In the more usual notation, that would correspond to a lognormal
46,506
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$)
As is pointed out in this related question, the normality of the error term in a linear regression is not sufficient to ensure the marginal normality of the response variable. The latter is also affected by the distribution of the explanatory variable, which is not assumed to be normal in a regression analysis. Under the linear regression model you have specified, the conditional distribution of $Y$ is: $$Y|x \sim \text{N}(\alpha + \beta x, \sigma^2).$$ The marginal distribution of $Y$ is: $$F_Y(y) \equiv \mathbb{P}(Y \leqslant y) = \int \limits_{-\infty}^\infty \Phi \Big( \frac{y - \alpha - \beta x}{\sigma} \Big) f_X(x) dx,$$ where $\Phi$ is the CDF of the standard normal distribution. In the special case where $X \sim \text{N}$ this leads to a normal distribution, but in the more general case where the explanatory variable has some other distribution, you will often get a marginal distribution for the response variable that is not normal.
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$,
As is pointed out in this related question, the normality of the error term in a linear regression is not sufficient to ensure the marginal normality of the response variable. The latter is also affe
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$) As is pointed out in this related question, the normality of the error term in a linear regression is not sufficient to ensure the marginal normality of the response variable. The latter is also affected by the distribution of the explanatory variable, which is not assumed to be normal in a regression analysis. Under the linear regression model you have specified, the conditional distribution of $Y$ is: $$Y|x \sim \text{N}(\alpha + \beta x, \sigma^2).$$ The marginal distribution of $Y$ is: $$F_Y(y) \equiv \mathbb{P}(Y \leqslant y) = \int \limits_{-\infty}^\infty \Phi \Big( \frac{y - \alpha - \beta x}{\sigma} \Big) f_X(x) dx,$$ where $\Phi$ is the CDF of the standard normal distribution. In the special case where $X \sim \text{N}$ this leads to a normal distribution, but in the more general case where the explanatory variable has some other distribution, you will often get a marginal distribution for the response variable that is not normal.
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, As is pointed out in this related question, the normality of the error term in a linear regression is not sufficient to ensure the marginal normality of the response variable. The latter is also affe
46,507
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$)
The answer is a most definitive "no." Marginal normality of $\epsilon$ does not imply that the conditional distributions of $Y$ are normal. See here for a counterexample: https://stats.stackexchange.com/a/486951/102879
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$,
The answer is a most definitive "no." Marginal normality of $\epsilon$ does not imply that the conditional distributions of $Y$ are normal. See here for a counterexample: https://stats.stackexchange
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$) The answer is a most definitive "no." Marginal normality of $\epsilon$ does not imply that the conditional distributions of $Y$ are normal. See here for a counterexample: https://stats.stackexchange.com/a/486951/102879
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, The answer is a most definitive "no." Marginal normality of $\epsilon$ does not imply that the conditional distributions of $Y$ are normal. See here for a counterexample: https://stats.stackexchange
46,508
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$)
The distribution at a fixed value of x is normal. Y is not normal. Just look at the histogram of the response. It will not look like a normal distribution. But if you look at the distribution at a fixed x, then it will look normal.
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$,
The distribution at a fixed value of x is normal. Y is not normal. Just look at the histogram of the response. It will not look like a normal distribution. But if you look at the distribution at a
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$) The distribution at a fixed value of x is normal. Y is not normal. Just look at the histogram of the response. It will not look like a normal distribution. But if you look at the distribution at a fixed x, then it will look normal.
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, The distribution at a fixed value of x is normal. Y is not normal. Just look at the histogram of the response. It will not look like a normal distribution. But if you look at the distribution at a
46,509
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$)
Yes if $\varepsilon \sim N(0, \sigma^2)$ $Y=\alpha+\beta x+ \epsilon$ then we can say that $Y \sim N(\alpha+\beta x,\sigma^2)$. This follows from the result that if a random variable $X \sim N(\mu, \sigma^2)$ then $X+a \sim N(\mu+a, \sigma^2)$, for example if $X\sim N(0, 3^2)$ then $X+2 \sim N(2, 3^2)$
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$,
Yes if $\varepsilon \sim N(0, \sigma^2)$ $Y=\alpha+\beta x+ \epsilon$ then we can say that $Y \sim N(\alpha+\beta x,\sigma^2)$. This follows from the result that if a random variable $X \sim N(\mu, \
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, $\sigma^2$) Yes if $\varepsilon \sim N(0, \sigma^2)$ $Y=\alpha+\beta x+ \epsilon$ then we can say that $Y \sim N(\alpha+\beta x,\sigma^2)$. This follows from the result that if a random variable $X \sim N(\mu, \sigma^2)$ then $X+a \sim N(\mu+a, \sigma^2)$, for example if $X\sim N(0, 3^2)$ then $X+2 \sim N(2, 3^2)$
In linear regression, if the random error is N(0,$\sigma^2$) does this mean Y~N($\alpha + \beta X$, Yes if $\varepsilon \sim N(0, \sigma^2)$ $Y=\alpha+\beta x+ \epsilon$ then we can say that $Y \sim N(\alpha+\beta x,\sigma^2)$. This follows from the result that if a random variable $X \sim N(\mu, \
46,510
Is this actually an example of selection bias?
If it's true that only women with a hip fracture were selected, then there is no association between hip fracture and anything in the selected population. This would amount to saying something like "among women with hip fractures, there is an association between having a hip fracture and having lung cancer." Clearly, this doesn't make sense. An association requires variation in two variables. You can't talk about an association between a variable and a conditioned-upon variable. If what he meant was "women with hip fractures were more likely to be selected," then one is not conditioning on hip fracture but rather on selection, which is caused by fracture, as the DAG displays. He may have misspoken in the video, because this is clearly what he intended to mean.
Is this actually an example of selection bias?
If it's true that only women with a hip fracture were selected, then there is no association between hip fracture and anything in the selected population. This would amount to saying something like "a
Is this actually an example of selection bias? If it's true that only women with a hip fracture were selected, then there is no association between hip fracture and anything in the selected population. This would amount to saying something like "among women with hip fractures, there is an association between having a hip fracture and having lung cancer." Clearly, this doesn't make sense. An association requires variation in two variables. You can't talk about an association between a variable and a conditioned-upon variable. If what he meant was "women with hip fractures were more likely to be selected," then one is not conditioning on hip fracture but rather on selection, which is caused by fracture, as the DAG displays. He may have misspoken in the video, because this is clearly what he intended to mean.
Is this actually an example of selection bias? If it's true that only women with a hip fracture were selected, then there is no association between hip fracture and anything in the selected population. This would amount to saying something like "a
46,511
Is this actually an example of selection bias?
My question is, if only women with hip fractures were surveyed, doesn't that mean we are conditioning on hip fractures? If so, there should be a square around hip fracture, the backdoor path is actually blocked, and there is no selection bias. Notice that even if the DAG were only $A \rightarrow Y \rightarrow C$ the post-interventional distribution $P(Y|do(A))$ is not non-parametrically identified, since $P(Y|do(A)) = P(Y|A) \neq P(Y|A, C)$ and you only observe $P(Y|A, C =1)$. Thus, if your target estimate is $P(Y|do(A))$, there is selection bias even without the path $A \rightarrow F \rightarrow C$. For selection bias, you might want to check Bareinboim and Pearl and more recently Correa, Tian and Bareinboim.
Is this actually an example of selection bias?
My question is, if only women with hip fractures were surveyed, doesn't that mean we are conditioning on hip fractures? If so, there should be a square around hip fracture, the backdoor path is ac
Is this actually an example of selection bias? My question is, if only women with hip fractures were surveyed, doesn't that mean we are conditioning on hip fractures? If so, there should be a square around hip fracture, the backdoor path is actually blocked, and there is no selection bias. Notice that even if the DAG were only $A \rightarrow Y \rightarrow C$ the post-interventional distribution $P(Y|do(A))$ is not non-parametrically identified, since $P(Y|do(A)) = P(Y|A) \neq P(Y|A, C)$ and you only observe $P(Y|A, C =1)$. Thus, if your target estimate is $P(Y|do(A))$, there is selection bias even without the path $A \rightarrow F \rightarrow C$. For selection bias, you might want to check Bareinboim and Pearl and more recently Correa, Tian and Bareinboim.
Is this actually an example of selection bias? My question is, if only women with hip fractures were surveyed, doesn't that mean we are conditioning on hip fractures? If so, there should be a square around hip fracture, the backdoor path is ac
46,512
Can the covariance matrix in a Gaussian Process be non-symmetric?
Can the covariance matrix in a Gaussian Process be non-symmetric? Every valid covariance matrix is a real symmetric non-negative definite matrix. This holds regardless of the underlying distribution. So no, it can't be non-symmetric. If the lecturers are making an argument for using some non-symmetric matrix (e.g., using a non-symmetric kernel) in a way that "acts/is interpreted as a covariance" somehow, then the onus is on them to explain how far this analogy holds, given that the matrix is not a valid covariance matrix.
Can the covariance matrix in a Gaussian Process be non-symmetric?
Can the covariance matrix in a Gaussian Process be non-symmetric? Every valid covariance matrix is a real symmetric non-negative definite matrix. This holds regardless of the underlying distribution
Can the covariance matrix in a Gaussian Process be non-symmetric? Can the covariance matrix in a Gaussian Process be non-symmetric? Every valid covariance matrix is a real symmetric non-negative definite matrix. This holds regardless of the underlying distribution. So no, it can't be non-symmetric. If the lecturers are making an argument for using some non-symmetric matrix (e.g., using a non-symmetric kernel) in a way that "acts/is interpreted as a covariance" somehow, then the onus is on them to explain how far this analogy holds, given that the matrix is not a valid covariance matrix.
Can the covariance matrix in a Gaussian Process be non-symmetric? Can the covariance matrix in a Gaussian Process be non-symmetric? Every valid covariance matrix is a real symmetric non-negative definite matrix. This holds regardless of the underlying distribution
46,513
Can the covariance matrix in a Gaussian Process be non-symmetric?
Answering below in order to be able to post a screen shot in response to a comment, this is not an answer to the question.
Can the covariance matrix in a Gaussian Process be non-symmetric?
Answering below in order to be able to post a screen shot in response to a comment, this is not an answer to the question.
Can the covariance matrix in a Gaussian Process be non-symmetric? Answering below in order to be able to post a screen shot in response to a comment, this is not an answer to the question.
Can the covariance matrix in a Gaussian Process be non-symmetric? Answering below in order to be able to post a screen shot in response to a comment, this is not an answer to the question.
46,514
Self-Study Plan Help (no undergrad math or stats experience)
I see various areas you should have a look into: Basics of probability Here you should understand the most common continuous probability distributions (e.g. normal distribution, t-distribution) and the most common discrete distributions (e.g. binomial distribution and geometric distribution). You should also understand how they are related to each other, e.g. a t-distribution converges to a normal distribution if n goes to infinity. You should also understand concepts like conditional probability and Bayes' theorem and you should have a look into random processes, e.g. random walk. Basics of inferential statistics You should understand the basics of inferential statistics and statistical testing. In statistical testing p-values and power of tests is important. Linear algebra Linear algebra is one of the most important mathematical concepts for statistics. Important concepts are e.g. the inverse and the transpose of a matrix. You should also be able to calculate with matrices, e.g. multiplication. Regression and econometrics There are three different areas of regression analysis: Cross-sectional regressions, panel data and time series analysis. You should go through all of the three areas. Time series analysis might be the most important area of this three areas for practitioners as it is used for forecasting. Machine learning algorithms After having an overview of the different areas of machine learning you should have look in some of the most common supervised machine learning algorithms (e.g. regression and classification) and the most common unsupervised machine learning algorithms (e.g. clustering, cimensionality reduction and anomaly detection) Coding with statistical software R and Python are the most widespread languages for statistical computing. If I were you I would choose R as you need less pre-knowledge in object-oriented computing for using it.
Self-Study Plan Help (no undergrad math or stats experience)
I see various areas you should have a look into: Basics of probability Here you should understand the most common continuous probability distributions (e.g. normal distribution, t-distribution) and
Self-Study Plan Help (no undergrad math or stats experience) I see various areas you should have a look into: Basics of probability Here you should understand the most common continuous probability distributions (e.g. normal distribution, t-distribution) and the most common discrete distributions (e.g. binomial distribution and geometric distribution). You should also understand how they are related to each other, e.g. a t-distribution converges to a normal distribution if n goes to infinity. You should also understand concepts like conditional probability and Bayes' theorem and you should have a look into random processes, e.g. random walk. Basics of inferential statistics You should understand the basics of inferential statistics and statistical testing. In statistical testing p-values and power of tests is important. Linear algebra Linear algebra is one of the most important mathematical concepts for statistics. Important concepts are e.g. the inverse and the transpose of a matrix. You should also be able to calculate with matrices, e.g. multiplication. Regression and econometrics There are three different areas of regression analysis: Cross-sectional regressions, panel data and time series analysis. You should go through all of the three areas. Time series analysis might be the most important area of this three areas for practitioners as it is used for forecasting. Machine learning algorithms After having an overview of the different areas of machine learning you should have look in some of the most common supervised machine learning algorithms (e.g. regression and classification) and the most common unsupervised machine learning algorithms (e.g. clustering, cimensionality reduction and anomaly detection) Coding with statistical software R and Python are the most widespread languages for statistical computing. If I were you I would choose R as you need less pre-knowledge in object-oriented computing for using it.
Self-Study Plan Help (no undergrad math or stats experience) I see various areas you should have a look into: Basics of probability Here you should understand the most common continuous probability distributions (e.g. normal distribution, t-distribution) and
46,515
Self-Study Plan Help (no undergrad math or stats experience)
Since you mentioned Bayesian statistics, let me recommend Data Analysis: A Baysesian Tutorial by Sivia and Skilling to you. I am reading it myself at the moment and find it fantastic. The book really helps in understanding the big picture of (Bayesian) probability theory. Also it finally links together all the divergent pieces of information that I had accumulated but never really understood in statistics classes. It has just the right amount of mathematical rigor and practical application. I could go on, give it a try! Here is what the book says about itself: Statistics lectures have been a source of much bewilderment and frustration for generations of students. This book attempts to remedy the situation by expounding a logical and unified approach to the whole subject of data analysis. This text is intended as a tutorial guide for senior undergraduates and research students in science and engineering. After explaining the basic principles of Bayesian probability theory, their use is illustrated with a variety of examples ranging from elementary parameter estimation to image processing. Other topics covered include reliability analysis, multivariate optimization, least-squares and maximum likelihood, error-propagation, hypothesis testing, maximum entropy and experimental design.
Self-Study Plan Help (no undergrad math or stats experience)
Since you mentioned Bayesian statistics, let me recommend Data Analysis: A Baysesian Tutorial by Sivia and Skilling to you. I am reading it myself at the moment and find it fantastic. The book really
Self-Study Plan Help (no undergrad math or stats experience) Since you mentioned Bayesian statistics, let me recommend Data Analysis: A Baysesian Tutorial by Sivia and Skilling to you. I am reading it myself at the moment and find it fantastic. The book really helps in understanding the big picture of (Bayesian) probability theory. Also it finally links together all the divergent pieces of information that I had accumulated but never really understood in statistics classes. It has just the right amount of mathematical rigor and practical application. I could go on, give it a try! Here is what the book says about itself: Statistics lectures have been a source of much bewilderment and frustration for generations of students. This book attempts to remedy the situation by expounding a logical and unified approach to the whole subject of data analysis. This text is intended as a tutorial guide for senior undergraduates and research students in science and engineering. After explaining the basic principles of Bayesian probability theory, their use is illustrated with a variety of examples ranging from elementary parameter estimation to image processing. Other topics covered include reliability analysis, multivariate optimization, least-squares and maximum likelihood, error-propagation, hypothesis testing, maximum entropy and experimental design.
Self-Study Plan Help (no undergrad math or stats experience) Since you mentioned Bayesian statistics, let me recommend Data Analysis: A Baysesian Tutorial by Sivia and Skilling to you. I am reading it myself at the moment and find it fantastic. The book really
46,516
Redundant variables in linear regression
Not necessarily. It is instructive to understand why not. The issue is whether some linear combination of the variables is linearly correlated with the response. Sometimes a set of explanatory variables can be extremely closely correlated, but removing any single one of those variables significantly reduces the quality of the model. This can be illustrated through a simulation. The R code below does the following: It creates $n$ independent realizations of two explanatory variables $X_1$ and $X_2$ randomly in the form $$X_1=Z + \rho E,\ X_2 = Z-\rho E$$ where $Z$ and $E$ are independent standard Normal variables and $|\rho|$ is intended to be a small number. Since the variance of each $X_i$ is $$\operatorname{Var}(X_i) = \operatorname{Var}(Z \pm \rho E) = 1 \pm 2(0) + (\pm\rho)^2 = 1+\rho^2,$$ the correlation of the $X_i$ is therefore $$\operatorname{Cor}(X_1,X_2) = \frac{\operatorname{Cov}(Z+\rho E, Z-\rho E)}{1+\rho^2} = \frac{1-\rho^2}{1+\rho^2} \approx 1 - 2\rho^2.$$ For smallish $\rho$ that's very strong correlation. It realizes $n$ responses from the random variable $$Y = E + \sigma W$$ where $W$ is another Standard normal variable independent of $Z$ and $E.$ Algebra shows $$Y = \frac{1}{2\rho}X_1 + \frac{-1}{2\rho}X_2 + \sigma W.$$ When $\sigma/\rho$ is not too small, these coefficients of the $X_i$ are large relative to the random error $\sigma W.$ That makes this a very strong linear dependence of $Y$ on the $X_i.$ It fits three ordinary least squares models, $E[Y] = \alpha_0 + \alpha_1 X_1 + \alpha_2 X_2$ (a multiple regression), $E[Y] = \beta_0 + \beta_1 X_1$ (an ordinary regression against $X_1$), and $E[Y] = \gamma_0 + \gamma_1 X_2$ (an ordinary regression against $X_2$). $Z$ plays the role of a "nuisance:" it represents a great deal of variability common to all regressors but unrelated to the response. Let's study this situation. Here is a scatterplot showing an example of the data the simulation produces (for a sample size of $24$) when $\rho=0.1$ and $\sigma=0.01.$ The strong positive correlation of the $X_i$ is apparent, even in this small sample, through the clustering of data along the diagonals of the $X_1-X_2$ scatterplots. $Y$ doesn't appear to have much of a linear relationship to the $X_i,$ as the random scatter in the top and left plots and the results of the two ordinary regressions show. The ordinary regression results are similar, so I will display only the first one. Call: lm(formula = y ~ x1) Residuals: Min 1Q Median 3Q Max -0.142002 -0.059922 -0.004332 0.048009 0.137539 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.041016 0.016586 2.473 0.0216 * x1 -0.007055 0.014991 -0.471 0.6426 --- F-statistic: 0.2215 on 1 and 22 DF, p-value: 0.6426 I would like to draw your attention to (1) the insignificant p-value of $0.64,$ (2) the estimated coefficient of nearly $0,$ and (3) that the residuals are typically around $0.05$ in size. Compare this to the multiple regression using both variables: Call: lm(formula = y ~ x1 + x2) Residuals: Min 1Q Median 3Q Max -0.0186887 -0.0078369 0.0002194 0.0039288 0.0214359 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.002080 0.002443 0.851 0.404 x1 0.498225 0.014422 34.547 <2e-16 *** x2 -0.496415 0.014036 -35.368 <2e-16 *** --- F-statistic: 631.8 on 2 and 21 DF, p-value: < 2.2e-16 This time, The p-value is essentially zero: this is a "highly significant" linear response. The estimated coefficients, close to $\pm 1/2,$ are sizable (much larger than the estimates in the single-regressor situations), close to what we know the true values of $\alpha_1$ and $\alpha_2$ to be, and both are highly significant. The residuals are typically around $0.01$ or less in size--almost an order of magnitude reduction. In most applications this would represent a huge improvement in the regression. These are all dramatic differences, showing why even when regressors are correlated, it might be useful to include them all. It can be instructive to play with this simulation by modifying its parameters $n,$ $\rho,$ and $\sigma.$ (Remove the set.seed line in order to get varying results.) n <- 24 rho <- 0.1 sigma <- 0.01 set.seed(17) eps <- rnorm(n) * rho x1 <- rnorm(n) x2 <- x1 - eps x1 <- x1 + eps y <- eps + rnorm(n) * sigma pairs(cbind(y, x1, x2), pch=21, bg="#00000020") summary(lm(y ~ x1 + x2)) summary(lm(y ~ x1)) summary(lm(y ~ x2))
Redundant variables in linear regression
Not necessarily. It is instructive to understand why not. The issue is whether some linear combination of the variables is linearly correlated with the response. Sometimes a set of explanatory varia
Redundant variables in linear regression Not necessarily. It is instructive to understand why not. The issue is whether some linear combination of the variables is linearly correlated with the response. Sometimes a set of explanatory variables can be extremely closely correlated, but removing any single one of those variables significantly reduces the quality of the model. This can be illustrated through a simulation. The R code below does the following: It creates $n$ independent realizations of two explanatory variables $X_1$ and $X_2$ randomly in the form $$X_1=Z + \rho E,\ X_2 = Z-\rho E$$ where $Z$ and $E$ are independent standard Normal variables and $|\rho|$ is intended to be a small number. Since the variance of each $X_i$ is $$\operatorname{Var}(X_i) = \operatorname{Var}(Z \pm \rho E) = 1 \pm 2(0) + (\pm\rho)^2 = 1+\rho^2,$$ the correlation of the $X_i$ is therefore $$\operatorname{Cor}(X_1,X_2) = \frac{\operatorname{Cov}(Z+\rho E, Z-\rho E)}{1+\rho^2} = \frac{1-\rho^2}{1+\rho^2} \approx 1 - 2\rho^2.$$ For smallish $\rho$ that's very strong correlation. It realizes $n$ responses from the random variable $$Y = E + \sigma W$$ where $W$ is another Standard normal variable independent of $Z$ and $E.$ Algebra shows $$Y = \frac{1}{2\rho}X_1 + \frac{-1}{2\rho}X_2 + \sigma W.$$ When $\sigma/\rho$ is not too small, these coefficients of the $X_i$ are large relative to the random error $\sigma W.$ That makes this a very strong linear dependence of $Y$ on the $X_i.$ It fits three ordinary least squares models, $E[Y] = \alpha_0 + \alpha_1 X_1 + \alpha_2 X_2$ (a multiple regression), $E[Y] = \beta_0 + \beta_1 X_1$ (an ordinary regression against $X_1$), and $E[Y] = \gamma_0 + \gamma_1 X_2$ (an ordinary regression against $X_2$). $Z$ plays the role of a "nuisance:" it represents a great deal of variability common to all regressors but unrelated to the response. Let's study this situation. Here is a scatterplot showing an example of the data the simulation produces (for a sample size of $24$) when $\rho=0.1$ and $\sigma=0.01.$ The strong positive correlation of the $X_i$ is apparent, even in this small sample, through the clustering of data along the diagonals of the $X_1-X_2$ scatterplots. $Y$ doesn't appear to have much of a linear relationship to the $X_i,$ as the random scatter in the top and left plots and the results of the two ordinary regressions show. The ordinary regression results are similar, so I will display only the first one. Call: lm(formula = y ~ x1) Residuals: Min 1Q Median 3Q Max -0.142002 -0.059922 -0.004332 0.048009 0.137539 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.041016 0.016586 2.473 0.0216 * x1 -0.007055 0.014991 -0.471 0.6426 --- F-statistic: 0.2215 on 1 and 22 DF, p-value: 0.6426 I would like to draw your attention to (1) the insignificant p-value of $0.64,$ (2) the estimated coefficient of nearly $0,$ and (3) that the residuals are typically around $0.05$ in size. Compare this to the multiple regression using both variables: Call: lm(formula = y ~ x1 + x2) Residuals: Min 1Q Median 3Q Max -0.0186887 -0.0078369 0.0002194 0.0039288 0.0214359 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.002080 0.002443 0.851 0.404 x1 0.498225 0.014422 34.547 <2e-16 *** x2 -0.496415 0.014036 -35.368 <2e-16 *** --- F-statistic: 631.8 on 2 and 21 DF, p-value: < 2.2e-16 This time, The p-value is essentially zero: this is a "highly significant" linear response. The estimated coefficients, close to $\pm 1/2,$ are sizable (much larger than the estimates in the single-regressor situations), close to what we know the true values of $\alpha_1$ and $\alpha_2$ to be, and both are highly significant. The residuals are typically around $0.01$ or less in size--almost an order of magnitude reduction. In most applications this would represent a huge improvement in the regression. These are all dramatic differences, showing why even when regressors are correlated, it might be useful to include them all. It can be instructive to play with this simulation by modifying its parameters $n,$ $\rho,$ and $\sigma.$ (Remove the set.seed line in order to get varying results.) n <- 24 rho <- 0.1 sigma <- 0.01 set.seed(17) eps <- rnorm(n) * rho x1 <- rnorm(n) x2 <- x1 - eps x1 <- x1 + eps y <- eps + rnorm(n) * sigma pairs(cbind(y, x1, x2), pch=21, bg="#00000020") summary(lm(y ~ x1 + x2)) summary(lm(y ~ x1)) summary(lm(y ~ x2))
Redundant variables in linear regression Not necessarily. It is instructive to understand why not. The issue is whether some linear combination of the variables is linearly correlated with the response. Sometimes a set of explanatory varia
46,517
Why is the risk function defined to be the expectation of loss function?
In my understanding, the expected value of a random variable is not necessarily a good description of it. This depends on what you mean by "description". The expectation has a number of interpretations, all of which might or might not be "good" for you. In frequentist terms, it is the long-run average of a data-generating process. If you draw from a random variable $X$ an infinite number of times, the average of the observations will converge on $E(X)$. Mathematically, it is a weighted average of the possible outcomes (even in the continuous case if you squint at it). The more probable an outcome, the greater its weight. The expectation is also the center of mass of the probability distribution. This description is appealing in higher dimensions (where you can think of the data as occupying a "blob" in space), and is analogous to the center of mass in physics. Finally, the expectation is a location parameter. This means that a change in the expectation of the distribution represents a shift in the density of the distribution. If you change the expected value, it's like you are picking the density of the distribution up off the graph, and just dropping it elsewhere, without otherwise modifying its shape. The "not necessarily a good description" criticism is probably related to the fact that, in highly skewed or heavy-tailed distributions, very few observations are actually near the expected value point. This is valid, but probably not something we have the luxury to care about. As I mention below, we don't really have an alternative. I am wondering why do we assume that the expected value of loss is considered a good description of the random variable? It is a location parameter. Smaller loss is good. If the location of the loss distribution is lower, then loss on average is smaller. This is what we want. It's relatively easy to compute. The fact that it's linear is especially helpful. The alternative location parameters (median, mode, ...?) are not so easy to compute, and are arguably less representative than the mean. We use it everywhere else anyway. In economics and decision theory, some of the easiest utility functions to work with imply that agents minimize expected loss (or equivalently maximize expected gain). This is what it comes down to: we can compute it, it works for the most part, and there isn't a clear alternative.
Why is the risk function defined to be the expectation of loss function?
In my understanding, the expected value of a random variable is not necessarily a good description of it. This depends on what you mean by "description". The expectation has a number of interpretatio
Why is the risk function defined to be the expectation of loss function? In my understanding, the expected value of a random variable is not necessarily a good description of it. This depends on what you mean by "description". The expectation has a number of interpretations, all of which might or might not be "good" for you. In frequentist terms, it is the long-run average of a data-generating process. If you draw from a random variable $X$ an infinite number of times, the average of the observations will converge on $E(X)$. Mathematically, it is a weighted average of the possible outcomes (even in the continuous case if you squint at it). The more probable an outcome, the greater its weight. The expectation is also the center of mass of the probability distribution. This description is appealing in higher dimensions (where you can think of the data as occupying a "blob" in space), and is analogous to the center of mass in physics. Finally, the expectation is a location parameter. This means that a change in the expectation of the distribution represents a shift in the density of the distribution. If you change the expected value, it's like you are picking the density of the distribution up off the graph, and just dropping it elsewhere, without otherwise modifying its shape. The "not necessarily a good description" criticism is probably related to the fact that, in highly skewed or heavy-tailed distributions, very few observations are actually near the expected value point. This is valid, but probably not something we have the luxury to care about. As I mention below, we don't really have an alternative. I am wondering why do we assume that the expected value of loss is considered a good description of the random variable? It is a location parameter. Smaller loss is good. If the location of the loss distribution is lower, then loss on average is smaller. This is what we want. It's relatively easy to compute. The fact that it's linear is especially helpful. The alternative location parameters (median, mode, ...?) are not so easy to compute, and are arguably less representative than the mean. We use it everywhere else anyway. In economics and decision theory, some of the easiest utility functions to work with imply that agents minimize expected loss (or equivalently maximize expected gain). This is what it comes down to: we can compute it, it works for the most part, and there isn't a clear alternative.
Why is the risk function defined to be the expectation of loss function? In my understanding, the expected value of a random variable is not necessarily a good description of it. This depends on what you mean by "description". The expectation has a number of interpretatio
46,518
Why is the risk function defined to be the expectation of loss function?
My intuition about the topic: In a statistical parametric setting, which is in Desion Theory bounds, we'd like to estime, say, $\theta \in \Theta$ in the best way possible, by choosing a function of the sample data (a statistic) before we met the data. Let 'best' be measured by a loss function $l: t \times \theta \to \!R^+$, where $t$ is the estimate for $\theta$. So $l(t, \theta)$ is high for poor values of $t$ and zero for $t=\theta$. Now we want to compare statistics $T_1$ and $T_2$. One is clearly the winner if the loss function is less or equal than the other for all samples. If that's not the case, we cannot say which one is better. In other words, $T_1$ may be better than $T_2$ in some subset of sample space, but $T_2$ may be better than $T_1$ in another subset. To remove the dependency on sample space, we may take the average value over it. That's the risk function. Now, suppose $T_1$ is better than $T_2$ in average. $T_2$ may be better than $T_1$ in certain circumstances yet! $T_2$ mat be better than $T_1$ for some values of $\theta \in \Theta_1 \subset \Theta$, yet worse in average! To further remove the dependency on $\Theta$ is to set a priori over $\Theta$ - this is the Bayesian approach. Here, we set 'importance' over $\Theta$: more reasonable values of $\theta$ are more important, since they're more likely to be found in reallity. In a nutshell, I think we consider the risk function the way it is because it removes dependency on information, in a setting where we are making decision before we gather it. In complementation of @shadowtalker's answer, it's important to notice that sometimes (like @shadowtalker suggested on heavy-tailed distributions) expectation is not sufficient to summarise a random variable (though being a good "descriptor"). In those cases, we may need variance, skewness or kurtosis. Also, other central measure of tendendy as median are very useful in nonparametric statistcis for instance. Alhough historicaly theory was developed first for pararmetric statistics, where expected value has more appeal.
Why is the risk function defined to be the expectation of loss function?
My intuition about the topic: In a statistical parametric setting, which is in Desion Theory bounds, we'd like to estime, say, $\theta \in \Theta$ in the best way possible, by choosing a function of t
Why is the risk function defined to be the expectation of loss function? My intuition about the topic: In a statistical parametric setting, which is in Desion Theory bounds, we'd like to estime, say, $\theta \in \Theta$ in the best way possible, by choosing a function of the sample data (a statistic) before we met the data. Let 'best' be measured by a loss function $l: t \times \theta \to \!R^+$, where $t$ is the estimate for $\theta$. So $l(t, \theta)$ is high for poor values of $t$ and zero for $t=\theta$. Now we want to compare statistics $T_1$ and $T_2$. One is clearly the winner if the loss function is less or equal than the other for all samples. If that's not the case, we cannot say which one is better. In other words, $T_1$ may be better than $T_2$ in some subset of sample space, but $T_2$ may be better than $T_1$ in another subset. To remove the dependency on sample space, we may take the average value over it. That's the risk function. Now, suppose $T_1$ is better than $T_2$ in average. $T_2$ may be better than $T_1$ in certain circumstances yet! $T_2$ mat be better than $T_1$ for some values of $\theta \in \Theta_1 \subset \Theta$, yet worse in average! To further remove the dependency on $\Theta$ is to set a priori over $\Theta$ - this is the Bayesian approach. Here, we set 'importance' over $\Theta$: more reasonable values of $\theta$ are more important, since they're more likely to be found in reallity. In a nutshell, I think we consider the risk function the way it is because it removes dependency on information, in a setting where we are making decision before we gather it. In complementation of @shadowtalker's answer, it's important to notice that sometimes (like @shadowtalker suggested on heavy-tailed distributions) expectation is not sufficient to summarise a random variable (though being a good "descriptor"). In those cases, we may need variance, skewness or kurtosis. Also, other central measure of tendendy as median are very useful in nonparametric statistcis for instance. Alhough historicaly theory was developed first for pararmetric statistics, where expected value has more appeal.
Why is the risk function defined to be the expectation of loss function? My intuition about the topic: In a statistical parametric setting, which is in Desion Theory bounds, we'd like to estime, say, $\theta \in \Theta$ in the best way possible, by choosing a function of t
46,519
How to build a predictive model when more levels of a categorical predictor are possible than appear in the training data
Categorical features that can't be fully enumerated are failure-prone The challenge that you've discovered is a natural consequence of how you've organized your research project: your model has no generalizable information about new file paths or new names of .exe files. This theme is very common -- suppose you're trying to predict credit default using a unique identifier such as a person's social security number. You'll find that you can do really well on your training data by assigning a risk to each SSN. However, when you have new SSNs which are not in the training data, the model has no relevant information to work with. Or, we can extend this analogy to the malware context and just have a lookup table and declare some file as malware when the sha256 hash of the file matches a known malware sample: clearly this will have problems whenever (1) someone makes a new malware file that doesn't have a sha256 matching an existing known malware sample or (2) someone makes a malware file that has the same hash as a known clean sample. The conceptual model is also a security flaw From a security standpoint, there's a conceptual flaw with this approach. Whenever a malware file is located in a directory which your model thinks is clean, with a name that the model thinks is clean, the malware will evade detection. Instead, use generalizable features for static analysis A more robust approach would take various measurements from a corpus of .exe files and attempt to learn a model based on those features. This is the most common approach for modern machine learning applications applied to malware detection. An open-source example of such a feature extraction engine is EMBER, by Hyrum S. Anderson & Phil Roth. The EMBER paper outlines a number of generalizable features for malware detection in PE files. Of course if you're representing software files as fixed-length feature vectors, then you can use any standard machine learning model for tabular data (logistic regression, svm, random-forest, xgboost, etc.), not solely neural networks. Hyrum S. Anderson & Phil Roth. EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models A less-common approach is to "eat the whole .exe" by having the a neural network ingest the entire .exe binary and make decisions based on the binary sequence, or byte-encoded sequence. Usually this involves a combination of recurrent and convolutional network structures. Edward Raff, Jon Barker, Jared Sylvester, Robert Brandon, Bryan Catanzaro, Charles Nicholas, "Malware Detection by Eating a Whole EXE" Scott Coull, Christopher Gardner, "What are Deep Neural Networks Learning About Malware?" Right now, hand-crafted features for malware detection are state-of-the-art. However, I wouldn't be surprised if some clever researchers can come up with a combination of a nice architecture and data augmentation strategy which can make a feature-free neural network out-perform hand-crafted feature vectors. More generically, the advice at The suggestions at Encoding of categorical variables with high cardinality and Principled way of collapsing categorical variables with many levels? may also be helpful.
How to build a predictive model when more levels of a categorical predictor are possible than appear
Categorical features that can't be fully enumerated are failure-prone The challenge that you've discovered is a natural consequence of how you've organized your research project: your model has no gen
How to build a predictive model when more levels of a categorical predictor are possible than appear in the training data Categorical features that can't be fully enumerated are failure-prone The challenge that you've discovered is a natural consequence of how you've organized your research project: your model has no generalizable information about new file paths or new names of .exe files. This theme is very common -- suppose you're trying to predict credit default using a unique identifier such as a person's social security number. You'll find that you can do really well on your training data by assigning a risk to each SSN. However, when you have new SSNs which are not in the training data, the model has no relevant information to work with. Or, we can extend this analogy to the malware context and just have a lookup table and declare some file as malware when the sha256 hash of the file matches a known malware sample: clearly this will have problems whenever (1) someone makes a new malware file that doesn't have a sha256 matching an existing known malware sample or (2) someone makes a malware file that has the same hash as a known clean sample. The conceptual model is also a security flaw From a security standpoint, there's a conceptual flaw with this approach. Whenever a malware file is located in a directory which your model thinks is clean, with a name that the model thinks is clean, the malware will evade detection. Instead, use generalizable features for static analysis A more robust approach would take various measurements from a corpus of .exe files and attempt to learn a model based on those features. This is the most common approach for modern machine learning applications applied to malware detection. An open-source example of such a feature extraction engine is EMBER, by Hyrum S. Anderson & Phil Roth. The EMBER paper outlines a number of generalizable features for malware detection in PE files. Of course if you're representing software files as fixed-length feature vectors, then you can use any standard machine learning model for tabular data (logistic regression, svm, random-forest, xgboost, etc.), not solely neural networks. Hyrum S. Anderson & Phil Roth. EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models A less-common approach is to "eat the whole .exe" by having the a neural network ingest the entire .exe binary and make decisions based on the binary sequence, or byte-encoded sequence. Usually this involves a combination of recurrent and convolutional network structures. Edward Raff, Jon Barker, Jared Sylvester, Robert Brandon, Bryan Catanzaro, Charles Nicholas, "Malware Detection by Eating a Whole EXE" Scott Coull, Christopher Gardner, "What are Deep Neural Networks Learning About Malware?" Right now, hand-crafted features for malware detection are state-of-the-art. However, I wouldn't be surprised if some clever researchers can come up with a combination of a nice architecture and data augmentation strategy which can make a feature-free neural network out-perform hand-crafted feature vectors. More generically, the advice at The suggestions at Encoding of categorical variables with high cardinality and Principled way of collapsing categorical variables with many levels? may also be helpful.
How to build a predictive model when more levels of a categorical predictor are possible than appear Categorical features that can't be fully enumerated are failure-prone The challenge that you've discovered is a natural consequence of how you've organized your research project: your model has no gen
46,520
Time series analysis textbooks for mathematicians
I recommend Time Series: Theory and Methods by Brockwell & Davis. They have a strong focus on ARIMA models and related topics (stationarity, autocorrelation etc.), and they are as rigorous as you would expect from a book that appeared in the Springer Series in Statistics. They include exercises for self-study - without solutions, though.
Time series analysis textbooks for mathematicians
I recommend Time Series: Theory and Methods by Brockwell & Davis. They have a strong focus on ARIMA models and related topics (stationarity, autocorrelation etc.), and they are as rigorous as you woul
Time series analysis textbooks for mathematicians I recommend Time Series: Theory and Methods by Brockwell & Davis. They have a strong focus on ARIMA models and related topics (stationarity, autocorrelation etc.), and they are as rigorous as you would expect from a book that appeared in the Springer Series in Statistics. They include exercises for self-study - without solutions, though.
Time series analysis textbooks for mathematicians I recommend Time Series: Theory and Methods by Brockwell & Davis. They have a strong focus on ARIMA models and related topics (stationarity, autocorrelation etc.), and they are as rigorous as you woul
46,521
Time series analysis textbooks for mathematicians
I learned Time Series from Time Series Analysis and Its Applications by R.H. Shumway and D.S. Stoffer. The textbook has its own website, where you can also find accompanying R packages, and a stripped down version of the textbook and the actual, statistically and mathematically rigorous version. If you have access to Springer Link, you can download the Springer markup version for free. The author version is available for free on the textbook website. It also has some exercises in the end of each chapter but with no solution guide. Some answers and solutions can be found on google or you can ask them here :)
Time series analysis textbooks for mathematicians
I learned Time Series from Time Series Analysis and Its Applications by R.H. Shumway and D.S. Stoffer. The textbook has its own website, where you can also find accompanying R packages, and a stripped
Time series analysis textbooks for mathematicians I learned Time Series from Time Series Analysis and Its Applications by R.H. Shumway and D.S. Stoffer. The textbook has its own website, where you can also find accompanying R packages, and a stripped down version of the textbook and the actual, statistically and mathematically rigorous version. If you have access to Springer Link, you can download the Springer markup version for free. The author version is available for free on the textbook website. It also has some exercises in the end of each chapter but with no solution guide. Some answers and solutions can be found on google or you can ask them here :)
Time series analysis textbooks for mathematicians I learned Time Series from Time Series Analysis and Its Applications by R.H. Shumway and D.S. Stoffer. The textbook has its own website, where you can also find accompanying R packages, and a stripped
46,522
How do we know $X'X$ is nonsingular in OLS?
It's a property of the $\text{rank}$ operator when its used on real matrices $\mathbf{A}$: $$ \text{rank}(\mathbf{A}) = \text{rank}(\mathbf{A}') = \text{rank}(\mathbf{A}'\mathbf{A}) = \text{rank}(\mathbf{A}\mathbf{A}'). $$ In your case, the data matrix $\mathbf{X} \in \mathbb{R}^{n \times p}$ is usually tall and skinny ($n > p$), so the rank of everything is the number of linearly independent columns/predictors/covariates/independent variables. If everything is linearly independent $\text{rank}(\mathbf{X}) = p$, and so you have $\mathbf{X}'\mathbf{X}$ is invertible. If you have collinearity, or columns that can be written as linear combinations of others, then $\text{rank}(\mathbf{X}) < p$, and you cannot find a unique inverse for $\mathbf{X}'\mathbf{X}$ (you can, however, find generalized inverses for it).
How do we know $X'X$ is nonsingular in OLS?
It's a property of the $\text{rank}$ operator when its used on real matrices $\mathbf{A}$: $$ \text{rank}(\mathbf{A}) = \text{rank}(\mathbf{A}') = \text{rank}(\mathbf{A}'\mathbf{A}) = \text{rank}(\mat
How do we know $X'X$ is nonsingular in OLS? It's a property of the $\text{rank}$ operator when its used on real matrices $\mathbf{A}$: $$ \text{rank}(\mathbf{A}) = \text{rank}(\mathbf{A}') = \text{rank}(\mathbf{A}'\mathbf{A}) = \text{rank}(\mathbf{A}\mathbf{A}'). $$ In your case, the data matrix $\mathbf{X} \in \mathbb{R}^{n \times p}$ is usually tall and skinny ($n > p$), so the rank of everything is the number of linearly independent columns/predictors/covariates/independent variables. If everything is linearly independent $\text{rank}(\mathbf{X}) = p$, and so you have $\mathbf{X}'\mathbf{X}$ is invertible. If you have collinearity, or columns that can be written as linear combinations of others, then $\text{rank}(\mathbf{X}) < p$, and you cannot find a unique inverse for $\mathbf{X}'\mathbf{X}$ (you can, however, find generalized inverses for it).
How do we know $X'X$ is nonsingular in OLS? It's a property of the $\text{rank}$ operator when its used on real matrices $\mathbf{A}$: $$ \text{rank}(\mathbf{A}) = \text{rank}(\mathbf{A}') = \text{rank}(\mathbf{A}'\mathbf{A}) = \text{rank}(\mat
46,523
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR)
The probability that $K = k$ is given by $$ p(k) = \frac{\binom{m}{k} f(n,k)}{m^n} $$ where $f(n,k)$ is the number of sequences consisting of only the integers $i = 1, \ldots, k$ of length $n$ in which each $i$ occurs at least once. To see this, note that we want the probability that exactly $k$ unique entries appear in a sequence of $n$ draws from a discrete uniform on $1, \ldots, m$. We can get this in two steps by (1) selecting which $k$ entries of the $m$ will appear and (2) choosing a sequence in which each appears at least once. The total number of sequences of length $n$ is $m^n$ which gives the denominator. If one considers the Stirling numbers of the second kind to be "closed form" then $f(n,k)$ can be simplified as $$ f(n,k) = S(n,k) k! $$ Recall that $S(n,k)$ counts the number of ways to partition $n$ objects into $k$ non-empty equivalence classes. So, we simply partition each of our $n$ draws into $k$ classes, such that the entries in each equivalence class will be associated to the same $i \in \{1,\ldots,k\}$. Next, we need to actually associated each $i$ to the equivalence classes, and there are $k!$ ways to do this. Simplifying, we get $$ p(k) = \frac{m! S(n,k)}{(m-k)! m^n} $$ for the final answer. This should be as simple as the answer can possibly get, because Stirling numbers cannot be simplified. Some R code to verify that this is correct, Stirling code taken from here: Stirling2 <- function(n,m) { ## Purpose: Stirling Numbers of the 2-nd kind ## S^{(m)}_n = number of ways of partitioning a set of ## $n$ elements into $m$ non-empty subsets ## Author: Martin Maechler, Date: May 28 1992, 23:42 ## ---------------------------------------------------------------- ## Abramowitz/Stegun: 24,1,4 (p. 824-5 ; Table 24.4, p.835) ## Closed Form : p.824 "C." ## ---------------------------------------------------------------- if (0 > m || m > n) stop("'m' must be in 0..n !") k <- 0:m sig <- rep(c(1,-1)*(-1)^m, length= m+1)# 1 for m=0; -1 1 (m=1) ## The following gives rounding errors for (25,5) : ## r <- sum( sig * k^n /(gamma(k+1)*gamma(m+1-k)) ) ga <- gamma(k+1) round(sum( sig * k^n /(ga * rev(ga)))) } set.seed(123) n <- 7 m <- 5 f <- function(k) { choose(m,k) * Stirling2(n,k) * factorial(k) / m^n } foo <- t(replicate(100000, sample(1:m, n, replace = TRUE))) foo2 <- apply(foo, 1, function(x) length(unique(x))) f_hat <- mean(foo2 == 3) f_hat + c(-1,0,1) * 1.96 * sqrt(f_hat * (1 - f_hat) / 100000) ## [1] 0.2276407 0.2302500 0.2328593 f(3) ## [1] 0.231168 sum(Vectorize(f)(1:m)) ## [1] 1
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR)
The probability that $K = k$ is given by $$ p(k) = \frac{\binom{m}{k} f(n,k)}{m^n} $$ where $f(n,k)$ is the number of sequences consisting of only the integers $i = 1, \ldots, k$ of length $n$ in whi
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR) The probability that $K = k$ is given by $$ p(k) = \frac{\binom{m}{k} f(n,k)}{m^n} $$ where $f(n,k)$ is the number of sequences consisting of only the integers $i = 1, \ldots, k$ of length $n$ in which each $i$ occurs at least once. To see this, note that we want the probability that exactly $k$ unique entries appear in a sequence of $n$ draws from a discrete uniform on $1, \ldots, m$. We can get this in two steps by (1) selecting which $k$ entries of the $m$ will appear and (2) choosing a sequence in which each appears at least once. The total number of sequences of length $n$ is $m^n$ which gives the denominator. If one considers the Stirling numbers of the second kind to be "closed form" then $f(n,k)$ can be simplified as $$ f(n,k) = S(n,k) k! $$ Recall that $S(n,k)$ counts the number of ways to partition $n$ objects into $k$ non-empty equivalence classes. So, we simply partition each of our $n$ draws into $k$ classes, such that the entries in each equivalence class will be associated to the same $i \in \{1,\ldots,k\}$. Next, we need to actually associated each $i$ to the equivalence classes, and there are $k!$ ways to do this. Simplifying, we get $$ p(k) = \frac{m! S(n,k)}{(m-k)! m^n} $$ for the final answer. This should be as simple as the answer can possibly get, because Stirling numbers cannot be simplified. Some R code to verify that this is correct, Stirling code taken from here: Stirling2 <- function(n,m) { ## Purpose: Stirling Numbers of the 2-nd kind ## S^{(m)}_n = number of ways of partitioning a set of ## $n$ elements into $m$ non-empty subsets ## Author: Martin Maechler, Date: May 28 1992, 23:42 ## ---------------------------------------------------------------- ## Abramowitz/Stegun: 24,1,4 (p. 824-5 ; Table 24.4, p.835) ## Closed Form : p.824 "C." ## ---------------------------------------------------------------- if (0 > m || m > n) stop("'m' must be in 0..n !") k <- 0:m sig <- rep(c(1,-1)*(-1)^m, length= m+1)# 1 for m=0; -1 1 (m=1) ## The following gives rounding errors for (25,5) : ## r <- sum( sig * k^n /(gamma(k+1)*gamma(m+1-k)) ) ga <- gamma(k+1) round(sum( sig * k^n /(ga * rev(ga)))) } set.seed(123) n <- 7 m <- 5 f <- function(k) { choose(m,k) * Stirling2(n,k) * factorial(k) / m^n } foo <- t(replicate(100000, sample(1:m, n, replace = TRUE))) foo2 <- apply(foo, 1, function(x) length(unique(x))) f_hat <- mean(foo2 == 3) f_hat + c(-1,0,1) * 1.96 * sqrt(f_hat * (1 - f_hat) / 100000) ## [1] 0.2276407 0.2302500 0.2328593 f(3) ## [1] 0.231168 sum(Vectorize(f)(1:m)) ## [1] 1
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR) The probability that $K = k$ is given by $$ p(k) = \frac{\binom{m}{k} f(n,k)}{m^n} $$ where $f(n,k)$ is the number of sequences consisting of only the integers $i = 1, \ldots, k$ of length $n$ in whi
46,524
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR)
Having now done some more study on this problem I have found that this is actually a distribution that has received quite a lot of attention in the mathematical literature. The general problem is called the "classical occupancy problem" and the resulting distribution of the number of occupied groups is called the "occupancy distribution". This distribution has been studied in detail (see e.g., Johnson and Kotz 1977; Kolchin et al 1978). The mass function is: $$p_K(k) = \frac{(m)_k \cdot S(n,k)}{m^n} \quad \quad \quad \text{for all } 1 \leqslant K \leqslant \min (m,n),$$ where the values $(m)_k = m (m-1) \cdots (m-k+1)$ are the falling factorials. This distribution is included in some books on discrete distributions, but it is more obscure than the standard discrete distributions, and as a result, it is not well-known. Nevertheless, the distribution has been studied in great detail and its moments and generating functions are known. Moments: The form of the distribution leads to a simple formula for the expected falling factorials: $$\mathbb{E}((K)_r) = (m)_r \Big( \frac{m-r}{m} \Big)^n.$$ Since $(K)_r$ is a polynomial of degree $r$ in $K$, this leads to corresponding results for the raw and central moments. These get very messy for the higher-order moments, but the formulae for the mean and variance are fairly simple: $$\begin{equation} \begin{aligned} \mathbb{E}(K) &= m \Bigg[ 1 - \Big( \frac{m-1}{m} \Big)^n \Bigg], \\[6pt] \mathbb{V}(K) &= m \Bigg[ (m-1) \Big( \frac{m-2}{m} \Big)^n + \Big( \frac{m-1}{m} \Big)^n - \Big( \frac{m-1}{m} \Big)^{2n} \Bigg]. \\[6pt] \end{aligned} \end{equation}$$ Asymptotic results: There are various well-known limiting results that look at the asymptotic form of the distribution as $m \rightarrow \infty$ and $n \rightarrow \infty$. Results depend on the "domain of convergence", but for a broad limiting domain the distribution of the number of empty cells converges to either a normal distribution or a Poisson distribution (see Kolchin et al 1978, Ch 4). For finite parameter values the Poisson approximation suffers from the fact that it constrains the variance, so it it a poor approximation except for very large $n$. Nevertheless, for very large $n$ we have: $$n-K \sim \text{Pois}(m \cdot e^{-n/m}).$$ The normal approximation is generally a preferable approximation, since it allows freedom of the mean and variance. For large $n$ and $m$ we have the approximation: $$K \sim \text{N}(\mu = \mathbb{E}(K), \sigma^2 = \mathbb{V}(K)).$$ References Johnson, N.L. and Kotz, S. (1977) Urn Models and their Applications. John Wiley and Sons: New York. Kolchin, V.F., Sevast'yanov, B.A. and Christyakov, V.P. (1978) Random Allocations. John Wiley and Sons: New York.
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR)
Having now done some more study on this problem I have found that this is actually a distribution that has received quite a lot of attention in the mathematical literature. The general problem is cal
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR) Having now done some more study on this problem I have found that this is actually a distribution that has received quite a lot of attention in the mathematical literature. The general problem is called the "classical occupancy problem" and the resulting distribution of the number of occupied groups is called the "occupancy distribution". This distribution has been studied in detail (see e.g., Johnson and Kotz 1977; Kolchin et al 1978). The mass function is: $$p_K(k) = \frac{(m)_k \cdot S(n,k)}{m^n} \quad \quad \quad \text{for all } 1 \leqslant K \leqslant \min (m,n),$$ where the values $(m)_k = m (m-1) \cdots (m-k+1)$ are the falling factorials. This distribution is included in some books on discrete distributions, but it is more obscure than the standard discrete distributions, and as a result, it is not well-known. Nevertheless, the distribution has been studied in great detail and its moments and generating functions are known. Moments: The form of the distribution leads to a simple formula for the expected falling factorials: $$\mathbb{E}((K)_r) = (m)_r \Big( \frac{m-r}{m} \Big)^n.$$ Since $(K)_r$ is a polynomial of degree $r$ in $K$, this leads to corresponding results for the raw and central moments. These get very messy for the higher-order moments, but the formulae for the mean and variance are fairly simple: $$\begin{equation} \begin{aligned} \mathbb{E}(K) &= m \Bigg[ 1 - \Big( \frac{m-1}{m} \Big)^n \Bigg], \\[6pt] \mathbb{V}(K) &= m \Bigg[ (m-1) \Big( \frac{m-2}{m} \Big)^n + \Big( \frac{m-1}{m} \Big)^n - \Big( \frac{m-1}{m} \Big)^{2n} \Bigg]. \\[6pt] \end{aligned} \end{equation}$$ Asymptotic results: There are various well-known limiting results that look at the asymptotic form of the distribution as $m \rightarrow \infty$ and $n \rightarrow \infty$. Results depend on the "domain of convergence", but for a broad limiting domain the distribution of the number of empty cells converges to either a normal distribution or a Poisson distribution (see Kolchin et al 1978, Ch 4). For finite parameter values the Poisson approximation suffers from the fact that it constrains the variance, so it it a poor approximation except for very large $n$. Nevertheless, for very large $n$ we have: $$n-K \sim \text{Pois}(m \cdot e^{-n/m}).$$ The normal approximation is generally a preferable approximation, since it allows freedom of the mean and variance. For large $n$ and $m$ we have the approximation: $$K \sim \text{N}(\mu = \mathbb{E}(K), \sigma^2 = \mathbb{V}(K)).$$ References Johnson, N.L. and Kotz, S. (1977) Urn Models and their Applications. John Wiley and Sons: New York. Kolchin, V.F., Sevast'yanov, B.A. and Christyakov, V.P. (1978) Random Allocations. John Wiley and Sons: New York.
Distribution of number of objects in Simple Random Sampling with Replacement (SRSWR) Having now done some more study on this problem I have found that this is actually a distribution that has received quite a lot of attention in the mathematical literature. The general problem is cal
46,525
Random process not so random after all (deterministic)
Suppose that after $T$ iterations, your process should end up at a predefined value $m$. You can first simulate a process $f_t$ with whatever characteristics you want and then modify it as follows: $$ f_t \mapsto f_t + \frac{t}{T}(m-f_T) $$ Note that this requires that we know the end value $f_T$ of the unconstrained process when we modify it at time $t$. Here is an example with $T=1000$ and $m=2$: target <- 2 n_steps <- 1000 set.seed(1) process_raw <- cumsum(rnorm(n_steps+1)) process <- process_raw + (0:n_steps)/n_steps * (target-tail(process_raw,1)) plot(process,type="l") abline(h=target,lty=2) If you need something that can be calculated at time $t$ without "looking ahead", you can use $f_t$ instead of $f_T$ in the above formula. $$ f_t \mapsto f_t + \frac{t}{T}(m-f_t) $$ However, then your process will have lower and lower variance as $t\to T$: process <- process_raw + (0:n_steps)/n_steps * (target-process_raw) plot(process,type="l") abline(h=target,lty=2)
Random process not so random after all (deterministic)
Suppose that after $T$ iterations, your process should end up at a predefined value $m$. You can first simulate a process $f_t$ with whatever characteristics you want and then modify it as follows: $$
Random process not so random after all (deterministic) Suppose that after $T$ iterations, your process should end up at a predefined value $m$. You can first simulate a process $f_t$ with whatever characteristics you want and then modify it as follows: $$ f_t \mapsto f_t + \frac{t}{T}(m-f_T) $$ Note that this requires that we know the end value $f_T$ of the unconstrained process when we modify it at time $t$. Here is an example with $T=1000$ and $m=2$: target <- 2 n_steps <- 1000 set.seed(1) process_raw <- cumsum(rnorm(n_steps+1)) process <- process_raw + (0:n_steps)/n_steps * (target-tail(process_raw,1)) plot(process,type="l") abline(h=target,lty=2) If you need something that can be calculated at time $t$ without "looking ahead", you can use $f_t$ instead of $f_T$ in the above formula. $$ f_t \mapsto f_t + \frac{t}{T}(m-f_t) $$ However, then your process will have lower and lower variance as $t\to T$: process <- process_raw + (0:n_steps)/n_steps * (target-process_raw) plot(process,type="l") abline(h=target,lty=2)
Random process not so random after all (deterministic) Suppose that after $T$ iterations, your process should end up at a predefined value $m$. You can first simulate a process $f_t$ with whatever characteristics you want and then modify it as follows: $$
46,526
Random process not so random after all (deterministic)
What you are asking for is called a Brownian bridge ; there is an answer elsewhere on CV that asks how to convert a Brownian bridge into a Brownian "excursion": Simulating a Brownian Excursion using a Brownian Bridge? . That question uses the rbridge() function from the e1071 package: library(e1071) set.seed(101) r <- rbridge() ## default: end time=1, frequency=1000 plot(r) abline(h=0,col="red") The underlying code for rbridge is pretty simple: z <- rwiener(end = end, frequency = frequency) ts(z - time(z) * as.vector(z)[frequency], start = 1/frequency, frequency = frequency) Stripped of its extra details, this corresponds to $B(t) = W(t) - t/T \cdot W(T)$, where $W$ is a Wiener process and $T$ is the ending time, as suggested in the Wikipedia article. This simulates a Brownian bridge that starts and ends at zero; I would suggest adding a linear trend if you want to modify the starting and ending points (as suggested by the "general case" section of the Wikipedia article). An ensemble: rr <- replicate(500,rbridge()) matplot(rr,type="l",col=adjustcolor("black",alpha=0.05)) A comment on a previous version of this answer argued that the volatility would not be constant; based on a numerical experiment (easier than thinking), I believe this is false - the volatility is constant (we can also see this by looking at the $B(t)$ expression above ... However, a careful observer should be able to detect that something is going on, because $\Delta x$ will be biased toward the starting point (similar to, but not the same as, an Ornstein-Uhlenbeck process).
Random process not so random after all (deterministic)
What you are asking for is called a Brownian bridge ; there is an answer elsewhere on CV that asks how to convert a Brownian bridge into a Brownian "excursion": Simulating a Brownian Excursion using
Random process not so random after all (deterministic) What you are asking for is called a Brownian bridge ; there is an answer elsewhere on CV that asks how to convert a Brownian bridge into a Brownian "excursion": Simulating a Brownian Excursion using a Brownian Bridge? . That question uses the rbridge() function from the e1071 package: library(e1071) set.seed(101) r <- rbridge() ## default: end time=1, frequency=1000 plot(r) abline(h=0,col="red") The underlying code for rbridge is pretty simple: z <- rwiener(end = end, frequency = frequency) ts(z - time(z) * as.vector(z)[frequency], start = 1/frequency, frequency = frequency) Stripped of its extra details, this corresponds to $B(t) = W(t) - t/T \cdot W(T)$, where $W$ is a Wiener process and $T$ is the ending time, as suggested in the Wikipedia article. This simulates a Brownian bridge that starts and ends at zero; I would suggest adding a linear trend if you want to modify the starting and ending points (as suggested by the "general case" section of the Wikipedia article). An ensemble: rr <- replicate(500,rbridge()) matplot(rr,type="l",col=adjustcolor("black",alpha=0.05)) A comment on a previous version of this answer argued that the volatility would not be constant; based on a numerical experiment (easier than thinking), I believe this is false - the volatility is constant (we can also see this by looking at the $B(t)$ expression above ... However, a careful observer should be able to detect that something is going on, because $\Delta x$ will be biased toward the starting point (similar to, but not the same as, an Ornstein-Uhlenbeck process).
Random process not so random after all (deterministic) What you are asking for is called a Brownian bridge ; there is an answer elsewhere on CV that asks how to convert a Brownian bridge into a Brownian "excursion": Simulating a Brownian Excursion using
46,527
UMVU estimator for non-linear transformation of a parameter
Your final answer is not quite right. The conclusion due to the sample mean $\bar X$ being only sufficient for $\mu$ also looks faulty. Recall that $T(X_1,X_2,\cdots,X_n)=\sum_{i=1}^n X_i$ is a complete sufficient statistic for $\mu$. It is easy to see this if you work with the exponential family setup. Now we know the distribution of $\bar X$, namely $\bar X\sim\mathcal N\left(\mu,\frac{1}{n}\right)$. From the moment generating function of a univariate normal distribution, it follows that $$E_{\mu}(e^{t\bar X})=\exp\left(\mu t+\frac{t^2}{2n}\right)$$ That is, $$E_{\mu}(e^{t\bar X-t^2/2n})=e^{\mu t}$$ So an unbiased estimator of $e^{\mu t}$ is \begin{align}h(T)&=\exp\left(t\bar X-t^2/2n\right) \\&=\exp\left(T\frac{t}{n}-\frac{t^2}{2n}\right) \end{align} $h(T)$ is a function of the complete sufficient statistic $T$. Hence by the Lehmann-Scheffe theorem, $h(T)$ is the UMVUE of $e^{\mu t}$. You ask how to approach problems regarding estimation of a non-linear transformation of the parameter of interest. I think this is pretty much the same as estimating any function of the parameter. The usual tools to find a UMVUE (if it exists) are the Rao-Blackwell theorem and/or the Lehmann-Scheffe theorem. One needs to find a complete sufficient statistic ($T$, say), if it exists, for some $\theta$ (which may well be a vector) that parametrises the given population distribution. The first step is to find an unbiased estimator (if it exists) of $\theta$. Now if this unbiased estimator is a function of the complete sufficient statistic, then it will be the UMVUE of $\theta$. This is a corollary of the Lehmann-Scheffe theorem. Even if the unbiased estimator is not a function of the complete sufficient statistic, we have the Rao-Blackwell theorem at hand. This says that if we take any trivial unbiased estimator ($h$, say) of $\theta$, then the conditional expectation $E(h\mid T)$ is the UMVUE of $\theta$. Finding this conditional expectation explicitly might not be an easy task in general. The remark by @CagdasOzgenc in the comments is worth noticing. If $U$ is unbiased for $\theta$, then we do not expect $g(U)$ to be unbiased for $g(\theta)$ for any $g$. That approach would just not work in general. One way to see this is Jensen's inequality: $E(g(U))\ge g(E(U))$ for convex $g$ (inequality reverses when $g$ is concave). Note that equality holds in Jensen's inequality if $g$ is a constant function or if $g$ is an affine function.
UMVU estimator for non-linear transformation of a parameter
Your final answer is not quite right. The conclusion due to the sample mean $\bar X$ being only sufficient for $\mu$ also looks faulty. Recall that $T(X_1,X_2,\cdots,X_n)=\sum_{i=1}^n X_i$ is a comple
UMVU estimator for non-linear transformation of a parameter Your final answer is not quite right. The conclusion due to the sample mean $\bar X$ being only sufficient for $\mu$ also looks faulty. Recall that $T(X_1,X_2,\cdots,X_n)=\sum_{i=1}^n X_i$ is a complete sufficient statistic for $\mu$. It is easy to see this if you work with the exponential family setup. Now we know the distribution of $\bar X$, namely $\bar X\sim\mathcal N\left(\mu,\frac{1}{n}\right)$. From the moment generating function of a univariate normal distribution, it follows that $$E_{\mu}(e^{t\bar X})=\exp\left(\mu t+\frac{t^2}{2n}\right)$$ That is, $$E_{\mu}(e^{t\bar X-t^2/2n})=e^{\mu t}$$ So an unbiased estimator of $e^{\mu t}$ is \begin{align}h(T)&=\exp\left(t\bar X-t^2/2n\right) \\&=\exp\left(T\frac{t}{n}-\frac{t^2}{2n}\right) \end{align} $h(T)$ is a function of the complete sufficient statistic $T$. Hence by the Lehmann-Scheffe theorem, $h(T)$ is the UMVUE of $e^{\mu t}$. You ask how to approach problems regarding estimation of a non-linear transformation of the parameter of interest. I think this is pretty much the same as estimating any function of the parameter. The usual tools to find a UMVUE (if it exists) are the Rao-Blackwell theorem and/or the Lehmann-Scheffe theorem. One needs to find a complete sufficient statistic ($T$, say), if it exists, for some $\theta$ (which may well be a vector) that parametrises the given population distribution. The first step is to find an unbiased estimator (if it exists) of $\theta$. Now if this unbiased estimator is a function of the complete sufficient statistic, then it will be the UMVUE of $\theta$. This is a corollary of the Lehmann-Scheffe theorem. Even if the unbiased estimator is not a function of the complete sufficient statistic, we have the Rao-Blackwell theorem at hand. This says that if we take any trivial unbiased estimator ($h$, say) of $\theta$, then the conditional expectation $E(h\mid T)$ is the UMVUE of $\theta$. Finding this conditional expectation explicitly might not be an easy task in general. The remark by @CagdasOzgenc in the comments is worth noticing. If $U$ is unbiased for $\theta$, then we do not expect $g(U)$ to be unbiased for $g(\theta)$ for any $g$. That approach would just not work in general. One way to see this is Jensen's inequality: $E(g(U))\ge g(E(U))$ for convex $g$ (inequality reverses when $g$ is concave). Note that equality holds in Jensen's inequality if $g$ is a constant function or if $g$ is an affine function.
UMVU estimator for non-linear transformation of a parameter Your final answer is not quite right. The conclusion due to the sample mean $\bar X$ being only sufficient for $\mu$ also looks faulty. Recall that $T(X_1,X_2,\cdots,X_n)=\sum_{i=1}^n X_i$ is a comple
46,528
UMVU estimator for non-linear transformation of a parameter
A more general perspective on the question is that most non-linear transforms of parameters $\theta$ associated with an unbiased estimator cannot be unbiasedly estimated. There are indeed many instances in the literature about the impossibility to find an unbiased estimator: "A Class of Parameter Functions for Which the Unbiased Estimator Does Not Exist" by Shande Chen, IMS Lecture Notes-Monograph Series Vol. 43, Crossing Boundaries: Statistical Essays in Honor of Jack Hall (2003), pp. 159-164 "On the Non-Existence of Unbiased Estimators in Constrained Estimation Problems" by Anelia Somekh-Baruch, Amir Leshem, Venkatesh Saligrama (2016), arXiv:1609.07415 "On nonnegative unbiased estimators", by Pierre E. Jacob, Alexandre H. Thiery (2013)11, arXiv:1309.6473 Lehmann. E.L. and Casella, G. (Theory of Point Estimation, 1999) have a section [2.4] on this issue, including the case of the standard deviation $\sigma$ for which no unbiased estimator based on a fixed sample size exists. And an extract from C.R. Rao's piece on Erich Lehmann's contribution [9] to the topic, in Selected Works of E.L. Lehmann: On the side, note that sufficiency and completeness are notions that remain invariant under bijective changes of parameters.
UMVU estimator for non-linear transformation of a parameter
A more general perspective on the question is that most non-linear transforms of parameters $\theta$ associated with an unbiased estimator cannot be unbiasedly estimated. There are indeed many in
UMVU estimator for non-linear transformation of a parameter A more general perspective on the question is that most non-linear transforms of parameters $\theta$ associated with an unbiased estimator cannot be unbiasedly estimated. There are indeed many instances in the literature about the impossibility to find an unbiased estimator: "A Class of Parameter Functions for Which the Unbiased Estimator Does Not Exist" by Shande Chen, IMS Lecture Notes-Monograph Series Vol. 43, Crossing Boundaries: Statistical Essays in Honor of Jack Hall (2003), pp. 159-164 "On the Non-Existence of Unbiased Estimators in Constrained Estimation Problems" by Anelia Somekh-Baruch, Amir Leshem, Venkatesh Saligrama (2016), arXiv:1609.07415 "On nonnegative unbiased estimators", by Pierre E. Jacob, Alexandre H. Thiery (2013)11, arXiv:1309.6473 Lehmann. E.L. and Casella, G. (Theory of Point Estimation, 1999) have a section [2.4] on this issue, including the case of the standard deviation $\sigma$ for which no unbiased estimator based on a fixed sample size exists. And an extract from C.R. Rao's piece on Erich Lehmann's contribution [9] to the topic, in Selected Works of E.L. Lehmann: On the side, note that sufficiency and completeness are notions that remain invariant under bijective changes of parameters.
UMVU estimator for non-linear transformation of a parameter A more general perspective on the question is that most non-linear transforms of parameters $\theta$ associated with an unbiased estimator cannot be unbiasedly estimated. There are indeed many in
46,529
What's the value of $\text{cov}(x, x^TAx)$, when $x$ follows a normal distribution
Writing $$z=x-\mu,$$ we see that $z \sim \mathcal{N}(0,\Sigma).$ Using the bilinearity of the covariance operator repeatedly, make the substitution $x=z+\mu$ and (mindlessly) compute $$\eqalign{ \operatorname{Cov}(x, x^\prime A x) &= \operatorname{Cov}(z+\mu,\ (z+\mu)^\prime A (z+\mu))\\ &= \operatorname{Cov}(z,\ z^\prime A z + \mu^\prime A z + z^\prime A \mu + \mu^\prime A \mu) \\ &= \operatorname{Cov}(z, z^\prime A z) + \operatorname{Cov}(z, \mu^\prime A z) + \operatorname{Cov}(z, z^\prime A \mu) + 0. }$$ The first of those three terms must evaluate to $0$ because it is the expectation of a homogeneous odd-order polynomial in the components of $z.$ The symmetry of the distribution ($-z$ also has a $\mathcal{N}(0,\Sigma)$ distribution) shows this expectation equals its negative, whence--since it is finite--it can only be zero. For the second term use the identity (often taken as the definition) $$\operatorname{Cov}(u, v) = E(uv^\prime) - E(u)E(v)^\prime$$ for vector-valued random variables $u$ and $v$, whence (since $E(z)=0$) we obtain $$\operatorname{Cov}(z,\ \mu^\prime A z) = E(z\ (\mu^\prime A z)^\prime) = E(z\ z^\prime A^\prime \mu) = E(zz^\prime)A^\prime\mu = \Sigma A^\prime \mu.$$ For the third, note that $z^\prime A\mu$ is a $1\times 1$ matrix and therefore equals its own transpose, whence $$\operatorname{Cov}(z, z^\prime A\mu) = E(z\ z^\prime A\mu) = E(zz^\prime)A\mu = \Sigma A \mu.$$ Finally, the symmetry of $A$ means $A=A^\prime,$ entailing $$\operatorname{Cov}(x, x^\prime A x) = 0 + \Sigma A^\prime \mu + \Sigma A \mu + 0 = \Sigma(A^\prime+A)\mu = 2\Sigma A \mu.$$
What's the value of $\text{cov}(x, x^TAx)$, when $x$ follows a normal distribution
Writing $$z=x-\mu,$$ we see that $z \sim \mathcal{N}(0,\Sigma).$ Using the bilinearity of the covariance operator repeatedly, make the substitution $x=z+\mu$ and (mindlessly) compute $$\eqalign{ \ope
What's the value of $\text{cov}(x, x^TAx)$, when $x$ follows a normal distribution Writing $$z=x-\mu,$$ we see that $z \sim \mathcal{N}(0,\Sigma).$ Using the bilinearity of the covariance operator repeatedly, make the substitution $x=z+\mu$ and (mindlessly) compute $$\eqalign{ \operatorname{Cov}(x, x^\prime A x) &= \operatorname{Cov}(z+\mu,\ (z+\mu)^\prime A (z+\mu))\\ &= \operatorname{Cov}(z,\ z^\prime A z + \mu^\prime A z + z^\prime A \mu + \mu^\prime A \mu) \\ &= \operatorname{Cov}(z, z^\prime A z) + \operatorname{Cov}(z, \mu^\prime A z) + \operatorname{Cov}(z, z^\prime A \mu) + 0. }$$ The first of those three terms must evaluate to $0$ because it is the expectation of a homogeneous odd-order polynomial in the components of $z.$ The symmetry of the distribution ($-z$ also has a $\mathcal{N}(0,\Sigma)$ distribution) shows this expectation equals its negative, whence--since it is finite--it can only be zero. For the second term use the identity (often taken as the definition) $$\operatorname{Cov}(u, v) = E(uv^\prime) - E(u)E(v)^\prime$$ for vector-valued random variables $u$ and $v$, whence (since $E(z)=0$) we obtain $$\operatorname{Cov}(z,\ \mu^\prime A z) = E(z\ (\mu^\prime A z)^\prime) = E(z\ z^\prime A^\prime \mu) = E(zz^\prime)A^\prime\mu = \Sigma A^\prime \mu.$$ For the third, note that $z^\prime A\mu$ is a $1\times 1$ matrix and therefore equals its own transpose, whence $$\operatorname{Cov}(z, z^\prime A\mu) = E(z\ z^\prime A\mu) = E(zz^\prime)A\mu = \Sigma A \mu.$$ Finally, the symmetry of $A$ means $A=A^\prime,$ entailing $$\operatorname{Cov}(x, x^\prime A x) = 0 + \Sigma A^\prime \mu + \Sigma A \mu + 0 = \Sigma(A^\prime+A)\mu = 2\Sigma A \mu.$$
What's the value of $\text{cov}(x, x^TAx)$, when $x$ follows a normal distribution Writing $$z=x-\mu,$$ we see that $z \sim \mathcal{N}(0,\Sigma).$ Using the bilinearity of the covariance operator repeatedly, make the substitution $x=z+\mu$ and (mindlessly) compute $$\eqalign{ \ope
46,530
How do I transform a non-linear relationship to make it linear?
In this problem you have an explicit functional relationship between the two variables: $$y = \text{sgn}(x) (10^{4|x|}-1).$$ You can obtain a linear relationship between transformed variables by using: $$\text{sgn}(y) \log_{10}(1+|y|) = 4x.$$
How do I transform a non-linear relationship to make it linear?
In this problem you have an explicit functional relationship between the two variables: $$y = \text{sgn}(x) (10^{4|x|}-1).$$ You can obtain a linear relationship between transformed variables by usin
How do I transform a non-linear relationship to make it linear? In this problem you have an explicit functional relationship between the two variables: $$y = \text{sgn}(x) (10^{4|x|}-1).$$ You can obtain a linear relationship between transformed variables by using: $$\text{sgn}(y) \log_{10}(1+|y|) = 4x.$$
How do I transform a non-linear relationship to make it linear? In this problem you have an explicit functional relationship between the two variables: $$y = \text{sgn}(x) (10^{4|x|}-1).$$ You can obtain a linear relationship between transformed variables by usin
46,531
Interpreting logistic regression results when explanatory variable has multiple levels
The interpretation for categorical variables with more than 2 levels is very similar to the binary case you mention; for a $k$-level categorical variable, you will have $k-1$ regression coefficients each of which compare the odds of the outcome to the reference group. For the example you state, ethnicity (Caucasian, African-American, Hispanic, and Asian), let us assume your referent (baseline) group is African-American. Many software packages for logistic regressions will give you 3 Odds ratios (for a 4-level categorical predictor) once you run the regression. Let us quickly look at how this is done in R based on simulated dataset: ###########Simulate Data########### set.seed(123) # set seed if you want to re-produce #simulation results x1 <- sample(c("AF","AS","HI","CA"),10000,replace = T) #Caucasian (CA), African-American(AA), Hispanic(HI), # and Asian(AA) x1 <- factor(x1,levels =c("AF","AS","HI","CA")) # ensure the ordering by setting AF as reference x1.fac <- model.matrix(~ x1) # generate dummy variables for #simulation purposes (in practice you may not need to do #this) betas <- c(.2,.5,.53) # log odds comparing the three groups #to the referent level of AF (these are just made up #values for illustration and simulation purposes!) xbeta <- x1.fac[,-1]%*%betas #need only k-1 dummies for a #variable with k-levels y <- rbinom(n = 10000, size = 1, prob = exp(xbeta)/(1+exp(xbeta))) # Simulate outcome (Y) #Finally we have the following sample data: example_data <- data.frame(y,x1) ####Run regression of outcome against ethnicity model1 <- glm(y~x1,family = binomial,data = example_data) exp(coef(model1))[-1] ###Odds Ratios comparing each group #with the reference group of AF x1AS x1HI x1CA 1.229610 1.800985 1.796416 So what does the odds ratio of 1.23 for Asians mean? This means, compared to African-Americans Asians had 23% higher odds of the outcome. Equivalently, you can interpret as Asians have 1.23 times the odds of the outcome compared to the referent group of African Americans. The odds of 1.800 and 1.796 for Caucasians and Hispanics, respectively, are interpreted in the same manner. The most important part of modeling categorical variables is identifying the proper referent group. You can always change the reference group by using the relevel() command in R. See example here. In order to make comparison between two groups where one of them is not a referent group, there are a few ways to go: Use relevel() function and re-run the regression changing the reference group to your variable of interest (not my favorite approach when there are many levels in your categorical predictor) Use already built in packages to do this comparison. I am not sure how this is done in Stata or SAS (probably contrast statement for SAS) but you can easily do this in R using the car package. For example, if you want to test if the odds of the outcome differ between Caucasians and Hispanics, use the following commands: library(car) linearHypothesis(model1, c("x1CA - x1HI = 0")) Linear hypothesis test Hypothesis: - x1HI + x1CA = 0 Model 1: restricted model Model 2: y ~ x1 Res.Df Df Chisq Pr(>Chisq) 1 9997 2 9996 1 0.0018 0.9658 In this case, we fail to reject the null hypothesis of no difference in the odds of the outcome between Caucasians and Hispanics (p-value=0.9658).
Interpreting logistic regression results when explanatory variable has multiple levels
The interpretation for categorical variables with more than 2 levels is very similar to the binary case you mention; for a $k$-level categorical variable, you will have $k-1$ regression coefficients e
Interpreting logistic regression results when explanatory variable has multiple levels The interpretation for categorical variables with more than 2 levels is very similar to the binary case you mention; for a $k$-level categorical variable, you will have $k-1$ regression coefficients each of which compare the odds of the outcome to the reference group. For the example you state, ethnicity (Caucasian, African-American, Hispanic, and Asian), let us assume your referent (baseline) group is African-American. Many software packages for logistic regressions will give you 3 Odds ratios (for a 4-level categorical predictor) once you run the regression. Let us quickly look at how this is done in R based on simulated dataset: ###########Simulate Data########### set.seed(123) # set seed if you want to re-produce #simulation results x1 <- sample(c("AF","AS","HI","CA"),10000,replace = T) #Caucasian (CA), African-American(AA), Hispanic(HI), # and Asian(AA) x1 <- factor(x1,levels =c("AF","AS","HI","CA")) # ensure the ordering by setting AF as reference x1.fac <- model.matrix(~ x1) # generate dummy variables for #simulation purposes (in practice you may not need to do #this) betas <- c(.2,.5,.53) # log odds comparing the three groups #to the referent level of AF (these are just made up #values for illustration and simulation purposes!) xbeta <- x1.fac[,-1]%*%betas #need only k-1 dummies for a #variable with k-levels y <- rbinom(n = 10000, size = 1, prob = exp(xbeta)/(1+exp(xbeta))) # Simulate outcome (Y) #Finally we have the following sample data: example_data <- data.frame(y,x1) ####Run regression of outcome against ethnicity model1 <- glm(y~x1,family = binomial,data = example_data) exp(coef(model1))[-1] ###Odds Ratios comparing each group #with the reference group of AF x1AS x1HI x1CA 1.229610 1.800985 1.796416 So what does the odds ratio of 1.23 for Asians mean? This means, compared to African-Americans Asians had 23% higher odds of the outcome. Equivalently, you can interpret as Asians have 1.23 times the odds of the outcome compared to the referent group of African Americans. The odds of 1.800 and 1.796 for Caucasians and Hispanics, respectively, are interpreted in the same manner. The most important part of modeling categorical variables is identifying the proper referent group. You can always change the reference group by using the relevel() command in R. See example here. In order to make comparison between two groups where one of them is not a referent group, there are a few ways to go: Use relevel() function and re-run the regression changing the reference group to your variable of interest (not my favorite approach when there are many levels in your categorical predictor) Use already built in packages to do this comparison. I am not sure how this is done in Stata or SAS (probably contrast statement for SAS) but you can easily do this in R using the car package. For example, if you want to test if the odds of the outcome differ between Caucasians and Hispanics, use the following commands: library(car) linearHypothesis(model1, c("x1CA - x1HI = 0")) Linear hypothesis test Hypothesis: - x1HI + x1CA = 0 Model 1: restricted model Model 2: y ~ x1 Res.Df Df Chisq Pr(>Chisq) 1 9997 2 9996 1 0.0018 0.9658 In this case, we fail to reject the null hypothesis of no difference in the odds of the outcome between Caucasians and Hispanics (p-value=0.9658).
Interpreting logistic regression results when explanatory variable has multiple levels The interpretation for categorical variables with more than 2 levels is very similar to the binary case you mention; for a $k$-level categorical variable, you will have $k-1$ regression coefficients e
46,532
Interpreting logistic regression results when explanatory variable has multiple levels
For a categorical variable that is not nominal, a logistic regression will output coefficients to a One Hot Encoded version of it. Therefore the logic remains the same: there will be a coefficient for "Caucasian" / "Not caucasian", another for "Hispanic" / "Not hispanic" and so on. The encoding makes it impossible to have "Caucasian" and "Hispanic" at the same time.
Interpreting logistic regression results when explanatory variable has multiple levels
For a categorical variable that is not nominal, a logistic regression will output coefficients to a One Hot Encoded version of it. Therefore the logic remains the same: there will be a coefficient for
Interpreting logistic regression results when explanatory variable has multiple levels For a categorical variable that is not nominal, a logistic regression will output coefficients to a One Hot Encoded version of it. Therefore the logic remains the same: there will be a coefficient for "Caucasian" / "Not caucasian", another for "Hispanic" / "Not hispanic" and so on. The encoding makes it impossible to have "Caucasian" and "Hispanic" at the same time.
Interpreting logistic regression results when explanatory variable has multiple levels For a categorical variable that is not nominal, a logistic regression will output coefficients to a One Hot Encoded version of it. Therefore the logic remains the same: there will be a coefficient for
46,533
Interpreting logistic regression results when explanatory variable has multiple levels
This is a good question, I've had it myself. Note if you only have one categorical variable then the intercept term corresponds to the reference category. If you have more than one categorical variable in your model then it becomes tricky. One way is to rerun the model with different reference levels (clunky). A better way is to create a dummy variables for each category (one hot encoding) as you mention. However, if you estimate the model this way you need to remove the intercept term or else it is overparameterized.
Interpreting logistic regression results when explanatory variable has multiple levels
This is a good question, I've had it myself. Note if you only have one categorical variable then the intercept term corresponds to the reference category. If you have more than one categorical varia
Interpreting logistic regression results when explanatory variable has multiple levels This is a good question, I've had it myself. Note if you only have one categorical variable then the intercept term corresponds to the reference category. If you have more than one categorical variable in your model then it becomes tricky. One way is to rerun the model with different reference levels (clunky). A better way is to create a dummy variables for each category (one hot encoding) as you mention. However, if you estimate the model this way you need to remove the intercept term or else it is overparameterized.
Interpreting logistic regression results when explanatory variable has multiple levels This is a good question, I've had it myself. Note if you only have one categorical variable then the intercept term corresponds to the reference category. If you have more than one categorical varia
46,534
When is weighted average of $F_1$ scores $\simeq$ accuracy in classification?
Assessing the difference between a support-weighted mean $F1$ and accuracy Class $A$'s $F1$ Using the classification outcomes $a$, $b$, $c$, $d$ as laid out in the confusion matrix above, the function for Class $A$'s $F1$ can be defined as: $$ F_{1;A} = \frac{2a}{(a+b)+(a+c)} $$ Class $B$'s $F1$ Similarly, the function for Class $B$'s $F1$ can be defined as: $$ F_{1;B} = \frac{2d}{(b+d)+(c+d)} $$ Support-weighted mean $F1$ Combining the $F1$s for Classes $A$ and $B$ into a support-weighted average and simplifying results in: $$ Support\text{-}weighted\text{ }mean_{F1} = \frac{(a+b) \cdot \frac{2a}{(a+b)+(a+c)} + (c+d) \cdot \frac{2d}{(b+d)+(c+d)}}{a+b+c+d}=\frac{a^2+ab+cd+d^2}{(a+b+c+d)^2} $$ Classification Accuracy Finally, in the same regard, the function for the classification accuracy can be defined as: $$ Accuracy = \frac{a+d}{a+b+c+d} $$ Support-weighted mean $F1$ vs. Classification Accuracy - A Dinstinguishing Component By setting the functions for the support-weighted mean $F1$ and accuracy equal, we can figure out which conditions involving $a$, $b$, $c$, $d$ determine similarity between the two statistics: $$ Support\text{-}weighted\text{ }mean_{F1} = Accuracy $$ $$ \frac{a^2+ab+cd+d^2}{(a+b+c+d)^2} = \frac{a+d}{a+b+c+d} $$ $$ a^2+ab+cd+d^2 = (a+d)(a+b+c+d) $$ $$ a^2+ab+cd+d^2 = a^2+ab+cd+d^2 + (ac+2ad+bd) $$ Therefore, the difference between the two statistics is smaller when the $\frac{ac+2ad+bd}{(a+b+c+d)^2}$ component of the support-weighted mean $F1$ (let's just call this the '$SWM\text{ }F1$ component') is minimal. Simulating the Component Using R, I simulated 2000 confusion matrices (with $a, b, c, d \sim Uniform(0,100)$) and created the following plot to demonstrate the influence of this $SWM\text{ }F1$ component on the difference between the two statistics: The plot shows that small $SWM\text{ }F1$ components contribute to heightened similarity between the two statistics. ...and back to your question To summarize, your support-weighted mean $F1$ and accuracy are similar because a particular component of the support-weighted mean $F1$ (i.e. $\frac{ac+2ad+bd}{(a+b+c+d)^2}$) is relatively small, particularly because of your small number of false predictions ($b$ and $c$). It is also worth noting that test sets with small $n$ (as can be deduced from the component's formula) will be less likely to produce large differences between the two statistics. ...
When is weighted average of $F_1$ scores $\simeq$ accuracy in classification?
Assessing the difference between a support-weighted mean $F1$ and accuracy Class $A$'s $F1$ Using the classification outcomes $a$, $b$, $c$, $d$ as laid out in the confusion matrix above, the functio
When is weighted average of $F_1$ scores $\simeq$ accuracy in classification? Assessing the difference between a support-weighted mean $F1$ and accuracy Class $A$'s $F1$ Using the classification outcomes $a$, $b$, $c$, $d$ as laid out in the confusion matrix above, the function for Class $A$'s $F1$ can be defined as: $$ F_{1;A} = \frac{2a}{(a+b)+(a+c)} $$ Class $B$'s $F1$ Similarly, the function for Class $B$'s $F1$ can be defined as: $$ F_{1;B} = \frac{2d}{(b+d)+(c+d)} $$ Support-weighted mean $F1$ Combining the $F1$s for Classes $A$ and $B$ into a support-weighted average and simplifying results in: $$ Support\text{-}weighted\text{ }mean_{F1} = \frac{(a+b) \cdot \frac{2a}{(a+b)+(a+c)} + (c+d) \cdot \frac{2d}{(b+d)+(c+d)}}{a+b+c+d}=\frac{a^2+ab+cd+d^2}{(a+b+c+d)^2} $$ Classification Accuracy Finally, in the same regard, the function for the classification accuracy can be defined as: $$ Accuracy = \frac{a+d}{a+b+c+d} $$ Support-weighted mean $F1$ vs. Classification Accuracy - A Dinstinguishing Component By setting the functions for the support-weighted mean $F1$ and accuracy equal, we can figure out which conditions involving $a$, $b$, $c$, $d$ determine similarity between the two statistics: $$ Support\text{-}weighted\text{ }mean_{F1} = Accuracy $$ $$ \frac{a^2+ab+cd+d^2}{(a+b+c+d)^2} = \frac{a+d}{a+b+c+d} $$ $$ a^2+ab+cd+d^2 = (a+d)(a+b+c+d) $$ $$ a^2+ab+cd+d^2 = a^2+ab+cd+d^2 + (ac+2ad+bd) $$ Therefore, the difference between the two statistics is smaller when the $\frac{ac+2ad+bd}{(a+b+c+d)^2}$ component of the support-weighted mean $F1$ (let's just call this the '$SWM\text{ }F1$ component') is minimal. Simulating the Component Using R, I simulated 2000 confusion matrices (with $a, b, c, d \sim Uniform(0,100)$) and created the following plot to demonstrate the influence of this $SWM\text{ }F1$ component on the difference between the two statistics: The plot shows that small $SWM\text{ }F1$ components contribute to heightened similarity between the two statistics. ...and back to your question To summarize, your support-weighted mean $F1$ and accuracy are similar because a particular component of the support-weighted mean $F1$ (i.e. $\frac{ac+2ad+bd}{(a+b+c+d)^2}$) is relatively small, particularly because of your small number of false predictions ($b$ and $c$). It is also worth noting that test sets with small $n$ (as can be deduced from the component's formula) will be less likely to produce large differences between the two statistics. ...
When is weighted average of $F_1$ scores $\simeq$ accuracy in classification? Assessing the difference between a support-weighted mean $F1$ and accuracy Class $A$'s $F1$ Using the classification outcomes $a$, $b$, $c$, $d$ as laid out in the confusion matrix above, the functio
46,535
What's the inverse of the finite polynomial $\phi_p$ in an $\ ARMA(p,q)$ model?
The law you are looking for is the infinite geometric sum: $$\sum_{t=0}^\infty r^t = \frac{1}{1-r} = (1-r)^{-1} \quad \quad \text{for }|r|<1.$$ This law shows that the inverse of a polynomial of degree one (an affine function) can be written as an infinite degree polynomial. To apply this to the inversion of an autoregressive characteristic polynomial of arbitrary finite degree, you first write the finite polynomial in its factorised form: $$\phi_p(x) = \prod_{i=1}^p \Big( 1-\frac{x}{r_i} \Big),$$ where $r_1, ..., r_p$ are the roots of the polynomial. Now the polynomial is written as a product of first order polynomials (i.e., affine functions). Over the polynomial argument range $|x| < \min |r_i|$, you have $|x/r_i| < 1$ for all $i=1,...,p$, which allows the following inversion: $$\phi_p(x)^{-1} = \prod_{i=1}^p \Big( 1-\frac{x}{r_i} \Big)^{-1} = \prod_{i=1}^p \Big( \sum_{t=0}^\infty (x/r_i)^t \Big) = \sum_{t=0}^\infty \kappa_t x^t.$$ This form is an infinite polynomial, with coefficients $\kappa_t$ that decrease to zero as $t \rightarrow \infty$. Note that this is a general result that occurs whenever you are dealing with inversion of polynomials; it is a result that occurs in areas of mathematics outside of time-series analysis, though one particular application is in the context of ARMA models. Within the context of ARMA models, we use the backshift operator as a polynomial argument, rather than using a fixed real number. Understanding how this operator functions requires a knowledge of function-theory, which looks at operators as mappings on a function-space. Without going into the details of this, the insight that is relevant for our purposes is that the backshift operator behaves like the number one in the argument, and it obeys the invertability property above (for proof, see e.g., Kasparis 2016). Thus, when you are inverting the polynomial with the backshift operator, you need $|r_i|>1$ for all $i=1,...,p$, and you then have: $$\phi_p(B)^{-1} = \sum_{t=0}^\infty \kappa_t B^t.$$
What's the inverse of the finite polynomial $\phi_p$ in an $\ ARMA(p,q)$ model?
The law you are looking for is the infinite geometric sum: $$\sum_{t=0}^\infty r^t = \frac{1}{1-r} = (1-r)^{-1} \quad \quad \text{for }|r|<1.$$ This law shows that the inverse of a polynomial of degre
What's the inverse of the finite polynomial $\phi_p$ in an $\ ARMA(p,q)$ model? The law you are looking for is the infinite geometric sum: $$\sum_{t=0}^\infty r^t = \frac{1}{1-r} = (1-r)^{-1} \quad \quad \text{for }|r|<1.$$ This law shows that the inverse of a polynomial of degree one (an affine function) can be written as an infinite degree polynomial. To apply this to the inversion of an autoregressive characteristic polynomial of arbitrary finite degree, you first write the finite polynomial in its factorised form: $$\phi_p(x) = \prod_{i=1}^p \Big( 1-\frac{x}{r_i} \Big),$$ where $r_1, ..., r_p$ are the roots of the polynomial. Now the polynomial is written as a product of first order polynomials (i.e., affine functions). Over the polynomial argument range $|x| < \min |r_i|$, you have $|x/r_i| < 1$ for all $i=1,...,p$, which allows the following inversion: $$\phi_p(x)^{-1} = \prod_{i=1}^p \Big( 1-\frac{x}{r_i} \Big)^{-1} = \prod_{i=1}^p \Big( \sum_{t=0}^\infty (x/r_i)^t \Big) = \sum_{t=0}^\infty \kappa_t x^t.$$ This form is an infinite polynomial, with coefficients $\kappa_t$ that decrease to zero as $t \rightarrow \infty$. Note that this is a general result that occurs whenever you are dealing with inversion of polynomials; it is a result that occurs in areas of mathematics outside of time-series analysis, though one particular application is in the context of ARMA models. Within the context of ARMA models, we use the backshift operator as a polynomial argument, rather than using a fixed real number. Understanding how this operator functions requires a knowledge of function-theory, which looks at operators as mappings on a function-space. Without going into the details of this, the insight that is relevant for our purposes is that the backshift operator behaves like the number one in the argument, and it obeys the invertability property above (for proof, see e.g., Kasparis 2016). Thus, when you are inverting the polynomial with the backshift operator, you need $|r_i|>1$ for all $i=1,...,p$, and you then have: $$\phi_p(B)^{-1} = \sum_{t=0}^\infty \kappa_t B^t.$$
What's the inverse of the finite polynomial $\phi_p$ in an $\ ARMA(p,q)$ model? The law you are looking for is the infinite geometric sum: $$\sum_{t=0}^\infty r^t = \frac{1}{1-r} = (1-r)^{-1} \quad \quad \text{for }|r|<1.$$ This law shows that the inverse of a polynomial of degre
46,536
Should I give more weight to goodness of fit or to conceptual approach?. Example
There are a bunch of issues here You can't compare likelihoods / deviance / AIC between models with continuous vs. count data, see, e.g. Can WAIC be used to compare Bayesian linear regression models with different likelihoods?. Moreover, do you have discrete k/n or continuous proportions? In either case, applying an lm on the raw data is usually not a good idea (see What are the issues with using percentage outcome in linear regression?), at least use a transformation (e.g. logit is sometimes used for continuous proportions, also arcsine, but see https://www.ncbi.nlm.nih.gov/pubmed/21560670). Better use a glm, for k/n binomial, for continuous proportions it is common to use beta regression or a pseudo-binomial. About the decision what to do - in doubt, I would simply go for the data-generating model, i.e. in case of k/n for a binomial. Check the model fit, e.g. with DHARMa, and with k/n binomial, you also have to check for overdispersion.
Should I give more weight to goodness of fit or to conceptual approach?. Example
There are a bunch of issues here You can't compare likelihoods / deviance / AIC between models with continuous vs. count data, see, e.g. Can WAIC be used to compare Bayesian linear regression models
Should I give more weight to goodness of fit or to conceptual approach?. Example There are a bunch of issues here You can't compare likelihoods / deviance / AIC between models with continuous vs. count data, see, e.g. Can WAIC be used to compare Bayesian linear regression models with different likelihoods?. Moreover, do you have discrete k/n or continuous proportions? In either case, applying an lm on the raw data is usually not a good idea (see What are the issues with using percentage outcome in linear regression?), at least use a transformation (e.g. logit is sometimes used for continuous proportions, also arcsine, but see https://www.ncbi.nlm.nih.gov/pubmed/21560670). Better use a glm, for k/n binomial, for continuous proportions it is common to use beta regression or a pseudo-binomial. About the decision what to do - in doubt, I would simply go for the data-generating model, i.e. in case of k/n for a binomial. Check the model fit, e.g. with DHARMa, and with k/n binomial, you also have to check for overdispersion.
Should I give more weight to goodness of fit or to conceptual approach?. Example There are a bunch of issues here You can't compare likelihoods / deviance / AIC between models with continuous vs. count data, see, e.g. Can WAIC be used to compare Bayesian linear regression models
46,537
Distribution of "p-value-like" quantities under null hypothesis
Let $f$ be the density of $X$. You are concerned about the distribution of ''d-values'' $$d = P( f(X) < f(x_{obs}))$$ when $x_{obs}$ is drawn in the distribution of $X$. Let's construct an other random variable by transforming $X$ : $Y = f(X)$, and let $y_{obs} = f(x_{obs})$. Then in fact you're looking at the distribution of $$P(Y < y_{obs})$$ when $y_{obs}$ is drawn in the distribution of $Y$. It is then the uniform distribution. A quick numerical experiment Consider a mixture of two Gaussian with variance 1 and means 0 and 4. Its density looks like Now for the numerical experiment: # a reference sample to compute d values X_ref <- c( rnorm(1e4), rnorm(1e4, mean = 4) ) # a set of observations x_obs <- c( rnorm(1e4), rnorm(1e4, mean = 4) ) # the d-values d <- sapply(x_obs, function(x) mean(f(x) < f(X_ref)) ) plot(ppoints(2e4), sort(d), pch = ".")
Distribution of "p-value-like" quantities under null hypothesis
Let $f$ be the density of $X$. You are concerned about the distribution of ''d-values'' $$d = P( f(X) < f(x_{obs}))$$ when $x_{obs}$ is drawn in the distribution of $X$. Let's construct an other rand
Distribution of "p-value-like" quantities under null hypothesis Let $f$ be the density of $X$. You are concerned about the distribution of ''d-values'' $$d = P( f(X) < f(x_{obs}))$$ when $x_{obs}$ is drawn in the distribution of $X$. Let's construct an other random variable by transforming $X$ : $Y = f(X)$, and let $y_{obs} = f(x_{obs})$. Then in fact you're looking at the distribution of $$P(Y < y_{obs})$$ when $y_{obs}$ is drawn in the distribution of $Y$. It is then the uniform distribution. A quick numerical experiment Consider a mixture of two Gaussian with variance 1 and means 0 and 4. Its density looks like Now for the numerical experiment: # a reference sample to compute d values X_ref <- c( rnorm(1e4), rnorm(1e4, mean = 4) ) # a set of observations x_obs <- c( rnorm(1e4), rnorm(1e4, mean = 4) ) # the d-values d <- sapply(x_obs, function(x) mean(f(x) < f(X_ref)) ) plot(ppoints(2e4), sort(d), pch = ".")
Distribution of "p-value-like" quantities under null hypothesis Let $f$ be the density of $X$. You are concerned about the distribution of ''d-values'' $$d = P( f(X) < f(x_{obs}))$$ when $x_{obs}$ is drawn in the distribution of $X$. Let's construct an other rand
46,538
Distribution of "p-value-like" quantities under null hypothesis
Short answer: The statistic you are referring to may just be the p-value (depending on the ordering of evidence for the null vs alternative. Don't assume that p-values are for the area that is "extreme" in the sense of having the highest magnitude values (i.e., the tail area). Longer answer: Every hypothesis test involves an implicit ordering of possible outcomes on an ordinal scale from those that are more conducive to the null hypothesis to those that are more conducive to the alternative hypothesis. This implicit ordering is captured in the test-statistic and its order as a measure of evidence. The p-value is defined as the probability of observing evidence at least as conducive to the alternative hypothesis as what was actually observed, assuming the null hypothesis is actually true. It is certainly not the case that observations that are "more extreme" in the sense of being high magnitude (i.e., in the tail of a distribution) are necessarily more conducive to the alternative hypothesis than values like the one you highlight above. In fact, the most common measure used for the test statistic is the likelihood-ratio statistic comparing the null and alternative hypotheses. This test statistic orders the possible outcomes so that outcomes with lower relative likelihood for the null hypothesis (compared to the alternative) constitute greater evidence against the null. In this test, the p-value is the values that are "most extreme" in favour of the alternative, which is the set of values with low likelihood ratio: $$p(x) \equiv \mathbb{P}( LR(X) \leqslant LR(x) | H_0 ) \quad \quad LR(x) = \frac{L_0(x)}{L_A(x)},$$ where $L_0 \equiv \sup_{\theta \in \Theta_0} L_x(\theta) $ and $L_A \equiv \sup_{\theta \in \Theta_A} L_x(\theta) $ are the likelihoods under the null and alternative models. Now, if you were to show the likelihood ratio in your function instead of the null distribution, then the area you are calling a "d-value" would actually just be the p-value of the test. The critical region for the test would be a disjointed set of intervals on the horizontal axis. The value you have highlighted in your diagram is based solely on looking at the null distribution, which means we cant really see what the proper ordering of evidence in the test is. But you shouldn't assume that the ordering is such that higher magnitude values are more evidence for the alternative (particularly with a multi-modal null distribution. Once you specify the likelihood for the alternative, you will be able to determine the ordering of evidence implicit in use of the likelihood ratio statistic and this will tell you what constitutes a "more extreme" value in your test.
Distribution of "p-value-like" quantities under null hypothesis
Short answer: The statistic you are referring to may just be the p-value (depending on the ordering of evidence for the null vs alternative. Don't assume that p-values are for the area that is "extre
Distribution of "p-value-like" quantities under null hypothesis Short answer: The statistic you are referring to may just be the p-value (depending on the ordering of evidence for the null vs alternative. Don't assume that p-values are for the area that is "extreme" in the sense of having the highest magnitude values (i.e., the tail area). Longer answer: Every hypothesis test involves an implicit ordering of possible outcomes on an ordinal scale from those that are more conducive to the null hypothesis to those that are more conducive to the alternative hypothesis. This implicit ordering is captured in the test-statistic and its order as a measure of evidence. The p-value is defined as the probability of observing evidence at least as conducive to the alternative hypothesis as what was actually observed, assuming the null hypothesis is actually true. It is certainly not the case that observations that are "more extreme" in the sense of being high magnitude (i.e., in the tail of a distribution) are necessarily more conducive to the alternative hypothesis than values like the one you highlight above. In fact, the most common measure used for the test statistic is the likelihood-ratio statistic comparing the null and alternative hypotheses. This test statistic orders the possible outcomes so that outcomes with lower relative likelihood for the null hypothesis (compared to the alternative) constitute greater evidence against the null. In this test, the p-value is the values that are "most extreme" in favour of the alternative, which is the set of values with low likelihood ratio: $$p(x) \equiv \mathbb{P}( LR(X) \leqslant LR(x) | H_0 ) \quad \quad LR(x) = \frac{L_0(x)}{L_A(x)},$$ where $L_0 \equiv \sup_{\theta \in \Theta_0} L_x(\theta) $ and $L_A \equiv \sup_{\theta \in \Theta_A} L_x(\theta) $ are the likelihoods under the null and alternative models. Now, if you were to show the likelihood ratio in your function instead of the null distribution, then the area you are calling a "d-value" would actually just be the p-value of the test. The critical region for the test would be a disjointed set of intervals on the horizontal axis. The value you have highlighted in your diagram is based solely on looking at the null distribution, which means we cant really see what the proper ordering of evidence in the test is. But you shouldn't assume that the ordering is such that higher magnitude values are more evidence for the alternative (particularly with a multi-modal null distribution. Once you specify the likelihood for the alternative, you will be able to determine the ordering of evidence implicit in use of the likelihood ratio statistic and this will tell you what constitutes a "more extreme" value in your test.
Distribution of "p-value-like" quantities under null hypothesis Short answer: The statistic you are referring to may just be the p-value (depending on the ordering of evidence for the null vs alternative. Don't assume that p-values are for the area that is "extre
46,539
Featurization before or after dataset splitting
That comment is correct: we have to do "feature extraction" from our training data only. Let's consider one of the most common data-transformation procedures, centring. We get an "expected value" $\hat{\mu}_{x_j}$ for our feature $x_j$ and then we subtract that from the values of $x_j$, nothing magical. A central question is: what this "expected value" reflects; does it reflect our understanding of $x_j$ using the whole sample or just the training sample? If we use the whole sample we have what is called data-leakage, "we cheat" using information that should be available during prediction. To give an NLP example, if some very unusual word or n-gram is present in our corpus and all instances happen to land in the test set, it is obviously wrong to inform the process of convert our collection of text documents to a matrix of token counts with that unusual n-gram. It will give us a false scene of security about the generalised performance of our procedure. Therefore, when doing serious feature extraction/engineering we need to use only the training data and not the whole dataset.
Featurization before or after dataset splitting
That comment is correct: we have to do "feature extraction" from our training data only. Let's consider one of the most common data-transformation procedures, centring. We get an "expected value" $\h
Featurization before or after dataset splitting That comment is correct: we have to do "feature extraction" from our training data only. Let's consider one of the most common data-transformation procedures, centring. We get an "expected value" $\hat{\mu}_{x_j}$ for our feature $x_j$ and then we subtract that from the values of $x_j$, nothing magical. A central question is: what this "expected value" reflects; does it reflect our understanding of $x_j$ using the whole sample or just the training sample? If we use the whole sample we have what is called data-leakage, "we cheat" using information that should be available during prediction. To give an NLP example, if some very unusual word or n-gram is present in our corpus and all instances happen to land in the test set, it is obviously wrong to inform the process of convert our collection of text documents to a matrix of token counts with that unusual n-gram. It will give us a false scene of security about the generalised performance of our procedure. Therefore, when doing serious feature extraction/engineering we need to use only the training data and not the whole dataset.
Featurization before or after dataset splitting That comment is correct: we have to do "feature extraction" from our training data only. Let's consider one of the most common data-transformation procedures, centring. We get an "expected value" $\h
46,540
Choosing the "Correct" Seed for Reproducible Research/Results
The seed choice should not affect the ultimate result, otherwise you have an issue. Then why do we need a seed at all? The reason is mainly for debugging and trouble shooting. What do I call an ultimate result? Suppose that you're analyzing a drug efficacy, and using Monte Carlo simulation to come up with some kind of a critical value. The seed shouldn't matter to your conclusion about whether the drug is efficient or not. Consider this: what if you're using R and I'm suing Excel, how would I use your seed? I should be able to reproduce the ultimate result regardless of the differences in our software packages and platforms. Of course, the seed will impact the exact value obtained for the critical value, e.g. 3.1278765876 instead of 3.128765987 with another seed, but this is not the ultimate result of your study. Suppose the test statistic is 20.5, then the difference in critical values between two seeds is not material. Actually, you should not even report the critical value beyond the third digit, just show 3.13, unless it's for debugging purposes. However, if somehow the difference in fourth significant digit makes it or breaks it for this drug, then we have an issue. It means that we can't use this critical value, OR that we need to increase the number of simulations to nail the fourth digit and reduce the variation between seeds to a much smaller number. Therefore, you need to set other parameters of simulation in such a way that seed wouldn't matter for the conclusion of your study. Do not "optimize" the seed in any way. In my practice I had funny projects, where the client would insist on reporting all the calculated digits, e.g. $31,456,890.01. The simulations would yield maybe 1% precision, hence the number would be changing in second or third digit between different seeds. Moreover, the model itself had accuracy around 10% at best, so to a physicist I would have reported 3e7. However, accountants would complain that the number looks "rounded" which drives auditors nuts: it looks to them as if someone's "cooking the books." We ended up reporting the numbers to the cents, and storing the seeds so that the numbers would be reproducible upon audit requests.
Choosing the "Correct" Seed for Reproducible Research/Results
The seed choice should not affect the ultimate result, otherwise you have an issue. Then why do we need a seed at all? The reason is mainly for debugging and trouble shooting. What do I call an ultim
Choosing the "Correct" Seed for Reproducible Research/Results The seed choice should not affect the ultimate result, otherwise you have an issue. Then why do we need a seed at all? The reason is mainly for debugging and trouble shooting. What do I call an ultimate result? Suppose that you're analyzing a drug efficacy, and using Monte Carlo simulation to come up with some kind of a critical value. The seed shouldn't matter to your conclusion about whether the drug is efficient or not. Consider this: what if you're using R and I'm suing Excel, how would I use your seed? I should be able to reproduce the ultimate result regardless of the differences in our software packages and platforms. Of course, the seed will impact the exact value obtained for the critical value, e.g. 3.1278765876 instead of 3.128765987 with another seed, but this is not the ultimate result of your study. Suppose the test statistic is 20.5, then the difference in critical values between two seeds is not material. Actually, you should not even report the critical value beyond the third digit, just show 3.13, unless it's for debugging purposes. However, if somehow the difference in fourth significant digit makes it or breaks it for this drug, then we have an issue. It means that we can't use this critical value, OR that we need to increase the number of simulations to nail the fourth digit and reduce the variation between seeds to a much smaller number. Therefore, you need to set other parameters of simulation in such a way that seed wouldn't matter for the conclusion of your study. Do not "optimize" the seed in any way. In my practice I had funny projects, where the client would insist on reporting all the calculated digits, e.g. $31,456,890.01. The simulations would yield maybe 1% precision, hence the number would be changing in second or third digit between different seeds. Moreover, the model itself had accuracy around 10% at best, so to a physicist I would have reported 3e7. However, accountants would complain that the number looks "rounded" which drives auditors nuts: it looks to them as if someone's "cooking the books." We ended up reporting the numbers to the cents, and storing the seeds so that the numbers would be reproducible upon audit requests.
Choosing the "Correct" Seed for Reproducible Research/Results The seed choice should not affect the ultimate result, otherwise you have an issue. Then why do we need a seed at all? The reason is mainly for debugging and trouble shooting. What do I call an ultim
46,541
Choosing the "Correct" Seed for Reproducible Research/Results
You certainly can use "seed optimization" to be deceptive about performance. For example, suppose I'm comparing two estimators that just give back pure noise. Fifty percent of my seeds will say estimator A is better than B when using cross validation, so all I need to do is make sure I pick a good seed and then go publish my paper! Does that mean the use of saved seeds is bad? Not really. The whole point of the seeds is that you've got a script that someone can use to completely reproduce the exact results you got. If you claim the cross validated MSE was 1.2, and a researcher says "hmm, I don't believe that...", just rerun the script right in front of them and they will see it's what you got. Now, could you have seed optimized to get that 1.2 MSE? Absolutely. But in the exact same manner, they can take your same script, change the seed a few times, and make sure the results almost replicate! So you can use a seed to replicate exactly the results you saw...and then test how reliable that is by randomly using other seeds on the exact same script.
Choosing the "Correct" Seed for Reproducible Research/Results
You certainly can use "seed optimization" to be deceptive about performance. For example, suppose I'm comparing two estimators that just give back pure noise. Fifty percent of my seeds will say estima
Choosing the "Correct" Seed for Reproducible Research/Results You certainly can use "seed optimization" to be deceptive about performance. For example, suppose I'm comparing two estimators that just give back pure noise. Fifty percent of my seeds will say estimator A is better than B when using cross validation, so all I need to do is make sure I pick a good seed and then go publish my paper! Does that mean the use of saved seeds is bad? Not really. The whole point of the seeds is that you've got a script that someone can use to completely reproduce the exact results you got. If you claim the cross validated MSE was 1.2, and a researcher says "hmm, I don't believe that...", just rerun the script right in front of them and they will see it's what you got. Now, could you have seed optimized to get that 1.2 MSE? Absolutely. But in the exact same manner, they can take your same script, change the seed a few times, and make sure the results almost replicate! So you can use a seed to replicate exactly the results you saw...and then test how reliable that is by randomly using other seeds on the exact same script.
Choosing the "Correct" Seed for Reproducible Research/Results You certainly can use "seed optimization" to be deceptive about performance. For example, suppose I'm comparing two estimators that just give back pure noise. Fifty percent of my seeds will say estima
46,542
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper
After I obtained some help from the authors, I can write down now how I understand it. Somebody jump in, if there is disagreement. Say, we have some differentiable loss function $L(y,H(x))$ , where $H(x)$ is our tree ensemble at some iteration. Let $g_i$ be the gradient of our loss function at some entry corresponding to observation i. In each iteration, the gradient is our new label vector on which we fit a regression tree. Like, $\tilde{y_i} := g_i$ Let's only consider the gradient instances belonging to some parent node at some iteration. So, when I write $\forall g_i$ I mean all the instances in this parent node. Let $L = \left\{ g_j | x_{j,s} \leq d \right\}$ and define R similar. Then we search the best variable s with splitting point d for the next split. Therefore, we choose s and d according to $ \min_{s,d} \sum_{g_i \in L}^{}(g_i - \bar{g}_L)^2 + \sum_{g_i \in R}^{}(g_i - \bar{g}_R)^2 - \sum_{\forall g_i }^{}(g_i - \bar{g})^2 \\ \quad = \sum_{g_i \in L}^{}g_i^2 - n_L *\bar{g}_L^2 + \sum_{g_i \in R}^{}g_i^2 - n_R *\bar{g}_R^2 - (\sum_{\forall g_i}^{}g_i^2 - n *\bar{g}^2) $ (as $\sum_{g_i \in L}^{}g_i^2 + \sum_{g_i \in R}^{}g_i^2 = \sum_{\forall g_i}^{}g_i^2 $, these terms cancel out) $\quad = - n_L *\bar{g}_L^2 - n_R *\bar{g}_R^2 + n *\bar{g}^2 $ Now, $n *\bar{g}^2$ is always the same, independent of how we make the split. Hence, for the minimization we can ignore it. Therefore, the minimization from the first line is equivalent to: $ \min_{s,d}\quad - n_L *\bar{g}_L^2 - n_R *\bar{g}_R^2 $, which is equivalent to $ \max_{s,d} \quad n_L *\bar{g}_L^2 + n_R *\bar{g}_R^2 \\ \quad \quad = n_L * (\frac{1}{n_L}\sum_{g_i \in L}g_i)^2 + n_R * (\frac{1}{n_R}\sum_{g_i \in R}g_i)^2 \\ \quad\quad = n_L * \frac{1}{n_L^2} (\sum_{g_i \in L}g_i)^2 + n_R * \frac{1}{n_R^2} (\sum_{g_i \in R}g_i)^2 \\ \quad\quad = \frac{(\sum_{g_i \in L}g_i)^2}{n_L} + \frac{(\sum_{g_i \in R}g_i)^2}{n_R} $ This is almost exactly the formula from the picture but they weight this with the overall number of instances in the parent node. I assume, this is done to compare different splits between different nodes because they use best-first splitting.
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper
After I obtained some help from the authors, I can write down now how I understand it. Somebody jump in, if there is disagreement. Say, we have some differentiable loss function $L(y,H(x))$ , where $H
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper After I obtained some help from the authors, I can write down now how I understand it. Somebody jump in, if there is disagreement. Say, we have some differentiable loss function $L(y,H(x))$ , where $H(x)$ is our tree ensemble at some iteration. Let $g_i$ be the gradient of our loss function at some entry corresponding to observation i. In each iteration, the gradient is our new label vector on which we fit a regression tree. Like, $\tilde{y_i} := g_i$ Let's only consider the gradient instances belonging to some parent node at some iteration. So, when I write $\forall g_i$ I mean all the instances in this parent node. Let $L = \left\{ g_j | x_{j,s} \leq d \right\}$ and define R similar. Then we search the best variable s with splitting point d for the next split. Therefore, we choose s and d according to $ \min_{s,d} \sum_{g_i \in L}^{}(g_i - \bar{g}_L)^2 + \sum_{g_i \in R}^{}(g_i - \bar{g}_R)^2 - \sum_{\forall g_i }^{}(g_i - \bar{g})^2 \\ \quad = \sum_{g_i \in L}^{}g_i^2 - n_L *\bar{g}_L^2 + \sum_{g_i \in R}^{}g_i^2 - n_R *\bar{g}_R^2 - (\sum_{\forall g_i}^{}g_i^2 - n *\bar{g}^2) $ (as $\sum_{g_i \in L}^{}g_i^2 + \sum_{g_i \in R}^{}g_i^2 = \sum_{\forall g_i}^{}g_i^2 $, these terms cancel out) $\quad = - n_L *\bar{g}_L^2 - n_R *\bar{g}_R^2 + n *\bar{g}^2 $ Now, $n *\bar{g}^2$ is always the same, independent of how we make the split. Hence, for the minimization we can ignore it. Therefore, the minimization from the first line is equivalent to: $ \min_{s,d}\quad - n_L *\bar{g}_L^2 - n_R *\bar{g}_R^2 $, which is equivalent to $ \max_{s,d} \quad n_L *\bar{g}_L^2 + n_R *\bar{g}_R^2 \\ \quad \quad = n_L * (\frac{1}{n_L}\sum_{g_i \in L}g_i)^2 + n_R * (\frac{1}{n_R}\sum_{g_i \in R}g_i)^2 \\ \quad\quad = n_L * \frac{1}{n_L^2} (\sum_{g_i \in L}g_i)^2 + n_R * \frac{1}{n_R^2} (\sum_{g_i \in R}g_i)^2 \\ \quad\quad = \frac{(\sum_{g_i \in L}g_i)^2}{n_L} + \frac{(\sum_{g_i \in R}g_i)^2}{n_R} $ This is almost exactly the formula from the picture but they weight this with the overall number of instances in the parent node. I assume, this is done to compare different splits between different nodes because they use best-first splitting.
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper After I obtained some help from the authors, I can write down now how I understand it. Somebody jump in, if there is disagreement. Say, we have some differentiable loss function $L(y,H(x))$ , where $H
46,543
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper
Section 3 in the LightGBM paper is valid for the MSE loss function for which hessians reduce to 1. In that case the formula from Definition 3.1. coincides with formulas (6) and (7) from the XGBoost paper (where they are derived in an understandable way). Also, you can find in the LightGBM code (goss.php, line 110) that in GOSS data instances are actually sorted with respect to gradients multiplied by hessians, not gradients (as written in the paper), which are the same for MSE only.
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper
Section 3 in the LightGBM paper is valid for the MSE loss function for which hessians reduce to 1. In that case the formula from Definition 3.1. coincides with formulas (6) and (7) from the XGBoost pa
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper Section 3 in the LightGBM paper is valid for the MSE loss function for which hessians reduce to 1. In that case the formula from Definition 3.1. coincides with formulas (6) and (7) from the XGBoost paper (where they are derived in an understandable way). Also, you can find in the LightGBM code (goss.php, line 110) that in GOSS data instances are actually sorted with respect to gradients multiplied by hessians, not gradients (as written in the paper), which are the same for MSE only.
Understanding weak learner splitting criterion in gradient boosting decision tree (lightgbm) paper Section 3 in the LightGBM paper is valid for the MSE loss function for which hessians reduce to 1. In that case the formula from Definition 3.1. coincides with formulas (6) and (7) from the XGBoost pa
46,544
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
$\require{mediawiki-texvc}$Let $T=T(X)=T(X_1,X_2, \dotsc, X_n)$ be a statistic, and assume we have some statistical model for the random variable $X$ (the data), say that $X$ is distributed according to the distribution $f(x;\theta)$, $f$ is then a model function (often a density or probability mass function) which is known only up to the parameter $\theta$, which is unknown. Then the statistic $T$ has a distribution which depend upon the unknown parameter $\theta$, but $T$, as a function of the data $X$, do not depend upon $\theta$. That only says that you can calculate the realized value of $T$, from some observed data, without knowing the value of the parameter $\theta$. That is good, because you do not know $\theta$, so if you needed $\theta$ to calculate $T$, you would not be able to calculate $T$. That would be bad, because you could not even start your statistical analysis! But, still the distribution of $T$ depends upon the value of $\theta$. That is good, because it means that observing the realized value of $T$ you can guess something about $\theta$, maybe calculate a confidence interval for $\theta$. If the distribution of $T$ was the same for all possible values of $\theta^\P$, then observing the value of $T$ would not teach us anything about $\theta$! So, this boils down to: You must distinguish between $T$ as a function of the data, and the distribution of the random variable $T(X)$. The first one do not depend upon $\theta$, the second one does. $\P$: Such a statistic is called ancillary. It might be useful, just not directly, alone for inference about $\theta$.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
$\require{mediawiki-texvc}$Let $T=T(X)=T(X_1,X_2, \dotsc, X_n)$ be a statistic, and assume we have some statistical model for the random variable $X$ (the data), say that $X$ is distributed according
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? $\require{mediawiki-texvc}$Let $T=T(X)=T(X_1,X_2, \dotsc, X_n)$ be a statistic, and assume we have some statistical model for the random variable $X$ (the data), say that $X$ is distributed according to the distribution $f(x;\theta)$, $f$ is then a model function (often a density or probability mass function) which is known only up to the parameter $\theta$, which is unknown. Then the statistic $T$ has a distribution which depend upon the unknown parameter $\theta$, but $T$, as a function of the data $X$, do not depend upon $\theta$. That only says that you can calculate the realized value of $T$, from some observed data, without knowing the value of the parameter $\theta$. That is good, because you do not know $\theta$, so if you needed $\theta$ to calculate $T$, you would not be able to calculate $T$. That would be bad, because you could not even start your statistical analysis! But, still the distribution of $T$ depends upon the value of $\theta$. That is good, because it means that observing the realized value of $T$ you can guess something about $\theta$, maybe calculate a confidence interval for $\theta$. If the distribution of $T$ was the same for all possible values of $\theta^\P$, then observing the value of $T$ would not teach us anything about $\theta$! So, this boils down to: You must distinguish between $T$ as a function of the data, and the distribution of the random variable $T(X)$. The first one do not depend upon $\theta$, the second one does. $\P$: Such a statistic is called ancillary. It might be useful, just not directly, alone for inference about $\theta$.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? $\require{mediawiki-texvc}$Let $T=T(X)=T(X_1,X_2, \dotsc, X_n)$ be a statistic, and assume we have some statistical model for the random variable $X$ (the data), say that $X$ is distributed according
46,545
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
The confusion here stems from conflating a random variable with its distribution. To be clear about the issue, a random variable is not a function of the model parameters, but its distribution is. Taking things back to their foundations, you have some probability space that consists of a sample space $\Omega$, a class of subsets on that space, and a class of probability measures $\mathbb{P}_\theta$ indexed by a model parameter $\theta$. Now, the random variable $X: \Omega \rightarrow \mathbb{R}$ is just a mapping defined on the domain $\Omega$. The random variable itself does not depend in any way on the parameter $\theta$, and so it is wrong to write it as a function $X(\theta)$. It is of course true that the probability distribution of $X$ depends on $\theta$, since the latter affects the probability measure over the sample space. However, it does not affect the sample space itself.$\dagger$ Consequently, when you are dealing with a statistic, which is just a function of the observed random variables, this also does not depend on $\theta$, but its distribution usually does. (If not, it is an ancillary statistic,) $\dagger$ This treatment has taken $\theta$ as an index for the probability measure, but the same result occurs under a Bayesian treatment where $\theta$ is regarded as a random variable on $\Omega$ and the behaviour of $X$ is treated conditionally on the parameter.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
The confusion here stems from conflating a random variable with its distribution. To be clear about the issue, a random variable is not a function of the model parameters, but its distribution is. Ta
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? The confusion here stems from conflating a random variable with its distribution. To be clear about the issue, a random variable is not a function of the model parameters, but its distribution is. Taking things back to their foundations, you have some probability space that consists of a sample space $\Omega$, a class of subsets on that space, and a class of probability measures $\mathbb{P}_\theta$ indexed by a model parameter $\theta$. Now, the random variable $X: \Omega \rightarrow \mathbb{R}$ is just a mapping defined on the domain $\Omega$. The random variable itself does not depend in any way on the parameter $\theta$, and so it is wrong to write it as a function $X(\theta)$. It is of course true that the probability distribution of $X$ depends on $\theta$, since the latter affects the probability measure over the sample space. However, it does not affect the sample space itself.$\dagger$ Consequently, when you are dealing with a statistic, which is just a function of the observed random variables, this also does not depend on $\theta$, but its distribution usually does. (If not, it is an ancillary statistic,) $\dagger$ This treatment has taken $\theta$ as an index for the probability measure, but the same result occurs under a Bayesian treatment where $\theta$ is regarded as a random variable on $\Omega$ and the behaviour of $X$ is treated conditionally on the parameter.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? The confusion here stems from conflating a random variable with its distribution. To be clear about the issue, a random variable is not a function of the model parameters, but its distribution is. Ta
46,546
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
While the other answers (so far) are quite to the point and valid, I would like to add another direction to the discussion that relates to both fiducial inference (Fisher's pet theory) and a form of sampling called "perfect sampling" (or "sampling from the past"). Since a random variable is a measurable function from a (probability) space $(\Omega,\mathbb{P})$ to $\mathbb{R}$ (or $\mathbb{R}^n$), $X:\Omega\to\mathbb{R}$, the function may itself depend on a parameter $\theta$ if its distribution depends on $\theta$, in the sense that $X=\Psi(\omega,\theta)$. For instance, if $F_\theta$ denotes the cdf of $X$, we can write $X=F_\theta^{-1}(U)$ where $U$ is a uniform $\mathcal{U}(0,1)$ random variable. In this sense, $X$ (and the sample $(X_1,\ldots,X_n)$ as well) can be written as a [known] function of the [unknown] parameter $\theta$ and a fixed distribution [unobserved] random vector $\xi$, $$(X_1,\ldots,X_n)=\Psi(\xi,\theta)$$ This representation is eminently useful for simulation, either for the production of (pseudo-) samples from $F_\theta$ as in the inverse cdf approach, or for achieving "perfect" simulation. And for conducting inference by inverting the equation in $\theta$ into a distribution as in fiducial inference. Called by Efron Fisher's biggest blunder. To relate with the previous answers, this [distributional] dependence of $X$ on [the true value of] $\theta$ does not imply that one can build a statistic that depends on $\theta$ because in the above equation both $\theta$ and $\xi$ are unobserved. Which is the whole point for conducting inference.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter?
While the other answers (so far) are quite to the point and valid, I would like to add another direction to the discussion that relates to both fiducial inference (Fisher's pet theory) and a form of
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? While the other answers (so far) are quite to the point and valid, I would like to add another direction to the discussion that relates to both fiducial inference (Fisher's pet theory) and a form of sampling called "perfect sampling" (or "sampling from the past"). Since a random variable is a measurable function from a (probability) space $(\Omega,\mathbb{P})$ to $\mathbb{R}$ (or $\mathbb{R}^n$), $X:\Omega\to\mathbb{R}$, the function may itself depend on a parameter $\theta$ if its distribution depends on $\theta$, in the sense that $X=\Psi(\omega,\theta)$. For instance, if $F_\theta$ denotes the cdf of $X$, we can write $X=F_\theta^{-1}(U)$ where $U$ is a uniform $\mathcal{U}(0,1)$ random variable. In this sense, $X$ (and the sample $(X_1,\ldots,X_n)$ as well) can be written as a [known] function of the [unknown] parameter $\theta$ and a fixed distribution [unobserved] random vector $\xi$, $$(X_1,\ldots,X_n)=\Psi(\xi,\theta)$$ This representation is eminently useful for simulation, either for the production of (pseudo-) samples from $F_\theta$ as in the inverse cdf approach, or for achieving "perfect" simulation. And for conducting inference by inverting the equation in $\theta$ into a distribution as in fiducial inference. Called by Efron Fisher's biggest blunder. To relate with the previous answers, this [distributional] dependence of $X$ on [the true value of] $\theta$ does not imply that one can build a statistic that depends on $\theta$ because in the above equation both $\theta$ and $\xi$ are unobserved. Which is the whole point for conducting inference.
Statistics can't be a function of a parameter - but isn't the sample a function of the parameter? While the other answers (so far) are quite to the point and valid, I would like to add another direction to the discussion that relates to both fiducial inference (Fisher's pet theory) and a form of
46,547
Batch Normalization decreasing model accuracy
Try putting your Batch Normalization layer AFTER activation. Because what it's doing right now is effectively killing off half of your gradient on each layer - you normalize to 0 mean, which means only half of your ReLUs are firing, and you get vanishing gradient.
Batch Normalization decreasing model accuracy
Try putting your Batch Normalization layer AFTER activation. Because what it's doing right now is effectively killing off half of your gradient on each layer - you normalize to 0 mean, which means onl
Batch Normalization decreasing model accuracy Try putting your Batch Normalization layer AFTER activation. Because what it's doing right now is effectively killing off half of your gradient on each layer - you normalize to 0 mean, which means only half of your ReLUs are firing, and you get vanishing gradient.
Batch Normalization decreasing model accuracy Try putting your Batch Normalization layer AFTER activation. Because what it's doing right now is effectively killing off half of your gradient on each layer - you normalize to 0 mean, which means onl
46,548
Easy post-hoc tests when meta-analyzing with the `metafor` package in r
You could use the contrMat() function. Something like this should work: summary(glht(fit, linfct=cbind(contrMat(rep(1,7), type="Tukey"))), test=adjusted("none")) You might want to consider an adjustment for multiple testing though. See help(summary.glht) for some options.
Easy post-hoc tests when meta-analyzing with the `metafor` package in r
You could use the contrMat() function. Something like this should work: summary(glht(fit, linfct=cbind(contrMat(rep(1,7), type="Tukey"))), test=adjusted("none")) You might want to consider an adjustm
Easy post-hoc tests when meta-analyzing with the `metafor` package in r You could use the contrMat() function. Something like this should work: summary(glht(fit, linfct=cbind(contrMat(rep(1,7), type="Tukey"))), test=adjusted("none")) You might want to consider an adjustment for multiple testing though. See help(summary.glht) for some options.
Easy post-hoc tests when meta-analyzing with the `metafor` package in r You could use the contrMat() function. Something like this should work: summary(glht(fit, linfct=cbind(contrMat(rep(1,7), type="Tukey"))), test=adjusted("none")) You might want to consider an adjustm
46,549
Why can minimizing $\|w\|$ be solved by minimizing $\frac{\|w\|^2}{2}$?
Notice that $\frac{1}{x}$ is a decreasing function over the positive domain and $\frac{x^2}{2}$ is an increasing function over the non-negative domain. If $g$ is a decreasing function (a function where as the input increases, the output decreases). Maximizing $f_1(x)$ is equivalent to minimizing $g(f_1(x))$. Here $f_1(w)=\frac{1}{\|w\|}$, and $g(x)=\frac{1}{x}$, hence $g(f_1(w))=\|w\|$. If $h$ is an increasing function (a function where if the input increases, the output increases, similarly, if the input decreases, the output decreases). Minimizing $f_2(x)$ is equivalent to minimizing $h(f_2(x))$. Here $f_2(w)=\|w\|$ and $h(x)=\frac{x^2}{2}$, hence $h(f_2(w))=\frac{\|w\|^2}{2}$.
Why can minimizing $\|w\|$ be solved by minimizing $\frac{\|w\|^2}{2}$?
Notice that $\frac{1}{x}$ is a decreasing function over the positive domain and $\frac{x^2}{2}$ is an increasing function over the non-negative domain. If $g$ is a decreasing function (a function wher
Why can minimizing $\|w\|$ be solved by minimizing $\frac{\|w\|^2}{2}$? Notice that $\frac{1}{x}$ is a decreasing function over the positive domain and $\frac{x^2}{2}$ is an increasing function over the non-negative domain. If $g$ is a decreasing function (a function where as the input increases, the output decreases). Maximizing $f_1(x)$ is equivalent to minimizing $g(f_1(x))$. Here $f_1(w)=\frac{1}{\|w\|}$, and $g(x)=\frac{1}{x}$, hence $g(f_1(w))=\|w\|$. If $h$ is an increasing function (a function where if the input increases, the output increases, similarly, if the input decreases, the output decreases). Minimizing $f_2(x)$ is equivalent to minimizing $h(f_2(x))$. Here $f_2(w)=\|w\|$ and $h(x)=\frac{x^2}{2}$, hence $h(f_2(w))=\frac{\|w\|^2}{2}$.
Why can minimizing $\|w\|$ be solved by minimizing $\frac{\|w\|^2}{2}$? Notice that $\frac{1}{x}$ is a decreasing function over the positive domain and $\frac{x^2}{2}$ is an increasing function over the non-negative domain. If $g$ is a decreasing function (a function wher
46,550
Seed in a grid search
The premise that the same random seed will lead two randomized algorithms to have more similar performance is extremely dubious (except perhaps for the most similar and specially structured of algorithms over the smallest of samples). An analogy Using a Monte-Carlo simulation, let's say you're trying to estimate a casino's house take in: Game A: blackjack where the dealer hits on soft 17 Game B: blackjack where the dealer stands on soft 17 Would it make the comparison less noisy if Game A and Game B used the same order of cards (i.e. started with the same random seed)? No! (Not in any meaningful way.) The moment Game A leads the dealer to take an additional card (compared to Game B), the games are no longer in sync: players will be dealt different hands, cards that would have gone to the dealer instead go to a player etc.... Just one card offset makes a huge difference, and everything will just diverge from there. There may be some special case algorithms where the small differences don't just compound, but I would think these are unusual cases.
Seed in a grid search
The premise that the same random seed will lead two randomized algorithms to have more similar performance is extremely dubious (except perhaps for the most similar and specially structured of algorit
Seed in a grid search The premise that the same random seed will lead two randomized algorithms to have more similar performance is extremely dubious (except perhaps for the most similar and specially structured of algorithms over the smallest of samples). An analogy Using a Monte-Carlo simulation, let's say you're trying to estimate a casino's house take in: Game A: blackjack where the dealer hits on soft 17 Game B: blackjack where the dealer stands on soft 17 Would it make the comparison less noisy if Game A and Game B used the same order of cards (i.e. started with the same random seed)? No! (Not in any meaningful way.) The moment Game A leads the dealer to take an additional card (compared to Game B), the games are no longer in sync: players will be dealt different hands, cards that would have gone to the dealer instead go to a player etc.... Just one card offset makes a huge difference, and everything will just diverge from there. There may be some special case algorithms where the small differences don't just compound, but I would think these are unusual cases.
Seed in a grid search The premise that the same random seed will lead two randomized algorithms to have more similar performance is extremely dubious (except perhaps for the most similar and specially structured of algorit
46,551
Seed in a grid search
That is an ongoing reseach topic (hyperparameter optimization). A very popular technique following the idea you formulate in your question is random search. Once you see it, the idea is quite simple, and it is shown to work well in practice. Consider you search space with a finite maximum. Take the 5% interval around the maximum. If you sample at random, you have 5% chance of landing in that interval. The probability that when you sample n times you hit at least one time this interval is, $$ 1-(1-0.05)^n $$ Now, you need to determine, how many times you need to sample. First you set a threshold for that probability. For example, you want to have a 95% confidence that you will eventually hit the interval once. Then it yields that n has to be at least 60.
Seed in a grid search
That is an ongoing reseach topic (hyperparameter optimization). A very popular technique following the idea you formulate in your question is random search. Once you see it, the idea is quite simple,
Seed in a grid search That is an ongoing reseach topic (hyperparameter optimization). A very popular technique following the idea you formulate in your question is random search. Once you see it, the idea is quite simple, and it is shown to work well in practice. Consider you search space with a finite maximum. Take the 5% interval around the maximum. If you sample at random, you have 5% chance of landing in that interval. The probability that when you sample n times you hit at least one time this interval is, $$ 1-(1-0.05)^n $$ Now, you need to determine, how many times you need to sample. First you set a threshold for that probability. For example, you want to have a 95% confidence that you will eventually hit the interval once. Then it yields that n has to be at least 60.
Seed in a grid search That is an ongoing reseach topic (hyperparameter optimization). A very popular technique following the idea you formulate in your question is random search. Once you see it, the idea is quite simple,
46,552
Seed in a grid search
It seems straightforward, that you ONLY want to test the parameters, and the less variance, the better Well, it isn't that straightforward. @MatthewGunn already explained that it typically won't help as you apparently thought. In general, if you encounter variance there are two quite opposide strategies of dealing with it. (As you suggest,) reduce it as much as possible by restricting experimental conditions, or measure and account for it. Strategy 1 will only help if the restricted conditions can be applied to your further process. If they can not, you need to go with approach 2. Besides, there are further points to consider: If you fix the seed and for the algorithm you tune that does indeed lower the variance, then your conclusions are limited to that one seed (always the case with strategy 1). This may or may not acceptable for the task at hand - but you need to consider this point carefully. Besides algorithms where the seed has negligible influence on the randomness (see @MattewGunn's answer) there are also algorithms where the combination of seed and training cases together lead to variance. In that situation, you may be successfully suppressing variance during the grid search using the same training set and the same seed but e.g. a final model built form the larger base of (training + optimization test cases) for training will be subject to additional variance. In other words, your grid search overfits. Strategy 2 becomes particularly important, if some parameter of your grid may be influencing this variance: you'd then be able to consider whether the apparent optimum in your grid may be due to variance.
Seed in a grid search
It seems straightforward, that you ONLY want to test the parameters, and the less variance, the better Well, it isn't that straightforward. @MatthewGunn already explained that it typically won't help
Seed in a grid search It seems straightforward, that you ONLY want to test the parameters, and the less variance, the better Well, it isn't that straightforward. @MatthewGunn already explained that it typically won't help as you apparently thought. In general, if you encounter variance there are two quite opposide strategies of dealing with it. (As you suggest,) reduce it as much as possible by restricting experimental conditions, or measure and account for it. Strategy 1 will only help if the restricted conditions can be applied to your further process. If they can not, you need to go with approach 2. Besides, there are further points to consider: If you fix the seed and for the algorithm you tune that does indeed lower the variance, then your conclusions are limited to that one seed (always the case with strategy 1). This may or may not acceptable for the task at hand - but you need to consider this point carefully. Besides algorithms where the seed has negligible influence on the randomness (see @MattewGunn's answer) there are also algorithms where the combination of seed and training cases together lead to variance. In that situation, you may be successfully suppressing variance during the grid search using the same training set and the same seed but e.g. a final model built form the larger base of (training + optimization test cases) for training will be subject to additional variance. In other words, your grid search overfits. Strategy 2 becomes particularly important, if some parameter of your grid may be influencing this variance: you'd then be able to consider whether the apparent optimum in your grid may be due to variance.
Seed in a grid search It seems straightforward, that you ONLY want to test the parameters, and the less variance, the better Well, it isn't that straightforward. @MatthewGunn already explained that it typically won't help
46,553
Seed in a grid search
It seems that there is no scientific consensus on it. I think that Monte Carlo analogy by @Matthew is not perfect. E.g. if you had a neural network and you did a grid search of learning rate and momentum, then using the same random seed would lead to the same initialization which seems a good idea, so I agree with your intuition. Key point here is different. If variance coming from random seed is significant compared to variance coming from different choice of hyper-parameter, then grid search may not have sens. For different seeds it may find different optimal hyper-points. If such a case occurs, you may want to perform repeated cross validation, for more see this site So the final answer is: if fixing seed matters, something is going wrong.
Seed in a grid search
It seems that there is no scientific consensus on it. I think that Monte Carlo analogy by @Matthew is not perfect. E.g. if you had a neural network and you did a grid search of learning rate and mome
Seed in a grid search It seems that there is no scientific consensus on it. I think that Monte Carlo analogy by @Matthew is not perfect. E.g. if you had a neural network and you did a grid search of learning rate and momentum, then using the same random seed would lead to the same initialization which seems a good idea, so I agree with your intuition. Key point here is different. If variance coming from random seed is significant compared to variance coming from different choice of hyper-parameter, then grid search may not have sens. For different seeds it may find different optimal hyper-points. If such a case occurs, you may want to perform repeated cross validation, for more see this site So the final answer is: if fixing seed matters, something is going wrong.
Seed in a grid search It seems that there is no scientific consensus on it. I think that Monte Carlo analogy by @Matthew is not perfect. E.g. if you had a neural network and you did a grid search of learning rate and mome
46,554
Gaussian Process smooths in mgcv: choosing between spherical and exponential covariance functions
The gp smooth type is only discussed in the second edition of Simon's book as it was added to the mgcv long after the first edition went to press. The main difference to consider is that spherical covariance function is not entirely smooth; there is a discontinuity which can pass through to the resultant smoother. The Matérn and power exponential functions do not suffer from this problem. The discontinuity is due to the spherical covariance function taking a value if 0 if the distance between two points is greater than $\rho$, the range parameter: $$ c(d)=\begin{cases} 1 - 1.5d / \rho + 0.5(d/\rho)^2, & \text{if $d \leq \rho$}.\\ 0, & \text{otherwise}. \end{cases} $$ where $d$ is the distance between a pair of points. We can see the effect of this in the following R example, modified from ?smooth.construct.gp.smooth library("mgcv") set.seed(24) eg <- gamSim(2, n = 300, scale = 0.05) b <- gam(y ~ s(x, z, bs= "gp", k = 50, m = c(3, 0.175)), data = eg$data, method = "REML") ## Matern spline b1 <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(1, 0.175)), data = eg$data, method = "REML") ## spherical b2 <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(2, 0.175)), data = eg$data, method = "REML") ## exponential op <- par(mfrow=c(2,2), mar = c(0.5,0.5,3,0.5)) with(eg$truth, persp(x, z, f, theta = 30, main = "Truth")) ## truth vis.gam(b, theta=30, main = "Matern") vis.gam(b1, theta=30, main = "Spherical") vis.gam(b2, theta=30, main = "Exponential") par(op) For the same value of $\rho$ we still recover a smooth surface with the Matern and exponential covariance functions unlike with the spherical one. That said, using a profile likelihood approach to determine an optimal value for $\rho$ should result in a fit closer to the Matern or exponential fits show in the figure ## slightly modified from Wood (2017, pp. 362) REML <- r <- seq(0.1, 1.5, by = 0.05) for (i in seq_along(r)) { m <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(1, r[i])), data = eg$data, method = "REML") REML[i] <- m$gcv.ubre } plot(REML ~ r, type = "o", pch = 16, ylab = expression(rho)) There is a minimum in the REML score at $\rho = 0.65$ in this sequence of values tried, which, I understand is close to the true effective range of ~ 0.7 for this example, and which results in a fit that is smooth like the Matern and exponential fits show earlier I doubt you'll find too much difference between the various covariance functions. The main issue will be to set up a profile likelihood loop to fit the GAM for a series of values for the range parameter or each function and to choose the power parameter. Then go with the parameters of the covariance function that results in lowest value of the REML or ML score. Example code above shows how this can be done for $\rho$. The second edition of Simon's book has an example of this. In the spatial context you might get away with the defaults - which basically say that the effective range of the spatial correlation is as large as the maximal distance between the pairs of observations - but it is a relatively simple thing to check with a loop over a range of values for this parameter. I'm not aware that you can use gam.check to fully diagnose issues with the GP smoothers; you need to specify values of any required parameters for the covariance functions for these smoothers to be estimated using the quadratic penalty approach adopted in mgcv. The output from gam.check will confirm if you have the right basis dimension but you still need to optimise the other parameters for the covariance function you are using. Wood, S. N. (2017). Generalized Additive Models: An Introduction with R, Second Edition. CRC Press.
Gaussian Process smooths in mgcv: choosing between spherical and exponential covariance functions
The gp smooth type is only discussed in the second edition of Simon's book as it was added to the mgcv long after the first edition went to press. The main difference to consider is that spherical cov
Gaussian Process smooths in mgcv: choosing between spherical and exponential covariance functions The gp smooth type is only discussed in the second edition of Simon's book as it was added to the mgcv long after the first edition went to press. The main difference to consider is that spherical covariance function is not entirely smooth; there is a discontinuity which can pass through to the resultant smoother. The Matérn and power exponential functions do not suffer from this problem. The discontinuity is due to the spherical covariance function taking a value if 0 if the distance between two points is greater than $\rho$, the range parameter: $$ c(d)=\begin{cases} 1 - 1.5d / \rho + 0.5(d/\rho)^2, & \text{if $d \leq \rho$}.\\ 0, & \text{otherwise}. \end{cases} $$ where $d$ is the distance between a pair of points. We can see the effect of this in the following R example, modified from ?smooth.construct.gp.smooth library("mgcv") set.seed(24) eg <- gamSim(2, n = 300, scale = 0.05) b <- gam(y ~ s(x, z, bs= "gp", k = 50, m = c(3, 0.175)), data = eg$data, method = "REML") ## Matern spline b1 <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(1, 0.175)), data = eg$data, method = "REML") ## spherical b2 <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(2, 0.175)), data = eg$data, method = "REML") ## exponential op <- par(mfrow=c(2,2), mar = c(0.5,0.5,3,0.5)) with(eg$truth, persp(x, z, f, theta = 30, main = "Truth")) ## truth vis.gam(b, theta=30, main = "Matern") vis.gam(b1, theta=30, main = "Spherical") vis.gam(b2, theta=30, main = "Exponential") par(op) For the same value of $\rho$ we still recover a smooth surface with the Matern and exponential covariance functions unlike with the spherical one. That said, using a profile likelihood approach to determine an optimal value for $\rho$ should result in a fit closer to the Matern or exponential fits show in the figure ## slightly modified from Wood (2017, pp. 362) REML <- r <- seq(0.1, 1.5, by = 0.05) for (i in seq_along(r)) { m <- gam(y ~ s(x, z, bs = "gp", k = 50, m = c(1, r[i])), data = eg$data, method = "REML") REML[i] <- m$gcv.ubre } plot(REML ~ r, type = "o", pch = 16, ylab = expression(rho)) There is a minimum in the REML score at $\rho = 0.65$ in this sequence of values tried, which, I understand is close to the true effective range of ~ 0.7 for this example, and which results in a fit that is smooth like the Matern and exponential fits show earlier I doubt you'll find too much difference between the various covariance functions. The main issue will be to set up a profile likelihood loop to fit the GAM for a series of values for the range parameter or each function and to choose the power parameter. Then go with the parameters of the covariance function that results in lowest value of the REML or ML score. Example code above shows how this can be done for $\rho$. The second edition of Simon's book has an example of this. In the spatial context you might get away with the defaults - which basically say that the effective range of the spatial correlation is as large as the maximal distance between the pairs of observations - but it is a relatively simple thing to check with a loop over a range of values for this parameter. I'm not aware that you can use gam.check to fully diagnose issues with the GP smoothers; you need to specify values of any required parameters for the covariance functions for these smoothers to be estimated using the quadratic penalty approach adopted in mgcv. The output from gam.check will confirm if you have the right basis dimension but you still need to optimise the other parameters for the covariance function you are using. Wood, S. N. (2017). Generalized Additive Models: An Introduction with R, Second Edition. CRC Press.
Gaussian Process smooths in mgcv: choosing between spherical and exponential covariance functions The gp smooth type is only discussed in the second edition of Simon's book as it was added to the mgcv long after the first edition went to press. The main difference to consider is that spherical cov
46,555
Is non-integer power of a kernel still a kernel?
You have exactly defined the class of infinitely divisible kernels, i.e., a kernel $k(x, y)$ such that $k(x, y)^p$ is a kernel for any $p > 0$. Not all kernels are infinitely divisible. Many of the kernels you know and love are infinitely divisible.
Is non-integer power of a kernel still a kernel?
You have exactly defined the class of infinitely divisible kernels, i.e., a kernel $k(x, y)$ such that $k(x, y)^p$ is a kernel for any $p > 0$. Not all kernels are infinitely divisible. Many of the
Is non-integer power of a kernel still a kernel? You have exactly defined the class of infinitely divisible kernels, i.e., a kernel $k(x, y)$ such that $k(x, y)^p$ is a kernel for any $p > 0$. Not all kernels are infinitely divisible. Many of the kernels you know and love are infinitely divisible.
Is non-integer power of a kernel still a kernel? You have exactly defined the class of infinitely divisible kernels, i.e., a kernel $k(x, y)$ such that $k(x, y)^p$ is a kernel for any $p > 0$. Not all kernels are infinitely divisible. Many of the
46,556
What should we do when changing SGD optimizer to Adam optimizer?
In my experience, changing optimizers is not a simple matter of swapping one for the other. Instead, changing optimizers also interacts with several other configuration choices in the neural network. The optimizer interacts with the initialization scheme, so this might need to be changed. The learning rate may need to be changed. The learning rate schedule may need to be adjusted. In some cases, SGD with momentum can be a big improvement over Adam. See: "The Marginal Value of Adaptive Gradient Methods in Machine Learning" by Ashia C. Wilson, Rebecca Roelofs, Mitchell Stern, Nathan Srebro, Benjamin Recht Adaptive optimization methods, which perform local optimization with a metric constructed from the history of iterates, are becoming increasingly popular for training deep neural networks. Examples include AdaGrad, RMSProp, and Adam. We show that for simple overparameterized problems, adaptive methods often find drastically different solutions than gradient descent (GD) or stochastic gradient descent (SGD). We construct an illustrative binary classification problem where the data is linearly separable, GD and SGD achieve zero test error, and AdaGrad, Adam, and RMSProp attain test errors arbitrarily close to half. We additionally study the empirical generalization capability of adaptive methods on several state-of-the-art deep learning models. We observe that the solutions found by adaptive methods generalize worse (often significantly worse) than SGD, even when these solutions have better training performance. These results suggest that practitioners should reconsider the use of adaptive methods to train neural networks.
What should we do when changing SGD optimizer to Adam optimizer?
In my experience, changing optimizers is not a simple matter of swapping one for the other. Instead, changing optimizers also interacts with several other configuration choices in the neural network.
What should we do when changing SGD optimizer to Adam optimizer? In my experience, changing optimizers is not a simple matter of swapping one for the other. Instead, changing optimizers also interacts with several other configuration choices in the neural network. The optimizer interacts with the initialization scheme, so this might need to be changed. The learning rate may need to be changed. The learning rate schedule may need to be adjusted. In some cases, SGD with momentum can be a big improvement over Adam. See: "The Marginal Value of Adaptive Gradient Methods in Machine Learning" by Ashia C. Wilson, Rebecca Roelofs, Mitchell Stern, Nathan Srebro, Benjamin Recht Adaptive optimization methods, which perform local optimization with a metric constructed from the history of iterates, are becoming increasingly popular for training deep neural networks. Examples include AdaGrad, RMSProp, and Adam. We show that for simple overparameterized problems, adaptive methods often find drastically different solutions than gradient descent (GD) or stochastic gradient descent (SGD). We construct an illustrative binary classification problem where the data is linearly separable, GD and SGD achieve zero test error, and AdaGrad, Adam, and RMSProp attain test errors arbitrarily close to half. We additionally study the empirical generalization capability of adaptive methods on several state-of-the-art deep learning models. We observe that the solutions found by adaptive methods generalize worse (often significantly worse) than SGD, even when these solutions have better training performance. These results suggest that practitioners should reconsider the use of adaptive methods to train neural networks.
What should we do when changing SGD optimizer to Adam optimizer? In my experience, changing optimizers is not a simple matter of swapping one for the other. Instead, changing optimizers also interacts with several other configuration choices in the neural network.
46,557
Find marginal distribution of $K$-variate Dirichlet
The marginal distribution of $x_j$ is, $$ p(x_j) = \frac{1}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-2} x_k} \prod_{p=1}^{K-1} x_p^{a_p - 1} \left( 1 - \sum_{l=1}^{K-1} x_l \right)^{a_K - 1} d x_{K-1} d x_{K-2} \dots d x_1, $$ where $\bf a$ is the vector of all $a_j$ values, $B({\bf a})$ is the multivariate Beta function, and the integration variables do not include $d x_j.$ We can marginalize out $x_{K-1}$ by doing the innermost integral, $$ \int_0^{1 - \sum_{k =1}^{K-2} x_k} x_{K-1}^{a_{K-1} -1} \left( 1 - \sum_{l=1}^{K-1} x_l \right)^{a_K - 1} d x_{K-1}. $$ Let $z (1 - \sum_{k=1}^{K-2} x_k) = x_{K-1}.$ Then the above integral becomes, $$ \begin{split} & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_{K-1}-1} \int_0^1 z^{a_{K-1}-1} \left( [1 - z] \left[1 - \sum_{k=1}^{K-2} x_k \right] \right)^{a_K -1} \left( 1 - \sum_{k=1}^{K-2} x_k \right) dz \\ = & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} \int_0^1 z^{a_{K-1} -1} (1-z)^{a_K -1} dz \\ = & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} B(a_{K-1}, a_K). \end{split} $$ Plugging this into $p(x_j)$ we have, $$ p(x_j) = \frac{B(a_{K-1}, a_K)}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-3} x_k} \prod_{p=1}^{K-2} x_p^{a_p - 1} \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} d x_{K-2} d x_{K-3} \dots d x_1. $$ Compare this to the original expression. This is very similar, except that the "determined" value $x_K$ has its role replaced by $x_K + x_{K-1}.$ We can now marginalize out $x_{K-2}$ purely by analogy to how we marginalized $x_{K-1}$ (i.e. replacing $a_K$ with $a_K + a_{K-1},$ etc.): $$ p(x_j) = \frac{B(a_{K-1}, a_K) B(a_{K-2}, a_{K-1} + a_K)}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-4} x_k} \prod_{p=1}^{K-3} x_p^{a_p - 1} \left( 1 - \sum_{k=1}^{K-3} x_k \right)^{a_K + a_{K-1} + a_{K-2} -1} d x_{K-3} d x_{K-3} \dots d x_1. $$ Note, however, that $B(a_{K-1},a_{K}) B(a_{K-2}, a_{K-1} + a_K) = B(a_{K-2}, a_{K-1}, a_K).$ As we can see, each iteration of this procedure involves taking out the last factor from the product in the integral, the last term from the sum in the integral, adding the last $a$ coefficient to the exponent on the sum, and adding the same coefficient to the list of variables in the multivariate Beta coefficient outside the integral. We need only apply this pattern to all variables in the integral, from the inside out. We get, $$ p(x_j) = \frac{B({\bf a}_{-j})}{B({\bf a})} x_j^{a_j -1} (1 - x_j)^{\sum_{i \ne j} a_i -1}, $$ where ${\bf a}_{-j}$ is all values of $a_k$ for $k \ne j.$ Note that $\frac{B({\bf a}_{-j})}{B({\bf a})}$ is just $\frac{1}{B(a_j, \sum_{i \ne j} a_i)}.$ Therefore, $$ p(x_j) = \text{Beta}(x_j; a_j, \sum_{i \ne j} a_i). $$ This was just a general version of the link provided by @marmle. (I even stole the idea of the integration substitution from it.) EDIT: It's not clear from the notation, but in all of the integrals above, the integration variables do not include $x_j.$
Find marginal distribution of $K$-variate Dirichlet
The marginal distribution of $x_j$ is, $$ p(x_j) = \frac{1}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-2} x_k} \prod_{p=1}^{K-1} x_p^{a_p - 1} \left( 1 - \su
Find marginal distribution of $K$-variate Dirichlet The marginal distribution of $x_j$ is, $$ p(x_j) = \frac{1}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-2} x_k} \prod_{p=1}^{K-1} x_p^{a_p - 1} \left( 1 - \sum_{l=1}^{K-1} x_l \right)^{a_K - 1} d x_{K-1} d x_{K-2} \dots d x_1, $$ where $\bf a$ is the vector of all $a_j$ values, $B({\bf a})$ is the multivariate Beta function, and the integration variables do not include $d x_j.$ We can marginalize out $x_{K-1}$ by doing the innermost integral, $$ \int_0^{1 - \sum_{k =1}^{K-2} x_k} x_{K-1}^{a_{K-1} -1} \left( 1 - \sum_{l=1}^{K-1} x_l \right)^{a_K - 1} d x_{K-1}. $$ Let $z (1 - \sum_{k=1}^{K-2} x_k) = x_{K-1}.$ Then the above integral becomes, $$ \begin{split} & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_{K-1}-1} \int_0^1 z^{a_{K-1}-1} \left( [1 - z] \left[1 - \sum_{k=1}^{K-2} x_k \right] \right)^{a_K -1} \left( 1 - \sum_{k=1}^{K-2} x_k \right) dz \\ = & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} \int_0^1 z^{a_{K-1} -1} (1-z)^{a_K -1} dz \\ = & \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} B(a_{K-1}, a_K). \end{split} $$ Plugging this into $p(x_j)$ we have, $$ p(x_j) = \frac{B(a_{K-1}, a_K)}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-3} x_k} \prod_{p=1}^{K-2} x_p^{a_p - 1} \left( 1 - \sum_{k=1}^{K-2} x_k \right)^{a_K + a_{K-1} -1} d x_{K-2} d x_{K-3} \dots d x_1. $$ Compare this to the original expression. This is very similar, except that the "determined" value $x_K$ has its role replaced by $x_K + x_{K-1}.$ We can now marginalize out $x_{K-2}$ purely by analogy to how we marginalized $x_{K-1}$ (i.e. replacing $a_K$ with $a_K + a_{K-1},$ etc.): $$ p(x_j) = \frac{B(a_{K-1}, a_K) B(a_{K-2}, a_{K-1} + a_K)}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-4} x_k} \prod_{p=1}^{K-3} x_p^{a_p - 1} \left( 1 - \sum_{k=1}^{K-3} x_k \right)^{a_K + a_{K-1} + a_{K-2} -1} d x_{K-3} d x_{K-3} \dots d x_1. $$ Note, however, that $B(a_{K-1},a_{K}) B(a_{K-2}, a_{K-1} + a_K) = B(a_{K-2}, a_{K-1}, a_K).$ As we can see, each iteration of this procedure involves taking out the last factor from the product in the integral, the last term from the sum in the integral, adding the last $a$ coefficient to the exponent on the sum, and adding the same coefficient to the list of variables in the multivariate Beta coefficient outside the integral. We need only apply this pattern to all variables in the integral, from the inside out. We get, $$ p(x_j) = \frac{B({\bf a}_{-j})}{B({\bf a})} x_j^{a_j -1} (1 - x_j)^{\sum_{i \ne j} a_i -1}, $$ where ${\bf a}_{-j}$ is all values of $a_k$ for $k \ne j.$ Note that $\frac{B({\bf a}_{-j})}{B({\bf a})}$ is just $\frac{1}{B(a_j, \sum_{i \ne j} a_i)}.$ Therefore, $$ p(x_j) = \text{Beta}(x_j; a_j, \sum_{i \ne j} a_i). $$ This was just a general version of the link provided by @marmle. (I even stole the idea of the integration substitution from it.) EDIT: It's not clear from the notation, but in all of the integrals above, the integration variables do not include $x_j.$
Find marginal distribution of $K$-variate Dirichlet The marginal distribution of $x_j$ is, $$ p(x_j) = \frac{1}{B({\bf a})} \int_0^{1 - x_j} \int_0^{1 - x_j - x_1} \cdots \int_0^{1 - \sum_{k =1}^{K-2} x_k} \prod_{p=1}^{K-1} x_p^{a_p - 1} \left( 1 - \su
46,558
Poisson process: how long until we observe two events separated by at least a specified amount of time?
This answer requires solving three subproblems: How many bus arrivals $N$ do I expect to suffer through before experiencing a time between bus arrivals $> T_{min}$? How long is the expected wait between buses $\mathbb{E}T_s$ given that $T_s \leq T_{min}$? How long is the expected wait between two consecutive buses $\mathbb{E}T_l$ given that $T_l > T_{min}$? The final answer is equal to $\mathbb{E}N \mathbb{E}T_s + \mathbb{E}T_l$, or perhaps just $\mathbb{E}N \mathbb{E}T_s$ if the time spent in the last interval isn't counted. The answer to 3 is quite easy, thanks to the Exponential / Poisson assumption. The memoryless property of the Exponential distribution implies that $\mathbb{E}T_l = T_{min} + T_0$. The answer to 2 is a little more involved; we have to find the expected value of the appropriate conditional random variate: $$\frac{\int_0^{T_{\min}}xe^{-x/T_0}\text{d}x}{T_0(1-e^{-T_{min}/T_0})}$$ which, using integration by parts, solves to: $$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}$$ As @Moormanly has observed, $N$ is distributed Geometric, in this case with parameter $p = \exp\{-T_{min}/T_0\}$. The expected value of a Geometric$(p)$ distribution is $(1-p)/p$, so, substituting and writing the full equation out, we get: $$\left(\frac{1-e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}\right)\left(\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}\right)+T_{min}+T_0$$ where the last two terms are optional depending upon the exact nature of the problem being solved. Making the obvious cancellation leads to: $$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}+T_{min}+T_0$$ and some further algebra gets us to: $$\frac{T_0}{e^{-T_{min}/T_0}}$$ Checking our results via simulation on your sample problem comes next. $T_0 = 10$ and $T_{min}=5$ gives us a calculated result of 16.483. Our simulation code: res <- rep(0,10000) for (i in 1:length(res)) { res[i] <- x <- rexp(1,1/10) while (x < 5) { x <- rexp(1,1/10) res[i] <- res[i] + x } } c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res)))) reports the simulated mean and the associated t-statistic for testing whether or not it is equal to the calculated value. The results are: > c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res)))) [1] 16.5793553 0.8998745 which would seem to confirm that we haven't messed up our algebra anywhere.
Poisson process: how long until we observe two events separated by at least a specified amount of ti
This answer requires solving three subproblems: How many bus arrivals $N$ do I expect to suffer through before experiencing a time between bus arrivals $> T_{min}$? How long is the expected wait betw
Poisson process: how long until we observe two events separated by at least a specified amount of time? This answer requires solving three subproblems: How many bus arrivals $N$ do I expect to suffer through before experiencing a time between bus arrivals $> T_{min}$? How long is the expected wait between buses $\mathbb{E}T_s$ given that $T_s \leq T_{min}$? How long is the expected wait between two consecutive buses $\mathbb{E}T_l$ given that $T_l > T_{min}$? The final answer is equal to $\mathbb{E}N \mathbb{E}T_s + \mathbb{E}T_l$, or perhaps just $\mathbb{E}N \mathbb{E}T_s$ if the time spent in the last interval isn't counted. The answer to 3 is quite easy, thanks to the Exponential / Poisson assumption. The memoryless property of the Exponential distribution implies that $\mathbb{E}T_l = T_{min} + T_0$. The answer to 2 is a little more involved; we have to find the expected value of the appropriate conditional random variate: $$\frac{\int_0^{T_{\min}}xe^{-x/T_0}\text{d}x}{T_0(1-e^{-T_{min}/T_0})}$$ which, using integration by parts, solves to: $$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}$$ As @Moormanly has observed, $N$ is distributed Geometric, in this case with parameter $p = \exp\{-T_{min}/T_0\}$. The expected value of a Geometric$(p)$ distribution is $(1-p)/p$, so, substituting and writing the full equation out, we get: $$\left(\frac{1-e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}\right)\left(\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}\right)+T_{min}+T_0$$ where the last two terms are optional depending upon the exact nature of the problem being solved. Making the obvious cancellation leads to: $$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}+T_{min}+T_0$$ and some further algebra gets us to: $$\frac{T_0}{e^{-T_{min}/T_0}}$$ Checking our results via simulation on your sample problem comes next. $T_0 = 10$ and $T_{min}=5$ gives us a calculated result of 16.483. Our simulation code: res <- rep(0,10000) for (i in 1:length(res)) { res[i] <- x <- rexp(1,1/10) while (x < 5) { x <- rexp(1,1/10) res[i] <- res[i] + x } } c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res)))) reports the simulated mean and the associated t-statistic for testing whether or not it is equal to the calculated value. The results are: > c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res)))) [1] 16.5793553 0.8998745 which would seem to confirm that we haven't messed up our algebra anywhere.
Poisson process: how long until we observe two events separated by at least a specified amount of ti This answer requires solving three subproblems: How many bus arrivals $N$ do I expect to suffer through before experiencing a time between bus arrivals $> T_{min}$? How long is the expected wait betw
46,559
Poisson process: how long until we observe two events separated by at least a specified amount of time?
Think first about the number of events you expect to observe, think next about the amount of time it will take to observe those events. Letting $N$ be the number of events before an inter-arrival time of at least $T_{min}$, see that $N$ is geometric with parameter $p=P(T_i>T_{min})$. Now let $T$ be the amount of time taken to observe these events. Expanding using total expectation: $$E[T]\\=\sum_{n=1}^\infty P(N=n) E[T|N=n]\\=\sum_{n=1}^\infty P(N=n) \bigg((n-1)E[T_i|T_i<T_{min}]+E[T_i|T_i \ge T_{min}]\bigg) $$
Poisson process: how long until we observe two events separated by at least a specified amount of ti
Think first about the number of events you expect to observe, think next about the amount of time it will take to observe those events. Letting $N$ be the number of events before an inter-arrival time
Poisson process: how long until we observe two events separated by at least a specified amount of time? Think first about the number of events you expect to observe, think next about the amount of time it will take to observe those events. Letting $N$ be the number of events before an inter-arrival time of at least $T_{min}$, see that $N$ is geometric with parameter $p=P(T_i>T_{min})$. Now let $T$ be the amount of time taken to observe these events. Expanding using total expectation: $$E[T]\\=\sum_{n=1}^\infty P(N=n) E[T|N=n]\\=\sum_{n=1}^\infty P(N=n) \bigg((n-1)E[T_i|T_i<T_{min}]+E[T_i|T_i \ge T_{min}]\bigg) $$
Poisson process: how long until we observe two events separated by at least a specified amount of ti Think first about the number of events you expect to observe, think next about the amount of time it will take to observe those events. Letting $N$ be the number of events before an inter-arrival time
46,560
KNN and K-folding in R
To use 5-fold cross validation in caret, you can set the "train control" as follows: trControl <- trainControl(method = "cv", number = 5) Then you can evaluate the accuracy of the KNN classifier with different values of k by cross validation using fit <- train(Species ~ ., method = "knn", tuneGrid = expand.grid(k = 1:10), trControl = trControl, metric = "Accuracy", data = iris) Output: k-Nearest Neighbors 150 samples 4 predictor 3 classes: 'setosa', 'versicolor', 'virginica' No pre-processing Resampling: Cross-Validated (5 fold) Summary of sample sizes: 120, 120, 120, 120, 120 Resampling results across tuning parameters: k Accuracy Kappa 1 0.9600000 0.94 2 0.9600000 0.94 3 0.9600000 0.94 4 0.9533333 0.93 5 0.9733333 0.96 6 0.9666667 0.95 7 0.9600000 0.94 8 0.9666667 0.95 9 0.9733333 0.96 10 0.9600000 0.94 Accuracy was used to select the optimal model using the largest value. The final value used for the model was k = 9. Useful ref: http://topepo.github.io/caret/index.html
KNN and K-folding in R
To use 5-fold cross validation in caret, you can set the "train control" as follows: trControl <- trainControl(method = "cv", number = 5) Then you can evaluate the accurac
KNN and K-folding in R To use 5-fold cross validation in caret, you can set the "train control" as follows: trControl <- trainControl(method = "cv", number = 5) Then you can evaluate the accuracy of the KNN classifier with different values of k by cross validation using fit <- train(Species ~ ., method = "knn", tuneGrid = expand.grid(k = 1:10), trControl = trControl, metric = "Accuracy", data = iris) Output: k-Nearest Neighbors 150 samples 4 predictor 3 classes: 'setosa', 'versicolor', 'virginica' No pre-processing Resampling: Cross-Validated (5 fold) Summary of sample sizes: 120, 120, 120, 120, 120 Resampling results across tuning parameters: k Accuracy Kappa 1 0.9600000 0.94 2 0.9600000 0.94 3 0.9600000 0.94 4 0.9533333 0.93 5 0.9733333 0.96 6 0.9666667 0.95 7 0.9600000 0.94 8 0.9666667 0.95 9 0.9733333 0.96 10 0.9600000 0.94 Accuracy was used to select the optimal model using the largest value. The final value used for the model was k = 9. Useful ref: http://topepo.github.io/caret/index.html
KNN and K-folding in R To use 5-fold cross validation in caret, you can set the "train control" as follows: trControl <- trainControl(method = "cv", number = 5) Then you can evaluate the accurac
46,561
In deep learning, what is the difference between "disentangled representation" and "distributed representation"
Let's say the following vectors are respectively representations for a ball: [1,0,0,0] and a car: [0,1,0,0] In this representation a single neuron learns the meaning of a ball or a car without having to rely on other neurons. This is a disentangled representation, which is meant to facilitate the understanding of artificial neural networks. This in contrast to distributed representations, for example, a ball: [0.1,-0.02,0.45,0.06] and a car: [-0.78,-0.1,0.83,0.01]. In this case, an object is represented by a particular location in the vector space. This type of representation is for example the outcome of the word2vec algorithms.
In deep learning, what is the difference between "disentangled representation" and "distributed repr
Let's say the following vectors are respectively representations for a ball: [1,0,0,0] and a car: [0,1,0,0] In this representation a single neuron learns the meaning of a ball or a car without havin
In deep learning, what is the difference between "disentangled representation" and "distributed representation" Let's say the following vectors are respectively representations for a ball: [1,0,0,0] and a car: [0,1,0,0] In this representation a single neuron learns the meaning of a ball or a car without having to rely on other neurons. This is a disentangled representation, which is meant to facilitate the understanding of artificial neural networks. This in contrast to distributed representations, for example, a ball: [0.1,-0.02,0.45,0.06] and a car: [-0.78,-0.1,0.83,0.01]. In this case, an object is represented by a particular location in the vector space. This type of representation is for example the outcome of the word2vec algorithms.
In deep learning, what is the difference between "disentangled representation" and "distributed repr Let's say the following vectors are respectively representations for a ball: [1,0,0,0] and a car: [0,1,0,0] In this representation a single neuron learns the meaning of a ball or a car without havin
46,562
Forecasting daily time series with many zeros
(This answer is based on experience with the business side of sales forecasting, more so than on rigorous statistical/mathematical knowledge) Looking at your data, it makes more sense to forecast it at a weekly level than at a daily level. At at daily level it is too sparse, but at a weekly level you would have a more meaningful times series. week 1: 0,0,1,0,0,0,0 week 2: 2,0,0,0,0,0,0 week 3: 0,0,0,1,0,0,0 week 4: 1,0,1,0,0,0,0 week 5: 0,0,0,0,0,0,0 week 6: 1,0,0,2,0,0,0 Any forecasting method you would use at a daily level, would give a fractional value per day. This doesn't really help, since these are sales units, so a forecast value of ~ 0.14 doesn't mean much, unless you interpret it as a probability (and I don't know enough math to help in that case, but others might know better how to treat that). If you aggregate the data by week, you get: week 1: 1 week 2: 2 week 3: 1 week 4: 2 week 5: 0 week 6: 3 You can then simply average that value over all the weeks you have, or maybe use a moving average. You would then get an average of 3 units sold per two weeks. Keep in mind that this is a sales forecast: What is the purpose of a sales forecast? To make sure that you have enough inventory to satisfy customers' demand. Based on the method I described above, you would know that you need to ship/order 3 units of inventory every 2 weeks to satisfy the demand for that product - without going into ARIMA or Exponential smoothing or some other more involved time series analysis.
Forecasting daily time series with many zeros
(This answer is based on experience with the business side of sales forecasting, more so than on rigorous statistical/mathematical knowledge) Looking at your data, it makes more sense to forecast it
Forecasting daily time series with many zeros (This answer is based on experience with the business side of sales forecasting, more so than on rigorous statistical/mathematical knowledge) Looking at your data, it makes more sense to forecast it at a weekly level than at a daily level. At at daily level it is too sparse, but at a weekly level you would have a more meaningful times series. week 1: 0,0,1,0,0,0,0 week 2: 2,0,0,0,0,0,0 week 3: 0,0,0,1,0,0,0 week 4: 1,0,1,0,0,0,0 week 5: 0,0,0,0,0,0,0 week 6: 1,0,0,2,0,0,0 Any forecasting method you would use at a daily level, would give a fractional value per day. This doesn't really help, since these are sales units, so a forecast value of ~ 0.14 doesn't mean much, unless you interpret it as a probability (and I don't know enough math to help in that case, but others might know better how to treat that). If you aggregate the data by week, you get: week 1: 1 week 2: 2 week 3: 1 week 4: 2 week 5: 0 week 6: 3 You can then simply average that value over all the weeks you have, or maybe use a moving average. You would then get an average of 3 units sold per two weeks. Keep in mind that this is a sales forecast: What is the purpose of a sales forecast? To make sure that you have enough inventory to satisfy customers' demand. Based on the method I described above, you would know that you need to ship/order 3 units of inventory every 2 weeks to satisfy the demand for that product - without going into ARIMA or Exponential smoothing or some other more involved time series analysis.
Forecasting daily time series with many zeros (This answer is based on experience with the business side of sales forecasting, more so than on rigorous statistical/mathematical knowledge) Looking at your data, it makes more sense to forecast it
46,563
Forecasting daily time series with many zeros
Croston's method is definitely an appropriate choice for this case. Its basic idea is to estimate non-zero demand and inter-demand interval separately. But note that its output is actually "demand rate", not actual demand units (e.g. a forecast of 0.1 means a demand of 1 unit over 10 periods). The exact timing of the demand is actually not provided. tsintermittent package provides some alternatives for intermittent time series forecasting, including iMAPA and Teunter-Syntetos-Babai method. This package also lets you use some adjustments to deal with the bias of Croston's method, like Syntetos-Boylan approximation.
Forecasting daily time series with many zeros
Croston's method is definitely an appropriate choice for this case. Its basic idea is to estimate non-zero demand and inter-demand interval separately. But note that its output is actually "demand rat
Forecasting daily time series with many zeros Croston's method is definitely an appropriate choice for this case. Its basic idea is to estimate non-zero demand and inter-demand interval separately. But note that its output is actually "demand rate", not actual demand units (e.g. a forecast of 0.1 means a demand of 1 unit over 10 periods). The exact timing of the demand is actually not provided. tsintermittent package provides some alternatives for intermittent time series forecasting, including iMAPA and Teunter-Syntetos-Babai method. This package also lets you use some adjustments to deal with the bias of Croston's method, like Syntetos-Boylan approximation.
Forecasting daily time series with many zeros Croston's method is definitely an appropriate choice for this case. Its basic idea is to estimate non-zero demand and inter-demand interval separately. But note that its output is actually "demand rat
46,564
Implicit Regularization in SGD on linear model
As noted by Leo, the other answer is technically incorrect since it assumes that $x^T x$ is invertible, but this is incompatible with the underdetermined problem where $d > n$, where $x^T x$ is not invertible but $xx^T$ is. A correct derivation still, however, follows the same approach outlined by elliotp. In general, Lagrange multipliers to optimize a function $f(x)$ subject to the equality constraint $g(x) = 0$ yields the Lagrangian $\mathcal{L}(x, \lambda) = f(x) - \lambda g(x)$. We form the Lagrangian to optimize the L2-norm $||w||_2^2$ subject to the equality constraint $y - xw = 0$: $$||w||^2_2 + \lambda^T(y-xw)$$ We differentiate with respect to $w$ and set it to 0. $$2w - x^T\lambda = 0$$ Left multiply by $x$: $$2xw - xx^T \lambda = 0$$ Using $y = xw$, $$2y = xx^t \lambda$$ $$2(xx^T)^{-1}y = (xx^T)(xx^T)^{-1} \lambda$$ $$2(xx^T)^{-1} y = \lambda$$ Using $2w - x^T \lambda = 0$, we get: $$w = x^T(xx^T)^{-1}y$$ where $x^T(xx^T)^{-1}$ is the right pseudo-inverse of $x$. Finally, using $y = xx^T \alpha$ from the parent post, $$w = x^T (xx^T)^{-1}xx^T\alpha$$ $$w = x^T \alpha$$ since the middle term $(xx^T)^{-1}xx^T = I$.
Implicit Regularization in SGD on linear model
As noted by Leo, the other answer is technically incorrect since it assumes that $x^T x$ is invertible, but this is incompatible with the underdetermined problem where $d > n$, where $x^T x$ is not in
Implicit Regularization in SGD on linear model As noted by Leo, the other answer is technically incorrect since it assumes that $x^T x$ is invertible, but this is incompatible with the underdetermined problem where $d > n$, where $x^T x$ is not invertible but $xx^T$ is. A correct derivation still, however, follows the same approach outlined by elliotp. In general, Lagrange multipliers to optimize a function $f(x)$ subject to the equality constraint $g(x) = 0$ yields the Lagrangian $\mathcal{L}(x, \lambda) = f(x) - \lambda g(x)$. We form the Lagrangian to optimize the L2-norm $||w||_2^2$ subject to the equality constraint $y - xw = 0$: $$||w||^2_2 + \lambda^T(y-xw)$$ We differentiate with respect to $w$ and set it to 0. $$2w - x^T\lambda = 0$$ Left multiply by $x$: $$2xw - xx^T \lambda = 0$$ Using $y = xw$, $$2y = xx^t \lambda$$ $$2(xx^T)^{-1}y = (xx^T)(xx^T)^{-1} \lambda$$ $$2(xx^T)^{-1} y = \lambda$$ Using $2w - x^T \lambda = 0$, we get: $$w = x^T(xx^T)^{-1}y$$ where $x^T(xx^T)^{-1}$ is the right pseudo-inverse of $x$. Finally, using $y = xx^T \alpha$ from the parent post, $$w = x^T (xx^T)^{-1}xx^T\alpha$$ $$w = x^T \alpha$$ since the middle term $(xx^T)^{-1}xx^T = I$.
Implicit Regularization in SGD on linear model As noted by Leo, the other answer is technically incorrect since it assumes that $x^T x$ is invertible, but this is incompatible with the underdetermined problem where $d > n$, where $x^T x$ is not in
46,565
Implicit Regularization in SGD on linear model
The minimum $\ell_2$ norm solution can be found by solving the constrained optimization problem: $\underset{w}{\min} \Vert w \Vert_2^2~~s.t.~~y=Xw $ This can be written as an unconstrained convex optimization using the method of Lagrange multipliers at the limit $\lambda \rightarrow \infty$: $\underset{w}{\min}{\left(\Vert w \Vert_2^2 + \lambda \Vert y - Xw \Vert_2^2\right)}$ The reason $\lambda \rightarrow \infty$ is that we want $y=Xw$ exactly, with zero squared error. This is a convex function, so the gradient should equal zero at the minimum: $2w - 2\lambda X^T\left(y-Xw \right)=0$ $w\left(I+\lambda X^TX\right) = \lambda X^T y$, where $I$ is the identity matrix. At the limit $\lambda \rightarrow \infty$, the solution is: $w^* = \left( X^TX\right)^{-1}X^Ty$ where $\left( X^TX\right)^{-1}X^T$ is known as the left pseudoinverse of $X$. Now, we use $w=X^T \alpha$ to replace $y$ with $XX^T \alpha$ $w^* = \left( X^TX\right)^{-1}X^T XX^T \alpha = X^T \alpha =w$ Therefore, if $w=X^T \alpha$ then the minimum $\ell_2$ norm solution for $y=Xw$ is the same: $w^*=X^T \alpha$.
Implicit Regularization in SGD on linear model
The minimum $\ell_2$ norm solution can be found by solving the constrained optimization problem: $\underset{w}{\min} \Vert w \Vert_2^2~~s.t.~~y=Xw $ This can be written as an unconstrained convex opti
Implicit Regularization in SGD on linear model The minimum $\ell_2$ norm solution can be found by solving the constrained optimization problem: $\underset{w}{\min} \Vert w \Vert_2^2~~s.t.~~y=Xw $ This can be written as an unconstrained convex optimization using the method of Lagrange multipliers at the limit $\lambda \rightarrow \infty$: $\underset{w}{\min}{\left(\Vert w \Vert_2^2 + \lambda \Vert y - Xw \Vert_2^2\right)}$ The reason $\lambda \rightarrow \infty$ is that we want $y=Xw$ exactly, with zero squared error. This is a convex function, so the gradient should equal zero at the minimum: $2w - 2\lambda X^T\left(y-Xw \right)=0$ $w\left(I+\lambda X^TX\right) = \lambda X^T y$, where $I$ is the identity matrix. At the limit $\lambda \rightarrow \infty$, the solution is: $w^* = \left( X^TX\right)^{-1}X^Ty$ where $\left( X^TX\right)^{-1}X^T$ is known as the left pseudoinverse of $X$. Now, we use $w=X^T \alpha$ to replace $y$ with $XX^T \alpha$ $w^* = \left( X^TX\right)^{-1}X^T XX^T \alpha = X^T \alpha =w$ Therefore, if $w=X^T \alpha$ then the minimum $\ell_2$ norm solution for $y=Xw$ is the same: $w^*=X^T \alpha$.
Implicit Regularization in SGD on linear model The minimum $\ell_2$ norm solution can be found by solving the constrained optimization problem: $\underset{w}{\min} \Vert w \Vert_2^2~~s.t.~~y=Xw $ This can be written as an unconstrained convex opti
46,566
What are the leverage values for Ridge regression?
Ridge regression can be calculated via ordinary least squares (OLS) calculated with the data matrix $X$ extended with some surrogate data, taken as corresponding to the surrogate observations $Y_0=0$. Write the model, extended with the surrogate data, as $$ \begin{pmatrix} Y \\ Y_0=0\end{pmatrix} = \begin{pmatrix} X\beta \\ X_0 \beta \end{pmatrix} + \begin{pmatrix} \epsilon \\ \epsilon_0 \end{pmatrix} $$ Using this surrogate formulation, we can calculate the USUAL OLS estimator as $$ ( X^TX + X_0^T X_0)^{-1} (X^T Y + X_0^T 0) = (X^T X + X_0^T X_0)^{-1}X^TY $$ and comparing that with your expression for the ridge estimator, shows that you need to solve $$ \Gamma = X_0^T X_0 $$ for $X_0$, any matrix square root will do, for instance the Cholesky decomposition. Then you can use the usual formulas for leverage with the extended data matrix $$ \begin{pmatrix} X \\ X_0 \end{pmatrix} $$ which is an $(n+p)\times p$-matrix, so the $n$ first leverage values correspond to the data. As a bonus you get, from the $p$ last leverage values, leverage information on the surrogate data, so you get information on how much influence there is from the surrogate data. You ask also about cluster robust versions. I don't know about those, but guess the same approach can be used.
What are the leverage values for Ridge regression?
Ridge regression can be calculated via ordinary least squares (OLS) calculated with the data matrix $X$ extended with some surrogate data, taken as corresponding to the surrogate observations $Y_0=0$.
What are the leverage values for Ridge regression? Ridge regression can be calculated via ordinary least squares (OLS) calculated with the data matrix $X$ extended with some surrogate data, taken as corresponding to the surrogate observations $Y_0=0$. Write the model, extended with the surrogate data, as $$ \begin{pmatrix} Y \\ Y_0=0\end{pmatrix} = \begin{pmatrix} X\beta \\ X_0 \beta \end{pmatrix} + \begin{pmatrix} \epsilon \\ \epsilon_0 \end{pmatrix} $$ Using this surrogate formulation, we can calculate the USUAL OLS estimator as $$ ( X^TX + X_0^T X_0)^{-1} (X^T Y + X_0^T 0) = (X^T X + X_0^T X_0)^{-1}X^TY $$ and comparing that with your expression for the ridge estimator, shows that you need to solve $$ \Gamma = X_0^T X_0 $$ for $X_0$, any matrix square root will do, for instance the Cholesky decomposition. Then you can use the usual formulas for leverage with the extended data matrix $$ \begin{pmatrix} X \\ X_0 \end{pmatrix} $$ which is an $(n+p)\times p$-matrix, so the $n$ first leverage values correspond to the data. As a bonus you get, from the $p$ last leverage values, leverage information on the surrogate data, so you get information on how much influence there is from the surrogate data. You ask also about cluster robust versions. I don't know about those, but guess the same approach can be used.
What are the leverage values for Ridge regression? Ridge regression can be calculated via ordinary least squares (OLS) calculated with the data matrix $X$ extended with some surrogate data, taken as corresponding to the surrogate observations $Y_0=0$.
46,567
Gibbs sampling an Ising model with 0s and 1s
The Ising model is one of the simplest examples of distributions with intractable normalising constant: the exact definition of the pmf is $$\pi(x) \propto \exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x_i| \right\}\qquad x\in\{0,1\}^{20}$$meaning that $\pi(x)$ is equal to $$\dfrac{\exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x_i| \right\}}{\sum_{y\in \{0,1\}^{20}} \exp\left\{-\beta \sum_{i=1}^{19} |y_{i+1}-y_i| \right\}}$$ a sum that cannot be computed in closed form because of the $2^{20}$ terms inside. A Gibbs sampling simulation from this distribution is nonetheless feasible as, if one considers a single element $x_i$ $(1\le i\le 20)$ of the vector $x=(x_1,\ldots,x_{20})$, then its conditional distribution satisfies \begin{align*}\pi(x_i|x_{-i})&\propto \pi(x)\propto \exp\left\{-\beta \sum_{j=1}^{19} |x_{j+1}-x_j| \right\}\\ &=\overbrace{\exp\left\{-\beta \sum_{j=1}^{i-1} |x_{j+1}-x_j| \right\}}^ {\text{does not depend on }x_i}\\ &\qquad \times\exp\left\{-\beta |x_{i+1}-x_i| \right\}\times\exp\left\{-\beta |x_{i+1}-x_i| \right\}\\ &\qquad\qquad \times\underbrace{\exp\left\{-\beta \sum_{j=i+1}^{19} |x_{j+1}-x_j| \right\}}_{\text{does not depend on }x_i}\end{align*} The same proportionality symbol occurs in this representation but is no longer an issue: since $x_i\in \{0,1\}$ the pmf can easily be normalised into a probability distribution: \begin{align*}\pi(x_i=0|x_{-i})&\propto \exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}\\ \pi(x_i=1|x_{-i})&\propto \exp\left\{-\beta |x_{i-1}-1| -\beta |x_{i+1}-1|\right\}\end{align*} with obvious adjustments when $i=1,20$. Therefore, $$\pi(x_i=0|x_{-i})=\dfrac{\exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}}{\exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}+\exp\left\{-\beta |x_{i-1}-1| -\beta |x_{i+1}-1|\right\}}$$ which can be simulated directly. Actually, this Gibbs sampler can be sped up by simulating: $(x_1,x_3,\ldots,x_{19})|(x_2,x_4,\ldots,x_{20})$ $(x_2,x_4,\ldots,x_{20})|(x_1,x_3,\ldots,x_{19})$ $(x_1,x_3,\ldots,x_{19})|(x_2,x_4,\ldots,x_{20})$ because the components with odd (resp. even) indices are independent conditional on the components with even (resp. odd) indices. And, while the Gibbs sampler gets less and less energy to converge to its stationary when $\beta$ gets larger, an alternative (slice) sampler called the Wang-Landau algorithm can speed up the Gibbs sampler considerably. There also exist "perfect" sampling algorithms for simulating exact realisations from the Ising model, rather than Markov chains converging to this model, but the description is a bit too advanced for the forum. See this book by Mark Huber for details. Or my blog comments about it.
Gibbs sampling an Ising model with 0s and 1s
The Ising model is one of the simplest examples of distributions with intractable normalising constant: the exact definition of the pmf is $$\pi(x) \propto \exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x
Gibbs sampling an Ising model with 0s and 1s The Ising model is one of the simplest examples of distributions with intractable normalising constant: the exact definition of the pmf is $$\pi(x) \propto \exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x_i| \right\}\qquad x\in\{0,1\}^{20}$$meaning that $\pi(x)$ is equal to $$\dfrac{\exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x_i| \right\}}{\sum_{y\in \{0,1\}^{20}} \exp\left\{-\beta \sum_{i=1}^{19} |y_{i+1}-y_i| \right\}}$$ a sum that cannot be computed in closed form because of the $2^{20}$ terms inside. A Gibbs sampling simulation from this distribution is nonetheless feasible as, if one considers a single element $x_i$ $(1\le i\le 20)$ of the vector $x=(x_1,\ldots,x_{20})$, then its conditional distribution satisfies \begin{align*}\pi(x_i|x_{-i})&\propto \pi(x)\propto \exp\left\{-\beta \sum_{j=1}^{19} |x_{j+1}-x_j| \right\}\\ &=\overbrace{\exp\left\{-\beta \sum_{j=1}^{i-1} |x_{j+1}-x_j| \right\}}^ {\text{does not depend on }x_i}\\ &\qquad \times\exp\left\{-\beta |x_{i+1}-x_i| \right\}\times\exp\left\{-\beta |x_{i+1}-x_i| \right\}\\ &\qquad\qquad \times\underbrace{\exp\left\{-\beta \sum_{j=i+1}^{19} |x_{j+1}-x_j| \right\}}_{\text{does not depend on }x_i}\end{align*} The same proportionality symbol occurs in this representation but is no longer an issue: since $x_i\in \{0,1\}$ the pmf can easily be normalised into a probability distribution: \begin{align*}\pi(x_i=0|x_{-i})&\propto \exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}\\ \pi(x_i=1|x_{-i})&\propto \exp\left\{-\beta |x_{i-1}-1| -\beta |x_{i+1}-1|\right\}\end{align*} with obvious adjustments when $i=1,20$. Therefore, $$\pi(x_i=0|x_{-i})=\dfrac{\exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}}{\exp\left\{-\beta |x_{i-1}| -\beta |x_{i+1}|\right\}+\exp\left\{-\beta |x_{i-1}-1| -\beta |x_{i+1}-1|\right\}}$$ which can be simulated directly. Actually, this Gibbs sampler can be sped up by simulating: $(x_1,x_3,\ldots,x_{19})|(x_2,x_4,\ldots,x_{20})$ $(x_2,x_4,\ldots,x_{20})|(x_1,x_3,\ldots,x_{19})$ $(x_1,x_3,\ldots,x_{19})|(x_2,x_4,\ldots,x_{20})$ because the components with odd (resp. even) indices are independent conditional on the components with even (resp. odd) indices. And, while the Gibbs sampler gets less and less energy to converge to its stationary when $\beta$ gets larger, an alternative (slice) sampler called the Wang-Landau algorithm can speed up the Gibbs sampler considerably. There also exist "perfect" sampling algorithms for simulating exact realisations from the Ising model, rather than Markov chains converging to this model, but the description is a bit too advanced for the forum. See this book by Mark Huber for details. Or my blog comments about it.
Gibbs sampling an Ising model with 0s and 1s The Ising model is one of the simplest examples of distributions with intractable normalising constant: the exact definition of the pmf is $$\pi(x) \propto \exp\left\{-\beta \sum_{i=1}^{19} |x_{i+1}-x
46,568
Estimation of quantile regression by hand
(A little bit more a long comment than an answer, but I'm missing the repetition to comment) First, your calculation of the loss appears to be correct (this is R code): y <- c(5, 4, 5, 4, 7) x <- c(1, 2, 3, 4, 5) a <- 0.217092 b <- 1.594303 tau <- 0.75 f <- function(par, y, x, tau) { sum((tau - (y <= par[1] + par[2]*x)) * (y - (par[1] + par[2]*x))) } f(par=c(a, b), y=y, x=x, tau=tau) [1] 3.782908 Second, there seems to be a problem with the Excel solver. Using R's optimizer, we find: optim(c(0.1, 0.2), f, y=y, x=x, tau=tau) $par [1] 4.4999998 0.4999998 $value [1] 1.250001 $counts function gradient 143 NA so the loss is lower using optim than using Excel's solver. Third, note that your approach of estimating quantile regression is inferior to solving the corresponding linear program. Anyway, a comparison with Roger Koenker's quantregpackage yields: library(quantreg) rq(y ~ x, tau=tau) Call: rq(formula = y ~ x, tau = tau) Coefficients: (Intercept) x 4.5 0.5 Degrees of freedom: 5 total; 3 residual which is very close to the solution of R's optim solver. About your other question: could you elaborate what exactly you want to understand?
Estimation of quantile regression by hand
(A little bit more a long comment than an answer, but I'm missing the repetition to comment) First, your calculation of the loss appears to be correct (this is R code): y <- c(5, 4, 5, 4, 7) x <- c(1,
Estimation of quantile regression by hand (A little bit more a long comment than an answer, but I'm missing the repetition to comment) First, your calculation of the loss appears to be correct (this is R code): y <- c(5, 4, 5, 4, 7) x <- c(1, 2, 3, 4, 5) a <- 0.217092 b <- 1.594303 tau <- 0.75 f <- function(par, y, x, tau) { sum((tau - (y <= par[1] + par[2]*x)) * (y - (par[1] + par[2]*x))) } f(par=c(a, b), y=y, x=x, tau=tau) [1] 3.782908 Second, there seems to be a problem with the Excel solver. Using R's optimizer, we find: optim(c(0.1, 0.2), f, y=y, x=x, tau=tau) $par [1] 4.4999998 0.4999998 $value [1] 1.250001 $counts function gradient 143 NA so the loss is lower using optim than using Excel's solver. Third, note that your approach of estimating quantile regression is inferior to solving the corresponding linear program. Anyway, a comparison with Roger Koenker's quantregpackage yields: library(quantreg) rq(y ~ x, tau=tau) Call: rq(formula = y ~ x, tau = tau) Coefficients: (Intercept) x 4.5 0.5 Degrees of freedom: 5 total; 3 residual which is very close to the solution of R's optim solver. About your other question: could you elaborate what exactly you want to understand?
Estimation of quantile regression by hand (A little bit more a long comment than an answer, but I'm missing the repetition to comment) First, your calculation of the loss appears to be correct (this is R code): y <- c(5, 4, 5, 4, 7) x <- c(1,
46,569
Estimation of quantile regression by hand
solving solution using matlab, on the base of @BayerSe (thanks my friend,i always respect humans who share their knowledge to others), i have solved this problem in matlab define objective function f=@(a) sum((q-(y<=a(1)+a(2)x)).(y-a(1)-a(2)*x)) make initial guess of $\alpha$ and $\beta$ and $q$ a_b = [0.1,0.2]; $q=0.75$ and finally solve options = optimset('PlotFcns',@optimplotfval); x = fminsearch(f,a_b,options) x = 4.5000 0.5000
Estimation of quantile regression by hand
solving solution using matlab, on the base of @BayerSe (thanks my friend,i always respect humans who share their knowledge to others), i have solved this problem in matlab define objective function
Estimation of quantile regression by hand solving solution using matlab, on the base of @BayerSe (thanks my friend,i always respect humans who share their knowledge to others), i have solved this problem in matlab define objective function f=@(a) sum((q-(y<=a(1)+a(2)x)).(y-a(1)-a(2)*x)) make initial guess of $\alpha$ and $\beta$ and $q$ a_b = [0.1,0.2]; $q=0.75$ and finally solve options = optimset('PlotFcns',@optimplotfval); x = fminsearch(f,a_b,options) x = 4.5000 0.5000
Estimation of quantile regression by hand solving solution using matlab, on the base of @BayerSe (thanks my friend,i always respect humans who share their knowledge to others), i have solved this problem in matlab define objective function
46,570
z score on Wilcoxon signed ranks test?
Given the number of elements in your samples (and the number of ties in them), you can transform one (the test stat, say in your case the $V$ stat though as I show below, this will also work for the $W$ stat) to the other (the corresponding z score) fairly easily. The formula's for the W and V stats are widely available (here and here). In fact, these computations are already done in the R code when exact = FALSE --to compute the p-val-- they are just not exported. To have R export these statistics, copy to the source code to an R script. On line 397-403 you see: RVAL <- list(statistic = STATISTIC, parameter = NULL, p.value = as.numeric(PVAL), null.value = mu, alternative = alternative, method = METHOD, data.name = DNAME) Change it to: RVAL <- list(statistic = STATISTIC, parameter = NULL, p.value = as.numeric(PVAL), null.value = mu, alternative = alternative, method = METHOD, z_val = z, data.name = DNAME) Save the function under a different name. Say wilcox_test. Then, whenever the $z$ score is available (when exact = FALSE), wilcox_test will return it. Example; set.seed(123); wilcox_test(runif(4000), rnorm(100), exact = FALSE)$z_val W 8.77776 or: set.seed(123); wilcox_test(runif(4000), exact = FALSE)$z_val V 54.77567
z score on Wilcoxon signed ranks test?
Given the number of elements in your samples (and the number of ties in them), you can transform one (the test stat, say in your case the $V$ stat though as I show below, this will also work for the $
z score on Wilcoxon signed ranks test? Given the number of elements in your samples (and the number of ties in them), you can transform one (the test stat, say in your case the $V$ stat though as I show below, this will also work for the $W$ stat) to the other (the corresponding z score) fairly easily. The formula's for the W and V stats are widely available (here and here). In fact, these computations are already done in the R code when exact = FALSE --to compute the p-val-- they are just not exported. To have R export these statistics, copy to the source code to an R script. On line 397-403 you see: RVAL <- list(statistic = STATISTIC, parameter = NULL, p.value = as.numeric(PVAL), null.value = mu, alternative = alternative, method = METHOD, data.name = DNAME) Change it to: RVAL <- list(statistic = STATISTIC, parameter = NULL, p.value = as.numeric(PVAL), null.value = mu, alternative = alternative, method = METHOD, z_val = z, data.name = DNAME) Save the function under a different name. Say wilcox_test. Then, whenever the $z$ score is available (when exact = FALSE), wilcox_test will return it. Example; set.seed(123); wilcox_test(runif(4000), rnorm(100), exact = FALSE)$z_val W 8.77776 or: set.seed(123); wilcox_test(runif(4000), exact = FALSE)$z_val V 54.77567
z score on Wilcoxon signed ranks test? Given the number of elements in your samples (and the number of ties in them), you can transform one (the test stat, say in your case the $V$ stat though as I show below, this will also work for the $
46,571
z score on Wilcoxon signed ranks test?
See Section 7.2 of BBR which discusses a simple, accurate $z$ test statistic for the Wilcoxon signed-rank test. $z$ equals the sum of signed ranks divided by the square root of the sum of their squares. This handles ties well also.
z score on Wilcoxon signed ranks test?
See Section 7.2 of BBR which discusses a simple, accurate $z$ test statistic for the Wilcoxon signed-rank test. $z$ equals the sum of signed ranks divided by the square root of the sum of their squar
z score on Wilcoxon signed ranks test? See Section 7.2 of BBR which discusses a simple, accurate $z$ test statistic for the Wilcoxon signed-rank test. $z$ equals the sum of signed ranks divided by the square root of the sum of their squares. This handles ties well also.
z score on Wilcoxon signed ranks test? See Section 7.2 of BBR which discusses a simple, accurate $z$ test statistic for the Wilcoxon signed-rank test. $z$ equals the sum of signed ranks divided by the square root of the sum of their squar
46,572
z score on Wilcoxon signed ranks test?
No, they are not interchangeable. The $V$ in Wilcoxon signed test from R wilcox test is "the sum of ranks assigned to the differences with positive sign". Let me show you by using ZeaMays data. First we do the Wilcoxon signed test using wilcox.test funciton. install.packages("HistData") library(HistData) data(ZeaMays) head(ZeaMays) wilcox.test(ZeaMays$cross, ZeaMays$self, paired=TRUE) The results are: # Wilcoxon signed rank test # data: ZeaMays$cross and ZeaMays$self # V = 96, p-value = 0.04126 # alternative hypothesis: true location shift is not equal to 0 Now let us calculate V by hand diff<-ZeaMays$cross-ZeaMays$self #calculate paired difference diff rank_d<-rank(abs(diff))*sign(diff) #rank the difference and assign the sign Next we calculate "the sum of ranks assigned to the differences with positive sign". i.e $V$ p_rank<-c() #postive ranks only for (i in 1:15){ if (rank_d[i]>0){ p_rank[i]=rank_d[i]} } V<-sum(p_rank,na.rm=TRUE) V #[1] 96 You can see $V=96$ which is exactly the same as the $V$ of the wilcox.test. Next what is $Z$ score? $E_{H_0}(V)=\frac{n(n+1)}{4} =\frac{15\times 16}{4}=60$ $Var_{H_0}(V)=\frac{n(n+1)(2n+1)}{24}=\frac{15\times 16\times 31}{24}$ and $Z=\frac{V-E(V)}{\sqrt{Var(V)}}\sim N(0,1)$ i.e the $Z$ can be shown converge to standard normal. Therefore your $z$ score is:$\frac{96-60}{\sqrt{\frac{15\times 16\times31}{24}}}=2.044663$ Which correspond the two sided p value 0.04088813 2*(1-pnorm(z,0,1)) #p=0.04088813$ The p value is a little different, maybe because wilcox.test used some correction.
z score on Wilcoxon signed ranks test?
No, they are not interchangeable. The $V$ in Wilcoxon signed test from R wilcox test is "the sum of ranks assigned to the differences with positive sign". Let me show you by using ZeaMays data. First
z score on Wilcoxon signed ranks test? No, they are not interchangeable. The $V$ in Wilcoxon signed test from R wilcox test is "the sum of ranks assigned to the differences with positive sign". Let me show you by using ZeaMays data. First we do the Wilcoxon signed test using wilcox.test funciton. install.packages("HistData") library(HistData) data(ZeaMays) head(ZeaMays) wilcox.test(ZeaMays$cross, ZeaMays$self, paired=TRUE) The results are: # Wilcoxon signed rank test # data: ZeaMays$cross and ZeaMays$self # V = 96, p-value = 0.04126 # alternative hypothesis: true location shift is not equal to 0 Now let us calculate V by hand diff<-ZeaMays$cross-ZeaMays$self #calculate paired difference diff rank_d<-rank(abs(diff))*sign(diff) #rank the difference and assign the sign Next we calculate "the sum of ranks assigned to the differences with positive sign". i.e $V$ p_rank<-c() #postive ranks only for (i in 1:15){ if (rank_d[i]>0){ p_rank[i]=rank_d[i]} } V<-sum(p_rank,na.rm=TRUE) V #[1] 96 You can see $V=96$ which is exactly the same as the $V$ of the wilcox.test. Next what is $Z$ score? $E_{H_0}(V)=\frac{n(n+1)}{4} =\frac{15\times 16}{4}=60$ $Var_{H_0}(V)=\frac{n(n+1)(2n+1)}{24}=\frac{15\times 16\times 31}{24}$ and $Z=\frac{V-E(V)}{\sqrt{Var(V)}}\sim N(0,1)$ i.e the $Z$ can be shown converge to standard normal. Therefore your $z$ score is:$\frac{96-60}{\sqrt{\frac{15\times 16\times31}{24}}}=2.044663$ Which correspond the two sided p value 0.04088813 2*(1-pnorm(z,0,1)) #p=0.04088813$ The p value is a little different, maybe because wilcox.test used some correction.
z score on Wilcoxon signed ranks test? No, they are not interchangeable. The $V$ in Wilcoxon signed test from R wilcox test is "the sum of ranks assigned to the differences with positive sign". Let me show you by using ZeaMays data. First
46,573
z score on Wilcoxon signed ranks test?
I do the following to obtain the Z-score when doing a Wilcoxon signed rank test. test<-wilcox.test(mtdata$x, mydata$y, paired=TRUE, exact=TRUE) print(test) # get the results of the Wilcoxon signed rank test Zstat<-qnorm(test$p.value/2) # obtain the Z-score abs(Zstat)/sqrt(20)
z score on Wilcoxon signed ranks test?
I do the following to obtain the Z-score when doing a Wilcoxon signed rank test. test<-wilcox.test(mtdata$x, mydata$y, paired=TRUE, exact=TRUE) print(test) # get the results of the Wilcoxon signed r
z score on Wilcoxon signed ranks test? I do the following to obtain the Z-score when doing a Wilcoxon signed rank test. test<-wilcox.test(mtdata$x, mydata$y, paired=TRUE, exact=TRUE) print(test) # get the results of the Wilcoxon signed rank test Zstat<-qnorm(test$p.value/2) # obtain the Z-score abs(Zstat)/sqrt(20)
z score on Wilcoxon signed ranks test? I do the following to obtain the Z-score when doing a Wilcoxon signed rank test. test<-wilcox.test(mtdata$x, mydata$y, paired=TRUE, exact=TRUE) print(test) # get the results of the Wilcoxon signed r
46,574
Bayesian inference on the correlation parameter of a bivariate normal
Since $$L(y_1,\ldots,y_n|\rho)\propto(1-\rho^2)^{-\frac{n}{2}}\exp\bigg\{-\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\bigg \}$$ is a function of $\rho$ of the form $$(1-\rho^2)^{-\alpha}\exp\bigg\{-\dfrac{\beta}{1-\rho^2}-\dfrac{\gamma\rho}{1-\rho^2}\bigg \}\qquad (1)$$this leads to an exponential family choice of a conjugate prior (with $\alpha,\beta>0$ and $|\gamma|<\beta$). While this is not a standard distribution, as far as I know, an accept-reject solution may be available, using the bound$$\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\ge\dfrac{\sum_{i=1}^{n}\min[(\tilde{y}_{i1}-\tilde{y}_{i2})^2,(\tilde{y}_{i1}+\tilde{y}_{i2})^2]}{2(1-\rho^2)}$$ may help, even though I have not been able to find a simple way to simulate from $$f(\rho)\propto(1-\rho^2)^{-\alpha}\exp\bigg\{-\dfrac{\beta}{1-\rho^2}\bigg\}$$ Obviously, since the above density (1) is bounded, a brute-force accept-reject method based on a Uniform works, if slowly [in the picture below the acceptance rate is 2.35%!]: targ=function(x,a,b,c){ (1-x*x)^{-a}*exp(-b/(1-x*x)-c*x/(1-x*x))} upb=function(a,b,c){ return(optimise(targ,maximum=TRUE,a=a,b=b,c=c,inte=c(-1,1))$obj)} simz=function(n,a=1,b=1,c=0){ bon=upb(a,b,c) rejcz=integrate(targ,low=-1,upp=1,a=a,b=b,c=c)$val/2/bon uniz=runif(ceiling(2*n/rejcz),min=-1,max=1) vuniz=runif(ceiling(2*n/rejcz)) samplz=uniz[vuniz<targ(uniz,a,b,c)/bon] return(samplz[1:n])}
Bayesian inference on the correlation parameter of a bivariate normal
Since $$L(y_1,\ldots,y_n|\rho)\propto(1-\rho^2)^{-\frac{n}{2}}\exp\bigg\{-\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\bigg \}$$ is a functi
Bayesian inference on the correlation parameter of a bivariate normal Since $$L(y_1,\ldots,y_n|\rho)\propto(1-\rho^2)^{-\frac{n}{2}}\exp\bigg\{-\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\bigg \}$$ is a function of $\rho$ of the form $$(1-\rho^2)^{-\alpha}\exp\bigg\{-\dfrac{\beta}{1-\rho^2}-\dfrac{\gamma\rho}{1-\rho^2}\bigg \}\qquad (1)$$this leads to an exponential family choice of a conjugate prior (with $\alpha,\beta>0$ and $|\gamma|<\beta$). While this is not a standard distribution, as far as I know, an accept-reject solution may be available, using the bound$$\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\ge\dfrac{\sum_{i=1}^{n}\min[(\tilde{y}_{i1}-\tilde{y}_{i2})^2,(\tilde{y}_{i1}+\tilde{y}_{i2})^2]}{2(1-\rho^2)}$$ may help, even though I have not been able to find a simple way to simulate from $$f(\rho)\propto(1-\rho^2)^{-\alpha}\exp\bigg\{-\dfrac{\beta}{1-\rho^2}\bigg\}$$ Obviously, since the above density (1) is bounded, a brute-force accept-reject method based on a Uniform works, if slowly [in the picture below the acceptance rate is 2.35%!]: targ=function(x,a,b,c){ (1-x*x)^{-a}*exp(-b/(1-x*x)-c*x/(1-x*x))} upb=function(a,b,c){ return(optimise(targ,maximum=TRUE,a=a,b=b,c=c,inte=c(-1,1))$obj)} simz=function(n,a=1,b=1,c=0){ bon=upb(a,b,c) rejcz=integrate(targ,low=-1,upp=1,a=a,b=b,c=c)$val/2/bon uniz=runif(ceiling(2*n/rejcz),min=-1,max=1) vuniz=runif(ceiling(2*n/rejcz)) samplz=uniz[vuniz<targ(uniz,a,b,c)/bon] return(samplz[1:n])}
Bayesian inference on the correlation parameter of a bivariate normal Since $$L(y_1,\ldots,y_n|\rho)\propto(1-\rho^2)^{-\frac{n}{2}}\exp\bigg\{-\dfrac{\sum_{i=1}^{n}\tilde{y}_{i1}^2 - 2\rho\tilde{y}_{i1}\tilde{y}_{i2}+\tilde{y}_{i2}^2}{2(1-\rho^2)}\bigg \}$$ is a functi
46,575
Bayesian inference on the correlation parameter of a bivariate normal
It seems that a Laplace approximation works quite well. Below I define the log-likelihood and its gradient. Note that I change the variable so that the support is on the real line for better Laplace approximation performance. I use a logit transformation, i.e., $\rho = \dfrac{2}{e^{-x}+1}-1$. likfcn <- function(x, a, b, c, log = FALSE) { rho = 2 / (exp(-x) + 1) - 1 aux = 1 - rho^2 llik = -a * log(aux) - b / aux - c * rho / aux if (log) { return(llik) } else { return(exp(llik)) } } llikGradient <- function(x, a, b, c) { rho = 2 / (exp(-x) + 1) - 1 aux = 1 - rho^2 llik_gradient_rho = (2 * a * rho * aux - 2 * b * rho - c - c * rho^2) / aux^2 return(llik_gradient_rho * 2 * exp(x) / (1 + exp(x))^2) } Then I simulate some data from some simple bivariate gaussian and calculate the corresponding a, b and c. # simulation data set.seed(2017) suppressMessages(require(mvtnorm)) Sigma = matrix(c(1, .5, .5, 1), 2, 2) n = 20 y = rmvnorm(n, c(0, 0), Sigma) a = n / 2 b = sum(y[, 1]^2 + y[, 2]^2) / 2 c = -sum(y[, 1] * y[, 2]) I then maximize the log-likelihood and obtain the hessian at the maximum. With the information I can create a Laplace approximation. fn <- function(x) { -likfcn(x, a, b, c, log = TRUE) } gr <- function(x) { -llikGradient(x, a, b, c) } optim_res = optim(par = 0, fn = fn, gr = gr, method = "BFGS", lower = -Inf, upper = Inf,hessian = TRUE) # laplace approximation laplace_mean = optim_res$par laplace_var = 1 / optim_res$hessian Then I compare the Laplace approximation to the true posterior. # compare the laplace approximation to the true posterior x_rho = seq(-.99, .99, .01) targ=function(x,a,b,c){ (1-x*x)^{-a}*exp(-b/(1-x*x)-c*x/(1-x*x))} normalizing_const = integrate(targ,a,b,c,low=-1,upp=1)$val y_dens_true = targ(x_rho,a,b,c) / normalizing_const plot(x_rho, y_dens_true, 'l') x = log((x_rho+1)/2/(1-(x_rho+1)/2)) y_dens_laplace = dnorm(x, laplace_mean, sqrt(laplace_var)) * (1 / (1+x_rho) + 1 / (1-x_rho)) lines(x_rho, y_dens_laplace, col = "red") where the black line is the density plot of the truth and the red is the Laplace approximation. As can be seen, Laplace approximation performs well, especially noting that the data size $n=20$ is not big.
Bayesian inference on the correlation parameter of a bivariate normal
It seems that a Laplace approximation works quite well. Below I define the log-likelihood and its gradient. Note that I change the variable so that the support is on the real line for better Laplace a
Bayesian inference on the correlation parameter of a bivariate normal It seems that a Laplace approximation works quite well. Below I define the log-likelihood and its gradient. Note that I change the variable so that the support is on the real line for better Laplace approximation performance. I use a logit transformation, i.e., $\rho = \dfrac{2}{e^{-x}+1}-1$. likfcn <- function(x, a, b, c, log = FALSE) { rho = 2 / (exp(-x) + 1) - 1 aux = 1 - rho^2 llik = -a * log(aux) - b / aux - c * rho / aux if (log) { return(llik) } else { return(exp(llik)) } } llikGradient <- function(x, a, b, c) { rho = 2 / (exp(-x) + 1) - 1 aux = 1 - rho^2 llik_gradient_rho = (2 * a * rho * aux - 2 * b * rho - c - c * rho^2) / aux^2 return(llik_gradient_rho * 2 * exp(x) / (1 + exp(x))^2) } Then I simulate some data from some simple bivariate gaussian and calculate the corresponding a, b and c. # simulation data set.seed(2017) suppressMessages(require(mvtnorm)) Sigma = matrix(c(1, .5, .5, 1), 2, 2) n = 20 y = rmvnorm(n, c(0, 0), Sigma) a = n / 2 b = sum(y[, 1]^2 + y[, 2]^2) / 2 c = -sum(y[, 1] * y[, 2]) I then maximize the log-likelihood and obtain the hessian at the maximum. With the information I can create a Laplace approximation. fn <- function(x) { -likfcn(x, a, b, c, log = TRUE) } gr <- function(x) { -llikGradient(x, a, b, c) } optim_res = optim(par = 0, fn = fn, gr = gr, method = "BFGS", lower = -Inf, upper = Inf,hessian = TRUE) # laplace approximation laplace_mean = optim_res$par laplace_var = 1 / optim_res$hessian Then I compare the Laplace approximation to the true posterior. # compare the laplace approximation to the true posterior x_rho = seq(-.99, .99, .01) targ=function(x,a,b,c){ (1-x*x)^{-a}*exp(-b/(1-x*x)-c*x/(1-x*x))} normalizing_const = integrate(targ,a,b,c,low=-1,upp=1)$val y_dens_true = targ(x_rho,a,b,c) / normalizing_const plot(x_rho, y_dens_true, 'l') x = log((x_rho+1)/2/(1-(x_rho+1)/2)) y_dens_laplace = dnorm(x, laplace_mean, sqrt(laplace_var)) * (1 / (1+x_rho) + 1 / (1-x_rho)) lines(x_rho, y_dens_laplace, col = "red") where the black line is the density plot of the truth and the red is the Laplace approximation. As can be seen, Laplace approximation performs well, especially noting that the data size $n=20$ is not big.
Bayesian inference on the correlation parameter of a bivariate normal It seems that a Laplace approximation works quite well. Below I define the log-likelihood and its gradient. Note that I change the variable so that the support is on the real line for better Laplace a
46,576
What is the point of introducing the concept of estimable function?
If you want to test $H_0: c^T\beta=0$ vs $H_1: c^T\beta\neq 0$, you will want to be able to estimate $c^T\beta$. Or, for example, if you need a prediction interval for $x_\text{new}\beta$, it would really help a lot if it's actually possible to estimate $x_\text{new}\beta$ ... (here we have $c=x_\text{new}^T$). When your design is not of full rank it's useful to be able to distinguish what can and can't be estimated.
What is the point of introducing the concept of estimable function?
If you want to test $H_0: c^T\beta=0$ vs $H_1: c^T\beta\neq 0$, you will want to be able to estimate $c^T\beta$. Or, for example, if you need a prediction interval for $x_\text{new}\beta$, it would r
What is the point of introducing the concept of estimable function? If you want to test $H_0: c^T\beta=0$ vs $H_1: c^T\beta\neq 0$, you will want to be able to estimate $c^T\beta$. Or, for example, if you need a prediction interval for $x_\text{new}\beta$, it would really help a lot if it's actually possible to estimate $x_\text{new}\beta$ ... (here we have $c=x_\text{new}^T$). When your design is not of full rank it's useful to be able to distinguish what can and can't be estimated.
What is the point of introducing the concept of estimable function? If you want to test $H_0: c^T\beta=0$ vs $H_1: c^T\beta\neq 0$, you will want to be able to estimate $c^T\beta$. Or, for example, if you need a prediction interval for $x_\text{new}\beta$, it would r
46,577
What is the point of introducing the concept of estimable function?
Let me give some perspective from linear algebra. In linear model $ y = X\beta +\epsilon$, $E(a'y) = a'X\beta$ so the definition actually says that $c'\beta$ is estimable if and only if $c\in C(X')$ where $C(X')$ is the row space of $X$. So if $X$ is full rank then any $c'\beta$ would be estimable. But what if $X$ is not full rank? This definition is born to answer this question. For any design matrix, full rank or not, we can estimate $c'\beta$ as long as $c$ is in the row space of $X$. You can have a look at the pseudoinverse to find more intuition.
What is the point of introducing the concept of estimable function?
Let me give some perspective from linear algebra. In linear model $ y = X\beta +\epsilon$, $E(a'y) = a'X\beta$ so the definition actually says that $c'\beta$ is estimable if and only if $c\in C(X')$ w
What is the point of introducing the concept of estimable function? Let me give some perspective from linear algebra. In linear model $ y = X\beta +\epsilon$, $E(a'y) = a'X\beta$ so the definition actually says that $c'\beta$ is estimable if and only if $c\in C(X')$ where $C(X')$ is the row space of $X$. So if $X$ is full rank then any $c'\beta$ would be estimable. But what if $X$ is not full rank? This definition is born to answer this question. For any design matrix, full rank or not, we can estimate $c'\beta$ as long as $c$ is in the row space of $X$. You can have a look at the pseudoinverse to find more intuition.
What is the point of introducing the concept of estimable function? Let me give some perspective from linear algebra. In linear model $ y = X\beta +\epsilon$, $E(a'y) = a'X\beta$ so the definition actually says that $c'\beta$ is estimable if and only if $c\in C(X')$ w
46,578
What is the point of introducing the concept of estimable function?
In the general situation, we have a model that is parametrised by $\theta \in \Theta$. We are interested in estimating $\theta$, or estimating some function $g$ of $\theta$. We say that $g(\theta)$ is estimable if an unbiased estimator of $g(\theta)$ exists. That is, if there exists a statistic $T(Y)$ (a function from the data to $\mathbb R$) such that $$ \mathbb E_{\theta} (T(Y)) = g(\theta) $$ for all $\theta \in \Theta$. In the linear model scenario, our model is parametrised by $\beta \in \mathbb R^p$. Our data is the value of dependent variable $y$. We only consider linear functions. Therefore the definition is as follows: $g(\beta) = c^T\beta$ is estimable if there exists a statistic $T(y) = a^T y$ such that $$\mathbb E_{\beta} (a^T y) = c^T \beta,$$ for all $\beta \in \mathbb R^p$.
What is the point of introducing the concept of estimable function?
In the general situation, we have a model that is parametrised by $\theta \in \Theta$. We are interested in estimating $\theta$, or estimating some function $g$ of $\theta$. We say that $g(\theta)$ is
What is the point of introducing the concept of estimable function? In the general situation, we have a model that is parametrised by $\theta \in \Theta$. We are interested in estimating $\theta$, or estimating some function $g$ of $\theta$. We say that $g(\theta)$ is estimable if an unbiased estimator of $g(\theta)$ exists. That is, if there exists a statistic $T(Y)$ (a function from the data to $\mathbb R$) such that $$ \mathbb E_{\theta} (T(Y)) = g(\theta) $$ for all $\theta \in \Theta$. In the linear model scenario, our model is parametrised by $\beta \in \mathbb R^p$. Our data is the value of dependent variable $y$. We only consider linear functions. Therefore the definition is as follows: $g(\beta) = c^T\beta$ is estimable if there exists a statistic $T(y) = a^T y$ such that $$\mathbb E_{\beta} (a^T y) = c^T \beta,$$ for all $\beta \in \mathbb R^p$.
What is the point of introducing the concept of estimable function? In the general situation, we have a model that is parametrised by $\theta \in \Theta$. We are interested in estimating $\theta$, or estimating some function $g$ of $\theta$. We say that $g(\theta)$ is
46,579
Cox Regression when survival doesn't go to 0?
There is quite some literature on survival analysis under population heterogeneity, but like you notice yourself, I rarely see such models being used - or even considered - in applied research. I'll give some brief intuition, and hopefully others can add mathematically-heavier explanations if that's what you're looking for. So let's say our observations look like this - quarter of the sample is "cured" and does not experience the event during observation period, while the rest are "susceptible" and slowly dying/failing/divorcing: The entire blue fraction will be censored at $t=50$, and you can have additional censoring in both groups as usual (not seen in the plot). Now, Cox PH models assume that survival time is independent of censoring. However, if you fit such a model to the pictured sample, the censored group will have much higher time-to-event a different hazard function because it contains the entire "cured" fraction. Simulations (e.g. 2) show that the HR estimate can be strongly biased under these conditions. The problem could be solved by excluding the "cured" observations, but those usually are not distinguishable from censored, but "susceptible" individuals. Another analysis option is to only consider the binary outcome event vs. no event, but this again means excluding all censored individuals. A conceptually simple solution is to treat the sample as a mixture of "cured" and "susceptible" distributions with weights $p$ and $1-p$, and fit a mixture model with survival $S(t) = 1$ for the "cured" fraction and some decreasing $S(t)$ for the "susceptible" fraction. These are known as mixture cure models; there are also non-mixture solutions, but I'm unsure if those are popular in practice. Some references, in the order from most-layman to most mathematical: Cure Models as a Useful Statistical Tool for Analyzing Survival Mixture and non-mixture cure fraction models based on the generalized modified Weibull distribution with an application to gastric cancer data What Cure Models Can Teach us About Genome-Wide Survival Analysis A General Approach for Cure Models in Survival Analysis EDIT Given the good comments by @JarleTufto below, I should clarify this answer. I do not propose that merely censoring at the end of observation period is bad, or that the hazard after final $t$ is somehow relevant, but that problems are caused by underlying heterogeneity in population - i.e. fractions with different hazard functions $h(t)$ are censored differently. The corresponding Cox model assumption is stated as: $$h(t|covariates) = h(t|C_i > t, covariates)$$ (e.g. Relaxing the independent censoring assumption in the Cox proportional hazards model using multiple imputation) Let's take the simulation code from the answer below, and add a "cured" fraction with $h(t)=0$ (also added seed and increased sample size for easier reproducibility): set.seed(1234) # simulated survival times from the model n <- 5000 x <- rnorm(n) beta <- 0.5 # variation of inversion method u <- runif(n) eventtime <- 1/(1 + exp(-beta*x)*log(u)) - 1 eventtime[eventtime < 0] <- Inf # simulate independent right censoring points censoringtime <- runif(n,0,20) # compute the observed data, that is, the censoring indicator and # the time of whichever event comes first delta <- eventtime < censoringtime time <- pmin(eventtime, censoringtime) # add "cured" fraction, censored at max observation time: n2 <- 1000 time2 <- c(time, rep(20, n2)) delta2 <- c(delta, rep(FALSE, n2)) x2 <- c(x, rnorm(n2)) So the observed (event or censoring) timepoints look like: qplot(time2) Using only the "susceptible" fraction, we get the expected estimate of $\beta=0.5$: # Fit the cox proportional hazards model library(survival) model <- coxph(Surv(time,delta) ~ x) model coef exp(coef) se(coef) z p x 0.5067 1.6598 0.0198 25.6 <2e-16 Likelihood ratio test=661 on 1 df, p=0 n= 5000, number of events= 2923 However, using the full sample, the HR is underestimated: model2 <- coxph(Surv(time2,delta2) ~ x2) model2 coef exp(coef) se(coef) z p x2 0.4192 1.5207 0.0192 21.8 <2e-16 Likelihood ratio test=478 on 1 df, p=0 n= 6000, number of events= 2923
Cox Regression when survival doesn't go to 0?
There is quite some literature on survival analysis under population heterogeneity, but like you notice yourself, I rarely see such models being used - or even considered - in applied research. I'll g
Cox Regression when survival doesn't go to 0? There is quite some literature on survival analysis under population heterogeneity, but like you notice yourself, I rarely see such models being used - or even considered - in applied research. I'll give some brief intuition, and hopefully others can add mathematically-heavier explanations if that's what you're looking for. So let's say our observations look like this - quarter of the sample is "cured" and does not experience the event during observation period, while the rest are "susceptible" and slowly dying/failing/divorcing: The entire blue fraction will be censored at $t=50$, and you can have additional censoring in both groups as usual (not seen in the plot). Now, Cox PH models assume that survival time is independent of censoring. However, if you fit such a model to the pictured sample, the censored group will have much higher time-to-event a different hazard function because it contains the entire "cured" fraction. Simulations (e.g. 2) show that the HR estimate can be strongly biased under these conditions. The problem could be solved by excluding the "cured" observations, but those usually are not distinguishable from censored, but "susceptible" individuals. Another analysis option is to only consider the binary outcome event vs. no event, but this again means excluding all censored individuals. A conceptually simple solution is to treat the sample as a mixture of "cured" and "susceptible" distributions with weights $p$ and $1-p$, and fit a mixture model with survival $S(t) = 1$ for the "cured" fraction and some decreasing $S(t)$ for the "susceptible" fraction. These are known as mixture cure models; there are also non-mixture solutions, but I'm unsure if those are popular in practice. Some references, in the order from most-layman to most mathematical: Cure Models as a Useful Statistical Tool for Analyzing Survival Mixture and non-mixture cure fraction models based on the generalized modified Weibull distribution with an application to gastric cancer data What Cure Models Can Teach us About Genome-Wide Survival Analysis A General Approach for Cure Models in Survival Analysis EDIT Given the good comments by @JarleTufto below, I should clarify this answer. I do not propose that merely censoring at the end of observation period is bad, or that the hazard after final $t$ is somehow relevant, but that problems are caused by underlying heterogeneity in population - i.e. fractions with different hazard functions $h(t)$ are censored differently. The corresponding Cox model assumption is stated as: $$h(t|covariates) = h(t|C_i > t, covariates)$$ (e.g. Relaxing the independent censoring assumption in the Cox proportional hazards model using multiple imputation) Let's take the simulation code from the answer below, and add a "cured" fraction with $h(t)=0$ (also added seed and increased sample size for easier reproducibility): set.seed(1234) # simulated survival times from the model n <- 5000 x <- rnorm(n) beta <- 0.5 # variation of inversion method u <- runif(n) eventtime <- 1/(1 + exp(-beta*x)*log(u)) - 1 eventtime[eventtime < 0] <- Inf # simulate independent right censoring points censoringtime <- runif(n,0,20) # compute the observed data, that is, the censoring indicator and # the time of whichever event comes first delta <- eventtime < censoringtime time <- pmin(eventtime, censoringtime) # add "cured" fraction, censored at max observation time: n2 <- 1000 time2 <- c(time, rep(20, n2)) delta2 <- c(delta, rep(FALSE, n2)) x2 <- c(x, rnorm(n2)) So the observed (event or censoring) timepoints look like: qplot(time2) Using only the "susceptible" fraction, we get the expected estimate of $\beta=0.5$: # Fit the cox proportional hazards model library(survival) model <- coxph(Surv(time,delta) ~ x) model coef exp(coef) se(coef) z p x 0.5067 1.6598 0.0198 25.6 <2e-16 Likelihood ratio test=661 on 1 df, p=0 n= 5000, number of events= 2923 However, using the full sample, the HR is underestimated: model2 <- coxph(Surv(time2,delta2) ~ x2) model2 coef exp(coef) se(coef) z p x2 0.4192 1.5207 0.0192 21.8 <2e-16 Likelihood ratio test=478 on 1 df, p=0 n= 6000, number of events= 2923
Cox Regression when survival doesn't go to 0? There is quite some literature on survival analysis under population heterogeneity, but like you notice yourself, I rarely see such models being used - or even considered - in applied research. I'll g
46,580
Cox Regression when survival doesn't go to 0?
It may perfectly fine to apply the Cox model in the situation you describe. The Cox model makes no assumptions about the baseline hazard $h_0(t)$ other than that it is non-negative for all $t$. So the baseline hazard may well go to zero fast enough to make the cumulative hazard $\int_0^t h_0(u) du$ go to a finite value and $S(t)$ to some positive value as $t\rightarrow \infty$. Unlike parametric survival models, no inference is made about the hazard function beyond the last censoring event/last observed failure. Instead, just as the simpler Kaplan-Meier estimator of $S(t)$, the Cox model gives you a non-parametric estimate of the baseline survival function $S_0(t)$ only up to the last censoring event/last observed failure. So the theoretical behaviour of the hazard function after this time point is of no consequence whatsoever. For example, suppose that the true unknown baseline hazard has the form $$ h_0(t) = \frac1{(1+t)^2}. $$ The survival function for an individual with covariate vector $x$ is then \begin{align} S(t;x) &= e^{-e^{\beta x}\int_0^t h_0(u)du} \\&= e^{-e^{\beta x}(1-\frac1{t+1})}. \end{align} The cumulative baseline hazard $1-\frac1{t+1}$ then tends to a limiting value (of one) and the survival function $S(t;x)$ to the positive probability $e^{-e^{\beta x}}$ as $t\rightarrow\infty$. Note that the limiting value of $S(t;x)$ in general must depend on the covariates $x$, if this is not the case the proportional hazard assumption will be violated. In the following, survival times $T$ from this model (some of which are infinite) and independent right censoring times $C$ uniformly distributed on the interval from 0 to 20 are simulated and the Cox proportional hazard model is fitted to the observed data (the censoring indicator and the minimum of $T$ and $C$). # simulated survival times from the model n <- 300 x <- rnorm(n) beta <- .5 # variation of inversion method u <- runif(n) eventtime <- 1/(1 + exp(-beta*x)*log(u)) - 1 eventtime[eventtime < 0] <- Inf # simulate independent rigth censoring points censoringtime <- runif(n,0,20) # compute the observed data, that is, the censoring indicator and # the time of whichever event comes first delta <- eventtime < censoringtime time <- pmin(eventtime, censoringtime) # Fit the cox proportional hazards model library(survival) model <- coxph(Surv(time,delta) ~ x) Both the regression coefficient $\beta=0.5$, > model Call: coxph(formula = Surv(time, delta) ~ x) coef exp(coef) se(coef) z p x 0.5463 1.7269 0.0892 6.12 9.2e-10 Likelihood ratio test=39.6 on 1 df, p=3.19e-10 n= 300, number of events= 164 Call: and the baseline survival function $S_0(t)$ are estimated just fine. # Compare the estimated and true baseline survival functions plot(survfit(model, newdate=data.frame(x=0))) curve(exp(-(1-1/(t+1))),xname="t",add=TRUE,col="red")
Cox Regression when survival doesn't go to 0?
It may perfectly fine to apply the Cox model in the situation you describe. The Cox model makes no assumptions about the baseline hazard $h_0(t)$ other than that it is non-negative for all $t$. So th
Cox Regression when survival doesn't go to 0? It may perfectly fine to apply the Cox model in the situation you describe. The Cox model makes no assumptions about the baseline hazard $h_0(t)$ other than that it is non-negative for all $t$. So the baseline hazard may well go to zero fast enough to make the cumulative hazard $\int_0^t h_0(u) du$ go to a finite value and $S(t)$ to some positive value as $t\rightarrow \infty$. Unlike parametric survival models, no inference is made about the hazard function beyond the last censoring event/last observed failure. Instead, just as the simpler Kaplan-Meier estimator of $S(t)$, the Cox model gives you a non-parametric estimate of the baseline survival function $S_0(t)$ only up to the last censoring event/last observed failure. So the theoretical behaviour of the hazard function after this time point is of no consequence whatsoever. For example, suppose that the true unknown baseline hazard has the form $$ h_0(t) = \frac1{(1+t)^2}. $$ The survival function for an individual with covariate vector $x$ is then \begin{align} S(t;x) &= e^{-e^{\beta x}\int_0^t h_0(u)du} \\&= e^{-e^{\beta x}(1-\frac1{t+1})}. \end{align} The cumulative baseline hazard $1-\frac1{t+1}$ then tends to a limiting value (of one) and the survival function $S(t;x)$ to the positive probability $e^{-e^{\beta x}}$ as $t\rightarrow\infty$. Note that the limiting value of $S(t;x)$ in general must depend on the covariates $x$, if this is not the case the proportional hazard assumption will be violated. In the following, survival times $T$ from this model (some of which are infinite) and independent right censoring times $C$ uniformly distributed on the interval from 0 to 20 are simulated and the Cox proportional hazard model is fitted to the observed data (the censoring indicator and the minimum of $T$ and $C$). # simulated survival times from the model n <- 300 x <- rnorm(n) beta <- .5 # variation of inversion method u <- runif(n) eventtime <- 1/(1 + exp(-beta*x)*log(u)) - 1 eventtime[eventtime < 0] <- Inf # simulate independent rigth censoring points censoringtime <- runif(n,0,20) # compute the observed data, that is, the censoring indicator and # the time of whichever event comes first delta <- eventtime < censoringtime time <- pmin(eventtime, censoringtime) # Fit the cox proportional hazards model library(survival) model <- coxph(Surv(time,delta) ~ x) Both the regression coefficient $\beta=0.5$, > model Call: coxph(formula = Surv(time, delta) ~ x) coef exp(coef) se(coef) z p x 0.5463 1.7269 0.0892 6.12 9.2e-10 Likelihood ratio test=39.6 on 1 df, p=3.19e-10 n= 300, number of events= 164 Call: and the baseline survival function $S_0(t)$ are estimated just fine. # Compare the estimated and true baseline survival functions plot(survfit(model, newdate=data.frame(x=0))) curve(exp(-(1-1/(t+1))),xname="t",add=TRUE,col="red")
Cox Regression when survival doesn't go to 0? It may perfectly fine to apply the Cox model in the situation you describe. The Cox model makes no assumptions about the baseline hazard $h_0(t)$ other than that it is non-negative for all $t$. So th
46,581
Polynomial approximations of nonlinearities in neural networks
The problem you're having is due to the asymptotic behavior of the remainder between the Taylor approximation of a function, and the function itself. If $f$ is at least $k$ times differentiable and you approximate it with a $k$'th order polynomial, $$ P_k(x) = f(a) + f'(a) (x - a) + \frac{1}{2} f''(a) (x-a)^2 + \dots + \frac{1}{k!} f^{(k)}(a) (x-a)^k, $$ Then the scaling of the error $P_k(x) - f(x)$ goes as $o(|x - a|^k).$ I'm using the little-o notation. This is particularly noticeable for an infinite-differentiable function, such as the smooth-RELU. The example that's often used to illustrate this concept is $\sin x.$ The function $\sin x$ has infinite stationary points. This is required for the constant oscillation behavior. However, a polynomial of order $k$ can only have, at max, $k-1$ stationary points. So trying to fit a polynomial to a sine function can approximate it decently well around the point you're referencing. In fact, the higher order your polynomial, the wider the domain of validity your approximation will be. But it will always eventually diverge. The example you gave, the smooth RELU, also has its own assortment of problems. You can either simulate it well near the origin, or at some infinite asymptotic point, but not both. To see this, look at its asymptotic behavior as $x \rightarrow \infty:$ $$ \begin{split} \lim_{x \rightarrow \infty} \log (1 + e^x) &= \lim_{x \rightarrow \infty} \log \left[\frac{e^{-x} + 1}{e^{-x}}\right] \\ &= \lim_{x \rightarrow \infty} \log \left[ \frac{1}{e^{-x}} \right] \rightarrow x. \end{split} $$ That is, its infinite asymptotic behavior is just that of the function $g(x) = x.$ However, there is an inflection point near the origin, which cannot possibly be represented well by a first order polynomial, so you need a higher order polynomial to capture that. However, if you use a polynomial $P_k(x)$ of order $k>1$ then, $$ \lim_{x \rightarrow \infty} \frac{P_k(x)}{x} = \infty. $$ That is, you cannot possibly have consistent behavior as you increase $x.$ The higher order polynomial will always overtake $x$ at some point, and continue to grow more rapidly, whereas $x$ is the asymptotic behavior you're looking for. Furthermore, its asymptotic behavior on the left side is $h(x) = 0,$ which is itself a polynomial. So you have zero'th order behavior on the left, first order behavior on the right, and an inflection point near the middle, which suggests a polynomial of at least order 2. You cannot possible fit all of these behaviors by a single polynomial. It is a matter of scale. Looking at the sine wave approximation, the polynomial is indeed a solid approximation of the function, and in fact, this is used by most calculators to give you the output of a $\sin$ function. But this only works within a certain range. If you want to approximate activation functions in your Neural Network you have to keep in mind that the input to the activation functions are somewhat uncontrolled, because they're the linear combination of input nodes that you're fitting by looking for the appropriate weights. You have to ensure that your weights are small enough that the domain of validity of your Taylor approximations hold. Regularization, such as $L2$ weight decay, might do the trick, but it's no guarantee. Another way around this is to increase the order of the polynomial, to make the domain of validity larger. But, given the asymptotic arguments I illustrated above, there is no general way to ensure that a polynomial gives you the behavior you expect out of an infinitely-differentiable activation function.
Polynomial approximations of nonlinearities in neural networks
The problem you're having is due to the asymptotic behavior of the remainder between the Taylor approximation of a function, and the function itself. If $f$ is at least $k$ times differentiable and y
Polynomial approximations of nonlinearities in neural networks The problem you're having is due to the asymptotic behavior of the remainder between the Taylor approximation of a function, and the function itself. If $f$ is at least $k$ times differentiable and you approximate it with a $k$'th order polynomial, $$ P_k(x) = f(a) + f'(a) (x - a) + \frac{1}{2} f''(a) (x-a)^2 + \dots + \frac{1}{k!} f^{(k)}(a) (x-a)^k, $$ Then the scaling of the error $P_k(x) - f(x)$ goes as $o(|x - a|^k).$ I'm using the little-o notation. This is particularly noticeable for an infinite-differentiable function, such as the smooth-RELU. The example that's often used to illustrate this concept is $\sin x.$ The function $\sin x$ has infinite stationary points. This is required for the constant oscillation behavior. However, a polynomial of order $k$ can only have, at max, $k-1$ stationary points. So trying to fit a polynomial to a sine function can approximate it decently well around the point you're referencing. In fact, the higher order your polynomial, the wider the domain of validity your approximation will be. But it will always eventually diverge. The example you gave, the smooth RELU, also has its own assortment of problems. You can either simulate it well near the origin, or at some infinite asymptotic point, but not both. To see this, look at its asymptotic behavior as $x \rightarrow \infty:$ $$ \begin{split} \lim_{x \rightarrow \infty} \log (1 + e^x) &= \lim_{x \rightarrow \infty} \log \left[\frac{e^{-x} + 1}{e^{-x}}\right] \\ &= \lim_{x \rightarrow \infty} \log \left[ \frac{1}{e^{-x}} \right] \rightarrow x. \end{split} $$ That is, its infinite asymptotic behavior is just that of the function $g(x) = x.$ However, there is an inflection point near the origin, which cannot possibly be represented well by a first order polynomial, so you need a higher order polynomial to capture that. However, if you use a polynomial $P_k(x)$ of order $k>1$ then, $$ \lim_{x \rightarrow \infty} \frac{P_k(x)}{x} = \infty. $$ That is, you cannot possibly have consistent behavior as you increase $x.$ The higher order polynomial will always overtake $x$ at some point, and continue to grow more rapidly, whereas $x$ is the asymptotic behavior you're looking for. Furthermore, its asymptotic behavior on the left side is $h(x) = 0,$ which is itself a polynomial. So you have zero'th order behavior on the left, first order behavior on the right, and an inflection point near the middle, which suggests a polynomial of at least order 2. You cannot possible fit all of these behaviors by a single polynomial. It is a matter of scale. Looking at the sine wave approximation, the polynomial is indeed a solid approximation of the function, and in fact, this is used by most calculators to give you the output of a $\sin$ function. But this only works within a certain range. If you want to approximate activation functions in your Neural Network you have to keep in mind that the input to the activation functions are somewhat uncontrolled, because they're the linear combination of input nodes that you're fitting by looking for the appropriate weights. You have to ensure that your weights are small enough that the domain of validity of your Taylor approximations hold. Regularization, such as $L2$ weight decay, might do the trick, but it's no guarantee. Another way around this is to increase the order of the polynomial, to make the domain of validity larger. But, given the asymptotic arguments I illustrated above, there is no general way to ensure that a polynomial gives you the behavior you expect out of an infinitely-differentiable activation function.
Polynomial approximations of nonlinearities in neural networks The problem you're having is due to the asymptotic behavior of the remainder between the Taylor approximation of a function, and the function itself. If $f$ is at least $k$ times differentiable and y
46,582
Polynomial approximations of nonlinearities in neural networks
So the issue is that Taylor series are not always the best finite approximation for a function. With the smooth relu example, you can take advantage of a few tricks to make the approximation better. As an example, $\ln(1+e^{x})=\ln(e^x(e^{-x}+1))=x+\ln(1+e^{-x})$. This form is advantageous when $x$ is large, because then $\ln(1+e^{-x})=e^{-x}-e^{-2x}/2+...$ where all the next terms drop off exponentially. If you're willing to divide by polynomials, then an even better series is: $\ln(x) = 2\sum_{k=0}^\infty\frac{1}{2k+1}\left(\frac{x-1}{x+1}\right)^{2k+1},$ which usually gives you great approximations with only a few terms, as long as $x$ is near 1 (but say, x=2 isn't terrible either). By using $\ln(xy)=\ln(x)+\ln(y)$ and $\ln(x)=a\ln(x^{1/a})$, you can always reduce $x$ to something near 1 and then apply the above approximation. By using batch normalization, you can guesstimate the variance of your inputs and pick an $a$ that does the trick for most inputs.
Polynomial approximations of nonlinearities in neural networks
So the issue is that Taylor series are not always the best finite approximation for a function. With the smooth relu example, you can take advantage of a few tricks to make the approximation better. A
Polynomial approximations of nonlinearities in neural networks So the issue is that Taylor series are not always the best finite approximation for a function. With the smooth relu example, you can take advantage of a few tricks to make the approximation better. As an example, $\ln(1+e^{x})=\ln(e^x(e^{-x}+1))=x+\ln(1+e^{-x})$. This form is advantageous when $x$ is large, because then $\ln(1+e^{-x})=e^{-x}-e^{-2x}/2+...$ where all the next terms drop off exponentially. If you're willing to divide by polynomials, then an even better series is: $\ln(x) = 2\sum_{k=0}^\infty\frac{1}{2k+1}\left(\frac{x-1}{x+1}\right)^{2k+1},$ which usually gives you great approximations with only a few terms, as long as $x$ is near 1 (but say, x=2 isn't terrible either). By using $\ln(xy)=\ln(x)+\ln(y)$ and $\ln(x)=a\ln(x^{1/a})$, you can always reduce $x$ to something near 1 and then apply the above approximation. By using batch normalization, you can guesstimate the variance of your inputs and pick an $a$ that does the trick for most inputs.
Polynomial approximations of nonlinearities in neural networks So the issue is that Taylor series are not always the best finite approximation for a function. With the smooth relu example, you can take advantage of a few tricks to make the approximation better. A
46,583
Logistic regression and inclusion of independent and/or correlated variables
@NULL is right that this is a general question that isn't specific to your use case. Let me supplement his answer a little. What you really need to do in any given situation is think very hard about what you want to do and why. You have a situation where you want to build a model with response $Y$, but you believe that a set of $X$-variables will be highly correlated. That may not be a problem. First, why do you think the variables are correlated? Are they all measures of the same underlying construct? Are they partly overlapping, but partly distinct? Are some of them causally related to others? Second, what are your long-run goals? Do you just want to describe the data (their distributions and relationships)? Are you exploring the data to generate hypotheses for future research? Do you want to test a hypothesis? About what, one of the correlated variables relative to another, or about what they have in common, or about something completely unrelated (these are controls and the variable of interest is uncorrelated with them)? Do you want to to make a predictive model? Who is going to be using this to make predictions? What data will they have (e.g., will they have some of the variables, but not others)? Is it likely that values of the different variables will diverge in future cases? Your answers to the questions above will guide how you deal with the variables. Here are some possible strategies: If you want to describe the data, just do so. The collinearity is part of the results to be described. Good exploratory data analysis to generate hypotheses is hard. Try a lot of different models (e.g., different combinations of variables) and think deeply about them. Which are plausible? What would it mean, substantively, if one or another were the true data generating process? Don't only consider the point estimates of your betas, but also compute the models that would result from the true values being towards the extremes of the confidence intervals. If you think these $X$-variables are all just different manifestations of a single latent variable (which is somewhat implied by your description), you could: Combine them (for example, you could run a factor analysis, or maybe a PCA). Or possibly, use all of them. Extracting factors will inevitably leave out some information (and hopefully the measurement error); using all of them will guarantee every nuance is captured. To test them, drop all the correlated $X$-variables as a group and perform a nested model test. Or possibly, just pick one $X$-variable at random if the correlations are close enough to $r = 1.0$. At that point there is little to be gained by bothering with other strategies. If you think the $X$-variables are partly overlapping, you could perform a factor analysis and extract $>1$ factor, or use the $X$-variable you see as most directly measuring the main idea and residualizing the rest so that the resulting set are orthogonal. There are various ways to deal with causally related $X$-variables, and which to use will depend on the nature of the causal pattern you suspect and what you are trying to do. That said, the default approach might be to model the relations among the $X$-variables and $Y$ using something like structural equation modeling. A test of an extracted central factor from your $X$-variables used as an explanatory variable in a multiple regression model will be a good test of the information shared in common amongst your $X$-variables. If you want to test something about two (or more) correlated $X$-variables vis-a-vis each other, that is going to be very difficult to do, and you are just in a difficult situation. On the other hand, if you want to test an exposure completely unrelated to the correlated $X$-variables, just go ahead. The multicollinearity won't have any effect on the test of interest. If you are trying to create a predictive model, consider who will use the model to make predictions, in what situation, and what data will they most likely have access to. If they are likely to have $X_3$, but not $X_1, X_2, X_4,$ or $X_5$, use $X_3$. Predicted means aren't terribly affected by collinearity, so if that's all you care about and the correlations are likely to be similar when the model is used to make predictions, you should be fine. Conversely, if future data may occur in the regions of the $X$-variable space that aren't represented in your dataset, thar be dragons. Making a variety of different models and using model averaging may provide some limited safeguard.
Logistic regression and inclusion of independent and/or correlated variables
@NULL is right that this is a general question that isn't specific to your use case. Let me supplement his answer a little. What you really need to do in any given situation is think very hard abou
Logistic regression and inclusion of independent and/or correlated variables @NULL is right that this is a general question that isn't specific to your use case. Let me supplement his answer a little. What you really need to do in any given situation is think very hard about what you want to do and why. You have a situation where you want to build a model with response $Y$, but you believe that a set of $X$-variables will be highly correlated. That may not be a problem. First, why do you think the variables are correlated? Are they all measures of the same underlying construct? Are they partly overlapping, but partly distinct? Are some of them causally related to others? Second, what are your long-run goals? Do you just want to describe the data (their distributions and relationships)? Are you exploring the data to generate hypotheses for future research? Do you want to test a hypothesis? About what, one of the correlated variables relative to another, or about what they have in common, or about something completely unrelated (these are controls and the variable of interest is uncorrelated with them)? Do you want to to make a predictive model? Who is going to be using this to make predictions? What data will they have (e.g., will they have some of the variables, but not others)? Is it likely that values of the different variables will diverge in future cases? Your answers to the questions above will guide how you deal with the variables. Here are some possible strategies: If you want to describe the data, just do so. The collinearity is part of the results to be described. Good exploratory data analysis to generate hypotheses is hard. Try a lot of different models (e.g., different combinations of variables) and think deeply about them. Which are plausible? What would it mean, substantively, if one or another were the true data generating process? Don't only consider the point estimates of your betas, but also compute the models that would result from the true values being towards the extremes of the confidence intervals. If you think these $X$-variables are all just different manifestations of a single latent variable (which is somewhat implied by your description), you could: Combine them (for example, you could run a factor analysis, or maybe a PCA). Or possibly, use all of them. Extracting factors will inevitably leave out some information (and hopefully the measurement error); using all of them will guarantee every nuance is captured. To test them, drop all the correlated $X$-variables as a group and perform a nested model test. Or possibly, just pick one $X$-variable at random if the correlations are close enough to $r = 1.0$. At that point there is little to be gained by bothering with other strategies. If you think the $X$-variables are partly overlapping, you could perform a factor analysis and extract $>1$ factor, or use the $X$-variable you see as most directly measuring the main idea and residualizing the rest so that the resulting set are orthogonal. There are various ways to deal with causally related $X$-variables, and which to use will depend on the nature of the causal pattern you suspect and what you are trying to do. That said, the default approach might be to model the relations among the $X$-variables and $Y$ using something like structural equation modeling. A test of an extracted central factor from your $X$-variables used as an explanatory variable in a multiple regression model will be a good test of the information shared in common amongst your $X$-variables. If you want to test something about two (or more) correlated $X$-variables vis-a-vis each other, that is going to be very difficult to do, and you are just in a difficult situation. On the other hand, if you want to test an exposure completely unrelated to the correlated $X$-variables, just go ahead. The multicollinearity won't have any effect on the test of interest. If you are trying to create a predictive model, consider who will use the model to make predictions, in what situation, and what data will they most likely have access to. If they are likely to have $X_3$, but not $X_1, X_2, X_4,$ or $X_5$, use $X_3$. Predicted means aren't terribly affected by collinearity, so if that's all you care about and the correlations are likely to be similar when the model is used to make predictions, you should be fine. Conversely, if future data may occur in the regions of the $X$-variable space that aren't represented in your dataset, thar be dragons. Making a variety of different models and using model averaging may provide some limited safeguard.
Logistic regression and inclusion of independent and/or correlated variables @NULL is right that this is a general question that isn't specific to your use case. Let me supplement his answer a little. What you really need to do in any given situation is think very hard abou
46,584
Logistic regression and inclusion of independent and/or correlated variables
What you are asking are some fundamental questions about regression analysis that are not just about your specific use case. Hence, I recommend you reading more on regression analysis or take an online course such as Statistical Learning thought by those whom actually proposed some of the regularization method I'm discussing: How do I select the one (or combination of) independent variable(s) that should represent student effort? (I imagine some will be strongly correlated, so might not be good to use in combination.) Selecting independent (or not so independent) variables depend on the regularization method used for logistic regression analysis. There are many of them such as LASSO (L1), Ridge Regression (L2), and Elastic Net. Have a look at this question. Each of these regularization methods treat correlated variables/features differently. L1, favors one and ignores the other (zero weight), while L2 distributes weights equally, and Elastic Net is basically a mix of both. This is from Elastic Net Wikipedia page: if there is a group of highly correlated variables, then the LASSO tends to select one variable from a group and ignore the others. To overcome these limitations, the elastic net adds a quadratic part to the penalty, which when used alone is ridge regression (known also as Tikhonov regularization). Now, regarding your second question: Is it okay to control for differences between courses (MOOCs) by adding course_id as an additional independent variable to the logistic regression? (This option seems to yield higher prediction accuracy and better model fit.) This is totally fine as long as you what you are doing which is separating the contribution of variables within course vs. among all courses. This is a very important topic in the regression analysis and very popular in clinical research. By creating a feature such as course_id, you'd need to also perform a regression for each course separately to analyze the contribution of variables for each course (within group). The weights (or contribution of variables) that you get when training on all courses together with course_id, would simply tell you the amount of contribution of variables for all courses, in general.
Logistic regression and inclusion of independent and/or correlated variables
What you are asking are some fundamental questions about regression analysis that are not just about your specific use case. Hence, I recommend you reading more on regression analysis or take an onlin
Logistic regression and inclusion of independent and/or correlated variables What you are asking are some fundamental questions about regression analysis that are not just about your specific use case. Hence, I recommend you reading more on regression analysis or take an online course such as Statistical Learning thought by those whom actually proposed some of the regularization method I'm discussing: How do I select the one (or combination of) independent variable(s) that should represent student effort? (I imagine some will be strongly correlated, so might not be good to use in combination.) Selecting independent (or not so independent) variables depend on the regularization method used for logistic regression analysis. There are many of them such as LASSO (L1), Ridge Regression (L2), and Elastic Net. Have a look at this question. Each of these regularization methods treat correlated variables/features differently. L1, favors one and ignores the other (zero weight), while L2 distributes weights equally, and Elastic Net is basically a mix of both. This is from Elastic Net Wikipedia page: if there is a group of highly correlated variables, then the LASSO tends to select one variable from a group and ignore the others. To overcome these limitations, the elastic net adds a quadratic part to the penalty, which when used alone is ridge regression (known also as Tikhonov regularization). Now, regarding your second question: Is it okay to control for differences between courses (MOOCs) by adding course_id as an additional independent variable to the logistic regression? (This option seems to yield higher prediction accuracy and better model fit.) This is totally fine as long as you what you are doing which is separating the contribution of variables within course vs. among all courses. This is a very important topic in the regression analysis and very popular in clinical research. By creating a feature such as course_id, you'd need to also perform a regression for each course separately to analyze the contribution of variables for each course (within group). The weights (or contribution of variables) that you get when training on all courses together with course_id, would simply tell you the amount of contribution of variables for all courses, in general.
Logistic regression and inclusion of independent and/or correlated variables What you are asking are some fundamental questions about regression analysis that are not just about your specific use case. Hence, I recommend you reading more on regression analysis or take an onlin
46,585
What are the consequences of including unnecessary random effects?
Barr, Levy, Scheepers & Tily (2013) present an argument and simulations for why you should (by default) use the maximal random effects structure justified by your design. The crux of the argument is that the maximal model will generalize better. The paper also provides an argument for why it is anti-conservative to use the maximal model (pt. 1). More generally, by allowing random slopes and intercepts you're more likely to get a better fit to the data and thus better detect when variance is attributable to the fixed effects. (2) In model comparison with models that feature the same random effects structure, only differences in the fixed effects should affect AIC. However, if you're using the maximal model, adding a fixed effect will necessitate adding random slope and intercept terms. It's not a great idea to use the sample data to determine if random effects are "necessary". Just because the inclusion of random effects doesn't explain variance in your current dataset doesn't mean that it is not important to the population you're making inferences about. You're right to suspect that the model is more likely to fail to converge with more complicated random effects structures (pt. 4). You'll have to balance the benefits of using the maximal random effects structure against the real-world constraints of your data; obviously if the model doesn't converge the results should be treated with suspicion. One possible solution in this situation is to try permutation-based analysis (bootstrapping).
What are the consequences of including unnecessary random effects?
Barr, Levy, Scheepers & Tily (2013) present an argument and simulations for why you should (by default) use the maximal random effects structure justified by your design. The crux of the argument is t
What are the consequences of including unnecessary random effects? Barr, Levy, Scheepers & Tily (2013) present an argument and simulations for why you should (by default) use the maximal random effects structure justified by your design. The crux of the argument is that the maximal model will generalize better. The paper also provides an argument for why it is anti-conservative to use the maximal model (pt. 1). More generally, by allowing random slopes and intercepts you're more likely to get a better fit to the data and thus better detect when variance is attributable to the fixed effects. (2) In model comparison with models that feature the same random effects structure, only differences in the fixed effects should affect AIC. However, if you're using the maximal model, adding a fixed effect will necessitate adding random slope and intercept terms. It's not a great idea to use the sample data to determine if random effects are "necessary". Just because the inclusion of random effects doesn't explain variance in your current dataset doesn't mean that it is not important to the population you're making inferences about. You're right to suspect that the model is more likely to fail to converge with more complicated random effects structures (pt. 4). You'll have to balance the benefits of using the maximal random effects structure against the real-world constraints of your data; obviously if the model doesn't converge the results should be treated with suspicion. One possible solution in this situation is to try permutation-based analysis (bootstrapping).
What are the consequences of including unnecessary random effects? Barr, Levy, Scheepers & Tily (2013) present an argument and simulations for why you should (by default) use the maximal random effects structure justified by your design. The crux of the argument is t
46,586
Formula for number of weights in neural network
The reason you're confused is the fact that function nnetar creates an autoregressive neural network and not a standard neural network. This means that the input layer nodes of the network are: the exogenous regressors that you pass with xreg , the autoregressive variables that nnetar creates, the bias term. Running nnetar(1:10, xreg=data.frame(10:1,3:12)), for example, creates by default a NNAR(1,2) model, i.e. a neural network with one lagged term and two hidden nodes. NNAR(1,2) with two regressors results to a 3-2-1 network where you have: 3 nodes in the input layer: $y_{t-1}$, $x_1$, $x_2$ 2 nodes in the hidden layer 1 node in the output layer If you calculate all weights so far you'll see that you only get 8: $3 \times 2 + 2 \times 1 $. But then why does nnetar return 11 weights? This is because of the "bias" nodes, which are not really counted in the 3-2-1 network though they are part of it and do carry extra weights. There is one bias node in the input layer and one in the hidden layer which connects only to the output layer. So you have 2 weights from the input layer bias node plus 1 weight from the hidden layer bias node, that makes 3 plus 8 from before, 11 weights in total. You can learn more on this architecture from the documentation of nnetar or Hyndman's new book. Here's what NNAR(1,2) with 2 regressors looks like: You can find the number of weights by counting the edges in that network. To address the original question: In a canonical neural network, the weights go on the edges between the input layer and the hidden layers, between all hidden layers, and between hidden layers and the output layer. If you are looking for a way to count weights in a 1-hidden-layer network that would be the number of nodes in the hidden layer times number of nodes in the input layer plus number of nodes in the hidden layer times number of nodes in the output layer. If you're using nnetar, you must make sure you add the autoregressive terms as nodes in the input layer (nnetar that always comes with 1 hidden layer but if you have more hidden layers you simply have to adapt this method to all layers).
Formula for number of weights in neural network
The reason you're confused is the fact that function nnetar creates an autoregressive neural network and not a standard neural network. This means that the input layer nodes of the network are: the
Formula for number of weights in neural network The reason you're confused is the fact that function nnetar creates an autoregressive neural network and not a standard neural network. This means that the input layer nodes of the network are: the exogenous regressors that you pass with xreg , the autoregressive variables that nnetar creates, the bias term. Running nnetar(1:10, xreg=data.frame(10:1,3:12)), for example, creates by default a NNAR(1,2) model, i.e. a neural network with one lagged term and two hidden nodes. NNAR(1,2) with two regressors results to a 3-2-1 network where you have: 3 nodes in the input layer: $y_{t-1}$, $x_1$, $x_2$ 2 nodes in the hidden layer 1 node in the output layer If you calculate all weights so far you'll see that you only get 8: $3 \times 2 + 2 \times 1 $. But then why does nnetar return 11 weights? This is because of the "bias" nodes, which are not really counted in the 3-2-1 network though they are part of it and do carry extra weights. There is one bias node in the input layer and one in the hidden layer which connects only to the output layer. So you have 2 weights from the input layer bias node plus 1 weight from the hidden layer bias node, that makes 3 plus 8 from before, 11 weights in total. You can learn more on this architecture from the documentation of nnetar or Hyndman's new book. Here's what NNAR(1,2) with 2 regressors looks like: You can find the number of weights by counting the edges in that network. To address the original question: In a canonical neural network, the weights go on the edges between the input layer and the hidden layers, between all hidden layers, and between hidden layers and the output layer. If you are looking for a way to count weights in a 1-hidden-layer network that would be the number of nodes in the hidden layer times number of nodes in the input layer plus number of nodes in the hidden layer times number of nodes in the output layer. If you're using nnetar, you must make sure you add the autoregressive terms as nodes in the input layer (nnetar that always comes with 1 hidden layer but if you have more hidden layers you simply have to adapt this method to all layers).
Formula for number of weights in neural network The reason you're confused is the fact that function nnetar creates an autoregressive neural network and not a standard neural network. This means that the input layer nodes of the network are: the
46,587
What is this chart of before and after data called?
They are called Sankey Diagrams. There are a few different options to create these in R. Your example could have been created with straight lines using parallel sets. There are a few other R packages though that can make more complicated diagrams, see this SO Q/A for some examples.
What is this chart of before and after data called?
They are called Sankey Diagrams. There are a few different options to create these in R. Your example could have been created with straight lines using parallel sets. There are a few other R packages
What is this chart of before and after data called? They are called Sankey Diagrams. There are a few different options to create these in R. Your example could have been created with straight lines using parallel sets. There are a few other R packages though that can make more complicated diagrams, see this SO Q/A for some examples.
What is this chart of before and after data called? They are called Sankey Diagrams. There are a few different options to create these in R. Your example could have been created with straight lines using parallel sets. There are a few other R packages
46,588
How to improve rare event binary classification performance?
Casting this as a classification problem was a major misstep. This is inherently a "tendency estimation", i.e., probability estimation problem. That is what logistic regression is all about. And you've chosen improper accuracy scores - scores that are optimized by choosing the wrong features and giving them the wrong weights. For details see http://www.fharrell.com/2017/01/classification-vs-prediction.html and http://www.fharrell.com/2017/03/damage-caused-by-classification.html
How to improve rare event binary classification performance?
Casting this as a classification problem was a major misstep. This is inherently a "tendency estimation", i.e., probability estimation problem. That is what logistic regression is all about. And yo
How to improve rare event binary classification performance? Casting this as a classification problem was a major misstep. This is inherently a "tendency estimation", i.e., probability estimation problem. That is what logistic regression is all about. And you've chosen improper accuracy scores - scores that are optimized by choosing the wrong features and giving them the wrong weights. For details see http://www.fharrell.com/2017/01/classification-vs-prediction.html and http://www.fharrell.com/2017/03/damage-caused-by-classification.html
How to improve rare event binary classification performance? Casting this as a classification problem was a major misstep. This is inherently a "tendency estimation", i.e., probability estimation problem. That is what logistic regression is all about. And yo
46,589
How to improve rare event binary classification performance?
In addition to Frank Harrell's important point about classification versus prediction, you might need to consider that you don't have the information needed to judge the probability of admission. AUC is the one measure in your list that isn't subject to arbitrary choices of cutoffs for classification, and it is very close to the value of 0.5 seen when your model is no better than random. It might just be too hard to determine the precise day when an individual will be admitted, particularly for a first admission, which seems to be what your data-set construction and analysis are examining. Dealing with re-admission characteristics might be possible with a survival model. The starting date in each case would be the date of discharge from the first admission. Then you could incorporate weather and air-quality measures as time-dependent covariates in a model of time-to-readmission.
How to improve rare event binary classification performance?
In addition to Frank Harrell's important point about classification versus prediction, you might need to consider that you don't have the information needed to judge the probability of admission. AUC
How to improve rare event binary classification performance? In addition to Frank Harrell's important point about classification versus prediction, you might need to consider that you don't have the information needed to judge the probability of admission. AUC is the one measure in your list that isn't subject to arbitrary choices of cutoffs for classification, and it is very close to the value of 0.5 seen when your model is no better than random. It might just be too hard to determine the precise day when an individual will be admitted, particularly for a first admission, which seems to be what your data-set construction and analysis are examining. Dealing with re-admission characteristics might be possible with a survival model. The starting date in each case would be the date of discharge from the first admission. Then you could incorporate weather and air-quality measures as time-dependent covariates in a model of time-to-readmission.
How to improve rare event binary classification performance? In addition to Frank Harrell's important point about classification versus prediction, you might need to consider that you don't have the information needed to judge the probability of admission. AUC
46,590
Variance of a sample covariance for normal variables
The OP is interested in Var(sample covariances) in a bivariate Normal world. You know the solution for: Var(sample variances) (main diagonal), so ... All that is needed is the solution for: Var(sample covariance) Then there is no need for any matrix notation whatsoever, and if I understand correctly, the question reduces to: Question: Let $(X,Y)$ be bivariate Normal. Given a sample of size $n$, namely $\big( (X_1, Y_1), \dots, (X_n, Y_n) \big)$, find $\text{Var}(W)$, where the sample covariance $W$ is defined as: $$W = \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y). $$ Answer: This problem can be solved much more generally. We will obtain a general solution to $\text{Var}(W)$ for any distribution whose moments exist, and then solve for the Normal as a special case. The modus operandi for solving such problems is to work with power sum notation, which in our bivariate world is of form $s_{r,t}$, namely: $$s_{r,t}=\sum _{i=1}^n X_i^r Y_i^t$$ In particular, sample covariance $W$ can be written in power sum notation as: We seek $\text{Var}(W)$. Since the variance operator is the $2^\text{nd}$ Central Moment of $W$, we can find the variance using the mathStatica (for Mathematica) package function : where: $\mu _{r,s}$ denotes the product central moment: $$\mu _{r,s}=E\left[(X-E[X]]^r (Y-E[Y])^s\right]$$ For example, $\mu_{1,1} = \text{Cov}(X,Y)$, $\mu_{2,0}= \text{Var}(X)$ and $\mu_{0,2}= \text{Var}(Y)$. This is a general solution for any bivariate distribution whose moments exist. Special case of bivariate Normal In the case of a bivariate Normal with variance-covariance: $$\Sigma = \left( \begin{array}{cc} \sigma _{11}^2 & \rho \sigma _{11} \sigma _{22} \\ \rho \sigma _{11} \sigma _{22} & \sigma _{22}^2 \\ \end{array} \right)$$ ... the various central moments $\mu_{i,j}$ are: Substituting in these values into the general solution sol yields $\text{Var}(W)$ in the bivariate Normal case as: I am not sure if this is the same as the OP's posted solution of: $\frac{1}{n-1}(\sigma_{ij}^2 + \sigma_{ii}\sigma_{jj})$, as the notation he intended for $\sigma_{ij}$ is not tied down and appears inconsistent with that used by the OP for the diagonal cases, which the OP states correctly as: $\text{Var}(s^2) = \frac{2\sigma^4}{n-1}$ In summary, for the Normal case, the Variance of sample covariances is: $$ \text{Var} \left( \begin{array}{cc} \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)^2 & \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y) \\ \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y) & \frac 1 {n-1} \sum_{i=1}^n (Y_i-\bar Y)^2 \\ \end{array} \right)$$ $$= \frac{1}{n-1}\left( \begin{array}{cc} 2 \sigma _{11}^4 & \left(1+\rho ^2\right) \sigma _{11}^2 \sigma _{22}^2 \\ \left(1+\rho ^2\right) \sigma _{11}^2 \sigma _{22}^2 & 2 \sigma _{22}^4 \\ \end{array} \right)$$
Variance of a sample covariance for normal variables
The OP is interested in Var(sample covariances) in a bivariate Normal world. You know the solution for: Var(sample variances) (main diagonal), so ... All that is needed is the solution for: Var(samp
Variance of a sample covariance for normal variables The OP is interested in Var(sample covariances) in a bivariate Normal world. You know the solution for: Var(sample variances) (main diagonal), so ... All that is needed is the solution for: Var(sample covariance) Then there is no need for any matrix notation whatsoever, and if I understand correctly, the question reduces to: Question: Let $(X,Y)$ be bivariate Normal. Given a sample of size $n$, namely $\big( (X_1, Y_1), \dots, (X_n, Y_n) \big)$, find $\text{Var}(W)$, where the sample covariance $W$ is defined as: $$W = \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y). $$ Answer: This problem can be solved much more generally. We will obtain a general solution to $\text{Var}(W)$ for any distribution whose moments exist, and then solve for the Normal as a special case. The modus operandi for solving such problems is to work with power sum notation, which in our bivariate world is of form $s_{r,t}$, namely: $$s_{r,t}=\sum _{i=1}^n X_i^r Y_i^t$$ In particular, sample covariance $W$ can be written in power sum notation as: We seek $\text{Var}(W)$. Since the variance operator is the $2^\text{nd}$ Central Moment of $W$, we can find the variance using the mathStatica (for Mathematica) package function : where: $\mu _{r,s}$ denotes the product central moment: $$\mu _{r,s}=E\left[(X-E[X]]^r (Y-E[Y])^s\right]$$ For example, $\mu_{1,1} = \text{Cov}(X,Y)$, $\mu_{2,0}= \text{Var}(X)$ and $\mu_{0,2}= \text{Var}(Y)$. This is a general solution for any bivariate distribution whose moments exist. Special case of bivariate Normal In the case of a bivariate Normal with variance-covariance: $$\Sigma = \left( \begin{array}{cc} \sigma _{11}^2 & \rho \sigma _{11} \sigma _{22} \\ \rho \sigma _{11} \sigma _{22} & \sigma _{22}^2 \\ \end{array} \right)$$ ... the various central moments $\mu_{i,j}$ are: Substituting in these values into the general solution sol yields $\text{Var}(W)$ in the bivariate Normal case as: I am not sure if this is the same as the OP's posted solution of: $\frac{1}{n-1}(\sigma_{ij}^2 + \sigma_{ii}\sigma_{jj})$, as the notation he intended for $\sigma_{ij}$ is not tied down and appears inconsistent with that used by the OP for the diagonal cases, which the OP states correctly as: $\text{Var}(s^2) = \frac{2\sigma^4}{n-1}$ In summary, for the Normal case, the Variance of sample covariances is: $$ \text{Var} \left( \begin{array}{cc} \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)^2 & \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y) \\ \frac 1 {n-1} \sum_{i=1}^n (X_i - \bar X)(Y_i-\bar Y) & \frac 1 {n-1} \sum_{i=1}^n (Y_i-\bar Y)^2 \\ \end{array} \right)$$ $$= \frac{1}{n-1}\left( \begin{array}{cc} 2 \sigma _{11}^4 & \left(1+\rho ^2\right) \sigma _{11}^2 \sigma _{22}^2 \\ \left(1+\rho ^2\right) \sigma _{11}^2 \sigma _{22}^2 & 2 \sigma _{22}^4 \\ \end{array} \right)$$
Variance of a sample covariance for normal variables The OP is interested in Var(sample covariances) in a bivariate Normal world. You know the solution for: Var(sample variances) (main diagonal), so ... All that is needed is the solution for: Var(samp
46,591
Variance of a sample covariance for normal variables
After following the suggestion from Mark Stone I looked up Wishart distribution and estimation of covariance matrices and here's a quick summary. For a random, normally distributed $p$ element vector with a covariance matrix $\Sigma$ the quantity: $$ \sum_{i=1}^n \mathbf{X}_i\mathbf{X}_i^T \sim W_p(\Sigma, n-1) $$ where $W_p$ is a Wishart distribution. The formula for a variance of the sample covariance is then given by: $$ \text{Var}(Q_{ij}) = \frac{1}{n-1}(\sigma_{ij}^2 + \sigma_{ii}\sigma_{jj}), $$ where $\sigma_{ij}$ are components of covariance matrix $\Sigma$.
Variance of a sample covariance for normal variables
After following the suggestion from Mark Stone I looked up Wishart distribution and estimation of covariance matrices and here's a quick summary. For a random, normally distributed $p$ element vector
Variance of a sample covariance for normal variables After following the suggestion from Mark Stone I looked up Wishart distribution and estimation of covariance matrices and here's a quick summary. For a random, normally distributed $p$ element vector with a covariance matrix $\Sigma$ the quantity: $$ \sum_{i=1}^n \mathbf{X}_i\mathbf{X}_i^T \sim W_p(\Sigma, n-1) $$ where $W_p$ is a Wishart distribution. The formula for a variance of the sample covariance is then given by: $$ \text{Var}(Q_{ij}) = \frac{1}{n-1}(\sigma_{ij}^2 + \sigma_{ii}\sigma_{jj}), $$ where $\sigma_{ij}$ are components of covariance matrix $\Sigma$.
Variance of a sample covariance for normal variables After following the suggestion from Mark Stone I looked up Wishart distribution and estimation of covariance matrices and here's a quick summary. For a random, normally distributed $p$ element vector
46,592
Distribution of sum of two independent normals conditional on one of them
Given: $X$ and $Y$ are independent standard Normals with pdf's $\phi(.)$ and cdf's $\Phi(.)$. Since $X$ and $Y$ are independent, the joint pdf of $\big((X \; \big|\;X<c), \; Y\big)$ is $f(x,y) = {\large\frac{\phi(x)}{\Phi(c)}} \phi(y)$: where Erf[.] denotes the error function. Part 1: The pdf of $Z = X+Y \; | \; X<c$ Given $f(x,y)$, consider the transformation $(Z = X+Y, V=Y)$. If $X <c$ and $Z = X+Y$, then $Z < c + Y$. That is, $Z < c + V$. This dependency is invoked in the following line using the Boole statement. Then the joint pdf of $(Z,V)$, say $g(z,v)$ can be obtained with: ... where I am using the Transform function from mathStatica/Mathematica to automate the nitty-gritties using the Method of Transformations (Jacobian etc). The pdf of $Z$ that we seek is simply the marginal pdf of $Z$: ... which is our desired closed form solution. The following diagram plots the pdf of $Z$ (i.e. the sum of 2 independent Normals, conditional on one of them) for six different vales of parameter $c$: Part 2: Find $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$ To find $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$, integrate the above pdfZ over $(\sqrt2 c, \infty)$ wrt $z$. Alternatively, $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$ can be obtained directly from the first step by : ... where I am using the Prob function from mathStatica/Mathematica to automate the nitty-gritties. This solution can be written in conventional notation as: $$\frac{1}{\Phi(c)} \quad \int_{-\infty}^c \phi(x) \; \Phi \left(x-\sqrt{2} c\right) \, dx$$ While the probability does not appear to have a convenient closed-form, it is nevertheless a useful and practical result that is reduced to integrating a single variable. In particular: a) when $c = 0$, the solution simplifies to $\frac14$ b) for other $c$ values, replace Integrate with NIntegrate for a solution via numerical integration in a single variable, which works very nicely. For instance, here is a plot of the desired probability, as a function of the truncation point $c$:
Distribution of sum of two independent normals conditional on one of them
Given: $X$ and $Y$ are independent standard Normals with pdf's $\phi(.)$ and cdf's $\Phi(.)$. Since $X$ and $Y$ are independent, the joint pdf of $\big((X \; \big|\;X<c), \; Y\big)$ is $f(x,y) = {\la
Distribution of sum of two independent normals conditional on one of them Given: $X$ and $Y$ are independent standard Normals with pdf's $\phi(.)$ and cdf's $\Phi(.)$. Since $X$ and $Y$ are independent, the joint pdf of $\big((X \; \big|\;X<c), \; Y\big)$ is $f(x,y) = {\large\frac{\phi(x)}{\Phi(c)}} \phi(y)$: where Erf[.] denotes the error function. Part 1: The pdf of $Z = X+Y \; | \; X<c$ Given $f(x,y)$, consider the transformation $(Z = X+Y, V=Y)$. If $X <c$ and $Z = X+Y$, then $Z < c + Y$. That is, $Z < c + V$. This dependency is invoked in the following line using the Boole statement. Then the joint pdf of $(Z,V)$, say $g(z,v)$ can be obtained with: ... where I am using the Transform function from mathStatica/Mathematica to automate the nitty-gritties using the Method of Transformations (Jacobian etc). The pdf of $Z$ that we seek is simply the marginal pdf of $Z$: ... which is our desired closed form solution. The following diagram plots the pdf of $Z$ (i.e. the sum of 2 independent Normals, conditional on one of them) for six different vales of parameter $c$: Part 2: Find $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$ To find $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$, integrate the above pdfZ over $(\sqrt2 c, \infty)$ wrt $z$. Alternatively, $P\left(\frac{X+Y}{\sqrt{2}}>c\,\Biggl|\,X<c\right)$ can be obtained directly from the first step by : ... where I am using the Prob function from mathStatica/Mathematica to automate the nitty-gritties. This solution can be written in conventional notation as: $$\frac{1}{\Phi(c)} \quad \int_{-\infty}^c \phi(x) \; \Phi \left(x-\sqrt{2} c\right) \, dx$$ While the probability does not appear to have a convenient closed-form, it is nevertheless a useful and practical result that is reduced to integrating a single variable. In particular: a) when $c = 0$, the solution simplifies to $\frac14$ b) for other $c$ values, replace Integrate with NIntegrate for a solution via numerical integration in a single variable, which works very nicely. For instance, here is a plot of the desired probability, as a function of the truncation point $c$:
Distribution of sum of two independent normals conditional on one of them Given: $X$ and $Y$ are independent standard Normals with pdf's $\phi(.)$ and cdf's $\Phi(.)$. Since $X$ and $Y$ are independent, the joint pdf of $\big((X \; \big|\;X<c), \; Y\big)$ is $f(x,y) = {\la
46,593
Distribution of sum of two independent normals conditional on one of them
Sorry for not delivering the details, but $$ \int_{-\infty}^c \phi(x) \; \Phi(x-\sqrt{2} c) \, dx = 2T(c, \sqrt{2}-1) $$ where $T$ is the Owen $T$-function. This function is available in Mathematica/Wolfram and in the R package OwenQ. library(OwenQ) pr <- function(c){ 2*OwenT(c, sqrt(2)-1) / pnorm(c) } curve(Vectorize(pr)(x), from=-6, to=6) Alternatively you can get the Owen $T$-function with the help of the cdf of the noncentral Student distribution: owenT <- function(h, a) 1/2*(pt(a, 1, h*sqrt(1+a^2)) - pnorm(-h)) But this implementation is not reliable for large values of the noncentrality parameter h*sqrt(1+a^2).
Distribution of sum of two independent normals conditional on one of them
Sorry for not delivering the details, but $$ \int_{-\infty}^c \phi(x) \; \Phi(x-\sqrt{2} c) \, dx = 2T(c, \sqrt{2}-1) $$ where $T$ is the Owen $T$-function. This function is available in Mathematica/W
Distribution of sum of two independent normals conditional on one of them Sorry for not delivering the details, but $$ \int_{-\infty}^c \phi(x) \; \Phi(x-\sqrt{2} c) \, dx = 2T(c, \sqrt{2}-1) $$ where $T$ is the Owen $T$-function. This function is available in Mathematica/Wolfram and in the R package OwenQ. library(OwenQ) pr <- function(c){ 2*OwenT(c, sqrt(2)-1) / pnorm(c) } curve(Vectorize(pr)(x), from=-6, to=6) Alternatively you can get the Owen $T$-function with the help of the cdf of the noncentral Student distribution: owenT <- function(h, a) 1/2*(pt(a, 1, h*sqrt(1+a^2)) - pnorm(-h)) But this implementation is not reliable for large values of the noncentrality parameter h*sqrt(1+a^2).
Distribution of sum of two independent normals conditional on one of them Sorry for not delivering the details, but $$ \int_{-\infty}^c \phi(x) \; \Phi(x-\sqrt{2} c) \, dx = 2T(c, \sqrt{2}-1) $$ where $T$ is the Owen $T$-function. This function is available in Mathematica/W
46,594
Are D-separation and Conditional independence equivalent?
D-seperation is not equivalent to conditional independence. The D-seperation of $X$ and $Y$ given $Z$ implies the following conditional independence: $$P(X,Y|Z) = P(X|Z)P(Y|Z).$$ However D-seperation is a concept that applies specifically to graphical models. You can talk about conditional independence in any context involving random variables. The statement is talking about something different. What the statement is saying is that just because two nodes $X$ and $Y$ are not D-seperated given some subset of nodes $Z$, that doesn't mean there doesn't exist some probability distribution which factorizes over $G$ for which $X$ and $Y$ are conditionally independent given $Z$. In fact there will always exist such a distribution (see the following paragraph). Graphical models are only required to not encode any independency which doesn't actually exist in the joint probability distribution, that is to say, they are required to make no unwarranted assumptions. However there's no requirement that they encode every independency that does in fact exist, and often times building a graphical model which captures every existing independency while at the same time avoiding the instantiation of spurious independencies is impossible (such a graph when it does exist is called a perfect I-map). Therefore given a graphical model $G$, any mutually independent probability distribution on the nodes of $G$ trivially factorizes over $G$.
Are D-separation and Conditional independence equivalent?
D-seperation is not equivalent to conditional independence. The D-seperation of $X$ and $Y$ given $Z$ implies the following conditional independence: $$P(X,Y|Z) = P(X|Z)P(Y|Z).$$ However D-seperation
Are D-separation and Conditional independence equivalent? D-seperation is not equivalent to conditional independence. The D-seperation of $X$ and $Y$ given $Z$ implies the following conditional independence: $$P(X,Y|Z) = P(X|Z)P(Y|Z).$$ However D-seperation is a concept that applies specifically to graphical models. You can talk about conditional independence in any context involving random variables. The statement is talking about something different. What the statement is saying is that just because two nodes $X$ and $Y$ are not D-seperated given some subset of nodes $Z$, that doesn't mean there doesn't exist some probability distribution which factorizes over $G$ for which $X$ and $Y$ are conditionally independent given $Z$. In fact there will always exist such a distribution (see the following paragraph). Graphical models are only required to not encode any independency which doesn't actually exist in the joint probability distribution, that is to say, they are required to make no unwarranted assumptions. However there's no requirement that they encode every independency that does in fact exist, and often times building a graphical model which captures every existing independency while at the same time avoiding the instantiation of spurious independencies is impossible (such a graph when it does exist is called a perfect I-map). Therefore given a graphical model $G$, any mutually independent probability distribution on the nodes of $G$ trivially factorizes over $G$.
Are D-separation and Conditional independence equivalent? D-seperation is not equivalent to conditional independence. The D-seperation of $X$ and $Y$ given $Z$ implies the following conditional independence: $$P(X,Y|Z) = P(X|Z)P(Y|Z).$$ However D-seperation
46,595
Why is empirical risk minimization prone to overfitting?
It's a pretty general question, I'll try to lay out the main ideas in a simple manner. There are a lot of good resources which you can use for further reading, one which I can recommend is Shai Shalev-Schwarz "Understanding Machine Learning" which focuses on the theoretical foundations for machine learning. Put very simply, the idea in machine learning is to be able to learn (for example, a classifier) given a set of labeled examples ("training set"), and then use that classifier to also classify new data ("test set"). The goal is to do well on the unseen test data - this is known as "generalization". Probably the most natural way to accomplish the above task is to choose a classifier that performs best on the training data. This is what is known as ERM (empirical risk minimization). But is that always a good strategy? As it turns out, the answer is no. Suppose we are given the following training data: points in blue belong to class 1, and points in red belong to class 2. Our goal is to learn a classifier that "separates" them (i.e can classify a new example to one of the classes). Then, if I were to follow the ERM rule, I would choose the classifier denoted in green: It achieves an accuracy of 100% on the training data (no example is mis-classified). But is this really what we wanted? We learned a very complex model, but most of the chances are that the data we got was a little noisy. With ERM, we essentially "learned" the noise, instead of ignoring it. If we were now to receive new test data from a similar distribution, we are likely to make mistakes. This is the phenomena of overfitting: We fitted out training data very well (too well), at the cost of performing badly on test data. Essentially, we hurt our ability to generalize! If, on the other hand, we are willing to not perform perfectly on the training set, than we can actually do better on test data (see the black classifier in the above image). It's a little surprising when you encounter it for the first time. The transition from the green classifier to something that resembles the black classifier can be achieved by introducing regularization - you've probably encountered the R-ERM (regularized empirical risk minimization), but this is already another subject.
Why is empirical risk minimization prone to overfitting?
It's a pretty general question, I'll try to lay out the main ideas in a simple manner. There are a lot of good resources which you can use for further reading, one which I can recommend is Shai Shalev
Why is empirical risk minimization prone to overfitting? It's a pretty general question, I'll try to lay out the main ideas in a simple manner. There are a lot of good resources which you can use for further reading, one which I can recommend is Shai Shalev-Schwarz "Understanding Machine Learning" which focuses on the theoretical foundations for machine learning. Put very simply, the idea in machine learning is to be able to learn (for example, a classifier) given a set of labeled examples ("training set"), and then use that classifier to also classify new data ("test set"). The goal is to do well on the unseen test data - this is known as "generalization". Probably the most natural way to accomplish the above task is to choose a classifier that performs best on the training data. This is what is known as ERM (empirical risk minimization). But is that always a good strategy? As it turns out, the answer is no. Suppose we are given the following training data: points in blue belong to class 1, and points in red belong to class 2. Our goal is to learn a classifier that "separates" them (i.e can classify a new example to one of the classes). Then, if I were to follow the ERM rule, I would choose the classifier denoted in green: It achieves an accuracy of 100% on the training data (no example is mis-classified). But is this really what we wanted? We learned a very complex model, but most of the chances are that the data we got was a little noisy. With ERM, we essentially "learned" the noise, instead of ignoring it. If we were now to receive new test data from a similar distribution, we are likely to make mistakes. This is the phenomena of overfitting: We fitted out training data very well (too well), at the cost of performing badly on test data. Essentially, we hurt our ability to generalize! If, on the other hand, we are willing to not perform perfectly on the training set, than we can actually do better on test data (see the black classifier in the above image). It's a little surprising when you encounter it for the first time. The transition from the green classifier to something that resembles the black classifier can be achieved by introducing regularization - you've probably encountered the R-ERM (regularized empirical risk minimization), but this is already another subject.
Why is empirical risk minimization prone to overfitting? It's a pretty general question, I'll try to lay out the main ideas in a simple manner. There are a lot of good resources which you can use for further reading, one which I can recommend is Shai Shalev
46,596
Why is empirical risk minimization prone to overfitting?
If we know the true distribution, memorizing it won't lead to overfitting. In the example in the above answer, suppose the true distribution is the black curve plus some noise, we will know that the empirical loss at those overfit points is different from their expected loss, $E_{sample}[L(x,y,\theta)]\neq E_{data}[L(x,y,\theta)]$. Therefore minimizing the "true loss" in this case will not lead to overfitting (if the loss is properly defined). In most problems we won't know the true distribution, so we often need some techniques (regularization, data augmentation, network structures, etc.) to close the gap between our data/model and the true distribution.
Why is empirical risk minimization prone to overfitting?
If we know the true distribution, memorizing it won't lead to overfitting. In the example in the above answer, suppose the true distribution is the black curve plus some noise, we will know that the e
Why is empirical risk minimization prone to overfitting? If we know the true distribution, memorizing it won't lead to overfitting. In the example in the above answer, suppose the true distribution is the black curve plus some noise, we will know that the empirical loss at those overfit points is different from their expected loss, $E_{sample}[L(x,y,\theta)]\neq E_{data}[L(x,y,\theta)]$. Therefore minimizing the "true loss" in this case will not lead to overfitting (if the loss is properly defined). In most problems we won't know the true distribution, so we often need some techniques (regularization, data augmentation, network structures, etc.) to close the gap between our data/model and the true distribution.
Why is empirical risk minimization prone to overfitting? If we know the true distribution, memorizing it won't lead to overfitting. In the example in the above answer, suppose the true distribution is the black curve plus some noise, we will know that the e
46,597
Why is empirical risk minimization prone to overfitting?
There are already some good answers here explaining the general point, I'll just add two more points: The overfitting of the empirical risk is especially prominent in cases of a small training set. When the data don't contain enough information to learn the underlying pattern, more regularization is needed to fill in the gap. In the specific case of the Deep learning the case is not so clear. Especially with very large nets, it is virtually impossible to find the global minimizer of the loss function, which likely corresponds to the heavily overfitted case. See AISTATS 2015 paper by Choromanska et al. for details [1]. Moreover, there are various interesting works studying the memorization behavior of the deep nets, such as [2] and [3]. Their implication is that even though deep nets have certainly the capacity to overfit terribly, in practice they generalize well even when trained with the unregularized empirical risk. [1] https://arxiv.org/abs/1412.0233 [2] https://openreview.net/forum?id=rJv6ZgHYg&noteId=rJv6ZgHYg [3] https://arxiv.org/abs/1611.03530
Why is empirical risk minimization prone to overfitting?
There are already some good answers here explaining the general point, I'll just add two more points: The overfitting of the empirical risk is especially prominent in cases of a small training set. W
Why is empirical risk minimization prone to overfitting? There are already some good answers here explaining the general point, I'll just add two more points: The overfitting of the empirical risk is especially prominent in cases of a small training set. When the data don't contain enough information to learn the underlying pattern, more regularization is needed to fill in the gap. In the specific case of the Deep learning the case is not so clear. Especially with very large nets, it is virtually impossible to find the global minimizer of the loss function, which likely corresponds to the heavily overfitted case. See AISTATS 2015 paper by Choromanska et al. for details [1]. Moreover, there are various interesting works studying the memorization behavior of the deep nets, such as [2] and [3]. Their implication is that even though deep nets have certainly the capacity to overfit terribly, in practice they generalize well even when trained with the unregularized empirical risk. [1] https://arxiv.org/abs/1412.0233 [2] https://openreview.net/forum?id=rJv6ZgHYg&noteId=rJv6ZgHYg [3] https://arxiv.org/abs/1611.03530
Why is empirical risk minimization prone to overfitting? There are already some good answers here explaining the general point, I'll just add two more points: The overfitting of the empirical risk is especially prominent in cases of a small training set. W
46,598
What is the difference between PCA and PLS-DA?
Quick answer which I will expand in few days is PLS-DA is a supervised method where you supply the information about each sample's group. PCA, on the other hand, is an unsupervised method which means that you are just projecting the data to, lets say, 2D space in a good way to observe how the samples are clustering by theirselves. PCA, after coloring of samples on the graph and if a good class seperation is achieved, may look like a somewhat supervised method though... Which one is better depends, if you know each sample's group and want to predict a new sample's group PLS-DA is a "go to" for me, for instance.
What is the difference between PCA and PLS-DA?
Quick answer which I will expand in few days is PLS-DA is a supervised method where you supply the information about each sample's group. PCA, on the other hand, is an unsupervised method which means
What is the difference between PCA and PLS-DA? Quick answer which I will expand in few days is PLS-DA is a supervised method where you supply the information about each sample's group. PCA, on the other hand, is an unsupervised method which means that you are just projecting the data to, lets say, 2D space in a good way to observe how the samples are clustering by theirselves. PCA, after coloring of samples on the graph and if a good class seperation is achieved, may look like a somewhat supervised method though... Which one is better depends, if you know each sample's group and want to predict a new sample's group PLS-DA is a "go to" for me, for instance.
What is the difference between PCA and PLS-DA? Quick answer which I will expand in few days is PLS-DA is a supervised method where you supply the information about each sample's group. PCA, on the other hand, is an unsupervised method which means
46,599
What is the difference between PCA and PLS-DA?
PCA is used for clustering where as PLS-DA use for classification in other word PCA shows the similarities in variables but PLS-DA shows the discrimination between variables
What is the difference between PCA and PLS-DA?
PCA is used for clustering where as PLS-DA use for classification in other word PCA shows the similarities in variables but PLS-DA shows the discrimination between variables
What is the difference between PCA and PLS-DA? PCA is used for clustering where as PLS-DA use for classification in other word PCA shows the similarities in variables but PLS-DA shows the discrimination between variables
What is the difference between PCA and PLS-DA? PCA is used for clustering where as PLS-DA use for classification in other word PCA shows the similarities in variables but PLS-DA shows the discrimination between variables
46,600
Loss function for Logistic Regression
You got off on the wrong track as detailed here. Just because you have a binary $Y$ it doesn't mean that you should be interested in classification. You are really interested in a probability model, so logistic regression is a good choice. Get the nomenclature right or you will confuse everyone. To the main point, the theory of statistical estimation shows that in the absence of outside information (which would make you use Bayesian logistic regression), maximum likelihood estimation is the gold standard for efficiency and bias. The log likelihood function provides the objective function. You may have confused a loss/cost/utility function with estimation optimization. Get the optimum estimates using maximum likelihood estimation or penalized maximum likelihood (or better Bayesian modeling if you have constraints or other information). The a utility function comes in when needing to make an optimum decision to minimize expected loss (maximize expected utility). But I don't think you are asking about decision analysis. So stick with the gold standard objective function - the log likelihood.
Loss function for Logistic Regression
You got off on the wrong track as detailed here. Just because you have a binary $Y$ it doesn't mean that you should be interested in classification. You are really interested in a probability model,
Loss function for Logistic Regression You got off on the wrong track as detailed here. Just because you have a binary $Y$ it doesn't mean that you should be interested in classification. You are really interested in a probability model, so logistic regression is a good choice. Get the nomenclature right or you will confuse everyone. To the main point, the theory of statistical estimation shows that in the absence of outside information (which would make you use Bayesian logistic regression), maximum likelihood estimation is the gold standard for efficiency and bias. The log likelihood function provides the objective function. You may have confused a loss/cost/utility function with estimation optimization. Get the optimum estimates using maximum likelihood estimation or penalized maximum likelihood (or better Bayesian modeling if you have constraints or other information). The a utility function comes in when needing to make an optimum decision to minimize expected loss (maximize expected utility). But I don't think you are asking about decision analysis. So stick with the gold standard objective function - the log likelihood.
Loss function for Logistic Regression You got off on the wrong track as detailed here. Just because you have a binary $Y$ it doesn't mean that you should be interested in classification. You are really interested in a probability model,