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
18,601
How can I group numerical data into naturally forming "brackets"? (e.g. income)
Take a look for Jenks Natural Break: https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization I think it's what you need, and there are implementations in many languages.
How can I group numerical data into naturally forming "brackets"? (e.g. income)
Take a look for Jenks Natural Break: https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization I think it's what you need, and there are implementations in many languages.
How can I group numerical data into naturally forming "brackets"? (e.g. income) Take a look for Jenks Natural Break: https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization I think it's what you need, and there are implementations in many languages.
How can I group numerical data into naturally forming "brackets"? (e.g. income) Take a look for Jenks Natural Break: https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization I think it's what you need, and there are implementations in many languages.
18,602
Are the degrees of freedom for Welch's test always less than the DF of the pooled test?
Yes. The Welch test uses the Satterthaite-Welch adjustment for the degrees of freedom: $$ df'=\frac{\left(\frac{s^2_1}{n_1}+\frac{s^2_2}{n_2}\right)^2}{\frac{\left(\frac{s^2_1}{n_1}\right)^2}{n_1-1}+\frac{\left(\frac{s^2_2}{n_2}\right)^2}{n_2-1}} $$ As you can see, it's rather ugly (and in fact is approximated numerically), but it necessitates that $df'<df$. Here's a reference: Howell (2002, p. 214) states that, "$df'$ is bounded by the smaller of $n_1-1$ and $n_2-1$ at one extreme and by $n_1+n_2-2~df$ at the other". Here are the 'official' references (note that the adjustment above--the one that is typically used--is derived in the second paper): Welch, B.L. (1938). "The significance of the difference between two means when the population variances are unequal". Biometrika, 29, 3/4, pp. 350–62. Satterthwaite, F.E. (1946). "An Approximate Distribution of Estimates of Variance Components". Biometrics Bulletin, 2, 6, pp. 110–114. Welch, B.L. (1947). "The generalization of "Student's" problem when several different population variances are involved". Biometrika, 34, 1/2, pp. 28–35. (Googling may yield ungated versions of these.)
Are the degrees of freedom for Welch's test always less than the DF of the pooled test?
Yes. The Welch test uses the Satterthaite-Welch adjustment for the degrees of freedom: $$ df'=\frac{\left(\frac{s^2_1}{n_1}+\frac{s^2_2}{n_2}\right)^2}{\frac{\left(\frac{s^2_1}{n_1}\right)^2}{n_1-1}
Are the degrees of freedom for Welch's test always less than the DF of the pooled test? Yes. The Welch test uses the Satterthaite-Welch adjustment for the degrees of freedom: $$ df'=\frac{\left(\frac{s^2_1}{n_1}+\frac{s^2_2}{n_2}\right)^2}{\frac{\left(\frac{s^2_1}{n_1}\right)^2}{n_1-1}+\frac{\left(\frac{s^2_2}{n_2}\right)^2}{n_2-1}} $$ As you can see, it's rather ugly (and in fact is approximated numerically), but it necessitates that $df'<df$. Here's a reference: Howell (2002, p. 214) states that, "$df'$ is bounded by the smaller of $n_1-1$ and $n_2-1$ at one extreme and by $n_1+n_2-2~df$ at the other". Here are the 'official' references (note that the adjustment above--the one that is typically used--is derived in the second paper): Welch, B.L. (1938). "The significance of the difference between two means when the population variances are unequal". Biometrika, 29, 3/4, pp. 350–62. Satterthwaite, F.E. (1946). "An Approximate Distribution of Estimates of Variance Components". Biometrics Bulletin, 2, 6, pp. 110–114. Welch, B.L. (1947). "The generalization of "Student's" problem when several different population variances are involved". Biometrika, 34, 1/2, pp. 28–35. (Googling may yield ungated versions of these.)
Are the degrees of freedom for Welch's test always less than the DF of the pooled test? Yes. The Welch test uses the Satterthaite-Welch adjustment for the degrees of freedom: $$ df'=\frac{\left(\frac{s^2_1}{n_1}+\frac{s^2_2}{n_2}\right)^2}{\frac{\left(\frac{s^2_1}{n_1}\right)^2}{n_1-1}
18,603
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
I don't think this is an "overparamaterized" model at all. I would argue that by placing a prior over the Dirichlet paramaters, you're being less committal about any particular outcome. In particular, as you probably know, for symmetric dirichlet distributions (i.e. $\alpha_1 = \alpha_2 = ... \alpha_K$) setting $\alpha<1$ gives more prior probability to sparse multinomial distributions, while $\alpha>1$ gives more prior probability to smooth multinomial distributions. In cases where one has no strong expectation for either sparse or dense multinomial distributions, placing a hyperprior over your Dirichlet distribution gives your model some added flexibility to chose between them. I originally got the idea of doing this from this paper. The hyperprior they use is slightly different than what you suggest. They sample a probability vector from a dirichlet and then scale it by a draw from an exponential (or gamma). So the model is \begin{eqnarray} \beta &\sim &Dirichlet(1)\\ \lambda& \sim &Exponential(\cdot)\\ \theta& \sim &Dirichlet(\beta\lambda) \end{eqnarray} The extra Dirichlet is simply to avoid imposing symmetry. I've also seen people use just the Gamma hyper prior for a Dirichlet in the context of hidden markov models with multinomial emission distributions, but I can't seem to find a reference. Also, it seems like I've encountered similar hypers used in topic models.
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
I don't think this is an "overparamaterized" model at all. I would argue that by placing a prior over the Dirichlet paramaters, you're being less committal about any particular outcome. In particular,
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters I don't think this is an "overparamaterized" model at all. I would argue that by placing a prior over the Dirichlet paramaters, you're being less committal about any particular outcome. In particular, as you probably know, for symmetric dirichlet distributions (i.e. $\alpha_1 = \alpha_2 = ... \alpha_K$) setting $\alpha<1$ gives more prior probability to sparse multinomial distributions, while $\alpha>1$ gives more prior probability to smooth multinomial distributions. In cases where one has no strong expectation for either sparse or dense multinomial distributions, placing a hyperprior over your Dirichlet distribution gives your model some added flexibility to chose between them. I originally got the idea of doing this from this paper. The hyperprior they use is slightly different than what you suggest. They sample a probability vector from a dirichlet and then scale it by a draw from an exponential (or gamma). So the model is \begin{eqnarray} \beta &\sim &Dirichlet(1)\\ \lambda& \sim &Exponential(\cdot)\\ \theta& \sim &Dirichlet(\beta\lambda) \end{eqnarray} The extra Dirichlet is simply to avoid imposing symmetry. I've also seen people use just the Gamma hyper prior for a Dirichlet in the context of hidden markov models with multinomial emission distributions, but I can't seem to find a reference. Also, it seems like I've encountered similar hypers used in topic models.
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters I don't think this is an "overparamaterized" model at all. I would argue that by placing a prior over the Dirichlet paramaters, you're being less committal about any particular outcome. In particular,
18,604
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
To demonstrate a solution to this hyperprior problem, I implemented an hierarchical gamma-Dirichlet-multinomial model in PyMC3. The gamma prior for the Dirichlet is specified and sampled per Ted Dunning's blog post. The model I implemented can be found at this Gist but is also described below: This is a Bayesian hierarchical (pooling) model for movie ratings. Each movie can be rated on a scale from zero to five. Each movie is rated several times. We want to find a smoothed distribution of ratings for each movie. We are going to learn a top-level prior distribution (hyperprior) on movie ratings from the data. Each movie will then have its own prior that is smoothed by this top-level prior. Another way of thinking about this is that the prior for ratings for each movie will be shrunk towards the group-level, or pooled, distribution. If a movie has an atypical rating distribution, this approach will shrink the ratings to something more in-line with what is expected. Furthermore, this learned prior can be useful to bootstrap movies with few ratings to allow them to be meaningfully compared to movies with many ratings. The model is as follows: $\gamma_{k=1...K} \sim Gamma(\alpha, \beta)$ $\theta_{m=1...M} \sim Dirichlet_M(c\gamma_1, ..., c\gamma_K)$ $z_{m=1...M,n=1...N_m} \sim Categorical_M(\theta_m)$ where: $K$ number of movie rating levels (e.g. $K = 6$ implies ratings 0, ..., 5) $M$ number of movies being rated $N_m$ number of ratings for movie $m$ $\alpha = 1 / K$ in order to make the collection of gamma r.v.s act as an exponential coefficient $\beta$ rate parameter for the exponential top-level prior $c$ concentration parameter dictating the strength of the top-level prior $\gamma_k$ top-level prior for rating level $k$ $\theta_m$ movie-level prior for rating levels (multivariate with dimension = $K$) $z_{mn}$ rating $n$ for movie $m$
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
To demonstrate a solution to this hyperprior problem, I implemented an hierarchical gamma-Dirichlet-multinomial model in PyMC3. The gamma prior for the Dirichlet is specified and sampled per Ted Dunn
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters To demonstrate a solution to this hyperprior problem, I implemented an hierarchical gamma-Dirichlet-multinomial model in PyMC3. The gamma prior for the Dirichlet is specified and sampled per Ted Dunning's blog post. The model I implemented can be found at this Gist but is also described below: This is a Bayesian hierarchical (pooling) model for movie ratings. Each movie can be rated on a scale from zero to five. Each movie is rated several times. We want to find a smoothed distribution of ratings for each movie. We are going to learn a top-level prior distribution (hyperprior) on movie ratings from the data. Each movie will then have its own prior that is smoothed by this top-level prior. Another way of thinking about this is that the prior for ratings for each movie will be shrunk towards the group-level, or pooled, distribution. If a movie has an atypical rating distribution, this approach will shrink the ratings to something more in-line with what is expected. Furthermore, this learned prior can be useful to bootstrap movies with few ratings to allow them to be meaningfully compared to movies with many ratings. The model is as follows: $\gamma_{k=1...K} \sim Gamma(\alpha, \beta)$ $\theta_{m=1...M} \sim Dirichlet_M(c\gamma_1, ..., c\gamma_K)$ $z_{m=1...M,n=1...N_m} \sim Categorical_M(\theta_m)$ where: $K$ number of movie rating levels (e.g. $K = 6$ implies ratings 0, ..., 5) $M$ number of movies being rated $N_m$ number of ratings for movie $m$ $\alpha = 1 / K$ in order to make the collection of gamma r.v.s act as an exponential coefficient $\beta$ rate parameter for the exponential top-level prior $c$ concentration parameter dictating the strength of the top-level prior $\gamma_k$ top-level prior for rating level $k$ $\theta_m$ movie-level prior for rating levels (multivariate with dimension = $K$) $z_{mn}$ rating $n$ for movie $m$
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters To demonstrate a solution to this hyperprior problem, I implemented an hierarchical gamma-Dirichlet-multinomial model in PyMC3. The gamma prior for the Dirichlet is specified and sampled per Ted Dunn
18,605
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
This is a direct Bayesian conjugate prior modeling. A natural extension from Beta-Binomial model. A good resource for this could be from the book. And Posterior is also Dirichlet and hence simulating from dirichlet will give necessary summaries
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters
This is a direct Bayesian conjugate prior modeling. A natural extension from Beta-Binomial model. A good resource for this could be from the book. And Posterior is also Dirichlet and hence simulating
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters This is a direct Bayesian conjugate prior modeling. A natural extension from Beta-Binomial model. A good resource for this could be from the book. And Posterior is also Dirichlet and hence simulating from dirichlet will give necessary summaries
Multinomial-Dirichlet model with hyperprior distribution on the concentration parameters This is a direct Bayesian conjugate prior modeling. A natural extension from Beta-Binomial model. A good resource for this could be from the book. And Posterior is also Dirichlet and hence simulating
18,606
Linear regression with repeated measures in R
What you do really depends on the goals of the analysis. I'm not certain exactly what the goals of your analysis are, but I'll go through several examples, and hopefully one of them will be applicable to your situation. Case 1: One quantitive variable measured twice Let's say that you ran a human subject study in which you had participants take a stats test twice and you wanted to find out if the average scores on the second measurement were different from the first measurement (to determine whether learning occurred). If scores test1 and test2 are stored in data frame d, You could do this entirely using the lm() function, as in: mod <- lm(test2 - test1 ~ 1, data = d) summary(mod) The test of the intercept is the test of the difference between test1 and test2. Note that you will have no delta-R^2 for the difference between test1 and test2 -- instead, your measure of effect size should be something like cohen's d. Case 2a: One quantitative variable measured twice, one dichotomous variable, measured totally between subjects Let's say that we have the same study design, but we want to know if different rates of learning occurred for men and women. So, we have one quantitative variable (test performance) that is measured twice, and one dichotomous variable, measured once. Assuming test1, test2, and gender are all contained in data frame d, We could also test this model only using lm(), as in: mod <- lm(test2 - test1 ~ gender, data = d) summary(mod) lm.sumSquares(mod) # lm.sumSquares() is located in the lmSupport package, and gives the change in R^2 due to the between-subjects part of the model Assuming gender is centered (i.e., coded, for example, male = -.5 and female = +.5), the intercept in this model is the test of the difference between test 1 and test 2, averaged across males and females. The coefficient for gender is the interaction between time and gender. To get the effect of gender, averaged across time, you would have to do: mod <- lm(rowMeans(cbind(test2, test1)) ~ gender, data = d) summary(mod) Case 2b: One quantitative variable measured twice, one quantitative variable, only measured once Let's assume that again we have one quantitative variable measured twice and one quantitative variable measured once. So, for example, let's say we had a measure of baseline interest in statistics and we wanted to determine whether people who had higher levels of baseline interest learned more from time 1 to time 2. We'd first have to center interest, as in: d$interestc <- d$interest - mean(d$interest) Assuming that test1, test2, and interestc are all in data frame d, this question could then be tested very similarly to Case 1a: mod <- lm(test2 - test1 ~ interestc, data = d) summary(mod) lm.sumSquares(mod) Once again, the intercept in this model tests whether, averaged across interest, test scores changed from time 1 to time 2. However, this interpretation only holds when interest is centered. The coefficient for interest is whether the effect of time depends on baseline interest. We could get the effect of interest, averaged across time, by averaging together test1 and test 2, as above, and testing the effect of interest on this composite variable. Case 2c: One quantitative variable measured twice, one categorical variable, only measured once Let's assume that your between-subjects variable was a category, measured only once. So, for example, let's assume that you were interested in whether people of different races (White vs Asian vs Black vs Hispanic) had different amounts of learning from time 1 to time 2. Assuming test1, test2, and race are in data frame d, you would first need to contrast code race. This could be done using planned orthogonal contrasts, dummy codes, or using effects codes, depending on specific hypotheses / questions you want to test (I recommend looking at lm.setContrasts() if you're looking for a helper function to do this). Assuming the race variable is already contrast coded, you would use lm() very similarly to the above two cases, as in: mod <- lm(test2 - test1 ~ race, data = d) summary(mod) lm.sumSquares(mod) Assuming the race contrasts are centered, the intercept in this model is, once again, the "main effect" of time. The coefficients for the race contrasts are the interactions between those contrasts and time. To obtain the omnibus effects of race, use the following code: Anova(mod, type = 3) Case 3: One quantitative variable measured 3 times (i.e., a three-level within-subjects manipulation) Let's assume that you added a third point of measurement to the design from case one. So, your participants took a stats test three times instead of twice. Here you have a couple choices, depending on whether you want an omnibus test of the differences between time points (sometimes you don't). For example, let's say that your main hypothesis is that test scores will linearly increase from time 1 to time 3. Assuming that test1, test2, and test3 are in data frame d, this hypothesis could be tested by first creating the following composite: d$lin <- d[, paste("test", sep = "", 1:3)] %*% c(-1, 0, 1) Then you would test whether an intercept only model using lin as the dependent variable has an intercept that is different from 0, as in: mod <- lm(lin ~ 1, data = d) summary(mod) This will give you your test of whether stats scores were increasing over time. You can, of course, create other types of custom difference scores, depending on your particular hypotheses. If you care about omnibus tests of significance, you need to use the Anova() function from the car package. The specific implementation is a little convoluted. Basically, you specify which variables are within-subjects and which are between-subjects using lm(). You then create the within-subjects portion of the model (i.e., specify which of test1, test2, and test3 were measured first, second, and third) and then pass that model to Anova() by creating a data frame called idata. Using my hypothetical example: mod <- lm(cbind(test1, test2, test3) ~ 1, data = d) # No between-subjects portion of the model idata <- data.frame(time = c("time1", "time2", "time3")) # Specify the within-subjects portion of the model mod.A <- Anova(mod, idata = idata, idesign = ~time, type = 3) # Gives multivariate tests. For univariate tests, add multivariate = FALSE summary(mod.A) The idesign statement tells Anova to include the time variable (composed of test1, test2, and test3) in the model. This code will give you your omnibus tests of the effects of time on test scores. Case 4: One quantitative variable measured 3 times, one between-subjects quantitative variable This case is a simple extension of Case 3. As above, if you merely care about 1 degree of freedom tests, you can simply create a custom difference score with your within-subjects variable. So, assuming that test1, test2, test3, and interest are all in data frame d, and assuming that we are interested in the linear effects of time on test scores (and how those effects of time vary with baseline interest), you would do the following: d$lin <- d[, paste("test", sep = "", 1:3)] %*% c(-1, 0, 1) Then, do the following (with mean-centered interest): mod <- lm(lin ~ interestc, data = d) summary(mod) lm.sumSquares(mod) If you want omnibus tests, do the following: mod <- lm(cbind(test1, test2, test3) ~ interest, data = d) # We now have a between-subjects portion of the model idata <- data.frame(time = c("time1", "time2", "time3")) mod.A <- Anova(mod, idata = idata, idesign = ~time * interest, type = 3) # The idesign statement assumes that we're interested in the interaction between time and interest summary(mod.A) Other cases: I will omit these for brevity, but they are simple extensions of what I've already described. Please note that the (univariate) omnibus tests of time where time has more than 2 levels all assume sphericity. This assumption becomes pretty untenable as you increase the number of levels. If you have quite a few points of measurement in your design (say, 4+) I strongly recommend you use something like multilevel modeling and move to a package that is specialized for this technique (such as nlme or lme4. Hope this helps!
Linear regression with repeated measures in R
What you do really depends on the goals of the analysis. I'm not certain exactly what the goals of your analysis are, but I'll go through several examples, and hopefully one of them will be applicabl
Linear regression with repeated measures in R What you do really depends on the goals of the analysis. I'm not certain exactly what the goals of your analysis are, but I'll go through several examples, and hopefully one of them will be applicable to your situation. Case 1: One quantitive variable measured twice Let's say that you ran a human subject study in which you had participants take a stats test twice and you wanted to find out if the average scores on the second measurement were different from the first measurement (to determine whether learning occurred). If scores test1 and test2 are stored in data frame d, You could do this entirely using the lm() function, as in: mod <- lm(test2 - test1 ~ 1, data = d) summary(mod) The test of the intercept is the test of the difference between test1 and test2. Note that you will have no delta-R^2 for the difference between test1 and test2 -- instead, your measure of effect size should be something like cohen's d. Case 2a: One quantitative variable measured twice, one dichotomous variable, measured totally between subjects Let's say that we have the same study design, but we want to know if different rates of learning occurred for men and women. So, we have one quantitative variable (test performance) that is measured twice, and one dichotomous variable, measured once. Assuming test1, test2, and gender are all contained in data frame d, We could also test this model only using lm(), as in: mod <- lm(test2 - test1 ~ gender, data = d) summary(mod) lm.sumSquares(mod) # lm.sumSquares() is located in the lmSupport package, and gives the change in R^2 due to the between-subjects part of the model Assuming gender is centered (i.e., coded, for example, male = -.5 and female = +.5), the intercept in this model is the test of the difference between test 1 and test 2, averaged across males and females. The coefficient for gender is the interaction between time and gender. To get the effect of gender, averaged across time, you would have to do: mod <- lm(rowMeans(cbind(test2, test1)) ~ gender, data = d) summary(mod) Case 2b: One quantitative variable measured twice, one quantitative variable, only measured once Let's assume that again we have one quantitative variable measured twice and one quantitative variable measured once. So, for example, let's say we had a measure of baseline interest in statistics and we wanted to determine whether people who had higher levels of baseline interest learned more from time 1 to time 2. We'd first have to center interest, as in: d$interestc <- d$interest - mean(d$interest) Assuming that test1, test2, and interestc are all in data frame d, this question could then be tested very similarly to Case 1a: mod <- lm(test2 - test1 ~ interestc, data = d) summary(mod) lm.sumSquares(mod) Once again, the intercept in this model tests whether, averaged across interest, test scores changed from time 1 to time 2. However, this interpretation only holds when interest is centered. The coefficient for interest is whether the effect of time depends on baseline interest. We could get the effect of interest, averaged across time, by averaging together test1 and test 2, as above, and testing the effect of interest on this composite variable. Case 2c: One quantitative variable measured twice, one categorical variable, only measured once Let's assume that your between-subjects variable was a category, measured only once. So, for example, let's assume that you were interested in whether people of different races (White vs Asian vs Black vs Hispanic) had different amounts of learning from time 1 to time 2. Assuming test1, test2, and race are in data frame d, you would first need to contrast code race. This could be done using planned orthogonal contrasts, dummy codes, or using effects codes, depending on specific hypotheses / questions you want to test (I recommend looking at lm.setContrasts() if you're looking for a helper function to do this). Assuming the race variable is already contrast coded, you would use lm() very similarly to the above two cases, as in: mod <- lm(test2 - test1 ~ race, data = d) summary(mod) lm.sumSquares(mod) Assuming the race contrasts are centered, the intercept in this model is, once again, the "main effect" of time. The coefficients for the race contrasts are the interactions between those contrasts and time. To obtain the omnibus effects of race, use the following code: Anova(mod, type = 3) Case 3: One quantitative variable measured 3 times (i.e., a three-level within-subjects manipulation) Let's assume that you added a third point of measurement to the design from case one. So, your participants took a stats test three times instead of twice. Here you have a couple choices, depending on whether you want an omnibus test of the differences between time points (sometimes you don't). For example, let's say that your main hypothesis is that test scores will linearly increase from time 1 to time 3. Assuming that test1, test2, and test3 are in data frame d, this hypothesis could be tested by first creating the following composite: d$lin <- d[, paste("test", sep = "", 1:3)] %*% c(-1, 0, 1) Then you would test whether an intercept only model using lin as the dependent variable has an intercept that is different from 0, as in: mod <- lm(lin ~ 1, data = d) summary(mod) This will give you your test of whether stats scores were increasing over time. You can, of course, create other types of custom difference scores, depending on your particular hypotheses. If you care about omnibus tests of significance, you need to use the Anova() function from the car package. The specific implementation is a little convoluted. Basically, you specify which variables are within-subjects and which are between-subjects using lm(). You then create the within-subjects portion of the model (i.e., specify which of test1, test2, and test3 were measured first, second, and third) and then pass that model to Anova() by creating a data frame called idata. Using my hypothetical example: mod <- lm(cbind(test1, test2, test3) ~ 1, data = d) # No between-subjects portion of the model idata <- data.frame(time = c("time1", "time2", "time3")) # Specify the within-subjects portion of the model mod.A <- Anova(mod, idata = idata, idesign = ~time, type = 3) # Gives multivariate tests. For univariate tests, add multivariate = FALSE summary(mod.A) The idesign statement tells Anova to include the time variable (composed of test1, test2, and test3) in the model. This code will give you your omnibus tests of the effects of time on test scores. Case 4: One quantitative variable measured 3 times, one between-subjects quantitative variable This case is a simple extension of Case 3. As above, if you merely care about 1 degree of freedom tests, you can simply create a custom difference score with your within-subjects variable. So, assuming that test1, test2, test3, and interest are all in data frame d, and assuming that we are interested in the linear effects of time on test scores (and how those effects of time vary with baseline interest), you would do the following: d$lin <- d[, paste("test", sep = "", 1:3)] %*% c(-1, 0, 1) Then, do the following (with mean-centered interest): mod <- lm(lin ~ interestc, data = d) summary(mod) lm.sumSquares(mod) If you want omnibus tests, do the following: mod <- lm(cbind(test1, test2, test3) ~ interest, data = d) # We now have a between-subjects portion of the model idata <- data.frame(time = c("time1", "time2", "time3")) mod.A <- Anova(mod, idata = idata, idesign = ~time * interest, type = 3) # The idesign statement assumes that we're interested in the interaction between time and interest summary(mod.A) Other cases: I will omit these for brevity, but they are simple extensions of what I've already described. Please note that the (univariate) omnibus tests of time where time has more than 2 levels all assume sphericity. This assumption becomes pretty untenable as you increase the number of levels. If you have quite a few points of measurement in your design (say, 4+) I strongly recommend you use something like multilevel modeling and move to a package that is specialized for this technique (such as nlme or lme4. Hope this helps!
Linear regression with repeated measures in R What you do really depends on the goals of the analysis. I'm not certain exactly what the goals of your analysis are, but I'll go through several examples, and hopefully one of them will be applicabl
18,607
Estimating percentages as the dependent variable in regression
If you are working with Stata have a look at the following example: http://www.ats.ucla.edu/stat/stata/faq/proportion.htm Here is a quote from this webpage: "How does one do regression when the dependent variable is a proportion? Proportion data has values that fall between zero and one. Naturally, it would be nice to have the predicted values also fall between zero and one. One way to accomplish this is to use a generalized linear model (glm) with a logit link and the binomial family. We will include the robust option in the glm model to obtain robust standard errors which will be particularly useful if we have misspecified the distribution family."
Estimating percentages as the dependent variable in regression
If you are working with Stata have a look at the following example: http://www.ats.ucla.edu/stat/stata/faq/proportion.htm Here is a quote from this webpage: "How does one do regression when the depen
Estimating percentages as the dependent variable in regression If you are working with Stata have a look at the following example: http://www.ats.ucla.edu/stat/stata/faq/proportion.htm Here is a quote from this webpage: "How does one do regression when the dependent variable is a proportion? Proportion data has values that fall between zero and one. Naturally, it would be nice to have the predicted values also fall between zero and one. One way to accomplish this is to use a generalized linear model (glm) with a logit link and the binomial family. We will include the robust option in the glm model to obtain robust standard errors which will be particularly useful if we have misspecified the distribution family."
Estimating percentages as the dependent variable in regression If you are working with Stata have a look at the following example: http://www.ats.ucla.edu/stat/stata/faq/proportion.htm Here is a quote from this webpage: "How does one do regression when the depen
18,608
Estimating percentages as the dependent variable in regression
Synopsis Regression results may have some limited value when carefully interpreted. Unavoidable forms of variation will cause coefficient estimates to shrink substantially towards zero. A better model is needed that handles variation in a more appropriate way. (A maximum likelihood model can be constructed but may be impracticable due to the computation needed, which involves numerical evaluation of multidimensional integrals. The numbers of dimensions are equal to the numbers of students enrolled in the classes.) Introduction As a narrative to inform our intuition, imagine that these 38 exams were given in 38 separate courses during one semester at a small school with enrollment of 200 college students. In a realistic situation those students will have varying abilities and experiences. As surrogate measures of these abilities and experiences we might take, say, scores on the SAT math and verbal tests and year in college (1 through 4). Typically, students will enroll in courses according to their abilities and interests. Freshmen take introductory courses and introductory courses are populated primarily by freshmen. Upperclassmen and talented freshmen and sophomores take the advanced and graduate-level courses. This selection partially stratifies the students so that the innate abilities of students within any class are typically more homogeneous than the spread of abilities throughout the school. Thus, the most capable students may find themselves scoring near the bottom of the difficult, advanced classes in which they enroll, while the least capable students may score near the top of the easy introductory classes they take. This may confound a direct attempt to relate the exam ranks directly to attributes of students and the classes. Analysis Index the students with $i$ and let the attributes of student $i$ be given by the vector $\mathbf{x}_i$. Index the classes with $j$ and let the attributes of class $j$ be given by the vector $\mathbf{z}_j$. The set of students enrolled in class $j$ is $A_j$. Assume the "strength" of each student $s_i$ is a function of their attributes plus some random value, which may as well have zero mean: $$s_i = f(\mathbf{x}_i, \beta) + \varepsilon_i.$$ We model the exam in class $j$ by adding independent random values to the strength of each student enrolled in the class and converting those to ranks. Whence, if student $i$ is enrolled in class $j$, their relative rank $r_{i,j}$ is determined by their position in the sorted array of values $$\left(s_k + \delta_{k,j}, k \in A_j\right).$$ This position $r_{i,j}$ is divided by one more than the total class enrolment to give the dependent variable, the percentage rank: $$p_{i,j} = \frac{r_{i,j}}{1 + |A_j|}.$$ I claim that the regression results depend (quite a bit) on the sizes and structure of the random (unobserved) values $\varepsilon_i$ and $\delta_{i,j}$. The results also depend on precisely how students are enrolled in classes. This should be intuitively obvious, but what is not so obvious--and appears difficult to analyze theoretically--is how and how much the unobserved values and the class structures affect the regression. Simulation Without too much effort we can simulate this situation to create and analyze some sample data. One advantage of the simulation is that it can incorporate the true strengths of the students, which in reality are not observable. Another is that we can vary the typical sizes of the unobserved values as well as the class assignments. This provides a "sandbox" for assessing proposed analytical methods such as regression. To get started, let's set the random number generator for reproducible results and specify the size of the problem. I use R because it's available to anyone. set.seed(17) n.pop <- 200 # Number of students n.classes <- 38 # Number of classes courseload <- 4.5 # Expected number of classes per student To provide realism, create n.classes classes of varying difficulties on two scales (mathematical and verbal, with a negative correlation), conducted at varying academic levels (ranging from 1=introductory to 7=research), and with variable ease. (In an "easy" class, differences among the amounts of student learning may be large and/or the exam may provide little discrimination among the students. This is modeled by random terms $\delta_{i,j}$ that, for class $j$ tend to be large. The exam results will then be almost unpredictable from the student strength data. When the class is not "easy," these random terms are negligibly small and the student strengths can perfectly determine the exam rankings.) classes <- data.frame(cbind( math <- runif(n.classes), rbeta(n.classes, shape1=(verbal <- (1-math)*5), shape2=5-verbal), runif(n.classes, min=0, max=7), rgamma(n.classes, 10, 10))) rm(math, verbal) colnames(classes) <- c("math.dif", "verbal.dif", "level", "ease") classes <- classes[order(classes$math.dif + classes$verbal.dif + classes$level), ] row.names(classes) <- 1:n.classes plot(classes, main="Classes") The students are spread among the four years and endowed with random values of their attributes. There are no correlations among any of these attributes: students <- data.frame(cbind( as.factor(ceiling(runif(n.pop, max=4))), sapply(rnorm(n.pop, mean=60, sd=10), function(x) 10*median(c(20, 80, floor(x)))), sapply(rnorm(n.pop, mean=55, sd=10), function(x) 10*median(c(00, 80, floor(x)))), rnorm(n.pop) )) colnames(students) <- c("year", "math", "verbal", "ability") plot(students, main="Students") The model is that each student has an inherent "strength" determined partly by their attributes and partly by their "ability," which is the $\varepsilon_i$ value. The strength coefficients beta, which determine the strength in terms of other attributes, are what the subsequent data analysis will seek to estimate. If you want to play with this simulation, do so by changing beta. The following is an interesting and realistic set of coefficients reflecting continued student learning throughout college (with a large amount between years 2 and 3); where 100 points on each part of the SAT are worth about one year of school; and where about half the variation is due to the "ability" values not captured by SAT scores or year in school. beta <- list(year.1=0, year.2=1, year.3=3, year.4=4, math=1/100, verbal=1/100, ability=2, sigma=0.01) students$strength <- (students$year==1)*beta$year.1 + (students$year==2)*beta$year.2 + (students$year==3)*beta$year.3 + (students$year==4)*beta$year.4 + students$math*beta$math + students$verbal*beta$verbal + students$ability*beta$ability students <- students[order(students$strength), ] row.names(students) <- 1:n.pop (Bear in mind that students$ability is unobservable: it is an apparently random deviation between the strength predicted from the other observable attributes and the actual strength on exams. To remove this random effect, set beta$ability to zero. beta$sigma will multiply the ease values: it's basically the standard deviation of the $\delta_{i,j}$ relative to the range of strengths of students in a given course. Values around $.01$ to $.2$ or so seem reasonable to me.) Let the students pick courses to match their abilities. Once they do that, we can compute the class sizes and stash those with the classes dataframe for later use. The value of spread in the assignments <-... line determines how closely the students are sectioned into classes by ability. A value close to $0$ essentially pairs the weakest students with the easiest courses. A value close to the number of classes spreads the students out a little more. Much larger values than that start to get unrealistic, because they tend to put weaker students into the most difficult courses. pick.classes <- function(i, k, spread) { # i is student strength rank # k is number to pick p <- pmin(0.05, diff(pbeta(0:n.classes/n.classes, i/spread, (1+n.pop-i)/spread))) sample(1:n.classes, k, prob=p) } students$n.classes <- floor(1/2 + 2 * rbeta(n.pop,10,10) * courseload) assignments <- lapply(1:n.pop, function(i) pick.classes(i, students$n.classes[i], spread=1)) enrolment <- function(k) length(seq(1, n.pop)[sapply(assignments, function(x) !is.na(match(k, x)))]) classes$size <- sapply(1:n.classes, enrolment) classes$variation <- by(data, data$Class, function(x) diff(range(x$strength))) (As an example of what this step has accomplished, see the figure further below.) Now apply the model: the abilities of the students in each class are independently varied--more for easy exams, less for hard (discriminating) exams--to determine their exam scores. These are summarized as ranks and "pranks", which are rank percents. The pranks for a class of $n$ students range from $1/(n+1)$ through $n/(n+1)$ in increments of $1/(n+1)$. This will later make it possible to apply transformations such as the logistic function (which is undefined when applied to values of $0$ or $1$). exam.do <- function(k) { s <- seq(1, n.pop)[sapply(assignments, function(x) !is.na(match(k, x)))] e <- classes$ease[k] rv <- cbind(rep(k, length(s)), s, order(rnorm(length(s), students$strength[s], sd=e*beta$sigma*classes$variation[k]))) rv <- cbind(rv, rv[,3] / (length(s)+1)) dimnames(rv) <- list(NULL, c("Class", "Student", "Rank", "Prank")) rv } data.raw <- do.call(rbind, sapply(1:n.classes, exam.do)) To these raw data we attach the student and class attributes to create a dataset suitable for analysis: data <- merge(data.raw, classes, by.x="Class", by.y="row.names") data <- merge(data, students, by.x="Student", by.y="row.names") Let's orient ourselves by inspecting a random sample of the data: > data[sort(sample(1:dim(data)[1], 5)),] Row Student Class Rank Prank math.dif verbal.dif level ease Size year math verbal ability strength n.classes 118 28 1 22 0.957 0.77997 6.95e-02 0.0523 1.032 22 2 590 380 0.576 16.9 4 248 55 5 24 0.889 0.96838 1.32e-07 0.5217 0.956 26 3 460 520 -2.163 19.0 5 278 62 6 22 0.917 0.15505 9.54e-01 0.4112 0.497 23 2 640 510 -0.673 19.7 4 400 89 10 16 0.800 0.00227 1.00e+00 1.3880 0.579 19 1 800 350 0.598 21.6 5 806 182 35 18 0.692 0.88116 5.44e-02 6.1747 0.800 25 4 610 580 0.776 30.7 4 Record 118, for example, says that student #28 enrolled in class #1 and scored 22nd (from the bottom) on the exam for a percentage rank of 0.957. This class's overall level of difficulty was 0.0523 (very easy). A total of 22 students were enrolled. This student is a sophomore (year 2) with 590 math, 380 verbal SAT scores. Their overall inherent academic strength is 16.9. They were enrolled in four classes at the time. This dataset comports with the description in the question. For instance, the percentage ranks indeed are almost uniform (as they must be for any complete dataset, because the percentage ranks for a single class have a discrete uniform distribution). Remember, by virtue of the coefficients in beta, this model has assumed a strong connection between examination scores and the variables shown in this dataset. But what does regression show? Let's regress the logistic of the percentage rank against all the observable student characteristics that might be related to their abilities, as well as the indicators of class difficulty: logistic <- function(p) log(p / (1-p)) fit <- lm(logistic(Prank) ~ as.factor(year) + math + verbal + level, data=data) summary(fit) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.577788 0.421579 -6.11 1.5e-09 *** as.factor(year)2 0.467846 0.150670 3.11 0.0020 ** as.factor(year)3 0.984671 0.164614 5.98 3.2e-09 *** as.factor(year)4 1.109897 0.171704 6.46 1.7e-10 *** math 0.002599 0.000538 4.83 1.6e-06 *** verbal 0.002130 0.000514 4.14 3.8e-05 *** level -0.208495 0.036365 -5.73 1.4e-08 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.48 on 883 degrees of freedom Multiple R-squared: 0.0661, Adjusted R-squared: 0.0598 F-statistic: 10.4 on 6 and 883 DF, p-value: 3.51e-11 Diagnostic plots (plot(fit)) look fastastic: the residuals are homoscedastic and beautifully normal (albeit slightly short tailed, which is no problem); no outliers; and no untoward influence in any observation. As you can see, everything is highly significant, although the small R-squared might be disappointing. The coefficients all have the roughly the correct signs and relative sizes. If we were to multiply them by $3.5$, they would equal $(-9, 1.6, 3.4, 3.9, 0.009, 0.007, -0.7)$. The original betas were $(*, 1, 3, 4, 0.010, 0.010, *)$ (where $*$ stands for a coefficient that was not explicitly specified). Notice the high significance of level, which is an attribute of the classes, not of the students. Its size is pretty large: the class levels range from near $0$ to near $7$, so multiplying this range by the estimated coefficient of level show it has the same size of effect as any of the other terms. Its negative sign reflects a tendency for students to do a little bit worse in the more challenging classes. It is very interesting to see this behavior emerge from the model, because the level was never explicitly involved in determining the examination outcomes: it only affected how the students chose their classes. (By the way, using the percentage ranks untransformed in the regression does not qualitatively change the results reported below.) Let's vary things a bit. Instead of setting spread to $1$, we were to use $38$, thereby causing a wider (more realistic) distribution of students throughout the classes. Rerunning everything from the top gives these results: Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -4.902006 0.349924 -14.01 < 2e-16 *** as.factor(year)2 0.605444 0.130355 4.64 3.9e-06 *** as.factor(year)3 1.707590 0.134649 12.68 < 2e-16 *** as.factor(year)4 1.926272 0.136595 14.10 < 2e-16 *** math 0.004667 0.000448 10.41 < 2e-16 *** verbal 0.004019 0.000434 9.25 < 2e-16 *** level -0.299475 0.026415 -11.34 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.3 on 883 degrees of freedom Multiple R-squared: 0.282, Adjusted R-squared: 0.277 F-statistic: 57.9 on 6 and 883 DF, p-value: <2e-16 (In this scatterplot of class assignments, with spread set to $38$, students are sorted by increasing strength and classes are sorted by increasing level. When spread originally was set to 1, the assignment plot fell in a tight diagonal band. Weaker students tend to take easier classes and stronger students take harder classes, but there are plenty of exceptions.) This time the R-squared is much improved (although still not great). However, all the coefficients have increased by 20 - 100%. This table compares them along with some additional simulations: Simulation Intercept Year.2 Year.3 Year.4 Math Verbal Level R^2 Beta * 1.0 3.0 4.0 .010 .010 * * Spread=1 -2.6 0.5 1.0 1.1 .003 .002 -0.21 7% Spread=38 -4.9 0.6 1.7 1.9 .005 .004 -0.30 25% Ability=1 -8.3 0.9 2.6 3.3 .008 .008 -0.63 58% No error -11.2 1.1 3.3 4.4 .011 .011 -0.09 88% Keeping spread at $38$ and changing ability from $2$ to $1$ (which is a very optimistic assessment of how predictable the student strengths are) yielded the penultimate line. Now the estimates (for student year and student SAT scores) are getting reasonably close to the true values. Finally, setting both ability and sigma to $0$, to remove the error terms $\varepsilon_i$ and $\delta_{i,j}$ altogether, gives a high R squared and produces estimates close to the correct values. (It is noteworthy that the coefficient for level then decreases by an order of magnitude.) This quick analysis shows that regression, at least as performed here, is going to confound unavoidable forms of variation with the coefficients. Furthermore, the coefficients also depend (to some extent) on how students are distributed among classes. This can partially be accommodated by including class attributes among the independent variables in the regression, as done here, but even so the effect of student distribution does not disappear. Any lack of predictability of true student performance, and any variation in student learning and actual performance on examinations, apparently cause the coefficient estimates to shrink towards zero. They appear to do so uniformly, suggesting that the relative coefficients may still be meaningful.
Estimating percentages as the dependent variable in regression
Synopsis Regression results may have some limited value when carefully interpreted. Unavoidable forms of variation will cause coefficient estimates to shrink substantially towards zero. A better model
Estimating percentages as the dependent variable in regression Synopsis Regression results may have some limited value when carefully interpreted. Unavoidable forms of variation will cause coefficient estimates to shrink substantially towards zero. A better model is needed that handles variation in a more appropriate way. (A maximum likelihood model can be constructed but may be impracticable due to the computation needed, which involves numerical evaluation of multidimensional integrals. The numbers of dimensions are equal to the numbers of students enrolled in the classes.) Introduction As a narrative to inform our intuition, imagine that these 38 exams were given in 38 separate courses during one semester at a small school with enrollment of 200 college students. In a realistic situation those students will have varying abilities and experiences. As surrogate measures of these abilities and experiences we might take, say, scores on the SAT math and verbal tests and year in college (1 through 4). Typically, students will enroll in courses according to their abilities and interests. Freshmen take introductory courses and introductory courses are populated primarily by freshmen. Upperclassmen and talented freshmen and sophomores take the advanced and graduate-level courses. This selection partially stratifies the students so that the innate abilities of students within any class are typically more homogeneous than the spread of abilities throughout the school. Thus, the most capable students may find themselves scoring near the bottom of the difficult, advanced classes in which they enroll, while the least capable students may score near the top of the easy introductory classes they take. This may confound a direct attempt to relate the exam ranks directly to attributes of students and the classes. Analysis Index the students with $i$ and let the attributes of student $i$ be given by the vector $\mathbf{x}_i$. Index the classes with $j$ and let the attributes of class $j$ be given by the vector $\mathbf{z}_j$. The set of students enrolled in class $j$ is $A_j$. Assume the "strength" of each student $s_i$ is a function of their attributes plus some random value, which may as well have zero mean: $$s_i = f(\mathbf{x}_i, \beta) + \varepsilon_i.$$ We model the exam in class $j$ by adding independent random values to the strength of each student enrolled in the class and converting those to ranks. Whence, if student $i$ is enrolled in class $j$, their relative rank $r_{i,j}$ is determined by their position in the sorted array of values $$\left(s_k + \delta_{k,j}, k \in A_j\right).$$ This position $r_{i,j}$ is divided by one more than the total class enrolment to give the dependent variable, the percentage rank: $$p_{i,j} = \frac{r_{i,j}}{1 + |A_j|}.$$ I claim that the regression results depend (quite a bit) on the sizes and structure of the random (unobserved) values $\varepsilon_i$ and $\delta_{i,j}$. The results also depend on precisely how students are enrolled in classes. This should be intuitively obvious, but what is not so obvious--and appears difficult to analyze theoretically--is how and how much the unobserved values and the class structures affect the regression. Simulation Without too much effort we can simulate this situation to create and analyze some sample data. One advantage of the simulation is that it can incorporate the true strengths of the students, which in reality are not observable. Another is that we can vary the typical sizes of the unobserved values as well as the class assignments. This provides a "sandbox" for assessing proposed analytical methods such as regression. To get started, let's set the random number generator for reproducible results and specify the size of the problem. I use R because it's available to anyone. set.seed(17) n.pop <- 200 # Number of students n.classes <- 38 # Number of classes courseload <- 4.5 # Expected number of classes per student To provide realism, create n.classes classes of varying difficulties on two scales (mathematical and verbal, with a negative correlation), conducted at varying academic levels (ranging from 1=introductory to 7=research), and with variable ease. (In an "easy" class, differences among the amounts of student learning may be large and/or the exam may provide little discrimination among the students. This is modeled by random terms $\delta_{i,j}$ that, for class $j$ tend to be large. The exam results will then be almost unpredictable from the student strength data. When the class is not "easy," these random terms are negligibly small and the student strengths can perfectly determine the exam rankings.) classes <- data.frame(cbind( math <- runif(n.classes), rbeta(n.classes, shape1=(verbal <- (1-math)*5), shape2=5-verbal), runif(n.classes, min=0, max=7), rgamma(n.classes, 10, 10))) rm(math, verbal) colnames(classes) <- c("math.dif", "verbal.dif", "level", "ease") classes <- classes[order(classes$math.dif + classes$verbal.dif + classes$level), ] row.names(classes) <- 1:n.classes plot(classes, main="Classes") The students are spread among the four years and endowed with random values of their attributes. There are no correlations among any of these attributes: students <- data.frame(cbind( as.factor(ceiling(runif(n.pop, max=4))), sapply(rnorm(n.pop, mean=60, sd=10), function(x) 10*median(c(20, 80, floor(x)))), sapply(rnorm(n.pop, mean=55, sd=10), function(x) 10*median(c(00, 80, floor(x)))), rnorm(n.pop) )) colnames(students) <- c("year", "math", "verbal", "ability") plot(students, main="Students") The model is that each student has an inherent "strength" determined partly by their attributes and partly by their "ability," which is the $\varepsilon_i$ value. The strength coefficients beta, which determine the strength in terms of other attributes, are what the subsequent data analysis will seek to estimate. If you want to play with this simulation, do so by changing beta. The following is an interesting and realistic set of coefficients reflecting continued student learning throughout college (with a large amount between years 2 and 3); where 100 points on each part of the SAT are worth about one year of school; and where about half the variation is due to the "ability" values not captured by SAT scores or year in school. beta <- list(year.1=0, year.2=1, year.3=3, year.4=4, math=1/100, verbal=1/100, ability=2, sigma=0.01) students$strength <- (students$year==1)*beta$year.1 + (students$year==2)*beta$year.2 + (students$year==3)*beta$year.3 + (students$year==4)*beta$year.4 + students$math*beta$math + students$verbal*beta$verbal + students$ability*beta$ability students <- students[order(students$strength), ] row.names(students) <- 1:n.pop (Bear in mind that students$ability is unobservable: it is an apparently random deviation between the strength predicted from the other observable attributes and the actual strength on exams. To remove this random effect, set beta$ability to zero. beta$sigma will multiply the ease values: it's basically the standard deviation of the $\delta_{i,j}$ relative to the range of strengths of students in a given course. Values around $.01$ to $.2$ or so seem reasonable to me.) Let the students pick courses to match their abilities. Once they do that, we can compute the class sizes and stash those with the classes dataframe for later use. The value of spread in the assignments <-... line determines how closely the students are sectioned into classes by ability. A value close to $0$ essentially pairs the weakest students with the easiest courses. A value close to the number of classes spreads the students out a little more. Much larger values than that start to get unrealistic, because they tend to put weaker students into the most difficult courses. pick.classes <- function(i, k, spread) { # i is student strength rank # k is number to pick p <- pmin(0.05, diff(pbeta(0:n.classes/n.classes, i/spread, (1+n.pop-i)/spread))) sample(1:n.classes, k, prob=p) } students$n.classes <- floor(1/2 + 2 * rbeta(n.pop,10,10) * courseload) assignments <- lapply(1:n.pop, function(i) pick.classes(i, students$n.classes[i], spread=1)) enrolment <- function(k) length(seq(1, n.pop)[sapply(assignments, function(x) !is.na(match(k, x)))]) classes$size <- sapply(1:n.classes, enrolment) classes$variation <- by(data, data$Class, function(x) diff(range(x$strength))) (As an example of what this step has accomplished, see the figure further below.) Now apply the model: the abilities of the students in each class are independently varied--more for easy exams, less for hard (discriminating) exams--to determine their exam scores. These are summarized as ranks and "pranks", which are rank percents. The pranks for a class of $n$ students range from $1/(n+1)$ through $n/(n+1)$ in increments of $1/(n+1)$. This will later make it possible to apply transformations such as the logistic function (which is undefined when applied to values of $0$ or $1$). exam.do <- function(k) { s <- seq(1, n.pop)[sapply(assignments, function(x) !is.na(match(k, x)))] e <- classes$ease[k] rv <- cbind(rep(k, length(s)), s, order(rnorm(length(s), students$strength[s], sd=e*beta$sigma*classes$variation[k]))) rv <- cbind(rv, rv[,3] / (length(s)+1)) dimnames(rv) <- list(NULL, c("Class", "Student", "Rank", "Prank")) rv } data.raw <- do.call(rbind, sapply(1:n.classes, exam.do)) To these raw data we attach the student and class attributes to create a dataset suitable for analysis: data <- merge(data.raw, classes, by.x="Class", by.y="row.names") data <- merge(data, students, by.x="Student", by.y="row.names") Let's orient ourselves by inspecting a random sample of the data: > data[sort(sample(1:dim(data)[1], 5)),] Row Student Class Rank Prank math.dif verbal.dif level ease Size year math verbal ability strength n.classes 118 28 1 22 0.957 0.77997 6.95e-02 0.0523 1.032 22 2 590 380 0.576 16.9 4 248 55 5 24 0.889 0.96838 1.32e-07 0.5217 0.956 26 3 460 520 -2.163 19.0 5 278 62 6 22 0.917 0.15505 9.54e-01 0.4112 0.497 23 2 640 510 -0.673 19.7 4 400 89 10 16 0.800 0.00227 1.00e+00 1.3880 0.579 19 1 800 350 0.598 21.6 5 806 182 35 18 0.692 0.88116 5.44e-02 6.1747 0.800 25 4 610 580 0.776 30.7 4 Record 118, for example, says that student #28 enrolled in class #1 and scored 22nd (from the bottom) on the exam for a percentage rank of 0.957. This class's overall level of difficulty was 0.0523 (very easy). A total of 22 students were enrolled. This student is a sophomore (year 2) with 590 math, 380 verbal SAT scores. Their overall inherent academic strength is 16.9. They were enrolled in four classes at the time. This dataset comports with the description in the question. For instance, the percentage ranks indeed are almost uniform (as they must be for any complete dataset, because the percentage ranks for a single class have a discrete uniform distribution). Remember, by virtue of the coefficients in beta, this model has assumed a strong connection between examination scores and the variables shown in this dataset. But what does regression show? Let's regress the logistic of the percentage rank against all the observable student characteristics that might be related to their abilities, as well as the indicators of class difficulty: logistic <- function(p) log(p / (1-p)) fit <- lm(logistic(Prank) ~ as.factor(year) + math + verbal + level, data=data) summary(fit) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.577788 0.421579 -6.11 1.5e-09 *** as.factor(year)2 0.467846 0.150670 3.11 0.0020 ** as.factor(year)3 0.984671 0.164614 5.98 3.2e-09 *** as.factor(year)4 1.109897 0.171704 6.46 1.7e-10 *** math 0.002599 0.000538 4.83 1.6e-06 *** verbal 0.002130 0.000514 4.14 3.8e-05 *** level -0.208495 0.036365 -5.73 1.4e-08 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.48 on 883 degrees of freedom Multiple R-squared: 0.0661, Adjusted R-squared: 0.0598 F-statistic: 10.4 on 6 and 883 DF, p-value: 3.51e-11 Diagnostic plots (plot(fit)) look fastastic: the residuals are homoscedastic and beautifully normal (albeit slightly short tailed, which is no problem); no outliers; and no untoward influence in any observation. As you can see, everything is highly significant, although the small R-squared might be disappointing. The coefficients all have the roughly the correct signs and relative sizes. If we were to multiply them by $3.5$, they would equal $(-9, 1.6, 3.4, 3.9, 0.009, 0.007, -0.7)$. The original betas were $(*, 1, 3, 4, 0.010, 0.010, *)$ (where $*$ stands for a coefficient that was not explicitly specified). Notice the high significance of level, which is an attribute of the classes, not of the students. Its size is pretty large: the class levels range from near $0$ to near $7$, so multiplying this range by the estimated coefficient of level show it has the same size of effect as any of the other terms. Its negative sign reflects a tendency for students to do a little bit worse in the more challenging classes. It is very interesting to see this behavior emerge from the model, because the level was never explicitly involved in determining the examination outcomes: it only affected how the students chose their classes. (By the way, using the percentage ranks untransformed in the regression does not qualitatively change the results reported below.) Let's vary things a bit. Instead of setting spread to $1$, we were to use $38$, thereby causing a wider (more realistic) distribution of students throughout the classes. Rerunning everything from the top gives these results: Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -4.902006 0.349924 -14.01 < 2e-16 *** as.factor(year)2 0.605444 0.130355 4.64 3.9e-06 *** as.factor(year)3 1.707590 0.134649 12.68 < 2e-16 *** as.factor(year)4 1.926272 0.136595 14.10 < 2e-16 *** math 0.004667 0.000448 10.41 < 2e-16 *** verbal 0.004019 0.000434 9.25 < 2e-16 *** level -0.299475 0.026415 -11.34 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.3 on 883 degrees of freedom Multiple R-squared: 0.282, Adjusted R-squared: 0.277 F-statistic: 57.9 on 6 and 883 DF, p-value: <2e-16 (In this scatterplot of class assignments, with spread set to $38$, students are sorted by increasing strength and classes are sorted by increasing level. When spread originally was set to 1, the assignment plot fell in a tight diagonal band. Weaker students tend to take easier classes and stronger students take harder classes, but there are plenty of exceptions.) This time the R-squared is much improved (although still not great). However, all the coefficients have increased by 20 - 100%. This table compares them along with some additional simulations: Simulation Intercept Year.2 Year.3 Year.4 Math Verbal Level R^2 Beta * 1.0 3.0 4.0 .010 .010 * * Spread=1 -2.6 0.5 1.0 1.1 .003 .002 -0.21 7% Spread=38 -4.9 0.6 1.7 1.9 .005 .004 -0.30 25% Ability=1 -8.3 0.9 2.6 3.3 .008 .008 -0.63 58% No error -11.2 1.1 3.3 4.4 .011 .011 -0.09 88% Keeping spread at $38$ and changing ability from $2$ to $1$ (which is a very optimistic assessment of how predictable the student strengths are) yielded the penultimate line. Now the estimates (for student year and student SAT scores) are getting reasonably close to the true values. Finally, setting both ability and sigma to $0$, to remove the error terms $\varepsilon_i$ and $\delta_{i,j}$ altogether, gives a high R squared and produces estimates close to the correct values. (It is noteworthy that the coefficient for level then decreases by an order of magnitude.) This quick analysis shows that regression, at least as performed here, is going to confound unavoidable forms of variation with the coefficients. Furthermore, the coefficients also depend (to some extent) on how students are distributed among classes. This can partially be accommodated by including class attributes among the independent variables in the regression, as done here, but even so the effect of student distribution does not disappear. Any lack of predictability of true student performance, and any variation in student learning and actual performance on examinations, apparently cause the coefficient estimates to shrink towards zero. They appear to do so uniformly, suggesting that the relative coefficients may still be meaningful.
Estimating percentages as the dependent variable in regression Synopsis Regression results may have some limited value when carefully interpreted. Unavoidable forms of variation will cause coefficient estimates to shrink substantially towards zero. A better model
18,609
Estimating percentages as the dependent variable in regression
The measure @user13203 proposes may be considered as a continous bounded underperformance score, the lower the better the performance: $y_{ij} $ i-th student underperformance at j-th exam. Using a logit linearizing transformation where $\mu_{ij}$ may depend on observable student or exams characteristics : $\ln(y_{ij}/(1-y_{ij})) = \mu_{ij} + e_{ij} + v_i $ student's unobserved skills are modeled through the random component $v_i$ while $e_{ij}$ models other non systematic unobservables. Correlation between responses (examinations) may be addresed by assming a general covariance structure for $e_{ij}$. Why not a White (or sandwich/robust) variance structure ? Moreover, some of the responses correlation can be accounted within the $\mu_{ij}$ (conditional dependence). (This is just an idea from my biased experience, comments and critics are more than welcome.) Unobservable abilities are likely to be correlated with students or exams observables attributes within $\mu_{ij}$. This assumptions makes this model a RE with correlated error components, that can be estimated by ML or a two stage estimator: first stage: a within (or analog) transformation that eliminates $v_i$. Second stage: OLS on the transformed model.
Estimating percentages as the dependent variable in regression
The measure @user13203 proposes may be considered as a continous bounded underperformance score, the lower the better the performance: $y_{ij} $ i-th student underperformance at j-th exam. Using a log
Estimating percentages as the dependent variable in regression The measure @user13203 proposes may be considered as a continous bounded underperformance score, the lower the better the performance: $y_{ij} $ i-th student underperformance at j-th exam. Using a logit linearizing transformation where $\mu_{ij}$ may depend on observable student or exams characteristics : $\ln(y_{ij}/(1-y_{ij})) = \mu_{ij} + e_{ij} + v_i $ student's unobserved skills are modeled through the random component $v_i$ while $e_{ij}$ models other non systematic unobservables. Correlation between responses (examinations) may be addresed by assming a general covariance structure for $e_{ij}$. Why not a White (or sandwich/robust) variance structure ? Moreover, some of the responses correlation can be accounted within the $\mu_{ij}$ (conditional dependence). (This is just an idea from my biased experience, comments and critics are more than welcome.) Unobservable abilities are likely to be correlated with students or exams observables attributes within $\mu_{ij}$. This assumptions makes this model a RE with correlated error components, that can be estimated by ML or a two stage estimator: first stage: a within (or analog) transformation that eliminates $v_i$. Second stage: OLS on the transformed model.
Estimating percentages as the dependent variable in regression The measure @user13203 proposes may be considered as a continous bounded underperformance score, the lower the better the performance: $y_{ij} $ i-th student underperformance at j-th exam. Using a log
18,610
Estimating percentages as the dependent variable in regression
You might want to try logistic regression. The logit transform $\ln(\frac{p}{1-p})$ will spread your response variable out over the real line so you won't get absurd predicted rank percentages like -3% or +110%.
Estimating percentages as the dependent variable in regression
You might want to try logistic regression. The logit transform $\ln(\frac{p}{1-p})$ will spread your response variable out over the real line so you won't get absurd predicted rank percentages like -
Estimating percentages as the dependent variable in regression You might want to try logistic regression. The logit transform $\ln(\frac{p}{1-p})$ will spread your response variable out over the real line so you won't get absurd predicted rank percentages like -3% or +110%.
Estimating percentages as the dependent variable in regression You might want to try logistic regression. The logit transform $\ln(\frac{p}{1-p})$ will spread your response variable out over the real line so you won't get absurd predicted rank percentages like -
18,611
Estimating percentages as the dependent variable in regression
A perfect model in this case will map the inputs (whatever covariates you have) to the outputs (the rank of the student in the class). Another way to think of this is by mapping first to the scores, and then mapping those scores to the rank. I'm going to ignore error for now. test score: $y = \sum \beta x$ rank: $ r = R(y)$ In which $R$ is the ranking function. The problem is that $R$ is a non-linear function that depends entirely on the data itself. If we assume that we have an infinite amount of data, then we know the complete distribution of $y$, and $R(y)$ is essentially the cumulative density function. It tells you what percent of people scored worse than you on the test, the area to the left of your score. This appears to be quite similar to the functional form of the generalized linear model. I think this is why the logistic regression approach was proposed by @Mike Anderson. If your exam scores were logistically distributed, then the link function to use would be the logit (its inverse is the cumulative density function we care about). Similarly, if the scores were normally distributed, the probit function would be the link function. For your regression, the only way to estimate ranks is to say "given that my data are distributed as X, this point is in the 34th percentile". Otherwise, how do you know what a two point increase in your test score translates to in terms of rank? The caveat is that you have to estimate that distribution in order to choose your link function (certain functional forms will make your life a lot easier). Furthermore, this model isn't going to say "you were the 6th best out of a class of 38", rather "if the test scores were distributed how we think they are, your score would put you in the 15th percentile."
Estimating percentages as the dependent variable in regression
A perfect model in this case will map the inputs (whatever covariates you have) to the outputs (the rank of the student in the class). Another way to think of this is by mapping first to the scores,
Estimating percentages as the dependent variable in regression A perfect model in this case will map the inputs (whatever covariates you have) to the outputs (the rank of the student in the class). Another way to think of this is by mapping first to the scores, and then mapping those scores to the rank. I'm going to ignore error for now. test score: $y = \sum \beta x$ rank: $ r = R(y)$ In which $R$ is the ranking function. The problem is that $R$ is a non-linear function that depends entirely on the data itself. If we assume that we have an infinite amount of data, then we know the complete distribution of $y$, and $R(y)$ is essentially the cumulative density function. It tells you what percent of people scored worse than you on the test, the area to the left of your score. This appears to be quite similar to the functional form of the generalized linear model. I think this is why the logistic regression approach was proposed by @Mike Anderson. If your exam scores were logistically distributed, then the link function to use would be the logit (its inverse is the cumulative density function we care about). Similarly, if the scores were normally distributed, the probit function would be the link function. For your regression, the only way to estimate ranks is to say "given that my data are distributed as X, this point is in the 34th percentile". Otherwise, how do you know what a two point increase in your test score translates to in terms of rank? The caveat is that you have to estimate that distribution in order to choose your link function (certain functional forms will make your life a lot easier). Furthermore, this model isn't going to say "you were the 6th best out of a class of 38", rather "if the test scores were distributed how we think they are, your score would put you in the 15th percentile."
Estimating percentages as the dependent variable in regression A perfect model in this case will map the inputs (whatever covariates you have) to the outputs (the rank of the student in the class). Another way to think of this is by mapping first to the scores,
18,612
Distribution to reflect situation where some waiting leads us to expect more waiting
The exponential distribution has the property of being "memoryless," i.e. (using your analogy) the length of your journey so far has no effect on the length of the remaining journey. If the density of distribution decays faster than that of the exponential distribution, then a longer journey will mean a shorter remaining journey; conversely, a density that decays slower than exponential (see e.g. subexponetial distributions) will have the property you describe. Since I think the comparison with memorylessness is clearest, my first suggestion would be to look at other distributions for which the exponential distribution is a special case. That will allow you to control fairly intuitively the magnitude of this effect. The Weibull distribution with shape parameter $<1$ would be a good choice.
Distribution to reflect situation where some waiting leads us to expect more waiting
The exponential distribution has the property of being "memoryless," i.e. (using your analogy) the length of your journey so far has no effect on the length of the remaining journey. If the density of
Distribution to reflect situation where some waiting leads us to expect more waiting The exponential distribution has the property of being "memoryless," i.e. (using your analogy) the length of your journey so far has no effect on the length of the remaining journey. If the density of distribution decays faster than that of the exponential distribution, then a longer journey will mean a shorter remaining journey; conversely, a density that decays slower than exponential (see e.g. subexponetial distributions) will have the property you describe. Since I think the comparison with memorylessness is clearest, my first suggestion would be to look at other distributions for which the exponential distribution is a special case. That will allow you to control fairly intuitively the magnitude of this effect. The Weibull distribution with shape parameter $<1$ would be a good choice.
Distribution to reflect situation where some waiting leads us to expect more waiting The exponential distribution has the property of being "memoryless," i.e. (using your analogy) the length of your journey so far has no effect on the length of the remaining journey. If the density of
18,613
Distribution to reflect situation where some waiting leads us to expect more waiting
The answer by bnaul gives the general property you are looking for. Rather than a Weibull distribution though, I'd suggest the Pareto distribution as the best example. The general pdf is $$ f(x) = \frac{\alpha x_m}{x^{\alpha - 1}} $$ with support $[x_m, \infty)$ and $\alpha>0$. This has the nice property that conditional on $x>y$, the distribution has the same shape parameter, but with $y$ as the new minimum. The distribution has $E[x] = \frac{\alpha x_m}{\alpha - 1}$. Suppose $\alpha=2$. Then, conditional on waiting $T$ days, you should expect the event to happen at time $2T$.
Distribution to reflect situation where some waiting leads us to expect more waiting
The answer by bnaul gives the general property you are looking for. Rather than a Weibull distribution though, I'd suggest the Pareto distribution as the best example. The general pdf is $$ f(x) = \f
Distribution to reflect situation where some waiting leads us to expect more waiting The answer by bnaul gives the general property you are looking for. Rather than a Weibull distribution though, I'd suggest the Pareto distribution as the best example. The general pdf is $$ f(x) = \frac{\alpha x_m}{x^{\alpha - 1}} $$ with support $[x_m, \infty)$ and $\alpha>0$. This has the nice property that conditional on $x>y$, the distribution has the same shape parameter, but with $y$ as the new minimum. The distribution has $E[x] = \frac{\alpha x_m}{\alpha - 1}$. Suppose $\alpha=2$. Then, conditional on waiting $T$ days, you should expect the event to happen at time $2T$.
Distribution to reflect situation where some waiting leads us to expect more waiting The answer by bnaul gives the general property you are looking for. Rather than a Weibull distribution though, I'd suggest the Pareto distribution as the best example. The general pdf is $$ f(x) = \f
18,614
Are experts harmful?
I think this is more about Engineering Problem Solving. Most successful engineering projects do not duplicate expert reasoning or or the expert's nature exactly. They solved the problem in a different way. For example washing machines use a different technique than humans, airplanes use different dynamics than birds. If you are duplicating Expert Reasoning, their input is everything. But if you are solving same problem using different techniques (fast search, huge memory ...), their input is only helpful.
Are experts harmful?
I think this is more about Engineering Problem Solving. Most successful engineering projects do not duplicate expert reasoning or or the expert's nature exactly. They solved the problem in a different
Are experts harmful? I think this is more about Engineering Problem Solving. Most successful engineering projects do not duplicate expert reasoning or or the expert's nature exactly. They solved the problem in a different way. For example washing machines use a different technique than humans, airplanes use different dynamics than birds. If you are duplicating Expert Reasoning, their input is everything. But if you are solving same problem using different techniques (fast search, huge memory ...), their input is only helpful.
Are experts harmful? I think this is more about Engineering Problem Solving. Most successful engineering projects do not duplicate expert reasoning or or the expert's nature exactly. They solved the problem in a different
18,615
Are experts harmful?
Such issues are common in various areas requiring judgement. The chapter on "Judgemental forecasting and adjustments" in Makridakis, Wheelwright and Hyndman Forecasting: Methods and applications has similar stories of expert judgement under-performing sometimes even very simple systems. There's a paper (Dawes et al (1989) "Clinical vs Actuarial Judgement" Science, Vol 243, No 4899, p1668-74) about the failures of expert judgement in the medical area against what it calls 'actuarial' methods - basically fairly simple statistical models. On the other hand there's a paper in the actuarial literature about the 'noisiness' and inconsistency of expert judgement in a particular problem in that area where expert judgement is often regarded by its practitioners as of paramount importance. Makridakis et al discuss failures of expert judgement in many areas, as they relate to forecasting, and contains quite a bit of valuable advice. And so on it goes. Cognitive biases abound and human experts suffer from them along with everyone else.
Are experts harmful?
Such issues are common in various areas requiring judgement. The chapter on "Judgemental forecasting and adjustments" in Makridakis, Wheelwright and Hyndman Forecasting: Methods and applications has s
Are experts harmful? Such issues are common in various areas requiring judgement. The chapter on "Judgemental forecasting and adjustments" in Makridakis, Wheelwright and Hyndman Forecasting: Methods and applications has similar stories of expert judgement under-performing sometimes even very simple systems. There's a paper (Dawes et al (1989) "Clinical vs Actuarial Judgement" Science, Vol 243, No 4899, p1668-74) about the failures of expert judgement in the medical area against what it calls 'actuarial' methods - basically fairly simple statistical models. On the other hand there's a paper in the actuarial literature about the 'noisiness' and inconsistency of expert judgement in a particular problem in that area where expert judgement is often regarded by its practitioners as of paramount importance. Makridakis et al discuss failures of expert judgement in many areas, as they relate to forecasting, and contains quite a bit of valuable advice. And so on it goes. Cognitive biases abound and human experts suffer from them along with everyone else.
Are experts harmful? Such issues are common in various areas requiring judgement. The chapter on "Judgemental forecasting and adjustments" in Makridakis, Wheelwright and Hyndman Forecasting: Methods and applications has s
18,616
Are experts harmful?
The question of whether or not experts are harmful is certainly not a problem restricted to the game of chess. An interesting question in the literature regarding the optimal design of Monetary Policy Committees (MPC) is whether or not committees should include outside experts who are not full-time employees of the central bank. To put this into perspective, first consider the Bank of England's MPC. It is composed of five internal executive members of the bank and four outside experts. On the other hand, the Federal Reserve Bank employs a committee composed solely of bank employees. Outside expert members are included in the Bank of England's MPC as they are believed to bring in expertise and extra information to that gained inside the Bank of England. So, which MPC design is better? Experts in, or experts out? Well, this area of research is still active and it has been investigated recently by Hansen & McMahon (2010). I suggest consulting the references mentioned in this paper for further reading on this issue of "committees of experts". Is this a big (important) problem? Taking into consideration the effects that a MPC's decision may have for the economy, I'd say this is a pretty important problem! Lastly, I ought to mention that monetary policy decisions can, in theory, be delegated to a computer. For example, the computer could be programmed to implement, say, a simple monetary policy rule; for instance, one of committment. This would remove expert input after the monetary policy rule has been programmed into the computer. The use of the computer in monetary policy is mentioned in Svensson (1999). Reference: Stephen Eliot Hansen & Michael McMahon, 2010. "What do outside experts bring to a committee? Evidence from the Bank of England," Economics Working Papers 1238, Department of Economics and Business, Universitat Pompeu Fabra. Lars E.O. Svensson, 1999. "How should monetary policy be conducted in an era of price stability?," Proceedings, Federal Reserve Bank of Kansas City, pages 195-259.
Are experts harmful?
The question of whether or not experts are harmful is certainly not a problem restricted to the game of chess. An interesting question in the literature regarding the optimal design of Monetary Polic
Are experts harmful? The question of whether or not experts are harmful is certainly not a problem restricted to the game of chess. An interesting question in the literature regarding the optimal design of Monetary Policy Committees (MPC) is whether or not committees should include outside experts who are not full-time employees of the central bank. To put this into perspective, first consider the Bank of England's MPC. It is composed of five internal executive members of the bank and four outside experts. On the other hand, the Federal Reserve Bank employs a committee composed solely of bank employees. Outside expert members are included in the Bank of England's MPC as they are believed to bring in expertise and extra information to that gained inside the Bank of England. So, which MPC design is better? Experts in, or experts out? Well, this area of research is still active and it has been investigated recently by Hansen & McMahon (2010). I suggest consulting the references mentioned in this paper for further reading on this issue of "committees of experts". Is this a big (important) problem? Taking into consideration the effects that a MPC's decision may have for the economy, I'd say this is a pretty important problem! Lastly, I ought to mention that monetary policy decisions can, in theory, be delegated to a computer. For example, the computer could be programmed to implement, say, a simple monetary policy rule; for instance, one of committment. This would remove expert input after the monetary policy rule has been programmed into the computer. The use of the computer in monetary policy is mentioned in Svensson (1999). Reference: Stephen Eliot Hansen & Michael McMahon, 2010. "What do outside experts bring to a committee? Evidence from the Bank of England," Economics Working Papers 1238, Department of Economics and Business, Universitat Pompeu Fabra. Lars E.O. Svensson, 1999. "How should monetary policy be conducted in an era of price stability?," Proceedings, Federal Reserve Bank of Kansas City, pages 195-259.
Are experts harmful? The question of whether or not experts are harmful is certainly not a problem restricted to the game of chess. An interesting question in the literature regarding the optimal design of Monetary Polic
18,617
Are experts harmful?
I think the key is consistency. The expert has not only particular knowledge, but a system within which that knowledge operates. They have a persona, an overall strategy, within which their tactics reside and evolve. In some sense, a computer program playing chess is a Frankenstein's Monster created from a mashup of various bodies (programmers, experts, etc). So it's not surprising that any one expert's advice would not fit well with the system that exists. I agree with other comments that experts may not know how they do what they do. In which case, being human, their conscious mind makes up a plausible story as to why they reached a particular decision. But I still think that expert advice to the programming team is always out of context (i.e. inconsistent with the context of the program's design and history). EDIT: There may also be a Reinforcement Bias here. I can't find any good links to explain Reinforcement Bias, but the way I understand the term it's the effect you get when you update (refit) a supervised model using the previous results of the model -- usually indirectly -- as targets. It's similar to Confirmation bias, but it involves a level of indirection. Human experts would have their Reinforcement Biases, which could affect things.
Are experts harmful?
I think the key is consistency. The expert has not only particular knowledge, but a system within which that knowledge operates. They have a persona, an overall strategy, within which their tactics re
Are experts harmful? I think the key is consistency. The expert has not only particular knowledge, but a system within which that knowledge operates. They have a persona, an overall strategy, within which their tactics reside and evolve. In some sense, a computer program playing chess is a Frankenstein's Monster created from a mashup of various bodies (programmers, experts, etc). So it's not surprising that any one expert's advice would not fit well with the system that exists. I agree with other comments that experts may not know how they do what they do. In which case, being human, their conscious mind makes up a plausible story as to why they reached a particular decision. But I still think that expert advice to the programming team is always out of context (i.e. inconsistent with the context of the program's design and history). EDIT: There may also be a Reinforcement Bias here. I can't find any good links to explain Reinforcement Bias, but the way I understand the term it's the effect you get when you update (refit) a supervised model using the previous results of the model -- usually indirectly -- as targets. It's similar to Confirmation bias, but it involves a level of indirection. Human experts would have their Reinforcement Biases, which could affect things.
Are experts harmful? I think the key is consistency. The expert has not only particular knowledge, but a system within which that knowledge operates. They have a persona, an overall strategy, within which their tactics re
18,618
Confidence interval for geometric mean
The geometric mean $(\prod_{i=1}^n X_i)^{1/n}$ is an arithmetic mean after taking logs $1/n \sum_{i=1}^n \log X_i$, so if you do know the CI for the arithmetic mean do the same for the logarithms of your data points and take exponents of the upper and lower bounds.
Confidence interval for geometric mean
The geometric mean $(\prod_{i=1}^n X_i)^{1/n}$ is an arithmetic mean after taking logs $1/n \sum_{i=1}^n \log X_i$, so if you do know the CI for the arithmetic mean do the same for the logarithms of y
Confidence interval for geometric mean The geometric mean $(\prod_{i=1}^n X_i)^{1/n}$ is an arithmetic mean after taking logs $1/n \sum_{i=1}^n \log X_i$, so if you do know the CI for the arithmetic mean do the same for the logarithms of your data points and take exponents of the upper and lower bounds.
Confidence interval for geometric mean The geometric mean $(\prod_{i=1}^n X_i)^{1/n}$ is an arithmetic mean after taking logs $1/n \sum_{i=1}^n \log X_i$, so if you do know the CI for the arithmetic mean do the same for the logarithms of y
18,619
What does the assumption of the Fisher test that "The row and column totals should be fixed" mean?
In my opinion, the source that you link to is wrong in that it is confusing conditioning with assumptions. Fisher's exact test conditions on the margin totals, meaning that it does not use any information about independence that might be inferable from the margin totals. In probability theory, once you condition on a random variable, the random variable is then treated as fixed in the downstream computations. This however is purely a mathematical device. It is not at all the same as assuming that the margin totals were fixed in advance as part of the experimental design. It is simply a matter of choosing what information to extract from the data. Conditioning actually reduces the assumptions made by the test. Since Fisher's test only uses the distribution of the cell counts given the margin counts, it therefore makes no assumptions about how the margin counts were generated. The source you link to states that Fisher's exact test makes more assumptions than Pearson's chisquare test or the G-test. In my opinion, this statement is wrong. All three tests condition on the margin totals and all three make the same distributional assumptions. Fisher's exact test gives correct control of the type I error rate regardless of whether the marginal totals are fixed or not and the p-values are exact in the sense that they are derived from exact computations using the hypergeometric distribution. IMO there is a lot of misunderstanding about this issue on the internet and it possibly derives from the question of optimality. If the margin totals are not fixed by the experimental design, then potentially there is information about independence contained in the row and column totals, and hence potentially one might be able to create a statistical test that is more powerful than Fisher's exact test. There is some interesting literature about this but in practice (i) there's not much information to retrieve if the counts are small and (ii) Fisher's exact test is already powerful enough when the counts are large. Another misunderstanding is that people interpret "exact" to mean that the type I error rate is controlled exactly at a specified rate. Like all tests that return exact p-values for discrete counts, Fisher's test gives somewhat conservative control of any pre-specified type I error rate, simply because the p-values are granular (and this has nothing to do with whether the margins are fixed or not).
What does the assumption of the Fisher test that "The row and column totals should be fixed" mean?
In my opinion, the source that you link to is wrong in that it is confusing conditioning with assumptions. Fisher's exact test conditions on the margin totals, meaning that it does not use any informa
What does the assumption of the Fisher test that "The row and column totals should be fixed" mean? In my opinion, the source that you link to is wrong in that it is confusing conditioning with assumptions. Fisher's exact test conditions on the margin totals, meaning that it does not use any information about independence that might be inferable from the margin totals. In probability theory, once you condition on a random variable, the random variable is then treated as fixed in the downstream computations. This however is purely a mathematical device. It is not at all the same as assuming that the margin totals were fixed in advance as part of the experimental design. It is simply a matter of choosing what information to extract from the data. Conditioning actually reduces the assumptions made by the test. Since Fisher's test only uses the distribution of the cell counts given the margin counts, it therefore makes no assumptions about how the margin counts were generated. The source you link to states that Fisher's exact test makes more assumptions than Pearson's chisquare test or the G-test. In my opinion, this statement is wrong. All three tests condition on the margin totals and all three make the same distributional assumptions. Fisher's exact test gives correct control of the type I error rate regardless of whether the marginal totals are fixed or not and the p-values are exact in the sense that they are derived from exact computations using the hypergeometric distribution. IMO there is a lot of misunderstanding about this issue on the internet and it possibly derives from the question of optimality. If the margin totals are not fixed by the experimental design, then potentially there is information about independence contained in the row and column totals, and hence potentially one might be able to create a statistical test that is more powerful than Fisher's exact test. There is some interesting literature about this but in practice (i) there's not much information to retrieve if the counts are small and (ii) Fisher's exact test is already powerful enough when the counts are large. Another misunderstanding is that people interpret "exact" to mean that the type I error rate is controlled exactly at a specified rate. Like all tests that return exact p-values for discrete counts, Fisher's test gives somewhat conservative control of any pre-specified type I error rate, simply because the p-values are granular (and this has nothing to do with whether the margins are fixed or not).
What does the assumption of the Fisher test that "The row and column totals should be fixed" mean? In my opinion, the source that you link to is wrong in that it is confusing conditioning with assumptions. Fisher's exact test conditions on the margin totals, meaning that it does not use any informa
18,620
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$
The idea's right--but there's a question of expressing it a little more rigorously. I will therefore focus on notation and on exposing the essence of the idea. Let's begin with the idea of exchangeability: A random variable $\mathbf X=(X_1, X_2, \ldots, X_n)$ is exchangeable when the distributions of the permuted variables $\mathbf{X}^\sigma=(X_{\sigma(1)}, X_{\sigma(2)}, \ldots, X_{\sigma(n)})$ are all the same for every possible permutation $\sigma$. Clearly iid implies exchangeable. As a matter of notation, write $X^\sigma_i = X_{\sigma(i)}$ for the $i^\text{th}$ component of $\mathbf{X}^\sigma$ and let $$T^\sigma = \sum_{i=1}^n X^\sigma_i = \sum_{i=1}^n X_i = T.$$ Let $j$ be any index and let $\sigma$ be any permutation of the indices that sends $1$ to $j = \sigma(1).$ (Such a $\sigma$ exists because one can always just swap $1$ and $j.$) Exchangeability of $\mathbf X$ implies $$E[X_1\mid T] = E[X^\sigma_1\mid T^\sigma] = E[X_j\mid T],$$ because (in the first inequality) we have merely replaced $\mathbf X$ by the identically distributed vector $\mathbf X^\sigma.$ This is the crux of the matter. Consequently $$T = E[T \mid T] = E[\sum_{i=1}^n X_i\mid T] = \sum_{i=1}^n E[X_i\mid T] = \sum_{i=1}^n E[X_1\mid T] = n E[X_1 \mid T],$$ whence $$E[X_1\mid T] = \frac{1}{n} T.$$
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig
The idea's right--but there's a question of expressing it a little more rigorously. I will therefore focus on notation and on exposing the essence of the idea. Let's begin with the idea of exchangea
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$ The idea's right--but there's a question of expressing it a little more rigorously. I will therefore focus on notation and on exposing the essence of the idea. Let's begin with the idea of exchangeability: A random variable $\mathbf X=(X_1, X_2, \ldots, X_n)$ is exchangeable when the distributions of the permuted variables $\mathbf{X}^\sigma=(X_{\sigma(1)}, X_{\sigma(2)}, \ldots, X_{\sigma(n)})$ are all the same for every possible permutation $\sigma$. Clearly iid implies exchangeable. As a matter of notation, write $X^\sigma_i = X_{\sigma(i)}$ for the $i^\text{th}$ component of $\mathbf{X}^\sigma$ and let $$T^\sigma = \sum_{i=1}^n X^\sigma_i = \sum_{i=1}^n X_i = T.$$ Let $j$ be any index and let $\sigma$ be any permutation of the indices that sends $1$ to $j = \sigma(1).$ (Such a $\sigma$ exists because one can always just swap $1$ and $j.$) Exchangeability of $\mathbf X$ implies $$E[X_1\mid T] = E[X^\sigma_1\mid T^\sigma] = E[X_j\mid T],$$ because (in the first inequality) we have merely replaced $\mathbf X$ by the identically distributed vector $\mathbf X^\sigma.$ This is the crux of the matter. Consequently $$T = E[T \mid T] = E[\sum_{i=1}^n X_i\mid T] = \sum_{i=1}^n E[X_i\mid T] = \sum_{i=1}^n E[X_1\mid T] = n E[X_1 \mid T],$$ whence $$E[X_1\mid T] = \frac{1}{n} T.$$
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig The idea's right--but there's a question of expressing it a little more rigorously. I will therefore focus on notation and on exposing the essence of the idea. Let's begin with the idea of exchangea
18,621
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$
$\newcommand{\one}{\mathbf 1}$This is not a proof (and +1 to @whuber's answer), but it's a geometric way to build some intuition as to why $E(X_1 | T) = T/n$ is a sensible answer. Let $X = (X_1,\dots,X_n)^T$ and $\one = (1,\dots,1)^T$ so $T = \one^TX$. We're then conditioning on the event that $\one^TX = t$ for some $t \in \mathbb R$, so this is like drawing multivariate Gaussians supported on $\mathbb R^n$ but only looking at the ones that end up in the affine space $\{x \in \mathbb R^n : \one^Tx = t\}$. Then we want to know the average of the $x_1$ coordinates of the points that land in this affine space (never mind that it's a measure zero subset). We know $$ X \sim \mathcal N(\mu \one, I) $$ so we've got a spherical Gaussian with a constant mean vector, and the mean vector $\mu\one$ is on the same line as the normal vector of the hyperplane $x^T\one = 0$. This gives us a situation like the picture below: The key idea: first imagine the density over the affine subspace $H_t := \{x : x^T\one = t\}$. The density of $X$ is symmetric around $x_1 = x_2$ since $E(X) \in \text{span } \one$. The density will also be symmetric on $H_t$ as $H_t$ is also symmetric over the same line, and the point around which it is symmetric is the intersection of the lines $x_1 + x_2 = t$ and $x_1 = x_2$. This happens for $x = (t/2, t/2)$. To picture $E(X_1 | T)$ we can imagine sampling over and over, and then whenever we get a point in $H_t$ we take just the $x_1$ coordinate and save that. From the symmetry of the density on $H_t$ the distribution of the $x_1$ coordinates will also be symmetric, and it'll have the same center point of $t/2$. The mean of a symmetric distribution is the central point of symmetry so this means $E(X_1 | T) = T/2$, and that $E(X_1| T) = E(X_2 | T)$ since $X_1$ and $X_2$ can be excahnged without affecting anything. In higher dimensions this gets hard (or impossible) to exactly visualize, but the same idea applies: we've got a spherical Gaussian with a mean in the span of $\one$, and we're looking at an affine subspace that's perpendicular to that. The balance point of the distribution on the subspace will still be the intersection of $\text{span }\one$ and $\{x : x^T\one = t\}$ which is at $x=(t/n, \dots, t/n)$, and the density is still symmetric so this balance point is again the mean. Again, that's not a proof, but I think it gives a decent idea of why you'd expect this behavior in the first place. Beyond this, as some such as @StubbornAtom have noted, this doesn't actually require $X$ to be Gaussian. In 2-D, note that if $X$ is exchangeable then $f(x_1, x_2) = f(x_2, x_1)$ (more generally, $f(x) = f(x^\sigma)$) so $f$ must be symmetric over the line $x_1 = x_2$. We also have $E(X) \in \text{span }\one$ so everything I said regarding the "key idea" in the first picture still exactly holds. Here's an example where the $X_i$ are iid from a Gaussian mixture model. All the lines have the same meaning as before.
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig
$\newcommand{\one}{\mathbf 1}$This is not a proof (and +1 to @whuber's answer), but it's a geometric way to build some intuition as to why $E(X_1 | T) = T/n$ is a sensible answer. Let $X = (X_1,\dots,
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$ $\newcommand{\one}{\mathbf 1}$This is not a proof (and +1 to @whuber's answer), but it's a geometric way to build some intuition as to why $E(X_1 | T) = T/n$ is a sensible answer. Let $X = (X_1,\dots,X_n)^T$ and $\one = (1,\dots,1)^T$ so $T = \one^TX$. We're then conditioning on the event that $\one^TX = t$ for some $t \in \mathbb R$, so this is like drawing multivariate Gaussians supported on $\mathbb R^n$ but only looking at the ones that end up in the affine space $\{x \in \mathbb R^n : \one^Tx = t\}$. Then we want to know the average of the $x_1$ coordinates of the points that land in this affine space (never mind that it's a measure zero subset). We know $$ X \sim \mathcal N(\mu \one, I) $$ so we've got a spherical Gaussian with a constant mean vector, and the mean vector $\mu\one$ is on the same line as the normal vector of the hyperplane $x^T\one = 0$. This gives us a situation like the picture below: The key idea: first imagine the density over the affine subspace $H_t := \{x : x^T\one = t\}$. The density of $X$ is symmetric around $x_1 = x_2$ since $E(X) \in \text{span } \one$. The density will also be symmetric on $H_t$ as $H_t$ is also symmetric over the same line, and the point around which it is symmetric is the intersection of the lines $x_1 + x_2 = t$ and $x_1 = x_2$. This happens for $x = (t/2, t/2)$. To picture $E(X_1 | T)$ we can imagine sampling over and over, and then whenever we get a point in $H_t$ we take just the $x_1$ coordinate and save that. From the symmetry of the density on $H_t$ the distribution of the $x_1$ coordinates will also be symmetric, and it'll have the same center point of $t/2$. The mean of a symmetric distribution is the central point of symmetry so this means $E(X_1 | T) = T/2$, and that $E(X_1| T) = E(X_2 | T)$ since $X_1$ and $X_2$ can be excahnged without affecting anything. In higher dimensions this gets hard (or impossible) to exactly visualize, but the same idea applies: we've got a spherical Gaussian with a mean in the span of $\one$, and we're looking at an affine subspace that's perpendicular to that. The balance point of the distribution on the subspace will still be the intersection of $\text{span }\one$ and $\{x : x^T\one = t\}$ which is at $x=(t/n, \dots, t/n)$, and the density is still symmetric so this balance point is again the mean. Again, that's not a proof, but I think it gives a decent idea of why you'd expect this behavior in the first place. Beyond this, as some such as @StubbornAtom have noted, this doesn't actually require $X$ to be Gaussian. In 2-D, note that if $X$ is exchangeable then $f(x_1, x_2) = f(x_2, x_1)$ (more generally, $f(x) = f(x^\sigma)$) so $f$ must be symmetric over the line $x_1 = x_2$. We also have $E(X) \in \text{span }\one$ so everything I said regarding the "key idea" in the first picture still exactly holds. Here's an example where the $X_i$ are iid from a Gaussian mixture model. All the lines have the same meaning as before.
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig $\newcommand{\one}{\mathbf 1}$This is not a proof (and +1 to @whuber's answer), but it's a geometric way to build some intuition as to why $E(X_1 | T) = T/n$ is a sensible answer. Let $X = (X_1,\dots,
18,622
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$
I think your answer is right, although I'm not entirely sure about the killer line in your proof, about it being true "because they are i.i.d". A more wordy way to the same solution is as follows: Think about what $\mathbb{E}(x_{i}|T)$ actually means. You know that you have a sample with N readings and that their mean is T. What this actually means, is that now, the underlying distribution they were sampled from no longer matters (you'll notice you at no point used the fact it was sampled from a Gaussian in your proof). $\mathbb{E}(x_{i}|T)$ is the answer to the question, if you sampled from your sample, with replacement many times, what would be the average you obtained. This is the sum over all the possible values, multiplied by their probability, or $\sum_{i=1}^{N}\frac{1}{N}x_{i}$ which equals T.
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig
I think your answer is right, although I'm not entirely sure about the killer line in your proof, about it being true "because they are i.i.d". A more wordy way to the same solution is as follows: Thi
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$ I think your answer is right, although I'm not entirely sure about the killer line in your proof, about it being true "because they are i.i.d". A more wordy way to the same solution is as follows: Think about what $\mathbb{E}(x_{i}|T)$ actually means. You know that you have a sample with N readings and that their mean is T. What this actually means, is that now, the underlying distribution they were sampled from no longer matters (you'll notice you at no point used the fact it was sampled from a Gaussian in your proof). $\mathbb{E}(x_{i}|T)$ is the answer to the question, if you sampled from your sample, with replacement many times, what would be the average you obtained. This is the sum over all the possible values, multiplied by their probability, or $\sum_{i=1}^{N}\frac{1}{N}x_{i}$ which equals T.
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig I think your answer is right, although I'm not entirely sure about the killer line in your proof, about it being true "because they are i.i.d". A more wordy way to the same solution is as follows: Thi
18,623
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$
Proof: Let $u_1\times u_2 \times...\times u_n$ be the product measure $\mathbb{P}=u_1\times u_2 \times...\times u_n$ of these probability space where the random vector ($X_1,X_2,...,X_n$) lives. Let $F(x_1, x_2, x_3, ... , x_n)$ be the joint distribution function of random vector $X_1,X_2,...,X_n$ Easy to know that $(u_1 \circ X_1^{-1}) \times (u_2 \circ X_2^{-1}) \times...\times (u_n \circ X_n^{-1}) = F$ Since $X_i$ is i.i.d., for each permutation $p$ of $p$($X_1,X_2,...,X_n$)=($X_{p 1},X_{p 2},...,X_{p n}$), we have $F(x_1, x_2, ... , x_n) = F(x_{p 1}, x_{p 2}, ... , x_{p n})$ Then according to the definition of conditional expectation: For each $A \in \sigma(T)$ , we have $A=\left\{X_1+X_2+..+X_n \in C \right\}$ for $C \in \mathcal{B}$ $\int_{A}{\mathbb{E}(X_1|T)d\mathbb{P}}=\int_{A}{X_1d\mathbb{P}}$ $=\int_{A}{X_1d(\mathbb{u_1\times u_2 \times...\times u_n})}$ $=\int_{C}{x_1F(dx_1,dx_2,...dx_n)}$ Change variables : $x_{p i} = x_{i}$, for $i = 1,2,...,n$ $= \int_{C}{x_{\sigma 1}F(dx_{p 1}, dx_{p 2}, ..., dx_{p n})}$ $= \int_{C}{x_{\sigma 1}F(dx_{1}, dx_{2}, ..., dx_{n})}$ $= \int_{A}{X_{\sigma 1}d(\mathbb{u_1\times u_2 \times...\times u_n})}$ $= \int_{A}{X_{\sigma 1}d\mathbb{P}}$ $= \int_{A}{\mathbb{E}(X_{p 1}|T)d\mathbb{P}}$ $\Rightarrow \mathbb{E}(X_{p 1}|T) = \mathbb{E}(X_1|T)$ a.s. for each permutation $p$ $\Rightarrow \mathbb{E}(X_{1}|T) = \mathbb{E}(T|T)/n = T/n$ Q.E.D
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig
Proof: Let $u_1\times u_2 \times...\times u_n$ be the product measure $\mathbb{P}=u_1\times u_2 \times...\times u_n$ of these probability space where the random vector ($X_1,X_2,...,X_n$) lives. Let $
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \right)$, where $T = \sum_i X_i$ Proof: Let $u_1\times u_2 \times...\times u_n$ be the product measure $\mathbb{P}=u_1\times u_2 \times...\times u_n$ of these probability space where the random vector ($X_1,X_2,...,X_n$) lives. Let $F(x_1, x_2, x_3, ... , x_n)$ be the joint distribution function of random vector $X_1,X_2,...,X_n$ Easy to know that $(u_1 \circ X_1^{-1}) \times (u_2 \circ X_2^{-1}) \times...\times (u_n \circ X_n^{-1}) = F$ Since $X_i$ is i.i.d., for each permutation $p$ of $p$($X_1,X_2,...,X_n$)=($X_{p 1},X_{p 2},...,X_{p n}$), we have $F(x_1, x_2, ... , x_n) = F(x_{p 1}, x_{p 2}, ... , x_{p n})$ Then according to the definition of conditional expectation: For each $A \in \sigma(T)$ , we have $A=\left\{X_1+X_2+..+X_n \in C \right\}$ for $C \in \mathcal{B}$ $\int_{A}{\mathbb{E}(X_1|T)d\mathbb{P}}=\int_{A}{X_1d\mathbb{P}}$ $=\int_{A}{X_1d(\mathbb{u_1\times u_2 \times...\times u_n})}$ $=\int_{C}{x_1F(dx_1,dx_2,...dx_n)}$ Change variables : $x_{p i} = x_{i}$, for $i = 1,2,...,n$ $= \int_{C}{x_{\sigma 1}F(dx_{p 1}, dx_{p 2}, ..., dx_{p n})}$ $= \int_{C}{x_{\sigma 1}F(dx_{1}, dx_{2}, ..., dx_{n})}$ $= \int_{A}{X_{\sigma 1}d(\mathbb{u_1\times u_2 \times...\times u_n})}$ $= \int_{A}{X_{\sigma 1}d\mathbb{P}}$ $= \int_{A}{\mathbb{E}(X_{p 1}|T)d\mathbb{P}}$ $\Rightarrow \mathbb{E}(X_{p 1}|T) = \mathbb{E}(X_1|T)$ a.s. for each permutation $p$ $\Rightarrow \mathbb{E}(X_{1}|T) = \mathbb{E}(T|T)/n = T/n$ Q.E.D
If $X_1,\cdots,X_n \sim \mathcal{N}(\mu, 1)$ are IID, then compute $\mathbb{E}\left( X_1 \mid T \rig Proof: Let $u_1\times u_2 \times...\times u_n$ be the product measure $\mathbb{P}=u_1\times u_2 \times...\times u_n$ of these probability space where the random vector ($X_1,X_2,...,X_n$) lives. Let $
18,624
Is is true that Bayesians don't need test sets?
If we use "the one true model" and "true priors" reflecting some appropriately captured prior information, then as far as I am aware a Bayesian truly does not have an overfitting problem and that posterior predictive distribution given very little data will be suitably uncertain. However, if we use some kind of pragmatically chosen model (i.e. we have decided that e.g. the hazard rate is constant over time and an exponential model is appropriate or e.g. that some covariate is not in the model = point prior of coefficient zero) with some default uninformative or regularizing priors, then we really do not know whether this still applies. In that case the choice of (hyper-)priors has some arbitrariness to it that may or may not result in good out of sample predictions. Thus, it is then very reasonable to ask the question whether the hyperparameter choice(=parameters of the hyperpriors) in combination with the chosen likelihood will perform well. In fact, you could easily decide that it is a good idea to tune your hyperparameters to obtain some desired prediction performance. From that perspective a validation set (or cross-validation) to tune hyperparameters and test set to confirm performance make perfect sense. I think this is closely related to a number of discussions of Andrew Gelman on his blog (see e.g. blog entry 1, blog entry 2, blog entry 3 on LOO for Stan and discusions on posterior predictive checks), where he discusses his concerns around the (in some sense correct) claims that a Bayesian should not check whether their model makes sense and about practical Bayesian model evaluation. Of course, we very often are the most interested in using Bayesian methods in settings, where there is little prior information and we want to use somewhat informative priors. At that point it may become somewhat tricky to have enough data to get anywhere with validation and evaluation on a test set.
Is is true that Bayesians don't need test sets?
If we use "the one true model" and "true priors" reflecting some appropriately captured prior information, then as far as I am aware a Bayesian truly does not have an overfitting problem and that post
Is is true that Bayesians don't need test sets? If we use "the one true model" and "true priors" reflecting some appropriately captured prior information, then as far as I am aware a Bayesian truly does not have an overfitting problem and that posterior predictive distribution given very little data will be suitably uncertain. However, if we use some kind of pragmatically chosen model (i.e. we have decided that e.g. the hazard rate is constant over time and an exponential model is appropriate or e.g. that some covariate is not in the model = point prior of coefficient zero) with some default uninformative or regularizing priors, then we really do not know whether this still applies. In that case the choice of (hyper-)priors has some arbitrariness to it that may or may not result in good out of sample predictions. Thus, it is then very reasonable to ask the question whether the hyperparameter choice(=parameters of the hyperpriors) in combination with the chosen likelihood will perform well. In fact, you could easily decide that it is a good idea to tune your hyperparameters to obtain some desired prediction performance. From that perspective a validation set (or cross-validation) to tune hyperparameters and test set to confirm performance make perfect sense. I think this is closely related to a number of discussions of Andrew Gelman on his blog (see e.g. blog entry 1, blog entry 2, blog entry 3 on LOO for Stan and discusions on posterior predictive checks), where he discusses his concerns around the (in some sense correct) claims that a Bayesian should not check whether their model makes sense and about practical Bayesian model evaluation. Of course, we very often are the most interested in using Bayesian methods in settings, where there is little prior information and we want to use somewhat informative priors. At that point it may become somewhat tricky to have enough data to get anywhere with validation and evaluation on a test set.
Is is true that Bayesians don't need test sets? If we use "the one true model" and "true priors" reflecting some appropriately captured prior information, then as far as I am aware a Bayesian truly does not have an overfitting problem and that post
18,625
Is is true that Bayesians don't need test sets?
So I answered the question on overfitting that you reference and I watched the video and read the blog post. Radford Neal is not saying that Bayesian models do not overfit. Let us remember that overfitting is the phenomenon of noise being treated as signal and impounded into the parameter estimate. That is not the only source of model selection error. Neal's discussion is broader though by venturing into the idea of a small sample size he ventured into the discussion of overfitting. Let me partially revise my prior posting that Bayesian models can overfit to all Bayesian models overfit, but do so in a way that improves prediction. Again, going back to the definition of confusing signal with noise, the uncertainty in Bayesian methods, the posterior distribution, is the quantification of that uncertainty as to what is signal and what is noise. In doing so, Bayesian methods are impounding noise into estimates of signal as the whole posterior is used in inference and prediction. Overfitting and other sources of model classification error is a different type of problem in Bayesian methods. To simplify, let us adopt the structure of Ma’s talk and focus on linear regression and avoid the deep learning discussion because, as he points out, the alternative methods he mentions are just compositions of functions and there is a direct linkage between the logic of linear regression and deep learning. Consider the following potential model $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3.$$ Lets create a broad sample of size $N$ composed of two subsamples, $n_1,n_2$, where $n_1$ is the training set and $n_2$ is the validation set. We will see why, subject to a few caveats, Bayesian methods do not need a separate training and validation set. For this discussion, we need to create eight more parameters, one for each model. They are $m_1\dots{_8}$. They follow a multinomial distribution and have proper priors as do the regression coefficients. The eight models are $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3,$$ $$y=\beta_0,$$ $$y=\beta_0+\beta_1x_1,$$ $$y=\beta_0+\beta_2x_2,$$ $$y=\beta_0+\beta_3x_3,$$ $$y=\beta_0+\beta_1x_1+\beta_2x_2,$$ $$y=\beta_0+\beta_1x_1+\beta_3x_3,$$ $$y=\beta_0+\beta_2x_2+\beta_3x_3,$$ $$y=\beta_0+\beta_1x_1,$$ $$y=\beta_0+\beta_2x_2,$$ and $$y=\beta_0+\beta_3x_3.$$ Now we need to get into the weeds of the differences between Bayesian and Frequentist methods. In training set, $n_1,$ the modeler using Frequentist methods chooses just one model. The modeler using Bayesian methods is not so restricted. Although the Bayesian modeler could use a model selection criterion to find just one model, they are also free to use model averaging. The Bayesian modeler is also free to change selected models in midstream in the validation segment. Moreso, the modeler using Bayesian methods can mix and match between selection and averaging. To give a real-world example, I tested 78 models of bankruptcy. Of the 78 models, the combined posterior probability of 76 of them was about one ten-thousandth of one percent. The other two models were roughly 54 percent and 46 percent respectively. Fortunately, they also did not share any variables. That allowed me to select both models and ignore the other 76. When I had all the data points for both, I averaged their predictions based on the posterior probabilities of the two models, using only one model when I had missing data points that precluded the other. While I did have a training set and validation set, it wasn’t for the same reason a Frequentist would have them. Furthermore, at the end of every day over two business cycles, I updated my posteriors with each day’s data. That meant that my model at the end of the validation set was not the model at the end of the training set. Bayesian models do not stop learning while Frequentist models do. To go deeper let us get concrete with our models. Let us assume that during the training sample the best fit Frequentist model and the Bayesian model using model selection matched or, alternatively, that the model weight in model averaging was so great that it was almost indistinguishable to the Frequentist model. We will imagine this model to be $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3.$$ Let’s also imagine that the true model in nature is $$y=\beta_0+\beta_1x_1+\beta_3x_3.$$ Now let's consider the difference in the validation set. The Frequentist model is overfitted to the data. Let’s assume that by some point $n_2^i$ that the model selection or validation procedure had changed the selection to the true model in nature. Further, if model averaging was used, then the true model in nature carried weight in the prediction long before the choice of models was clear-cut. E.T. Jaynes in his tome on probability theory spends some time discussing this issue. I have the book at work so I cannot get you a good citation, but you should read it. Its ISBN is 978-0521592710. Models are parameters in Bayesian thinking and as such are random, or if you would prefer, uncertain. That uncertainty does not end during the validation process. It is continually updated. Because of the differences between Bayesian and Frequentist methods, there are other types of cases that also must be considered. The first comes from parameter inference, the second from formal predictions. They are not the same thing in Bayesian methods. Bayesian methods formally separate out inference and decision making. They also separate out parameter estimation and prediction. Let’s imagine, without loss of generality, that a model would be successful if $\hat{\sigma^2}<k$ and a failure otherwise. We are going to ignore the other parameters because it would be a lot of extra work to get at a simple idea. For the modeler using Bayesian methods, this is a very different type of question than it is for the one using Frequentist methods. For the Frequentist a hypothesis test is formed based off of the training set. The modeler using Frequentist methods would test whether the estimated variance is greater than or equal to $k$ and attempt to reject the null over the sample whose size is $n_2$ by fixing the parameters to those discovered in $n_1$. For the modeler using Bayesian methods, they would form parameter estimates during from sample $n_1$ and the posterior density of $n_1$ would become the prior for sample $n_2$. Assuming the exchangeability property holds, then it is assured that the posterior estimate of $n_2$ is equal in all senses of the word of that of a probability estimate formed from the joint sample. Splitting them into two samples is equivalent by force of math to having not split them at all. For predictions, a similar issue holds. Bayesian methods have a predictive distribution that is also updated with each observation, whereas the Frequentist one is frozen at the end of sample $n_1$. The predictive density can be written as $\Pr(\tilde{x}=k|\mathbf{X})$. If $\tilde{x}$ is the prediction and $\mathbf{X}$ is the sample, then where are the parameters, which we will denote $\theta?$ Although Frequentist prediction systems do exist, most people just treat the point estimates as the true parameters and calculate residuals. Bayesian methods would score each prediction against the predicted density rather than just one single point. These predictions do not depend upon the parameters which are different from the point methods used in Frequentist solutions. As a side note, formal Frequentist predictive densities do exist using the standard errors, and scoring could be done on them, but this is rare in practice. If there is no specific prior knowledge, then the two sets of predictions should be identical for the same set of data points. They will end up differing because $n_1+n_2>n_1$ and so the Bayesian solution will impound more information. If there is no material prior information and if Frequentist predictive densities are used rather than point estimates, then for a fixed sample the results of the Bayesian and Frequentist methods will be identical if a single model is chosen. If there is prior information, then the Bayesian method will tend to generate more accurate predictions. This difference can be very large in practice. Further, if there is model averaging, then it is quite likely that the Bayesian method will be more robust. If you use model selection and freeze the Bayesian predictions, then there is no difference to using a Frequentist model using Frequentist predictions. I used a test and validation set because my data was not exchangeable. As a result, I needed to solve two problems. The first is similar to burn-in in MCMC methods. I needed a good set of parameter estimates to start my test sequence, and so I used fifty years of prior data to get a good prior density to start my validation test. The second problem was that I needed some form of standardized period to test in so that the test would not be questioned. I used the two prior business cycles as dated by NBER.
Is is true that Bayesians don't need test sets?
So I answered the question on overfitting that you reference and I watched the video and read the blog post. Radford Neal is not saying that Bayesian models do not overfit. Let us remember that over
Is is true that Bayesians don't need test sets? So I answered the question on overfitting that you reference and I watched the video and read the blog post. Radford Neal is not saying that Bayesian models do not overfit. Let us remember that overfitting is the phenomenon of noise being treated as signal and impounded into the parameter estimate. That is not the only source of model selection error. Neal's discussion is broader though by venturing into the idea of a small sample size he ventured into the discussion of overfitting. Let me partially revise my prior posting that Bayesian models can overfit to all Bayesian models overfit, but do so in a way that improves prediction. Again, going back to the definition of confusing signal with noise, the uncertainty in Bayesian methods, the posterior distribution, is the quantification of that uncertainty as to what is signal and what is noise. In doing so, Bayesian methods are impounding noise into estimates of signal as the whole posterior is used in inference and prediction. Overfitting and other sources of model classification error is a different type of problem in Bayesian methods. To simplify, let us adopt the structure of Ma’s talk and focus on linear regression and avoid the deep learning discussion because, as he points out, the alternative methods he mentions are just compositions of functions and there is a direct linkage between the logic of linear regression and deep learning. Consider the following potential model $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3.$$ Lets create a broad sample of size $N$ composed of two subsamples, $n_1,n_2$, where $n_1$ is the training set and $n_2$ is the validation set. We will see why, subject to a few caveats, Bayesian methods do not need a separate training and validation set. For this discussion, we need to create eight more parameters, one for each model. They are $m_1\dots{_8}$. They follow a multinomial distribution and have proper priors as do the regression coefficients. The eight models are $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3,$$ $$y=\beta_0,$$ $$y=\beta_0+\beta_1x_1,$$ $$y=\beta_0+\beta_2x_2,$$ $$y=\beta_0+\beta_3x_3,$$ $$y=\beta_0+\beta_1x_1+\beta_2x_2,$$ $$y=\beta_0+\beta_1x_1+\beta_3x_3,$$ $$y=\beta_0+\beta_2x_2+\beta_3x_3,$$ $$y=\beta_0+\beta_1x_1,$$ $$y=\beta_0+\beta_2x_2,$$ and $$y=\beta_0+\beta_3x_3.$$ Now we need to get into the weeds of the differences between Bayesian and Frequentist methods. In training set, $n_1,$ the modeler using Frequentist methods chooses just one model. The modeler using Bayesian methods is not so restricted. Although the Bayesian modeler could use a model selection criterion to find just one model, they are also free to use model averaging. The Bayesian modeler is also free to change selected models in midstream in the validation segment. Moreso, the modeler using Bayesian methods can mix and match between selection and averaging. To give a real-world example, I tested 78 models of bankruptcy. Of the 78 models, the combined posterior probability of 76 of them was about one ten-thousandth of one percent. The other two models were roughly 54 percent and 46 percent respectively. Fortunately, they also did not share any variables. That allowed me to select both models and ignore the other 76. When I had all the data points for both, I averaged their predictions based on the posterior probabilities of the two models, using only one model when I had missing data points that precluded the other. While I did have a training set and validation set, it wasn’t for the same reason a Frequentist would have them. Furthermore, at the end of every day over two business cycles, I updated my posteriors with each day’s data. That meant that my model at the end of the validation set was not the model at the end of the training set. Bayesian models do not stop learning while Frequentist models do. To go deeper let us get concrete with our models. Let us assume that during the training sample the best fit Frequentist model and the Bayesian model using model selection matched or, alternatively, that the model weight in model averaging was so great that it was almost indistinguishable to the Frequentist model. We will imagine this model to be $$y=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3.$$ Let’s also imagine that the true model in nature is $$y=\beta_0+\beta_1x_1+\beta_3x_3.$$ Now let's consider the difference in the validation set. The Frequentist model is overfitted to the data. Let’s assume that by some point $n_2^i$ that the model selection or validation procedure had changed the selection to the true model in nature. Further, if model averaging was used, then the true model in nature carried weight in the prediction long before the choice of models was clear-cut. E.T. Jaynes in his tome on probability theory spends some time discussing this issue. I have the book at work so I cannot get you a good citation, but you should read it. Its ISBN is 978-0521592710. Models are parameters in Bayesian thinking and as such are random, or if you would prefer, uncertain. That uncertainty does not end during the validation process. It is continually updated. Because of the differences between Bayesian and Frequentist methods, there are other types of cases that also must be considered. The first comes from parameter inference, the second from formal predictions. They are not the same thing in Bayesian methods. Bayesian methods formally separate out inference and decision making. They also separate out parameter estimation and prediction. Let’s imagine, without loss of generality, that a model would be successful if $\hat{\sigma^2}<k$ and a failure otherwise. We are going to ignore the other parameters because it would be a lot of extra work to get at a simple idea. For the modeler using Bayesian methods, this is a very different type of question than it is for the one using Frequentist methods. For the Frequentist a hypothesis test is formed based off of the training set. The modeler using Frequentist methods would test whether the estimated variance is greater than or equal to $k$ and attempt to reject the null over the sample whose size is $n_2$ by fixing the parameters to those discovered in $n_1$. For the modeler using Bayesian methods, they would form parameter estimates during from sample $n_1$ and the posterior density of $n_1$ would become the prior for sample $n_2$. Assuming the exchangeability property holds, then it is assured that the posterior estimate of $n_2$ is equal in all senses of the word of that of a probability estimate formed from the joint sample. Splitting them into two samples is equivalent by force of math to having not split them at all. For predictions, a similar issue holds. Bayesian methods have a predictive distribution that is also updated with each observation, whereas the Frequentist one is frozen at the end of sample $n_1$. The predictive density can be written as $\Pr(\tilde{x}=k|\mathbf{X})$. If $\tilde{x}$ is the prediction and $\mathbf{X}$ is the sample, then where are the parameters, which we will denote $\theta?$ Although Frequentist prediction systems do exist, most people just treat the point estimates as the true parameters and calculate residuals. Bayesian methods would score each prediction against the predicted density rather than just one single point. These predictions do not depend upon the parameters which are different from the point methods used in Frequentist solutions. As a side note, formal Frequentist predictive densities do exist using the standard errors, and scoring could be done on them, but this is rare in practice. If there is no specific prior knowledge, then the two sets of predictions should be identical for the same set of data points. They will end up differing because $n_1+n_2>n_1$ and so the Bayesian solution will impound more information. If there is no material prior information and if Frequentist predictive densities are used rather than point estimates, then for a fixed sample the results of the Bayesian and Frequentist methods will be identical if a single model is chosen. If there is prior information, then the Bayesian method will tend to generate more accurate predictions. This difference can be very large in practice. Further, if there is model averaging, then it is quite likely that the Bayesian method will be more robust. If you use model selection and freeze the Bayesian predictions, then there is no difference to using a Frequentist model using Frequentist predictions. I used a test and validation set because my data was not exchangeable. As a result, I needed to solve two problems. The first is similar to burn-in in MCMC methods. I needed a good set of parameter estimates to start my test sequence, and so I used fifty years of prior data to get a good prior density to start my validation test. The second problem was that I needed some form of standardized period to test in so that the test would not be questioned. I used the two prior business cycles as dated by NBER.
Is is true that Bayesians don't need test sets? So I answered the question on overfitting that you reference and I watched the video and read the blog post. Radford Neal is not saying that Bayesian models do not overfit. Let us remember that over
18,626
Is is true that Bayesians don't need test sets?
I have also pondered this question and my tentative answer is a very practical one. Please take this with a pinch of salt. Suppose you have a model that has no parameters. For instance, your model could be a curve that predicts the growth of some scalar quantity over time, and you have chosen this particular curve because it is prescribed by some available domain knowledge. Since your model has no parameters, there is no need for a test set. To evaluate how well your model does, you can apply your model on the entire dataset. By applying, I mean you can check how well your chosen curve goes through observed data and use some criterion (e.g. likelihood) to quantify the goodness of the fit. Now, in practice, our model will have some parameters. The Bayesian methodology sets the goal of calculating the marginal log-likelihood which involves integrating out all the model parameters. Marginal log-likelihood quantifies how well the model explains the data (or should I say how well the data support the model?). By integrating out, we are left with no parameters to tune/optimise. I will risk saying that this seems to me very similar to the case where we had a model with no parameters, the similarity being that we do not need to adapt any parameters to the observed dataset. There is a nice quote that I have read in this forum which states that "optimisation is the root of all evil in statistics" (I think it originates from user DikranMarsupial). In my understanding, this quote says that once you have stated your model assumptions, all you have to do is "turn the Bayesian crank". In other words, as long as you can be Bayesian (i.e. integrate out the parameters), then you have no reason to worry about overfitting, as you are considering all possible settings of your parameters (with density dictated by the prior) according to your model assumptions. If instead you need to optimise a parameter, it is difficult to tell whether you are over-adapting it to the particular data you observe (overfitting) or not. One practical way of testing overfitting is of course holding out a test set which is not used when optimising the parameter. In the presence of competing rival models, that effectively challange your assumptions, you can compare them using marginal log-likelihood in order to find the most likely one. Of course, somebody naughty may posit a model which perfectly replicates the observed data (trivially, it could be the data itself). In such a case, I am not sure how I would defend myself. In real life, however, it would be hard to motivate this contrived model in a setting such as physics where explaination based models are required...
Is is true that Bayesians don't need test sets?
I have also pondered this question and my tentative answer is a very practical one. Please take this with a pinch of salt. Suppose you have a model that has no parameters. For instance, your model cou
Is is true that Bayesians don't need test sets? I have also pondered this question and my tentative answer is a very practical one. Please take this with a pinch of salt. Suppose you have a model that has no parameters. For instance, your model could be a curve that predicts the growth of some scalar quantity over time, and you have chosen this particular curve because it is prescribed by some available domain knowledge. Since your model has no parameters, there is no need for a test set. To evaluate how well your model does, you can apply your model on the entire dataset. By applying, I mean you can check how well your chosen curve goes through observed data and use some criterion (e.g. likelihood) to quantify the goodness of the fit. Now, in practice, our model will have some parameters. The Bayesian methodology sets the goal of calculating the marginal log-likelihood which involves integrating out all the model parameters. Marginal log-likelihood quantifies how well the model explains the data (or should I say how well the data support the model?). By integrating out, we are left with no parameters to tune/optimise. I will risk saying that this seems to me very similar to the case where we had a model with no parameters, the similarity being that we do not need to adapt any parameters to the observed dataset. There is a nice quote that I have read in this forum which states that "optimisation is the root of all evil in statistics" (I think it originates from user DikranMarsupial). In my understanding, this quote says that once you have stated your model assumptions, all you have to do is "turn the Bayesian crank". In other words, as long as you can be Bayesian (i.e. integrate out the parameters), then you have no reason to worry about overfitting, as you are considering all possible settings of your parameters (with density dictated by the prior) according to your model assumptions. If instead you need to optimise a parameter, it is difficult to tell whether you are over-adapting it to the particular data you observe (overfitting) or not. One practical way of testing overfitting is of course holding out a test set which is not used when optimising the parameter. In the presence of competing rival models, that effectively challange your assumptions, you can compare them using marginal log-likelihood in order to find the most likely one. Of course, somebody naughty may posit a model which perfectly replicates the observed data (trivially, it could be the data itself). In such a case, I am not sure how I would defend myself. In real life, however, it would be hard to motivate this contrived model in a setting such as physics where explaination based models are required...
Is is true that Bayesians don't need test sets? I have also pondered this question and my tentative answer is a very practical one. Please take this with a pinch of salt. Suppose you have a model that has no parameters. For instance, your model cou
18,627
A problem on estimability of parameters
This answer stresses the verification of estimability. The minimum variance property is of my secondary consideration. To begin with, summarize the information in terms of matrix form of a linear model as follows: \begin{align} Y := \begin{bmatrix} Y_1 \\ Y_2 \\ Y_3 \\ Y_4 \end{bmatrix} = \begin{bmatrix} 1 & 0 & -1 \\ 1 & 1 & -1 \\ 1 & 0 & -1 \\ 1 & -1 & -1 \\ \end{bmatrix} \begin{bmatrix} \theta_1 \\ \theta_2 \\ \theta_3 \end{bmatrix} + \begin{bmatrix} \varepsilon_1 \\ \varepsilon_2 \\ \varepsilon_3 \\ \varepsilon_4 \end{bmatrix}:= X\beta + \varepsilon, \tag{1} \end{align} where $E(\varepsilon) = 0, \text{Var}(\varepsilon) = \sigma^2 I$ (to discuss estimability, the spherity assumption is not necessary. But to discuss the Gauss-Markov property, we do need to assume the spherity of $\varepsilon$). If the design matrix $X$ is of full rank, then the orginal parameter $\beta$ admits a unique least-squares estimate $\hat{\beta} = (X'X)^{-1}X'Y$. Consequently, any parameter $\phi$, defined as a linear function $\phi(\beta)$ of $\beta$ is estimable in the sense that it can be unambiguously estimated by data via the least-squares estimate $\hat{\beta}$ as $\hat{\phi} = p'\hat{\beta}$. The subtlety arises when $X$ is not of full rank. To have a thorough discussion, we fix some notations and terms first below (I follow the convention of The Coordinate-free Approach to Linear Models, Section 4.8. Some of the terms sound unnecessarily technical). In addition, the discussion applies to the general linear model $Y = X\beta + \varepsilon$ with $X \in \mathbb{R}^{n \times k}$ and $\beta \in \mathbb{R}^k$. A regression manifold is the collection of mean vectors as $\beta$ varies over $\mathbb{R}^k$: $$M = \{X\beta: \beta \in \mathbb{R}^k\}.$$ 2. A parametric functional $\phi = \phi(\beta)$ is a linear functional of $\beta$, $$\phi(\beta) = p'\beta = p_1\beta_1 + \cdots + p_k\beta_k.$$ As mentioned above, when $\text{rank}(X) < k$, not every parametric functional $\phi(\beta)$ is estimable. But, wait, what is the definition of the term estimable technically? It seems difficult to give a clear definition without bothering a little linear algebra. One definition, which I think is the most intuitive, is as follows (from the same aforementioned reference): Definition 1. A parametric functional $\phi(\beta)$ is estimable if it is uniquely determined by $X\beta$ in the sense that $\phi(\beta_1) = \phi(\beta_2)$ whenever $\beta_1,\beta_2 \in \mathbb{R}^k$ satisfy $X\beta_1 = X\beta_2$. Interpretation. The above definition stipulates that the mapping from the regression manifold $M$ to the parameter space of $\phi$ must be one-to-one, which is guaranteed when $\text{rank}(X) = k$ (i.e., when $X$ itself is one-to-one). When $\text{rank}(X) < k$, we know that there exist $\beta_1 \neq \beta_2$ such that $X\beta_1 = X\beta_2$. The estimable definition above in effect rules out those structural-deficient parametric functionals that result in different values themselves even with the same value on $M$, which don't make sense naturally. On the other hand, an estimable parametric functional $\phi(\cdot)$ does allow the case $\phi(\beta_1) = \phi(\beta_2)$ with $\beta_1 \neq \beta_2$, as long as the condition $X\beta_1 = X\beta_2$ is fulfilled. There are other equivalent conditions to check the estimability of a parametric functional given in the same reference, Proposition 8.4. After such a verbose background introduction, let's come back to your question. A. $\beta$ itself is non-estimable for the reason that $\text{rank}(X) < 3$, which entails $X\beta_1 = X\beta_2$ with $\beta_1 \neq \beta_2$. Although the above definition is given for scalar functionals, it is easily generalized to vector-valued functionals. B. $\phi_1(\beta) = \theta_1 + \theta_3 = (1, 0, 1)'\beta$ is non-estimable. To wit, consider $\beta_1 = (0, 1, 0)'$ and $\beta_2 = (1, 1, 1)'$, which gives $X\beta_1 = X\beta_2$ but $\phi_1(\beta_1) = 0 + 0 = 0 \neq \phi_1(\beta_2) = 1 + 1 = 2$. C. $\phi_2(\beta) = \theta_1 - \theta_3 = (1, 0, -1)'\beta$ is estimable. Because $X\beta_1 = X\beta_2$ trivially implies $\theta_1^{(1)} - \theta_3^{(1)} = \theta_1^{(2)} - \theta_3^{(2)}$, i.e., $\phi_2(\beta_1) = \phi_2(\beta_2)$. D. $\phi_3(\beta) = \theta_2 = (0, 1, 0)'\beta$ is also estimable. The derivation from $X\beta_1 = X\beta_2$ to $\phi_3(\beta_1) = \phi_3(\beta_2)$ is also trivial. After the estimability is verified, there is a theorem (Proposition 8.16, same reference) claims the Gauss-Markov property of $\phi(\beta)$. Based on that theorem, the second part of option C is incorrect. The best linear unbiased estimate is $\bar{Y} = (Y_1 + Y_2 + Y_3 + Y_4)/4$, by the theorem below. Theorem. Let $\phi(\beta) = p'\beta$ be an estimable parametric functional, then its best linear unbiased estimate (aka, Gauss-Markov estimate) is $\phi(\hat{\beta})$ for any solution $\hat{\beta}$ to the normal equations $X'X\hat{\beta} = X'Y$. The proof goes as follows: Proof. Straightforward calculation shows that the normal equations is \begin{equation} \begin{bmatrix} 4 & 0 & -4 \\ 0 & 2 & 0 \\ -4 & 0 & 4 \end{bmatrix} \hat{\beta} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 0 & -1 \\ -1 & -1 & -1 & -1 \end{bmatrix} Y, \end{equation} which, after simplification, is \begin{equation} \begin{bmatrix} \phi(\hat{\beta}) \\ \hat{\theta}_2/2 \\ -\phi(\hat{\beta}) \end{bmatrix} = \begin{bmatrix} \bar{Y} \\ (Y_2 - Y_4)/4 \\ -\bar{Y} \end{bmatrix}, \end{equation} i.e., $\phi(\hat{\beta}) = \bar{Y}$. Therefore, option D is the only correct answer. Addendum: The connection of estimability and identifiability When I was at school, a professor briefly mentioned that the estimability of the parametric functional $\phi$ corresponds to the model identifiability. I took this claim for granted then. However, the equivalance needs to be spelled out more explicitly. According to A.C. Davison's monograph Statistical Models p.144, Definition 2. A parametric model in which each parameter $\theta$ generates a different distribution is called identifiable. For linear model $(1)$, regardless the spherity condition $\text{Var}(\varepsilon) = \sigma^2 I$, it can be reformulated as \begin{equation} E[Y] = X\beta, \quad \beta \in \mathbb{R}^k. \tag{2} \end{equation} It is such a simple model that we only specified the first moment form of the response vector $Y$. When $\text{rank}(X) = k$, model $(2)$ is identifiable since $\beta_1 \neq \beta_2$ implies $X\beta_1 \neq X\beta_2$ (the word "distribution" in the original definition, naturally reduces to "mean" under model $(2)$.). Now suppose that $\text{rank}(X) < k$ and a given parametric functional $\phi(\beta) = p'\beta$, how do we reconcile Definition 1 and Definition 2? Well, by manipulating notations and words, we can show that (the "proof" is rather trivial) the estimability of $\phi(\beta)$ is equivalent to that the model $(2)$ is identifiable when it is parametrized with parameter $\phi = \phi(\beta) = p'\beta$ (the design matrix $X$ is likely to change accordingly). To prove, suppose $\phi(\beta)$ is estimable so that $X\beta_1 = X\beta_2$ implies $p'\beta_1 = p'\beta_2$, by definition, this is $\phi_1 = \phi_2$, hence model $(2)$ is identifiable when indexing with $\phi$. Conversely, suppose model $(2)$ is identifiable so that $X\beta_1 = X\beta_2$ implies $\phi_1 = \phi_2$, which is trivially $\phi_1(\beta) = \phi_2(\beta)$. Intuitively, when $X$ is reduced-ranked, the model with $\beta$ is parameter redundant (too many parameters) hence a non-redundant lower-dimensional reparametrization (which could consist of a collection of linear functionals) is possible. When is such new representation possible? The key is estimability. To illustrate the above statements, let's reconsider your example. We have verified parametric functionals $\phi_2(\beta) = \theta_1 - \theta_3$ and $\phi_3(\beta) = \theta_2$ are estimable. Therefore, we can rewrite the model $(1)$ in terms of the reparametrized parameter $(\phi_2, \phi_3)'$ as follows \begin{equation} E[Y] = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 0 \\ 1 & - 1 \end{bmatrix} \begin{bmatrix} \phi_2 \\ \phi_3 \end{bmatrix} = \tilde{X}\gamma. \end{equation} Clearly, since $\tilde{X}$ is full-ranked, the model with the new parameter $\gamma$ is identifiable.
A problem on estimability of parameters
This answer stresses the verification of estimability. The minimum variance property is of my secondary consideration. To begin with, summarize the information in terms of matrix form of a linear mode
A problem on estimability of parameters This answer stresses the verification of estimability. The minimum variance property is of my secondary consideration. To begin with, summarize the information in terms of matrix form of a linear model as follows: \begin{align} Y := \begin{bmatrix} Y_1 \\ Y_2 \\ Y_3 \\ Y_4 \end{bmatrix} = \begin{bmatrix} 1 & 0 & -1 \\ 1 & 1 & -1 \\ 1 & 0 & -1 \\ 1 & -1 & -1 \\ \end{bmatrix} \begin{bmatrix} \theta_1 \\ \theta_2 \\ \theta_3 \end{bmatrix} + \begin{bmatrix} \varepsilon_1 \\ \varepsilon_2 \\ \varepsilon_3 \\ \varepsilon_4 \end{bmatrix}:= X\beta + \varepsilon, \tag{1} \end{align} where $E(\varepsilon) = 0, \text{Var}(\varepsilon) = \sigma^2 I$ (to discuss estimability, the spherity assumption is not necessary. But to discuss the Gauss-Markov property, we do need to assume the spherity of $\varepsilon$). If the design matrix $X$ is of full rank, then the orginal parameter $\beta$ admits a unique least-squares estimate $\hat{\beta} = (X'X)^{-1}X'Y$. Consequently, any parameter $\phi$, defined as a linear function $\phi(\beta)$ of $\beta$ is estimable in the sense that it can be unambiguously estimated by data via the least-squares estimate $\hat{\beta}$ as $\hat{\phi} = p'\hat{\beta}$. The subtlety arises when $X$ is not of full rank. To have a thorough discussion, we fix some notations and terms first below (I follow the convention of The Coordinate-free Approach to Linear Models, Section 4.8. Some of the terms sound unnecessarily technical). In addition, the discussion applies to the general linear model $Y = X\beta + \varepsilon$ with $X \in \mathbb{R}^{n \times k}$ and $\beta \in \mathbb{R}^k$. A regression manifold is the collection of mean vectors as $\beta$ varies over $\mathbb{R}^k$: $$M = \{X\beta: \beta \in \mathbb{R}^k\}.$$ 2. A parametric functional $\phi = \phi(\beta)$ is a linear functional of $\beta$, $$\phi(\beta) = p'\beta = p_1\beta_1 + \cdots + p_k\beta_k.$$ As mentioned above, when $\text{rank}(X) < k$, not every parametric functional $\phi(\beta)$ is estimable. But, wait, what is the definition of the term estimable technically? It seems difficult to give a clear definition without bothering a little linear algebra. One definition, which I think is the most intuitive, is as follows (from the same aforementioned reference): Definition 1. A parametric functional $\phi(\beta)$ is estimable if it is uniquely determined by $X\beta$ in the sense that $\phi(\beta_1) = \phi(\beta_2)$ whenever $\beta_1,\beta_2 \in \mathbb{R}^k$ satisfy $X\beta_1 = X\beta_2$. Interpretation. The above definition stipulates that the mapping from the regression manifold $M$ to the parameter space of $\phi$ must be one-to-one, which is guaranteed when $\text{rank}(X) = k$ (i.e., when $X$ itself is one-to-one). When $\text{rank}(X) < k$, we know that there exist $\beta_1 \neq \beta_2$ such that $X\beta_1 = X\beta_2$. The estimable definition above in effect rules out those structural-deficient parametric functionals that result in different values themselves even with the same value on $M$, which don't make sense naturally. On the other hand, an estimable parametric functional $\phi(\cdot)$ does allow the case $\phi(\beta_1) = \phi(\beta_2)$ with $\beta_1 \neq \beta_2$, as long as the condition $X\beta_1 = X\beta_2$ is fulfilled. There are other equivalent conditions to check the estimability of a parametric functional given in the same reference, Proposition 8.4. After such a verbose background introduction, let's come back to your question. A. $\beta$ itself is non-estimable for the reason that $\text{rank}(X) < 3$, which entails $X\beta_1 = X\beta_2$ with $\beta_1 \neq \beta_2$. Although the above definition is given for scalar functionals, it is easily generalized to vector-valued functionals. B. $\phi_1(\beta) = \theta_1 + \theta_3 = (1, 0, 1)'\beta$ is non-estimable. To wit, consider $\beta_1 = (0, 1, 0)'$ and $\beta_2 = (1, 1, 1)'$, which gives $X\beta_1 = X\beta_2$ but $\phi_1(\beta_1) = 0 + 0 = 0 \neq \phi_1(\beta_2) = 1 + 1 = 2$. C. $\phi_2(\beta) = \theta_1 - \theta_3 = (1, 0, -1)'\beta$ is estimable. Because $X\beta_1 = X\beta_2$ trivially implies $\theta_1^{(1)} - \theta_3^{(1)} = \theta_1^{(2)} - \theta_3^{(2)}$, i.e., $\phi_2(\beta_1) = \phi_2(\beta_2)$. D. $\phi_3(\beta) = \theta_2 = (0, 1, 0)'\beta$ is also estimable. The derivation from $X\beta_1 = X\beta_2$ to $\phi_3(\beta_1) = \phi_3(\beta_2)$ is also trivial. After the estimability is verified, there is a theorem (Proposition 8.16, same reference) claims the Gauss-Markov property of $\phi(\beta)$. Based on that theorem, the second part of option C is incorrect. The best linear unbiased estimate is $\bar{Y} = (Y_1 + Y_2 + Y_3 + Y_4)/4$, by the theorem below. Theorem. Let $\phi(\beta) = p'\beta$ be an estimable parametric functional, then its best linear unbiased estimate (aka, Gauss-Markov estimate) is $\phi(\hat{\beta})$ for any solution $\hat{\beta}$ to the normal equations $X'X\hat{\beta} = X'Y$. The proof goes as follows: Proof. Straightforward calculation shows that the normal equations is \begin{equation} \begin{bmatrix} 4 & 0 & -4 \\ 0 & 2 & 0 \\ -4 & 0 & 4 \end{bmatrix} \hat{\beta} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 0 & -1 \\ -1 & -1 & -1 & -1 \end{bmatrix} Y, \end{equation} which, after simplification, is \begin{equation} \begin{bmatrix} \phi(\hat{\beta}) \\ \hat{\theta}_2/2 \\ -\phi(\hat{\beta}) \end{bmatrix} = \begin{bmatrix} \bar{Y} \\ (Y_2 - Y_4)/4 \\ -\bar{Y} \end{bmatrix}, \end{equation} i.e., $\phi(\hat{\beta}) = \bar{Y}$. Therefore, option D is the only correct answer. Addendum: The connection of estimability and identifiability When I was at school, a professor briefly mentioned that the estimability of the parametric functional $\phi$ corresponds to the model identifiability. I took this claim for granted then. However, the equivalance needs to be spelled out more explicitly. According to A.C. Davison's monograph Statistical Models p.144, Definition 2. A parametric model in which each parameter $\theta$ generates a different distribution is called identifiable. For linear model $(1)$, regardless the spherity condition $\text{Var}(\varepsilon) = \sigma^2 I$, it can be reformulated as \begin{equation} E[Y] = X\beta, \quad \beta \in \mathbb{R}^k. \tag{2} \end{equation} It is such a simple model that we only specified the first moment form of the response vector $Y$. When $\text{rank}(X) = k$, model $(2)$ is identifiable since $\beta_1 \neq \beta_2$ implies $X\beta_1 \neq X\beta_2$ (the word "distribution" in the original definition, naturally reduces to "mean" under model $(2)$.). Now suppose that $\text{rank}(X) < k$ and a given parametric functional $\phi(\beta) = p'\beta$, how do we reconcile Definition 1 and Definition 2? Well, by manipulating notations and words, we can show that (the "proof" is rather trivial) the estimability of $\phi(\beta)$ is equivalent to that the model $(2)$ is identifiable when it is parametrized with parameter $\phi = \phi(\beta) = p'\beta$ (the design matrix $X$ is likely to change accordingly). To prove, suppose $\phi(\beta)$ is estimable so that $X\beta_1 = X\beta_2$ implies $p'\beta_1 = p'\beta_2$, by definition, this is $\phi_1 = \phi_2$, hence model $(2)$ is identifiable when indexing with $\phi$. Conversely, suppose model $(2)$ is identifiable so that $X\beta_1 = X\beta_2$ implies $\phi_1 = \phi_2$, which is trivially $\phi_1(\beta) = \phi_2(\beta)$. Intuitively, when $X$ is reduced-ranked, the model with $\beta$ is parameter redundant (too many parameters) hence a non-redundant lower-dimensional reparametrization (which could consist of a collection of linear functionals) is possible. When is such new representation possible? The key is estimability. To illustrate the above statements, let's reconsider your example. We have verified parametric functionals $\phi_2(\beta) = \theta_1 - \theta_3$ and $\phi_3(\beta) = \theta_2$ are estimable. Therefore, we can rewrite the model $(1)$ in terms of the reparametrized parameter $(\phi_2, \phi_3)'$ as follows \begin{equation} E[Y] = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 0 \\ 1 & - 1 \end{bmatrix} \begin{bmatrix} \phi_2 \\ \phi_3 \end{bmatrix} = \tilde{X}\gamma. \end{equation} Clearly, since $\tilde{X}$ is full-ranked, the model with the new parameter $\gamma$ is identifiable.
A problem on estimability of parameters This answer stresses the verification of estimability. The minimum variance property is of my secondary consideration. To begin with, summarize the information in terms of matrix form of a linear mode
18,628
A problem on estimability of parameters
Apply the definitions. I will provide details to demonstrate how you can use elementary techniques: you don't need to know any special theorems about estimation, nor will it be necessary to assume anything about the (marginal) distributions of the $Y_i$. We will need to supply one missing assumption about the moments of their joint distribution. Definitions All linear estimates are of the form $$t_\lambda(Y) = \sum_{i=1}^4 \lambda_i Y_i$$ for constants $\lambda = (\lambda_i)$. An estimator of $\theta_1-\theta_3$ is unbiased if and only if its expectation is $\theta_1-\theta_3$. By linearity of expectation, $$\eqalign{ \theta_1 - \theta_3 &= E[t_\lambda(Y)] = \sum_{i=1}^4 \lambda_i E[Y_i]\\ & = \lambda_1(\theta_1-\theta_3) + \lambda_2(\theta_1+\theta_2-\theta_3) + \lambda_3(\theta_1-\theta_3) + \lambda_4(\theta_1-\theta_2-\theta_3) \\ &=(\lambda_1+\lambda_2+\lambda_3+\lambda_4)(\theta_1-\theta_3) + (\lambda_2-\lambda_4)\theta_2. }$$ Comparing coefficients of the unknown quantities $\theta_i$ reveals $$\lambda_2-\lambda_4=0\text{ and }\lambda_1+\lambda_2+\lambda_3+\lambda_4=1.\tag{1}$$ In the context of linear unbiased estimation, "best" always means with least variance. The variance of $t_\lambda$ is $$\operatorname{Var}(t_\lambda) = \sum_{i=1}^4 \lambda_i^2 \operatorname{Var}(Y_i) + \sum_{i\ne j}^4 \lambda_i\lambda_j \operatorname{Cov}(Y_i,Y_j).$$ The only way to make progress is to add an assumption about the covariances: most likely, the question intended to stipulate they are all zero. (This does not imply the $Y_i$ are independent. Furthermore, the problem can be solved by making any assumption that stipulates those covariances up to a common multiplicative constant. The solution depends on the covariance structure.) Since $\operatorname{Var}(Y_i)=\sigma^2,$ we obtain $$\operatorname{Var}(t_\lambda) =\sigma^2(\lambda_1^2 + \lambda_2^2 + \lambda_3^2 + \lambda_4^2).\tag{2}$$ The problem therefore is to minimize $(2)$ subject to constraints $(1)$. Solution The constraints $(1)$ permit us to express all the $\lambda_i$ in terms of just two linear combinations of them. Let $u=\lambda_1-\lambda_3$ and $v=\lambda_1+\lambda_3$ (which are linearly independent). These determine $\lambda_1$ and $\lambda_3$ while the constraints determine $\lambda_2$ and $\lambda_4$. All we have to do is minimize $(2)$, which can be written $$\sigma^2(\lambda_1^2 + \lambda_2^2 + \lambda_3^2 + \lambda_4^2) = \frac{\sigma^2}{4}\left(2u^2 + (2v-1)^2 + 1\right).$$ No constraints apply to $(u,v)$. Assume $\sigma^2 \ne 0$ (so that the variables aren't just constants). Since $u^2$ and $(2v-1)^2$ are smallest only when $u=2v-1=0$, it is now obvious that the unique solution is $$\lambda = (\lambda_1,\lambda_2,\lambda_3,\lambda_4) = (1/4,1/4,1/4,1/4).$$ Option (C) is false because it does not give the best unbiased linear estimator. Option (D), although it doesn't give full information, nevertheless is correct, because $$\theta_2 = E[t_{(0,1/2,0,-1/2)}(Y)]$$ is the expectation of a linear estimator. It is easy to see that neither (A) nor (B) can be correct, because the space of expectations of linear estimators is generated by $\{\theta_2, \theta_1-\theta_3\}$ and none of $\theta_1,\theta_3,$ or $\theta_1+\theta_3$ are in that space. Consequently (D) is the unique correct answer.
A problem on estimability of parameters
Apply the definitions. I will provide details to demonstrate how you can use elementary techniques: you don't need to know any special theorems about estimation, nor will it be necessary to assume any
A problem on estimability of parameters Apply the definitions. I will provide details to demonstrate how you can use elementary techniques: you don't need to know any special theorems about estimation, nor will it be necessary to assume anything about the (marginal) distributions of the $Y_i$. We will need to supply one missing assumption about the moments of their joint distribution. Definitions All linear estimates are of the form $$t_\lambda(Y) = \sum_{i=1}^4 \lambda_i Y_i$$ for constants $\lambda = (\lambda_i)$. An estimator of $\theta_1-\theta_3$ is unbiased if and only if its expectation is $\theta_1-\theta_3$. By linearity of expectation, $$\eqalign{ \theta_1 - \theta_3 &= E[t_\lambda(Y)] = \sum_{i=1}^4 \lambda_i E[Y_i]\\ & = \lambda_1(\theta_1-\theta_3) + \lambda_2(\theta_1+\theta_2-\theta_3) + \lambda_3(\theta_1-\theta_3) + \lambda_4(\theta_1-\theta_2-\theta_3) \\ &=(\lambda_1+\lambda_2+\lambda_3+\lambda_4)(\theta_1-\theta_3) + (\lambda_2-\lambda_4)\theta_2. }$$ Comparing coefficients of the unknown quantities $\theta_i$ reveals $$\lambda_2-\lambda_4=0\text{ and }\lambda_1+\lambda_2+\lambda_3+\lambda_4=1.\tag{1}$$ In the context of linear unbiased estimation, "best" always means with least variance. The variance of $t_\lambda$ is $$\operatorname{Var}(t_\lambda) = \sum_{i=1}^4 \lambda_i^2 \operatorname{Var}(Y_i) + \sum_{i\ne j}^4 \lambda_i\lambda_j \operatorname{Cov}(Y_i,Y_j).$$ The only way to make progress is to add an assumption about the covariances: most likely, the question intended to stipulate they are all zero. (This does not imply the $Y_i$ are independent. Furthermore, the problem can be solved by making any assumption that stipulates those covariances up to a common multiplicative constant. The solution depends on the covariance structure.) Since $\operatorname{Var}(Y_i)=\sigma^2,$ we obtain $$\operatorname{Var}(t_\lambda) =\sigma^2(\lambda_1^2 + \lambda_2^2 + \lambda_3^2 + \lambda_4^2).\tag{2}$$ The problem therefore is to minimize $(2)$ subject to constraints $(1)$. Solution The constraints $(1)$ permit us to express all the $\lambda_i$ in terms of just two linear combinations of them. Let $u=\lambda_1-\lambda_3$ and $v=\lambda_1+\lambda_3$ (which are linearly independent). These determine $\lambda_1$ and $\lambda_3$ while the constraints determine $\lambda_2$ and $\lambda_4$. All we have to do is minimize $(2)$, which can be written $$\sigma^2(\lambda_1^2 + \lambda_2^2 + \lambda_3^2 + \lambda_4^2) = \frac{\sigma^2}{4}\left(2u^2 + (2v-1)^2 + 1\right).$$ No constraints apply to $(u,v)$. Assume $\sigma^2 \ne 0$ (so that the variables aren't just constants). Since $u^2$ and $(2v-1)^2$ are smallest only when $u=2v-1=0$, it is now obvious that the unique solution is $$\lambda = (\lambda_1,\lambda_2,\lambda_3,\lambda_4) = (1/4,1/4,1/4,1/4).$$ Option (C) is false because it does not give the best unbiased linear estimator. Option (D), although it doesn't give full information, nevertheless is correct, because $$\theta_2 = E[t_{(0,1/2,0,-1/2)}(Y)]$$ is the expectation of a linear estimator. It is easy to see that neither (A) nor (B) can be correct, because the space of expectations of linear estimators is generated by $\{\theta_2, \theta_1-\theta_3\}$ and none of $\theta_1,\theta_3,$ or $\theta_1+\theta_3$ are in that space. Consequently (D) is the unique correct answer.
A problem on estimability of parameters Apply the definitions. I will provide details to demonstrate how you can use elementary techniques: you don't need to know any special theorems about estimation, nor will it be necessary to assume any
18,629
How can Logistic Regression produce curves that aren't traditional functions?
This is an example of overfitting on the Coursera course on ML by Andrew Ng in the case of a classification model with two features $(x_1, x_2)$, in which the true values are symbolized by $\color{red}{\large \times}$ and $\color{blue}{\large\circ},$ and the decision boundary is precisely tailored to the training set through the use of high order polynomial terms. The problem that it tries to illustrate relates to the fact that, although the boundary decision line (curvilinear line in blue) doesn't mis-classify any examples, its ability to generalize out of the training set will be compromised. Andrew Ng goes on to explain that regularization can mitigate this effect, and draws the magenta curve as a decision boundary less tight to the training set, and more likely to generalize. With regards to your specific question: My intuition is that the blue/pink curve isn't really plotted on this graph but rather is a representation (circles and X's) that get mapped to values in the next dimension (3rd) of the graph. There is no height (third dimension): there are two categories, $(\large\times$ and $\large\circ),$ and the decision line shows how the model is separating them. In the simpler model $$h_\theta(x)=g\left(\theta_0 + \theta_1 \, x_1 + \theta_2 \, x_2 \right)$$ the decision boundary will be linear. Perhaps you have in mind something like this, for example: $$5 + 2 x - 1.3 x^2 -1.2 x^2 y + 1 x^2 y^2 + 3 x^2 y^3$$ However, notice that there is a $g(\cdot)$ function in the hypothesis - the logistic activation in your initial question. So for every value of $x_1$ and $x_2$ the polynomial function undergoes and "activation" (often non-linear, such in the a sigmoid function as in the OP, although not necessarily (e.g. RELU)). As a bounded output the sigmoid activation lends itself to a probabilistic interpretation: the idea in a classification model is that at a given threshold the output will be labeled $\large \times$ $\large($ or $\large \circ).$ Effectively, a continuous output will be squashed into a binary $(1,0)$ output. Depending on the weights (or parameters) and the activation function, each point $(x_1,x_2)$ in the feature plane will be mapped to either the category $\large \times$ or $\large \circ$. This labeling may or may not be correct: they will be correct when the points in the sample drawn by $\color{red}{\large \times}$ and $\color{blue}{\large \circ}$ on the plane in the picture on the OP correspond to the predicted labels. The boundaries between regions of the plane labeled $\large \times$ and those adjacent regions labeled $\large \circ$. They can be a line, or multiple lines isolating "islands" (see by yourself playing with this app by Tony Fischetti part of this blog entry on R-bloggers). Notice the entry in Wikipedia on decision boundary: In a statistical-classification problem with two classes, a decision boundary or decision surface is a hypersurface that partitions the underlying vector space into two sets, one for each class. The classifier will classify all the points on one side of the decision boundary as belonging to one class and all those on the other side as belonging to the other class. A decision boundary is the region of a problem space in which the output label of a classifier is ambiguous. There is no need for a height component to graph the actual boundary. If, on the other hand, you are plotting the sigmoid activation value (continuous with range $∈[0,1]),$ then you do need a third ("height") component to visualize the graph: If you want to introduce a $3$D visualization for the decision surface, check this slide on an online course on NN's by Hugo Larochelle, representing the activation of a neuron: where $y_1 = h_\theta(x)$, and $\mathbf W$ is the weight vector $(\Theta)$ in the example in the OP. Most interesting is the fact that $\Theta$ is orthogonal to the separating "ridge" in the classifier: effectively, if the ridge is a (hyper-)plane, the vector of weights or parameters is the normal vector. Joining multiple neurons, these separating hyperplanes can be added and subtracted to end up with capricious shapes: This links to the universal approximation theorem.
How can Logistic Regression produce curves that aren't traditional functions?
This is an example of overfitting on the Coursera course on ML by Andrew Ng in the case of a classification model with two features $(x_1, x_2)$, in which the true values are symbolized by $\color{red
How can Logistic Regression produce curves that aren't traditional functions? This is an example of overfitting on the Coursera course on ML by Andrew Ng in the case of a classification model with two features $(x_1, x_2)$, in which the true values are symbolized by $\color{red}{\large \times}$ and $\color{blue}{\large\circ},$ and the decision boundary is precisely tailored to the training set through the use of high order polynomial terms. The problem that it tries to illustrate relates to the fact that, although the boundary decision line (curvilinear line in blue) doesn't mis-classify any examples, its ability to generalize out of the training set will be compromised. Andrew Ng goes on to explain that regularization can mitigate this effect, and draws the magenta curve as a decision boundary less tight to the training set, and more likely to generalize. With regards to your specific question: My intuition is that the blue/pink curve isn't really plotted on this graph but rather is a representation (circles and X's) that get mapped to values in the next dimension (3rd) of the graph. There is no height (third dimension): there are two categories, $(\large\times$ and $\large\circ),$ and the decision line shows how the model is separating them. In the simpler model $$h_\theta(x)=g\left(\theta_0 + \theta_1 \, x_1 + \theta_2 \, x_2 \right)$$ the decision boundary will be linear. Perhaps you have in mind something like this, for example: $$5 + 2 x - 1.3 x^2 -1.2 x^2 y + 1 x^2 y^2 + 3 x^2 y^3$$ However, notice that there is a $g(\cdot)$ function in the hypothesis - the logistic activation in your initial question. So for every value of $x_1$ and $x_2$ the polynomial function undergoes and "activation" (often non-linear, such in the a sigmoid function as in the OP, although not necessarily (e.g. RELU)). As a bounded output the sigmoid activation lends itself to a probabilistic interpretation: the idea in a classification model is that at a given threshold the output will be labeled $\large \times$ $\large($ or $\large \circ).$ Effectively, a continuous output will be squashed into a binary $(1,0)$ output. Depending on the weights (or parameters) and the activation function, each point $(x_1,x_2)$ in the feature plane will be mapped to either the category $\large \times$ or $\large \circ$. This labeling may or may not be correct: they will be correct when the points in the sample drawn by $\color{red}{\large \times}$ and $\color{blue}{\large \circ}$ on the plane in the picture on the OP correspond to the predicted labels. The boundaries between regions of the plane labeled $\large \times$ and those adjacent regions labeled $\large \circ$. They can be a line, or multiple lines isolating "islands" (see by yourself playing with this app by Tony Fischetti part of this blog entry on R-bloggers). Notice the entry in Wikipedia on decision boundary: In a statistical-classification problem with two classes, a decision boundary or decision surface is a hypersurface that partitions the underlying vector space into two sets, one for each class. The classifier will classify all the points on one side of the decision boundary as belonging to one class and all those on the other side as belonging to the other class. A decision boundary is the region of a problem space in which the output label of a classifier is ambiguous. There is no need for a height component to graph the actual boundary. If, on the other hand, you are plotting the sigmoid activation value (continuous with range $∈[0,1]),$ then you do need a third ("height") component to visualize the graph: If you want to introduce a $3$D visualization for the decision surface, check this slide on an online course on NN's by Hugo Larochelle, representing the activation of a neuron: where $y_1 = h_\theta(x)$, and $\mathbf W$ is the weight vector $(\Theta)$ in the example in the OP. Most interesting is the fact that $\Theta$ is orthogonal to the separating "ridge" in the classifier: effectively, if the ridge is a (hyper-)plane, the vector of weights or parameters is the normal vector. Joining multiple neurons, these separating hyperplanes can be added and subtracted to end up with capricious shapes: This links to the universal approximation theorem.
How can Logistic Regression produce curves that aren't traditional functions? This is an example of overfitting on the Coursera course on ML by Andrew Ng in the case of a classification model with two features $(x_1, x_2)$, in which the true values are symbolized by $\color{red
18,630
How can Logistic Regression produce curves that aren't traditional functions?
We've got some heavy-duty mathematicians answering this question. I've never seen a diagram like you depict here, with the values for predictors X1 and X2 and the 'decision boundary' line separating the predicted positives from the predicted negatives. (or is it a map of predicted vs. actual outcomes?) But it is useful---as long as you have only two predictors of interest that you want to map. It appears that the magenta line separates the predicted positives from the predicted negatives, whereas the dark blue line includes all the positives. This is usually the case in logistic regression: the model will correctly predict the outcome for less than 100% of the cases (and will predict some false positives and/or false negatives). It's possible to run logistic regression and have the procedure produce the function h(x) for each individual case in the dataset. This will produce a propensity score for each subject, from 0 to 1, that gives the predicted likelihood or probability of the positive outcome for each subject based on that subject's predictor variables, based on the logistic regression model using all subjects. Those at the propensity score cutoff of 0.5 or above are predicted to have the outcome, and those below 0.5 are predicted to not have the outcome. But you can adjust this cutoff level as you see fit, for example to make a diagnostic prediction model of some outcome based on all the input variables that are entered in your logistic regression analysis. You can set the cutoff at 0.3 for example. You can then do a 2X2 table of predicted-vs-actual outcomes, and determine your sensitivity, specificity, false positive rate and false negative rate of the model based on this cutoff level. This provides more information and also frees you from the limit of 2 variables used in your graph. You can use as many predictors as you can reasonably fit in the model and still make a 2X2 table of actual-vs-predicted outcome. Since logistic regression uses categorical (yes-no) outcomes, each cell in the 2X2 table is simply a count of the subjects that meet the row and column criteria. In the graph you provide, it probably assumes a cutoff of 0.5. This is the common default for software. If you adjusted it higher (to 0.65 for example), it might include all the O's inside the line but you would also have some false positives (X's that it thinks should be O's) that would be predicted by the model to have the outcome of interest. (or adjust the cutoff score lower and have more false negatives). I hope this helps.
How can Logistic Regression produce curves that aren't traditional functions?
We've got some heavy-duty mathematicians answering this question. I've never seen a diagram like you depict here, with the values for predictors X1 and X2 and the 'decision boundary' line separating
How can Logistic Regression produce curves that aren't traditional functions? We've got some heavy-duty mathematicians answering this question. I've never seen a diagram like you depict here, with the values for predictors X1 and X2 and the 'decision boundary' line separating the predicted positives from the predicted negatives. (or is it a map of predicted vs. actual outcomes?) But it is useful---as long as you have only two predictors of interest that you want to map. It appears that the magenta line separates the predicted positives from the predicted negatives, whereas the dark blue line includes all the positives. This is usually the case in logistic regression: the model will correctly predict the outcome for less than 100% of the cases (and will predict some false positives and/or false negatives). It's possible to run logistic regression and have the procedure produce the function h(x) for each individual case in the dataset. This will produce a propensity score for each subject, from 0 to 1, that gives the predicted likelihood or probability of the positive outcome for each subject based on that subject's predictor variables, based on the logistic regression model using all subjects. Those at the propensity score cutoff of 0.5 or above are predicted to have the outcome, and those below 0.5 are predicted to not have the outcome. But you can adjust this cutoff level as you see fit, for example to make a diagnostic prediction model of some outcome based on all the input variables that are entered in your logistic regression analysis. You can set the cutoff at 0.3 for example. You can then do a 2X2 table of predicted-vs-actual outcomes, and determine your sensitivity, specificity, false positive rate and false negative rate of the model based on this cutoff level. This provides more information and also frees you from the limit of 2 variables used in your graph. You can use as many predictors as you can reasonably fit in the model and still make a 2X2 table of actual-vs-predicted outcome. Since logistic regression uses categorical (yes-no) outcomes, each cell in the 2X2 table is simply a count of the subjects that meet the row and column criteria. In the graph you provide, it probably assumes a cutoff of 0.5. This is the common default for software. If you adjusted it higher (to 0.65 for example), it might include all the O's inside the line but you would also have some false positives (X's that it thinks should be O's) that would be predicted by the model to have the outcome of interest. (or adjust the cutoff score lower and have more false negatives). I hope this helps.
How can Logistic Regression produce curves that aren't traditional functions? We've got some heavy-duty mathematicians answering this question. I've never seen a diagram like you depict here, with the values for predictors X1 and X2 and the 'decision boundary' line separating
18,631
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
Possibly because some of the earliest machine learning algorithms were implemented as actual physical machines. From Wikipedia: The perceptron was intended to be a machine, rather than a program, and while its first implementation was in software for the IBM 704, it was subsequently implemented in custom-built hardware as the "Mark 1 perceptron". (Picture from Cornell Library via Wikipedia) ADALINE (Adaptive Lineardi Neuron or later Adaptive Linear Element) is an early single-layer artificial neural network and the name of the physical device that implemented this network. A source for more information about these machines is the book Talking Nets.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
Possibly because some of the earliest machine learning algorithms were implemented as actual physical machines. From Wikipedia: The perceptron was intended to be a machine, rather than a program, a
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? Possibly because some of the earliest machine learning algorithms were implemented as actual physical machines. From Wikipedia: The perceptron was intended to be a machine, rather than a program, and while its first implementation was in software for the IBM 704, it was subsequently implemented in custom-built hardware as the "Mark 1 perceptron". (Picture from Cornell Library via Wikipedia) ADALINE (Adaptive Lineardi Neuron or later Adaptive Linear Element) is an early single-layer artificial neural network and the name of the physical device that implemented this network. A source for more information about these machines is the book Talking Nets.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? Possibly because some of the earliest machine learning algorithms were implemented as actual physical machines. From Wikipedia: The perceptron was intended to be a machine, rather than a program, a
18,632
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
I think this article sums it up. Basically, machine comes from machine learning, a term that was coined in 1959 by Arthur Samuel, way before the final developments that led to the soft marging kernel SVM in the 90's and the Boltzmann Machines in the 80's. Vapnik and Lerner called their algorithm the Generalized Portrait algorithm back in 1963, see more here. A machine in this context would be the output function, or as the article puts for historical reasons, the hypothesis, built from the learned parameters.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
I think this article sums it up. Basically, machine comes from machine learning, a term that was coined in 1959 by Arthur Samuel, way before the final developments that led to the soft marging kernel
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? I think this article sums it up. Basically, machine comes from machine learning, a term that was coined in 1959 by Arthur Samuel, way before the final developments that led to the soft marging kernel SVM in the 90's and the Boltzmann Machines in the 80's. Vapnik and Lerner called their algorithm the Generalized Portrait algorithm back in 1963, see more here. A machine in this context would be the output function, or as the article puts for historical reasons, the hypothesis, built from the learned parameters.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? I think this article sums it up. Basically, machine comes from machine learning, a term that was coined in 1959 by Arthur Samuel, way before the final developments that led to the soft marging kernel
18,633
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
Meriam-Webster defines the word as "a literary device or contrivance introduced for dramatic effect." It certainly does the job of increasing the dramatic effect. "Support vector algorithm/approach/equation/function/..." just doesn't sound as good as "support vector MACHINE!" I would also suggest "kernel density machine" and "maximum likelihood machine." Actually, I'm going to call all my algorithms "machines" from now on.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean?
Meriam-Webster defines the word as "a literary device or contrivance introduced for dramatic effect." It certainly does the job of increasing the dramatic effect. "Support vector algorithm/approach/eq
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? Meriam-Webster defines the word as "a literary device or contrivance introduced for dramatic effect." It certainly does the job of increasing the dramatic effect. "Support vector algorithm/approach/equation/function/..." just doesn't sound as good as "support vector MACHINE!" I would also suggest "kernel density machine" and "maximum likelihood machine." Actually, I'm going to call all my algorithms "machines" from now on.
What does the "machine" in "support vector machine" and "restricted Boltzmann machine" mean? Meriam-Webster defines the word as "a literary device or contrivance introduced for dramatic effect." It certainly does the job of increasing the dramatic effect. "Support vector algorithm/approach/eq
18,634
Is teacher forcing more accurate than using actual model output or just faster?
I'll begin by saying I'm no expert but was thinking about this same question. A little googling led me to this page: https://machinelearningmastery.com/teacher-forcing-for-recurrent-neural-networks/ and, in turn, this paper: https://arxiv.org/abs/1610.09038 which as a paragraph addressing this to some degree in the introduction: Unfortunately, [teacher forcing] can result in problems in generation as small prediction error compound in the conditioning context. This can lead to poor prediction performance as the RNN’s conditioning context (the sequence of previously generated samples) diverge from sequences seen during training In addition, from the deeplearning.org book, 10, p.378: The disadvantage of strict teacher forcing arises if the network is going to be later used in a closed-loop mode, with the network outputs (or samples from the output distribution) fed back as input. In this case, the fed-back inputs that the network sees during training could be quite different from the kind of inputs that it will see at test time. I would imagine (again, not an expert) that it is fairly problem-dependent, but that the main gain of teacher forcing is in the computational training and simplifying the loss landscape (i.e. since the whole sequence will contribute to the gradient of the parameters, for long sequences backpropagation through time may make it difficult for the optimiser to converge even if it has a lot of computational time.)
Is teacher forcing more accurate than using actual model output or just faster?
I'll begin by saying I'm no expert but was thinking about this same question. A little googling led me to this page: https://machinelearningmastery.com/teacher-forcing-for-recurrent-neural-networks/ a
Is teacher forcing more accurate than using actual model output or just faster? I'll begin by saying I'm no expert but was thinking about this same question. A little googling led me to this page: https://machinelearningmastery.com/teacher-forcing-for-recurrent-neural-networks/ and, in turn, this paper: https://arxiv.org/abs/1610.09038 which as a paragraph addressing this to some degree in the introduction: Unfortunately, [teacher forcing] can result in problems in generation as small prediction error compound in the conditioning context. This can lead to poor prediction performance as the RNN’s conditioning context (the sequence of previously generated samples) diverge from sequences seen during training In addition, from the deeplearning.org book, 10, p.378: The disadvantage of strict teacher forcing arises if the network is going to be later used in a closed-loop mode, with the network outputs (or samples from the output distribution) fed back as input. In this case, the fed-back inputs that the network sees during training could be quite different from the kind of inputs that it will see at test time. I would imagine (again, not an expert) that it is fairly problem-dependent, but that the main gain of teacher forcing is in the computational training and simplifying the loss landscape (i.e. since the whole sequence will contribute to the gradient of the parameters, for long sequences backpropagation through time may make it difficult for the optimiser to converge even if it has a lot of computational time.)
Is teacher forcing more accurate than using actual model output or just faster? I'll begin by saying I'm no expert but was thinking about this same question. A little googling led me to this page: https://machinelearningmastery.com/teacher-forcing-for-recurrent-neural-networks/ a
18,635
Is teacher forcing more accurate than using actual model output or just faster?
You might want to read this paper: https://arxiv.org/abs/1905.10617 "Exposure bias has been regarded as a central problem for auto-regressive language models (LM). It claims that teacher forcing would cause the test-time generation to be incrementally distorted due to the training-generation discrepancy. Although a lot of algorithms have been proposed to avoid teacher forcing and therefore alleviate exposure bias, there is little work showing how serious the exposure bias problem actually is. In this work, we focus on the task of open-ended language generation, propose metrics to quantify the impact of exposure bias in the aspects of quality, diversity, and consistency. Our key intuition is that if we feed ground-truth data prefixes (instead of prefixes generated by the model itself) into the model and ask it to continue the generation, the performance should become much better because the training-generation discrepancy in the prefix is removed. Both automatic and human evaluations are conducted in our experiments. On the contrary to the popular belief in exposure bias, we find that the the distortion induced by the prefix discrepancy is limited, and does not seem to be incremental during the generation. Moreover, our analysis reveals an interesting self-recovery ability of the LM, which we hypothesize to be countering the harmful effects from exposure bias"
Is teacher forcing more accurate than using actual model output or just faster?
You might want to read this paper: https://arxiv.org/abs/1905.10617 "Exposure bias has been regarded as a central problem for auto-regressive language models (LM). It claims that teacher forcing would
Is teacher forcing more accurate than using actual model output or just faster? You might want to read this paper: https://arxiv.org/abs/1905.10617 "Exposure bias has been regarded as a central problem for auto-regressive language models (LM). It claims that teacher forcing would cause the test-time generation to be incrementally distorted due to the training-generation discrepancy. Although a lot of algorithms have been proposed to avoid teacher forcing and therefore alleviate exposure bias, there is little work showing how serious the exposure bias problem actually is. In this work, we focus on the task of open-ended language generation, propose metrics to quantify the impact of exposure bias in the aspects of quality, diversity, and consistency. Our key intuition is that if we feed ground-truth data prefixes (instead of prefixes generated by the model itself) into the model and ask it to continue the generation, the performance should become much better because the training-generation discrepancy in the prefix is removed. Both automatic and human evaluations are conducted in our experiments. On the contrary to the popular belief in exposure bias, we find that the the distortion induced by the prefix discrepancy is limited, and does not seem to be incremental during the generation. Moreover, our analysis reveals an interesting self-recovery ability of the LM, which we hypothesize to be countering the harmful effects from exposure bias"
Is teacher forcing more accurate than using actual model output or just faster? You might want to read this paper: https://arxiv.org/abs/1905.10617 "Exposure bias has been regarded as a central problem for auto-regressive language models (LM). It claims that teacher forcing would
18,636
Example of heavy-tailed distribution that is not long-tailed
The two definitions are close, but not exactly the same. One difference lies in the need for the survival ratio to have a limit. For most of this answer I will ignore the criteria for the distribution to be continuous, symmetric, and of finite variance, because these are easy to accomplish once we have found any finite-variance heavy-tailed distribution that is not long-tailed. A distribution $F$ is heavy-tailed when for any $t\gt 0$, $$\int_\mathbb{R} e^{t x} dF(x) = \infty.\tag{1}$$ A distribution with survival function $G_F = 1-F$ is long-tailed when $$\lim_{x\to \infty} \frac{G_F(x+1)}{G_F(x)} = 1.\tag{2}$$ Long-tailed distributions are heavy. Furthermore, because $G$ is nonincreasing, the limit of the ratio $(2)$ cannot exceed $1$. If it exists and is less than $1$, then $G$ is decreasing exponentially--and that will allow the integral $(1)$ to converge. The only way to exhibit a heavy-tailed distribution that is not long-tailed, then, is to modify a long-tailed distribution so that $(1)$ continues to hold while $(2)$ is violated. It's easy to screw up a limit: change it in infinitely many places that diverge to infinity. That will take some doing with $F$, though, which must remain increasing and cadlag. One way is to introduce some upward jumps in $F$, which will make $G$ jump downwards, lowering the ratio $G_F(x+1)/G_F(x)$. To this end, let's define a transformation $T_u$ that turns $F$ into another valid distribution function while creating a sudden jump at the value $u$, say a jump halfway from $F(u)$ to $1$: $$T_u[F](x) = \begin{cases} F(x) & u<x \\ \frac{1}{2} (1-F(x))+F(x) & u\geq x \end{cases}$$ This alters no basic property of $F$: $T_u[F]$ is still a distribution function. The effect on $G_F$ is to make it drop by a factor of $1/2$ at $u$. Therefore, since $G$ is non-decreasing, then whenever $u-1 \le x \lt u$, $$\frac{G_{T_u[F]}(x + 1)}{G_{T_u[F]}(x )} \le \frac{1}{2}.$$ If we pick an increasing and diverging sequence of $u_i$, $i=1, 2, \ldots$, and apply each $T_{u_i}$ in succession, it determines a sequence of distributions $F_i$ with $F_0=F$ and $$F_{i+1} = T_{u_i}[F_i]$$ for $i \ge 1$. After the $i^\text{th}$ step, $F_i(x), F_{i+1}(x), \ldots$ all remain the same for $x\lt u_i$. Consequently the sequence of $F_i(x)$ is a nondecreasing, bounded, pointwise sequence of distribution functions, implying its limit $$F_\infty = \lim_{i\to\infty} F_i$$ is a distribution function. By construction, it is not long-tailed because there are infinitely many points at which its survival ratio $G_{F_\infty}(x+1)/G_{F_\infty}(x))$ drops to $1/2$ or below, showing it cannot have $1$ as a limit. This plot shows a survival function $G(x) = x^{-1/5}$ that has been cut down in this manner at points $u_1 \approx 12.9, u_2 \approx 40.5, u_3 \approx 101.6, \ldots.$ Note the logarithmic vertical axis. The hope is to be able to choose $(u_i)$ so that $F_\infty$ remains heavy-tailed. We know, because $F$ is heavy-tailed, that there are numbers $0 = u_0 \lt u_1 \lt u_2 \lt \cdots \lt u_n \cdots$ for which $$\int_{u_{i-1}}^{u_i} e^{x/i} dF(x) \ge 2^{i-1}$$ for every $i \ge 1$. The reason for the $2^{i-1}$ on the right is that the probabilities assigned by $F$ to values up to $u_i$ have been successively cut in half $i-1$ times. That procedure, when $dF(x)$ is replaced by $dF_{j}(x)$ for any $j\ge i$, will reduce $2^{i-1}$ to $1$, but no lower. This is a plot of $x f(x)$ for densities $f$ corresponding to the previous survival function and its "cut down" version. The areas under this curve contribute to the expectation. The area from $1$ to $u_1$ is $1$; the area from $u_1$ to $u_2$ is $2$, which when cut down (to the lower blue portion) becomes an area of $1$; the area from $u_2$ to $u_3$ is $4$, which when cut down becomes an area of $1$, and so on. Thus, the area under each successive "stair step" to the right is $1$. Let us pick such a sequence $(u_i)$ to define $F_\infty$. We can check that it remains heavy-tailed by picking $t=1/n$ for some whole number $n$ and applying the construction: $$\eqalign{ \int_\mathbb{R} e^{t x} dF_\infty(x) &=\int_\mathbb{R} e^{x/n} dF_\infty(x) \\ &= \sum_{i=1}^\infty \int_{u_{i-1}}^{u_i} e^{x/n} dF_\infty(x) \\ &\ge \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/n} dF_\infty(x) \\ &\ge \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/i} dF_\infty(x) \\ &= \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/i} dF_i(x) \\ &\ge \sum_{i=n+1}^\infty 1, }$$ which still diverges. Since $t$ is arbitrarily small, this demonstrates that $F_\infty$ remains heavy-tailed, even though its long-tailed property has been destroyed. This is a plot of the survival ratio $G(x+1)/G(x)$ for the cut down distribution. Like the ratio of the original $G$, it tends toward an upper accumulation value of $1$--but for unit-width intervals terminating at the $u_i$, the ratio suddenly drops to only half of what it originally was. These drops, although becoming less and less frequent as $x$ increases, occur infinitely often and therefore prevent the ratio from approaching $1$ in the limit. If you would like a continuous, symmetric, zero-mean, unit-variance example, begin with a finite-variance long-tailed distribution. $F(x) = 1 - x^{-p}$ (for $x \gt 0$) will do, provided $p \gt 1$; so would a Student t distribution for any degrees of freedom exceeding $2$. The moments of $F_\infty$ cannot exceed those of $F$, whence it too has finite variance. "Mollify" it via convolution with a nice smooth distribution, such as a Gaussian: this will make it continuous but will not destroy its heavy tail (obviously) nor the absence of a long tail (not quite as obvious, but it becomes obvious if you change the Gaussian to, say, a Beta distribution whose support is compact). Symmetrize the result--which I will still call $F_\infty$--by defining $$F_s(x) = \frac{1}{2}\left(1 + \text{sgn}(x) F_\infty(|x|)\right)$$ for all $x\in\mathbb{R}$. Its variance will remain finite, so it can be standardized to the desired distribution.
Example of heavy-tailed distribution that is not long-tailed
The two definitions are close, but not exactly the same. One difference lies in the need for the survival ratio to have a limit. For most of this answer I will ignore the criteria for the distributio
Example of heavy-tailed distribution that is not long-tailed The two definitions are close, but not exactly the same. One difference lies in the need for the survival ratio to have a limit. For most of this answer I will ignore the criteria for the distribution to be continuous, symmetric, and of finite variance, because these are easy to accomplish once we have found any finite-variance heavy-tailed distribution that is not long-tailed. A distribution $F$ is heavy-tailed when for any $t\gt 0$, $$\int_\mathbb{R} e^{t x} dF(x) = \infty.\tag{1}$$ A distribution with survival function $G_F = 1-F$ is long-tailed when $$\lim_{x\to \infty} \frac{G_F(x+1)}{G_F(x)} = 1.\tag{2}$$ Long-tailed distributions are heavy. Furthermore, because $G$ is nonincreasing, the limit of the ratio $(2)$ cannot exceed $1$. If it exists and is less than $1$, then $G$ is decreasing exponentially--and that will allow the integral $(1)$ to converge. The only way to exhibit a heavy-tailed distribution that is not long-tailed, then, is to modify a long-tailed distribution so that $(1)$ continues to hold while $(2)$ is violated. It's easy to screw up a limit: change it in infinitely many places that diverge to infinity. That will take some doing with $F$, though, which must remain increasing and cadlag. One way is to introduce some upward jumps in $F$, which will make $G$ jump downwards, lowering the ratio $G_F(x+1)/G_F(x)$. To this end, let's define a transformation $T_u$ that turns $F$ into another valid distribution function while creating a sudden jump at the value $u$, say a jump halfway from $F(u)$ to $1$: $$T_u[F](x) = \begin{cases} F(x) & u<x \\ \frac{1}{2} (1-F(x))+F(x) & u\geq x \end{cases}$$ This alters no basic property of $F$: $T_u[F]$ is still a distribution function. The effect on $G_F$ is to make it drop by a factor of $1/2$ at $u$. Therefore, since $G$ is non-decreasing, then whenever $u-1 \le x \lt u$, $$\frac{G_{T_u[F]}(x + 1)}{G_{T_u[F]}(x )} \le \frac{1}{2}.$$ If we pick an increasing and diverging sequence of $u_i$, $i=1, 2, \ldots$, and apply each $T_{u_i}$ in succession, it determines a sequence of distributions $F_i$ with $F_0=F$ and $$F_{i+1} = T_{u_i}[F_i]$$ for $i \ge 1$. After the $i^\text{th}$ step, $F_i(x), F_{i+1}(x), \ldots$ all remain the same for $x\lt u_i$. Consequently the sequence of $F_i(x)$ is a nondecreasing, bounded, pointwise sequence of distribution functions, implying its limit $$F_\infty = \lim_{i\to\infty} F_i$$ is a distribution function. By construction, it is not long-tailed because there are infinitely many points at which its survival ratio $G_{F_\infty}(x+1)/G_{F_\infty}(x))$ drops to $1/2$ or below, showing it cannot have $1$ as a limit. This plot shows a survival function $G(x) = x^{-1/5}$ that has been cut down in this manner at points $u_1 \approx 12.9, u_2 \approx 40.5, u_3 \approx 101.6, \ldots.$ Note the logarithmic vertical axis. The hope is to be able to choose $(u_i)$ so that $F_\infty$ remains heavy-tailed. We know, because $F$ is heavy-tailed, that there are numbers $0 = u_0 \lt u_1 \lt u_2 \lt \cdots \lt u_n \cdots$ for which $$\int_{u_{i-1}}^{u_i} e^{x/i} dF(x) \ge 2^{i-1}$$ for every $i \ge 1$. The reason for the $2^{i-1}$ on the right is that the probabilities assigned by $F$ to values up to $u_i$ have been successively cut in half $i-1$ times. That procedure, when $dF(x)$ is replaced by $dF_{j}(x)$ for any $j\ge i$, will reduce $2^{i-1}$ to $1$, but no lower. This is a plot of $x f(x)$ for densities $f$ corresponding to the previous survival function and its "cut down" version. The areas under this curve contribute to the expectation. The area from $1$ to $u_1$ is $1$; the area from $u_1$ to $u_2$ is $2$, which when cut down (to the lower blue portion) becomes an area of $1$; the area from $u_2$ to $u_3$ is $4$, which when cut down becomes an area of $1$, and so on. Thus, the area under each successive "stair step" to the right is $1$. Let us pick such a sequence $(u_i)$ to define $F_\infty$. We can check that it remains heavy-tailed by picking $t=1/n$ for some whole number $n$ and applying the construction: $$\eqalign{ \int_\mathbb{R} e^{t x} dF_\infty(x) &=\int_\mathbb{R} e^{x/n} dF_\infty(x) \\ &= \sum_{i=1}^\infty \int_{u_{i-1}}^{u_i} e^{x/n} dF_\infty(x) \\ &\ge \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/n} dF_\infty(x) \\ &\ge \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/i} dF_\infty(x) \\ &= \sum_{i=n+1}^\infty \int_{u_{i-1}}^{u_i} e^{x/i} dF_i(x) \\ &\ge \sum_{i=n+1}^\infty 1, }$$ which still diverges. Since $t$ is arbitrarily small, this demonstrates that $F_\infty$ remains heavy-tailed, even though its long-tailed property has been destroyed. This is a plot of the survival ratio $G(x+1)/G(x)$ for the cut down distribution. Like the ratio of the original $G$, it tends toward an upper accumulation value of $1$--but for unit-width intervals terminating at the $u_i$, the ratio suddenly drops to only half of what it originally was. These drops, although becoming less and less frequent as $x$ increases, occur infinitely often and therefore prevent the ratio from approaching $1$ in the limit. If you would like a continuous, symmetric, zero-mean, unit-variance example, begin with a finite-variance long-tailed distribution. $F(x) = 1 - x^{-p}$ (for $x \gt 0$) will do, provided $p \gt 1$; so would a Student t distribution for any degrees of freedom exceeding $2$. The moments of $F_\infty$ cannot exceed those of $F$, whence it too has finite variance. "Mollify" it via convolution with a nice smooth distribution, such as a Gaussian: this will make it continuous but will not destroy its heavy tail (obviously) nor the absence of a long tail (not quite as obvious, but it becomes obvious if you change the Gaussian to, say, a Beta distribution whose support is compact). Symmetrize the result--which I will still call $F_\infty$--by defining $$F_s(x) = \frac{1}{2}\left(1 + \text{sgn}(x) F_\infty(|x|)\right)$$ for all $x\in\mathbb{R}$. Its variance will remain finite, so it can be standardized to the desired distribution.
Example of heavy-tailed distribution that is not long-tailed The two definitions are close, but not exactly the same. One difference lies in the need for the survival ratio to have a limit. For most of this answer I will ignore the criteria for the distributio
18,637
What is a partial F-statistic?
The partial F-test is the most common method of testing for a nested normal linear regression model. "Nested" model is just a fancy way of saying a reduced model in terms of variables included. For illustration, suppose that you wish to test the hypothesis that $p$ coefficients are zero, and thus these variables can be omitted from the model, and you also have $k$ coefficients in the full model(including the intercept). The test is based on the comparison of the Residual Sum of Squares(RSS) and thus you need to run two separate regressions and save the RSS from each one. For the full model the RSS will be lower since the addition of new vabiables invariably leads to a reduction of the RSS (and an increase in the Explained Sum of Squares, this is closely related to $R^2$). What we are testing therefore is whether the difference is so large that the removal of the variables will be detrimental to the model. Let's be a little more specific. The test takes the following form $$F=\frac{\frac{RSS_{Reduced}-RSS_{Full}}{p}}{\frac{RSS_{Full}}{n-k}}$$ It can be shown that the variables in the numerator and the denominator when scaled by $\frac{1}{\sigma^2}$ are independent $\chi^2$ variables with degrees of freedom $p$ and $n-k$ respectively, hence the ratio is an F-distributed random variable with parameters $p$ and $n-k$. You reject the null hypothesis that the reduced model is appropriate if the statistic exceeds a critical value from the said distribution which in turn will happen if your model loses too much explanatory power after removing the variables. The statistic can actually be derived from a likelihood ratio point of view and therefore has some good properties when the standard assumptions of the linear model are met, for instance constant variance, normality and so on. It is also more powerful than a series of individual tests, not to mention that it has the desired level of significance.
What is a partial F-statistic?
The partial F-test is the most common method of testing for a nested normal linear regression model. "Nested" model is just a fancy way of saying a reduced model in terms of variables included. For il
What is a partial F-statistic? The partial F-test is the most common method of testing for a nested normal linear regression model. "Nested" model is just a fancy way of saying a reduced model in terms of variables included. For illustration, suppose that you wish to test the hypothesis that $p$ coefficients are zero, and thus these variables can be omitted from the model, and you also have $k$ coefficients in the full model(including the intercept). The test is based on the comparison of the Residual Sum of Squares(RSS) and thus you need to run two separate regressions and save the RSS from each one. For the full model the RSS will be lower since the addition of new vabiables invariably leads to a reduction of the RSS (and an increase in the Explained Sum of Squares, this is closely related to $R^2$). What we are testing therefore is whether the difference is so large that the removal of the variables will be detrimental to the model. Let's be a little more specific. The test takes the following form $$F=\frac{\frac{RSS_{Reduced}-RSS_{Full}}{p}}{\frac{RSS_{Full}}{n-k}}$$ It can be shown that the variables in the numerator and the denominator when scaled by $\frac{1}{\sigma^2}$ are independent $\chi^2$ variables with degrees of freedom $p$ and $n-k$ respectively, hence the ratio is an F-distributed random variable with parameters $p$ and $n-k$. You reject the null hypothesis that the reduced model is appropriate if the statistic exceeds a critical value from the said distribution which in turn will happen if your model loses too much explanatory power after removing the variables. The statistic can actually be derived from a likelihood ratio point of view and therefore has some good properties when the standard assumptions of the linear model are met, for instance constant variance, normality and so on. It is also more powerful than a series of individual tests, not to mention that it has the desired level of significance.
What is a partial F-statistic? The partial F-test is the most common method of testing for a nested normal linear regression model. "Nested" model is just a fancy way of saying a reduced model in terms of variables included. For il
18,638
Why we need trace plot for MCMC results
You create the parameter trace plots to make sure that your a priori distribution is well calibrated which is indicated by your parameters having sufficient state changes as the MCMC algorithm runs. An extreme example is that you set your a priori distribution variance at 0. Then the posterior parameter estimate will never change. Your algorithm would say that you have the best parameter estimate, but it didn't check a sufficient number of parameters to determine if this truly is the best fit. If you set the a priori distribution variance too high, you get a similar problem. This is because the new parameter is less likely to be related to your data - so the log likelihood calculated with your new parameter is not likely to be better than the log likelihood using the old parameter. (An example is if your "true" parameter is 0.5 and your initial estimate is 2, but you are selecting from a normal distribution with a mean of 2 and a variance of 10,000 then you are unlikely to get a parameter that is closer to 1.5 than your initial estimate of 2.) You need to select an a priori variance that allows your parameter states to change enough that you don't get stuck on local minimums and maximums in the loglikelihood distribution, but yet fine enough that you get reasonable parameter estimates. Most literature suggests you get your parameters to change states 40-60% of the time. One other reason for the trace plots is burn in. Usually the burn in period is obvious in the plot (for example, if the true parameter is 1.5 and your initial estimate is 4 then you should see the parameter estimates moving quickly from 4 to 1.5 and then "bouncing" around 1.5). Typically, you just exclude the first n iterations where n is large enough that you are certain to have removed the burn in (say 1000), but if the calculations are time consuming or if your parameter estimates are taking much longer to converge than your n allows then you may want to omit more or less observations to account for burn in. You can check your plots to see where the burn in period ends to make sure that burn in is not affecting your results. Note that I have been talking in context of parameter point estimates. If you are estimating parameter variance then ensuring that you have appropriate state changes is even more important.
Why we need trace plot for MCMC results
You create the parameter trace plots to make sure that your a priori distribution is well calibrated which is indicated by your parameters having sufficient state changes as the MCMC algorithm runs.
Why we need trace plot for MCMC results You create the parameter trace plots to make sure that your a priori distribution is well calibrated which is indicated by your parameters having sufficient state changes as the MCMC algorithm runs. An extreme example is that you set your a priori distribution variance at 0. Then the posterior parameter estimate will never change. Your algorithm would say that you have the best parameter estimate, but it didn't check a sufficient number of parameters to determine if this truly is the best fit. If you set the a priori distribution variance too high, you get a similar problem. This is because the new parameter is less likely to be related to your data - so the log likelihood calculated with your new parameter is not likely to be better than the log likelihood using the old parameter. (An example is if your "true" parameter is 0.5 and your initial estimate is 2, but you are selecting from a normal distribution with a mean of 2 and a variance of 10,000 then you are unlikely to get a parameter that is closer to 1.5 than your initial estimate of 2.) You need to select an a priori variance that allows your parameter states to change enough that you don't get stuck on local minimums and maximums in the loglikelihood distribution, but yet fine enough that you get reasonable parameter estimates. Most literature suggests you get your parameters to change states 40-60% of the time. One other reason for the trace plots is burn in. Usually the burn in period is obvious in the plot (for example, if the true parameter is 1.5 and your initial estimate is 4 then you should see the parameter estimates moving quickly from 4 to 1.5 and then "bouncing" around 1.5). Typically, you just exclude the first n iterations where n is large enough that you are certain to have removed the burn in (say 1000), but if the calculations are time consuming or if your parameter estimates are taking much longer to converge than your n allows then you may want to omit more or less observations to account for burn in. You can check your plots to see where the burn in period ends to make sure that burn in is not affecting your results. Note that I have been talking in context of parameter point estimates. If you are estimating parameter variance then ensuring that you have appropriate state changes is even more important.
Why we need trace plot for MCMC results You create the parameter trace plots to make sure that your a priori distribution is well calibrated which is indicated by your parameters having sufficient state changes as the MCMC algorithm runs.
18,639
Ridge & LASSO norms
There are lots of penalized approaches that have all kinds of different penalty functions now (ridge, lasso, MCP, SCAD). The question of why is one of a particular form is basically "what advantages/disadvantages does such a penalty provide?". Properties of interest might be: 1) nearly unbiased estimators (note all penalized estimators will be biased) 2) Sparsity (note ridge regression does not produce sparse results i.e. it does not shrink coefficients all the way to zero) 3) Continuity (to avoid instability in model prediction) These are just a few properties one might be interested in a penalty function. It is a lot easier to work with a sum in derivations and theoretical work: e.g. $||\beta||_2^2=\sum |\beta_i|^2$ and $||\beta||_1 = \sum |\beta_i|$. Imagine if we had $\sqrt{\left(\sum |\beta_i|^2\right)}$ or $\left( \sum |\beta_i|\right)^2$. Taking derivatives (which is necessary to show theoretical results like consistency, asymptotic normality etc) would be a pain with penalties like that.
Ridge & LASSO norms
There are lots of penalized approaches that have all kinds of different penalty functions now (ridge, lasso, MCP, SCAD). The question of why is one of a particular form is basically "what advantages/d
Ridge & LASSO norms There are lots of penalized approaches that have all kinds of different penalty functions now (ridge, lasso, MCP, SCAD). The question of why is one of a particular form is basically "what advantages/disadvantages does such a penalty provide?". Properties of interest might be: 1) nearly unbiased estimators (note all penalized estimators will be biased) 2) Sparsity (note ridge regression does not produce sparse results i.e. it does not shrink coefficients all the way to zero) 3) Continuity (to avoid instability in model prediction) These are just a few properties one might be interested in a penalty function. It is a lot easier to work with a sum in derivations and theoretical work: e.g. $||\beta||_2^2=\sum |\beta_i|^2$ and $||\beta||_1 = \sum |\beta_i|$. Imagine if we had $\sqrt{\left(\sum |\beta_i|^2\right)}$ or $\left( \sum |\beta_i|\right)^2$. Taking derivatives (which is necessary to show theoretical results like consistency, asymptotic normality etc) would be a pain with penalties like that.
Ridge & LASSO norms There are lots of penalized approaches that have all kinds of different penalty functions now (ridge, lasso, MCP, SCAD). The question of why is one of a particular form is basically "what advantages/d
18,640
Ridge & LASSO norms
Actually both the square of the $\ell_2$-norm and the $\ell_1$-norm come from a same class of regularization: $\|\boldsymbol{\beta}\|_p^p$ when $p > 0$. The Ridge regression is then using $p=2$, and the Lasso $p=1$ but one can use other values of $p$. For example you have sparse solution for all values of $p \leq 1$, and the smaller the value of $p$ the sparser the solution. For values of $p \leq 1$ your objective is no more smooth so the optimization become harder; for $p<1$ the objective is non-convex and so the optimization even harder...
Ridge & LASSO norms
Actually both the square of the $\ell_2$-norm and the $\ell_1$-norm come from a same class of regularization: $\|\boldsymbol{\beta}\|_p^p$ when $p > 0$. The Ridge regression is then using $p=2$, and t
Ridge & LASSO norms Actually both the square of the $\ell_2$-norm and the $\ell_1$-norm come from a same class of regularization: $\|\boldsymbol{\beta}\|_p^p$ when $p > 0$. The Ridge regression is then using $p=2$, and the Lasso $p=1$ but one can use other values of $p$. For example you have sparse solution for all values of $p \leq 1$, and the smaller the value of $p$ the sparser the solution. For values of $p \leq 1$ your objective is no more smooth so the optimization become harder; for $p<1$ the objective is non-convex and so the optimization even harder...
Ridge & LASSO norms Actually both the square of the $\ell_2$-norm and the $\ell_1$-norm come from a same class of regularization: $\|\boldsymbol{\beta}\|_p^p$ when $p > 0$. The Ridge regression is then using $p=2$, and t
18,641
Ridge & LASSO norms
I believe there is an even simpler answer here, although "why" questions are always hard to answer when a technique is developed. The squared $l_2$-norm is used so that the regularization term is easily differentiable. Ridge regression minimizes: $$\|\mathbf{y - X\beta}\|^2_2+\lambda\|\beta\|_2^2$$ Which can also be written: $$\|\mathbf{y - X\beta}\|^2_2+\lambda\beta^T\beta$$ This can now be easily differentiated wrt $\beta$ to get the closed-form solution: $$\hat\beta^{\text{ridge}} = (\mathbf{X}^T\mathbf{X} + \lambda I)^{-1}\mathbf{X}^T\mathbf{y}$$ from which all kinda of inference can be derived.
Ridge & LASSO norms
I believe there is an even simpler answer here, although "why" questions are always hard to answer when a technique is developed. The squared $l_2$-norm is used so that the regularization term is eas
Ridge & LASSO norms I believe there is an even simpler answer here, although "why" questions are always hard to answer when a technique is developed. The squared $l_2$-norm is used so that the regularization term is easily differentiable. Ridge regression minimizes: $$\|\mathbf{y - X\beta}\|^2_2+\lambda\|\beta\|_2^2$$ Which can also be written: $$\|\mathbf{y - X\beta}\|^2_2+\lambda\beta^T\beta$$ This can now be easily differentiated wrt $\beta$ to get the closed-form solution: $$\hat\beta^{\text{ridge}} = (\mathbf{X}^T\mathbf{X} + \lambda I)^{-1}\mathbf{X}^T\mathbf{y}$$ from which all kinda of inference can be derived.
Ridge & LASSO norms I believe there is an even simpler answer here, although "why" questions are always hard to answer when a technique is developed. The squared $l_2$-norm is used so that the regularization term is eas
18,642
Ridge & LASSO norms
Consider one other important difference between using the square of the $\ell_2$ norm (i.e. ridge regression) and the unmodified $\ell_2$ norm: the derivative of the $\ell_2$ norm of $x$, $||x||_2$, at $x$ is given by $\frac{x}{ ||x||_2}$ and therefore not differentiable at the zero vector. That is, although the $\ell_2$ norm does not do individual variable selection like the lasso, it could theoretically yield $\beta=0$ as the solution to the maximum penalized likelihood. By squaring the $\ell_2$ norm in the penalty, the ridge-type penalty is differentiable everywhere and can never yield such a solution. This behavior is exactly (by my understanding) why the group lasso (Yuan and Lin) and the sparse group lasso (Simon, et al.), etc, use the $\ell_2$ norm (on prespecified subsets of the coefficients) instead of the square of the $\ell_2$ norm.
Ridge & LASSO norms
Consider one other important difference between using the square of the $\ell_2$ norm (i.e. ridge regression) and the unmodified $\ell_2$ norm: the derivative of the $\ell_2$ norm of $x$, $||x||_2$, a
Ridge & LASSO norms Consider one other important difference between using the square of the $\ell_2$ norm (i.e. ridge regression) and the unmodified $\ell_2$ norm: the derivative of the $\ell_2$ norm of $x$, $||x||_2$, at $x$ is given by $\frac{x}{ ||x||_2}$ and therefore not differentiable at the zero vector. That is, although the $\ell_2$ norm does not do individual variable selection like the lasso, it could theoretically yield $\beta=0$ as the solution to the maximum penalized likelihood. By squaring the $\ell_2$ norm in the penalty, the ridge-type penalty is differentiable everywhere and can never yield such a solution. This behavior is exactly (by my understanding) why the group lasso (Yuan and Lin) and the sparse group lasso (Simon, et al.), etc, use the $\ell_2$ norm (on prespecified subsets of the coefficients) instead of the square of the $\ell_2$ norm.
Ridge & LASSO norms Consider one other important difference between using the square of the $\ell_2$ norm (i.e. ridge regression) and the unmodified $\ell_2$ norm: the derivative of the $\ell_2$ norm of $x$, $||x||_2$, a
18,643
Ridge & LASSO norms
Another interpretation of it is the Bayesian one. In a frequentist approach the regularization with $$\|\cdot\|_2^2$$ is equivalent to having a Gaussian prior on your weight vector $\beta$. See here for example: Why is the L2 regularization equivalent to Gaussian prior?
Ridge & LASSO norms
Another interpretation of it is the Bayesian one. In a frequentist approach the regularization with $$\|\cdot\|_2^2$$ is equivalent to having a Gaussian prior on your weight vector $\beta$. See here f
Ridge & LASSO norms Another interpretation of it is the Bayesian one. In a frequentist approach the regularization with $$\|\cdot\|_2^2$$ is equivalent to having a Gaussian prior on your weight vector $\beta$. See here for example: Why is the L2 regularization equivalent to Gaussian prior?
Ridge & LASSO norms Another interpretation of it is the Bayesian one. In a frequentist approach the regularization with $$\|\cdot\|_2^2$$ is equivalent to having a Gaussian prior on your weight vector $\beta$. See here f
18,644
Recalculate log-likelihood from a simple R lm model
The logLik() function provides the evaluation of the log-likelihood by substituting the ML estimates of the parameters for the values of the unknown parameters. Now, the maximum likelihood estimates of the regression parameters (the $\beta_j$'s in $X{\boldsymbol \beta}$) coincide with the least-squares estimates, but the ML estimate of $\sigma$ is $\sqrt{\frac{\sum \hat\epsilon_i^2}{n}}$, whereas you are using $\hat\sigma = \sqrt{\frac{\sum \hat\epsilon_i^2}{n-2}}$, that is the square root of the unbiased estimate of $\sigma^2$. > n <- 5 > x <- 1:n > set.seed(1) > y <- 10 + 2*x + rnorm(n, 0, 2) > modlm <- lm(y ~ x) > sigma <- summary(modlm)$sigma > > # value of the likelihood with the "classical" sigma hat > sum(log(dnorm(x = y, mean = predict(modlm), sd = sigma))) [1] -9.192832 > > # value of the likelihood with the ML sigma hat > sigma.ML <- sigma*sqrt((n-dim(model.matrix(modlm))[2])/n) > sum(log(dnorm(x = y, mean = predict(modlm), sd = sigma.ML))) [1] -8.915768 > logLik(modlm) 'log Lik.' -8.915768 (df=3)
Recalculate log-likelihood from a simple R lm model
The logLik() function provides the evaluation of the log-likelihood by substituting the ML estimates of the parameters for the values of the unknown parameters. Now, the maximum likelihood estimates o
Recalculate log-likelihood from a simple R lm model The logLik() function provides the evaluation of the log-likelihood by substituting the ML estimates of the parameters for the values of the unknown parameters. Now, the maximum likelihood estimates of the regression parameters (the $\beta_j$'s in $X{\boldsymbol \beta}$) coincide with the least-squares estimates, but the ML estimate of $\sigma$ is $\sqrt{\frac{\sum \hat\epsilon_i^2}{n}}$, whereas you are using $\hat\sigma = \sqrt{\frac{\sum \hat\epsilon_i^2}{n-2}}$, that is the square root of the unbiased estimate of $\sigma^2$. > n <- 5 > x <- 1:n > set.seed(1) > y <- 10 + 2*x + rnorm(n, 0, 2) > modlm <- lm(y ~ x) > sigma <- summary(modlm)$sigma > > # value of the likelihood with the "classical" sigma hat > sum(log(dnorm(x = y, mean = predict(modlm), sd = sigma))) [1] -9.192832 > > # value of the likelihood with the ML sigma hat > sigma.ML <- sigma*sqrt((n-dim(model.matrix(modlm))[2])/n) > sum(log(dnorm(x = y, mean = predict(modlm), sd = sigma.ML))) [1] -8.915768 > logLik(modlm) 'log Lik.' -8.915768 (df=3)
Recalculate log-likelihood from a simple R lm model The logLik() function provides the evaluation of the log-likelihood by substituting the ML estimates of the parameters for the values of the unknown parameters. Now, the maximum likelihood estimates o
18,645
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters?
The problem with linearizing and then using linear regression is that the assumption of a Gaussian distribution of residuals is not likely to be true for the transformed data. It is usually better to use nonlinear regression. Most nonlinear regression programs report the standard error and confidence interval of the best-fit parameters. If yours doesn't, these equations may help. Each standard error is computed using this equation: SE(Pi) = sqrt[ (SS/DF) * Cov(i,i) ] Pi : i-th adjustable(non-constant) parameter SS : sum of squared residuals DF : degrees of freedom (the number of data points minus number of parameters fit by regression) Cov(i,i) : i-th diagonal element of covariance matrix sqrt() : square root And here is the equation to compute the confidence interval for each parameter from the best-fit value, its standard error, and the number of degrees of freedom. From [BestFit(Pi)- t(95%,DF)*SE(Pi)] TO [BestFit(Pi)+ t(95%,DF)*SE(Pi)] BestFit(Pi) is the best fit value for the i-th parameter t is the value from the t distribution for 95% confidence for the specified number of DF. DF is degrees of freedom. Example with Excel for 95% confidence (so alpha = 0.05) and 23 degrees of freedom: = TINV(0.05,23) DF equals degrees of freedom (the number of data points minus number of parameters fit by regression)
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters?
The problem with linearizing and then using linear regression is that the assumption of a Gaussian distribution of residuals is not likely to be true for the transformed data. It is usually better to
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters? The problem with linearizing and then using linear regression is that the assumption of a Gaussian distribution of residuals is not likely to be true for the transformed data. It is usually better to use nonlinear regression. Most nonlinear regression programs report the standard error and confidence interval of the best-fit parameters. If yours doesn't, these equations may help. Each standard error is computed using this equation: SE(Pi) = sqrt[ (SS/DF) * Cov(i,i) ] Pi : i-th adjustable(non-constant) parameter SS : sum of squared residuals DF : degrees of freedom (the number of data points minus number of parameters fit by regression) Cov(i,i) : i-th diagonal element of covariance matrix sqrt() : square root And here is the equation to compute the confidence interval for each parameter from the best-fit value, its standard error, and the number of degrees of freedom. From [BestFit(Pi)- t(95%,DF)*SE(Pi)] TO [BestFit(Pi)+ t(95%,DF)*SE(Pi)] BestFit(Pi) is the best fit value for the i-th parameter t is the value from the t distribution for 95% confidence for the specified number of DF. DF is degrees of freedom. Example with Excel for 95% confidence (so alpha = 0.05) and 23 degrees of freedom: = TINV(0.05,23) DF equals degrees of freedom (the number of data points minus number of parameters fit by regression)
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters? The problem with linearizing and then using linear regression is that the assumption of a Gaussian distribution of residuals is not likely to be true for the transformed data. It is usually better to
18,646
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters?
If believe an appropriate model for your data is: $f = ae^{-bt}$ Then you can take a log transform your response data such that an appropriate model is: $f' = a' -bt$ with $f' = ln(f)$ and $a' = ln(a)$. The transformed data can be fit using simple linear regression and an estimate for the intercept and slope along with standard errors obtained. If the critical t value and standard error are applied to the parameter estimate, a confidence interval for that parameter estimate can be formed. In R: # Rough simulated data set. set.seed(1) a <- 50; b <- 0.2; n <- 25 x <- 1:n y <- a*(exp(-b * x)) y <- y + rnorm(n, sd=0.25) y <- ifelse(y>0, y, 0.1) plot(x,y) # Linearise: y2 <- log(y) plot(x,y2) # Fit model to transformed data model <- lm(y2 ~ x) summary(model) confint(model) # Or: param <- summary(model)$coefficients[, 1]; se <- summary(model)$coefficients[, 2] param + qt(0.975, 23) * se param - qt(0.975, 23) * se If you are using the model for predicting you should be sure to check that the assumptions of SLR have been met - iid $~N(0,\sigma^2)$.
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters?
If believe an appropriate model for your data is: $f = ae^{-bt}$ Then you can take a log transform your response data such that an appropriate model is: $f' = a' -bt$ with $f' = ln(f)$ and $a' = ln(a)
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters? If believe an appropriate model for your data is: $f = ae^{-bt}$ Then you can take a log transform your response data such that an appropriate model is: $f' = a' -bt$ with $f' = ln(f)$ and $a' = ln(a)$. The transformed data can be fit using simple linear regression and an estimate for the intercept and slope along with standard errors obtained. If the critical t value and standard error are applied to the parameter estimate, a confidence interval for that parameter estimate can be formed. In R: # Rough simulated data set. set.seed(1) a <- 50; b <- 0.2; n <- 25 x <- 1:n y <- a*(exp(-b * x)) y <- y + rnorm(n, sd=0.25) y <- ifelse(y>0, y, 0.1) plot(x,y) # Linearise: y2 <- log(y) plot(x,y2) # Fit model to transformed data model <- lm(y2 ~ x) summary(model) confint(model) # Or: param <- summary(model)$coefficients[, 1]; se <- summary(model)$coefficients[, 2] param + qt(0.975, 23) * se param - qt(0.975, 23) * se If you are using the model for predicting you should be sure to check that the assumptions of SLR have been met - iid $~N(0,\sigma^2)$.
When fitting a curve, how do I calculate the 95% confidence interval for my fitted parameters? If believe an appropriate model for your data is: $f = ae^{-bt}$ Then you can take a log transform your response data such that an appropriate model is: $f' = a' -bt$ with $f' = ln(f)$ and $a' = ln(a)
18,647
Difference Between Simultaneous Equation Model and Structural Equation Model
Simultaneous Equation Models (let's call them SIM to separate the two types of models), are models where you have some simultaneity. For example, $$ y=\alpha+\beta x + u_y\\ x=\gamma+\delta y + u_x $$ As you can see, the two equations form a system of equations. These are widely used in econometrics and applied economics, but it is not guaranteed that they have a reasonable (economic) interpretation. Furthermore, to make things even more complicated, SIMs can be written in both structural and reduced form. So you can speak of a simultaneous equation model in a structural form, without referring to what is traditionally known as structural equation modeling (SEM)! If you want a reference, Econometric Analysis of Cross Section and Panel Data by Wooldridge is pretty good. In the SEM universe you try to estimate causal relationships and things you cannot observe. For example, IQ is impossible to observe, but you may exploit relationships between related (observable) variables to study it. Factor analysis is a common SEM method. For applications of SEM on time series, you may want to have a look at dynamic factor analysis.
Difference Between Simultaneous Equation Model and Structural Equation Model
Simultaneous Equation Models (let's call them SIM to separate the two types of models), are models where you have some simultaneity. For example, $$ y=\alpha+\beta x + u_y\\ x=\gamma+\delta y + u_x $$
Difference Between Simultaneous Equation Model and Structural Equation Model Simultaneous Equation Models (let's call them SIM to separate the two types of models), are models where you have some simultaneity. For example, $$ y=\alpha+\beta x + u_y\\ x=\gamma+\delta y + u_x $$ As you can see, the two equations form a system of equations. These are widely used in econometrics and applied economics, but it is not guaranteed that they have a reasonable (economic) interpretation. Furthermore, to make things even more complicated, SIMs can be written in both structural and reduced form. So you can speak of a simultaneous equation model in a structural form, without referring to what is traditionally known as structural equation modeling (SEM)! If you want a reference, Econometric Analysis of Cross Section and Panel Data by Wooldridge is pretty good. In the SEM universe you try to estimate causal relationships and things you cannot observe. For example, IQ is impossible to observe, but you may exploit relationships between related (observable) variables to study it. Factor analysis is a common SEM method. For applications of SEM on time series, you may want to have a look at dynamic factor analysis.
Difference Between Simultaneous Equation Model and Structural Equation Model Simultaneous Equation Models (let's call them SIM to separate the two types of models), are models where you have some simultaneity. For example, $$ y=\alpha+\beta x + u_y\\ x=\gamma+\delta y + u_x $$
18,648
Difference Between Simultaneous Equation Model and Structural Equation Model
It seems me that the interpretation of structural equation models (SEM) in econometrics is matters of debate. Judea Pearl strongly defends the causal interpretation of SEM, and of its parameters. For example you can read: The Causal Foundations of Structural Equation Modeling - Pearl (2012). He consider terms like simultaneous equation model (SIM) as synonym of SEM. In Pearl's opinion, the last is a terminological strategy for remove/obscure causal meaning at SEM (page 3). In his opinion, SEM must be carried out such that it always has a clear causal meaning. Surely in the context of SIM and SEM, there are always structural forms and reduced forms, where reduced are achieved by identification. Please, if you know one econometrics textbook or serious article that speak about SIM/SEM without these distinctions let me know. Reduced form, per se, carried out only correlational/regression meaning but via identification we achieve causal one. Surely structural meaning go beyond correlational (in broad sense, not necessarily linear) one but if the structural meaning is not causal I don't know what it is. Time series context is also related, see my question here: Structural equation and causal model in economics
Difference Between Simultaneous Equation Model and Structural Equation Model
It seems me that the interpretation of structural equation models (SEM) in econometrics is matters of debate. Judea Pearl strongly defends the causal interpretation of SEM, and of its parameters. For
Difference Between Simultaneous Equation Model and Structural Equation Model It seems me that the interpretation of structural equation models (SEM) in econometrics is matters of debate. Judea Pearl strongly defends the causal interpretation of SEM, and of its parameters. For example you can read: The Causal Foundations of Structural Equation Modeling - Pearl (2012). He consider terms like simultaneous equation model (SIM) as synonym of SEM. In Pearl's opinion, the last is a terminological strategy for remove/obscure causal meaning at SEM (page 3). In his opinion, SEM must be carried out such that it always has a clear causal meaning. Surely in the context of SIM and SEM, there are always structural forms and reduced forms, where reduced are achieved by identification. Please, if you know one econometrics textbook or serious article that speak about SIM/SEM without these distinctions let me know. Reduced form, per se, carried out only correlational/regression meaning but via identification we achieve causal one. Surely structural meaning go beyond correlational (in broad sense, not necessarily linear) one but if the structural meaning is not causal I don't know what it is. Time series context is also related, see my question here: Structural equation and causal model in economics
Difference Between Simultaneous Equation Model and Structural Equation Model It seems me that the interpretation of structural equation models (SEM) in econometrics is matters of debate. Judea Pearl strongly defends the causal interpretation of SEM, and of its parameters. For
18,649
Difference Between Simultaneous Equation Model and Structural Equation Model
To add up to the former answer, I would say it is not different at all; in fact they have different point of view. Simultaneous equation term focuses on simultaneity, so according to the concept it is recommended to use techniques other than simple OLS to estimate parameters. On the other hand, structural equation term focuses on structure itself, so it may include latent variables etc. In fact, there are numerous ways to model structural equations.
Difference Between Simultaneous Equation Model and Structural Equation Model
To add up to the former answer, I would say it is not different at all; in fact they have different point of view. Simultaneous equation term focuses on simultaneity, so according to the concept it is
Difference Between Simultaneous Equation Model and Structural Equation Model To add up to the former answer, I would say it is not different at all; in fact they have different point of view. Simultaneous equation term focuses on simultaneity, so according to the concept it is recommended to use techniques other than simple OLS to estimate parameters. On the other hand, structural equation term focuses on structure itself, so it may include latent variables etc. In fact, there are numerous ways to model structural equations.
Difference Between Simultaneous Equation Model and Structural Equation Model To add up to the former answer, I would say it is not different at all; in fact they have different point of view. Simultaneous equation term focuses on simultaneity, so according to the concept it is
18,650
Interpolation of influenza data that conserves weekly mean
I have managed to create an R function that interpolates even-spaced points linearly and with splines while preserving the means (e.g. weekly, monthly, etc.). It uses the functions na.approx and na.spline from the zoo package and iteratively calculates the splines with the desired properties. The algorithm is described in this paper. Here is the code: interpol.consmean <- function(y, period=7, max.iter=100, tol=1e-4, plot=FALSE) { require(zoo) if( plot == TRUE ) { require(ggplot2) } y.temp.linear <- matrix(NA, ncol=length(y), nrow=max.iter+1) y.temp.linear[1, ] <- y y.temp.spline <- y.temp.linear y.temp.pred.spline <- matrix(NA, ncol=length(y), nrow=max.iter) y.temp.pred.linear <- matrix(NA, ncol=length(y), nrow=max.iter) ind.actual <- which(!is.na(y)) if ( !all(diff(ind.actual)[1]== diff(ind.actual)) ) { stop("\"y\" must contain an evenly spaced time series") } partial <- ifelse((length(y) - ind.actual[length(ind.actual)]) < period/2, TRUE, FALSE) for(k in 1:max.iter) { y.temp.pred.linear[k,] <- na.approx(y.temp.linear[k, ], na.rm=FALSE, rule=2) y.temp.pred.spline[k,] <- na.spline(y.temp.spline[k, ], method="fmm") interpol.means.linear <- rollapply(y.temp.pred.linear[k,], width=period, mean, by=period, align="left", partial=partial) interpol.means.splines <- rollapply(y.temp.pred.spline[k,], width=period, mean, by=period, align="left", partial=partial) resid.linear <- y.temp.linear[k, ][ ind.actual ] - interpol.means.linear resid.spline <- y.temp.spline[k, ][ ind.actual ] - interpol.means.splines if ( max(resid.linear, na.rm=TRUE) < tol & max(resid.spline, na.rm=TRUE) < tol ){ cat("Converged after", k, "iterations with tolerance of", tol, sep=" ") break } y.temp.linear[k+1, ][!is.na(y.temp.linear[k, ])] <- resid.linear y.temp.spline[k+1, ][!is.na(y.temp.spline[k, ])] <- resid.spline } interpol.linear.final <- colSums(y.temp.pred.linear, na.rm=TRUE) interpol.spline.final <- colSums(y.temp.pred.spline, na.rm=TRUE) if ( plot == TRUE ) { plot.frame <- data.frame( y=rep(y,2)/7, x=rep(1:length(y),2), inter.values=c(interpol.linear.final, interpol.spline.final)/7, method=c(rep("Linear", length(y)), rep("Spline", length(y))) ) p <- ggplot(data=plot.frame, aes(x=x)) + geom_point(aes(y=y, x=x), size=4) + geom_line(aes(y=inter.values, color=method), size=1) + ylab("y") + xlab("x") + theme(axis.title.y =element_text(vjust=0.4, size=20, angle=90)) + theme(axis.title.x =element_text(vjust=0, size=20, angle=0)) + theme(axis.text.x =element_text(size=15, colour = "black")) + theme(axis.text.y =element_text(size=17, colour = "black")) + theme(panel.background = element_rect(fill = "grey85", colour = NA), panel.grid.major = element_line(colour = "white"), panel.grid.minor = element_line(colour = "grey90", size = 0.25))+ scale_color_manual(values=c("#377EB8", "#E41A1C"), name="Interpolation method", breaks=c("Linear", "Spline"), labels=c("Linear", "Spline")) + theme(legend.position="none") + theme(strip.text.x = element_text(size=16)) + facet_wrap(~ method) suppressWarnings(print(p)) } list(linear=interpol.linear.final, spline=interpol.spline.final) } Let's apply the function to the example dataset given in the question: interpolations <- interpol.consmean(y=dat.frame$no.influ.cases, period=7, max.iter = 100, tol=1e-6, plot=TRUE) Both the linear and spline interpolations seem fine. Let's check if the weekly means are preserved (truncated output): cbind(dat.frame$no.influ.cases[!is.na(dat.frame$no.influ.cases)], rollapply(interpolations$linear, 7, mean, by=7, align="left", partial=F)) [,1] [,2] [1,] 168 168 [2,] 199 199 [3,] 214 214 [4,] 230 230 [5,] 267 267 [6,] 373 373 [7,] 387 387 [8,] 443 443 [9,] 579 579 [10,] 821 821 [11,] 1229 1229
Interpolation of influenza data that conserves weekly mean
I have managed to create an R function that interpolates even-spaced points linearly and with splines while preserving the means (e.g. weekly, monthly, etc.). It uses the functions na.approx and na.sp
Interpolation of influenza data that conserves weekly mean I have managed to create an R function that interpolates even-spaced points linearly and with splines while preserving the means (e.g. weekly, monthly, etc.). It uses the functions na.approx and na.spline from the zoo package and iteratively calculates the splines with the desired properties. The algorithm is described in this paper. Here is the code: interpol.consmean <- function(y, period=7, max.iter=100, tol=1e-4, plot=FALSE) { require(zoo) if( plot == TRUE ) { require(ggplot2) } y.temp.linear <- matrix(NA, ncol=length(y), nrow=max.iter+1) y.temp.linear[1, ] <- y y.temp.spline <- y.temp.linear y.temp.pred.spline <- matrix(NA, ncol=length(y), nrow=max.iter) y.temp.pred.linear <- matrix(NA, ncol=length(y), nrow=max.iter) ind.actual <- which(!is.na(y)) if ( !all(diff(ind.actual)[1]== diff(ind.actual)) ) { stop("\"y\" must contain an evenly spaced time series") } partial <- ifelse((length(y) - ind.actual[length(ind.actual)]) < period/2, TRUE, FALSE) for(k in 1:max.iter) { y.temp.pred.linear[k,] <- na.approx(y.temp.linear[k, ], na.rm=FALSE, rule=2) y.temp.pred.spline[k,] <- na.spline(y.temp.spline[k, ], method="fmm") interpol.means.linear <- rollapply(y.temp.pred.linear[k,], width=period, mean, by=period, align="left", partial=partial) interpol.means.splines <- rollapply(y.temp.pred.spline[k,], width=period, mean, by=period, align="left", partial=partial) resid.linear <- y.temp.linear[k, ][ ind.actual ] - interpol.means.linear resid.spline <- y.temp.spline[k, ][ ind.actual ] - interpol.means.splines if ( max(resid.linear, na.rm=TRUE) < tol & max(resid.spline, na.rm=TRUE) < tol ){ cat("Converged after", k, "iterations with tolerance of", tol, sep=" ") break } y.temp.linear[k+1, ][!is.na(y.temp.linear[k, ])] <- resid.linear y.temp.spline[k+1, ][!is.na(y.temp.spline[k, ])] <- resid.spline } interpol.linear.final <- colSums(y.temp.pred.linear, na.rm=TRUE) interpol.spline.final <- colSums(y.temp.pred.spline, na.rm=TRUE) if ( plot == TRUE ) { plot.frame <- data.frame( y=rep(y,2)/7, x=rep(1:length(y),2), inter.values=c(interpol.linear.final, interpol.spline.final)/7, method=c(rep("Linear", length(y)), rep("Spline", length(y))) ) p <- ggplot(data=plot.frame, aes(x=x)) + geom_point(aes(y=y, x=x), size=4) + geom_line(aes(y=inter.values, color=method), size=1) + ylab("y") + xlab("x") + theme(axis.title.y =element_text(vjust=0.4, size=20, angle=90)) + theme(axis.title.x =element_text(vjust=0, size=20, angle=0)) + theme(axis.text.x =element_text(size=15, colour = "black")) + theme(axis.text.y =element_text(size=17, colour = "black")) + theme(panel.background = element_rect(fill = "grey85", colour = NA), panel.grid.major = element_line(colour = "white"), panel.grid.minor = element_line(colour = "grey90", size = 0.25))+ scale_color_manual(values=c("#377EB8", "#E41A1C"), name="Interpolation method", breaks=c("Linear", "Spline"), labels=c("Linear", "Spline")) + theme(legend.position="none") + theme(strip.text.x = element_text(size=16)) + facet_wrap(~ method) suppressWarnings(print(p)) } list(linear=interpol.linear.final, spline=interpol.spline.final) } Let's apply the function to the example dataset given in the question: interpolations <- interpol.consmean(y=dat.frame$no.influ.cases, period=7, max.iter = 100, tol=1e-6, plot=TRUE) Both the linear and spline interpolations seem fine. Let's check if the weekly means are preserved (truncated output): cbind(dat.frame$no.influ.cases[!is.na(dat.frame$no.influ.cases)], rollapply(interpolations$linear, 7, mean, by=7, align="left", partial=F)) [,1] [,2] [1,] 168 168 [2,] 199 199 [3,] 214 214 [4,] 230 230 [5,] 267 267 [6,] 373 373 [7,] 387 387 [8,] 443 443 [9,] 579 579 [10,] 821 821 [11,] 1229 1229
Interpolation of influenza data that conserves weekly mean I have managed to create an R function that interpolates even-spaced points linearly and with splines while preserving the means (e.g. weekly, monthly, etc.). It uses the functions na.approx and na.sp
18,651
Interpolation of influenza data that conserves weekly mean
Any straight line that goes through the mean at the midpoint of the range will produce daily values that have the required mean. Nick Cox's last comment about 'divide weekly counts by number of days' is a special case of that with gradient=0. So we can adjust this and choose the gradient to make things perhaps a bit smoother. Here's three R functions to do something like that: interpwk <- function(x,y,delta){ offset=-3:3 yout=y+delta*offset xout=x+offset cbind(xout,yout) } get_delta <- function(x,y,pos){ (y[pos+1]-y[pos-1])/(x[pos+1]-x[pos-1]) } #' get slope from neighbours interpall <- function(x,y,delta1,f=1){ for(i in 2:(length(x)-1)){ delta=get_delta(x,y,i) xyout=interpwk(x[i],y[i],delta/f) points(xyout) } } Add a day measure to your data, then plot, and then plot the interpolator: > data$day=data$week*7 > plot(data$day,data$no.influ.cases,type="l") > interpall(data$day,data$no.influ.cases,f=1) Another possibility is to constrain continuity at weekends but this gives you a system with only one degree of freedom - ie it is completely defined by the slope of the first section (because then all the other sections have to join up). I've not coded this - you have a go! [Apols for the slightly shabby R code, it should really return the points rather than plotting them]
Interpolation of influenza data that conserves weekly mean
Any straight line that goes through the mean at the midpoint of the range will produce daily values that have the required mean. Nick Cox's last comment about 'divide weekly counts by number of days'
Interpolation of influenza data that conserves weekly mean Any straight line that goes through the mean at the midpoint of the range will produce daily values that have the required mean. Nick Cox's last comment about 'divide weekly counts by number of days' is a special case of that with gradient=0. So we can adjust this and choose the gradient to make things perhaps a bit smoother. Here's three R functions to do something like that: interpwk <- function(x,y,delta){ offset=-3:3 yout=y+delta*offset xout=x+offset cbind(xout,yout) } get_delta <- function(x,y,pos){ (y[pos+1]-y[pos-1])/(x[pos+1]-x[pos-1]) } #' get slope from neighbours interpall <- function(x,y,delta1,f=1){ for(i in 2:(length(x)-1)){ delta=get_delta(x,y,i) xyout=interpwk(x[i],y[i],delta/f) points(xyout) } } Add a day measure to your data, then plot, and then plot the interpolator: > data$day=data$week*7 > plot(data$day,data$no.influ.cases,type="l") > interpall(data$day,data$no.influ.cases,f=1) Another possibility is to constrain continuity at weekends but this gives you a system with only one degree of freedom - ie it is completely defined by the slope of the first section (because then all the other sections have to join up). I've not coded this - you have a go! [Apols for the slightly shabby R code, it should really return the points rather than plotting them]
Interpolation of influenza data that conserves weekly mean Any straight line that goes through the mean at the midpoint of the range will produce daily values that have the required mean. Nick Cox's last comment about 'divide weekly counts by number of days'
18,652
Interpolation of influenza data that conserves weekly mean
I think that since you're dealing with counts, you could model the daily counts as multinomial, with $n$ being the total for the week; it's possible to do spline smoothing in GLMs. (If the data had been measurements rather than counts, I'd lean toward modelling the proportions via a Dirichlet model, but that's slightly more involved.) The fact that the number of days won't always be the same shouldn't be a particular problem, as long as you know what it is - as long as you use an offset to put things at the same 'level'.
Interpolation of influenza data that conserves weekly mean
I think that since you're dealing with counts, you could model the daily counts as multinomial, with $n$ being the total for the week; it's possible to do spline smoothing in GLMs. (If the data had be
Interpolation of influenza data that conserves weekly mean I think that since you're dealing with counts, you could model the daily counts as multinomial, with $n$ being the total for the week; it's possible to do spline smoothing in GLMs. (If the data had been measurements rather than counts, I'd lean toward modelling the proportions via a Dirichlet model, but that's slightly more involved.) The fact that the number of days won't always be the same shouldn't be a particular problem, as long as you know what it is - as long as you use an offset to put things at the same 'level'.
Interpolation of influenza data that conserves weekly mean I think that since you're dealing with counts, you could model the daily counts as multinomial, with $n$ being the total for the week; it's possible to do spline smoothing in GLMs. (If the data had be
18,653
Interpolation of influenza data that conserves weekly mean
I'll bundle together some extra comments as another answer. It's taken a while for the structure of this project to become clearer. Given that influenza is now revealed as one covariate among several, quite what you do it with doesn't seem so crucial, or at least not to merit the scepticism expressed in some of my earlier comments. As everything else is on a daily basis, reducing everything else to weeks would throw away too much detail. The original focus of the question remains, on interpolation that preserves the weekly mean to which one (extreme) answer is that the weekly mean preserves the weekly mean. As that unsurprisingly seems unattractive or unrealistic, other interpolation methods seem more attractive and/or imputation methods as proposed by @Spacedman. (Quite whether that would be imputation with a temporal flavour or interpolation with added stochastic flavour I am not clear.) Two further specific thoughts: Taking the weekly values (divided by the number of days) and then smoothing with weighted averages would be likely in practice to preserve the mean to a good approximation. As the influenza cases are counts, smoothing the root or log counts and then back-transforming might work better than just smoothing the counts.
Interpolation of influenza data that conserves weekly mean
I'll bundle together some extra comments as another answer. It's taken a while for the structure of this project to become clearer. Given that influenza is now revealed as one covariate among several
Interpolation of influenza data that conserves weekly mean I'll bundle together some extra comments as another answer. It's taken a while for the structure of this project to become clearer. Given that influenza is now revealed as one covariate among several, quite what you do it with doesn't seem so crucial, or at least not to merit the scepticism expressed in some of my earlier comments. As everything else is on a daily basis, reducing everything else to weeks would throw away too much detail. The original focus of the question remains, on interpolation that preserves the weekly mean to which one (extreme) answer is that the weekly mean preserves the weekly mean. As that unsurprisingly seems unattractive or unrealistic, other interpolation methods seem more attractive and/or imputation methods as proposed by @Spacedman. (Quite whether that would be imputation with a temporal flavour or interpolation with added stochastic flavour I am not clear.) Two further specific thoughts: Taking the weekly values (divided by the number of days) and then smoothing with weighted averages would be likely in practice to preserve the mean to a good approximation. As the influenza cases are counts, smoothing the root or log counts and then back-transforming might work better than just smoothing the counts.
Interpolation of influenza data that conserves weekly mean I'll bundle together some extra comments as another answer. It's taken a while for the structure of this project to become clearer. Given that influenza is now revealed as one covariate among several
18,654
Interpolation of influenza data that conserves weekly mean
This question is related to another question and answer that was posted here. It appears that there are a number of methods for means-preserving interpolation, although many of these are computationally expensive because they require recursive iteration. The particular method chosen may depend on the need for precision and other requirements such as boundary conditions and limits to the interpolated result.
Interpolation of influenza data that conserves weekly mean
This question is related to another question and answer that was posted here. It appears that there are a number of methods for means-preserving interpolation, although many of these are computational
Interpolation of influenza data that conserves weekly mean This question is related to another question and answer that was posted here. It appears that there are a number of methods for means-preserving interpolation, although many of these are computationally expensive because they require recursive iteration. The particular method chosen may depend on the need for precision and other requirements such as boundary conditions and limits to the interpolated result.
Interpolation of influenza data that conserves weekly mean This question is related to another question and answer that was posted here. It appears that there are a number of methods for means-preserving interpolation, although many of these are computational
18,655
Relationship between the phi, Matthews and Pearson correlation coefficients
Yes, they are the same. The Matthews correlation coefficient is just a particular application of the Pearson correlation coefficient to a confusion table. A contingency table is just a summary of underlying data. You can convert it back from the counts shown in the contingency table to one row per observations. Consider the example confusion matrix used in the Wikipedia article with 5 true positives, 17 true negatives, 2 false positives and 3 false negatives > matrix(c(5,3,2,17), nrow=2, byrow=TRUE) [,1] [,2] [1,] 5 3 [2,] 2 17 > > # Matthews correlation coefficient directly from the Wikipedia formula > (5*17-3*2) / sqrt((5+3)*(5+2)*(17+3)*(17+2)) [1] 0.5415534 > > > # Convert this into a long form binary variable and find the correlation coefficient > conf.m <- data.frame( + X1=rep(c(0,1,0,1), c(5,3,2,17)), + X2=rep(c(0,0,1,1), c(5,3,2,17))) > conf.m # what does that look like? X1 X2 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 1 0 7 1 0 8 1 0 9 0 1 10 0 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 > cor(conf.m) X1 X2 X1 1.0000000 0.5415534 X2 0.5415534 1.0000000
Relationship between the phi, Matthews and Pearson correlation coefficients
Yes, they are the same. The Matthews correlation coefficient is just a particular application of the Pearson correlation coefficient to a confusion table. A contingency table is just a summary of und
Relationship between the phi, Matthews and Pearson correlation coefficients Yes, they are the same. The Matthews correlation coefficient is just a particular application of the Pearson correlation coefficient to a confusion table. A contingency table is just a summary of underlying data. You can convert it back from the counts shown in the contingency table to one row per observations. Consider the example confusion matrix used in the Wikipedia article with 5 true positives, 17 true negatives, 2 false positives and 3 false negatives > matrix(c(5,3,2,17), nrow=2, byrow=TRUE) [,1] [,2] [1,] 5 3 [2,] 2 17 > > # Matthews correlation coefficient directly from the Wikipedia formula > (5*17-3*2) / sqrt((5+3)*(5+2)*(17+3)*(17+2)) [1] 0.5415534 > > > # Convert this into a long form binary variable and find the correlation coefficient > conf.m <- data.frame( + X1=rep(c(0,1,0,1), c(5,3,2,17)), + X2=rep(c(0,0,1,1), c(5,3,2,17))) > conf.m # what does that look like? X1 X2 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 1 0 7 1 0 8 1 0 9 0 1 10 0 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 21 1 1 22 1 1 23 1 1 24 1 1 25 1 1 26 1 1 27 1 1 > cor(conf.m) X1 X2 X1 1.0000000 0.5415534 X2 0.5415534 1.0000000
Relationship between the phi, Matthews and Pearson correlation coefficients Yes, they are the same. The Matthews correlation coefficient is just a particular application of the Pearson correlation coefficient to a confusion table. A contingency table is just a summary of und
18,656
Relationship between the phi, Matthews and Pearson correlation coefficients
Firstly, there was a typo error in the question: $\mathbb{E}[xy]$ is not $\displaystyle \frac{n_{\bullet 1}n_{1\bullet}}{n^2}$ but rather $$ \frac{n_{11}}{n} \times 1 \times 1 + \frac{n_{10}}{n}\times 1 \times 0 + \frac{n_{01}}{n} \times 0 \times 1 + \frac{n_{00}}{n} \times 0 \times 0 = \frac{n_{11}}{n} $$ Secondly, the key to showing that $\rho = \phi$ is $$ n_{11} n - n_{1\bullet} n_{\bullet 1} = n_{11} (n_{01} + n_{10} + n_{11} + n_{00}) - (n_{11} + n_{10}) (n_{11} + n_{01}) \\ = n_{11} n_{00} - n_{10} n_{01} $$
Relationship between the phi, Matthews and Pearson correlation coefficients
Firstly, there was a typo error in the question: $\mathbb{E}[xy]$ is not $\displaystyle \frac{n_{\bullet 1}n_{1\bullet}}{n^2}$ but rather $$ \frac{n_{11}}{n} \times 1 \times 1 + \frac{n_{10}}{n}\times
Relationship between the phi, Matthews and Pearson correlation coefficients Firstly, there was a typo error in the question: $\mathbb{E}[xy]$ is not $\displaystyle \frac{n_{\bullet 1}n_{1\bullet}}{n^2}$ but rather $$ \frac{n_{11}}{n} \times 1 \times 1 + \frac{n_{10}}{n}\times 1 \times 0 + \frac{n_{01}}{n} \times 0 \times 1 + \frac{n_{00}}{n} \times 0 \times 0 = \frac{n_{11}}{n} $$ Secondly, the key to showing that $\rho = \phi$ is $$ n_{11} n - n_{1\bullet} n_{\bullet 1} = n_{11} (n_{01} + n_{10} + n_{11} + n_{00}) - (n_{11} + n_{10}) (n_{11} + n_{01}) \\ = n_{11} n_{00} - n_{10} n_{01} $$
Relationship between the phi, Matthews and Pearson correlation coefficients Firstly, there was a typo error in the question: $\mathbb{E}[xy]$ is not $\displaystyle \frac{n_{\bullet 1}n_{1\bullet}}{n^2}$ but rather $$ \frac{n_{11}}{n} \times 1 \times 1 + \frac{n_{10}}{n}\times
18,657
Relationship between the phi, Matthews and Pearson correlation coefficients
I want to note that the phi coefficient $\phi$ (MCC is just a synonym for it) will be equal to the Pearson correlation coefficient $r$ not only when random variables $X$ and $Y$ take values from the set $R = \{0,1\}$ but also in the following cases: When $X$ and $Y$ take values from any other numeric binary set, for example, from $R = \{-1,1\}$ or $R = \{5.5,3.7\}$, etc. When random variable $X$ takes values from the set $R_X = \{x_1, x_2\}$ and random variable $Y$ takes values from the set $R_Y = \{y_1, y_2\}$ (this case may correspond to a situation when $X$ and $Y$ are two nominal variables with two categories each, and we mapped the categories into some different numeric values; such mapping is, of course, not unique) if the contingency table is built in such a way that numbers $\mathrm{max}(x_1,x_2)$ and $\mathrm{max}(y_1,y_2)$ are the names of the 1st row and 1st column of the table respectively (or the names of the 2nd row and the 2nd column of the table respectively). The proof is given below. A key mathematical property of the Pearson correlation coefficient is that it is invariant under separate changes in location and scale in the two variables. That is, we may transform $X$ to $a + b X$ and transform $Y$ to $c + d Y$, where $a, b, c, d$ are constants with $b, d \gt 0$, without changing the correlation coefficient (this holds for both the population and sample Pearson correlation coefficients). So if we have $R_X = \{x_1,x_2\}$ and $R_Y = \{y_1,y_2\}$ there always exist linear mappings $$f: X \to U = \frac{-x_1 + X}{x_2 - x_1}, \quad g:Y \to V = \frac{-y_1+Y}{y_2-y_1},$$ they map $R_X \overset{f}{\to} \{0,1\}, \, R_Y \overset{g}{\to} \{0,1\}$. Using them, we get that Pearson's $r(\mathbf{x},\mathbf{y}) = r(f(\mathbf{x}), \, g(\mathbf{y})) = r(\mathbf{u}, \mathbf{v})$, where $\mathbf{u}, \mathbf{v} \in \{0,1\}^n$. Next, user ryan_tt proved in his post that $r(\mathbf{u}, \mathbf{v}) = \phi(\mathbf{u}, \mathbf{v})$. Hence, $$r(\mathbf{x},\mathbf{y}) = \phi\left(\frac{-x_1 + \mathbf{x}}{x_2 - x_1}, \frac{-y_1+\mathbf{y}}{y_2-y_1} \right), \qquad \forall \mathbf{x},\mathbf{y} \in \mathbb{R}^n.$$
Relationship between the phi, Matthews and Pearson correlation coefficients
I want to note that the phi coefficient $\phi$ (MCC is just a synonym for it) will be equal to the Pearson correlation coefficient $r$ not only when random variables $X$ and $Y$ take values from the s
Relationship between the phi, Matthews and Pearson correlation coefficients I want to note that the phi coefficient $\phi$ (MCC is just a synonym for it) will be equal to the Pearson correlation coefficient $r$ not only when random variables $X$ and $Y$ take values from the set $R = \{0,1\}$ but also in the following cases: When $X$ and $Y$ take values from any other numeric binary set, for example, from $R = \{-1,1\}$ or $R = \{5.5,3.7\}$, etc. When random variable $X$ takes values from the set $R_X = \{x_1, x_2\}$ and random variable $Y$ takes values from the set $R_Y = \{y_1, y_2\}$ (this case may correspond to a situation when $X$ and $Y$ are two nominal variables with two categories each, and we mapped the categories into some different numeric values; such mapping is, of course, not unique) if the contingency table is built in such a way that numbers $\mathrm{max}(x_1,x_2)$ and $\mathrm{max}(y_1,y_2)$ are the names of the 1st row and 1st column of the table respectively (or the names of the 2nd row and the 2nd column of the table respectively). The proof is given below. A key mathematical property of the Pearson correlation coefficient is that it is invariant under separate changes in location and scale in the two variables. That is, we may transform $X$ to $a + b X$ and transform $Y$ to $c + d Y$, where $a, b, c, d$ are constants with $b, d \gt 0$, without changing the correlation coefficient (this holds for both the population and sample Pearson correlation coefficients). So if we have $R_X = \{x_1,x_2\}$ and $R_Y = \{y_1,y_2\}$ there always exist linear mappings $$f: X \to U = \frac{-x_1 + X}{x_2 - x_1}, \quad g:Y \to V = \frac{-y_1+Y}{y_2-y_1},$$ they map $R_X \overset{f}{\to} \{0,1\}, \, R_Y \overset{g}{\to} \{0,1\}$. Using them, we get that Pearson's $r(\mathbf{x},\mathbf{y}) = r(f(\mathbf{x}), \, g(\mathbf{y})) = r(\mathbf{u}, \mathbf{v})$, where $\mathbf{u}, \mathbf{v} \in \{0,1\}^n$. Next, user ryan_tt proved in his post that $r(\mathbf{u}, \mathbf{v}) = \phi(\mathbf{u}, \mathbf{v})$. Hence, $$r(\mathbf{x},\mathbf{y}) = \phi\left(\frac{-x_1 + \mathbf{x}}{x_2 - x_1}, \frac{-y_1+\mathbf{y}}{y_2-y_1} \right), \qquad \forall \mathbf{x},\mathbf{y} \in \mathbb{R}^n.$$
Relationship between the phi, Matthews and Pearson correlation coefficients I want to note that the phi coefficient $\phi$ (MCC is just a synonym for it) will be equal to the Pearson correlation coefficient $r$ not only when random variables $X$ and $Y$ take values from the s
18,658
Comparing two linear regression models
If you set up the data in one long column with A and B as a new column, you then can run your regression model as a GLM with a continuous time variable and a nominal "experiment" variable (A, B). The output of the ANOVA will give you the significance of the difference between the parameters. "intercept' is the common intercept and the "experiment" factor will reflect differences between the intercepts (actually overall means) between the experiments. the "Time" factor will be the common slope, and the interaction is the difference between the experiments with respect to the slope. I have to admit I cheat (?) and run the models separately first to get the two sets of parameters and their errors and then run the combined model to acquire the differences between the treatments (in your case A and B)...
Comparing two linear regression models
If you set up the data in one long column with A and B as a new column, you then can run your regression model as a GLM with a continuous time variable and a nominal "experiment" variable (A, B). The
Comparing two linear regression models If you set up the data in one long column with A and B as a new column, you then can run your regression model as a GLM with a continuous time variable and a nominal "experiment" variable (A, B). The output of the ANOVA will give you the significance of the difference between the parameters. "intercept' is the common intercept and the "experiment" factor will reflect differences between the intercepts (actually overall means) between the experiments. the "Time" factor will be the common slope, and the interaction is the difference between the experiments with respect to the slope. I have to admit I cheat (?) and run the models separately first to get the two sets of parameters and their errors and then run the combined model to acquire the differences between the treatments (in your case A and B)...
Comparing two linear regression models If you set up the data in one long column with A and B as a new column, you then can run your regression model as a GLM with a continuous time variable and a nominal "experiment" variable (A, B). The
18,659
Comparing two linear regression models
The ANOVA analysis doesn't show an F statistics and a p.value since both models have the same residual degrees of freedom (i.e. 19) and if you take the difference then it would be zero! There should be at least one degree of freedom after you take the difference in order to perform the F-test.
Comparing two linear regression models
The ANOVA analysis doesn't show an F statistics and a p.value since both models have the same residual degrees of freedom (i.e. 19) and if you take the difference then it would be zero! There should b
Comparing two linear regression models The ANOVA analysis doesn't show an F statistics and a p.value since both models have the same residual degrees of freedom (i.e. 19) and if you take the difference then it would be zero! There should be at least one degree of freedom after you take the difference in order to perform the F-test.
Comparing two linear regression models The ANOVA analysis doesn't show an F statistics and a p.value since both models have the same residual degrees of freedom (i.e. 19) and if you take the difference then it would be zero! There should b
18,660
How to digest statistical context?
If I might clarify, your question appears to be: "What can I use to understand mathematics if a major resource like Wikipedia makes no sense?" Keep in mind that even a person who has mastered a concept had to begin with a period of not understanding it, and then go through a learning process, albeit one that almost never involved learning much from Wikipedia. Having spent a lot of time studying things that are described quite atrociously on Wikipedia, I can assure you that even when one understands the concepts quite well, it is difficult to make sense of what was going through the minds of one or more authors/editors on Wikipedia. It is not uncommon to see mathematical and statistical concepts mutilated by a bunch of people with a very rough grasp of the concepts or in pursuit of advancing yet another field's weak grasp of the fundamental concept. (I would say more, but it is hard to do so without sounding unduly pessimistic about the efforts of Wikipedians, especially those from certain other disciplines.) On a more constructive note, the best references are typically those textbooks edited by publishers with a strong track record of editing and publishing good works in the given field. Authors and editors in such cases have a reputation among their peers for the quality of their scholarship and rigor, and a series of successive editions usually indicates acceptance by other teachers and researchers. There are many levels of quality between that level and Wikipedia. If the print editions are not available, using Amazon's "Search inside the book" or Google Books may be the best alternatives. For other web-accessible references, you may find that review articles or manuals for non-specialist practitioners are most useful. An example of this is the statistics handbook published by NIST. You may need to synthesize your own understanding by way of looking for articles in Google Scholar. For instance you could query ["a point process is a"] and examine the definitions offered in various articles. Alternatively, a web search like ["point process" pdf site:edu] will turn up lecture notes, slides, and tutorials. The first result for that query appears to be "An introduction to point processes". The key idea is that one should search for terms that either tend to appear or may appear in the appropriate level of material that would define and introduce the concept, whether or not the phrasing was intended to denote that the reference has some relevant exposition (e.g. a journal article may define something in a useful way, even if it isn't intended to be an introductory text). It is impossible to push against the bad edits on Wikipedia: for certain articles, the number of bad editors exceeds the number of people who can tolerate fixing their errors.
How to digest statistical context?
If I might clarify, your question appears to be: "What can I use to understand mathematics if a major resource like Wikipedia makes no sense?" Keep in mind that even a person who has mastered a conce
How to digest statistical context? If I might clarify, your question appears to be: "What can I use to understand mathematics if a major resource like Wikipedia makes no sense?" Keep in mind that even a person who has mastered a concept had to begin with a period of not understanding it, and then go through a learning process, albeit one that almost never involved learning much from Wikipedia. Having spent a lot of time studying things that are described quite atrociously on Wikipedia, I can assure you that even when one understands the concepts quite well, it is difficult to make sense of what was going through the minds of one or more authors/editors on Wikipedia. It is not uncommon to see mathematical and statistical concepts mutilated by a bunch of people with a very rough grasp of the concepts or in pursuit of advancing yet another field's weak grasp of the fundamental concept. (I would say more, but it is hard to do so without sounding unduly pessimistic about the efforts of Wikipedians, especially those from certain other disciplines.) On a more constructive note, the best references are typically those textbooks edited by publishers with a strong track record of editing and publishing good works in the given field. Authors and editors in such cases have a reputation among their peers for the quality of their scholarship and rigor, and a series of successive editions usually indicates acceptance by other teachers and researchers. There are many levels of quality between that level and Wikipedia. If the print editions are not available, using Amazon's "Search inside the book" or Google Books may be the best alternatives. For other web-accessible references, you may find that review articles or manuals for non-specialist practitioners are most useful. An example of this is the statistics handbook published by NIST. You may need to synthesize your own understanding by way of looking for articles in Google Scholar. For instance you could query ["a point process is a"] and examine the definitions offered in various articles. Alternatively, a web search like ["point process" pdf site:edu] will turn up lecture notes, slides, and tutorials. The first result for that query appears to be "An introduction to point processes". The key idea is that one should search for terms that either tend to appear or may appear in the appropriate level of material that would define and introduce the concept, whether or not the phrasing was intended to denote that the reference has some relevant exposition (e.g. a journal article may define something in a useful way, even if it isn't intended to be an introductory text). It is impossible to push against the bad edits on Wikipedia: for certain articles, the number of bad editors exceeds the number of people who can tolerate fixing their errors.
How to digest statistical context? If I might clarify, your question appears to be: "What can I use to understand mathematics if a major resource like Wikipedia makes no sense?" Keep in mind that even a person who has mastered a conce
18,661
How to digest statistical context?
I understand where you are coming from. In my field of psychology, there are a lot of resources that present statistics in a superficial way. This is fine for many students, yet such books do not provide the prerequisites for reading more sophisticated books. It sounds like you need to (a) get a better picture of the range of statistics books out there and the necessary prerequisites that different resources imply. (b) define your learning goals; (c) identify your current knowledge; and (d) put it all together to create a learning environment. A. Develop sense of the statistics resources landscape Perhaps this provides a rough sense of the introductory statistics resource landscape organised on a continuum of rigour and mathematical sophistication. Cookbooks: Some resources have a cookbook style, showing how to use software and providing tips on when to use and how to interpret statistical output (e.g., SPSS Survival Manual). These books serve a purpose for people who have standardised data analysis needs, and don't have the time nor the inclination to engage in deeper learning. Standard introductions to statistics: There's also a wide range of introductory statistics books that vary in the degree of mathemtical rigour. For some the only prerequisite is that you can perform basic algebra. HyperStat provides one online example. More sophisticated introductions to statistics: While arguably on a continuum, other introductions to statistics are a little more mathematically rigorous. It seems to me that a big difference is whether the textbook assumes the reader is familiar with calculus and linear algebra. As @iterator has noted, the online Handbook of Engineering Statistics is one example of such a more sophisticated resource. Mathematical Statistics: At the next level of rigour are resources that one might classify as mathematical statistics. Check out for example Virtual Laboratories in Probability and Statistics, course notes for this MIT subject on mathematical statistics, or some of the video courses here on mathematical statistics. B. Define your learning goals What is it that you want to do with this statistics knowledge? How important is mathematical rigour? Do you need to understand mathematically sophisticated descriptions that might appear on Wikipedia? C. Identify your current knowledge For many students in the social sciences, engaging with mathematically sophisticated textbooks effectively requires learning or refreshing a large amount of mathematics. However, if you have an engineering background, then I imagine that engaging in a more mathematical treatment should not be a major issue. D. Put it all together Once you've defined what you want to learn, what you already know, and the prerequisites required to learn the new material, the challenge is to find the best resources for you. Does the resource need to be freely available on the Internet, or are you willing to buy or borrow a book? Are you able to learn sufficiently from a textbook style resource or do you want or need a classroom environment with a lecturer verbalising the material and the structure that a course provides? If you are after a textbook on a particular, what textbook do you find clearest, best, and so on? Once you have answers to the above questions, you may have more specific questions that would be suited to this site. E.g., "I know x, y, z, and what is a good textbook that explains a, b, c?"
How to digest statistical context?
I understand where you are coming from. In my field of psychology, there are a lot of resources that present statistics in a superficial way. This is fine for many students, yet such books do not prov
How to digest statistical context? I understand where you are coming from. In my field of psychology, there are a lot of resources that present statistics in a superficial way. This is fine for many students, yet such books do not provide the prerequisites for reading more sophisticated books. It sounds like you need to (a) get a better picture of the range of statistics books out there and the necessary prerequisites that different resources imply. (b) define your learning goals; (c) identify your current knowledge; and (d) put it all together to create a learning environment. A. Develop sense of the statistics resources landscape Perhaps this provides a rough sense of the introductory statistics resource landscape organised on a continuum of rigour and mathematical sophistication. Cookbooks: Some resources have a cookbook style, showing how to use software and providing tips on when to use and how to interpret statistical output (e.g., SPSS Survival Manual). These books serve a purpose for people who have standardised data analysis needs, and don't have the time nor the inclination to engage in deeper learning. Standard introductions to statistics: There's also a wide range of introductory statistics books that vary in the degree of mathemtical rigour. For some the only prerequisite is that you can perform basic algebra. HyperStat provides one online example. More sophisticated introductions to statistics: While arguably on a continuum, other introductions to statistics are a little more mathematically rigorous. It seems to me that a big difference is whether the textbook assumes the reader is familiar with calculus and linear algebra. As @iterator has noted, the online Handbook of Engineering Statistics is one example of such a more sophisticated resource. Mathematical Statistics: At the next level of rigour are resources that one might classify as mathematical statistics. Check out for example Virtual Laboratories in Probability and Statistics, course notes for this MIT subject on mathematical statistics, or some of the video courses here on mathematical statistics. B. Define your learning goals What is it that you want to do with this statistics knowledge? How important is mathematical rigour? Do you need to understand mathematically sophisticated descriptions that might appear on Wikipedia? C. Identify your current knowledge For many students in the social sciences, engaging with mathematically sophisticated textbooks effectively requires learning or refreshing a large amount of mathematics. However, if you have an engineering background, then I imagine that engaging in a more mathematical treatment should not be a major issue. D. Put it all together Once you've defined what you want to learn, what you already know, and the prerequisites required to learn the new material, the challenge is to find the best resources for you. Does the resource need to be freely available on the Internet, or are you willing to buy or borrow a book? Are you able to learn sufficiently from a textbook style resource or do you want or need a classroom environment with a lecturer verbalising the material and the structure that a course provides? If you are after a textbook on a particular, what textbook do you find clearest, best, and so on? Once you have answers to the above questions, you may have more specific questions that would be suited to this site. E.g., "I know x, y, z, and what is a good textbook that explains a, b, c?"
How to digest statistical context? I understand where you are coming from. In my field of psychology, there are a lot of resources that present statistics in a superficial way. This is fine for many students, yet such books do not prov
18,662
How to digest statistical context?
Just to add to excellent answer given by Iterator. Sometimes it is not necessary to understand the concept to successfully use it. I often encounter unknown concepts when reading articles, but before trying to figure out what they mean in external source, I always check whether it is possible to understand what is going on if I assume that the unknown concept is just a new fancy name for something that I already know. More often than not, only some specific easily understandable property of that new concept is used, so I in the end I understand what the author of the article did, and I can decide whether it is useful or not. Taking the example definition in your question, it is possible to simplify it, and actually you can find the simplifications in the same wikipedia article. For example $S=\mathbb{R}^d$ is locally compact second countable Hausdorff space, so if you are working only in $\mathbb{R}^d$, which is nice and understandable, just look for examples where $S=\mathbb{R}^d$ and ignore everything else. Unknown concept can become very simple for your particular problem. Note that this approach does not always work. Sometimes you really need to go deep, and then wikipedia is as good as the starting point for the search. In this case nothing beats a good book. Sometimes it is very easy to find one, sometimes unfortunately there are none.
How to digest statistical context?
Just to add to excellent answer given by Iterator. Sometimes it is not necessary to understand the concept to successfully use it. I often encounter unknown concepts when reading articles, but before
How to digest statistical context? Just to add to excellent answer given by Iterator. Sometimes it is not necessary to understand the concept to successfully use it. I often encounter unknown concepts when reading articles, but before trying to figure out what they mean in external source, I always check whether it is possible to understand what is going on if I assume that the unknown concept is just a new fancy name for something that I already know. More often than not, only some specific easily understandable property of that new concept is used, so I in the end I understand what the author of the article did, and I can decide whether it is useful or not. Taking the example definition in your question, it is possible to simplify it, and actually you can find the simplifications in the same wikipedia article. For example $S=\mathbb{R}^d$ is locally compact second countable Hausdorff space, so if you are working only in $\mathbb{R}^d$, which is nice and understandable, just look for examples where $S=\mathbb{R}^d$ and ignore everything else. Unknown concept can become very simple for your particular problem. Note that this approach does not always work. Sometimes you really need to go deep, and then wikipedia is as good as the starting point for the search. In this case nothing beats a good book. Sometimes it is very easy to find one, sometimes unfortunately there are none.
How to digest statistical context? Just to add to excellent answer given by Iterator. Sometimes it is not necessary to understand the concept to successfully use it. I often encounter unknown concepts when reading articles, but before
18,663
How to digest statistical context?
I think the problem exists but that you are overstating it. If you are persistent in your searching you will find extremely useful books and other sources that keep to a middle ground between the extremely technical (e.g., most articles in the Journal of the American Statistical Association; most pieces written by Andrew Gelman, Bradley Efron, or Donald Rubin) and the extremely simple. I've spent quite a bit of time searching for these 'middle-ground' sources myself. If you care to see some of my recommendations you'll find a set of them at yellowbrickstats.com. I also often find useful information at David Garson's site at North Carolina State U.
How to digest statistical context?
I think the problem exists but that you are overstating it. If you are persistent in your searching you will find extremely useful books and other sources that keep to a middle ground between the ext
How to digest statistical context? I think the problem exists but that you are overstating it. If you are persistent in your searching you will find extremely useful books and other sources that keep to a middle ground between the extremely technical (e.g., most articles in the Journal of the American Statistical Association; most pieces written by Andrew Gelman, Bradley Efron, or Donald Rubin) and the extremely simple. I've spent quite a bit of time searching for these 'middle-ground' sources myself. If you care to see some of my recommendations you'll find a set of them at yellowbrickstats.com. I also often find useful information at David Garson's site at North Carolina State U.
How to digest statistical context? I think the problem exists but that you are overstating it. If you are persistent in your searching you will find extremely useful books and other sources that keep to a middle ground between the ext
18,664
Are there differences in Bayesian and frequentist approaches to EDA?
In my mind, Bayes vs frequentist is about formal inference, and exploratory data analysis is neither. Certainly, when it comes to model assessment/goodness-of-fit and sensitivity analysis, in which I'd classify your points (1), (3), and (4), there will be differences in how one would proceed, but that's because the nature of the differences between the analysis and computational methods rather than about philosophy. Regarding your (2), I don't generally see the results of the EDA as pointing you towards the Bayesian or frquentist approach, but rather I'd think it was the goal of the study that mattered most. For me personally, the EDA (plus deep introspection) would point me towards a model, and if I could find a natural frequentist approach that answered the scientific question reasonably well, I'd go with that, but if by the nature of the situation, no frequentist method would work well, and if there were a reasonable prior, I'd use Bayes.
Are there differences in Bayesian and frequentist approaches to EDA?
In my mind, Bayes vs frequentist is about formal inference, and exploratory data analysis is neither. Certainly, when it comes to model assessment/goodness-of-fit and sensitivity analysis, in which I
Are there differences in Bayesian and frequentist approaches to EDA? In my mind, Bayes vs frequentist is about formal inference, and exploratory data analysis is neither. Certainly, when it comes to model assessment/goodness-of-fit and sensitivity analysis, in which I'd classify your points (1), (3), and (4), there will be differences in how one would proceed, but that's because the nature of the differences between the analysis and computational methods rather than about philosophy. Regarding your (2), I don't generally see the results of the EDA as pointing you towards the Bayesian or frquentist approach, but rather I'd think it was the goal of the study that mattered most. For me personally, the EDA (plus deep introspection) would point me towards a model, and if I could find a natural frequentist approach that answered the scientific question reasonably well, I'd go with that, but if by the nature of the situation, no frequentist method would work well, and if there were a reasonable prior, I'd use Bayes.
Are there differences in Bayesian and frequentist approaches to EDA? In my mind, Bayes vs frequentist is about formal inference, and exploratory data analysis is neither. Certainly, when it comes to model assessment/goodness-of-fit and sensitivity analysis, in which I
18,665
Are there differences in Bayesian and frequentist approaches to EDA?
I thinks that, EDA helps you to build a model, make some assumptions and (if required) update the model and its assumptions. I select a pragmatics approach to use for model fitting and assessment.
Are there differences in Bayesian and frequentist approaches to EDA?
I thinks that, EDA helps you to build a model, make some assumptions and (if required) update the model and its assumptions. I select a pragmatics approach to use for model fitting and assessment.
Are there differences in Bayesian and frequentist approaches to EDA? I thinks that, EDA helps you to build a model, make some assumptions and (if required) update the model and its assumptions. I select a pragmatics approach to use for model fitting and assessment.
Are there differences in Bayesian and frequentist approaches to EDA? I thinks that, EDA helps you to build a model, make some assumptions and (if required) update the model and its assumptions. I select a pragmatics approach to use for model fitting and assessment.
18,666
Why does the random forest OOB estimate of error improve when the number of features selected are decreased?
This is feature selection overfit and this is pretty known -- see Ambroise & McLachlan 2002. The problem is based on the facts that RF is too smart and number of objects is too small. In the latter case, it is generally pretty easy to randomly create attribute that may have good correlation with the decision. And when the number of attributes is large, you may be certain that some of totally irrelevant ones will be a very good predictors, even enough to form a cluster that will be able to recreate the decision in 100%, especially when the huge flexibility of RF is considered. And so, it becomes obvious that when instructed to find the best possible subset of attributes, the FS procedure finds this cluster. One solution (CV) is given in A&McL, you can also test our approach to the topic, the Boruta algorithm, which basically extends the set with "shadow attributes" made to be random by design and compares their RF importance to this obtained for real attributes to judge which of them are indeed random and can be removed; this is replicated many times to be significant. Boruta is rather intended to a bit different task, but as far as my tests showed, the resulting set is free of the FS overfit problem.
Why does the random forest OOB estimate of error improve when the number of features selected are de
This is feature selection overfit and this is pretty known -- see Ambroise & McLachlan 2002. The problem is based on the facts that RF is too smart and number of objects is too small. In the latter c
Why does the random forest OOB estimate of error improve when the number of features selected are decreased? This is feature selection overfit and this is pretty known -- see Ambroise & McLachlan 2002. The problem is based on the facts that RF is too smart and number of objects is too small. In the latter case, it is generally pretty easy to randomly create attribute that may have good correlation with the decision. And when the number of attributes is large, you may be certain that some of totally irrelevant ones will be a very good predictors, even enough to form a cluster that will be able to recreate the decision in 100%, especially when the huge flexibility of RF is considered. And so, it becomes obvious that when instructed to find the best possible subset of attributes, the FS procedure finds this cluster. One solution (CV) is given in A&McL, you can also test our approach to the topic, the Boruta algorithm, which basically extends the set with "shadow attributes" made to be random by design and compares their RF importance to this obtained for real attributes to judge which of them are indeed random and can be removed; this is replicated many times to be significant. Boruta is rather intended to a bit different task, but as far as my tests showed, the resulting set is free of the FS overfit problem.
Why does the random forest OOB estimate of error improve when the number of features selected are de This is feature selection overfit and this is pretty known -- see Ambroise & McLachlan 2002. The problem is based on the facts that RF is too smart and number of objects is too small. In the latter c
18,667
Why does the random forest OOB estimate of error improve when the number of features selected are decreased?
I thought I would add an intuitive explanation for this pattern. In each decision tree comprising the random forest, the data are iteratively split along single dimensions. Crucially, this procedure involves 1) considering only a small, randomly-selected subset of all the explanatory variables, and 2) selecting the most strongly associated explanatory variable within this randomly-selected variable subset to split the data along. Therefore, the probability of the n most important variables being selected at any particular node decreases as the number of explanatory variables increases. Therefore, if one adds in a large number of variables that contribute little-to-no explanatory power, it automatically leads to an increase in the forest's error rate. And conversely, choosing only the most important variables for inclusion will very likely lead to a decrease in the error rate. Random forests are quite robust to this and it typically requires a very large addition of these 'noise' parameters to meaningfully reduce performance.
Why does the random forest OOB estimate of error improve when the number of features selected are de
I thought I would add an intuitive explanation for this pattern. In each decision tree comprising the random forest, the data are iteratively split along single dimensions. Crucially, this procedure
Why does the random forest OOB estimate of error improve when the number of features selected are decreased? I thought I would add an intuitive explanation for this pattern. In each decision tree comprising the random forest, the data are iteratively split along single dimensions. Crucially, this procedure involves 1) considering only a small, randomly-selected subset of all the explanatory variables, and 2) selecting the most strongly associated explanatory variable within this randomly-selected variable subset to split the data along. Therefore, the probability of the n most important variables being selected at any particular node decreases as the number of explanatory variables increases. Therefore, if one adds in a large number of variables that contribute little-to-no explanatory power, it automatically leads to an increase in the forest's error rate. And conversely, choosing only the most important variables for inclusion will very likely lead to a decrease in the error rate. Random forests are quite robust to this and it typically requires a very large addition of these 'noise' parameters to meaningfully reduce performance.
Why does the random forest OOB estimate of error improve when the number of features selected are de I thought I would add an intuitive explanation for this pattern. In each decision tree comprising the random forest, the data are iteratively split along single dimensions. Crucially, this procedure
18,668
Splines: relationship of knots, degree and degrees of freedom
In essence, splines are piecewise polynomials, joined at points called knots. The degree specifies the degree of the polynomials. A polynomial of degree 1 is just a line, so these would be linear splines. Cubic splines have polynomials of degree 3 and so on. The degrees of freedom ($\mathrm{df}$) basically say how many parameters you have to estimate. They have a specific relationship with the number of knots and the degree, which depends on the type of spline. For B-splines: $\mathrm{df} = k + \mathrm{degree}$ if you specify the knots or $k = \mathrm{df} - \mathrm{degree}$ if you specify the degrees of freedom and the degree. For natural (restricted) cubic splines: $\mathrm{df} = k - 1$ if you specify the knots or $k = \mathrm{df} + 1$ if you specify the degrees of freedom. As an example: A cubic spline ($\mathrm{degree}=3$) with $4$ (internal) knots will have $\mathrm{df} = 4 + 3 = 7$ degrees of freedom. Or: A cubic spline ($\mathrm{degree}=3$) with 5 degrees of freedom will have $k = 5 - 3 = 2$ knots. The higher the degrees of freedom, the "wigglier" the spline gets because the number of knots is increased. The Boundary knots are the outermost two knots, ususally (but not always) placed at the minimum and maximum of $x$. The other knots are called internal knots and when I talked about the number of knots I was always referring to the internal knots. Let's see some illustrations. In the scatterplots below you see some artifical data together with the spline fits of different degrees but the same amount of knots ($k = 3$). The knots are indicated by dashed vertical lines (Boundary knots by red dashed lines) and are placed at the 25th, 50th and 75th percentile of $x$. The first plot shows a linear spline ($\mathrm{degree} = 1$), the second one a quadratic spline ($\mathrm{degree} = 2$) and the third is a cubic spline with $\mathrm{degree} = 3$. In the next plot, you see three cubic splines with different degrees of freedom. As before, the knots are shown as dashed vertical lines. With increasing degrees of freedom, the number of knots gets larger (from 1 to 3 to 5). The spline gets wigglier although the difference is only really noticeable between the first and second plot.
Splines: relationship of knots, degree and degrees of freedom
In essence, splines are piecewise polynomials, joined at points called knots. The degree specifies the degree of the polynomials. A polynomial of degree 1 is just a line, so these would be linear spli
Splines: relationship of knots, degree and degrees of freedom In essence, splines are piecewise polynomials, joined at points called knots. The degree specifies the degree of the polynomials. A polynomial of degree 1 is just a line, so these would be linear splines. Cubic splines have polynomials of degree 3 and so on. The degrees of freedom ($\mathrm{df}$) basically say how many parameters you have to estimate. They have a specific relationship with the number of knots and the degree, which depends on the type of spline. For B-splines: $\mathrm{df} = k + \mathrm{degree}$ if you specify the knots or $k = \mathrm{df} - \mathrm{degree}$ if you specify the degrees of freedom and the degree. For natural (restricted) cubic splines: $\mathrm{df} = k - 1$ if you specify the knots or $k = \mathrm{df} + 1$ if you specify the degrees of freedom. As an example: A cubic spline ($\mathrm{degree}=3$) with $4$ (internal) knots will have $\mathrm{df} = 4 + 3 = 7$ degrees of freedom. Or: A cubic spline ($\mathrm{degree}=3$) with 5 degrees of freedom will have $k = 5 - 3 = 2$ knots. The higher the degrees of freedom, the "wigglier" the spline gets because the number of knots is increased. The Boundary knots are the outermost two knots, ususally (but not always) placed at the minimum and maximum of $x$. The other knots are called internal knots and when I talked about the number of knots I was always referring to the internal knots. Let's see some illustrations. In the scatterplots below you see some artifical data together with the spline fits of different degrees but the same amount of knots ($k = 3$). The knots are indicated by dashed vertical lines (Boundary knots by red dashed lines) and are placed at the 25th, 50th and 75th percentile of $x$. The first plot shows a linear spline ($\mathrm{degree} = 1$), the second one a quadratic spline ($\mathrm{degree} = 2$) and the third is a cubic spline with $\mathrm{degree} = 3$. In the next plot, you see three cubic splines with different degrees of freedom. As before, the knots are shown as dashed vertical lines. With increasing degrees of freedom, the number of knots gets larger (from 1 to 3 to 5). The spline gets wigglier although the difference is only really noticeable between the first and second plot.
Splines: relationship of knots, degree and degrees of freedom In essence, splines are piecewise polynomials, joined at points called knots. The degree specifies the degree of the polynomials. A polynomial of degree 1 is just a line, so these would be linear spli
18,669
What is the "effective sample size" of the prior in Bayesian statistics?
Here is an example with a beta prior distribution and a binomial likelihood. Suppose the prior distribution of the heads probability $\theta$ of a coin is $\mathsf{Beta}(10,10)$ and that $n = 100$ tosses of the coin yield $x = 47$ Heads. Then the posterior distribution of $\theta$ is $\mathsf{Beta}(10 + x, 10 + 100 - x) \equiv \mathsf{Beta}(57, 63).$ This results from Bayes' Theorem, multiplying prior $f(\theta)$ by likelihood $g(x|\theta)$ to get posterior $h(\theta|x):$ $$f(\theta)\times g(x|\theta) \propto \theta^{10-1}(1-\theta)^{10-1} \times \theta^{x}(1-\theta)^{n-x}\\ \propto h(\theta|x) \propto \theta^{(10+x)-1}(1-\theta)^{(10+100-x)-1} \propto \theta^{57-1}(1-\theta)^{63-1}.$$ One could say that the prior distribution is 'effectively' equivalent to advance knowledge of $20$ tosses of the coin yielding 10 heads. Note: In the displayed relationship for Bayes' Theorem, use of the symbol $\propto$ (read "proportional to"), instead of $=,$ recognizes that we are showing the kernels (density functions without their norming constants) of the prior, likelihood, and posterior. Because the prior and likelihood are 'conjugate' (mathematically compatible), we can recognize the expression on the right as the kernel of $\mathsf{Beta}(57, 63).$
What is the "effective sample size" of the prior in Bayesian statistics?
Here is an example with a beta prior distribution and a binomial likelihood. Suppose the prior distribution of the heads probability $\theta$ of a coin is $\mathsf{Beta}(10,10)$ and that $n = 100$ tos
What is the "effective sample size" of the prior in Bayesian statistics? Here is an example with a beta prior distribution and a binomial likelihood. Suppose the prior distribution of the heads probability $\theta$ of a coin is $\mathsf{Beta}(10,10)$ and that $n = 100$ tosses of the coin yield $x = 47$ Heads. Then the posterior distribution of $\theta$ is $\mathsf{Beta}(10 + x, 10 + 100 - x) \equiv \mathsf{Beta}(57, 63).$ This results from Bayes' Theorem, multiplying prior $f(\theta)$ by likelihood $g(x|\theta)$ to get posterior $h(\theta|x):$ $$f(\theta)\times g(x|\theta) \propto \theta^{10-1}(1-\theta)^{10-1} \times \theta^{x}(1-\theta)^{n-x}\\ \propto h(\theta|x) \propto \theta^{(10+x)-1}(1-\theta)^{(10+100-x)-1} \propto \theta^{57-1}(1-\theta)^{63-1}.$$ One could say that the prior distribution is 'effectively' equivalent to advance knowledge of $20$ tosses of the coin yielding 10 heads. Note: In the displayed relationship for Bayes' Theorem, use of the symbol $\propto$ (read "proportional to"), instead of $=,$ recognizes that we are showing the kernels (density functions without their norming constants) of the prior, likelihood, and posterior. Because the prior and likelihood are 'conjugate' (mathematically compatible), we can recognize the expression on the right as the kernel of $\mathsf{Beta}(57, 63).$
What is the "effective sample size" of the prior in Bayesian statistics? Here is an example with a beta prior distribution and a binomial likelihood. Suppose the prior distribution of the heads probability $\theta$ of a coin is $\mathsf{Beta}(10,10)$ and that $n = 100$ tos
18,670
What is the "effective sample size" of the prior in Bayesian statistics?
Prior effective sample size (ESS) doesn't have a single definition. It's a heuristic to understand the influence of the prior on the posterior parameters. Prior ESS tells you that your choice of prior is comparable to having an additional $n_{E}$ data points. It is straightforward to demonstrate prior ESS with conjugate priors. It is more complicated when you have non-conjugate priors. Conjugate Priors Beta-Binomial Example Say you having a binomial random variable, $Y$ and you want to estimate the probability of success, $\theta$. You observe $y$ successes and $n-y$ failures. Assume a $Beta(\alpha, \beta)$ for $\theta$. $$ Y \sim Binom(n, \theta),$$ $$\theta \sim Beta(\alpha, \beta), \text{ and }$$ $$ \theta | Y \sim Beta(\alpha + y, \beta + n - y)$$ If the prior contributed no information to the posterior, we would use only the data to inform the posterior: $\theta | y \sim Beta(y, n - y)$. We can compare the parameters of this noninformative posterior to the general form of the posterior to see how the prior adds information to the likelihood. The $Beta(\alpha, \beta)$ prior is equivalent to observing an additional $\alpha$ heads and an additional $\beta$ tails. So the prior effective sample size is $\alpha + \beta$. Non-conjugate case When the prior and the likelihood aren't conjugate, we can't see exactly how the prior parameters interact with the likelihood to make the posterior parameters. Morita et all (2008) generalize the concept from conjugate distributions to distributions in general. I'll give the concept, but you can reference that paper for all the details. You find the prior ESS with the algoritm: Choose your prior distribution. Calculate the information matrix of the prior parameter. Identify a non-informative alternative to (1). Ex: $\theta \sim Normal(\mu = 0, \sigma^2 = 10e5)$ Take a sequence from $m = 0, \dots, M$ and get the posterior for each prior (2) with a dataset of size $m$. Calculate the information matrix. The prior ESS is the same size, $m_o$, which minimizes the distance of between the prior information from (1) and posterior information from (3).
What is the "effective sample size" of the prior in Bayesian statistics?
Prior effective sample size (ESS) doesn't have a single definition. It's a heuristic to understand the influence of the prior on the posterior parameters. Prior ESS tells you that your choice of prior
What is the "effective sample size" of the prior in Bayesian statistics? Prior effective sample size (ESS) doesn't have a single definition. It's a heuristic to understand the influence of the prior on the posterior parameters. Prior ESS tells you that your choice of prior is comparable to having an additional $n_{E}$ data points. It is straightforward to demonstrate prior ESS with conjugate priors. It is more complicated when you have non-conjugate priors. Conjugate Priors Beta-Binomial Example Say you having a binomial random variable, $Y$ and you want to estimate the probability of success, $\theta$. You observe $y$ successes and $n-y$ failures. Assume a $Beta(\alpha, \beta)$ for $\theta$. $$ Y \sim Binom(n, \theta),$$ $$\theta \sim Beta(\alpha, \beta), \text{ and }$$ $$ \theta | Y \sim Beta(\alpha + y, \beta + n - y)$$ If the prior contributed no information to the posterior, we would use only the data to inform the posterior: $\theta | y \sim Beta(y, n - y)$. We can compare the parameters of this noninformative posterior to the general form of the posterior to see how the prior adds information to the likelihood. The $Beta(\alpha, \beta)$ prior is equivalent to observing an additional $\alpha$ heads and an additional $\beta$ tails. So the prior effective sample size is $\alpha + \beta$. Non-conjugate case When the prior and the likelihood aren't conjugate, we can't see exactly how the prior parameters interact with the likelihood to make the posterior parameters. Morita et all (2008) generalize the concept from conjugate distributions to distributions in general. I'll give the concept, but you can reference that paper for all the details. You find the prior ESS with the algoritm: Choose your prior distribution. Calculate the information matrix of the prior parameter. Identify a non-informative alternative to (1). Ex: $\theta \sim Normal(\mu = 0, \sigma^2 = 10e5)$ Take a sequence from $m = 0, \dots, M$ and get the posterior for each prior (2) with a dataset of size $m$. Calculate the information matrix. The prior ESS is the same size, $m_o$, which minimizes the distance of between the prior information from (1) and posterior information from (3).
What is the "effective sample size" of the prior in Bayesian statistics? Prior effective sample size (ESS) doesn't have a single definition. It's a heuristic to understand the influence of the prior on the posterior parameters. Prior ESS tells you that your choice of prior
18,671
Is the sample quantile unbiased for the true quantile?
Assuming that $X_1, X_2, X_3 \sim \text{IID } F$ the empirical distribution function has a scaled binomial distribution: $$\hat{F}_n(x) \sim \frac{1}{n} \cdot \text{Bin}(n, F(x)).$$ For a given probability value $0 < p < 1$ we will denote the sample quantile as: $$\hat{Q} \equiv \hat{Q}_n(p) \equiv \inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \}.$$ Since the empirical distribution function $\hat{F}_n$ is non-decreasing and right-continuous, we have the event equivalence $\inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \} \leqslant q$ if and only if $\hat{F}_n(q) \geqslant p$. Thus, the distribution function for the sample quantile is: $$\begin{equation} \begin{aligned} F_{\hat{Q}}(q) = \mathbb{P}(\hat{Q} \leqslant q) = \mathbb{P} \bigg( \inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \} \leqslant q \bigg) = \mathbb{P} \big( \hat{F}_n(q) \geqslant p \big). \\[6pt] \end{aligned} \end{equation}$$ In order to look at the bias of the sample quantile as an estimator of the true quantile, we need to look at the expected value of the former. Using a general expectation rule shown here, the exact expected value of this random variable can be written as the integral: $$\mathbb{E}(\hat{Q}) = \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - F_{\hat{Q}}(q) \Big] dq = \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - \mathbb{P} ( \hat{F}_n(q) \geqslant p ) \Big] dq.$$ This integral is complicated, owing to the scaled binomial distribution for $\hat{F}_n$. However, as $n \rightarrow \infty$ we have $\hat{F}_n(q) \rightarrow F(q)$, and so if $F$ is continuous at $q$ then we also have $Q(\hat{F}_n(q)) \rightarrow q$. This gives the asymptotic convergence: $$\mathbb{E}(\hat{Q}) \rightarrow \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - \mathbb{I} ( q \geqslant Q(p) ) \Big] dq = \int \limits_{0}^{Q(p)} dq = Q(p),$$ so long as $F$ is continuous at $p$. Thus, you should expect the sample quantiles to be asymptotically unbiased, except at quantiles corresponding to points of discontinuity of the underlying distribution function. Obviously we may have non-zero bias for finite samples, with the bias depending on the form of the underlying distribution.
Is the sample quantile unbiased for the true quantile?
Assuming that $X_1, X_2, X_3 \sim \text{IID } F$ the empirical distribution function has a scaled binomial distribution: $$\hat{F}_n(x) \sim \frac{1}{n} \cdot \text{Bin}(n, F(x)).$$ For a given probab
Is the sample quantile unbiased for the true quantile? Assuming that $X_1, X_2, X_3 \sim \text{IID } F$ the empirical distribution function has a scaled binomial distribution: $$\hat{F}_n(x) \sim \frac{1}{n} \cdot \text{Bin}(n, F(x)).$$ For a given probability value $0 < p < 1$ we will denote the sample quantile as: $$\hat{Q} \equiv \hat{Q}_n(p) \equiv \inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \}.$$ Since the empirical distribution function $\hat{F}_n$ is non-decreasing and right-continuous, we have the event equivalence $\inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \} \leqslant q$ if and only if $\hat{F}_n(q) \geqslant p$. Thus, the distribution function for the sample quantile is: $$\begin{equation} \begin{aligned} F_{\hat{Q}}(q) = \mathbb{P}(\hat{Q} \leqslant q) = \mathbb{P} \bigg( \inf \{ x \in \mathbb{R} | \hat{F}_n(x) \geqslant p \} \leqslant q \bigg) = \mathbb{P} \big( \hat{F}_n(q) \geqslant p \big). \\[6pt] \end{aligned} \end{equation}$$ In order to look at the bias of the sample quantile as an estimator of the true quantile, we need to look at the expected value of the former. Using a general expectation rule shown here, the exact expected value of this random variable can be written as the integral: $$\mathbb{E}(\hat{Q}) = \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - F_{\hat{Q}}(q) \Big] dq = \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - \mathbb{P} ( \hat{F}_n(q) \geqslant p ) \Big] dq.$$ This integral is complicated, owing to the scaled binomial distribution for $\hat{F}_n$. However, as $n \rightarrow \infty$ we have $\hat{F}_n(q) \rightarrow F(q)$, and so if $F$ is continuous at $q$ then we also have $Q(\hat{F}_n(q)) \rightarrow q$. This gives the asymptotic convergence: $$\mathbb{E}(\hat{Q}) \rightarrow \int \limits_{-\infty}^\infty \Big[ \mathbb{I}(q \geqslant 0) - \mathbb{I} ( q \geqslant Q(p) ) \Big] dq = \int \limits_{0}^{Q(p)} dq = Q(p),$$ so long as $F$ is continuous at $p$. Thus, you should expect the sample quantiles to be asymptotically unbiased, except at quantiles corresponding to points of discontinuity of the underlying distribution function. Obviously we may have non-zero bias for finite samples, with the bias depending on the form of the underlying distribution.
Is the sample quantile unbiased for the true quantile? Assuming that $X_1, X_2, X_3 \sim \text{IID } F$ the empirical distribution function has a scaled binomial distribution: $$\hat{F}_n(x) \sim \frac{1}{n} \cdot \text{Bin}(n, F(x)).$$ For a given probab
18,672
Is the sample quantile unbiased for the true quantile?
I do not think Ben's derivation is completely correct. The asymptotic unbiasedness feature of sample quantile is not distribution free. There is an important assumption that the r.v. has to satisfy: there is a unique solution $x$ to the condition $F(x-) \leq p \leq F(x)$. A counter example: Let $X_1, \dots, X_n \sim$ $X$ i.i.d. where $X$ is Bernoulli taking $-1$ with probability $0.5$ and $1$ with probability $0.5$. Now let $p = 0.5$, then the theoretical quantile (median) $Q(p)$ should be $-1$. Now for the sample quantile $$ Q_n(p) = \begin{cases} -1, & \sum_{i=1}^n\mathbf{1}_{X_i = -1} \geq n/2 \\ 1, & \sum_{i=1}^n\mathbf{1}_{X_i = -1} < n/2. \end{cases} $$ Therefore, $$ E(Q_n(p)) = -P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} \geq 1/2\right) + P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} < 1/2\right). $$ Now if we take the limit, because of CLT, $$ \lim_{n\to\infty}P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} \geq 1/2\right) = \lim_{n\to\infty}P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} < 1/2\right) = 0.5. $$ Therefore, $\lim_{n\to\infty}E(Q_n(p)) = 0 \neq -1$. In fact, we can also check this with mean(2*(replicate(2000, mean(2*rbernoulli(10^6)-1 ==-1)) >= 0.5)-1) which gave an answer of -0.011. The issue is when the solution to $F(x-) \leq p \leq F(x)$ is not unique, i.e., there are segments where the cdf are flat. The sample quantile will jump around and does not settle down.
Is the sample quantile unbiased for the true quantile?
I do not think Ben's derivation is completely correct. The asymptotic unbiasedness feature of sample quantile is not distribution free. There is an important assumption that the r.v. has to satisfy: t
Is the sample quantile unbiased for the true quantile? I do not think Ben's derivation is completely correct. The asymptotic unbiasedness feature of sample quantile is not distribution free. There is an important assumption that the r.v. has to satisfy: there is a unique solution $x$ to the condition $F(x-) \leq p \leq F(x)$. A counter example: Let $X_1, \dots, X_n \sim$ $X$ i.i.d. where $X$ is Bernoulli taking $-1$ with probability $0.5$ and $1$ with probability $0.5$. Now let $p = 0.5$, then the theoretical quantile (median) $Q(p)$ should be $-1$. Now for the sample quantile $$ Q_n(p) = \begin{cases} -1, & \sum_{i=1}^n\mathbf{1}_{X_i = -1} \geq n/2 \\ 1, & \sum_{i=1}^n\mathbf{1}_{X_i = -1} < n/2. \end{cases} $$ Therefore, $$ E(Q_n(p)) = -P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} \geq 1/2\right) + P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} < 1/2\right). $$ Now if we take the limit, because of CLT, $$ \lim_{n\to\infty}P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} \geq 1/2\right) = \lim_{n\to\infty}P\left(\frac{\sum_{i=1}^n\mathbf{1}_{X_i = -1}}{n} < 1/2\right) = 0.5. $$ Therefore, $\lim_{n\to\infty}E(Q_n(p)) = 0 \neq -1$. In fact, we can also check this with mean(2*(replicate(2000, mean(2*rbernoulli(10^6)-1 ==-1)) >= 0.5)-1) which gave an answer of -0.011. The issue is when the solution to $F(x-) \leq p \leq F(x)$ is not unique, i.e., there are segments where the cdf are flat. The sample quantile will jump around and does not settle down.
Is the sample quantile unbiased for the true quantile? I do not think Ben's derivation is completely correct. The asymptotic unbiasedness feature of sample quantile is not distribution free. There is an important assumption that the r.v. has to satisfy: t
18,673
A/B testing ratio of sums
z-test of proportions This applies to a different case when you have binary outcomes. The z-test of proportions compares the proportions of those binary outcomes. (Below some argument is made that you will be able to do a t-test, which for large numbers is approximately the same as the z-test. With proportions you can do a z-test because the binomial distribution has one parameter determining the variance and mean, unlike a normal distribution) Bootstrapping This will be possible but not really neccesary because of the Delta method which provides the error of your observed statistic more straightforward. Delta method You are interested in the ratio of two, possibly correlated variables, 1. the total sales and 2. the sales in star items. These variables are likely asymptotically normal distributed since they are the sums of the sales from many individuals (the testing procedure could be considered to be a process like picking a sample of sales from individual users from a distribution of sales from individual users). Thus you can use the Delta method. The use of the Delta method for the estimation of ratio's is described here. The result of this application of the Delta method actually coincides with an approximation of Hinkley's result, an exact expression for the ratio of two correlated normal distributed variables (Hinkley D.V., 1969, On the Ratio of Two Correlated Normal Random Variables, Biometrica vol. 56 no. 3). (Sidenote: As noted by Xi'an in the comments an earlier description of the exact expression was given by George Marsaglia 1965 in the JASA Vol. 60, No. 309. A simple modern description is given in 2006 in Jstatsoft Volume 16 Issue 4) For $Z = \frac{X}{Y}$ with $$ \begin{bmatrix}X\\Y\end{bmatrix} \sim N\left(\begin{bmatrix} \mu_x \\ \mu_y \end{bmatrix} , \begin{bmatrix} \sigma_x^2 & \rho \sigma_x \sigma_y \\ \rho \sigma_x \sigma_y & \sigma_y^2 \end{bmatrix} \right) $$ The exact result is: $$ f(z) = \frac{b(z)d(z)}{a(z)^3} \frac{1}{\sqrt{2\pi} \sigma_X\sigma_Y} \left[ \Phi \left( \frac{b(z)}{\sqrt{1-\rho^2}a(z)} \right) - \Phi \left( - \frac{b(z)}{\sqrt{1-\rho^2}a(z)} \right) \right] + \frac{\sqrt{1-\rho^2}}{\pi \sigma_X \sigma_Y a(z)^2} \exp \left( -\frac{c}{2(1-\rho^2)}\right) $$ with $$ \begin{array}{} a(z) &=& \left( \frac{z^2}{\sigma_X^2} - \frac{2 \rho z}{\sigma_X \sigma_Y} + \frac{1}{\sigma_Y^2} \right) ^{\frac{1}{2}} \\ b(z) &=& \frac{\mu_X z}{ \sigma_X^2} - \frac{\rho (\mu_X+ \mu_Y z)}{ \sigma_X \sigma_Y} + \frac{\mu_Y}{\sigma_Y^2} \\ c &=& \frac{\mu_X^2}{\sigma_Y^2} - \frac{2 \rho \mu_X \mu_Y + }{\sigma_X \sigma_Y} + \frac{\mu_Y^2}{\sigma_Y^2}\\ d(z) &=& \text{exp} \left( \frac {b(z)^2 - c a(z) ^2}{2(1-\rho^2)a(z)^2}\right) \end{array}$$ And an approximation based on an assymptotic behaviour is: (for $\mu_Y/\sigma_Y \to \infty$): $$ F(z) \to \Phi\left( \frac{z - \mu_X/\mu_Y}{\sigma_X \sigma_Y a(z)/\mu_Y} \right) $$ You end up with the Delta method result when you insert the approximation $a(z) = a(\mu_X/\mu_Y)$ $$a(z) \sigma_X \sigma_Y /\mu_Y \approx a(\mu_X/\mu_Y) \sigma_X \sigma_Y /\mu_Y = \left( \frac{\mu_X^2\sigma_Y^2}{\mu_Y^4} - \frac{2 \mu_X \rho \sigma_X \sigma_Y}{\mu_Y^3} + \frac{\sigma_X^2}{\mu_Y^2} \right) ^{\frac{1}{2}}$$ The values for $\mu_X,\mu_Y,\sigma_X,\sigma_Y,\rho$ can be estimated from your observations which allow you to estimate the variance and mean of the distribution for single users and related to this the variance and mean for the sample distribution of the sum of several users. Change the metric I believe that it is interresting to do at least an intitial plot of the distribution of the sales (not the ratios) from the single users. Eventually you might end up with a situation that there is a difference between the users in group A and B, but it just happens to be not significant when you regard the single variable of the ratio (this is a bit similar to MANOVA being more powerfull than single ANOVA tests). While the knowledge of a difference between groups, without a significant difference in the metric that you are interrested in, may not help you much in making decisions, it does help you in understanding the underlying theory and possibly design better changes/experiments next time. Illustration Below is a simple illustration: Let the hypothetical distribution of sales from users be distributed as fractions $a,b,c,d$ which indicate how many user are of a particular case (in reality this distribution will be more complex): star item sales 0$ 40$ other item sales 0$ a b 10$ c d Then the sample distribution for totals from a groups with 10000 users, with for one algorithm $$a=0.190,b=0.001,c=0.800,d=0.009$$ and the other algorithm $$a=0.170,b=0.001,c=0.820,d=0.009$$ will look like: Which shows 10000 runs drawing new users and computing the sales and ratios. The histogram is for the distribution of the ratios. The lines are computations using the function from Hinkley. You can see that the distribution of the two total sales numbers is approximately a multivariate normal. The isolines for the ratio show that you can estimate the ratio very well as a linear sum (as in the previous mentioned/linked linearized Delta method) and that an approximation by a Gaussian distribution should work well (and then you can use a t-test which for large numbers will be just like a z-test). You can also see that a scatterplot like this might provide you with more information and insight in comparison to using only the histogram. R-Code for computing the graph: set.seed(1) # # # function to sampling hypothetic n users # which will buy star items and/or regular items # # star item sales # 0$ 40$ # # regular item sales 0$ a b # 10$ c d # # sample_users <- function(n,a,b,c,d) { # sampling q <- sample(1:4, n, replace=TRUE, prob=c(a,b,c,d)) # total dolar value of items dri = (sum(q==3)+sum(q==4))*10 dsi = (sum(q==2)+sum(q==4))*40 # output list(dri=dri,dsi=dsi,dti=dri+dsi, q=q) } # # function for drawing those blocks for the tilted histogram # block <- function(phi=0.045+0.001/2, r=100, col=1) { if (col == 1) { bgs <- rgb(0,0,1,1/4) cols <- rgb(0,0,1,1/4) } else { bgs <- rgb(1,0,0,1/4) cols <- rgb(1,0,0,1/4) } angle <- c(atan(phi+0.001/2),atan(phi+0.001/2),atan(phi-0.001/2),atan(phi-0.001/2)) rr <- c(90000,90000+r,90000+r,90000) x <- cos(angle)*rr y <- sin(angle)*rr polygon(x,y,col=cols,bg=bgs) } block <- Vectorize(block) # # function to compute Hinkley's density formula # fw <- function(w,mu1,mu2,sig1,sig2,rho) { #several parameters aw <- sqrt(w^2/sig1^2 - 2*rho*w/(sig1*sig2) + 1/sig2^2) bw <- w*mu1/sig1^2 - rho*(mu1+mu2*w)/(sig1*sig2)+ mu2/sig2^2 c <- mu1^2/sig1^2 - 2 * rho * mu1 * mu2 / (sig1*sig2) + mu2^2/sig2^2 dw <- exp((bw^2 - c*aw^2)/(2*(1-rho^2)*aw^2)) # output from Hinkley's density formula out <- (bw*dw / ( sqrt(2*pi) * sig1 * sig2 * aw^3)) * (pnorm(bw/aw/sqrt(1-rho^2),0,1) - pnorm(-bw/aw/sqrt(1-rho^2),0,1)) + sqrt(1-rho^2)/(pi*sig1*sig2*aw^2) * exp(-c/(2*(1-rho^2))) out } fw <- Vectorize(fw) # # function to compute # theoretic distribution for sample with parameters (a,b,c,d) # lazy way to compute the mean and variance of the theoretic distribution fwusers <- function(na,nb,nc,nd,n=10000) { users <- c(rep(1,na),rep(2,nb),rep(3,nc),rep(4,nd)) dsi <- c(0,40,0,40)[users] dri <- c(0,0,10,10)[users] dti <- dsi+dri sig1 <- sqrt(var(dsi))*sqrt(n) sig2 <- sqrt(var(dti))*sqrt(n) cor <- cor(dti,dsi) mu1 <- mean(dsi)*n mu2 <- mean(dti)*n w <- seq(0,1,0.001) f <- fw(w,mu1,mu2,sig1,sig2,cor) list(w=w,f=f,sig1 = sig1, sig2=sig2, cor = cor, mu1= mu1, mu2 = mu2) } # sample many ntr time to display sample distribution of experiment outcome ntr <- 10^4 # sample A dsi1 <- rep(0,ntr) dti1 <- rep(0,ntr) for (i in 1:ntr) { users <- sample_users(10000,0.19,0.001,0.8,0.009) dsi1[i] <- users$dsi dti1[i] <- users$dti } # sample B dsi2 <- rep(0,ntr) dti2 <- rep(0,ntr) for (i in 1:ntr) { users <- sample_users(10000,0.19-0.02,0.001,0.8+0.02,0.009) dsi2[i] <- users$dsi dti2[i] <- users$dti } # hiostograms for ratio ratio1 <- dsi1/dti1 ratio2 <- dsi2/dti2 h1<-hist(ratio1, breaks = seq(0, round(max(ratio2+0.04),2), 0.001)) h2<-hist(ratio2, breaks = seq(0, round(max(ratio2+0.04),2), 0.001)) # plotting plot(0, 0, xlab = "sum of total sales", ylab = "sum of star item sales", xlim = c(82000,92000), ylim = c(2500,6000), pch=21, col = rgb(0,0,1,1/10), bg = rgb(0,0,1,1/10)) title("sample distribution for sum of 10 000 users") # isolines brks <- seq(0, round(max(ratio2+0.02),2), 0.001) for (ls in 1:length(brks)) { col=rgb(0,0,0,0.25+0.25*(ls%%5==1)) lines(c(0,10000000),c(0,10000000)*brks[ls],lty=2,col=col) } # scatter points points(dti1, dsi1, pch=21, col = rgb(0,0,1,1/10), bg = rgb(0,0,1,1/10)) points(dti2, dsi2, pch=21, col = rgb(1,0,0,1/10), bg = rgb(1,0,0,1/10)) # diagonal axis phi <- atan(h1$breaks) r <- 90000 lines(cos(phi)*r,sin(phi)*r,col=1) # histograms phi <- h1$mids r <- h1$density*10 block(phi,r,col=1) phi <- h2$mids r <- h2$density*10 block(phi,r,col=2) # labels for histogram axis phi <- atan(h1$breaks)[1+10*c(1:7)] r <- 90000 text(cos(phi)*r-130,sin(phi)*r,h1$breaks[1+10*c(1:7)],srt=-87.5,cex=0.9) text(cos(atan(0.045))*r-400,sin(atan(0.045))*r,"ratio of sum of star items and sum of total items", srt=-87.5,cex=0.9) # plotting functions for Hinkley densities using variance and means estimated from theoretic samples distribution wf1 <- fwusers(190,1,800,9,10000) wf2 <- fwusers(170,1,820,9,10000) rf1 <- 90000+10*wf1$f phi1 <- atan(wf1$w) lines(cos(phi1)*rf1,sin(phi1)*rf1,col=4) rf2 <- 90000+10*wf2$f phi2 <- atan(wf2$w) lines(cos(phi2)*rf2,sin(phi2)*rf2,col=2)
A/B testing ratio of sums
z-test of proportions This applies to a different case when you have binary outcomes. The z-test of proportions compares the proportions of those binary outcomes. (Below some argument is made that yo
A/B testing ratio of sums z-test of proportions This applies to a different case when you have binary outcomes. The z-test of proportions compares the proportions of those binary outcomes. (Below some argument is made that you will be able to do a t-test, which for large numbers is approximately the same as the z-test. With proportions you can do a z-test because the binomial distribution has one parameter determining the variance and mean, unlike a normal distribution) Bootstrapping This will be possible but not really neccesary because of the Delta method which provides the error of your observed statistic more straightforward. Delta method You are interested in the ratio of two, possibly correlated variables, 1. the total sales and 2. the sales in star items. These variables are likely asymptotically normal distributed since they are the sums of the sales from many individuals (the testing procedure could be considered to be a process like picking a sample of sales from individual users from a distribution of sales from individual users). Thus you can use the Delta method. The use of the Delta method for the estimation of ratio's is described here. The result of this application of the Delta method actually coincides with an approximation of Hinkley's result, an exact expression for the ratio of two correlated normal distributed variables (Hinkley D.V., 1969, On the Ratio of Two Correlated Normal Random Variables, Biometrica vol. 56 no. 3). (Sidenote: As noted by Xi'an in the comments an earlier description of the exact expression was given by George Marsaglia 1965 in the JASA Vol. 60, No. 309. A simple modern description is given in 2006 in Jstatsoft Volume 16 Issue 4) For $Z = \frac{X}{Y}$ with $$ \begin{bmatrix}X\\Y\end{bmatrix} \sim N\left(\begin{bmatrix} \mu_x \\ \mu_y \end{bmatrix} , \begin{bmatrix} \sigma_x^2 & \rho \sigma_x \sigma_y \\ \rho \sigma_x \sigma_y & \sigma_y^2 \end{bmatrix} \right) $$ The exact result is: $$ f(z) = \frac{b(z)d(z)}{a(z)^3} \frac{1}{\sqrt{2\pi} \sigma_X\sigma_Y} \left[ \Phi \left( \frac{b(z)}{\sqrt{1-\rho^2}a(z)} \right) - \Phi \left( - \frac{b(z)}{\sqrt{1-\rho^2}a(z)} \right) \right] + \frac{\sqrt{1-\rho^2}}{\pi \sigma_X \sigma_Y a(z)^2} \exp \left( -\frac{c}{2(1-\rho^2)}\right) $$ with $$ \begin{array}{} a(z) &=& \left( \frac{z^2}{\sigma_X^2} - \frac{2 \rho z}{\sigma_X \sigma_Y} + \frac{1}{\sigma_Y^2} \right) ^{\frac{1}{2}} \\ b(z) &=& \frac{\mu_X z}{ \sigma_X^2} - \frac{\rho (\mu_X+ \mu_Y z)}{ \sigma_X \sigma_Y} + \frac{\mu_Y}{\sigma_Y^2} \\ c &=& \frac{\mu_X^2}{\sigma_Y^2} - \frac{2 \rho \mu_X \mu_Y + }{\sigma_X \sigma_Y} + \frac{\mu_Y^2}{\sigma_Y^2}\\ d(z) &=& \text{exp} \left( \frac {b(z)^2 - c a(z) ^2}{2(1-\rho^2)a(z)^2}\right) \end{array}$$ And an approximation based on an assymptotic behaviour is: (for $\mu_Y/\sigma_Y \to \infty$): $$ F(z) \to \Phi\left( \frac{z - \mu_X/\mu_Y}{\sigma_X \sigma_Y a(z)/\mu_Y} \right) $$ You end up with the Delta method result when you insert the approximation $a(z) = a(\mu_X/\mu_Y)$ $$a(z) \sigma_X \sigma_Y /\mu_Y \approx a(\mu_X/\mu_Y) \sigma_X \sigma_Y /\mu_Y = \left( \frac{\mu_X^2\sigma_Y^2}{\mu_Y^4} - \frac{2 \mu_X \rho \sigma_X \sigma_Y}{\mu_Y^3} + \frac{\sigma_X^2}{\mu_Y^2} \right) ^{\frac{1}{2}}$$ The values for $\mu_X,\mu_Y,\sigma_X,\sigma_Y,\rho$ can be estimated from your observations which allow you to estimate the variance and mean of the distribution for single users and related to this the variance and mean for the sample distribution of the sum of several users. Change the metric I believe that it is interresting to do at least an intitial plot of the distribution of the sales (not the ratios) from the single users. Eventually you might end up with a situation that there is a difference between the users in group A and B, but it just happens to be not significant when you regard the single variable of the ratio (this is a bit similar to MANOVA being more powerfull than single ANOVA tests). While the knowledge of a difference between groups, without a significant difference in the metric that you are interrested in, may not help you much in making decisions, it does help you in understanding the underlying theory and possibly design better changes/experiments next time. Illustration Below is a simple illustration: Let the hypothetical distribution of sales from users be distributed as fractions $a,b,c,d$ which indicate how many user are of a particular case (in reality this distribution will be more complex): star item sales 0$ 40$ other item sales 0$ a b 10$ c d Then the sample distribution for totals from a groups with 10000 users, with for one algorithm $$a=0.190,b=0.001,c=0.800,d=0.009$$ and the other algorithm $$a=0.170,b=0.001,c=0.820,d=0.009$$ will look like: Which shows 10000 runs drawing new users and computing the sales and ratios. The histogram is for the distribution of the ratios. The lines are computations using the function from Hinkley. You can see that the distribution of the two total sales numbers is approximately a multivariate normal. The isolines for the ratio show that you can estimate the ratio very well as a linear sum (as in the previous mentioned/linked linearized Delta method) and that an approximation by a Gaussian distribution should work well (and then you can use a t-test which for large numbers will be just like a z-test). You can also see that a scatterplot like this might provide you with more information and insight in comparison to using only the histogram. R-Code for computing the graph: set.seed(1) # # # function to sampling hypothetic n users # which will buy star items and/or regular items # # star item sales # 0$ 40$ # # regular item sales 0$ a b # 10$ c d # # sample_users <- function(n,a,b,c,d) { # sampling q <- sample(1:4, n, replace=TRUE, prob=c(a,b,c,d)) # total dolar value of items dri = (sum(q==3)+sum(q==4))*10 dsi = (sum(q==2)+sum(q==4))*40 # output list(dri=dri,dsi=dsi,dti=dri+dsi, q=q) } # # function for drawing those blocks for the tilted histogram # block <- function(phi=0.045+0.001/2, r=100, col=1) { if (col == 1) { bgs <- rgb(0,0,1,1/4) cols <- rgb(0,0,1,1/4) } else { bgs <- rgb(1,0,0,1/4) cols <- rgb(1,0,0,1/4) } angle <- c(atan(phi+0.001/2),atan(phi+0.001/2),atan(phi-0.001/2),atan(phi-0.001/2)) rr <- c(90000,90000+r,90000+r,90000) x <- cos(angle)*rr y <- sin(angle)*rr polygon(x,y,col=cols,bg=bgs) } block <- Vectorize(block) # # function to compute Hinkley's density formula # fw <- function(w,mu1,mu2,sig1,sig2,rho) { #several parameters aw <- sqrt(w^2/sig1^2 - 2*rho*w/(sig1*sig2) + 1/sig2^2) bw <- w*mu1/sig1^2 - rho*(mu1+mu2*w)/(sig1*sig2)+ mu2/sig2^2 c <- mu1^2/sig1^2 - 2 * rho * mu1 * mu2 / (sig1*sig2) + mu2^2/sig2^2 dw <- exp((bw^2 - c*aw^2)/(2*(1-rho^2)*aw^2)) # output from Hinkley's density formula out <- (bw*dw / ( sqrt(2*pi) * sig1 * sig2 * aw^3)) * (pnorm(bw/aw/sqrt(1-rho^2),0,1) - pnorm(-bw/aw/sqrt(1-rho^2),0,1)) + sqrt(1-rho^2)/(pi*sig1*sig2*aw^2) * exp(-c/(2*(1-rho^2))) out } fw <- Vectorize(fw) # # function to compute # theoretic distribution for sample with parameters (a,b,c,d) # lazy way to compute the mean and variance of the theoretic distribution fwusers <- function(na,nb,nc,nd,n=10000) { users <- c(rep(1,na),rep(2,nb),rep(3,nc),rep(4,nd)) dsi <- c(0,40,0,40)[users] dri <- c(0,0,10,10)[users] dti <- dsi+dri sig1 <- sqrt(var(dsi))*sqrt(n) sig2 <- sqrt(var(dti))*sqrt(n) cor <- cor(dti,dsi) mu1 <- mean(dsi)*n mu2 <- mean(dti)*n w <- seq(0,1,0.001) f <- fw(w,mu1,mu2,sig1,sig2,cor) list(w=w,f=f,sig1 = sig1, sig2=sig2, cor = cor, mu1= mu1, mu2 = mu2) } # sample many ntr time to display sample distribution of experiment outcome ntr <- 10^4 # sample A dsi1 <- rep(0,ntr) dti1 <- rep(0,ntr) for (i in 1:ntr) { users <- sample_users(10000,0.19,0.001,0.8,0.009) dsi1[i] <- users$dsi dti1[i] <- users$dti } # sample B dsi2 <- rep(0,ntr) dti2 <- rep(0,ntr) for (i in 1:ntr) { users <- sample_users(10000,0.19-0.02,0.001,0.8+0.02,0.009) dsi2[i] <- users$dsi dti2[i] <- users$dti } # hiostograms for ratio ratio1 <- dsi1/dti1 ratio2 <- dsi2/dti2 h1<-hist(ratio1, breaks = seq(0, round(max(ratio2+0.04),2), 0.001)) h2<-hist(ratio2, breaks = seq(0, round(max(ratio2+0.04),2), 0.001)) # plotting plot(0, 0, xlab = "sum of total sales", ylab = "sum of star item sales", xlim = c(82000,92000), ylim = c(2500,6000), pch=21, col = rgb(0,0,1,1/10), bg = rgb(0,0,1,1/10)) title("sample distribution for sum of 10 000 users") # isolines brks <- seq(0, round(max(ratio2+0.02),2), 0.001) for (ls in 1:length(brks)) { col=rgb(0,0,0,0.25+0.25*(ls%%5==1)) lines(c(0,10000000),c(0,10000000)*brks[ls],lty=2,col=col) } # scatter points points(dti1, dsi1, pch=21, col = rgb(0,0,1,1/10), bg = rgb(0,0,1,1/10)) points(dti2, dsi2, pch=21, col = rgb(1,0,0,1/10), bg = rgb(1,0,0,1/10)) # diagonal axis phi <- atan(h1$breaks) r <- 90000 lines(cos(phi)*r,sin(phi)*r,col=1) # histograms phi <- h1$mids r <- h1$density*10 block(phi,r,col=1) phi <- h2$mids r <- h2$density*10 block(phi,r,col=2) # labels for histogram axis phi <- atan(h1$breaks)[1+10*c(1:7)] r <- 90000 text(cos(phi)*r-130,sin(phi)*r,h1$breaks[1+10*c(1:7)],srt=-87.5,cex=0.9) text(cos(atan(0.045))*r-400,sin(atan(0.045))*r,"ratio of sum of star items and sum of total items", srt=-87.5,cex=0.9) # plotting functions for Hinkley densities using variance and means estimated from theoretic samples distribution wf1 <- fwusers(190,1,800,9,10000) wf2 <- fwusers(170,1,820,9,10000) rf1 <- 90000+10*wf1$f phi1 <- atan(wf1$w) lines(cos(phi1)*rf1,sin(phi1)*rf1,col=4) rf2 <- 90000+10*wf2$f phi2 <- atan(wf2$w) lines(cos(phi2)*rf2,sin(phi2)*rf2,col=2)
A/B testing ratio of sums z-test of proportions This applies to a different case when you have binary outcomes. The z-test of proportions compares the proportions of those binary outcomes. (Below some argument is made that yo
18,674
A/B testing ratio of sums
What is described is a classical case of an A/B experiment where we have dependence between users and items (purchases here); we need to account for this because otherwise we will have a biased estimate of the associated variance. To counter that, we either bootstrap by taking account user/item clusters or we go fully parametric using a mixed model. The paper by Bakshy & Eckles (2013) Uncertainty in Online Experiments with Dependent Data: An Evaluation of Bootstrap Methods is an invaluable reference on that matter that focuses on online A/B tests. Looking into the things in more detail, in some ways the B&E paper is a extended use-case of the Owen's (2007) paper The pigeonhole bootstrap. Similarly the mixed effect approach is based on the uber-classic paper by Bayeen et al. (2009) Mixed-effects modeling with crossed random effects for subjects and items. To briefly comment in the methods you mention: as you correctly identify the $z$-test on proportion is oversimplifying; it will assume IID and as the B&E paper presents, that assumption can be seriously misleading. The same limitation extends to bootstrap, if we ignore the structure of the data. Regarding the Delta method: deviations from normality and/or noisy data usually make the Delta method suboptimal in comparison to bootstrap approaches (e.g. Hole 2007 A comparison of approaches to estimating confidence intervals for willingness to pay measures) but I have seen some recent papers (e.g. Deng et al. 2017 Trustworthy analysis of online A/B tests: Pitfalls, challenges and solutions and Deng et al. 2018 Applying the Delta Method in Metric Analytics: A Practical Guide with Novel Ideas) that seem promising; notice that there is the implicit assumption that the average treatment effect will be normal. Finally, the change of metric is also an excellent idea when reasonable. We should not be afraid to push for changes that are more mathematically coherent just because a metric is already in place. In conclusion: If there is an over-arching scheme on all the papers I cited above is that we need to ensure that our unit of analysis and our unit of randomisation are aligned with our research questions.
A/B testing ratio of sums
What is described is a classical case of an A/B experiment where we have dependence between users and items (purchases here); we need to account for this because otherwise we will have a biased estima
A/B testing ratio of sums What is described is a classical case of an A/B experiment where we have dependence between users and items (purchases here); we need to account for this because otherwise we will have a biased estimate of the associated variance. To counter that, we either bootstrap by taking account user/item clusters or we go fully parametric using a mixed model. The paper by Bakshy & Eckles (2013) Uncertainty in Online Experiments with Dependent Data: An Evaluation of Bootstrap Methods is an invaluable reference on that matter that focuses on online A/B tests. Looking into the things in more detail, in some ways the B&E paper is a extended use-case of the Owen's (2007) paper The pigeonhole bootstrap. Similarly the mixed effect approach is based on the uber-classic paper by Bayeen et al. (2009) Mixed-effects modeling with crossed random effects for subjects and items. To briefly comment in the methods you mention: as you correctly identify the $z$-test on proportion is oversimplifying; it will assume IID and as the B&E paper presents, that assumption can be seriously misleading. The same limitation extends to bootstrap, if we ignore the structure of the data. Regarding the Delta method: deviations from normality and/or noisy data usually make the Delta method suboptimal in comparison to bootstrap approaches (e.g. Hole 2007 A comparison of approaches to estimating confidence intervals for willingness to pay measures) but I have seen some recent papers (e.g. Deng et al. 2017 Trustworthy analysis of online A/B tests: Pitfalls, challenges and solutions and Deng et al. 2018 Applying the Delta Method in Metric Analytics: A Practical Guide with Novel Ideas) that seem promising; notice that there is the implicit assumption that the average treatment effect will be normal. Finally, the change of metric is also an excellent idea when reasonable. We should not be afraid to push for changes that are more mathematically coherent just because a metric is already in place. In conclusion: If there is an over-arching scheme on all the papers I cited above is that we need to ensure that our unit of analysis and our unit of randomisation are aligned with our research questions.
A/B testing ratio of sums What is described is a classical case of an A/B experiment where we have dependence between users and items (purchases here); we need to account for this because otherwise we will have a biased estima
18,675
A/B testing ratio of sums
A very simple approach would be to use a permutation test. This is is distribution-free test so you don't have to worry about distributions. The idea is simple. You randomly shuffle the labels and count how many times the measured difference of your metric of interest is larger than the difference you got from your real data. The ratio you get is your p-value. Why does it work ? Well, if the null hypothesis is True, then randomly shuffling the labels (i.e being in group A or B) would very often yield better values then the one you measured. However, if your recommendation algorithm works, then randomly shuffling would rarely yield better result than the one you got. You may also use bootstrapping to get confidence intervals on your metric of both your A and B group. This, two, is allowed without assumptions on your distribution. That's not equivalent of a statistical test (even if the CI intervals do not cross), but the visual aspect of "bars + error" bars can be interesting for your team. I have answered a very similar question (where you indeed found me). How to test the difference in two proportions when the outcomes aren't binary? . I think the code I suggested there apply here too. p1 <- sum(sales_data[target_control==1,"final_value"])/sum(sales_data[target_control==1,"initial_value"]) p2 <- sum(sales_data[target_control==0,"final_value"])/sum(sales_data[target_control==0,"initial_value"]) yourGap<-abs(p1-p2) L<-sales_data["target_control"]==1 LfilterOnlyBuyers<-sales_data["sale_success"]==1 count=0 for ( i in 1:10000) { Lperm=sample(L) p1_perm <- sum(sales_data[Lperm,"final_value"])/sum(sales_data[Lperm & LfilterOnlyBuyers,"initial_value"]) p2_perm <- sum(sales_data[!Lperm,"final_value"])/sum(sales_data[!Lperm & LfilterOnlyBuyers,"initial_value"]) if (abs(p1_perm-p2_perm)>=yourGap) { count=count+1 } } pvalue=count/10000
A/B testing ratio of sums
A very simple approach would be to use a permutation test. This is is distribution-free test so you don't have to worry about distributions. The idea is simple. You randomly shuffle the labels and cou
A/B testing ratio of sums A very simple approach would be to use a permutation test. This is is distribution-free test so you don't have to worry about distributions. The idea is simple. You randomly shuffle the labels and count how many times the measured difference of your metric of interest is larger than the difference you got from your real data. The ratio you get is your p-value. Why does it work ? Well, if the null hypothesis is True, then randomly shuffling the labels (i.e being in group A or B) would very often yield better values then the one you measured. However, if your recommendation algorithm works, then randomly shuffling would rarely yield better result than the one you got. You may also use bootstrapping to get confidence intervals on your metric of both your A and B group. This, two, is allowed without assumptions on your distribution. That's not equivalent of a statistical test (even if the CI intervals do not cross), but the visual aspect of "bars + error" bars can be interesting for your team. I have answered a very similar question (where you indeed found me). How to test the difference in two proportions when the outcomes aren't binary? . I think the code I suggested there apply here too. p1 <- sum(sales_data[target_control==1,"final_value"])/sum(sales_data[target_control==1,"initial_value"]) p2 <- sum(sales_data[target_control==0,"final_value"])/sum(sales_data[target_control==0,"initial_value"]) yourGap<-abs(p1-p2) L<-sales_data["target_control"]==1 LfilterOnlyBuyers<-sales_data["sale_success"]==1 count=0 for ( i in 1:10000) { Lperm=sample(L) p1_perm <- sum(sales_data[Lperm,"final_value"])/sum(sales_data[Lperm & LfilterOnlyBuyers,"initial_value"]) p2_perm <- sum(sales_data[!Lperm,"final_value"])/sum(sales_data[!Lperm & LfilterOnlyBuyers,"initial_value"]) if (abs(p1_perm-p2_perm)>=yourGap) { count=count+1 } } pvalue=count/10000
A/B testing ratio of sums A very simple approach would be to use a permutation test. This is is distribution-free test so you don't have to worry about distributions. The idea is simple. You randomly shuffle the labels and cou
18,676
A/B testing ratio of sums
Bootstrap confidence intervals would be my choice of technique for this scenario. I would like to outline an approach with some example choice numbers that you can use and the reasoning behind the approach: You have two pots/bags and each bag contains people from the control group and variant group: $U_{ctr}$ and $U_{var}$ with respective sizes $N_{ctr}$ and $N_{var}$. I changed your notation slightly, I hope that's OK. You select a random sample of $k$ people from both groups with replacement. If both of your populations are "sufficiently large" (say at least 2000 users for example) you can choose $k\leq N_{ctr}$ and $k \leq N_{var}$. Rule of thumb: I usually select $k = \frac{min(N_{ctr},N_{var})}{5}$ for more flexible results but in most bagging (bootstrap aggregating) algorithms, the default option is to sample from the whole population. If your populations are smaller then you can still do that but make sure you select a "sufficiently large" $k$ (say at least 400 users), again by sampling with replacement. Let's say note them $SU_{ctr}$ and $SU_{var}$ both of size $k$ You calculate your metric by getting all transactions that each person in each group made by looking at the original $T$ transactions dataset for each user in $SU_{ctr}$ and $SU_{var}$. You will then end up with $Metric_{ctr1}$ and $Metric_{ctr2}$. Store these values. Important notice: you should calculate these values by summing the total star items sales and dividing by the total sales. Don't take the average of each person's individual sales basket. This is very important as this is the metric you are looking at. Go back to point 2 and iterate. The optimal number of bootstrap samples, $B$, that you can choose depends on many factors but again, a good rule of thumb would be around 1000 times. You now have a $B$ amount of $Metric_{ctr}$ and same for $Metric_{var}$. You can now choose to compare their means using many of the usual techniques. I would personally choose to construct confidence intervals and see if they overlap or an independent sample t-test AND complete the analysis with some histograms/density plots & boxplots. Off-topic personal opinion: Always choose to viz things such as distributions whenever possible, we have the power to do that nowadays. The tests above are totally fine but there are cases where they might go wrong. For instance if you choose $B$ to be extremely high, say 1000000, then even the smallest difference between the means is more likely to be flagged as significant. The above is robust because no matter what underlying distribution is, the central limit theorem ensures that if $B$ is sufficiently large, both means of $Metric_{var}$ and $Metric_{ctr}$ across the samples will be normally distributed and the tests will be valid. You will witness that from the visuals as well. Any concerns about underlying distributions of different user spends etc will be dealt by the CLT. There are plenty of references and good reads by the users before me. Furthermore, there is a lot of research conducted on the optimal example numbers I mentioned above you can look into it to. I just wanted to give you a more empirical and easy to understand outline of approach that is robust. You can start with that and see whether things change by changing the above example numbers.
A/B testing ratio of sums
Bootstrap confidence intervals would be my choice of technique for this scenario. I would like to outline an approach with some example choice numbers that you can use and the reasoning behind the app
A/B testing ratio of sums Bootstrap confidence intervals would be my choice of technique for this scenario. I would like to outline an approach with some example choice numbers that you can use and the reasoning behind the approach: You have two pots/bags and each bag contains people from the control group and variant group: $U_{ctr}$ and $U_{var}$ with respective sizes $N_{ctr}$ and $N_{var}$. I changed your notation slightly, I hope that's OK. You select a random sample of $k$ people from both groups with replacement. If both of your populations are "sufficiently large" (say at least 2000 users for example) you can choose $k\leq N_{ctr}$ and $k \leq N_{var}$. Rule of thumb: I usually select $k = \frac{min(N_{ctr},N_{var})}{5}$ for more flexible results but in most bagging (bootstrap aggregating) algorithms, the default option is to sample from the whole population. If your populations are smaller then you can still do that but make sure you select a "sufficiently large" $k$ (say at least 400 users), again by sampling with replacement. Let's say note them $SU_{ctr}$ and $SU_{var}$ both of size $k$ You calculate your metric by getting all transactions that each person in each group made by looking at the original $T$ transactions dataset for each user in $SU_{ctr}$ and $SU_{var}$. You will then end up with $Metric_{ctr1}$ and $Metric_{ctr2}$. Store these values. Important notice: you should calculate these values by summing the total star items sales and dividing by the total sales. Don't take the average of each person's individual sales basket. This is very important as this is the metric you are looking at. Go back to point 2 and iterate. The optimal number of bootstrap samples, $B$, that you can choose depends on many factors but again, a good rule of thumb would be around 1000 times. You now have a $B$ amount of $Metric_{ctr}$ and same for $Metric_{var}$. You can now choose to compare their means using many of the usual techniques. I would personally choose to construct confidence intervals and see if they overlap or an independent sample t-test AND complete the analysis with some histograms/density plots & boxplots. Off-topic personal opinion: Always choose to viz things such as distributions whenever possible, we have the power to do that nowadays. The tests above are totally fine but there are cases where they might go wrong. For instance if you choose $B$ to be extremely high, say 1000000, then even the smallest difference between the means is more likely to be flagged as significant. The above is robust because no matter what underlying distribution is, the central limit theorem ensures that if $B$ is sufficiently large, both means of $Metric_{var}$ and $Metric_{ctr}$ across the samples will be normally distributed and the tests will be valid. You will witness that from the visuals as well. Any concerns about underlying distributions of different user spends etc will be dealt by the CLT. There are plenty of references and good reads by the users before me. Furthermore, there is a lot of research conducted on the optimal example numbers I mentioned above you can look into it to. I just wanted to give you a more empirical and easy to understand outline of approach that is robust. You can start with that and see whether things change by changing the above example numbers.
A/B testing ratio of sums Bootstrap confidence intervals would be my choice of technique for this scenario. I would like to outline an approach with some example choice numbers that you can use and the reasoning behind the app
18,677
A/B testing ratio of sums
regression with cluster robust standard errors will be a solution. assume raw data df like this: randomization_id, analysis_id, treat, y 1, 1, 1, 0 1, 2, 1, 1 1, 3, 1, 0 2, 1, 0, 1 2, 2, 0, 0 library(sandwich) library(lmtest) mod <- lm(y ~ treat, df) coeftest(mod, vcov = vcovCL, cluster = ~randomization_id) this will give exactly the same value as Delta method. The advantage of this approach is that it can easily handle more complex situations, for example, control for the imbalance of covariates to improve statistical power. reference: Deng, A., Lu, J., & Qin, W. (2021). The equivalence of the Delta method and the cluster-robust variance estimator for the analysis of clustered randomized experiments. arXiv preprint arXiv:2105.14705.
A/B testing ratio of sums
regression with cluster robust standard errors will be a solution. assume raw data df like this: randomization_id, analysis_id, treat, y 1, 1, 1, 0 1,
A/B testing ratio of sums regression with cluster robust standard errors will be a solution. assume raw data df like this: randomization_id, analysis_id, treat, y 1, 1, 1, 0 1, 2, 1, 1 1, 3, 1, 0 2, 1, 0, 1 2, 2, 0, 0 library(sandwich) library(lmtest) mod <- lm(y ~ treat, df) coeftest(mod, vcov = vcovCL, cluster = ~randomization_id) this will give exactly the same value as Delta method. The advantage of this approach is that it can easily handle more complex situations, for example, control for the imbalance of covariates to improve statistical power. reference: Deng, A., Lu, J., & Qin, W. (2021). The equivalence of the Delta method and the cluster-robust variance estimator for the analysis of clustered randomized experiments. arXiv preprint arXiv:2105.14705.
A/B testing ratio of sums regression with cluster robust standard errors will be a solution. assume raw data df like this: randomization_id, analysis_id, treat, y 1, 1, 1, 0 1,
18,678
Checking if a coin is fair based on how often a subsequence occurs
Solving the problem by simulation My first attempt would be to simulate this on a computer, which can flip many fair coins very fast. Below is an example with one milion trials. The event 'that the number of times $X$ the pattern '1-0-0' occurs in $n=100$ coin flips is 20 or more' occurs roughly once every three thousand trials, so what you observed is not very likely (for a fair coin). Note that the histrogram is for the simulation and the line is the exact computation explained further below. set.seed(1) # number of trials n <- 10^6 # flip coins q <- matrix(rbinom(100*n, 1, 0.5),n) # function to compute number of 100 patterns npattern <- function(x) { sum((1-x[-c(99,100)])*(1-x[-c(1,100)])*x[-c(1,2)]) } # apply function on data counts <- sapply(1:n, function(x) npattern(q[x,])) hist(counts, freq = 0) # estimated probability sum(counts>=20)/10^6 10^6/sum(counts>=20) Solving the problem with an exact computation For an analytical approach you can use the fact that 'the probability to observe 20 or more sequences '1-0-0' in hundred coin flips is equal to the 1 minus the probability that it takes more that hundred flips to make 20 of those sequences'. (for this correspondence between counts and waiting time see also: https://stats.stackexchange.com/a/450135) This is solved in the following steps: Waiting time for probability of flipping '1-0-0' The distribution, $f_{N,x=1}(n)$, of the number of times you need to flip untill you get exactly one sequence '1-0-0' can be computed as following: Let's analyse the ways to get to '1-0-0' as a Markov chain. We follow the states described by the suffix of the string of flips: '1', '1-0', or '1-0-0'. For example if you have the following eight flips 10101100 then you passed, in order, the following eight states: '1', '1-0', '1', '1-0', '1', '1', '1-0', '1-0-0' and it took eight flips to reach '1-0-0'. Note that you do not have equal probability to reach the state '1-0-0' in every flip. Thus you can not model this as a binomial distribution. Instead you should follow a tree of probabilities. The state '1' can go into '1' and '1-0', the state '1-0' can go into '1' and '1-0-0', and the state '1-0-0' is an absorbing state. You can write it down as: number of flips 1 2 3 4 5 6 7 8 9 .... n '1' 1 1 2 3 5 8 13 21 34 .... F_n '1-0' 0 1 1 2 3 5 8 13 21 F_{n-1} '1-0-0' 0 0 1 2 4 7 12 20 33 sum_{x=1}^{n-2} F_{x} and the probability to reach the pattern '1-0-0', after having rolled a first '1' (you start with the state '0', not having flipped a heads yet), within $n$ flips is a half times the probability to be in state '1-0' within $n-1$ flips: $$f_{N_c,x=1}(n) = \frac{F_{n-2}}{2^{n-1}}$$ where $F_i$ is the $i$-th Fibonnaci number. The non-conditional probability is a sum $$f_{N,x=1}(n) = \sum_{k=1}^{n-2} 0.5^{k} f_{N_c,x=1}(1+(n-k)) = 0.5^{n} \sum_{k=1}^{n-2} F_{k}$$ Waiting time for probability of flipping $k$ times '1-0-0' This you can compute by a convolution. $$f_{N,x=k}(n) = \sum_{l=1}^{n} f_{N,x=1}(l)f_{N,x=1}(n-l)$$ you will get as probability to observe 20 or more '1-0-0' patterns (based on the hypothesis that the coin is fair) > # exact computation > 1-Fx[20] [1] 0.0003247105 > # estimated from simulation > sum(counts>=20)/10^6 [1] 0.000337 Here is the R-code to compute it: # fibonacci numbers fn <- c(1,1) for (i in 3:99) { fn <- c(fn,fn[i-1]+fn[i-2]) } # matrix to contain the probabilities ps <- matrix(rep(0,101*33),33) # waiting time probabilities to flip one pattern ps[1,] <- c(0,0,cumsum(fn))/2^(c(1:101)) #convoluting to get the others for (i in 2:33) { for (n in 3:101) { for (l in c(1:(n-2))) { ps[i,n] = ps[i,n] + ps[1,l]*ps[i-1,n-l] } } } # cumulative probabilities to get x patterns in n flips Fx <- 1-rowSums(ps[,1:100]) # probabilities to get x patterns in n flips fx <- Fx[-1]-Fx[-33] #plot in the previous histogram lines(c(1:32)-0.5,fx) Computing for unfair coins We can generalize the above computation of the probability to observe $x$ patterns in $n$ flips, when the probability of '1=head' is $p$ and the flips are independent. We now use a generalization of the Fibonacci numbers: $$F_{n}(x) = \begin{cases} 1 & \quad \text{if $n=1$} \\ x & \quad \text{if $n=2$} \\ x(F_{n-1}+ F_{n-2}) & \quad \text{if $n>2$} \end{cases}$$ the probabilities are now as: $$f_{N_c,x=1,p}(n) = (1-p)^{n-1} F_{n-2}((1-p)^{-1}-1)$$ and $$f_{N,x=1,p}(n) = \sum_{k=1}^{n-2} p(1-p)^{k-1} f_{N_c,x=1,p}(1+n-k) = p(1-p)^{n-1}\sum_{k=1}^{n-2} F_{k}((1-p)^{-1}-1)$$ When we plot this you get: So while the p-value is small for a fair coin 0.0003247, we must note that it is not much better (only a single order) for different unfair coins. The likelihood ratio, or Bayes factor, is around 11 when the null hypothesis ($p=0.5$) is compared with the alternative hypothesis $p=0.33$. This means that the posterior odds ratio is only ten times higher than the prior odds ratio. Thus if it you thought before the experiment that the coin was unlikely unfair, then now you should still think the coin is unlikely unfair. A coin with $p_{heads} = p_{tails}$ but unfairness regarding '1-0-0' occurences One could much easier test the probability for a fair coin by counting the number of heads and tails and use a binomial distribution to model these observations and test whether the observation is particular or not. However it might be that the coin is flipping, on average, an equal number of heads and tails but is not fair regarding certain patterns. For instance the coin might have some correlation for succeeding coin flips (I imagine some mechanism with cavities inside the metal of the coin that are filledwith sand that will flows like an hourglass towards the opposite end of the previous coin flip, which is loading the coin to fall more likely on the same side as the previous side). Let the first coin flip be equal probability heads and tails and succeeding flips are with probability $p$ the same side as the flip before. Then a similar simulation as the beginning of this post will give the following probabilities for the number of times that the pattern '1-0-0' exceeds 20: You can see that it is possible to make it slighlty more likely to observe the '1-0-0' pattern (somewhere around $p=0.45$ a coin that has some negative correlation), but more dramatic is that one can make it much less likely to oberve the '1-0-0' pattern. For low $p$ you get many times the tails after a heads, the first '1-0' part of the '1-0-0' pattern, but you do not get so often two tails in a row the '0-0' part of the pattern. The opposite is true for the high $p$ values. # number of trials set.seed(1) n <- 10^6 p <- seq(0.3,0.6,0.02) np <- length(p) mcounts <- matrix(rep(0,33*np),33) pb <- txtProgressBar(title = "progress bar", min = 0, max = np, style=3) for (i in 1:np) { # flip first coins qfirst <- matrix(rbinom(n, 1, 0.5),n)*2-1 # flip the changes of the sign of the coin qrest <- matrix(rbinom(99*n, 1, p[i]),n)*2-1 # determining the sign of the coins qprod <- t(sapply(1:n, function(x) qfirst[x]*cumprod(qrest[x,]))) # representing in terms of 1s and 0s qcoins <- cbind(qfirst,qprod)*0.5+0.5 counts <- sapply(1:n, function(x) npattern(qcoins[x,])) mcounts[,i] <- sapply(1:33, function(x) sum(counts==x)) setTxtProgressBar(pb, i) } close(pb) plot(p,colSums(mcounts[c(20:33),]), type="l", xlab="p same flip", ylab="counts/million trials", main="observation of 20 or more times '1-0-0' pattern \n for coin with correlated flips") points(p,colSums(mcounts[c(20:33),])) Using the mathematics in statistics The above is all fine but it is not a direct answer to the question "do you think this is a fair coin?" To answer that question one can use the mathematics above but one should really first describe very well the situation, the goals, definition of fairness, etc. Without any knowledge of the background and circumstances any computation will just be math exercise and not an answer to the explicit question. One open question is why and how we are looking for the pattern '1-0-0'. For instance maybe this pattern was not a target, which was decided upon before doing the investigation. Maybe it was just something that 'stood out' in the data and it was something that got attention after the experiment. In that case one needs to consider that one is effectively making multiple comparisons. Another issue is that the probabilty calculated above is a p-value. The meaning of a p-value needs to be considered carefully. It is not the probability that the coin is fair. It is, instead, the probability to observe a particular result if the coin is fair. If one has an environment in which one knows some distribution of the fairness of coins, or one can make a reasonable assumption, then one can take this into account and use a Bayesian expression. What is fair, what is unfair. Eventually, given enough trials one may find some tiny little bit unfairness. But is it relevant and is such a search not biased? When we stick to a frequentist approach, then one should describe something like a boundary above which we consider a coin fair (some relevant effect size). Then one could use something similar to the two one sided t-test in order to decide whether the coin is fair or not (regarding the '1-0-0' pattern).
Checking if a coin is fair based on how often a subsequence occurs
Solving the problem by simulation My first attempt would be to simulate this on a computer, which can flip many fair coins very fast. Below is an example with one milion trials. The event 'that the nu
Checking if a coin is fair based on how often a subsequence occurs Solving the problem by simulation My first attempt would be to simulate this on a computer, which can flip many fair coins very fast. Below is an example with one milion trials. The event 'that the number of times $X$ the pattern '1-0-0' occurs in $n=100$ coin flips is 20 or more' occurs roughly once every three thousand trials, so what you observed is not very likely (for a fair coin). Note that the histrogram is for the simulation and the line is the exact computation explained further below. set.seed(1) # number of trials n <- 10^6 # flip coins q <- matrix(rbinom(100*n, 1, 0.5),n) # function to compute number of 100 patterns npattern <- function(x) { sum((1-x[-c(99,100)])*(1-x[-c(1,100)])*x[-c(1,2)]) } # apply function on data counts <- sapply(1:n, function(x) npattern(q[x,])) hist(counts, freq = 0) # estimated probability sum(counts>=20)/10^6 10^6/sum(counts>=20) Solving the problem with an exact computation For an analytical approach you can use the fact that 'the probability to observe 20 or more sequences '1-0-0' in hundred coin flips is equal to the 1 minus the probability that it takes more that hundred flips to make 20 of those sequences'. (for this correspondence between counts and waiting time see also: https://stats.stackexchange.com/a/450135) This is solved in the following steps: Waiting time for probability of flipping '1-0-0' The distribution, $f_{N,x=1}(n)$, of the number of times you need to flip untill you get exactly one sequence '1-0-0' can be computed as following: Let's analyse the ways to get to '1-0-0' as a Markov chain. We follow the states described by the suffix of the string of flips: '1', '1-0', or '1-0-0'. For example if you have the following eight flips 10101100 then you passed, in order, the following eight states: '1', '1-0', '1', '1-0', '1', '1', '1-0', '1-0-0' and it took eight flips to reach '1-0-0'. Note that you do not have equal probability to reach the state '1-0-0' in every flip. Thus you can not model this as a binomial distribution. Instead you should follow a tree of probabilities. The state '1' can go into '1' and '1-0', the state '1-0' can go into '1' and '1-0-0', and the state '1-0-0' is an absorbing state. You can write it down as: number of flips 1 2 3 4 5 6 7 8 9 .... n '1' 1 1 2 3 5 8 13 21 34 .... F_n '1-0' 0 1 1 2 3 5 8 13 21 F_{n-1} '1-0-0' 0 0 1 2 4 7 12 20 33 sum_{x=1}^{n-2} F_{x} and the probability to reach the pattern '1-0-0', after having rolled a first '1' (you start with the state '0', not having flipped a heads yet), within $n$ flips is a half times the probability to be in state '1-0' within $n-1$ flips: $$f_{N_c,x=1}(n) = \frac{F_{n-2}}{2^{n-1}}$$ where $F_i$ is the $i$-th Fibonnaci number. The non-conditional probability is a sum $$f_{N,x=1}(n) = \sum_{k=1}^{n-2} 0.5^{k} f_{N_c,x=1}(1+(n-k)) = 0.5^{n} \sum_{k=1}^{n-2} F_{k}$$ Waiting time for probability of flipping $k$ times '1-0-0' This you can compute by a convolution. $$f_{N,x=k}(n) = \sum_{l=1}^{n} f_{N,x=1}(l)f_{N,x=1}(n-l)$$ you will get as probability to observe 20 or more '1-0-0' patterns (based on the hypothesis that the coin is fair) > # exact computation > 1-Fx[20] [1] 0.0003247105 > # estimated from simulation > sum(counts>=20)/10^6 [1] 0.000337 Here is the R-code to compute it: # fibonacci numbers fn <- c(1,1) for (i in 3:99) { fn <- c(fn,fn[i-1]+fn[i-2]) } # matrix to contain the probabilities ps <- matrix(rep(0,101*33),33) # waiting time probabilities to flip one pattern ps[1,] <- c(0,0,cumsum(fn))/2^(c(1:101)) #convoluting to get the others for (i in 2:33) { for (n in 3:101) { for (l in c(1:(n-2))) { ps[i,n] = ps[i,n] + ps[1,l]*ps[i-1,n-l] } } } # cumulative probabilities to get x patterns in n flips Fx <- 1-rowSums(ps[,1:100]) # probabilities to get x patterns in n flips fx <- Fx[-1]-Fx[-33] #plot in the previous histogram lines(c(1:32)-0.5,fx) Computing for unfair coins We can generalize the above computation of the probability to observe $x$ patterns in $n$ flips, when the probability of '1=head' is $p$ and the flips are independent. We now use a generalization of the Fibonacci numbers: $$F_{n}(x) = \begin{cases} 1 & \quad \text{if $n=1$} \\ x & \quad \text{if $n=2$} \\ x(F_{n-1}+ F_{n-2}) & \quad \text{if $n>2$} \end{cases}$$ the probabilities are now as: $$f_{N_c,x=1,p}(n) = (1-p)^{n-1} F_{n-2}((1-p)^{-1}-1)$$ and $$f_{N,x=1,p}(n) = \sum_{k=1}^{n-2} p(1-p)^{k-1} f_{N_c,x=1,p}(1+n-k) = p(1-p)^{n-1}\sum_{k=1}^{n-2} F_{k}((1-p)^{-1}-1)$$ When we plot this you get: So while the p-value is small for a fair coin 0.0003247, we must note that it is not much better (only a single order) for different unfair coins. The likelihood ratio, or Bayes factor, is around 11 when the null hypothesis ($p=0.5$) is compared with the alternative hypothesis $p=0.33$. This means that the posterior odds ratio is only ten times higher than the prior odds ratio. Thus if it you thought before the experiment that the coin was unlikely unfair, then now you should still think the coin is unlikely unfair. A coin with $p_{heads} = p_{tails}$ but unfairness regarding '1-0-0' occurences One could much easier test the probability for a fair coin by counting the number of heads and tails and use a binomial distribution to model these observations and test whether the observation is particular or not. However it might be that the coin is flipping, on average, an equal number of heads and tails but is not fair regarding certain patterns. For instance the coin might have some correlation for succeeding coin flips (I imagine some mechanism with cavities inside the metal of the coin that are filledwith sand that will flows like an hourglass towards the opposite end of the previous coin flip, which is loading the coin to fall more likely on the same side as the previous side). Let the first coin flip be equal probability heads and tails and succeeding flips are with probability $p$ the same side as the flip before. Then a similar simulation as the beginning of this post will give the following probabilities for the number of times that the pattern '1-0-0' exceeds 20: You can see that it is possible to make it slighlty more likely to observe the '1-0-0' pattern (somewhere around $p=0.45$ a coin that has some negative correlation), but more dramatic is that one can make it much less likely to oberve the '1-0-0' pattern. For low $p$ you get many times the tails after a heads, the first '1-0' part of the '1-0-0' pattern, but you do not get so often two tails in a row the '0-0' part of the pattern. The opposite is true for the high $p$ values. # number of trials set.seed(1) n <- 10^6 p <- seq(0.3,0.6,0.02) np <- length(p) mcounts <- matrix(rep(0,33*np),33) pb <- txtProgressBar(title = "progress bar", min = 0, max = np, style=3) for (i in 1:np) { # flip first coins qfirst <- matrix(rbinom(n, 1, 0.5),n)*2-1 # flip the changes of the sign of the coin qrest <- matrix(rbinom(99*n, 1, p[i]),n)*2-1 # determining the sign of the coins qprod <- t(sapply(1:n, function(x) qfirst[x]*cumprod(qrest[x,]))) # representing in terms of 1s and 0s qcoins <- cbind(qfirst,qprod)*0.5+0.5 counts <- sapply(1:n, function(x) npattern(qcoins[x,])) mcounts[,i] <- sapply(1:33, function(x) sum(counts==x)) setTxtProgressBar(pb, i) } close(pb) plot(p,colSums(mcounts[c(20:33),]), type="l", xlab="p same flip", ylab="counts/million trials", main="observation of 20 or more times '1-0-0' pattern \n for coin with correlated flips") points(p,colSums(mcounts[c(20:33),])) Using the mathematics in statistics The above is all fine but it is not a direct answer to the question "do you think this is a fair coin?" To answer that question one can use the mathematics above but one should really first describe very well the situation, the goals, definition of fairness, etc. Without any knowledge of the background and circumstances any computation will just be math exercise and not an answer to the explicit question. One open question is why and how we are looking for the pattern '1-0-0'. For instance maybe this pattern was not a target, which was decided upon before doing the investigation. Maybe it was just something that 'stood out' in the data and it was something that got attention after the experiment. In that case one needs to consider that one is effectively making multiple comparisons. Another issue is that the probabilty calculated above is a p-value. The meaning of a p-value needs to be considered carefully. It is not the probability that the coin is fair. It is, instead, the probability to observe a particular result if the coin is fair. If one has an environment in which one knows some distribution of the fairness of coins, or one can make a reasonable assumption, then one can take this into account and use a Bayesian expression. What is fair, what is unfair. Eventually, given enough trials one may find some tiny little bit unfairness. But is it relevant and is such a search not biased? When we stick to a frequentist approach, then one should describe something like a boundary above which we consider a coin fair (some relevant effect size). Then one could use something similar to the two one sided t-test in order to decide whether the coin is fair or not (regarding the '1-0-0' pattern).
Checking if a coin is fair based on how often a subsequence occurs Solving the problem by simulation My first attempt would be to simulate this on a computer, which can flip many fair coins very fast. Below is an example with one milion trials. The event 'that the nu
18,679
Why don't we use importance sampling for one step Q-learning?
Here is the one-step Q-learning update rule as you gave it: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma \max_a Q(s_{t+1}, a) - Q(s_t, a_t) \right]\end{equation} That update rule actually matches exactly what the "target policy" (greedy policy in this case) is doing; we update the $Q$ value for the state-action pair for which we've just obtained a new observation ($s_t, a_t$, with the new observation being $R_{t+1}$) under the assumption that we follow up with the greedy / target policy immediately afterwards (resulting in $\max_a Q(s_{t+1}, a)$). In this equation, the only action that we may not have taken according to the target policy is the action $a_t$, but that's fine because precisely that same action is the one for which we're updating the $Q$-value. Now suppose that we try writing a multi-step (or two-step) update rule naively, without importance sampling. That would look as follows: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma R_{t+2} + \gamma^2 \max_a Q(s_{t+2}, a) - Q(s_t, a_t) \right]\end{equation} This update rule assumes that our behaviour policy (typically something like $\epsilon$-greedy) was used to select another action $a_{t+1}$, resulting in an additional reward observation $R_{t+2}$ and state $s_{t+2}$. In this update rule, we suddenly have a problem for off-policy learning, because our update rule uses a reward $R_{t+2}$ that is the result of an action $a_{t+1}$ which our target policy may not have selected, and it's a different action ($a_t$) for which we're actually updating the $Q$-value. Using information from "incorrect" actions is fine if it's only used to update $Q$-values for those same "incorrect" actions, but it's not fine if we're using it to update $Q$-values for a different ("correct") action (an action that would also have been selected by the greedy / target policy).
Why don't we use importance sampling for one step Q-learning?
Here is the one-step Q-learning update rule as you gave it: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma \max_a Q(s_{t+1}, a) - Q(s_t, a_t) \right]\end{equation} That upd
Why don't we use importance sampling for one step Q-learning? Here is the one-step Q-learning update rule as you gave it: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma \max_a Q(s_{t+1}, a) - Q(s_t, a_t) \right]\end{equation} That update rule actually matches exactly what the "target policy" (greedy policy in this case) is doing; we update the $Q$ value for the state-action pair for which we've just obtained a new observation ($s_t, a_t$, with the new observation being $R_{t+1}$) under the assumption that we follow up with the greedy / target policy immediately afterwards (resulting in $\max_a Q(s_{t+1}, a)$). In this equation, the only action that we may not have taken according to the target policy is the action $a_t$, but that's fine because precisely that same action is the one for which we're updating the $Q$-value. Now suppose that we try writing a multi-step (or two-step) update rule naively, without importance sampling. That would look as follows: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma R_{t+2} + \gamma^2 \max_a Q(s_{t+2}, a) - Q(s_t, a_t) \right]\end{equation} This update rule assumes that our behaviour policy (typically something like $\epsilon$-greedy) was used to select another action $a_{t+1}$, resulting in an additional reward observation $R_{t+2}$ and state $s_{t+2}$. In this update rule, we suddenly have a problem for off-policy learning, because our update rule uses a reward $R_{t+2}$ that is the result of an action $a_{t+1}$ which our target policy may not have selected, and it's a different action ($a_t$) for which we're actually updating the $Q$-value. Using information from "incorrect" actions is fine if it's only used to update $Q$-values for those same "incorrect" actions, but it's not fine if we're using it to update $Q$-values for a different ("correct") action (an action that would also have been selected by the greedy / target policy).
Why don't we use importance sampling for one step Q-learning? Here is the one-step Q-learning update rule as you gave it: \begin{equation}Q(s_t, a_t) = Q(s_t, a_t) + \alpha \left[ R_{t+1} + \gamma \max_a Q(s_{t+1}, a) - Q(s_t, a_t) \right]\end{equation} That upd
18,680
Why don't we use importance sampling for one step Q-learning?
It is explained in the book on page 149: Note that the importance sampling ratio here starts and ends one step later than for n-step TD (7.9). This is because here we are updating a state–action pair. We do not have to care how likely we were to select the action; now that we have selected it we want to learn fully from what happens, with importance sampling only for subsequent actions.
Why don't we use importance sampling for one step Q-learning?
It is explained in the book on page 149: Note that the importance sampling ratio here starts and ends one step later than for n-step TD (7.9). This is because here we are updating a state–action pa
Why don't we use importance sampling for one step Q-learning? It is explained in the book on page 149: Note that the importance sampling ratio here starts and ends one step later than for n-step TD (7.9). This is because here we are updating a state–action pair. We do not have to care how likely we were to select the action; now that we have selected it we want to learn fully from what happens, with importance sampling only for subsequent actions.
Why don't we use importance sampling for one step Q-learning? It is explained in the book on page 149: Note that the importance sampling ratio here starts and ends one step later than for n-step TD (7.9). This is because here we are updating a state–action pa
18,681
Why don't we use importance sampling for one step Q-learning?
One-step Q-learning does not sample forward trajectories, it just takes the maximum value bootstrapped from the estimated action value. You will notice that in the examples of importance sampling in Monte Carlo control, that the weighting by importance sampling is applied after taking a step. So the weight is always 1.0 for the first step. This is then consistent with having no apparent importance sampling in one-step off-policy bootstrapping methods. In multi-step Q-learning, e.g. Q($\lambda$) you should notice that taking any action other than the greedy action will zero the weights of further samples from that trajectory that are used to adjust earlier state, action values. That is a form of importance sampling, since the probability of not taking the greedy action in the target policy is zero. In theory you could also multiply weights of future greedy actions by the inverse probability of selecting them in the behaviour policy - I have not tried that, but I suspect that it mainly just interacts with $\lambda$ and/or increases variance without much benefit. You would also need to track (and average) all the zero-ed adjustments and add them back in . . .
Why don't we use importance sampling for one step Q-learning?
One-step Q-learning does not sample forward trajectories, it just takes the maximum value bootstrapped from the estimated action value. You will notice that in the examples of importance sampling in M
Why don't we use importance sampling for one step Q-learning? One-step Q-learning does not sample forward trajectories, it just takes the maximum value bootstrapped from the estimated action value. You will notice that in the examples of importance sampling in Monte Carlo control, that the weighting by importance sampling is applied after taking a step. So the weight is always 1.0 for the first step. This is then consistent with having no apparent importance sampling in one-step off-policy bootstrapping methods. In multi-step Q-learning, e.g. Q($\lambda$) you should notice that taking any action other than the greedy action will zero the weights of further samples from that trajectory that are used to adjust earlier state, action values. That is a form of importance sampling, since the probability of not taking the greedy action in the target policy is zero. In theory you could also multiply weights of future greedy actions by the inverse probability of selecting them in the behaviour policy - I have not tried that, but I suspect that it mainly just interacts with $\lambda$ and/or increases variance without much benefit. You would also need to track (and average) all the zero-ed adjustments and add them back in . . .
Why don't we use importance sampling for one step Q-learning? One-step Q-learning does not sample forward trajectories, it just takes the maximum value bootstrapped from the estimated action value. You will notice that in the examples of importance sampling in M
18,682
Why don't we use importance sampling for one step Q-learning?
Since a(t) is already determined in 1 step, the importance sampling ratio is 1.
Why don't we use importance sampling for one step Q-learning?
Since a(t) is already determined in 1 step, the importance sampling ratio is 1.
Why don't we use importance sampling for one step Q-learning? Since a(t) is already determined in 1 step, the importance sampling ratio is 1.
Why don't we use importance sampling for one step Q-learning? Since a(t) is already determined in 1 step, the importance sampling ratio is 1.
18,683
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer?
The original GRU paper "Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation" by Kyunghyum Cho et al. does not include bias parameters in their equations. Instead, the authors write To make the equations uncluttered, we omit biases. which does not help a reader understand how the authors envisioned using bias neurons; nor does it allow readers to easily count the number of bias neurons. So we have to look elsewhere. According to Rahul Dey and Fathi M. Salem, "Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks": ... the total number of parameters in the GRU RNN equals $\color{blue}{3 (n^2 + nm + n)}$. where $m$ is the input dimension and $n$ is the output dimension. This is due to the fact that there are three sets of operations requiring weight matrices of these sizes. Dey and Salem outline the GRU in this manner: The GRU RNN reduce the gating signals to two from the LSTM RNN model. The two gates are called an update gate $z_t$ and a reset gate $r_t$. The GRU RNN model is presented in the form: $$\begin{align} h_t &= (1 - z_t)\odot h_{t-1} + z_t \odot \tilde{h}_t \\ \tilde{h}_t &= g(W_h x_t + U_h(r_t \odot h_{t-1}) + b_h) \end{align}$$ with the two gates presented as: $$\begin{align} z_t &= \sigma(W_z x_t + U_z h_{t-1} + b_z) \\ r_t &= \sigma(W_r x_t + U_r h_{t-1} + b_r) \end{align}$$ and in the beginning of the paper, they lay out the notation used as $W$ is an $n \times m$ matrix, $U$ is an $n \times n$ matrix and $b$ is an $n \times 1$ matrix (or vector) for a hidden state of size $n$ and an input of size $m$. These parameters counts might differ from what you find in software. It seems that some software (e.g. PyTorch, Keras) has made the decision to over-parameterize the model, by including additional bias units. In these software implementations, the total parameter count is given as $$ \color{blue}{3 (n^2 + nm + }\color{red}{2}\color{blue}{n)}. $$ This appears to change three of the GRU equations: $$\begin{align} \tilde{h}_t &= g(W_h x_t + b_{hW} + U_h(r_t \odot h_{t-1}) + b_{hU}) \\ z_t &= \sigma(W_z x_t + b_{zW} + U_z h_{t-1} + b_{zU}) \\ r_t &= \sigma(W_r x_t + b_{rW} + U_r h_{t-1} + b_{rU}) \end{align}$$ which we can see is algebraically the same, using the substitution $b_{iW} + b_{iU} = b_{i}$. I'm not sure why software would do this. Perhaps the intention is to create the GRU using compositions of existing linear layer classes, and biases are included in both linear layers. Perhaps this parameterization works better with CUDA devices for some reason. Here's a toy script to verify this behavior, using torch==1.12.1. import torch.nn as nn def count_parameters(model): return sum(p.numel() for p in model.parameters() if p.requires_grad) if __name__ == "__main__": n = 7 m = 5 gru = nn.GRU(input_size=m, hidden_size=n, num_layers=1) print(count_parameters(gru)==3 * (n ** 2 + n * m + 2 * n)) # True
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer?
The original GRU paper "Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation" by Kyunghyum Cho et al. does not include bias parameters in their equations. Inst
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer? The original GRU paper "Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation" by Kyunghyum Cho et al. does not include bias parameters in their equations. Instead, the authors write To make the equations uncluttered, we omit biases. which does not help a reader understand how the authors envisioned using bias neurons; nor does it allow readers to easily count the number of bias neurons. So we have to look elsewhere. According to Rahul Dey and Fathi M. Salem, "Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks": ... the total number of parameters in the GRU RNN equals $\color{blue}{3 (n^2 + nm + n)}$. where $m$ is the input dimension and $n$ is the output dimension. This is due to the fact that there are three sets of operations requiring weight matrices of these sizes. Dey and Salem outline the GRU in this manner: The GRU RNN reduce the gating signals to two from the LSTM RNN model. The two gates are called an update gate $z_t$ and a reset gate $r_t$. The GRU RNN model is presented in the form: $$\begin{align} h_t &= (1 - z_t)\odot h_{t-1} + z_t \odot \tilde{h}_t \\ \tilde{h}_t &= g(W_h x_t + U_h(r_t \odot h_{t-1}) + b_h) \end{align}$$ with the two gates presented as: $$\begin{align} z_t &= \sigma(W_z x_t + U_z h_{t-1} + b_z) \\ r_t &= \sigma(W_r x_t + U_r h_{t-1} + b_r) \end{align}$$ and in the beginning of the paper, they lay out the notation used as $W$ is an $n \times m$ matrix, $U$ is an $n \times n$ matrix and $b$ is an $n \times 1$ matrix (or vector) for a hidden state of size $n$ and an input of size $m$. These parameters counts might differ from what you find in software. It seems that some software (e.g. PyTorch, Keras) has made the decision to over-parameterize the model, by including additional bias units. In these software implementations, the total parameter count is given as $$ \color{blue}{3 (n^2 + nm + }\color{red}{2}\color{blue}{n)}. $$ This appears to change three of the GRU equations: $$\begin{align} \tilde{h}_t &= g(W_h x_t + b_{hW} + U_h(r_t \odot h_{t-1}) + b_{hU}) \\ z_t &= \sigma(W_z x_t + b_{zW} + U_z h_{t-1} + b_{zU}) \\ r_t &= \sigma(W_r x_t + b_{rW} + U_r h_{t-1} + b_{rU}) \end{align}$$ which we can see is algebraically the same, using the substitution $b_{iW} + b_{iU} = b_{i}$. I'm not sure why software would do this. Perhaps the intention is to create the GRU using compositions of existing linear layer classes, and biases are included in both linear layers. Perhaps this parameterization works better with CUDA devices for some reason. Here's a toy script to verify this behavior, using torch==1.12.1. import torch.nn as nn def count_parameters(model): return sum(p.numel() for p in model.parameters() if p.requires_grad) if __name__ == "__main__": n = 7 m = 5 gru = nn.GRU(input_size=m, hidden_size=n, num_layers=1) print(count_parameters(gru)==3 * (n ** 2 + n * m + 2 * n)) # True
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer? The original GRU paper "Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation" by Kyunghyum Cho et al. does not include bias parameters in their equations. Inst
18,684
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer?
should be 3*(n^2+nm+2n). (1) W for input -> hidden 3nm (2)b for input -> hidden 3*n (3)W for hidden -> hidden 3nn (4) b for hidden -> hidden 3*n (1)+(2)+(3)+(4) = 3*(nm+n+nn+n) = 3(n^2+m*n+2n) check https://pytorch.org/docs/stable/generated/torch.nn.GRU.html for cross validating or the original GRU paper.
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer?
should be 3*(n^2+nm+2n). (1) W for input -> hidden 3nm (2)b for input -> hidden 3*n (3)W for hidden -> hidden 3nn (4) b for hidden -> hidden 3*n (1)+(2)+(3)+(4) = 3*(nm+n+nn+n) = 3(n^2+m*n+2n) check h
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer? should be 3*(n^2+nm+2n). (1) W for input -> hidden 3nm (2)b for input -> hidden 3*n (3)W for hidden -> hidden 3nn (4) b for hidden -> hidden 3*n (1)+(2)+(3)+(4) = 3*(nm+n+nn+n) = 3(n^2+m*n+2n) check https://pytorch.org/docs/stable/generated/torch.nn.GRU.html for cross validating or the original GRU paper.
How many parameters are in a gated recurrent unit (GRU) recurrent neural network (RNN) layer? should be 3*(n^2+nm+2n). (1) W for input -> hidden 3nm (2)b for input -> hidden 3*n (3)W for hidden -> hidden 3nn (4) b for hidden -> hidden 3*n (1)+(2)+(3)+(4) = 3*(nm+n+nn+n) = 3(n^2+m*n+2n) check h
18,685
Variational Autoencoder − Dimension of the latent space
You seem to have misunderstood your architecture and are, quite simply, overfitting your data. It looks like your interpretation of the latent space is that it represents a manifold of realistic-looking images. That is unlikely in the best case, and if your decoder performs any transformation (except perhaps an affine transformation) on the sampling outputs - impossible. Autoencoders (or rather the encoder component of them) in general are compression algorithms. This means that they approximate 'real' data with a smaller set of more abstract features. For example, a string '33333333000000000669111222222' could be losslessly compressed by a very simplistic algorithm to '8:3/9:0/2:6/1:9/3:1/6:2' - occurences:number, maintaining position. If your criterion was length of text, the encoding is six characters shorter - not a huge improvement, but an improvement nonetheless. What happened was we've introduced an abstract, higher-dimensional feature - 'number of repetitions' - that helps us express the original data more tersely. You could compress the output further; for example, noticing that even positions are just separators, you could encode them as a single-bit padding rather than an ASCII code. Autoencoders do exactly that, except they get to pick the features themselves, and variational autoencoders enforce that the final level of coding (at least) is fuzzy in a way that can be manipulated. So what you do in your model is that you're describing your input image using over sixty-five thousand features. And in a variational autoencoder, each feature is actually a sliding scale between two distinct versions of a feature, e.g. male/female for faces, or wide/thin brushstroke for MNIST digits. Can you think of just a hundred ways to describe the differences between two realistic pictures in a meaningful way? Possible, I suppose, but they'll get increasingly forced as you try to go on. With so much room to spare, the optimizer can comfortably encode each distinct training image's features in a non-overlapping slice of the latent space rather than learning the features of the training data taken globally. So, when you feed it a validation picture, its encoding lands somewhere between islands of locally applicable feature encodings and so the result is entirely incoherent.
Variational Autoencoder − Dimension of the latent space
You seem to have misunderstood your architecture and are, quite simply, overfitting your data. It looks like your interpretation of the latent space is that it represents a manifold of realistic-looki
Variational Autoencoder − Dimension of the latent space You seem to have misunderstood your architecture and are, quite simply, overfitting your data. It looks like your interpretation of the latent space is that it represents a manifold of realistic-looking images. That is unlikely in the best case, and if your decoder performs any transformation (except perhaps an affine transformation) on the sampling outputs - impossible. Autoencoders (or rather the encoder component of them) in general are compression algorithms. This means that they approximate 'real' data with a smaller set of more abstract features. For example, a string '33333333000000000669111222222' could be losslessly compressed by a very simplistic algorithm to '8:3/9:0/2:6/1:9/3:1/6:2' - occurences:number, maintaining position. If your criterion was length of text, the encoding is six characters shorter - not a huge improvement, but an improvement nonetheless. What happened was we've introduced an abstract, higher-dimensional feature - 'number of repetitions' - that helps us express the original data more tersely. You could compress the output further; for example, noticing that even positions are just separators, you could encode them as a single-bit padding rather than an ASCII code. Autoencoders do exactly that, except they get to pick the features themselves, and variational autoencoders enforce that the final level of coding (at least) is fuzzy in a way that can be manipulated. So what you do in your model is that you're describing your input image using over sixty-five thousand features. And in a variational autoencoder, each feature is actually a sliding scale between two distinct versions of a feature, e.g. male/female for faces, or wide/thin brushstroke for MNIST digits. Can you think of just a hundred ways to describe the differences between two realistic pictures in a meaningful way? Possible, I suppose, but they'll get increasingly forced as you try to go on. With so much room to spare, the optimizer can comfortably encode each distinct training image's features in a non-overlapping slice of the latent space rather than learning the features of the training data taken globally. So, when you feed it a validation picture, its encoding lands somewhere between islands of locally applicable feature encodings and so the result is entirely incoherent.
Variational Autoencoder − Dimension of the latent space You seem to have misunderstood your architecture and are, quite simply, overfitting your data. It looks like your interpretation of the latent space is that it represents a manifold of realistic-looki
18,686
How to interpret Lasso shrinking all coefficients to 0?
I don't think you have made a mistake in the code. This is a matter of interpreting the output. The Lasso doesn't indicate which individual regressors are "more predictive" than others. It simply has a built-in tendency to estimate coefficients as zero. The larger the penalty coefficient $\log(\lambda)$ is, the greater is that tendency. Your cross-validation plot shows that as more and more coefficients are forced to zero, the model does a better and better job of predicting subsets of values that have been randomly removed from the dataset. When the best cross-validated prediction errors (measured as the "Binomial Deviance" here) are achieved when all coefficients are zero, you should suspect that no linear combination of any subset of the regressors may be useful for predicting the outcomes. You can verify this by generating random responses that are independent of all the regressors and applying your fitting procedure to them. Here's a quick way to emulate your dataset: n <- 570 k <- 338 set.seed(17) X <- data.frame(matrix(floor(runif(n*(k+1), 0, 2)), nrow=n, dimnames=list(1:n, c("y", paste0("x", 1:k))))) The data frame X has one random binary column named "y" and 338 other binary columns (whose names don't matter). I used your approach to regress "y" against those variables, but--just to be careful--I made sure the response vector y and model matrix x match up (which they might not do in case there are any missing values in the data): f <- y ~ . - 1 # cv.glmnet will include its own intercept M <- model.frame(f, X) x <- model.matrix(f, M) y <- model.extract(M, "response") fit <- cv.glmnet(x, y, family="binomial") The result is remarkably like yours: plot(fit) Indeed, with these completely random data the Lasso still returns nine nonzero coefficient estimates (even though we know, by construction, that the correct values are all zero). But we shouldn't expect perfection. Moreover, because the fitting is based on randomly removing subsets of the data for cross-validation, you typically won't get the same output from one run to the next. In this example, a second call to cv.glmnet produces a fit with only one nonzero coefficient. For this reason, if you have the time, it's always a good idea to re-run the fitting procedure several times and keep track of which coefficient estimates are consistently nonzero. For these data--with hundreds of regressors--this will take a couple of minutes to repeat nine more times. sim <- cbind(as.numeric(coef(fit)), replicate(9, as.numeric(coef(cv.glmnet(x, y, family="binomial"))))) plot(1:k, rowMeans(sim[-1,] != 0) + runif(k, -0.025, 0.025), xlab="Coefficient Index", ylab="Frequency not zero (jittered)", main="Results of Repeated Cross-Validated Lasso Fits") Eight of these regressors have nonzero estimates in about half of the fits; the rest of them never have nonzero estimates. This shows to what extent the Lasso will still include nonzero coefficient estimates even when the coefficients themselves are truly zero.
How to interpret Lasso shrinking all coefficients to 0?
I don't think you have made a mistake in the code. This is a matter of interpreting the output. The Lasso doesn't indicate which individual regressors are "more predictive" than others. It simply ha
How to interpret Lasso shrinking all coefficients to 0? I don't think you have made a mistake in the code. This is a matter of interpreting the output. The Lasso doesn't indicate which individual regressors are "more predictive" than others. It simply has a built-in tendency to estimate coefficients as zero. The larger the penalty coefficient $\log(\lambda)$ is, the greater is that tendency. Your cross-validation plot shows that as more and more coefficients are forced to zero, the model does a better and better job of predicting subsets of values that have been randomly removed from the dataset. When the best cross-validated prediction errors (measured as the "Binomial Deviance" here) are achieved when all coefficients are zero, you should suspect that no linear combination of any subset of the regressors may be useful for predicting the outcomes. You can verify this by generating random responses that are independent of all the regressors and applying your fitting procedure to them. Here's a quick way to emulate your dataset: n <- 570 k <- 338 set.seed(17) X <- data.frame(matrix(floor(runif(n*(k+1), 0, 2)), nrow=n, dimnames=list(1:n, c("y", paste0("x", 1:k))))) The data frame X has one random binary column named "y" and 338 other binary columns (whose names don't matter). I used your approach to regress "y" against those variables, but--just to be careful--I made sure the response vector y and model matrix x match up (which they might not do in case there are any missing values in the data): f <- y ~ . - 1 # cv.glmnet will include its own intercept M <- model.frame(f, X) x <- model.matrix(f, M) y <- model.extract(M, "response") fit <- cv.glmnet(x, y, family="binomial") The result is remarkably like yours: plot(fit) Indeed, with these completely random data the Lasso still returns nine nonzero coefficient estimates (even though we know, by construction, that the correct values are all zero). But we shouldn't expect perfection. Moreover, because the fitting is based on randomly removing subsets of the data for cross-validation, you typically won't get the same output from one run to the next. In this example, a second call to cv.glmnet produces a fit with only one nonzero coefficient. For this reason, if you have the time, it's always a good idea to re-run the fitting procedure several times and keep track of which coefficient estimates are consistently nonzero. For these data--with hundreds of regressors--this will take a couple of minutes to repeat nine more times. sim <- cbind(as.numeric(coef(fit)), replicate(9, as.numeric(coef(cv.glmnet(x, y, family="binomial"))))) plot(1:k, rowMeans(sim[-1,] != 0) + runif(k, -0.025, 0.025), xlab="Coefficient Index", ylab="Frequency not zero (jittered)", main="Results of Repeated Cross-Validated Lasso Fits") Eight of these regressors have nonzero estimates in about half of the fits; the rest of them never have nonzero estimates. This shows to what extent the Lasso will still include nonzero coefficient estimates even when the coefficients themselves are truly zero.
How to interpret Lasso shrinking all coefficients to 0? I don't think you have made a mistake in the code. This is a matter of interpreting the output. The Lasso doesn't indicate which individual regressors are "more predictive" than others. It simply ha
18,687
How to interpret Lasso shrinking all coefficients to 0?
If you want to obtain more informations can use the function fit1<-glmnet(x_dat, y, family='binomial', alpha= x) plot(fit1, xvar = "lambda", label = TRUE) The graph should be similar to The labels allow to identify the effect of lambda for the regressors. Can you use differents value of x ( in the model is called alpha factor) to 0 (ridge regression) to 1 (LASSO Regression). The value [0,1] are the elastic net regression
How to interpret Lasso shrinking all coefficients to 0?
If you want to obtain more informations can use the function fit1<-glmnet(x_dat, y, family='binomial', alpha= x) plot(fit1, xvar = "lambda", label = TRUE) The graph should be similar to The labels
How to interpret Lasso shrinking all coefficients to 0? If you want to obtain more informations can use the function fit1<-glmnet(x_dat, y, family='binomial', alpha= x) plot(fit1, xvar = "lambda", label = TRUE) The graph should be similar to The labels allow to identify the effect of lambda for the regressors. Can you use differents value of x ( in the model is called alpha factor) to 0 (ridge regression) to 1 (LASSO Regression). The value [0,1] are the elastic net regression
How to interpret Lasso shrinking all coefficients to 0? If you want to obtain more informations can use the function fit1<-glmnet(x_dat, y, family='binomial', alpha= x) plot(fit1, xvar = "lambda", label = TRUE) The graph should be similar to The labels
18,688
How to interpret Lasso shrinking all coefficients to 0?
It's possible but a little surprising. LASSO can do weird things when you have collinearity, in which case you should probably set alpha<1 so you're fitting elastic net instead. You can choose alpha by cross-validation but make sure you're using the same folds for each value of alpha.
How to interpret Lasso shrinking all coefficients to 0?
It's possible but a little surprising. LASSO can do weird things when you have collinearity, in which case you should probably set alpha<1 so you're fitting elastic net instead. You can choose alpha b
How to interpret Lasso shrinking all coefficients to 0? It's possible but a little surprising. LASSO can do weird things when you have collinearity, in which case you should probably set alpha<1 so you're fitting elastic net instead. You can choose alpha by cross-validation but make sure you're using the same folds for each value of alpha.
How to interpret Lasso shrinking all coefficients to 0? It's possible but a little surprising. LASSO can do weird things when you have collinearity, in which case you should probably set alpha<1 so you're fitting elastic net instead. You can choose alpha b
18,689
How to interpret Lasso shrinking all coefficients to 0?
The answer that there are no linear combinations of variables that are useful in predicting outcomes is true in some but not all cases. I had a plot like the one above which was caused by multicollinearity in my data. Reducing the correlations allowed Lasso to work but it also removed useful information about the outcomes. Better sets of variables were obtained by using random forest importance to screen variables and then using Lasso.
How to interpret Lasso shrinking all coefficients to 0?
The answer that there are no linear combinations of variables that are useful in predicting outcomes is true in some but not all cases. I had a plot like the one above which was caused by multicolli
How to interpret Lasso shrinking all coefficients to 0? The answer that there are no linear combinations of variables that are useful in predicting outcomes is true in some but not all cases. I had a plot like the one above which was caused by multicollinearity in my data. Reducing the correlations allowed Lasso to work but it also removed useful information about the outcomes. Better sets of variables were obtained by using random forest importance to screen variables and then using Lasso.
How to interpret Lasso shrinking all coefficients to 0? The answer that there are no linear combinations of variables that are useful in predicting outcomes is true in some but not all cases. I had a plot like the one above which was caused by multicolli
18,690
Why is the naive bayes classifier optimal for 0-1 loss?
Actually this is pretty simple: Bayes classifier chooses the class that has greatest a posteriori probability of occurrence (so called maximum a posteriori estimation). The 0-1 loss function penalizes misclassification, i.e. it assigns the smallest loss to the solution that has greatest number of correct classifications. So in both cases we are talking about estimating mode. Recall that mode is the most common value in the dataset, or the most probable value, so both maximizing the posterior probability and minimizing the 0-1 loss leads to estimating the mode. If you need a formal proof, the one is given in the Introduction to Bayesian Decision Theory paper by Angela J. Yu: The 0-1 binary loss function has the following form: $$ l_\boldsymbol{x}(\hat s, s^*) = 1 - \delta_{\hat ss^*} = \begin{cases} 1 & \text{if} \quad \hat s \ne s^* \\ 0 & \text{otherwise} \end{cases} $$ where $\delta$ is the Kronecker Delta function. (...) the expected loss is: $$ \begin{align} \mathcal{L}_\boldsymbol{x}(\hat s) &= \sum_{s^*} l_\boldsymbol{x}(\hat s, s^*) \; P(s = s^* \mid \boldsymbol{x}) \\ &= \sum_{s^*} (1 - \delta_{\hat ss^*}) \; P(s = s^* \mid \boldsymbol{x}) \\ &= \sum_{s^*} P(s = s^* \mid \boldsymbol{x}) ds^* - \sum_{s^*} \delta_{\hat ss^*} P(s = s^* \mid \boldsymbol{x}) \\ &= 1 - P(s = s^* \mid \boldsymbol{x}) \end{align} $$ This is true for maximum a posteriori estimation in general. So if you know the posterior distribution, then assuming 0-1 loss, the most optimal classification rule is to take the mode of the posterior distribution, we call this a optimal Bayes classifier. In real-life we usually do not know the posterior distribution, but rather we estimate it. Naive Bayes classifier approximates the optimal classifier by looking at the empirical distribution and by assuming independence of predictors. So naive Bayes classifier is not itself optimal, but it approximates the optimal solution. In your question you seem to confuse those two things.
Why is the naive bayes classifier optimal for 0-1 loss?
Actually this is pretty simple: Bayes classifier chooses the class that has greatest a posteriori probability of occurrence (so called maximum a posteriori estimation). The 0-1 loss function penalizes
Why is the naive bayes classifier optimal for 0-1 loss? Actually this is pretty simple: Bayes classifier chooses the class that has greatest a posteriori probability of occurrence (so called maximum a posteriori estimation). The 0-1 loss function penalizes misclassification, i.e. it assigns the smallest loss to the solution that has greatest number of correct classifications. So in both cases we are talking about estimating mode. Recall that mode is the most common value in the dataset, or the most probable value, so both maximizing the posterior probability and minimizing the 0-1 loss leads to estimating the mode. If you need a formal proof, the one is given in the Introduction to Bayesian Decision Theory paper by Angela J. Yu: The 0-1 binary loss function has the following form: $$ l_\boldsymbol{x}(\hat s, s^*) = 1 - \delta_{\hat ss^*} = \begin{cases} 1 & \text{if} \quad \hat s \ne s^* \\ 0 & \text{otherwise} \end{cases} $$ where $\delta$ is the Kronecker Delta function. (...) the expected loss is: $$ \begin{align} \mathcal{L}_\boldsymbol{x}(\hat s) &= \sum_{s^*} l_\boldsymbol{x}(\hat s, s^*) \; P(s = s^* \mid \boldsymbol{x}) \\ &= \sum_{s^*} (1 - \delta_{\hat ss^*}) \; P(s = s^* \mid \boldsymbol{x}) \\ &= \sum_{s^*} P(s = s^* \mid \boldsymbol{x}) ds^* - \sum_{s^*} \delta_{\hat ss^*} P(s = s^* \mid \boldsymbol{x}) \\ &= 1 - P(s = s^* \mid \boldsymbol{x}) \end{align} $$ This is true for maximum a posteriori estimation in general. So if you know the posterior distribution, then assuming 0-1 loss, the most optimal classification rule is to take the mode of the posterior distribution, we call this a optimal Bayes classifier. In real-life we usually do not know the posterior distribution, but rather we estimate it. Naive Bayes classifier approximates the optimal classifier by looking at the empirical distribution and by assuming independence of predictors. So naive Bayes classifier is not itself optimal, but it approximates the optimal solution. In your question you seem to confuse those two things.
Why is the naive bayes classifier optimal for 0-1 loss? Actually this is pretty simple: Bayes classifier chooses the class that has greatest a posteriori probability of occurrence (so called maximum a posteriori estimation). The 0-1 loss function penalizes
18,691
What algorithms require one-hot encoding?
Most algorithms (linear regression, logistic regression, neural network, support vector machine, etc.) require some sort of the encoding on categorical variables. This is because most algorithms only take numerical values as inputs. Algorithms that do not require an encoding are algorithms that can directly deal with joint discrete distributions such as Markov chain / Naive Bayes / Bayesian network, tree based, etc. Additional comments: One hot encoding is one of the encoding methods. Here is a good resource for categorical variable encoding (not limited to R). R LIBRARY CONTRAST CODING SYSTEMS FOR CATEGORICAL VARIABLES Even without encoding, distance between data points with discrete variables can be defined, such as hamming distance or Levenshtein Distance
What algorithms require one-hot encoding?
Most algorithms (linear regression, logistic regression, neural network, support vector machine, etc.) require some sort of the encoding on categorical variables. This is because most algorithms only
What algorithms require one-hot encoding? Most algorithms (linear regression, logistic regression, neural network, support vector machine, etc.) require some sort of the encoding on categorical variables. This is because most algorithms only take numerical values as inputs. Algorithms that do not require an encoding are algorithms that can directly deal with joint discrete distributions such as Markov chain / Naive Bayes / Bayesian network, tree based, etc. Additional comments: One hot encoding is one of the encoding methods. Here is a good resource for categorical variable encoding (not limited to R). R LIBRARY CONTRAST CODING SYSTEMS FOR CATEGORICAL VARIABLES Even without encoding, distance between data points with discrete variables can be defined, such as hamming distance or Levenshtein Distance
What algorithms require one-hot encoding? Most algorithms (linear regression, logistic regression, neural network, support vector machine, etc.) require some sort of the encoding on categorical variables. This is because most algorithms only
18,692
What algorithms require one-hot encoding?
Can anyone give a list of what algorithms would require categorical features to be one-hot-encoded and which ones wouldn't? AFAIU, it has to do more with the particular data, less with the particular algorithm. Specifically, it depends on whether there is some meaningful order in the categories or not. Consider two cases. In the first you have the categories bad, meh, good, and in the second you have apple, orange, pear. There is a natural order in the first case, because meh is probably in between bad and good, but probably nothing similar happens in apple, orange, pear. If you avoid one-hot encoding for the first case, you're "losing" the information about the order. If you use one-hot encoding for the second case, you're assigning some order to the categories that is not naturally true. I do it whenever the algorithm uses a distance metric to compute similarity. Why? Suppose one of the features is a categorical bad, meh, good, and you have three instances, 1, 2, and 3, where they are identical, except that 1 is bad, 2 is meh, and 3 is good. You probably want to express to the algorithm that 1 is more similar to 2 than it is to 3.
What algorithms require one-hot encoding?
Can anyone give a list of what algorithms would require categorical features to be one-hot-encoded and which ones wouldn't? AFAIU, it has to do more with the particular data, less with the particular
What algorithms require one-hot encoding? Can anyone give a list of what algorithms would require categorical features to be one-hot-encoded and which ones wouldn't? AFAIU, it has to do more with the particular data, less with the particular algorithm. Specifically, it depends on whether there is some meaningful order in the categories or not. Consider two cases. In the first you have the categories bad, meh, good, and in the second you have apple, orange, pear. There is a natural order in the first case, because meh is probably in between bad and good, but probably nothing similar happens in apple, orange, pear. If you avoid one-hot encoding for the first case, you're "losing" the information about the order. If you use one-hot encoding for the second case, you're assigning some order to the categories that is not naturally true. I do it whenever the algorithm uses a distance metric to compute similarity. Why? Suppose one of the features is a categorical bad, meh, good, and you have three instances, 1, 2, and 3, where they are identical, except that 1 is bad, 2 is meh, and 3 is good. You probably want to express to the algorithm that 1 is more similar to 2 than it is to 3.
What algorithms require one-hot encoding? Can anyone give a list of what algorithms would require categorical features to be one-hot-encoded and which ones wouldn't? AFAIU, it has to do more with the particular data, less with the particular
18,693
What algorithms require one-hot encoding?
No machine learning algorithm requires one hot encoding. It is one method for dealing with categorical variables. Dummy variables is another. Traditionally, dummy variables was the preferred solution. For example, the R function lm() automatically creates dummy variables for categorical data. If you are using python and scikt-learn then I believe many of it's algos require one-hot encoding of categorical variables. I believe that tensorFlow also requires one-hot encoding. These are choices of how the variable is encoded. There is no reason why dummy variables couldn't be used in the code instead. This all has to deal with the actual code implementation of the algorithm. As hxd1011 points out the issue of describing the 'distance' between categorical variables is a delicate issue. In addition to the distances mentioned there is also Jaccard distance. Some ML methods, particularly SVM's are inappropriate for categorical data and adding categorical variables can/will (either, both, you decide) lead to models with very poor predictive power. Most ensemble models handle categorical data 'as is' and require no pre-processing.
What algorithms require one-hot encoding?
No machine learning algorithm requires one hot encoding. It is one method for dealing with categorical variables. Dummy variables is another. Traditionally, dummy variables was the preferred solut
What algorithms require one-hot encoding? No machine learning algorithm requires one hot encoding. It is one method for dealing with categorical variables. Dummy variables is another. Traditionally, dummy variables was the preferred solution. For example, the R function lm() automatically creates dummy variables for categorical data. If you are using python and scikt-learn then I believe many of it's algos require one-hot encoding of categorical variables. I believe that tensorFlow also requires one-hot encoding. These are choices of how the variable is encoded. There is no reason why dummy variables couldn't be used in the code instead. This all has to deal with the actual code implementation of the algorithm. As hxd1011 points out the issue of describing the 'distance' between categorical variables is a delicate issue. In addition to the distances mentioned there is also Jaccard distance. Some ML methods, particularly SVM's are inappropriate for categorical data and adding categorical variables can/will (either, both, you decide) lead to models with very poor predictive power. Most ensemble models handle categorical data 'as is' and require no pre-processing.
What algorithms require one-hot encoding? No machine learning algorithm requires one hot encoding. It is one method for dealing with categorical variables. Dummy variables is another. Traditionally, dummy variables was the preferred solut
18,694
Why is dimensionality reduction always done before clustering? [duplicate]
Clustering generally depends on some sort of distance measure. Points near each other are in the same cluster; points far apart are in different clusters. But in high dimensional spaces, distance measures do not work very well. There is a long and excellent discussion of that Here. You reduce the number of dimensions first so that your distance metric will make sense.
Why is dimensionality reduction always done before clustering? [duplicate]
Clustering generally depends on some sort of distance measure. Points near each other are in the same cluster; points far apart are in different clusters. But in high dimensional spaces, distance mea
Why is dimensionality reduction always done before clustering? [duplicate] Clustering generally depends on some sort of distance measure. Points near each other are in the same cluster; points far apart are in different clusters. But in high dimensional spaces, distance measures do not work very well. There is a long and excellent discussion of that Here. You reduce the number of dimensions first so that your distance metric will make sense.
Why is dimensionality reduction always done before clustering? [duplicate] Clustering generally depends on some sort of distance measure. Points near each other are in the same cluster; points far apart are in different clusters. But in high dimensional spaces, distance mea
18,695
Does cross-validation on simple or multiple linear regression make sense?
I would always perform cross validation. Even if you are fitting a simple linear model with only one explaining variable such as in $$Y=X_1 a_1 + b $$ The reason is, that Cross validation is not a tool to only fight overfitting, but also to evaluate the performance of your algorithm. Overfitting is definitely an aspect of the performance. However the performance not only consists of the question of whether overfitting occurred or not. Another aspect is the variance of the model parameter. Lets say you doing a 2 Fold CV for the model above and one time the fitted parameter is $a_1=1$ and on the other half of the data it is $a_1=-1$. I would not trust the linear model in such a situation. Another aspect would be the MAD between the predictions $\hat Y= X_1 a_1 + b$ and the true values $Y$ on the test set. I would compare the residuals for the different folds to get a feeling how high the deviation of the prediction error is. If one fold produces a perfect prediction and on the other fold the error is really high I would worry about the model...
Does cross-validation on simple or multiple linear regression make sense?
I would always perform cross validation. Even if you are fitting a simple linear model with only one explaining variable such as in $$Y=X_1 a_1 + b $$ The reason is, that Cross validation is not a too
Does cross-validation on simple or multiple linear regression make sense? I would always perform cross validation. Even if you are fitting a simple linear model with only one explaining variable such as in $$Y=X_1 a_1 + b $$ The reason is, that Cross validation is not a tool to only fight overfitting, but also to evaluate the performance of your algorithm. Overfitting is definitely an aspect of the performance. However the performance not only consists of the question of whether overfitting occurred or not. Another aspect is the variance of the model parameter. Lets say you doing a 2 Fold CV for the model above and one time the fitted parameter is $a_1=1$ and on the other half of the data it is $a_1=-1$. I would not trust the linear model in such a situation. Another aspect would be the MAD between the predictions $\hat Y= X_1 a_1 + b$ and the true values $Y$ on the test set. I would compare the residuals for the different folds to get a feeling how high the deviation of the prediction error is. If one fold produces a perfect prediction and on the other fold the error is really high I would worry about the model...
Does cross-validation on simple or multiple linear regression make sense? I would always perform cross validation. Even if you are fitting a simple linear model with only one explaining variable such as in $$Y=X_1 a_1 + b $$ The reason is, that Cross validation is not a too
18,696
Does cross-validation on simple or multiple linear regression make sense?
First, over-fitting may not always be a real concern. No variable selection (or any other way of using the response to decide how to specify the predictors), few estimated parameters, many observations, only weakly correlated predictors, & a low error variance might lead someone to suppose that validating the model-fitting procedure isn't worth the candle. Fair enough; though you might ask why, if they're so sure about that, they didn't specify more parameters to allow for non-linear relationships between predictors & response, or for interactions. Second, it may be that parameter estimation rather than prediction is the aim of the analysis. If you're using regression to estimate the Young's modulus of a material, then the job's done once you have the point estimate & confidence interval. Third, with ordinary least-squares regressions (& no variable selection) you can calculate estimates of predictive performance analytically: the adjusted coefficient of determination & predicted residual sum of squares statistic (see Does adjusted R-square seek to estimate fixed score or random score population r-squared? & Why not using cross validation for estimating the error of a linear model?).
Does cross-validation on simple or multiple linear regression make sense?
First, over-fitting may not always be a real concern. No variable selection (or any other way of using the response to decide how to specify the predictors), few estimated parameters, many observation
Does cross-validation on simple or multiple linear regression make sense? First, over-fitting may not always be a real concern. No variable selection (or any other way of using the response to decide how to specify the predictors), few estimated parameters, many observations, only weakly correlated predictors, & a low error variance might lead someone to suppose that validating the model-fitting procedure isn't worth the candle. Fair enough; though you might ask why, if they're so sure about that, they didn't specify more parameters to allow for non-linear relationships between predictors & response, or for interactions. Second, it may be that parameter estimation rather than prediction is the aim of the analysis. If you're using regression to estimate the Young's modulus of a material, then the job's done once you have the point estimate & confidence interval. Third, with ordinary least-squares regressions (& no variable selection) you can calculate estimates of predictive performance analytically: the adjusted coefficient of determination & predicted residual sum of squares statistic (see Does adjusted R-square seek to estimate fixed score or random score population r-squared? & Why not using cross validation for estimating the error of a linear model?).
Does cross-validation on simple or multiple linear regression make sense? First, over-fitting may not always be a real concern. No variable selection (or any other way of using the response to decide how to specify the predictors), few estimated parameters, many observation
18,697
Does cross-validation on simple or multiple linear regression make sense?
Cross validation and generally validation model techniques are used not only to avoid overfitting (never the case when using linear models) but also when there are different models to compare. A straight last square regression (with no macro-parameters) doesn't get any improvement with cross validation or train-test split that is not obtained by training the model with all the available data! Different is the case if your model is linear but with macro-parameters to choose as Ridge or Lasso regression. In this case using CV validation is a good way to choose the best macro-parameter value , that is the linear model with the best score on the training data see: https://scikit-learn.org/stable/modules/cross_validation.html#cross-validation
Does cross-validation on simple or multiple linear regression make sense?
Cross validation and generally validation model techniques are used not only to avoid overfitting (never the case when using linear models) but also when there are different models to compare. A strai
Does cross-validation on simple or multiple linear regression make sense? Cross validation and generally validation model techniques are used not only to avoid overfitting (never the case when using linear models) but also when there are different models to compare. A straight last square regression (with no macro-parameters) doesn't get any improvement with cross validation or train-test split that is not obtained by training the model with all the available data! Different is the case if your model is linear but with macro-parameters to choose as Ridge or Lasso regression. In this case using CV validation is a good way to choose the best macro-parameter value , that is the linear model with the best score on the training data see: https://scikit-learn.org/stable/modules/cross_validation.html#cross-validation
Does cross-validation on simple or multiple linear regression make sense? Cross validation and generally validation model techniques are used not only to avoid overfitting (never the case when using linear models) but also when there are different models to compare. A strai
18,698
Deep neural networks -- Just for image classification?
The characteristics of images that makes them amenable to classification with a deep neural network is there are a ton of features (possibly millions if not billions of pixels with RGB, intensity, etc.) and if you have accurate labels, it's not noisy data. Cameras these days are very good and they aren't mis-measuring anything. Thanks to the Internet, we now have a lot of accurately labeled images. A deep network can express arbitrarily complicated functions, which is a problem with noisy data because you can very easily overfit the noise, hence why many learning methods tend to penalize complicated models. In the case of image recognition, however, the true function seems to actually be very complicated, we have no idea what the functional form looks like, and we don't even know what the relevant features are in many cases. A many-layer network can automatically discover and extract relevant features, which doesn't make it completely unique, but that is one attractive part of the model. This doesn't mean you can't use deep networks to learn functions having nothing to do with images. You just need to be very careful about the downsides, mostly that it is very prone to overfitting, but also that it's computationally expensive and can take a long time to train (not as much an issue these days with parallelized SGD and GPUs). The other downside is you have very little to no model interpretability, which doesn't really matter for image classification. We're just trying to get computers to recognize the difference between a chimp and an orangutan. Human understanding of the formula doesn't matter. For other domains, especially medical diagnostics, policy research, etc., you want or might even need human understanding.
Deep neural networks -- Just for image classification?
The characteristics of images that makes them amenable to classification with a deep neural network is there are a ton of features (possibly millions if not billions of pixels with RGB, intensity, etc
Deep neural networks -- Just for image classification? The characteristics of images that makes them amenable to classification with a deep neural network is there are a ton of features (possibly millions if not billions of pixels with RGB, intensity, etc.) and if you have accurate labels, it's not noisy data. Cameras these days are very good and they aren't mis-measuring anything. Thanks to the Internet, we now have a lot of accurately labeled images. A deep network can express arbitrarily complicated functions, which is a problem with noisy data because you can very easily overfit the noise, hence why many learning methods tend to penalize complicated models. In the case of image recognition, however, the true function seems to actually be very complicated, we have no idea what the functional form looks like, and we don't even know what the relevant features are in many cases. A many-layer network can automatically discover and extract relevant features, which doesn't make it completely unique, but that is one attractive part of the model. This doesn't mean you can't use deep networks to learn functions having nothing to do with images. You just need to be very careful about the downsides, mostly that it is very prone to overfitting, but also that it's computationally expensive and can take a long time to train (not as much an issue these days with parallelized SGD and GPUs). The other downside is you have very little to no model interpretability, which doesn't really matter for image classification. We're just trying to get computers to recognize the difference between a chimp and an orangutan. Human understanding of the formula doesn't matter. For other domains, especially medical diagnostics, policy research, etc., you want or might even need human understanding.
Deep neural networks -- Just for image classification? The characteristics of images that makes them amenable to classification with a deep neural network is there are a ton of features (possibly millions if not billions of pixels with RGB, intensity, etc
18,699
Deep neural networks -- Just for image classification?
Sure you can use deep neural networks for many problems apart from image or speech recognition. The problem is if you really need it. Deep neural networks are far more powerful than a simple MLP however they also take more resources and are more difficult to develop. Thus they are used in really complex domains. You could use them to solve easier problems but usually simpler models obtain good results too. Using deep neural networks for easy problems will be like killing flies with a bazooka, sure you'll kill them but couldn't you find a simpler way?
Deep neural networks -- Just for image classification?
Sure you can use deep neural networks for many problems apart from image or speech recognition. The problem is if you really need it. Deep neural networks are far more powerful than a simple MLP howe
Deep neural networks -- Just for image classification? Sure you can use deep neural networks for many problems apart from image or speech recognition. The problem is if you really need it. Deep neural networks are far more powerful than a simple MLP however they also take more resources and are more difficult to develop. Thus they are used in really complex domains. You could use them to solve easier problems but usually simpler models obtain good results too. Using deep neural networks for easy problems will be like killing flies with a bazooka, sure you'll kill them but couldn't you find a simpler way?
Deep neural networks -- Just for image classification? Sure you can use deep neural networks for many problems apart from image or speech recognition. The problem is if you really need it. Deep neural networks are far more powerful than a simple MLP howe
18,700
Deep neural networks -- Just for image classification?
I agree with davidivad's answer. But also I think the application of deep neural networks to images is that images (and, more importantly, labeled images) are relatively inexpensive to collect. In other domains, it can be very expensive to collect data on a large scale, especially within the constraints of a typical industrial or government enterprise. Compounding this issue is that in many applications, the phenomenon of interest is relatively rare, so there will be precious few examples to learn from, so even a relatively large-scale data collection effort might yield a small number of members of some class.
Deep neural networks -- Just for image classification?
I agree with davidivad's answer. But also I think the application of deep neural networks to images is that images (and, more importantly, labeled images) are relatively inexpensive to collect. In oth
Deep neural networks -- Just for image classification? I agree with davidivad's answer. But also I think the application of deep neural networks to images is that images (and, more importantly, labeled images) are relatively inexpensive to collect. In other domains, it can be very expensive to collect data on a large scale, especially within the constraints of a typical industrial or government enterprise. Compounding this issue is that in many applications, the phenomenon of interest is relatively rare, so there will be precious few examples to learn from, so even a relatively large-scale data collection effort might yield a small number of members of some class.
Deep neural networks -- Just for image classification? I agree with davidivad's answer. But also I think the application of deep neural networks to images is that images (and, more importantly, labeled images) are relatively inexpensive to collect. In oth