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
43,801
How does the variance measure the information about the data?
Variance measures the amount of information in the data set. How? Information is a slippery concept, so it pays to be a little concrete. So specialize to the case of a regression model. You have some variables $x_1, x_2, \dotsc, x_p$, say, which you wants to use to predict or explain $Y$. Lets say now that all the observations of $x_1$ are equal, so its variance is zero. This variable will not be useful for explaining $Y$. If you want to study, say, the relationship between education level and income, but your sample only includes college graduates without any post-graduate education, how useful will that be? It is in this sense that variance can be a measure of information in the data. But this will only make sense in relationship to some given model. "Information" in the abstract, without any qualification, does not make sense. To see that more clearly, another example: let’s say your observations are repeated measurements of the same specimen, length, weight, whatever. The ideal case is that all are equal — no measurement error. Variance in this case represents measurement error, and higher variance corresponds to less information!
How does the variance measure the information about the data?
Variance measures the amount of information in the data set. How? Information is a slippery concept, so it pays to be a little concrete. So specialize to the case of a regression model. You have some
How does the variance measure the information about the data? Variance measures the amount of information in the data set. How? Information is a slippery concept, so it pays to be a little concrete. So specialize to the case of a regression model. You have some variables $x_1, x_2, \dotsc, x_p$, say, which you wants to use to predict or explain $Y$. Lets say now that all the observations of $x_1$ are equal, so its variance is zero. This variable will not be useful for explaining $Y$. If you want to study, say, the relationship between education level and income, but your sample only includes college graduates without any post-graduate education, how useful will that be? It is in this sense that variance can be a measure of information in the data. But this will only make sense in relationship to some given model. "Information" in the abstract, without any qualification, does not make sense. To see that more clearly, another example: let’s say your observations are repeated measurements of the same specimen, length, weight, whatever. The ideal case is that all are equal — no measurement error. Variance in this case represents measurement error, and higher variance corresponds to less information!
How does the variance measure the information about the data? Variance measures the amount of information in the data set. How? Information is a slippery concept, so it pays to be a little concrete. So specialize to the case of a regression model. You have some
43,802
How does the variance measure the information about the data?
One way to think about the amount of information in a dataset is to see how spread out the data points are. For example, if you had a dataset of five identical body weights x = [120, 120, 120, 120, 120], there is very little information here as there is no spread or variability at all - knowing the weight of one person tells us the weight of the others. Now, the variance tells us how spread out the data are, by taking the average squared deviations from the mean. So the more spread out our data are, the larger the variance. In x above, the variance is 0, which is consistent with the observation that there is very little information in x. Edit This is an oversimplified and misleading explanation - please refer to kjetil b halvorsen's answer above for a more nuanced and correct explanation.
How does the variance measure the information about the data?
One way to think about the amount of information in a dataset is to see how spread out the data points are. For example, if you had a dataset of five identical body weights x = [120, 120, 120, 120, 12
How does the variance measure the information about the data? One way to think about the amount of information in a dataset is to see how spread out the data points are. For example, if you had a dataset of five identical body weights x = [120, 120, 120, 120, 120], there is very little information here as there is no spread or variability at all - knowing the weight of one person tells us the weight of the others. Now, the variance tells us how spread out the data are, by taking the average squared deviations from the mean. So the more spread out our data are, the larger the variance. In x above, the variance is 0, which is consistent with the observation that there is very little information in x. Edit This is an oversimplified and misleading explanation - please refer to kjetil b halvorsen's answer above for a more nuanced and correct explanation.
How does the variance measure the information about the data? One way to think about the amount of information in a dataset is to see how spread out the data points are. For example, if you had a dataset of five identical body weights x = [120, 120, 120, 120, 12
43,803
How does the variance measure the information about the data?
This is not about variance but rather about PCA and principal components. PCA searches for orthogonal principal components (a linear combination of variables) which maximize explained variability (or equivalently minimize the squared distance from the points to the line; think of it as $R^2$ - the higher it is the more variability we explained, which means the points are closer to the fitted line). When we do this we say that the first PC explains most of the data, i.e. it explains most of the variability, i.e. it contains most of the information about the data, because it's what we can explain best, given our data. However, this does not necessarily mean that this information is of any value to us, the model may be learning associations which are perfectly clear to us or which are not of interest. In conclusion, this is not about variance, but rather about "explained variance", which is distributed among the PC's and which is interpreted (by some people) as "how much information this particular PC holds given all the rest".
How does the variance measure the information about the data?
This is not about variance but rather about PCA and principal components. PCA searches for orthogonal principal components (a linear combination of variables) which maximize explained variability (or
How does the variance measure the information about the data? This is not about variance but rather about PCA and principal components. PCA searches for orthogonal principal components (a linear combination of variables) which maximize explained variability (or equivalently minimize the squared distance from the points to the line; think of it as $R^2$ - the higher it is the more variability we explained, which means the points are closer to the fitted line). When we do this we say that the first PC explains most of the data, i.e. it explains most of the variability, i.e. it contains most of the information about the data, because it's what we can explain best, given our data. However, this does not necessarily mean that this information is of any value to us, the model may be learning associations which are perfectly clear to us or which are not of interest. In conclusion, this is not about variance, but rather about "explained variance", which is distributed among the PC's and which is interpreted (by some people) as "how much information this particular PC holds given all the rest".
How does the variance measure the information about the data? This is not about variance but rather about PCA and principal components. PCA searches for orthogonal principal components (a linear combination of variables) which maximize explained variability (or
43,804
How does the variance measure the information about the data?
Say you have a dataset about persons with two features: weight and number of eyes. Which of these two features do you think is more informative for describing persons, i.e. given a data point, which feature makes it easier for you to identify the person it represents? Here, given enough data, weight will have a much greater variance than number of eyes, whose variance will be close to zero. Therefore, we can conclude that weight is more informative than number of eyes.
How does the variance measure the information about the data?
Say you have a dataset about persons with two features: weight and number of eyes. Which of these two features do you think is more informative for describing persons, i.e. given a data point, which f
How does the variance measure the information about the data? Say you have a dataset about persons with two features: weight and number of eyes. Which of these two features do you think is more informative for describing persons, i.e. given a data point, which feature makes it easier for you to identify the person it represents? Here, given enough data, weight will have a much greater variance than number of eyes, whose variance will be close to zero. Therefore, we can conclude that weight is more informative than number of eyes.
How does the variance measure the information about the data? Say you have a dataset about persons with two features: weight and number of eyes. Which of these two features do you think is more informative for describing persons, i.e. given a data point, which f
43,805
How does the variance measure the information about the data?
Others already answered conveying perfectly some concepts but the major misunderstatement remains to be clarified: variance IS NOT information, is not even vaguely linked to information. In some application as PCA it is a parameter that allows you to evaluate how much information you can extract from your data with that specific tool, but this is not a measure of information of the data at all. I will not go into mathematical explanation because it is probably better to give basic ideas first (and there are very good formal explanation out there): information is the reduction of uncertainty, lack of variance in data does not correlate in any way with the information, it just means that the phenomenon is steady and this is a big amount of information because it reduces the a priori uncertainty about that phenomenon. The key concept is that information depends on the relation between the observer and the data, not on the data itself: if you think to source coding (data compression as an example) small variance means that you can use less symbols to encode the data and so it means less information, but if you think to channel coding (a repetition code for example) in a large set of "1" there could be no "useless" symbol because every symbol carries part of the original information, there are codes way better than the repetion code to increase the amount of information carried by each symbol, still it is the proof that having n+1 equal values conveys more information than n equal values and so even with 0 variance the information increases. Example: you receive a boolean information on a noisy channel with 0.5 cross-channel probability, if you receive "1" you have exactly 0 bit of information because there is no way to know if the sended bit was 0 or 1, if the sender repeats his message 3 times and you receive "111" you know that the probability that the message was 1 is 0.875 and with 0 variance you have a lot of information, passing from no information at all (1) to very good confidence (111).
How does the variance measure the information about the data?
Others already answered conveying perfectly some concepts but the major misunderstatement remains to be clarified: variance IS NOT information, is not even vaguely linked to information. In some appli
How does the variance measure the information about the data? Others already answered conveying perfectly some concepts but the major misunderstatement remains to be clarified: variance IS NOT information, is not even vaguely linked to information. In some application as PCA it is a parameter that allows you to evaluate how much information you can extract from your data with that specific tool, but this is not a measure of information of the data at all. I will not go into mathematical explanation because it is probably better to give basic ideas first (and there are very good formal explanation out there): information is the reduction of uncertainty, lack of variance in data does not correlate in any way with the information, it just means that the phenomenon is steady and this is a big amount of information because it reduces the a priori uncertainty about that phenomenon. The key concept is that information depends on the relation between the observer and the data, not on the data itself: if you think to source coding (data compression as an example) small variance means that you can use less symbols to encode the data and so it means less information, but if you think to channel coding (a repetition code for example) in a large set of "1" there could be no "useless" symbol because every symbol carries part of the original information, there are codes way better than the repetion code to increase the amount of information carried by each symbol, still it is the proof that having n+1 equal values conveys more information than n equal values and so even with 0 variance the information increases. Example: you receive a boolean information on a noisy channel with 0.5 cross-channel probability, if you receive "1" you have exactly 0 bit of information because there is no way to know if the sended bit was 0 or 1, if the sender repeats his message 3 times and you receive "111" you know that the probability that the message was 1 is 0.875 and with 0 variance you have a lot of information, passing from no information at all (1) to very good confidence (111).
How does the variance measure the information about the data? Others already answered conveying perfectly some concepts but the major misunderstatement remains to be clarified: variance IS NOT information, is not even vaguely linked to information. In some appli
43,806
What does a subscript on a probability represent?
Maybe this helps: $P$ is the distribution of random variable $x$ given the value of random variable $y$. And this distribution has parameters $\theta$. By varying the parameters, you get different distributions. For example, probability distribution over a random variable $x$ with uniform distribution on support $[a,b]$ can be written as $$P_{(a,b)}(x) = \frac{1}{b-a}I_{[a,b]}(x).$$ You will get a different distribution by varying $a$ and $b$. Edit: Frequently, you will see the probability density function of a random variable $X$ denoted as $f_X(x)$, here the subscript is just used to remember that $f_X$ is a probability density of $X$. Here $X$ is not a parameter. But if is written as $f_\theta(x)$, then $\theta$ is likely to be a parameter of the density function of the random variables $X$ which can also be written as $f_X(x|\theta).$ You will have to see what it is by the context which is very easy to see in all the cases I have encountered.
What does a subscript on a probability represent?
Maybe this helps: $P$ is the distribution of random variable $x$ given the value of random variable $y$. And this distribution has parameters $\theta$. By varying the parameters, you get different dis
What does a subscript on a probability represent? Maybe this helps: $P$ is the distribution of random variable $x$ given the value of random variable $y$. And this distribution has parameters $\theta$. By varying the parameters, you get different distributions. For example, probability distribution over a random variable $x$ with uniform distribution on support $[a,b]$ can be written as $$P_{(a,b)}(x) = \frac{1}{b-a}I_{[a,b]}(x).$$ You will get a different distribution by varying $a$ and $b$. Edit: Frequently, you will see the probability density function of a random variable $X$ denoted as $f_X(x)$, here the subscript is just used to remember that $f_X$ is a probability density of $X$. Here $X$ is not a parameter. But if is written as $f_\theta(x)$, then $\theta$ is likely to be a parameter of the density function of the random variables $X$ which can also be written as $f_X(x|\theta).$ You will have to see what it is by the context which is very easy to see in all the cases I have encountered.
What does a subscript on a probability represent? Maybe this helps: $P$ is the distribution of random variable $x$ given the value of random variable $y$. And this distribution has parameters $\theta$. By varying the parameters, you get different dis
43,807
What does a subscript on a probability represent?
Abhinav Gupta gave a nice example (+1). The general answer is that you can use the subscript to carry descriptive information about the distribution. For example, the definition of independence can be written as $$ P_{X,Y}(x,y) = P_X(x) \, P_Y(y) $$ Or you could define mixture distribution as $$ P_X(x) =\sum_k \pi_k P_k(x) $$ where $\sum_k \pi_k = 1$ are the mixing weights and $P_k$ are the individual components, the distributions that are “mixed”. In all the cases, the subscript carries information that makes more precise what does the distribution represent. As with mathematical notation in general, there is no single way how the subscripts are used, so you always need to verify it from the context.
What does a subscript on a probability represent?
Abhinav Gupta gave a nice example (+1). The general answer is that you can use the subscript to carry descriptive information about the distribution. For example, the definition of independence can be
What does a subscript on a probability represent? Abhinav Gupta gave a nice example (+1). The general answer is that you can use the subscript to carry descriptive information about the distribution. For example, the definition of independence can be written as $$ P_{X,Y}(x,y) = P_X(x) \, P_Y(y) $$ Or you could define mixture distribution as $$ P_X(x) =\sum_k \pi_k P_k(x) $$ where $\sum_k \pi_k = 1$ are the mixing weights and $P_k$ are the individual components, the distributions that are “mixed”. In all the cases, the subscript carries information that makes more precise what does the distribution represent. As with mathematical notation in general, there is no single way how the subscripts are used, so you always need to verify it from the context.
What does a subscript on a probability represent? Abhinav Gupta gave a nice example (+1). The general answer is that you can use the subscript to carry descriptive information about the distribution. For example, the definition of independence can be
43,808
Non-parametric alternative to simple t-test
Let's look at one variable at a time. As I understand it you have $n_1 =60$ observations from Population 1 which is distributed $\mathsf{Norm}(\mu_1, \sigma_1)$ and $n_2 =60$ observations from Population 2 which is distributed $\mathsf{Norm}(\mu_2, \sigma_2).$ You want to test $H_0: \mu_1 = \mu_2$ against $H_a: \mu_1 \ne \mu_2.$ You could use a 2-sample t test. Unless you have prior experience with such data indicating that $\sigma_1 = \sigma_2,$ it is considered good practice to use the Welch (separate-variances) t test, which does not require $\sigma_1 = \sigma_2.$ Specifically, suppose you have the following data: sort(x1); summary(x1); sd(x1) [1] 78.0 78.5 80.1 80.9 87.2 88.8 89.0 90.1 90.7 92.6 92.9 93.7 94.5 97.3 98.3 [16] 98.3 98.6 100.5 100.9 101.1 101.8 101.9 103.2 103.4 104.0 104.1 104.6 104.9 105.1 105.4 [31] 105.8 107.2 107.6 108.1 108.1 108.2 108.7 109.6 109.6 112.0 112.2 112.7 114.0 114.1 114.7 [46] 114.8 116.6 117.0 118.0 118.4 118.6 119.2 123.1 124.1 124.7 125.5 127.4 127.7 136.4 138.2 Min. 1st Qu. Median Mean 3rd Qu. Max. 78.0 98.3 105.6 106.2 114.7 138.2 [1] 13.55809 . sort(x2); summary(x2); sd(x2) [1] 65.3 70.1 76.1 76.8 80.9 81.3 82.4 82.5 84.9 85.0 85.6 86.6 87.7 88.6 89.4 [16] 89.7 90.3 91.9 92.2 92.5 93.0 93.0 93.5 94.0 94.4 96.1 96.4 96.9 97.3 97.6 [31] 98.5 98.9 99.7 99.9 100.2 101.3 101.5 101.7 103.3 103.4 103.5 103.6 104.5 104.7 106.0 [46] 106.2 107.2 107.7 109.2 109.3 110.5 110.7 110.9 111.1 111.3 113.8 114.9 115.2 118.1 118.9 Min. 1st Qu. Median Mean 3rd Qu. Max. 65.30 89.62 98.05 97.30 106.05 118.90 [1] 11.89914 boxplot(x1, x2, notch=T, col="skyblue2", pch=19) There are no outliers in either sample and samples seem roughly symmetrical. The notches in the sides of the boxplots are approximate nonparametric confidence intervals, here indicating that the population medians differ. The Welch 2-sample t test shows a significant difference. [A pooled t test would have had df = 118; because of a slight difference in sample standard deviations, the Welch test has only about df = 116.] t.test(x1, x2) Welch Two Sample t-test data: x1 and x2 t = 3.8288, df = 116.05, p-value = 0.0002092 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 4.304113 13.529220 sample estimates: mean of x mean of y 106.2117 97.2950 Now for your specific concerns: (1) For sample sizes of 60, you should not worry about a slight departure from normality. If you feel nonnormality may be a problem you can look at all 120 'residuals' in this model together in one normality test. (The residuals are $X_{1i} - \bar X_1, X_{2i} - \bar X_2.$ for $i=1, 2, \dots, 60.)$ (2) Any difference in variances is taken care of by doing the Welch 2-sample t test. (3) The nonparametric two-sample Wilcoxon (signed-rank) test could be used if you really feel data are far from normality. This is a test to see if one population is shifted from the other. (Some authors frame this as testing for a difference in medians, but a paper in this month's The American Statistician objects to that interpretation and takes a broader view of the test: Dixon et al. (2018), Vol. 72, Nr. 3, "The Wilcoxon-Mann-Whitney procedure fails as a test of medians.") For my example, this test finds a significant difference between the two populations, without assuming either population is normal. wilcox.test(x1, x2) Wilcoxon rank sum test with continuity correction data: x1 and x2 W = 2465, p-value = 0.0004871 alternative hypothesis: true location shift is not equal to 0 (4) Addendum: A Comment and a linked Q&A mention permutation tests, so we include one possible permutation test. [For an elementary discussion of permutation tests, perhaps see Eudey et al. (2010), especially Sect. 3.] Below is R code for a permutation test using the pooled t statistic as 'metric'. If the two groups are the same it should not matter if we randomly scramble the 120 observations into two groups of 60. We recognize the pooled t statistic as a reasonable way to measure the distance between two samples, but do not assume that statistic has Student's t distribution. The code assumes data x1 and x2 are present, does the scrambling with the function sample(gp), and (conveniently, but somewhat inefficiently) uses t.test()$stat to get the t statistics of the permuted samples. The P-value 0.0003 indicates rejection of the null hypothesis. (Results may vary slightly from one run to the next.) all = c(x1, x2); gp = rep(1:2, each=60) t.obs = t.test(all ~ gp, var.eq=T)$stat t.prm = replicate( 10^5, t.test(all ~ sample(gp), var.eq=T)$stat ) mean(abs(t.prm) > abs(t.obs)) [1] 0.00026 The figure below shows a histogram of the simulated permutation distribution. [It happens to match the density curve (black) of Student's t distribution with 118 degrees of freedom rather well, because data were simulated as normal with nearly equal SDs.] The P-value is the proportion of permuted t statistics outside the vertical dotted lines. Note: My data were generated in R as follows: set.seed(818) x1 = round(rnorm(60, 107, 15), 1); x2 = round(rnorm(60, 100, 14), 1)
Non-parametric alternative to simple t-test
Let's look at one variable at a time. As I understand it you have $n_1 =60$ observations from Population 1 which is distributed $\mathsf{Norm}(\mu_1, \sigma_1)$ and $n_2 =60$ observations from Popula
Non-parametric alternative to simple t-test Let's look at one variable at a time. As I understand it you have $n_1 =60$ observations from Population 1 which is distributed $\mathsf{Norm}(\mu_1, \sigma_1)$ and $n_2 =60$ observations from Population 2 which is distributed $\mathsf{Norm}(\mu_2, \sigma_2).$ You want to test $H_0: \mu_1 = \mu_2$ against $H_a: \mu_1 \ne \mu_2.$ You could use a 2-sample t test. Unless you have prior experience with such data indicating that $\sigma_1 = \sigma_2,$ it is considered good practice to use the Welch (separate-variances) t test, which does not require $\sigma_1 = \sigma_2.$ Specifically, suppose you have the following data: sort(x1); summary(x1); sd(x1) [1] 78.0 78.5 80.1 80.9 87.2 88.8 89.0 90.1 90.7 92.6 92.9 93.7 94.5 97.3 98.3 [16] 98.3 98.6 100.5 100.9 101.1 101.8 101.9 103.2 103.4 104.0 104.1 104.6 104.9 105.1 105.4 [31] 105.8 107.2 107.6 108.1 108.1 108.2 108.7 109.6 109.6 112.0 112.2 112.7 114.0 114.1 114.7 [46] 114.8 116.6 117.0 118.0 118.4 118.6 119.2 123.1 124.1 124.7 125.5 127.4 127.7 136.4 138.2 Min. 1st Qu. Median Mean 3rd Qu. Max. 78.0 98.3 105.6 106.2 114.7 138.2 [1] 13.55809 . sort(x2); summary(x2); sd(x2) [1] 65.3 70.1 76.1 76.8 80.9 81.3 82.4 82.5 84.9 85.0 85.6 86.6 87.7 88.6 89.4 [16] 89.7 90.3 91.9 92.2 92.5 93.0 93.0 93.5 94.0 94.4 96.1 96.4 96.9 97.3 97.6 [31] 98.5 98.9 99.7 99.9 100.2 101.3 101.5 101.7 103.3 103.4 103.5 103.6 104.5 104.7 106.0 [46] 106.2 107.2 107.7 109.2 109.3 110.5 110.7 110.9 111.1 111.3 113.8 114.9 115.2 118.1 118.9 Min. 1st Qu. Median Mean 3rd Qu. Max. 65.30 89.62 98.05 97.30 106.05 118.90 [1] 11.89914 boxplot(x1, x2, notch=T, col="skyblue2", pch=19) There are no outliers in either sample and samples seem roughly symmetrical. The notches in the sides of the boxplots are approximate nonparametric confidence intervals, here indicating that the population medians differ. The Welch 2-sample t test shows a significant difference. [A pooled t test would have had df = 118; because of a slight difference in sample standard deviations, the Welch test has only about df = 116.] t.test(x1, x2) Welch Two Sample t-test data: x1 and x2 t = 3.8288, df = 116.05, p-value = 0.0002092 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 4.304113 13.529220 sample estimates: mean of x mean of y 106.2117 97.2950 Now for your specific concerns: (1) For sample sizes of 60, you should not worry about a slight departure from normality. If you feel nonnormality may be a problem you can look at all 120 'residuals' in this model together in one normality test. (The residuals are $X_{1i} - \bar X_1, X_{2i} - \bar X_2.$ for $i=1, 2, \dots, 60.)$ (2) Any difference in variances is taken care of by doing the Welch 2-sample t test. (3) The nonparametric two-sample Wilcoxon (signed-rank) test could be used if you really feel data are far from normality. This is a test to see if one population is shifted from the other. (Some authors frame this as testing for a difference in medians, but a paper in this month's The American Statistician objects to that interpretation and takes a broader view of the test: Dixon et al. (2018), Vol. 72, Nr. 3, "The Wilcoxon-Mann-Whitney procedure fails as a test of medians.") For my example, this test finds a significant difference between the two populations, without assuming either population is normal. wilcox.test(x1, x2) Wilcoxon rank sum test with continuity correction data: x1 and x2 W = 2465, p-value = 0.0004871 alternative hypothesis: true location shift is not equal to 0 (4) Addendum: A Comment and a linked Q&A mention permutation tests, so we include one possible permutation test. [For an elementary discussion of permutation tests, perhaps see Eudey et al. (2010), especially Sect. 3.] Below is R code for a permutation test using the pooled t statistic as 'metric'. If the two groups are the same it should not matter if we randomly scramble the 120 observations into two groups of 60. We recognize the pooled t statistic as a reasonable way to measure the distance between two samples, but do not assume that statistic has Student's t distribution. The code assumes data x1 and x2 are present, does the scrambling with the function sample(gp), and (conveniently, but somewhat inefficiently) uses t.test()$stat to get the t statistics of the permuted samples. The P-value 0.0003 indicates rejection of the null hypothesis. (Results may vary slightly from one run to the next.) all = c(x1, x2); gp = rep(1:2, each=60) t.obs = t.test(all ~ gp, var.eq=T)$stat t.prm = replicate( 10^5, t.test(all ~ sample(gp), var.eq=T)$stat ) mean(abs(t.prm) > abs(t.obs)) [1] 0.00026 The figure below shows a histogram of the simulated permutation distribution. [It happens to match the density curve (black) of Student's t distribution with 118 degrees of freedom rather well, because data were simulated as normal with nearly equal SDs.] The P-value is the proportion of permuted t statistics outside the vertical dotted lines. Note: My data were generated in R as follows: set.seed(818) x1 = round(rnorm(60, 107, 15), 1); x2 = round(rnorm(60, 100, 14), 1)
Non-parametric alternative to simple t-test Let's look at one variable at a time. As I understand it you have $n_1 =60$ observations from Population 1 which is distributed $\mathsf{Norm}(\mu_1, \sigma_1)$ and $n_2 =60$ observations from Popula
43,809
Non-parametric alternative to simple t-test
The t-test does not assume normality of the dependent variable; it assumes normality conditional on the predictor. (See this thread: Where does the misconception that Y must be normally distributed come from?). A simple way to condition on your grouping variable is to look at a histogram of the dependent variable, splitting the data on your grouping variable. Normality tests, like the Shapiro-Wilk test, may not be that informative. Small deviations from normality may come up as significant (see this thread: Is normality testing 'essentially useless'?). However, given your small sample size, this probably is not an issue. Nonetheless, it does not really matter (practically speaking) if normality is violated, but the extent to which it is violated. Depending on how non-normal your data might be, you probably do not have much to worry about. The general linear model (of which the t-test is a part) is more robust to violations of the normality assumption than to other assumptions (such as independence of observations). Just how robust it is has been discussed on this website before, such as in this thread: How robust is the independent samples t-test when the distributions of the samples are non-normal?. There are many papers looking at how robust this method is to violations of normality, as well (as evidenced by this quick Scholar search: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C33&q=t-test+robust+to+nonnormality&btnG=). You might as well run a nonparametric test and see if your conclusions differ; it costs essentially nothing to do so. The most popular alternative is the Mann-Whitney test, which is done with the stats::wilcox.test function in R (http://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html). There are a lot of good introductions to this test on the internet—I would Google around until a description of it clicks with you. I find this video, calculating the test statistic by hand, to be very intuitive: https://www.youtube.com/watch?v=BT1FKd1Qzjw. Of course, you use a computer to calculate this, but I like knowing what's going on underneath.
Non-parametric alternative to simple t-test
The t-test does not assume normality of the dependent variable; it assumes normality conditional on the predictor. (See this thread: Where does the misconception that Y must be normally distributed co
Non-parametric alternative to simple t-test The t-test does not assume normality of the dependent variable; it assumes normality conditional on the predictor. (See this thread: Where does the misconception that Y must be normally distributed come from?). A simple way to condition on your grouping variable is to look at a histogram of the dependent variable, splitting the data on your grouping variable. Normality tests, like the Shapiro-Wilk test, may not be that informative. Small deviations from normality may come up as significant (see this thread: Is normality testing 'essentially useless'?). However, given your small sample size, this probably is not an issue. Nonetheless, it does not really matter (practically speaking) if normality is violated, but the extent to which it is violated. Depending on how non-normal your data might be, you probably do not have much to worry about. The general linear model (of which the t-test is a part) is more robust to violations of the normality assumption than to other assumptions (such as independence of observations). Just how robust it is has been discussed on this website before, such as in this thread: How robust is the independent samples t-test when the distributions of the samples are non-normal?. There are many papers looking at how robust this method is to violations of normality, as well (as evidenced by this quick Scholar search: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C33&q=t-test+robust+to+nonnormality&btnG=). You might as well run a nonparametric test and see if your conclusions differ; it costs essentially nothing to do so. The most popular alternative is the Mann-Whitney test, which is done with the stats::wilcox.test function in R (http://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html). There are a lot of good introductions to this test on the internet—I would Google around until a description of it clicks with you. I find this video, calculating the test statistic by hand, to be very intuitive: https://www.youtube.com/watch?v=BT1FKd1Qzjw. Of course, you use a computer to calculate this, but I like knowing what's going on underneath.
Non-parametric alternative to simple t-test The t-test does not assume normality of the dependent variable; it assumes normality conditional on the predictor. (See this thread: Where does the misconception that Y must be normally distributed co
43,810
Non-parametric alternative to simple t-test
One thing to keep in mind- outside of some contexts in physics, no process in nature will generate purely normally distributed data (or data with any particular nicely behaved distribution). What does this mean in practice? It means that if you possessed an omnipotent test for normality, the test would reject 100% of the time, because your data will essentially always only be, at best, approximately normal. This is why learning to ascertain the extent of approximate normality and its possible effects on inference is so important for researchers, rather than relying on tests.
Non-parametric alternative to simple t-test
One thing to keep in mind- outside of some contexts in physics, no process in nature will generate purely normally distributed data (or data with any particular nicely behaved distribution). What doe
Non-parametric alternative to simple t-test One thing to keep in mind- outside of some contexts in physics, no process in nature will generate purely normally distributed data (or data with any particular nicely behaved distribution). What does this mean in practice? It means that if you possessed an omnipotent test for normality, the test would reject 100% of the time, because your data will essentially always only be, at best, approximately normal. This is why learning to ascertain the extent of approximate normality and its possible effects on inference is so important for researchers, rather than relying on tests.
Non-parametric alternative to simple t-test One thing to keep in mind- outside of some contexts in physics, no process in nature will generate purely normally distributed data (or data with any particular nicely behaved distribution). What doe
43,811
What is the expected absolute difference between sample and population mean?
This is an addendum to @Aksakal's answer. As he points out, we need to find the value of $E|Y|]$ where $Y \sim \mathcal N(0,\sigma^2/n)$. This can be done very straightforwadly via the law of the unconscious statistician, without needing to think of $\chi$ random variables etc. We have \begin{align} E[|Y|] &= \int_{-\infty}^\infty |y|\cdot\frac{1}{(\sigma/\sqrt{n})\sqrt{2\pi}} \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= 2\int_{0}^\infty y\cdot\frac{1}{(\sigma/\sqrt{n})\sqrt{2\pi}} \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= \sqrt{\frac{2}{\pi}}\cdot \frac{\sigma}{\sqrt{n}}\int_{0}^\infty \frac{y}{\sigma^2/n}\cdot \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= \sqrt{\frac{2}{\pi}}\cdot \frac{\sigma}{\sqrt{n}}~\left[-\exp\left(-\frac{y^2}{2\sigma^2/n}\right)\right|_0^\infty\\ &= \sqrt{\frac{2}{n\pi}}\cdot\sigma \end{align}
What is the expected absolute difference between sample and population mean?
This is an addendum to @Aksakal's answer. As he points out, we need to find the value of $E|Y|]$ where $Y \sim \mathcal N(0,\sigma^2/n)$. This can be done very straightforwadly via the law of the unco
What is the expected absolute difference between sample and population mean? This is an addendum to @Aksakal's answer. As he points out, we need to find the value of $E|Y|]$ where $Y \sim \mathcal N(0,\sigma^2/n)$. This can be done very straightforwadly via the law of the unconscious statistician, without needing to think of $\chi$ random variables etc. We have \begin{align} E[|Y|] &= \int_{-\infty}^\infty |y|\cdot\frac{1}{(\sigma/\sqrt{n})\sqrt{2\pi}} \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= 2\int_{0}^\infty y\cdot\frac{1}{(\sigma/\sqrt{n})\sqrt{2\pi}} \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= \sqrt{\frac{2}{\pi}}\cdot \frac{\sigma}{\sqrt{n}}\int_{0}^\infty \frac{y}{\sigma^2/n}\cdot \exp\left(-\frac{y^2}{2\sigma^2/n}\right)\,\mathrm dy\\ &= \sqrt{\frac{2}{\pi}}\cdot \frac{\sigma}{\sqrt{n}}~\left[-\exp\left(-\frac{y^2}{2\sigma^2/n}\right)\right|_0^\infty\\ &= \sqrt{\frac{2}{n\pi}}\cdot\sigma \end{align}
What is the expected absolute difference between sample and population mean? This is an addendum to @Aksakal's answer. As he points out, we need to find the value of $E|Y|]$ where $Y \sim \mathcal N(0,\sigma^2/n)$. This can be done very straightforwadly via the law of the unco
43,812
What is the expected absolute difference between sample and population mean?
The sample mean is going to be normal since the underlying distribution is normal. The distribution of a sample mean is $\mathcal{N}(\mu,\sigma^2/n)$. It's easy to compute the expectation of the absolute deviation then: $$\bar x-\mu\sim\mathcal{N}(0,\sigma^2/n)$$ All you need is the expectation of absolute value of a normal. A distribution of the absolute value of a normal distribution is called "folded normal". In our case the underlying normal (of the deviation from population) has mean zero, hence it reduces to a $\chi$ distribution with degrees of freedom 1. You can find the formulas anywhere: $$\sigma\sqrt{\frac{2}{n\pi}}$$
What is the expected absolute difference between sample and population mean?
The sample mean is going to be normal since the underlying distribution is normal. The distribution of a sample mean is $\mathcal{N}(\mu,\sigma^2/n)$. It's easy to compute the expectation of the absol
What is the expected absolute difference between sample and population mean? The sample mean is going to be normal since the underlying distribution is normal. The distribution of a sample mean is $\mathcal{N}(\mu,\sigma^2/n)$. It's easy to compute the expectation of the absolute deviation then: $$\bar x-\mu\sim\mathcal{N}(0,\sigma^2/n)$$ All you need is the expectation of absolute value of a normal. A distribution of the absolute value of a normal distribution is called "folded normal". In our case the underlying normal (of the deviation from population) has mean zero, hence it reduces to a $\chi$ distribution with degrees of freedom 1. You can find the formulas anywhere: $$\sigma\sqrt{\frac{2}{n\pi}}$$
What is the expected absolute difference between sample and population mean? The sample mean is going to be normal since the underlying distribution is normal. The distribution of a sample mean is $\mathcal{N}(\mu,\sigma^2/n)$. It's easy to compute the expectation of the absol
43,813
What is the expected absolute difference between sample and population mean?
Consider a normal random variable $Y$ with mean $\mu$ and variance $\tau^2$, and let $Z=\frac{Y-\mu}{\tau}$ (so $Z$ is standard normal). $$\:\:E(|Z|)=2\int_0^\infty z\cdot \frac{1}{\sqrt{2\pi}} e^{-\frac{z^2}{2}} dz$$ $\quad$ Let $u=\frac{z^2}{2}$, so $du=z \,dz$. $$\qquad=\frac{2}{\sqrt{2\pi}}\int_0^\infty e^{-u} du$$ $$=\sqrt{\frac{2}{\pi}}\qquad\quad$$ Hence $E(|Y-\mu|)=\tau E(|Z|)=\tau\sqrt{\frac{2}{\pi}}$. Let $X\sim N(\mu,\sigma^2)$. Let $Y=\bar{X}$. Then $\tau=\sigma/\sqrt{n}$. Hence $E(|\bar{X}-\mu|)=E(|Y-\mu|)=\tau\sqrt{\frac{2}{\pi}}=\sigma\sqrt{\frac{2}{n\pi}}\quad$ ($\approx 0.8 \frac{\sigma}{\sqrt{n}}$)
What is the expected absolute difference between sample and population mean?
Consider a normal random variable $Y$ with mean $\mu$ and variance $\tau^2$, and let $Z=\frac{Y-\mu}{\tau}$ (so $Z$ is standard normal). $$\:\:E(|Z|)=2\int_0^\infty z\cdot \frac{1}{\sqrt{2\pi}} e^{-\f
What is the expected absolute difference between sample and population mean? Consider a normal random variable $Y$ with mean $\mu$ and variance $\tau^2$, and let $Z=\frac{Y-\mu}{\tau}$ (so $Z$ is standard normal). $$\:\:E(|Z|)=2\int_0^\infty z\cdot \frac{1}{\sqrt{2\pi}} e^{-\frac{z^2}{2}} dz$$ $\quad$ Let $u=\frac{z^2}{2}$, so $du=z \,dz$. $$\qquad=\frac{2}{\sqrt{2\pi}}\int_0^\infty e^{-u} du$$ $$=\sqrt{\frac{2}{\pi}}\qquad\quad$$ Hence $E(|Y-\mu|)=\tau E(|Z|)=\tau\sqrt{\frac{2}{\pi}}$. Let $X\sim N(\mu,\sigma^2)$. Let $Y=\bar{X}$. Then $\tau=\sigma/\sqrt{n}$. Hence $E(|\bar{X}-\mu|)=E(|Y-\mu|)=\tau\sqrt{\frac{2}{\pi}}=\sigma\sqrt{\frac{2}{n\pi}}\quad$ ($\approx 0.8 \frac{\sigma}{\sqrt{n}}$)
What is the expected absolute difference between sample and population mean? Consider a normal random variable $Y$ with mean $\mu$ and variance $\tau^2$, and let $Z=\frac{Y-\mu}{\tau}$ (so $Z$ is standard normal). $$\:\:E(|Z|)=2\int_0^\infty z\cdot \frac{1}{\sqrt{2\pi}} e^{-\f
43,814
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
The result shown is correct. Indeed, in general, for any true error variance $\sigma^2$ and under the usual linear model assumptions, $$ \hat\beta \sim N_p(\beta, \sigma^2(X^\top X)^{-1}), $$ where $\beta = (\beta_1,\ldots,\beta_{p})$. On the other hand, for a single component of $\hat\beta$, say $\hat\beta_r$, we have that $$ \hat\beta_r \sim N(\beta_r, \sigma^2(X^\top X)^{-1}_{rr}), $$ where $(X^\top X)^{-1}_{rr}$ denotes the $r$th element of the diagonal of the matrix $(X^\top X)^{-1}$, $r=1,\ldots,p$. Now the $t$-Student distribution comes in when you wish to perform inference on $\beta_r$. Indeed, given the pivot $$ \frac{(n-p)\hat S^2}{\sigma^2}\sim \chi_{n-p}^2, $$ under the assumption of the linear model, we have the following pivot for $\beta_r$ $$ \frac{\frac{\hat\beta_r-\beta_r}{\sqrt{\sigma^2(X^\top X)_{rr}^{-1}}}}{\sqrt{S^2/\sigma^2}} = \frac{\hat\beta_r-\beta_r}{\sqrt{S^2(X^\top X)_{rr}^{-1}}}\sim t_{n-p}\,\tag{*} $$ It is in (*) where you encounter the $t$-Student distribution concerning the OLS estimator.
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
The result shown is correct. Indeed, in general, for any true error variance $\sigma^2$ and under the usual linear model assumptions, $$ \hat\beta \sim N_p(\beta, \sigma^2(X^\top X)^{-1}), $$ where $\
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution The result shown is correct. Indeed, in general, for any true error variance $\sigma^2$ and under the usual linear model assumptions, $$ \hat\beta \sim N_p(\beta, \sigma^2(X^\top X)^{-1}), $$ where $\beta = (\beta_1,\ldots,\beta_{p})$. On the other hand, for a single component of $\hat\beta$, say $\hat\beta_r$, we have that $$ \hat\beta_r \sim N(\beta_r, \sigma^2(X^\top X)^{-1}_{rr}), $$ where $(X^\top X)^{-1}_{rr}$ denotes the $r$th element of the diagonal of the matrix $(X^\top X)^{-1}$, $r=1,\ldots,p$. Now the $t$-Student distribution comes in when you wish to perform inference on $\beta_r$. Indeed, given the pivot $$ \frac{(n-p)\hat S^2}{\sigma^2}\sim \chi_{n-p}^2, $$ under the assumption of the linear model, we have the following pivot for $\beta_r$ $$ \frac{\frac{\hat\beta_r-\beta_r}{\sqrt{\sigma^2(X^\top X)_{rr}^{-1}}}}{\sqrt{S^2/\sigma^2}} = \frac{\hat\beta_r-\beta_r}{\sqrt{S^2(X^\top X)_{rr}^{-1}}}\sim t_{n-p}\,\tag{*} $$ It is in (*) where you encounter the $t$-Student distribution concerning the OLS estimator.
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution The result shown is correct. Indeed, in general, for any true error variance $\sigma^2$ and under the usual linear model assumptions, $$ \hat\beta \sim N_p(\beta, \sigma^2(X^\top X)^{-1}), $$ where $\
43,815
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
$\hat\beta_3 \sim N(\beta_3, 0.022 \sigma^2)$ is the distribution of the estimate $\hat\beta_3$ conditional on the values of $\beta_3$ and $\sigma$. In inference, you often do not know $\beta_3$ and $\sigma$ and compute a statistic $\frac{\hat\beta_3}{\hat{\sigma}}$. That is the statistic which is t-distributed (if the null hypothesis, $\beta_3 = 0$, is true, otherwise it is non-central t-distributed). For your 'problem 1' the idea is to ignore this for a while and just experience/understand/observe how the estimate $\hat\beta_3$ is distributed, when we know the actual values of $\beta_3$ and $\sigma$. It is a sort of thought experiment.
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
$\hat\beta_3 \sim N(\beta_3, 0.022 \sigma^2)$ is the distribution of the estimate $\hat\beta_3$ conditional on the values of $\beta_3$ and $\sigma$. In inference, you often do not know $\beta_3$ and $
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution $\hat\beta_3 \sim N(\beta_3, 0.022 \sigma^2)$ is the distribution of the estimate $\hat\beta_3$ conditional on the values of $\beta_3$ and $\sigma$. In inference, you often do not know $\beta_3$ and $\sigma$ and compute a statistic $\frac{\hat\beta_3}{\hat{\sigma}}$. That is the statistic which is t-distributed (if the null hypothesis, $\beta_3 = 0$, is true, otherwise it is non-central t-distributed). For your 'problem 1' the idea is to ignore this for a while and just experience/understand/observe how the estimate $\hat\beta_3$ is distributed, when we know the actual values of $\beta_3$ and $\sigma$. It is a sort of thought experiment.
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution $\hat\beta_3 \sim N(\beta_3, 0.022 \sigma^2)$ is the distribution of the estimate $\hat\beta_3$ conditional on the values of $\beta_3$ and $\sigma$. In inference, you often do not know $\beta_3$ and $
43,816
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
In OLS, we typically assume the following for the error terms $u$: A(1): $ E(u) = 0 $ A(2): $ u \sim N(0, \sigma^2I) $ this leads to the distribution $ \widehat{\beta} \sim N(\beta, \operatorname{Var}(\widehat{\beta})) $ in small samples, if assumption A(2) holds true and even approximate for large samples, if A(2) is violated
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution
In OLS, we typically assume the following for the error terms $u$: A(1): $ E(u) = 0 $ A(2): $ u \sim N(0, \sigma^2I) $ this leads to the distribution $ \widehat{\beta} \sim N(\beta, \operatorname{Va
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution In OLS, we typically assume the following for the error terms $u$: A(1): $ E(u) = 0 $ A(2): $ u \sim N(0, \sigma^2I) $ this leads to the distribution $ \widehat{\beta} \sim N(\beta, \operatorname{Var}(\widehat{\beta})) $ in small samples, if assumption A(2) holds true and even approximate for large samples, if A(2) is violated
OLS - Why coefficient Beta has Normal Distribution but not t-Distribution In OLS, we typically assume the following for the error terms $u$: A(1): $ E(u) = 0 $ A(2): $ u \sim N(0, \sigma^2I) $ this leads to the distribution $ \widehat{\beta} \sim N(\beta, \operatorname{Va
43,817
Can we remove significant variables in a regression?
To just address the actual question: Significance means that there is evidence that the variable has a nonzero contribution given all other variables in the model. This means that correlation is not a valid reason to remove a significant variable, because its significance means that its contribution can not be accounted for by the other variable. Otherwise I agree regarding the critical remarks on variable selection based on p-values in general. The Lasso may be better here. Also, if you choose analyses based on what you expect from theory, your analyses will be invalid because you bias them in order to fit your theory.
Can we remove significant variables in a regression?
To just address the actual question: Significance means that there is evidence that the variable has a nonzero contribution given all other variables in the model. This means that correlation is not a
Can we remove significant variables in a regression? To just address the actual question: Significance means that there is evidence that the variable has a nonzero contribution given all other variables in the model. This means that correlation is not a valid reason to remove a significant variable, because its significance means that its contribution can not be accounted for by the other variable. Otherwise I agree regarding the critical remarks on variable selection based on p-values in general. The Lasso may be better here. Also, if you choose analyses based on what you expect from theory, your analyses will be invalid because you bias them in order to fit your theory.
Can we remove significant variables in a regression? To just address the actual question: Significance means that there is evidence that the variable has a nonzero contribution given all other variables in the model. This means that correlation is not a
43,818
Can we remove significant variables in a regression?
Please do not choose variables for a regression model based on p-values. Also please do not choose variables so that you achieve results that "meet expectations". If you include variables in your model to begin with, this was presumably because they were identified as possible confounders or as variables that were not associated with your main exposure but associated with the outcome (competing exposures). These are GOOD reasons, and p-values are not part of the decision making. Of course it is important not to over-adjust for possible confounding, and to avoid things like conditioning on a collider. The best way to do this in my opinion is by considering the possible causal relations between the variables using a causal diagram or DAG, which will then inform you of the minimally sufficient set of variables to condition on. A good free online too for doing this is http://www.dagitty.net/ Also, this answer may help you understand the pitfalls of not choosing variables in a principled manner. How do DAGs help to reduce bias in causal inference?
Can we remove significant variables in a regression?
Please do not choose variables for a regression model based on p-values. Also please do not choose variables so that you achieve results that "meet expectations". If you include variables in your mode
Can we remove significant variables in a regression? Please do not choose variables for a regression model based on p-values. Also please do not choose variables so that you achieve results that "meet expectations". If you include variables in your model to begin with, this was presumably because they were identified as possible confounders or as variables that were not associated with your main exposure but associated with the outcome (competing exposures). These are GOOD reasons, and p-values are not part of the decision making. Of course it is important not to over-adjust for possible confounding, and to avoid things like conditioning on a collider. The best way to do this in my opinion is by considering the possible causal relations between the variables using a causal diagram or DAG, which will then inform you of the minimally sufficient set of variables to condition on. A good free online too for doing this is http://www.dagitty.net/ Also, this answer may help you understand the pitfalls of not choosing variables in a principled manner. How do DAGs help to reduce bias in causal inference?
Can we remove significant variables in a regression? Please do not choose variables for a regression model based on p-values. Also please do not choose variables so that you achieve results that "meet expectations". If you include variables in your mode
43,819
Can we remove significant variables in a regression?
And this is causing the sign of the coefficient of other variables to go opposite way (not as per expectation or theory). Basically (i.e. this is an oversimplification), this means that the effect of the second variable is negative, once the effect of the first is controlled for. For example, suppose you're doing a regression on life span, and one of your variables is diabetes diagnosis, and another is use of insulin. You'll probably find that insulin use is negatively correlated with life span. But when you include diabetes diagnosis, the effect will probably become positive. That's because someone who has diabetes and is using insulin has a lower life expectancy when compared to the general population, but a higher life expectancy when compared to someone with diabetes but isn't taking their insulin shots. My question is that can we still remove one of those (correlated) significant variables? It makes the whole result come as per the expectations. Well, what the goal of the regression? To gain insight into reality, or to come up with numbers that accord with your expectations? If having a negative coefficient really bothers you, you can look at what happens when you do PCA and do regression on the principal components rather than the original variables. In my example above, "has diabetes and doesn't take insulin" would probably be the first component, and "takes the medically appropriate level of insulin" the second. Looking at what the components come out to be and what their coefficients may give you more insight into what's going on, and result in the coefficients "making sense" more. The lesson here is that properly interpreting regression is complicated, and involves more than just looking at the coefficients. Just saying "the coefficient for a variable represents how much effect that variable has on the response variable" is a simplification that sometimes is very misleading.
Can we remove significant variables in a regression?
And this is causing the sign of the coefficient of other variables to go opposite way (not as per expectation or theory). Basically (i.e. this is an oversimplification), this means that the effect of
Can we remove significant variables in a regression? And this is causing the sign of the coefficient of other variables to go opposite way (not as per expectation or theory). Basically (i.e. this is an oversimplification), this means that the effect of the second variable is negative, once the effect of the first is controlled for. For example, suppose you're doing a regression on life span, and one of your variables is diabetes diagnosis, and another is use of insulin. You'll probably find that insulin use is negatively correlated with life span. But when you include diabetes diagnosis, the effect will probably become positive. That's because someone who has diabetes and is using insulin has a lower life expectancy when compared to the general population, but a higher life expectancy when compared to someone with diabetes but isn't taking their insulin shots. My question is that can we still remove one of those (correlated) significant variables? It makes the whole result come as per the expectations. Well, what the goal of the regression? To gain insight into reality, or to come up with numbers that accord with your expectations? If having a negative coefficient really bothers you, you can look at what happens when you do PCA and do regression on the principal components rather than the original variables. In my example above, "has diabetes and doesn't take insulin" would probably be the first component, and "takes the medically appropriate level of insulin" the second. Looking at what the components come out to be and what their coefficients may give you more insight into what's going on, and result in the coefficients "making sense" more. The lesson here is that properly interpreting regression is complicated, and involves more than just looking at the coefficients. Just saying "the coefficient for a variable represents how much effect that variable has on the response variable" is a simplification that sometimes is very misleading.
Can we remove significant variables in a regression? And this is causing the sign of the coefficient of other variables to go opposite way (not as per expectation or theory). Basically (i.e. this is an oversimplification), this means that the effect of
43,820
Fitting known equation to data
Fitting data to an equation without free parameters First, let's clarify what it means "to see how well my data fits to the equation" when you have a fixed equation as in your original question. You have data on $x$ and $y$, and your equation: $$y=(3.5-(x/10))(x/25)^{5/2}$$ has no free parameters. Here's a plot; data points are circles, the equation a solid curve: So to answer your original question, your data don't fit that equation very well. Fitting parameters of an equation to match data Second, "fitting an equation" generally means having a general form of a relation between $y$ and $x$ in mind, but the details of the form depend on some additional unknown parameters of the equation. "Fitting" then means using the data to estimate the values of the parameters that best match the data, say by minimizing the sum of the squares of the discrepancies between the curve and the data. That is what's implicit in the form of the equation in your comment. (I corrected an apparently missing parenthesis so that it matches your original parameter-free equation at $z=25$): $$y = \frac{35-x}{35-z}\left(\frac{x}{z}\right)^{(z/10)}$$ Now there is something to "fit": find the value of $z$ that comes closest to your data. The simplest R function to do this is nls. (The R code I used is at the end of the answer.) The best fit to your $x$ and $y$ data is provided by a $z$ value of 33.1, not the value of 25 that would match your first parameter-free equation. It comes closer, but doesn't do very well, either, substantially below most of the true values: It looks like your equation might have an even more general form, like: $$y = \frac{a-x}{a-z}\left(\frac{x}{z}\right)^{(z/b)}$$ where $z$, $a$ and $b$ are parameters whose values might be estimated from the data. With that more general form, you can come fairly close to your data, at $z=34.0$, $a=36.7$, and $b=17.8$: Dangers in fitting equations Third, you must be very careful if you head down this fitting path. As John von Neumann allegedly said, "With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." Overfitting is a serious temptation when you start playing with data. In a case like yours you have to think about what the parameters might mean in the real world. It seems that there are competing processes that lead to a peak in growth rate ($y$) at a certain temperature ($x$), and if the parameters $z$, $a$ and $b$ have definite meanings in terms of those competing processes then you might be justified in doing this type of fit. You might, say, learn something about how those processes differ from one strain of bacteria to another. But if such parameters (or the fixed values in your original equation) were simply chosen by someone to make some earlier set of data fit a particular curve then you are headed for big trouble. Comparing fits to different data sets If you want to compare the parameter values fitted to two different data sets, it's best to start by examining whether the overall fits differ between the data sets. There is a "useful and rather easily overlooked" way to do this with nls as Peter Dalgaard put it in a recent answer on R-help. (It can be found at the very bottom of the nls help page.) Instead of working with separate vectors of $x$ and $y$ values from different experiments, construct a pooled data frame containing all the data. Each row should contain an $x$ value, the associated observed $y$ value, and a factor variable indicating the specific experiment. (Make sure the experiments are coded as factors, not as numbers.) nls then allows you to fit different sets of parameter values to different experiments. Instead of specifying general parameters like Topt in your call, you can subscript the parameters by experiment, e.g. Topt[expt], where "expt" is the name of the factor distinguishing experiments. Thus you can use anova to compare a fit to all the data, ignoring individual experiments, against a fit that allows different parameter values for different experiments. If these fits aren't statistically distinguishable, then you shouldn't be looking at differences of individual fitted parameter values among experiments. There's an example below where I present R code. If the fits do differ, then you can consider comparing fitted parameter values. In the limit of very large samples the fitted values should have normal distributions, but it's not clear what "large" means for nonlinear fits and the meaning might differ depending on the equation. Thus there will be questions about the validity of p-values. If you are willing to assume normality, nls reports standard errors for the parameter values, which you can use to obtain p-values under that assumption. A z-test can provide a rough overview, but it would probably be better to use the approach of Welch's t-test, which allows for different standard errors and degrees of freedom between two parameter estimates. To apply that approach, note that terms like $\frac{s_i^2}{N_i}$ in the formula for Welch's test are equivalent to $SE_i^2$ in the nls output. R code In terms of R code, it was simplest to define a general function for your temperature-response curve: trcFunc <- function(x,z,a,b){((a-x)/(a-z))*((x/z)^(z/b))} then give specific values for the parameters that matched your original equation, to compare your data to the curve: plot(x,y) curve(trcFunc(x,25,35,10),add=TRUE) For fitting, I used the nls function, for example for $z$ alone Zfit <- nls(y~trcFunc(x,z,35,10),start=list(z=30)) or for all 3 parameter values ZABfit <- nls(y~trcFunc(x,z,a,b),start=list(z=30,a=35,b=10)) Get the fitted parameter values with ZABfit Nonlinear regression model model: y ~ trcFunc(x, z, a, b) data: parent.frame() z a b 33.98 36.74 17.84 residual sum-of-squares: 1.228 Number of iterations to convergence: 5 Achieved convergence tolerance: 1.35e-06 and compare data and curve: plot(x,y,main="fit z, a, b") curve(trcFunc(x,33.98,36.74,17.84),add=TRUE) New form for relation; comparing fits With the new general form for the relation of $y$ to $x$ in an edit to the OP, a new general function for fitting is defined as: newFunc <- function(x,Topt,Tmax,Ymax){Ymax*((Tmax-x)/(Tmax-Topt))*(x/Topt)^(Topt/(Tmax-Topt))} For comparing two experiments, take expt1 as the data at the beginning of the question and expt2 as the second data set (x2,y2) toward the end, and construct a pooled data frame as suggested above. Then the fit ignoring the differences between experiments is: fitPool <- nls(y~newFunc(x,Topt,Tmax,Ymax),data=newDF,start=list(Topt=25,Tmax=35,Ymax=2.5)) and that allowing separate parameter values for the two experiments is: fitSeparate <- nls(y~newFunc(x,Topt[expt],Tmax[expt],Ymax[expt]),data=newDF,start=list(Topt=c(25,25),Tmax=c(35,35),Ymax=c(2.5,2.5))) The pooled and separate fits are not significantly different: > anova(fitPool,fitSeparate) Analysis of Variance Table Model 1: y ~ newFunc(x, Topt, Tmax, Ymax) Model 2: y ~ newFunc(x, Topt[expt], Tmax[expt], Ymax[expt]) Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F) 1 19 1.9215 2 16 1.4410 3 0.48046 1.7782 0.1918 Warning on choice of starting values Note that, as can happen in non-linear curve fitting, what you get as the "best" fit can depend on what you provide as an initial guess for the parameter values. With your data, if I provided an initial guess of 26 for $z$ and fixed values of 35 and 10 for $a$ and $b$: Zfit26start <- nls(y~trcFunc(x,z,35,10),start=list(z=26)) the value returned for $z$ is 13.1,which doesn't fit very well at all: This happened because the program wasn't set up to evaluate an entire range of $z$ values and got stuck in what's called a "local optimum" when it started searching from $z=26$. If I tried starting values of $z$ from 20 to 25 then the nls program returned an error: Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model while starting values of 19 or less gave the poorly fitting estimate of 13.1 for $z$. With a non-linear curve fit you can't count on getting the "global" optimum without doing a lot of exploration.
Fitting known equation to data
Fitting data to an equation without free parameters First, let's clarify what it means "to see how well my data fits to the equation" when you have a fixed equation as in your original question. You h
Fitting known equation to data Fitting data to an equation without free parameters First, let's clarify what it means "to see how well my data fits to the equation" when you have a fixed equation as in your original question. You have data on $x$ and $y$, and your equation: $$y=(3.5-(x/10))(x/25)^{5/2}$$ has no free parameters. Here's a plot; data points are circles, the equation a solid curve: So to answer your original question, your data don't fit that equation very well. Fitting parameters of an equation to match data Second, "fitting an equation" generally means having a general form of a relation between $y$ and $x$ in mind, but the details of the form depend on some additional unknown parameters of the equation. "Fitting" then means using the data to estimate the values of the parameters that best match the data, say by minimizing the sum of the squares of the discrepancies between the curve and the data. That is what's implicit in the form of the equation in your comment. (I corrected an apparently missing parenthesis so that it matches your original parameter-free equation at $z=25$): $$y = \frac{35-x}{35-z}\left(\frac{x}{z}\right)^{(z/10)}$$ Now there is something to "fit": find the value of $z$ that comes closest to your data. The simplest R function to do this is nls. (The R code I used is at the end of the answer.) The best fit to your $x$ and $y$ data is provided by a $z$ value of 33.1, not the value of 25 that would match your first parameter-free equation. It comes closer, but doesn't do very well, either, substantially below most of the true values: It looks like your equation might have an even more general form, like: $$y = \frac{a-x}{a-z}\left(\frac{x}{z}\right)^{(z/b)}$$ where $z$, $a$ and $b$ are parameters whose values might be estimated from the data. With that more general form, you can come fairly close to your data, at $z=34.0$, $a=36.7$, and $b=17.8$: Dangers in fitting equations Third, you must be very careful if you head down this fitting path. As John von Neumann allegedly said, "With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." Overfitting is a serious temptation when you start playing with data. In a case like yours you have to think about what the parameters might mean in the real world. It seems that there are competing processes that lead to a peak in growth rate ($y$) at a certain temperature ($x$), and if the parameters $z$, $a$ and $b$ have definite meanings in terms of those competing processes then you might be justified in doing this type of fit. You might, say, learn something about how those processes differ from one strain of bacteria to another. But if such parameters (or the fixed values in your original equation) were simply chosen by someone to make some earlier set of data fit a particular curve then you are headed for big trouble. Comparing fits to different data sets If you want to compare the parameter values fitted to two different data sets, it's best to start by examining whether the overall fits differ between the data sets. There is a "useful and rather easily overlooked" way to do this with nls as Peter Dalgaard put it in a recent answer on R-help. (It can be found at the very bottom of the nls help page.) Instead of working with separate vectors of $x$ and $y$ values from different experiments, construct a pooled data frame containing all the data. Each row should contain an $x$ value, the associated observed $y$ value, and a factor variable indicating the specific experiment. (Make sure the experiments are coded as factors, not as numbers.) nls then allows you to fit different sets of parameter values to different experiments. Instead of specifying general parameters like Topt in your call, you can subscript the parameters by experiment, e.g. Topt[expt], where "expt" is the name of the factor distinguishing experiments. Thus you can use anova to compare a fit to all the data, ignoring individual experiments, against a fit that allows different parameter values for different experiments. If these fits aren't statistically distinguishable, then you shouldn't be looking at differences of individual fitted parameter values among experiments. There's an example below where I present R code. If the fits do differ, then you can consider comparing fitted parameter values. In the limit of very large samples the fitted values should have normal distributions, but it's not clear what "large" means for nonlinear fits and the meaning might differ depending on the equation. Thus there will be questions about the validity of p-values. If you are willing to assume normality, nls reports standard errors for the parameter values, which you can use to obtain p-values under that assumption. A z-test can provide a rough overview, but it would probably be better to use the approach of Welch's t-test, which allows for different standard errors and degrees of freedom between two parameter estimates. To apply that approach, note that terms like $\frac{s_i^2}{N_i}$ in the formula for Welch's test are equivalent to $SE_i^2$ in the nls output. R code In terms of R code, it was simplest to define a general function for your temperature-response curve: trcFunc <- function(x,z,a,b){((a-x)/(a-z))*((x/z)^(z/b))} then give specific values for the parameters that matched your original equation, to compare your data to the curve: plot(x,y) curve(trcFunc(x,25,35,10),add=TRUE) For fitting, I used the nls function, for example for $z$ alone Zfit <- nls(y~trcFunc(x,z,35,10),start=list(z=30)) or for all 3 parameter values ZABfit <- nls(y~trcFunc(x,z,a,b),start=list(z=30,a=35,b=10)) Get the fitted parameter values with ZABfit Nonlinear regression model model: y ~ trcFunc(x, z, a, b) data: parent.frame() z a b 33.98 36.74 17.84 residual sum-of-squares: 1.228 Number of iterations to convergence: 5 Achieved convergence tolerance: 1.35e-06 and compare data and curve: plot(x,y,main="fit z, a, b") curve(trcFunc(x,33.98,36.74,17.84),add=TRUE) New form for relation; comparing fits With the new general form for the relation of $y$ to $x$ in an edit to the OP, a new general function for fitting is defined as: newFunc <- function(x,Topt,Tmax,Ymax){Ymax*((Tmax-x)/(Tmax-Topt))*(x/Topt)^(Topt/(Tmax-Topt))} For comparing two experiments, take expt1 as the data at the beginning of the question and expt2 as the second data set (x2,y2) toward the end, and construct a pooled data frame as suggested above. Then the fit ignoring the differences between experiments is: fitPool <- nls(y~newFunc(x,Topt,Tmax,Ymax),data=newDF,start=list(Topt=25,Tmax=35,Ymax=2.5)) and that allowing separate parameter values for the two experiments is: fitSeparate <- nls(y~newFunc(x,Topt[expt],Tmax[expt],Ymax[expt]),data=newDF,start=list(Topt=c(25,25),Tmax=c(35,35),Ymax=c(2.5,2.5))) The pooled and separate fits are not significantly different: > anova(fitPool,fitSeparate) Analysis of Variance Table Model 1: y ~ newFunc(x, Topt, Tmax, Ymax) Model 2: y ~ newFunc(x, Topt[expt], Tmax[expt], Ymax[expt]) Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F) 1 19 1.9215 2 16 1.4410 3 0.48046 1.7782 0.1918 Warning on choice of starting values Note that, as can happen in non-linear curve fitting, what you get as the "best" fit can depend on what you provide as an initial guess for the parameter values. With your data, if I provided an initial guess of 26 for $z$ and fixed values of 35 and 10 for $a$ and $b$: Zfit26start <- nls(y~trcFunc(x,z,35,10),start=list(z=26)) the value returned for $z$ is 13.1,which doesn't fit very well at all: This happened because the program wasn't set up to evaluate an entire range of $z$ values and got stuck in what's called a "local optimum" when it started searching from $z=26$. If I tried starting values of $z$ from 20 to 25 then the nls program returned an error: Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model while starting values of 19 or less gave the poorly fitting estimate of 13.1 for $z$. With a non-linear curve fit you can't count on getting the "global" optimum without doing a lot of exploration.
Fitting known equation to data Fitting data to an equation without free parameters First, let's clarify what it means "to see how well my data fits to the equation" when you have a fixed equation as in your original question. You h
43,821
What does the term "Estimation error" mean?
A common decomposition of the error incurred when forming a predictive model is into three pieces. 1) Bayes Error: Even the best predictor will sometimes be wrong. Imagine predicting height based on gender. If you had the best predictor available you would still incur error because height does not depend solely on gender. The best predictor is typically called the Bayes predictor. 2) Approximation Error: When forming predictive models, because we want a tractable problem, and because we do not want to over-fit to the data (see 3), we restrict our set of models to some family. For example, in ordinary least squares regression we typically restrict ourselves to a linear model with normal noise which has fixed variance. If the nature of the data generating mechanism does not follow these rules, even the best predictor in this family to which we've restricted ourselves will have more error than the Bayes predictor. 3) Estimation Error: Once we've restricted ourselves to some family of predictors, we must use our data to pick one predictor from that family. What if we do not choose the right one? Then we incur more error. To be clear, I am not referring to picking the wrong predictor by accident, but rather by statistical inference on a limited set of data. One of the most fundamental issues in machine learning is the interplay between approximation error and estimation error. As we enlarge our family of predictors our approximation error monotonically decreases, as we are able to capture more complex relationships. However, as our family of predictors increases, our estimation error increases as we over-fit more. An extreme example of this is fitting a polynomial model to scalar data $x_i$, $y_i$. Imagine that the data was generated by some cubic polynomial plus error. Now suppose we increase the maximum degree in our polynomial $d = 0, 1, 2, 3, \dots$. The first prediction will be the sample mean, lots of approximation error, little estimation error (but still some as this will most likely not be the true mean). As we increase $d$ we are trading approximation error for estimation error. Once we hit $d=3$ we will probably make our best predictions, after all, we have all of the flexibility needed to produce the Bayes predictor, so we are only limited by the limited size of our data. Eventually, as we increase $d$ we will have no error on our training set at all, and our data will have cooked up some higher order relations that don't exist at all.
What does the term "Estimation error" mean?
A common decomposition of the error incurred when forming a predictive model is into three pieces. 1) Bayes Error: Even the best predictor will sometimes be wrong. Imagine predicting height based o
What does the term "Estimation error" mean? A common decomposition of the error incurred when forming a predictive model is into three pieces. 1) Bayes Error: Even the best predictor will sometimes be wrong. Imagine predicting height based on gender. If you had the best predictor available you would still incur error because height does not depend solely on gender. The best predictor is typically called the Bayes predictor. 2) Approximation Error: When forming predictive models, because we want a tractable problem, and because we do not want to over-fit to the data (see 3), we restrict our set of models to some family. For example, in ordinary least squares regression we typically restrict ourselves to a linear model with normal noise which has fixed variance. If the nature of the data generating mechanism does not follow these rules, even the best predictor in this family to which we've restricted ourselves will have more error than the Bayes predictor. 3) Estimation Error: Once we've restricted ourselves to some family of predictors, we must use our data to pick one predictor from that family. What if we do not choose the right one? Then we incur more error. To be clear, I am not referring to picking the wrong predictor by accident, but rather by statistical inference on a limited set of data. One of the most fundamental issues in machine learning is the interplay between approximation error and estimation error. As we enlarge our family of predictors our approximation error monotonically decreases, as we are able to capture more complex relationships. However, as our family of predictors increases, our estimation error increases as we over-fit more. An extreme example of this is fitting a polynomial model to scalar data $x_i$, $y_i$. Imagine that the data was generated by some cubic polynomial plus error. Now suppose we increase the maximum degree in our polynomial $d = 0, 1, 2, 3, \dots$. The first prediction will be the sample mean, lots of approximation error, little estimation error (but still some as this will most likely not be the true mean). As we increase $d$ we are trading approximation error for estimation error. Once we hit $d=3$ we will probably make our best predictions, after all, we have all of the flexibility needed to produce the Bayes predictor, so we are only limited by the limited size of our data. Eventually, as we increase $d$ we will have no error on our training set at all, and our data will have cooked up some higher order relations that don't exist at all.
What does the term "Estimation error" mean? A common decomposition of the error incurred when forming a predictive model is into three pieces. 1) Bayes Error: Even the best predictor will sometimes be wrong. Imagine predicting height based o
43,822
What does the term "Estimation error" mean?
Found this on a research paper: hope it helps.
What does the term "Estimation error" mean?
Found this on a research paper: hope it helps.
What does the term "Estimation error" mean? Found this on a research paper: hope it helps.
What does the term "Estimation error" mean? Found this on a research paper: hope it helps.
43,823
What does the term "Estimation error" mean?
Let $F$ be a family of functions, $f^\prime$ is the best function given training dataset $D_n$, $R(f)$ be a function that give the estimation of loss of a given function $f$. $R^*$ is the minimum statistical risk (true risk) for all functions (including but not limited to those in $F$). Expected Risk - Minimum Statistical Risk = $E[R(f^\prime )] - R^* = (E[R(f^\prime )] -\inf_{f in F} R(f)) + (\inf_{f \in F} R(f) - R^*)$ = Estimation error + Approximation Error Or in other words, estimation error estimates how good is the algorithm that chooses $f$ from $F$ given training dataset, approximation error estimates how good the function family is.
What does the term "Estimation error" mean?
Let $F$ be a family of functions, $f^\prime$ is the best function given training dataset $D_n$, $R(f)$ be a function that give the estimation of loss of a given function $f$. $R^*$ is the minimum stat
What does the term "Estimation error" mean? Let $F$ be a family of functions, $f^\prime$ is the best function given training dataset $D_n$, $R(f)$ be a function that give the estimation of loss of a given function $f$. $R^*$ is the minimum statistical risk (true risk) for all functions (including but not limited to those in $F$). Expected Risk - Minimum Statistical Risk = $E[R(f^\prime )] - R^* = (E[R(f^\prime )] -\inf_{f in F} R(f)) + (\inf_{f \in F} R(f) - R^*)$ = Estimation error + Approximation Error Or in other words, estimation error estimates how good is the algorithm that chooses $f$ from $F$ given training dataset, approximation error estimates how good the function family is.
What does the term "Estimation error" mean? Let $F$ be a family of functions, $f^\prime$ is the best function given training dataset $D_n$, $R(f)$ be a function that give the estimation of loss of a given function $f$. $R^*$ is the minimum stat
43,824
What does the term "Estimation error" mean?
The intuition is this: imagine you have to listen to what someone's saying and transcribe it. If you're sitting in a quite room with a person it's much easier to do than in a night club where music is blasting. The person is saying the same thing in the same voice, but it's harder to catch what he's saying because of the noise in the latter case. Now if you are wearing the headphones and the person is talking into the noise cancelling microphones, that's a different story. In fact you might get the same error rate in transcribing the speech in both an isolated room and a nightclub depending on the equipment used. That's what estimation error is: you won't get every word the person is saying correctly because of the combination of interference of the noise in data and the estimation method. A "better" estimation method may allow you to eliminate a lot of noise. You want less noise in data but you also want good estimation methods.
What does the term "Estimation error" mean?
The intuition is this: imagine you have to listen to what someone's saying and transcribe it. If you're sitting in a quite room with a person it's much easier to do than in a night club where music is
What does the term "Estimation error" mean? The intuition is this: imagine you have to listen to what someone's saying and transcribe it. If you're sitting in a quite room with a person it's much easier to do than in a night club where music is blasting. The person is saying the same thing in the same voice, but it's harder to catch what he's saying because of the noise in the latter case. Now if you are wearing the headphones and the person is talking into the noise cancelling microphones, that's a different story. In fact you might get the same error rate in transcribing the speech in both an isolated room and a nightclub depending on the equipment used. That's what estimation error is: you won't get every word the person is saying correctly because of the combination of interference of the noise in data and the estimation method. A "better" estimation method may allow you to eliminate a lot of noise. You want less noise in data but you also want good estimation methods.
What does the term "Estimation error" mean? The intuition is this: imagine you have to listen to what someone's saying and transcribe it. If you're sitting in a quite room with a person it's much easier to do than in a night club where music is
43,825
Is winning a soccer match independent of previous wins\losses?
It is often the case in sports analytics that people ask questions about more ethereal concepts like momentum, clutch, or home-field advantage. At the surface it would sound silly to say that these things don't exist. However, whether or not they exist is a separate question from whether or not we can meaningfully use them in any sort of predictive analysis. Sometimes it takes so much data to separate the signal from the noise that the signal is mostly gone by the time it can be detected (this is largely, but not entirely, the case with clutch hitting in Major League Baseball for instance). Home-field advantage, on the other hand, is quite a significant predictor over a range of sports (often at least partially due to subconscious biases in officials). In the case of successive soccer matches, since the players are human beings with memory, of course matches will not be completely independent, but I don't think that's a very interesting question to ask. I think it's more interesting to wonder what meaningful predictive value might be found. This question is basically a variant of the so-called "hot hand effect." That is, does success in the recent past lead to more success in the future (after controlling for quality of teams, etc.)? I can't speak specifically about soccer, but this has been looked at numerous times across various sports (perhaps most notably in free-throw shooting in basketball where conditions are more homogeneous and outside forces are minimized). Typically any tiny effect that might be found in these studies tends to be too small to do much with. Perhaps soccer is different, but I wouldn't bet on it. If you wanted to investigate for yourself, you'd want to make sure you account for the skill and health of each team. If Team A won yesterday, I'd guess they are more likely to win tomorrow as well. This isn't because of a memory but because the knowledge that Team A won increases our belief that they are an above-average, healthy team. Also, there might be a fair amount of non-randomness in scheduling that you might need to account for. In Major League Baseball for instance, a large number of very good teams happened to be clustered on the East Coast, and teams from the West Coast tend to have their games against them clustered together. What might at the surface appear to be the team having a memory of their losses could just be a scheduling artifact.
Is winning a soccer match independent of previous wins\losses?
It is often the case in sports analytics that people ask questions about more ethereal concepts like momentum, clutch, or home-field advantage. At the surface it would sound silly to say that these t
Is winning a soccer match independent of previous wins\losses? It is often the case in sports analytics that people ask questions about more ethereal concepts like momentum, clutch, or home-field advantage. At the surface it would sound silly to say that these things don't exist. However, whether or not they exist is a separate question from whether or not we can meaningfully use them in any sort of predictive analysis. Sometimes it takes so much data to separate the signal from the noise that the signal is mostly gone by the time it can be detected (this is largely, but not entirely, the case with clutch hitting in Major League Baseball for instance). Home-field advantage, on the other hand, is quite a significant predictor over a range of sports (often at least partially due to subconscious biases in officials). In the case of successive soccer matches, since the players are human beings with memory, of course matches will not be completely independent, but I don't think that's a very interesting question to ask. I think it's more interesting to wonder what meaningful predictive value might be found. This question is basically a variant of the so-called "hot hand effect." That is, does success in the recent past lead to more success in the future (after controlling for quality of teams, etc.)? I can't speak specifically about soccer, but this has been looked at numerous times across various sports (perhaps most notably in free-throw shooting in basketball where conditions are more homogeneous and outside forces are minimized). Typically any tiny effect that might be found in these studies tends to be too small to do much with. Perhaps soccer is different, but I wouldn't bet on it. If you wanted to investigate for yourself, you'd want to make sure you account for the skill and health of each team. If Team A won yesterday, I'd guess they are more likely to win tomorrow as well. This isn't because of a memory but because the knowledge that Team A won increases our belief that they are an above-average, healthy team. Also, there might be a fair amount of non-randomness in scheduling that you might need to account for. In Major League Baseball for instance, a large number of very good teams happened to be clustered on the East Coast, and teams from the West Coast tend to have their games against them clustered together. What might at the surface appear to be the team having a memory of their losses could just be a scheduling artifact.
Is winning a soccer match independent of previous wins\losses? It is often the case in sports analytics that people ask questions about more ethereal concepts like momentum, clutch, or home-field advantage. At the surface it would sound silly to say that these t
43,826
Is winning a soccer match independent of previous wins\losses?
I think most people will agree that successive outcomes of soccer matches (of the same team?!) are not independent of each other. Clearly there are factors, such as injured players, making matches that are close in time dependent. The exact nature of these invisible ties is nearly impossible to state correctly and in particular completely. People very involved in the sport are probably able to make more educated guesses about the outcome of coming events. I don't think you can do anything to ensure independence between the results of soccer matches. Basically nothing on this earth is independent of anything else. True independence only occurs in idealized thought experiments. But the degree of correlation varies greatly. You can begin to control for the most influential factors (injuries, home play, change of players). But this list is infinite, although the effect of the factors on it decreases rapidly. So practically you can control for a large portion of dependencies. The remaining correlations will at some point become too small to detect - they will become empirically zero, but they will never become provably zero. By the way, successive real world roulette outcomes are also dependent on each other. But real world roulette resembles its idealistic counterpart very closely. So without considering any factors, they are very, very independent of each other.
Is winning a soccer match independent of previous wins\losses?
I think most people will agree that successive outcomes of soccer matches (of the same team?!) are not independent of each other. Clearly there are factors, such as injured players, making matches tha
Is winning a soccer match independent of previous wins\losses? I think most people will agree that successive outcomes of soccer matches (of the same team?!) are not independent of each other. Clearly there are factors, such as injured players, making matches that are close in time dependent. The exact nature of these invisible ties is nearly impossible to state correctly and in particular completely. People very involved in the sport are probably able to make more educated guesses about the outcome of coming events. I don't think you can do anything to ensure independence between the results of soccer matches. Basically nothing on this earth is independent of anything else. True independence only occurs in idealized thought experiments. But the degree of correlation varies greatly. You can begin to control for the most influential factors (injuries, home play, change of players). But this list is infinite, although the effect of the factors on it decreases rapidly. So practically you can control for a large portion of dependencies. The remaining correlations will at some point become too small to detect - they will become empirically zero, but they will never become provably zero. By the way, successive real world roulette outcomes are also dependent on each other. But real world roulette resembles its idealistic counterpart very closely. So without considering any factors, they are very, very independent of each other.
Is winning a soccer match independent of previous wins\losses? I think most people will agree that successive outcomes of soccer matches (of the same team?!) are not independent of each other. Clearly there are factors, such as injured players, making matches tha
43,827
Is winning a soccer match independent of previous wins\losses?
I am a beginner in sports analyses but perhaps a quick empirical example: There is a package "vcd" which contains all soccer games in the German Bundesliga from 1963 to 2008. We can use this dataset to have a look whether we see some (preliminary) evidence for a correlation between the performance across three consecutive games (it is already sorted). For simplicity reasons let us examine only one team (my favorite team Borussia Dortmund or BVB) install.packages("vcd") library("vcd") data("Bundesliga") bvb <- subset(Bundesliga, HomeTeam == "Borussia Dortmund" | AwayTeam == "Borussia Dortmund") bvb$Points <- 0 bvb$Home <- 0 # ... reg <- lm(Points ~ as.factor(Year) + Home + lag_Points + lag_Points2, data = bvb) summary(reg) and we get the following regression results (standard errors are not corrected for autocorrelation or potential intra-season correlation and OLS is probably not a very well-suited estimator for a dependent variable which is either zero, one or three, but this should be only an example): Call: lm(formula = Points ~ as.factor(Year) + Home + lag_Points + lag_Points2, data = bvb) ... Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.414743 0.241077 5.868 5.58e-09 as.factor(Year)1964 0.091076 0.323087 0.282 0.77807 ... as.factor(Year)2008 0.086770 0.312788 0.277 0.78151 Home 0.884637 0.070048 12.629 < 2e-16 lag_Points -0.078543 0.027344 -2.872 0.00414 lag_Points2 -0.052414 0.026662 -1.966 0.04952 We see (as expected) a strong relationship between playing at home and points obtained, and $--$ perhaps surprisingly $--$ negative coefficients for the points in the last two games prior to the current match. This could be just regression towards the mean but it is some anecdotical evidence for possible correlation over time.
Is winning a soccer match independent of previous wins\losses?
I am a beginner in sports analyses but perhaps a quick empirical example: There is a package "vcd" which contains all soccer games in the German Bundesliga from 1963 to 2008. We can use this dataset t
Is winning a soccer match independent of previous wins\losses? I am a beginner in sports analyses but perhaps a quick empirical example: There is a package "vcd" which contains all soccer games in the German Bundesliga from 1963 to 2008. We can use this dataset to have a look whether we see some (preliminary) evidence for a correlation between the performance across three consecutive games (it is already sorted). For simplicity reasons let us examine only one team (my favorite team Borussia Dortmund or BVB) install.packages("vcd") library("vcd") data("Bundesliga") bvb <- subset(Bundesliga, HomeTeam == "Borussia Dortmund" | AwayTeam == "Borussia Dortmund") bvb$Points <- 0 bvb$Home <- 0 # ... reg <- lm(Points ~ as.factor(Year) + Home + lag_Points + lag_Points2, data = bvb) summary(reg) and we get the following regression results (standard errors are not corrected for autocorrelation or potential intra-season correlation and OLS is probably not a very well-suited estimator for a dependent variable which is either zero, one or three, but this should be only an example): Call: lm(formula = Points ~ as.factor(Year) + Home + lag_Points + lag_Points2, data = bvb) ... Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.414743 0.241077 5.868 5.58e-09 as.factor(Year)1964 0.091076 0.323087 0.282 0.77807 ... as.factor(Year)2008 0.086770 0.312788 0.277 0.78151 Home 0.884637 0.070048 12.629 < 2e-16 lag_Points -0.078543 0.027344 -2.872 0.00414 lag_Points2 -0.052414 0.026662 -1.966 0.04952 We see (as expected) a strong relationship between playing at home and points obtained, and $--$ perhaps surprisingly $--$ negative coefficients for the points in the last two games prior to the current match. This could be just regression towards the mean but it is some anecdotical evidence for possible correlation over time.
Is winning a soccer match independent of previous wins\losses? I am a beginner in sports analyses but perhaps a quick empirical example: There is a package "vcd" which contains all soccer games in the German Bundesliga from 1963 to 2008. We can use this dataset t
43,828
Is winning a soccer match independent of previous wins\losses?
I found an article related to this. There the runs test and the chi squared goodness of fit test is used to test if the number of winning streaks is in line with the theoretical expectation under independence. Google: Winning Streaks in Sports and the Misperception of Momentum.
Is winning a soccer match independent of previous wins\losses?
I found an article related to this. There the runs test and the chi squared goodness of fit test is used to test if the number of winning streaks is in line with the theoretical expectation under inde
Is winning a soccer match independent of previous wins\losses? I found an article related to this. There the runs test and the chi squared goodness of fit test is used to test if the number of winning streaks is in line with the theoretical expectation under independence. Google: Winning Streaks in Sports and the Misperception of Momentum.
Is winning a soccer match independent of previous wins\losses? I found an article related to this. There the runs test and the chi squared goodness of fit test is used to test if the number of winning streaks is in line with the theoretical expectation under inde
43,829
Random number generation using t-distribution or laplace distribution
Here's how to do this in Matlab using TINV from that statistics toolbox: %# choose the degree of freedom df = 4; %# note you can also choose an array of df's if necessary %# create a vector of 100,000 uniformly distributed random varibles uni = rand(100000,1); %# look up the corresponding t-values out = tinv(uni,df); With a more recent version of Matlab, you can also simply use TRND to create the random numbers directly. out = trnd(100000,df); Here's the histogram of out EDIT Re:merged question Matlab has no built-in function for drawing numbers from a Laplace distribution. However, there is the function LAPRND from the Matlab File Exchange that provides a well-written implementation.
Random number generation using t-distribution or laplace distribution
Here's how to do this in Matlab using TINV from that statistics toolbox: %# choose the degree of freedom df = 4; %# note you can also choose an array of df's if necessary %# create a vector of 100,00
Random number generation using t-distribution or laplace distribution Here's how to do this in Matlab using TINV from that statistics toolbox: %# choose the degree of freedom df = 4; %# note you can also choose an array of df's if necessary %# create a vector of 100,000 uniformly distributed random varibles uni = rand(100000,1); %# look up the corresponding t-values out = tinv(uni,df); With a more recent version of Matlab, you can also simply use TRND to create the random numbers directly. out = trnd(100000,df); Here's the histogram of out EDIT Re:merged question Matlab has no built-in function for drawing numbers from a Laplace distribution. However, there is the function LAPRND from the Matlab File Exchange that provides a well-written implementation.
Random number generation using t-distribution or laplace distribution Here's how to do this in Matlab using TINV from that statistics toolbox: %# choose the degree of freedom df = 4; %# note you can also choose an array of df's if necessary %# create a vector of 100,00
43,830
Random number generation using t-distribution or laplace distribution
Easy answer: Use R and get n variables for a $t$-distribution with df degrees of freedom by rt(n, df). If you don't use R, maybe you can write what language you use, and others may be able to tell precisely what to do. If you don't use R or another language with a built in random number generator for the $t$-distribution, but you have access to the quantile function, $Q$, for the $t$-distribution and you can generate a uniform random variable $U$ on $[0,1]$ then $Q(U)$ follows a $t$-distribution. Else take a look at this brief section in the Wikipedia page.
Random number generation using t-distribution or laplace distribution
Easy answer: Use R and get n variables for a $t$-distribution with df degrees of freedom by rt(n, df). If you don't use R, maybe you can write what language you use, and others may be able to tell pre
Random number generation using t-distribution or laplace distribution Easy answer: Use R and get n variables for a $t$-distribution with df degrees of freedom by rt(n, df). If you don't use R, maybe you can write what language you use, and others may be able to tell precisely what to do. If you don't use R or another language with a built in random number generator for the $t$-distribution, but you have access to the quantile function, $Q$, for the $t$-distribution and you can generate a uniform random variable $U$ on $[0,1]$ then $Q(U)$ follows a $t$-distribution. Else take a look at this brief section in the Wikipedia page.
Random number generation using t-distribution or laplace distribution Easy answer: Use R and get n variables for a $t$-distribution with df degrees of freedom by rt(n, df). If you don't use R, maybe you can write what language you use, and others may be able to tell pre
43,831
Random number generation using t-distribution or laplace distribution
By looking at the Wikipedia article, I've written a function to generate random variables from the Laplace dsistribution. Here it is: function x = laplacernd(mu,b,sz) %LAPLACERND Generate Laplacian random variables % % x = LAPLACERND(mu,b,sz) generates random variables from a Laplace % distribution having parameters mu and b. sz stands for the size of the % returned random variables. See [1] for Laplace distribution. % % [1] http://en.wikipedia.org/wiki/Laplace_distribution % % by Ismail Ari, 2011 if nargin < 1 % Equal to exponential distribution scaled by 1/2 mu = 0; end if nargin < 2 b = 1; end if nargin < 3 sz = 1; end u = rand(sz) - 0.5; x = mu - b*sign(u) .* log(1-2*abs(u)); And here is a code snippet to use it clc, clear mu = 30; b = 2; sz = [50000 1]; x = laplacernd(mu,b,sz); hist(x,100)
Random number generation using t-distribution or laplace distribution
By looking at the Wikipedia article, I've written a function to generate random variables from the Laplace dsistribution. Here it is: function x = laplacernd(mu,b,sz) %LAPLACERND Generate Laplacian ra
Random number generation using t-distribution or laplace distribution By looking at the Wikipedia article, I've written a function to generate random variables from the Laplace dsistribution. Here it is: function x = laplacernd(mu,b,sz) %LAPLACERND Generate Laplacian random variables % % x = LAPLACERND(mu,b,sz) generates random variables from a Laplace % distribution having parameters mu and b. sz stands for the size of the % returned random variables. See [1] for Laplace distribution. % % [1] http://en.wikipedia.org/wiki/Laplace_distribution % % by Ismail Ari, 2011 if nargin < 1 % Equal to exponential distribution scaled by 1/2 mu = 0; end if nargin < 2 b = 1; end if nargin < 3 sz = 1; end u = rand(sz) - 0.5; x = mu - b*sign(u) .* log(1-2*abs(u)); And here is a code snippet to use it clc, clear mu = 30; b = 2; sz = [50000 1]; x = laplacernd(mu,b,sz); hist(x,100)
Random number generation using t-distribution or laplace distribution By looking at the Wikipedia article, I've written a function to generate random variables from the Laplace dsistribution. Here it is: function x = laplacernd(mu,b,sz) %LAPLACERND Generate Laplacian ra
43,832
Random number generation using t-distribution or laplace distribution
The best (fastest to run, not fastest to code;) free solution I have found in Matlab was to wrap R's MATHLIB_STANDALONE c library with a mex function. This gives you access to R's t-distribution PRNG. One advantage of this approach is that you also can use the same trick to get variates from a non-central t distribution. The second best free solution was to use octave's implementation of trnd. Porting from octave turned out to be more work than wrapping c code for me. For my tastes, using uniform generation via rand and inverting via tinv was much too slow. YMMV.
Random number generation using t-distribution or laplace distribution
The best (fastest to run, not fastest to code;) free solution I have found in Matlab was to wrap R's MATHLIB_STANDALONE c library with a mex function. This gives you access to R's t-distribution PRNG.
Random number generation using t-distribution or laplace distribution The best (fastest to run, not fastest to code;) free solution I have found in Matlab was to wrap R's MATHLIB_STANDALONE c library with a mex function. This gives you access to R's t-distribution PRNG. One advantage of this approach is that you also can use the same trick to get variates from a non-central t distribution. The second best free solution was to use octave's implementation of trnd. Porting from octave turned out to be more work than wrapping c code for me. For my tastes, using uniform generation via rand and inverting via tinv was much too slow. YMMV.
Random number generation using t-distribution or laplace distribution The best (fastest to run, not fastest to code;) free solution I have found in Matlab was to wrap R's MATHLIB_STANDALONE c library with a mex function. This gives you access to R's t-distribution PRNG.
43,833
Random number generation using t-distribution or laplace distribution
You can use the same approach that was described in response to your question about generating random numbers from a t-distribution. First generate uniformly distributed random numbers from (0,1) and then apply the inverse cumulative distribution function of the Laplace distribution, which is given in the Wikipedia article you linked to.
Random number generation using t-distribution or laplace distribution
You can use the same approach that was described in response to your question about generating random numbers from a t-distribution. First generate uniformly distributed random numbers from (0,1) and
Random number generation using t-distribution or laplace distribution You can use the same approach that was described in response to your question about generating random numbers from a t-distribution. First generate uniformly distributed random numbers from (0,1) and then apply the inverse cumulative distribution function of the Laplace distribution, which is given in the Wikipedia article you linked to.
Random number generation using t-distribution or laplace distribution You can use the same approach that was described in response to your question about generating random numbers from a t-distribution. First generate uniformly distributed random numbers from (0,1) and
43,834
Correct formula for MSE
Assuming that the slide is talking about linear regression with one input variable, i.e. $$y_i = \beta_0 + \beta_1 x_i + \varepsilon_i$$, the correct formula for MSE is: $$ \operatorname{MSE} = \frac{1}{n-2} \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 \ . $$ To reiterate, for the specific case of a linear model with only one input variable the denominator must be $n-2$. In the more general case when you have a linear model with $k$ input variables that is: $$ y_i = \beta_0 + \beta_1 x_{1i} + \beta_2 x_{2i} + \dots + \beta_k x_{ki} + \varepsilon_i \ , $$ then the MSE would be: $$ \operatorname{MSE} = \frac{1}{n-(k+1)} \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 \ . $$ I am not aware of any model in which the denominator would be $n$. Usually, the denominator of $n$ is only possible when we know the population parameters $\beta_j$, in which case we are computing the true residual variance not estimating the residual variance.
Correct formula for MSE
Assuming that the slide is talking about linear regression with one input variable, i.e. $$y_i = \beta_0 + \beta_1 x_i + \varepsilon_i$$, the correct formula for MSE is: $$ \operatorname{MSE} = \frac{
Correct formula for MSE Assuming that the slide is talking about linear regression with one input variable, i.e. $$y_i = \beta_0 + \beta_1 x_i + \varepsilon_i$$, the correct formula for MSE is: $$ \operatorname{MSE} = \frac{1}{n-2} \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 \ . $$ To reiterate, for the specific case of a linear model with only one input variable the denominator must be $n-2$. In the more general case when you have a linear model with $k$ input variables that is: $$ y_i = \beta_0 + \beta_1 x_{1i} + \beta_2 x_{2i} + \dots + \beta_k x_{ki} + \varepsilon_i \ , $$ then the MSE would be: $$ \operatorname{MSE} = \frac{1}{n-(k+1)} \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 \ . $$ I am not aware of any model in which the denominator would be $n$. Usually, the denominator of $n$ is only possible when we know the population parameters $\beta_j$, in which case we are computing the true residual variance not estimating the residual variance.
Correct formula for MSE Assuming that the slide is talking about linear regression with one input variable, i.e. $$y_i = \beta_0 + \beta_1 x_i + \varepsilon_i$$, the correct formula for MSE is: $$ \operatorname{MSE} = \frac{
43,835
Correct formula for MSE
Both are correct. As said by blooraven (+1), this is the same kind of correction as in the unbiased estimator for sample variance. The second formula is used with linear regression corrects for the number of degrees of freedom. Notice that the second formula would not make sense in every context. Some models can be used with more features than samples, so the denominator would be zero or negative. In non-parametric models, or even some parametric ones (neural networks), it may be hard to say how many degrees there are and what exactly they are. Because of that in machine learning, to compare different models, you would almost always see the first formula with the denominator that is simply $n$.
Correct formula for MSE
Both are correct. As said by blooraven (+1), this is the same kind of correction as in the unbiased estimator for sample variance. The second formula is used with linear regression corrects for the nu
Correct formula for MSE Both are correct. As said by blooraven (+1), this is the same kind of correction as in the unbiased estimator for sample variance. The second formula is used with linear regression corrects for the number of degrees of freedom. Notice that the second formula would not make sense in every context. Some models can be used with more features than samples, so the denominator would be zero or negative. In non-parametric models, or even some parametric ones (neural networks), it may be hard to say how many degrees there are and what exactly they are. Because of that in machine learning, to compare different models, you would almost always see the first formula with the denominator that is simply $n$.
Correct formula for MSE Both are correct. As said by blooraven (+1), this is the same kind of correction as in the unbiased estimator for sample variance. The second formula is used with linear regression corrects for the nu
43,836
Impose a condition on neural network
A dirt-simple solution is to add a regularization term, so your loss function is $\text{loss} + \lambda \text{ReLU} (i_3 - O)$. This adds a penalty whenever your inequality is violated, so the model will tend to respect the constraint. While this solution is inexact, It will be more challenging to solve this exactly because constrained optimization is not something NN libraries are designed for. Some related solutions: Loss function in machine learning - how to constrain?
Impose a condition on neural network
A dirt-simple solution is to add a regularization term, so your loss function is $\text{loss} + \lambda \text{ReLU} (i_3 - O)$. This adds a penalty whenever your inequality is violated, so the model w
Impose a condition on neural network A dirt-simple solution is to add a regularization term, so your loss function is $\text{loss} + \lambda \text{ReLU} (i_3 - O)$. This adds a penalty whenever your inequality is violated, so the model will tend to respect the constraint. While this solution is inexact, It will be more challenging to solve this exactly because constrained optimization is not something NN libraries are designed for. Some related solutions: Loss function in machine learning - how to constrain?
Impose a condition on neural network A dirt-simple solution is to add a regularization term, so your loss function is $\text{loss} + \lambda \text{ReLU} (i_3 - O)$. This adds a penalty whenever your inequality is violated, so the model w
43,837
Impose a condition on neural network
Could you just let the output be un-constrained, and then postprocess by doing something like $O + i3$? You can even put this directly into your loss function.
Impose a condition on neural network
Could you just let the output be un-constrained, and then postprocess by doing something like $O + i3$? You can even put this directly into your loss function.
Impose a condition on neural network Could you just let the output be un-constrained, and then postprocess by doing something like $O + i3$? You can even put this directly into your loss function.
Impose a condition on neural network Could you just let the output be un-constrained, and then postprocess by doing something like $O + i3$? You can even put this directly into your loss function.
43,838
Impose a condition on neural network
After devoting good time, finally I found how to implement the solution in keras/tensorflow library with the regard to previous useful answers to my question. First if we want to implement a costume keras loss function with some parameters and also accessing to inputs we have to define: def custom_loss(alpha): def loss(data, y_pred): y_true = tf.reshape(data[:, 0], (-1, 1)) input = tf.reshape(data[:, 1], (-1, 1)) diff = K.abs((y_true - y_pred) / K.clip(K.abs(y_true), K.epsilon(), None)) return 100. * K.mean(diff, axis=-1) + K.mean(alpha*tf.keras.activations.relu(input - y_pred)) here I padded inputs into the right side of the output tensor and then inside the function I repacked it to access inputs. here I used mean absolute percentage error as the base loss function and then added desired condition with the aid of alpha parameter as regularization parameter and the Relu function. be aware of using right column of your input data in this function then if we want to build neural network model the following codes has to be used. first we pad input to our output easily as follow: output_train = np.append(y_train, x_train, axis =1) output_valid = np.append(y_valid, x_valid, axis =1) in the compile function: model.compile(loss = custom_loss(alpha=10000)) here I used 10000 as the alpha and it's obvious that can be changed based on the case. now we can fit model on our data. but there is another problem when we want to load the saved model. if we want to load the model we have to use the following code model = keras.models.load_model(model_save_address, custom_objects={'loss': custom_loss(10000)}) now everything is fine and we can run our model and train and test it easily on our data. NOTE: First I thank all people helped me solve the issue. I think its worth noting that before solving the issue despite having the good model that performs well with very low error on my data, in the 50% of the cases my desired condition had been violating and that was a problem for me. but after implementing this solution, only in 0.5% cases the condition wont be satisfied and I hope to find another solution to reduce it furthermore.
Impose a condition on neural network
After devoting good time, finally I found how to implement the solution in keras/tensorflow library with the regard to previous useful answers to my question. First if we want to implement a costume k
Impose a condition on neural network After devoting good time, finally I found how to implement the solution in keras/tensorflow library with the regard to previous useful answers to my question. First if we want to implement a costume keras loss function with some parameters and also accessing to inputs we have to define: def custom_loss(alpha): def loss(data, y_pred): y_true = tf.reshape(data[:, 0], (-1, 1)) input = tf.reshape(data[:, 1], (-1, 1)) diff = K.abs((y_true - y_pred) / K.clip(K.abs(y_true), K.epsilon(), None)) return 100. * K.mean(diff, axis=-1) + K.mean(alpha*tf.keras.activations.relu(input - y_pred)) here I padded inputs into the right side of the output tensor and then inside the function I repacked it to access inputs. here I used mean absolute percentage error as the base loss function and then added desired condition with the aid of alpha parameter as regularization parameter and the Relu function. be aware of using right column of your input data in this function then if we want to build neural network model the following codes has to be used. first we pad input to our output easily as follow: output_train = np.append(y_train, x_train, axis =1) output_valid = np.append(y_valid, x_valid, axis =1) in the compile function: model.compile(loss = custom_loss(alpha=10000)) here I used 10000 as the alpha and it's obvious that can be changed based on the case. now we can fit model on our data. but there is another problem when we want to load the saved model. if we want to load the model we have to use the following code model = keras.models.load_model(model_save_address, custom_objects={'loss': custom_loss(10000)}) now everything is fine and we can run our model and train and test it easily on our data. NOTE: First I thank all people helped me solve the issue. I think its worth noting that before solving the issue despite having the good model that performs well with very low error on my data, in the 50% of the cases my desired condition had been violating and that was a problem for me. but after implementing this solution, only in 0.5% cases the condition wont be satisfied and I hope to find another solution to reduce it furthermore.
Impose a condition on neural network After devoting good time, finally I found how to implement the solution in keras/tensorflow library with the regard to previous useful answers to my question. First if we want to implement a costume k
43,839
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
There are some misconceptions in your question that I need to clear up before getting to the answer. The null hypothesis $H_0$ in a statistical test is always the claim you want to argue against. The alternative hypothesis $H_1$ is the claim you hope to be true. The null and the alternative need to be mutually exclusive (no overlap) collectively exhaustive (partition the parameter space) the equality sign ($=$, $\ge$, or $\le$) almost always appears in the null. So your first test should have $H_0: \mu \le 0$ and $H_1: \mu > 0$. Your second test should have $H_0: \mu = 0$ and $H_1: \mu \ne 0$. The p-value is the probability of seeing the observed mean (or something even more extreme) if the null hypothesis was true. Then we apply the rule “reject the null when the p-value is small.” The basic idea is that if seeing a big mean is unlikely if the null was true, the null is likely to be false. There is a slight complication in the first test. The null is a composite one: it's an interval rather than a single point. So we will have to calculate the probability when $\mu=0$, then when $\mu =-1$, and also everywhere else below zero, since all those points are inside the null. But that’s an infinite number of points! What we do instead is to calculate the probability at the most extreme point of the null hypothesis, closest to alternative parameter space, which is at $\mu = 0$. This means that the p-value is exact only for $\mu=0$. If $\mu<0$, then our p-value is just a conservative bound on the type I error rate (the error being finding a negative effect when there is none). In other words, if the true effect is negative, then finding a false positive result is even less likely than 5% (or whatever value of $\alpha$ your question requires). This is also the reason why statistics packages will express the one-sided null as $\mu=0$ rather than $\mu \le 0$, which is technically correct, but confusing notation. Now for your question. For both one-sided and two-sided tests, we calculate the p-value with $\mu=0$. Suppose you observe a mean of $u>0$. With a two-sided test, you need to calculate $\Pr(\bar X \ge u \vert \mu=0)$ and $\Pr(\bar X \le -u \vert \mu=0)$, since both kinds of extreme values constitute evidence against that null. With a one-sided test, seeing a mean that’s less than $-k$ doesn’t count as evidence against the null, so we only calculate $\Pr(\bar X \ge u \vert \mu=0)$. This is why the p-value is larger in the two-sided case, which means it’s easier to reject in the one-sided case. Another way to put this is that a two-sided test is just two one-sided tests cobbled together (a superiority and an inferiority one).
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
There are some misconceptions in your question that I need to clear up before getting to the answer. The null hypothesis $H_0$ in a statistical test is always the claim you want to argue against. The
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? There are some misconceptions in your question that I need to clear up before getting to the answer. The null hypothesis $H_0$ in a statistical test is always the claim you want to argue against. The alternative hypothesis $H_1$ is the claim you hope to be true. The null and the alternative need to be mutually exclusive (no overlap) collectively exhaustive (partition the parameter space) the equality sign ($=$, $\ge$, or $\le$) almost always appears in the null. So your first test should have $H_0: \mu \le 0$ and $H_1: \mu > 0$. Your second test should have $H_0: \mu = 0$ and $H_1: \mu \ne 0$. The p-value is the probability of seeing the observed mean (or something even more extreme) if the null hypothesis was true. Then we apply the rule “reject the null when the p-value is small.” The basic idea is that if seeing a big mean is unlikely if the null was true, the null is likely to be false. There is a slight complication in the first test. The null is a composite one: it's an interval rather than a single point. So we will have to calculate the probability when $\mu=0$, then when $\mu =-1$, and also everywhere else below zero, since all those points are inside the null. But that’s an infinite number of points! What we do instead is to calculate the probability at the most extreme point of the null hypothesis, closest to alternative parameter space, which is at $\mu = 0$. This means that the p-value is exact only for $\mu=0$. If $\mu<0$, then our p-value is just a conservative bound on the type I error rate (the error being finding a negative effect when there is none). In other words, if the true effect is negative, then finding a false positive result is even less likely than 5% (or whatever value of $\alpha$ your question requires). This is also the reason why statistics packages will express the one-sided null as $\mu=0$ rather than $\mu \le 0$, which is technically correct, but confusing notation. Now for your question. For both one-sided and two-sided tests, we calculate the p-value with $\mu=0$. Suppose you observe a mean of $u>0$. With a two-sided test, you need to calculate $\Pr(\bar X \ge u \vert \mu=0)$ and $\Pr(\bar X \le -u \vert \mu=0)$, since both kinds of extreme values constitute evidence against that null. With a one-sided test, seeing a mean that’s less than $-k$ doesn’t count as evidence against the null, so we only calculate $\Pr(\bar X \ge u \vert \mu=0)$. This is why the p-value is larger in the two-sided case, which means it’s easier to reject in the one-sided case. Another way to put this is that a two-sided test is just two one-sided tests cobbled together (a superiority and an inferiority one).
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? There are some misconceptions in your question that I need to clear up before getting to the answer. The null hypothesis $H_0$ in a statistical test is always the claim you want to argue against. The
43,840
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
the data may strongly support $\mu > 0$, but does not constitute sufficient evidence for $\mu \neq 0$ I don't know if this reasoning helps or if it is 100% correct... You accept to be wrong $\alpha$-percent of the times in hypothetical repeats of the test; for example, you accept to be wrong 5% of the times in rejecting the null. In a two-tailed test you spread this 5% in the left-tail and in the right-tail of the test distribution. In the one-tailed test, you still accept the be wrong with the same frequency (say, 5%) but always in the same direction so you put all the 5% in the same tail. In fact, I wouldn't say that in the one-tailed test it is easier to reject, but rather that you need less extreme values. You need less extreme values compared to the two-tailed test in order to keep the overall error rate at the same $\alpha$ level. Your trial metaphor is interesting but perhaps is not appropriate because A killed B is not more (or less) extreme than A killed B by stabbing.
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
the data may strongly support $\mu > 0$, but does not constitute sufficient evidence for $\mu \neq 0$ I don't know if this reasoning helps or if it is 100% correct... You accept to be wrong $\alpha$-
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? the data may strongly support $\mu > 0$, but does not constitute sufficient evidence for $\mu \neq 0$ I don't know if this reasoning helps or if it is 100% correct... You accept to be wrong $\alpha$-percent of the times in hypothetical repeats of the test; for example, you accept to be wrong 5% of the times in rejecting the null. In a two-tailed test you spread this 5% in the left-tail and in the right-tail of the test distribution. In the one-tailed test, you still accept the be wrong with the same frequency (say, 5%) but always in the same direction so you put all the 5% in the same tail. In fact, I wouldn't say that in the one-tailed test it is easier to reject, but rather that you need less extreme values. You need less extreme values compared to the two-tailed test in order to keep the overall error rate at the same $\alpha$ level. Your trial metaphor is interesting but perhaps is not appropriate because A killed B is not more (or less) extreme than A killed B by stabbing.
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? the data may strongly support $\mu > 0$, but does not constitute sufficient evidence for $\mu \neq 0$ I don't know if this reasoning helps or if it is 100% correct... You accept to be wrong $\alpha$-
43,841
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
Hypothesis testing: why $\mu > 0$ (or even $\mu > \epsilon$) "seems easier” to substantiate than $\mu \neq 0$? It seems easier because the one-sided t-test and two-sided t-test have different sensitivity for different values. The two-sided t-test has sensitivity split for both positive and negative values. The one-sided t-test has sensitivity for only the positive or only the negative values, and because of that will be 'easier' in substantiating a result (but only for a single side) Below is a graph of the sensitivity or power for the two tests as a function of the true mean of the distribution. (Power is the probability that an observation is a positive result). You can see that the one-sided test is not everywhere 'easier' than the two-sided test. It is only 'easier' for the positive values. Also note that the tests have an equal $5\%$ probability/frequency of a positive result when in reality the effect is negative (when the true mean is equal to zero). So if the true mean is equal to zero then the two hypothesis tests are equally 'easy' in making a false claim of substantiating an alternative hypothesis (like $\mu \neq 0$ or $\mu > 0$). But they are still different. They will make these (false) claims for different observations and for a specific observation they are not equally 'easy'. This can occur because there is no unique way to compute p-values and associated hypothesis tests. The p-values based on different methods can be different for a particular observation but on average (for all possible observations) they will be equal. Below you see a simulation of $10 000$ samples of size $n=5$ drawn from a standard normal distribution. We plot the observed (unbiased) sample standard deviation $s$ and the observed sample mean. Along with it we plot the rejected sampled based on a two-sided t-test and a one-sided t-test. The amount of rejected samples is in both cases the same, namely $5\%$. But, the rejected samples are different for the cases. The one-sided t-test is more sensitive to values on one side. The two-sided t-test splits the sensitivity to two sides. So again, that is why the one-sided test may seem more 'easy' but that is because of the choice to place the sensitivity in a different region. It is only 'easier' for that region. So it may occur that you reject $H_0: \mu \leq 0$ with an alternative hypothesis $H_a: \mu > 0$, but you can't reject with the same data $H_0: \mu = 0$ with an alternative hypothesis $H_a: \neq 0$. When such situation occurs then it is seemingly a paradox. But, It is not purely the data that rejected the $H_0$. It is also your choice and it is also the alternative hypothesis that 'helps' rejecting the null hypothesis. The same hypothesis, with the same data, can be or not be rejected, depending on your arbitrary rejection criteria. Other examples (from this website) were different tests reject a hypothesis for different observations are: ANOVA with F-test vs Tukey's range test. The ANOVA test and Tukey's procedure test the same null hypothesis 'equality of means' but have different p-values for different observations because they relate to different statistics and have sensitivity in different regions. One looks at the largest difference between samples, the other at the variance. Mann-Whitney U test versus t-test can be used to test equality of two means. They have different p-values because the one uses the t-statistic based on the ratio of the difference in the means and the standard deviation, the other computes a statistic based on how often a value in the one sample is larger than a sample in the other sample. Fisher exact test with pooled versus non-pooled data. In that question the Fisher exact test had a surprising behaviour in the power being different when the data was split into groups. But, effectively this was due to using different regions where the tests are sensitive.
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$?
Hypothesis testing: why $\mu > 0$ (or even $\mu > \epsilon$) "seems easier” to substantiate than $\mu \neq 0$? It seems easier because the one-sided t-test and two-sided t-test have different sensiti
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? Hypothesis testing: why $\mu > 0$ (or even $\mu > \epsilon$) "seems easier” to substantiate than $\mu \neq 0$? It seems easier because the one-sided t-test and two-sided t-test have different sensitivity for different values. The two-sided t-test has sensitivity split for both positive and negative values. The one-sided t-test has sensitivity for only the positive or only the negative values, and because of that will be 'easier' in substantiating a result (but only for a single side) Below is a graph of the sensitivity or power for the two tests as a function of the true mean of the distribution. (Power is the probability that an observation is a positive result). You can see that the one-sided test is not everywhere 'easier' than the two-sided test. It is only 'easier' for the positive values. Also note that the tests have an equal $5\%$ probability/frequency of a positive result when in reality the effect is negative (when the true mean is equal to zero). So if the true mean is equal to zero then the two hypothesis tests are equally 'easy' in making a false claim of substantiating an alternative hypothesis (like $\mu \neq 0$ or $\mu > 0$). But they are still different. They will make these (false) claims for different observations and for a specific observation they are not equally 'easy'. This can occur because there is no unique way to compute p-values and associated hypothesis tests. The p-values based on different methods can be different for a particular observation but on average (for all possible observations) they will be equal. Below you see a simulation of $10 000$ samples of size $n=5$ drawn from a standard normal distribution. We plot the observed (unbiased) sample standard deviation $s$ and the observed sample mean. Along with it we plot the rejected sampled based on a two-sided t-test and a one-sided t-test. The amount of rejected samples is in both cases the same, namely $5\%$. But, the rejected samples are different for the cases. The one-sided t-test is more sensitive to values on one side. The two-sided t-test splits the sensitivity to two sides. So again, that is why the one-sided test may seem more 'easy' but that is because of the choice to place the sensitivity in a different region. It is only 'easier' for that region. So it may occur that you reject $H_0: \mu \leq 0$ with an alternative hypothesis $H_a: \mu > 0$, but you can't reject with the same data $H_0: \mu = 0$ with an alternative hypothesis $H_a: \neq 0$. When such situation occurs then it is seemingly a paradox. But, It is not purely the data that rejected the $H_0$. It is also your choice and it is also the alternative hypothesis that 'helps' rejecting the null hypothesis. The same hypothesis, with the same data, can be or not be rejected, depending on your arbitrary rejection criteria. Other examples (from this website) were different tests reject a hypothesis for different observations are: ANOVA with F-test vs Tukey's range test. The ANOVA test and Tukey's procedure test the same null hypothesis 'equality of means' but have different p-values for different observations because they relate to different statistics and have sensitivity in different regions. One looks at the largest difference between samples, the other at the variance. Mann-Whitney U test versus t-test can be used to test equality of two means. They have different p-values because the one uses the t-statistic based on the ratio of the difference in the means and the standard deviation, the other computes a statistic based on how often a value in the one sample is larger than a sample in the other sample. Fisher exact test with pooled versus non-pooled data. In that question the Fisher exact test had a surprising behaviour in the power being different when the data was split into groups. But, effectively this was due to using different regions where the tests are sensitive.
Why does $\mu > 0$ (or even $\mu > \epsilon$) "seem easier” to substantiate than $\mu \neq 0$? Hypothesis testing: why $\mu > 0$ (or even $\mu > \epsilon$) "seems easier” to substantiate than $\mu \neq 0$? It seems easier because the one-sided t-test and two-sided t-test have different sensiti
43,842
CLT may fail under this condition?
The central limit theorem applies to infinite sequences of random variables $X_1,X_2,X_3,...$ rather than finite vectors of random variables. This is evident in the fact that we take the limit $n \rightarrow \infty$ in these theorems. So what this means is that these problems deal implicitly with an infinite population (or "superpopulation" if you prefer). When we take this kind of limit, the sample size never goes close to or equal to the population size, since the latter is infinite. Regardless of how big $n$ gets in the limiting analysis, it is still finite and so it is never close to the population size. Now, it is of course possible to look at the behaviour of the sample mean for a finite population of size $N \in \mathbb{N}$. In this case, if you take the sample size $n$ up to the population size $N$ then the sample mean will equal the population mean exactly. If your analysis conditions on knowledge of the population mean (or treats this as a fixed constant) then the distribution of the sample mean is a point-mass distribution on the population mean value. Similarly, if the sample mean is close to the (finite) population mean, then its distribution also will not be bell shaped. (You can think of this like the CLT in reverse; if the number of unsampled datapoints is small then the distribution of the unsampled mean is not well approximated by the normal, and the sample mean is an affine function of this value, so it is also not well approximated by the normal.)
CLT may fail under this condition?
The central limit theorem applies to infinite sequences of random variables $X_1,X_2,X_3,...$ rather than finite vectors of random variables. This is evident in the fact that we take the limit $n \ri
CLT may fail under this condition? The central limit theorem applies to infinite sequences of random variables $X_1,X_2,X_3,...$ rather than finite vectors of random variables. This is evident in the fact that we take the limit $n \rightarrow \infty$ in these theorems. So what this means is that these problems deal implicitly with an infinite population (or "superpopulation" if you prefer). When we take this kind of limit, the sample size never goes close to or equal to the population size, since the latter is infinite. Regardless of how big $n$ gets in the limiting analysis, it is still finite and so it is never close to the population size. Now, it is of course possible to look at the behaviour of the sample mean for a finite population of size $N \in \mathbb{N}$. In this case, if you take the sample size $n$ up to the population size $N$ then the sample mean will equal the population mean exactly. If your analysis conditions on knowledge of the population mean (or treats this as a fixed constant) then the distribution of the sample mean is a point-mass distribution on the population mean value. Similarly, if the sample mean is close to the (finite) population mean, then its distribution also will not be bell shaped. (You can think of this like the CLT in reverse; if the number of unsampled datapoints is small then the distribution of the unsampled mean is not well approximated by the normal, and the sample mean is an affine function of this value, so it is also not well approximated by the normal.)
CLT may fail under this condition? The central limit theorem applies to infinite sequences of random variables $X_1,X_2,X_3,...$ rather than finite vectors of random variables. This is evident in the fact that we take the limit $n \ri
43,843
CLT may fail under this condition?
If you're going to run an asymptotic argument with $n$ close to $N$, you need sequences of finite populations and samples. For each $m=1,2,3,\dots$ suppose you have a population of size $N_m$ and a sample of size $n_m$, with $N_m\geq n_m$ and $n_m\to\infty$. We'll need some assumptions about the populations; we can go back and work out what was needed after the argument We know already (under reasonable assumptions) that if $n_m\to\infty$ we have a Central Limit Theorem, either with $n_m/N_n\to 0$ or with $n_m/N_n\to c\in(0,1)$. If $\mu_m$ is the true finite population mean and $\sigma^2$ is the limit of the true population variances then $$\sqrt{n_m}(\bar X_{n_m}-\mu_m)\stackrel{d}{\to} N(0,\sigma^2)$$ Suppose $n_m$ is really big, so that the number of unsampled individuals does not go to infinity. In that case the CLT does fail. In the extreme case, suppose $n_m=N_m-1$, so that only one individual is not sampled. We could try to get a scaled mean to be Normal in a few ways First, we could try $\sqrt{n_m}(\bar X_{n_m}-\mu_m)$. That doesn't work because there's only one observation's difference between $\bar X_{n_m}$ and $\mu_m$: we get $$\sqrt{n_m}(\bar X_{n_m}-\mu_m)=\sqrt{n_m}\cdot O_p(1/n_m)\stackrel{p}{\to}0$$ We could rescale and try $n_m(\bar X_{n_m}-\mu_m)$. That's of the right order, but it is just equal $X_{n_m}-\mu$, the one unsampled observation centered minus the true mean. Or we could scale by $\sqrt{N_m-n_m}=1$, the square root of the unsampled size, but that goes to zero. Or scale the total to get $$\frac{N_m}{\sqrt{N_m-n_m}}(\bar X_{n_m}-\mu_m)$$ which is again just the unsampled observation minus the mean. If $N_m-n_m$ is bigger than one but bounded, you get the same sort of result: depending on the scaling it blows up, goes to zero, or gives you a finite sum that doesn't converge to Normal. However, if $N_n-n_m\to\infty$ you are good. The unsampled observations are an infinite sum that then does satisfy a CLT, and $$\frac{1}{\sqrt{N_m-n_m}}\left(\sum_{i=1}^{n_m} (X_i-\mu_m)\right)\stackrel{d}{\to}N(0,\sigma^2)$$ so $$\frac{n_m}{\sqrt{N_m-n_m}}\left(\bar X_{n_m}-\mu_m\right)\stackrel{d}{\to}N(0,\sigma^2)$$ It's still true, though, that $\sqrt{n_m}(\bar X_{n_m}-\mu_m)$ will blow up. Ok, so what did we need to assume? I think it would suffice that the population variances $$\sigma^2_m=\frac{1}{N_m}\sum_{i=1}^{N_m} (X_i-\mu_m)^2$$ converge to $\sigma^2$, and that the population third absolute moments $$\kappa_m=\frac{1}{N_m}\sum_{i=1}^{N_m} |X_i-\mu_m|^3$$ are bounded. This could be the assumption, or we could treat the populations as randomly generated and make assumptions about the data generating process that forces these to hold with probability one.
CLT may fail under this condition?
If you're going to run an asymptotic argument with $n$ close to $N$, you need sequences of finite populations and samples. For each $m=1,2,3,\dots$ suppose you have a population of size $N_m$ and a s
CLT may fail under this condition? If you're going to run an asymptotic argument with $n$ close to $N$, you need sequences of finite populations and samples. For each $m=1,2,3,\dots$ suppose you have a population of size $N_m$ and a sample of size $n_m$, with $N_m\geq n_m$ and $n_m\to\infty$. We'll need some assumptions about the populations; we can go back and work out what was needed after the argument We know already (under reasonable assumptions) that if $n_m\to\infty$ we have a Central Limit Theorem, either with $n_m/N_n\to 0$ or with $n_m/N_n\to c\in(0,1)$. If $\mu_m$ is the true finite population mean and $\sigma^2$ is the limit of the true population variances then $$\sqrt{n_m}(\bar X_{n_m}-\mu_m)\stackrel{d}{\to} N(0,\sigma^2)$$ Suppose $n_m$ is really big, so that the number of unsampled individuals does not go to infinity. In that case the CLT does fail. In the extreme case, suppose $n_m=N_m-1$, so that only one individual is not sampled. We could try to get a scaled mean to be Normal in a few ways First, we could try $\sqrt{n_m}(\bar X_{n_m}-\mu_m)$. That doesn't work because there's only one observation's difference between $\bar X_{n_m}$ and $\mu_m$: we get $$\sqrt{n_m}(\bar X_{n_m}-\mu_m)=\sqrt{n_m}\cdot O_p(1/n_m)\stackrel{p}{\to}0$$ We could rescale and try $n_m(\bar X_{n_m}-\mu_m)$. That's of the right order, but it is just equal $X_{n_m}-\mu$, the one unsampled observation centered minus the true mean. Or we could scale by $\sqrt{N_m-n_m}=1$, the square root of the unsampled size, but that goes to zero. Or scale the total to get $$\frac{N_m}{\sqrt{N_m-n_m}}(\bar X_{n_m}-\mu_m)$$ which is again just the unsampled observation minus the mean. If $N_m-n_m$ is bigger than one but bounded, you get the same sort of result: depending on the scaling it blows up, goes to zero, or gives you a finite sum that doesn't converge to Normal. However, if $N_n-n_m\to\infty$ you are good. The unsampled observations are an infinite sum that then does satisfy a CLT, and $$\frac{1}{\sqrt{N_m-n_m}}\left(\sum_{i=1}^{n_m} (X_i-\mu_m)\right)\stackrel{d}{\to}N(0,\sigma^2)$$ so $$\frac{n_m}{\sqrt{N_m-n_m}}\left(\bar X_{n_m}-\mu_m\right)\stackrel{d}{\to}N(0,\sigma^2)$$ It's still true, though, that $\sqrt{n_m}(\bar X_{n_m}-\mu_m)$ will blow up. Ok, so what did we need to assume? I think it would suffice that the population variances $$\sigma^2_m=\frac{1}{N_m}\sum_{i=1}^{N_m} (X_i-\mu_m)^2$$ converge to $\sigma^2$, and that the population third absolute moments $$\kappa_m=\frac{1}{N_m}\sum_{i=1}^{N_m} |X_i-\mu_m|^3$$ are bounded. This could be the assumption, or we could treat the populations as randomly generated and make assumptions about the data generating process that forces these to hold with probability one.
CLT may fail under this condition? If you're going to run an asymptotic argument with $n$ close to $N$, you need sequences of finite populations and samples. For each $m=1,2,3,\dots$ suppose you have a population of size $N_m$ and a s
43,844
CLT may fail under this condition?
No, it does not, since Gaussian distribution converges to Dirac Delta for very small s.d. $\epsilon$, $\delta(x)=\lim\limits_{\epsilon\to 0^+}\frac{e^{-\frac{1}{2}\frac{x^2}{\epsilon^2}}}{\epsilon\sqrt{2\pi}}$. By CLT, for i.i.d. r.v.s $X_1,\ldots, X_n$, with population mean $\mu$ and finite variance $\sigma^2$, $\bar{X_n}-\mu \overset{D}{\to} \mathcal{N}(0,\sigma^2/n)$. When we have large sample size $n$, we have $\epsilon=\dfrac{\sigma}{\sqrt{n}} \to 0$, so the shape of the distribution approaches Dirac Delta, which is a unit impulse function, refer to this: https://en.m.wikipedia.org/wiki/Dirac_delta_function. For example, you can use the following R code to visualize the shape of the pdf of a standard normal r.v., with variance $\dfrac{\sigma^2}{n}$, for some value of population s.d. $\sigma$ (e.g., 10) different sample size $n$, as shown in the next animation (approaches Dirac Delta with large $n$). σ <- 10 plot(x, dnorm(x, sd = sigma/sqrt(n)), ylab='pdf', type='l', main=paste('normal pdf with variance σ^2/n, σ = 10, n =', n))
CLT may fail under this condition?
No, it does not, since Gaussian distribution converges to Dirac Delta for very small s.d. $\epsilon$, $\delta(x)=\lim\limits_{\epsilon\to 0^+}\frac{e^{-\frac{1}{2}\frac{x^2}{\epsilon^2}}}{\epsilon\sqr
CLT may fail under this condition? No, it does not, since Gaussian distribution converges to Dirac Delta for very small s.d. $\epsilon$, $\delta(x)=\lim\limits_{\epsilon\to 0^+}\frac{e^{-\frac{1}{2}\frac{x^2}{\epsilon^2}}}{\epsilon\sqrt{2\pi}}$. By CLT, for i.i.d. r.v.s $X_1,\ldots, X_n$, with population mean $\mu$ and finite variance $\sigma^2$, $\bar{X_n}-\mu \overset{D}{\to} \mathcal{N}(0,\sigma^2/n)$. When we have large sample size $n$, we have $\epsilon=\dfrac{\sigma}{\sqrt{n}} \to 0$, so the shape of the distribution approaches Dirac Delta, which is a unit impulse function, refer to this: https://en.m.wikipedia.org/wiki/Dirac_delta_function. For example, you can use the following R code to visualize the shape of the pdf of a standard normal r.v., with variance $\dfrac{\sigma^2}{n}$, for some value of population s.d. $\sigma$ (e.g., 10) different sample size $n$, as shown in the next animation (approaches Dirac Delta with large $n$). σ <- 10 plot(x, dnorm(x, sd = sigma/sqrt(n)), ylab='pdf', type='l', main=paste('normal pdf with variance σ^2/n, σ = 10, n =', n))
CLT may fail under this condition? No, it does not, since Gaussian distribution converges to Dirac Delta for very small s.d. $\epsilon$, $\delta(x)=\lim\limits_{\epsilon\to 0^+}\frac{e^{-\frac{1}{2}\frac{x^2}{\epsilon^2}}}{\epsilon\sqr
43,845
CLT may fail under this condition?
My question is: if the sample size goes closer or even equal to the population size, wouldn't the average values cram so closely near the mean, that violate the "bell shape" distribution? Indeed, if you sample without repetition from a population, then for $n$ closer to the population size you get a distribution that at some point is exactly equal to the true mean of the population. But, note that you do not have all conditions that are necessary for the central limit theorem to apply. You need to have the individuals in the sample to be independent. This is not the case when you sample form a finite population without repetition.
CLT may fail under this condition?
My question is: if the sample size goes closer or even equal to the population size, wouldn't the average values cram so closely near the mean, that violate the "bell shape" distribution? Indeed, if
CLT may fail under this condition? My question is: if the sample size goes closer or even equal to the population size, wouldn't the average values cram so closely near the mean, that violate the "bell shape" distribution? Indeed, if you sample without repetition from a population, then for $n$ closer to the population size you get a distribution that at some point is exactly equal to the true mean of the population. But, note that you do not have all conditions that are necessary for the central limit theorem to apply. You need to have the individuals in the sample to be independent. This is not the case when you sample form a finite population without repetition.
CLT may fail under this condition? My question is: if the sample size goes closer or even equal to the population size, wouldn't the average values cram so closely near the mean, that violate the "bell shape" distribution? Indeed, if
43,846
CLT may fail under this condition?
Random variables are generally modelled as coming from an infinite population. Even when we're sampling from a finite set of instances, we can still view the population as being infinite. For instance, if you have an urn with 10 red balls and 30 green balls, you can consider your random variable to be "the color of a randomly selected ball", and as long as you do your selection with replacement, you can select balls an infinite number of times. Furthermore, you can model the situation as there being some process that created each of the balls in the urn, and you can imagine what you would get if you were to get an infinite number of balls from whatever process that is. If you do treat your population size as being finite, and you sample without replacement, then the conditions of CLT are not satisfied. The classical formulation of the CLT requires that the random variables be from identical distributions with a finite variance, and each random variable be independent of each other. The first two conditions can be relaxed for a more general statement, but having the random variables be dependent on each other can reduce or even eliminated the convergence to a gaussian distribution. If you draw from a finite population without replacement, then each draw affects the remaining population, and thus further draws are dependent on earlier ones, violating the conditions of the CLT.
CLT may fail under this condition?
Random variables are generally modelled as coming from an infinite population. Even when we're sampling from a finite set of instances, we can still view the population as being infinite. For instance
CLT may fail under this condition? Random variables are generally modelled as coming from an infinite population. Even when we're sampling from a finite set of instances, we can still view the population as being infinite. For instance, if you have an urn with 10 red balls and 30 green balls, you can consider your random variable to be "the color of a randomly selected ball", and as long as you do your selection with replacement, you can select balls an infinite number of times. Furthermore, you can model the situation as there being some process that created each of the balls in the urn, and you can imagine what you would get if you were to get an infinite number of balls from whatever process that is. If you do treat your population size as being finite, and you sample without replacement, then the conditions of CLT are not satisfied. The classical formulation of the CLT requires that the random variables be from identical distributions with a finite variance, and each random variable be independent of each other. The first two conditions can be relaxed for a more general statement, but having the random variables be dependent on each other can reduce or even eliminated the convergence to a gaussian distribution. If you draw from a finite population without replacement, then each draw affects the remaining population, and thus further draws are dependent on earlier ones, violating the conditions of the CLT.
CLT may fail under this condition? Random variables are generally modelled as coming from an infinite population. Even when we're sampling from a finite set of instances, we can still view the population as being infinite. For instance
43,847
What's the advantage of importance sampling? [closed]
Importance resampling is not for plotting the PDF. It is for sampling that PDF. Sometimes, even if you know the formula of the target PDF, it's hard to sample from it. For example, a typical method is inverse transform method, where you need to be able to analytically calculate the inverse of the CDF. A typical example where you cannot do so is normal distribution, in which another methods such as Box-Müller is used for sampling from it.
What's the advantage of importance sampling? [closed]
Importance resampling is not for plotting the PDF. It is for sampling that PDF. Sometimes, even if you know the formula of the target PDF, it's hard to sample from it. For example, a typical method is
What's the advantage of importance sampling? [closed] Importance resampling is not for plotting the PDF. It is for sampling that PDF. Sometimes, even if you know the formula of the target PDF, it's hard to sample from it. For example, a typical method is inverse transform method, where you need to be able to analytically calculate the inverse of the CDF. A typical example where you cannot do so is normal distribution, in which another methods such as Box-Müller is used for sampling from it.
What's the advantage of importance sampling? [closed] Importance resampling is not for plotting the PDF. It is for sampling that PDF. Sometimes, even if you know the formula of the target PDF, it's hard to sample from it. For example, a typical method is
43,848
What's the advantage of importance sampling? [closed]
Importance sampling is a Monte Carlo integration method that can be used to estimate the expected value of a function of a random variable. The method is useful in cases where the PDF is known, but the expected value of interest is unknown (and cannot be computed analytically from the PDF). In these cases, the method gives quite an efficient computation, so long as the generating distribution is reasonable. In your question, you have not actually finished the importance sampling, since you have not given an estimate of any function of the random variable with the distribution you are using. It is also important to bear in mind that, for pedagogical purposes, it is useful to use importance sampling on a distribution where the expected value of interest is known (from analytic computation), to confirm that the estimate does indeed converge to the desired value.
What's the advantage of importance sampling? [closed]
Importance sampling is a Monte Carlo integration method that can be used to estimate the expected value of a function of a random variable. The method is useful in cases where the PDF is known, but t
What's the advantage of importance sampling? [closed] Importance sampling is a Monte Carlo integration method that can be used to estimate the expected value of a function of a random variable. The method is useful in cases where the PDF is known, but the expected value of interest is unknown (and cannot be computed analytically from the PDF). In these cases, the method gives quite an efficient computation, so long as the generating distribution is reasonable. In your question, you have not actually finished the importance sampling, since you have not given an estimate of any function of the random variable with the distribution you are using. It is also important to bear in mind that, for pedagogical purposes, it is useful to use importance sampling on a distribution where the expected value of interest is known (from analytic computation), to confirm that the estimate does indeed converge to the desired value.
What's the advantage of importance sampling? [closed] Importance sampling is a Monte Carlo integration method that can be used to estimate the expected value of a function of a random variable. The method is useful in cases where the PDF is known, but t
43,849
What's the advantage of importance sampling? [closed]
The code is actually producing samples by sampling importance resampling (Rubin 1987), that is by drawing points from the original iid sample $(y_1,\ldots,y_n)\sim\mathcal U(0,1)$ x_samples = rand(N,1); according to the distribution $$\mathbb P(X=y_i)=\omega_i\big/\sum_{j=1}^n \omega_j$$ where the $\omega_j$'s are the importance weights, $\omega_j=f(y_j)/g(y_j)$ with $f$ the target true_func = @(x) betapdf(x,1+1,1+10);and $g$ the Uniform density (which should be $1$ rather than 1/N. While this produces converging (in $n$) approximations to integrals depending on $f$ and to simulation from $f$, it is not an exact iid simulation from $f$ for a given $f$, due to (a) the bias induced by the normalisation w = w ./ sum(w); and (b) the dependence between the resampled values.
What's the advantage of importance sampling? [closed]
The code is actually producing samples by sampling importance resampling (Rubin 1987), that is by drawing points from the original iid sample $(y_1,\ldots,y_n)\sim\mathcal U(0,1)$ x_samples = rand(N,
What's the advantage of importance sampling? [closed] The code is actually producing samples by sampling importance resampling (Rubin 1987), that is by drawing points from the original iid sample $(y_1,\ldots,y_n)\sim\mathcal U(0,1)$ x_samples = rand(N,1); according to the distribution $$\mathbb P(X=y_i)=\omega_i\big/\sum_{j=1}^n \omega_j$$ where the $\omega_j$'s are the importance weights, $\omega_j=f(y_j)/g(y_j)$ with $f$ the target true_func = @(x) betapdf(x,1+1,1+10);and $g$ the Uniform density (which should be $1$ rather than 1/N. While this produces converging (in $n$) approximations to integrals depending on $f$ and to simulation from $f$, it is not an exact iid simulation from $f$ for a given $f$, due to (a) the bias induced by the normalisation w = w ./ sum(w); and (b) the dependence between the resampled values.
What's the advantage of importance sampling? [closed] The code is actually producing samples by sampling importance resampling (Rubin 1987), that is by drawing points from the original iid sample $(y_1,\ldots,y_n)\sim\mathcal U(0,1)$ x_samples = rand(N,
43,850
Unexpected residuals plot of mixed linear model using lmer (lme4 package) in R
Your residual structure is totally expected with this model specification and an indication of an ill-specified model. What you basically are trying to do is to fit a linear line through points that can only take values of 0 and 1 on the $y$-axis. Let's look at a simple example with arbitrarily generated variables: #----------------------------------------------------------------------------- # Generate random data for logistic regression #----------------------------------------------------------------------------- set.seed(123) x <- rnorm(1000) z <- 1 + 2*x pr <- 1/(1+exp(-z)) y <- rbinom(1000,1, pr) #----------------------------------------------------------------------------- # Plot the data #----------------------------------------------------------------------------- par(bg="white", cex=1.2) plot(y~x, las=1, ylim=c(-0.1, 1.3)) #----------------------------------------------------------------------------- # Fit a linear regression (nonsensical) and plot the fit #----------------------------------------------------------------------------- linear.mod <- lm(y~x) segments(-2.32146, 0, 1.24196, 1, col="steelblue", lwd=2) segments(1.24196, 1, 100, 28.71447, col="red", lwd=2) segments(-100, -27.41153, -2.32146, 0, col="red", lwd=2) As you can see, a linear line is fitted through the data. One problem of this is that the line predicts outcomes that are outside the interval $[0,1]$ (illustrated by the red lines outside that interval). Let's have a look at the residuals: #----------------------------------------------------------------------------- # Add the residual lines #----------------------------------------------------------------------------- x.y0 <- sample(which(y==0), 50, replace=F) x.y1 <- sample(which(y==1), 50, replace=F) pre <- predict(linear.mod) segments(x[x.y0], y[x.y0], x[x.y0], pre[x.y0], col="red", lwd=2) points(x[x.y0], y[x.y0], pch=16, col="red", las=1) segments(x[x.y1], y[x.y1], x[x.y1], pre[x.y1], col="blue", lwd=2) points(x[x.y1], y[x.y1], pch=16, col="blue", las=1) I randomly picked some values to show the pattern. The red and blue lines are depicting the residuals, which is the difference between the predicted value of the line and the actual observed value (red and blue dots). The blue lines correspond to the residuals where $y=1$ whereas the red residuals correspond to the situation where $y=0$. Because the outcome can only be either 0 or 1, the residuals are simply the distances between the regression line and either 0 or 1. The residuals take exactly the form that you see in your data: #----------------------------------------------------------------------------- # Plot the residuals #----------------------------------------------------------------------------- res.linear <- residuals(linear.mod, type="response") par(bg="white", cex=1.2) plot(predict(linear.mod)[y==0], res.linear[y==0], las=1, xlab="Fitted values", ylab = "Residuals", ylim = max(abs(res.linear))*c(-1,1), xlim=c(-0.4, 1.6), col="red") points(predict(linear.mod)[y==1], res.linear[y==1], col="blue") abline(h = 0, lty = 2) The colors correspond to the residuals shown above: the blue dots are the residuals where $y=1$ and the red dots are the residuals where $y=0$. In normal linear regression, the residuals are assumed to be approximately normally distributed. But in this case, the residuals can hardly be normal. They are binomial. We need a transformation that transformes the probability, which is bound within $[0,1]$ into a variable that ranges over $(-\infty, \infty)$. One such transformation is the logit (this is not the only possibility: we could also use probit or the complementary log-log function). Let's fit a logistic regression with a logit-link and again plot the binned residuals (explained on page 97 by Gelman and Hill (2007)). Plotting the raw residuals vs. fitted values are generally not useful after logistic regression: #----------------------------------------------------------------------------- # Fit a logistic regression #----------------------------------------------------------------------------- glm.fit <- glm(y~x, family=binomial(link="logit")) #----------------------------------------------------------------------------- # Plot the binned residuals as recommended by Gelman and Hill (2007) #----------------------------------------------------------------------------- library(arm) par(bg="white", cex=1.2, las=1) binnedplot(predict(glm.fit), resid(glm.fit), cex.pts=1, col.int="black") The residuals in logistic regression can be define -$~$as in linear regression$~$- as observed minus expected values: $$ \text{residual}_{i}=y_{i}-\mathrm{E}(y_{i}|X_{i})=y_{i}-\text{logit}^{-1}(X_{i}\beta) $$ Because the data $y_{i}$ are discrete, so are the residuals. In the plot above, the residuals are binned by dividing the data into categories based on their fitted values, and are then plotted against the average residual versus the average fitted value for each category (bin). The lines indicate $\pm2$ standard-error bounds, within which one we would expect about 95% of the binned residuals to fall, under the assumption that the model is true. So the remedy for your immediate problem is to fit a mixed effects logistic regression by typing: model <- glmer(error~is_frisian*condition*person+(1|subject_id), data=output, family="binomial") For a good introduction to mixed effects logistic regression in R, see here. For a good overview of diagnostics in linear and generalized linear models, see here.
Unexpected residuals plot of mixed linear model using lmer (lme4 package) in R
Your residual structure is totally expected with this model specification and an indication of an ill-specified model. What you basically are trying to do is to fit a linear line through points that c
Unexpected residuals plot of mixed linear model using lmer (lme4 package) in R Your residual structure is totally expected with this model specification and an indication of an ill-specified model. What you basically are trying to do is to fit a linear line through points that can only take values of 0 and 1 on the $y$-axis. Let's look at a simple example with arbitrarily generated variables: #----------------------------------------------------------------------------- # Generate random data for logistic regression #----------------------------------------------------------------------------- set.seed(123) x <- rnorm(1000) z <- 1 + 2*x pr <- 1/(1+exp(-z)) y <- rbinom(1000,1, pr) #----------------------------------------------------------------------------- # Plot the data #----------------------------------------------------------------------------- par(bg="white", cex=1.2) plot(y~x, las=1, ylim=c(-0.1, 1.3)) #----------------------------------------------------------------------------- # Fit a linear regression (nonsensical) and plot the fit #----------------------------------------------------------------------------- linear.mod <- lm(y~x) segments(-2.32146, 0, 1.24196, 1, col="steelblue", lwd=2) segments(1.24196, 1, 100, 28.71447, col="red", lwd=2) segments(-100, -27.41153, -2.32146, 0, col="red", lwd=2) As you can see, a linear line is fitted through the data. One problem of this is that the line predicts outcomes that are outside the interval $[0,1]$ (illustrated by the red lines outside that interval). Let's have a look at the residuals: #----------------------------------------------------------------------------- # Add the residual lines #----------------------------------------------------------------------------- x.y0 <- sample(which(y==0), 50, replace=F) x.y1 <- sample(which(y==1), 50, replace=F) pre <- predict(linear.mod) segments(x[x.y0], y[x.y0], x[x.y0], pre[x.y0], col="red", lwd=2) points(x[x.y0], y[x.y0], pch=16, col="red", las=1) segments(x[x.y1], y[x.y1], x[x.y1], pre[x.y1], col="blue", lwd=2) points(x[x.y1], y[x.y1], pch=16, col="blue", las=1) I randomly picked some values to show the pattern. The red and blue lines are depicting the residuals, which is the difference between the predicted value of the line and the actual observed value (red and blue dots). The blue lines correspond to the residuals where $y=1$ whereas the red residuals correspond to the situation where $y=0$. Because the outcome can only be either 0 or 1, the residuals are simply the distances between the regression line and either 0 or 1. The residuals take exactly the form that you see in your data: #----------------------------------------------------------------------------- # Plot the residuals #----------------------------------------------------------------------------- res.linear <- residuals(linear.mod, type="response") par(bg="white", cex=1.2) plot(predict(linear.mod)[y==0], res.linear[y==0], las=1, xlab="Fitted values", ylab = "Residuals", ylim = max(abs(res.linear))*c(-1,1), xlim=c(-0.4, 1.6), col="red") points(predict(linear.mod)[y==1], res.linear[y==1], col="blue") abline(h = 0, lty = 2) The colors correspond to the residuals shown above: the blue dots are the residuals where $y=1$ and the red dots are the residuals where $y=0$. In normal linear regression, the residuals are assumed to be approximately normally distributed. But in this case, the residuals can hardly be normal. They are binomial. We need a transformation that transformes the probability, which is bound within $[0,1]$ into a variable that ranges over $(-\infty, \infty)$. One such transformation is the logit (this is not the only possibility: we could also use probit or the complementary log-log function). Let's fit a logistic regression with a logit-link and again plot the binned residuals (explained on page 97 by Gelman and Hill (2007)). Plotting the raw residuals vs. fitted values are generally not useful after logistic regression: #----------------------------------------------------------------------------- # Fit a logistic regression #----------------------------------------------------------------------------- glm.fit <- glm(y~x, family=binomial(link="logit")) #----------------------------------------------------------------------------- # Plot the binned residuals as recommended by Gelman and Hill (2007) #----------------------------------------------------------------------------- library(arm) par(bg="white", cex=1.2, las=1) binnedplot(predict(glm.fit), resid(glm.fit), cex.pts=1, col.int="black") The residuals in logistic regression can be define -$~$as in linear regression$~$- as observed minus expected values: $$ \text{residual}_{i}=y_{i}-\mathrm{E}(y_{i}|X_{i})=y_{i}-\text{logit}^{-1}(X_{i}\beta) $$ Because the data $y_{i}$ are discrete, so are the residuals. In the plot above, the residuals are binned by dividing the data into categories based on their fitted values, and are then plotted against the average residual versus the average fitted value for each category (bin). The lines indicate $\pm2$ standard-error bounds, within which one we would expect about 95% of the binned residuals to fall, under the assumption that the model is true. So the remedy for your immediate problem is to fit a mixed effects logistic regression by typing: model <- glmer(error~is_frisian*condition*person+(1|subject_id), data=output, family="binomial") For a good introduction to mixed effects logistic regression in R, see here. For a good overview of diagnostics in linear and generalized linear models, see here.
Unexpected residuals plot of mixed linear model using lmer (lme4 package) in R Your residual structure is totally expected with this model specification and an indication of an ill-specified model. What you basically are trying to do is to fit a linear line through points that c
43,851
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear?
If you look at Anscombe's quartet you can see examples of linear with noise, linear with outliers and non-linear sets of data with the same $r^2$, means and variances. This image is from the Wikipedia article
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep
If you look at Anscombe's quartet you can see examples of linear with noise, linear with outliers and non-linear sets of data with the same $r^2$, means and variances. This image is from the Wikiped
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear? If you look at Anscombe's quartet you can see examples of linear with noise, linear with outliers and non-linear sets of data with the same $r^2$, means and variances. This image is from the Wikipedia article
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep If you look at Anscombe's quartet you can see examples of linear with noise, linear with outliers and non-linear sets of data with the same $r^2$, means and variances. This image is from the Wikiped
43,852
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear?
Usually not. The model $$y_i = \beta + \varepsilon_i,$$ $\varepsilon \sim \text{iid}$, $\mathbb{E}[\varepsilon]=0$ for the relation between $(y_i)$ and $(x_i)$ is perfectly linear, yet has an $r^2$ of zero. For other examples of what $r^2$ does not say about linearity, see the illustrations in my reply at Is $R^2$ useful or dangerous?. Linearity is generally assessed by goodness of fit testing; for instance, by including additional terms in a follow-on regression and testing whether they are both significant and important in the application. One person's nonlinearity is just another person's randomness, so there's no omnibus method. Nevertheless, usually $r^2$ is just too crude.
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep
Usually not. The model $$y_i = \beta + \varepsilon_i,$$ $\varepsilon \sim \text{iid}$, $\mathbb{E}[\varepsilon]=0$ for the relation between $(y_i)$ and $(x_i)$ is perfectly linear, yet has an $r^2$ o
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear? Usually not. The model $$y_i = \beta + \varepsilon_i,$$ $\varepsilon \sim \text{iid}$, $\mathbb{E}[\varepsilon]=0$ for the relation between $(y_i)$ and $(x_i)$ is perfectly linear, yet has an $r^2$ of zero. For other examples of what $r^2$ does not say about linearity, see the illustrations in my reply at Is $R^2$ useful or dangerous?. Linearity is generally assessed by goodness of fit testing; for instance, by including additional terms in a follow-on regression and testing whether they are both significant and important in the application. One person's nonlinearity is just another person's randomness, so there's no omnibus method. Nevertheless, usually $r^2$ is just too crude.
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep Usually not. The model $$y_i = \beta + \varepsilon_i,$$ $\varepsilon \sim \text{iid}$, $\mathbb{E}[\varepsilon]=0$ for the relation between $(y_i)$ and $(x_i)$ is perfectly linear, yet has an $r^2$ o
43,853
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear?
In addition to the above answers, a commonly used (in econometrics) test for general regression nonlinearity is Ramsey's RESET test. Suppose you ran your main regression and obtained residuals $\hat\epsilon_i$ and fitted values $\hat y_i$ in it. Then RESET test is the test of the overall significance in an auxiliary regression of $\hat\epsilon_i$ on powers of $\hat y_i$. From regression geometry, we already know that $\hat\epsilon_i$ are orthogonal to the zeroth and the first power of $\hat y_i$, so it makes sense to run it as $\hat\epsilon_i \sim \hat y_i^2 + \hat y_i^3 + \ldots$, in R-like pseudocode. The test is implemented in R as resettest in lmtest package, and in Stata, as estat ovtest after regress.
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep
In addition to the above answers, a commonly used (in econometrics) test for general regression nonlinearity is Ramsey's RESET test. Suppose you ran your main regression and obtained residuals $\hat\e
In linear regression, is the $R^2$ value enough to assess whether the relationship between the independent and dependent variable is linear? In addition to the above answers, a commonly used (in econometrics) test for general regression nonlinearity is Ramsey's RESET test. Suppose you ran your main regression and obtained residuals $\hat\epsilon_i$ and fitted values $\hat y_i$ in it. Then RESET test is the test of the overall significance in an auxiliary regression of $\hat\epsilon_i$ on powers of $\hat y_i$. From regression geometry, we already know that $\hat\epsilon_i$ are orthogonal to the zeroth and the first power of $\hat y_i$, so it makes sense to run it as $\hat\epsilon_i \sim \hat y_i^2 + \hat y_i^3 + \ldots$, in R-like pseudocode. The test is implemented in R as resettest in lmtest package, and in Stata, as estat ovtest after regress.
In linear regression, is the $R^2$ value enough to assess whether the relationship between the indep In addition to the above answers, a commonly used (in econometrics) test for general regression nonlinearity is Ramsey's RESET test. Suppose you ran your main regression and obtained residuals $\hat\e
43,854
What is the best tool for customer segmentation?
I'm afraid you are mistaking software programs and statistical algorithms for thinking, judging beings. No tool can give you the Good, the Bad, and the Ugly. You'll have to exercise your own judgment along the way! What you need is not so much a tool but well-thought-out criteria for classifying each customer. Then the rest is a matter of mechanics, or follow-through.
What is the best tool for customer segmentation?
I'm afraid you are mistaking software programs and statistical algorithms for thinking, judging beings. No tool can give you the Good, the Bad, and the Ugly. You'll have to exercise your own judgmen
What is the best tool for customer segmentation? I'm afraid you are mistaking software programs and statistical algorithms for thinking, judging beings. No tool can give you the Good, the Bad, and the Ugly. You'll have to exercise your own judgment along the way! What you need is not so much a tool but well-thought-out criteria for classifying each customer. Then the rest is a matter of mechanics, or follow-through.
What is the best tool for customer segmentation? I'm afraid you are mistaking software programs and statistical algorithms for thinking, judging beings. No tool can give you the Good, the Bad, and the Ugly. You'll have to exercise your own judgmen
43,855
What is the best tool for customer segmentation?
Survival analysis of LTV (lifetime value) is a good place to start. It's pretty basic, but it gets the job done. But there is a lot of business intelligence work that you could do with what you have. If you have response rates to advertisements and such it could also provide you with a good way to look at effectiveness. I agree with rolando2, the good the bad and the ugly - being mathematically defined, is challenging. Especially with no behavioural or secondary element in your data other than purchases, even something as simple as postal code could add fantastic information to your data for understanding things like locus of purchase (it it's a store). I guess you could segment by LTV percentiles... 30%, 50%, 80% (following the 80/20 business rule...). In terms of software, I have no idea how to do this in Excel or STATA. But, for R there's a mixed intro and example of survival analysis using the survival package here: http://www.stats.uwo.ca/faculty/jones/survival_talk.pdf from Bruce Jones at the University of Western Ontario. I'm Canadian, sue me. In his example, Death, would be something like your average time between purchases identified in the data as 0 or 1 if the observation did purchase in the last average time between purchases. Some people like to set this up as Purchased in Last 3 Months... but obviously it's different for every type of business. You wouldn't by a car every month, would you? So that's a judgement call on your end. Otherwise, there's a lot of interesting things that you can do with your data from a business intelligence perspective. Average purchase price, number of items purchased based on stack outs in a store, or banners on a website if you know the time that the ad or stack out was placed.... those are just a few examples.
What is the best tool for customer segmentation?
Survival analysis of LTV (lifetime value) is a good place to start. It's pretty basic, but it gets the job done. But there is a lot of business intelligence work that you could do with what you have.
What is the best tool for customer segmentation? Survival analysis of LTV (lifetime value) is a good place to start. It's pretty basic, but it gets the job done. But there is a lot of business intelligence work that you could do with what you have. If you have response rates to advertisements and such it could also provide you with a good way to look at effectiveness. I agree with rolando2, the good the bad and the ugly - being mathematically defined, is challenging. Especially with no behavioural or secondary element in your data other than purchases, even something as simple as postal code could add fantastic information to your data for understanding things like locus of purchase (it it's a store). I guess you could segment by LTV percentiles... 30%, 50%, 80% (following the 80/20 business rule...). In terms of software, I have no idea how to do this in Excel or STATA. But, for R there's a mixed intro and example of survival analysis using the survival package here: http://www.stats.uwo.ca/faculty/jones/survival_talk.pdf from Bruce Jones at the University of Western Ontario. I'm Canadian, sue me. In his example, Death, would be something like your average time between purchases identified in the data as 0 or 1 if the observation did purchase in the last average time between purchases. Some people like to set this up as Purchased in Last 3 Months... but obviously it's different for every type of business. You wouldn't by a car every month, would you? So that's a judgement call on your end. Otherwise, there's a lot of interesting things that you can do with your data from a business intelligence perspective. Average purchase price, number of items purchased based on stack outs in a store, or banners on a website if you know the time that the ad or stack out was placed.... those are just a few examples.
What is the best tool for customer segmentation? Survival analysis of LTV (lifetime value) is a good place to start. It's pretty basic, but it gets the job done. But there is a lot of business intelligence work that you could do with what you have.
43,856
What is the best tool for customer segmentation?
I would suggest with your limited data (and perhaps limited experience with clustering), you simply create an RFM coding and separate into the three bins your desire. Otherwise, cluster analysis on the data is a basic method for customer segmentation based on transactional variables (of course your dates have to become measures such as distance between purchases, tenure and recency of purchase).
What is the best tool for customer segmentation?
I would suggest with your limited data (and perhaps limited experience with clustering), you simply create an RFM coding and separate into the three bins your desire. Otherwise, cluster analysis on th
What is the best tool for customer segmentation? I would suggest with your limited data (and perhaps limited experience with clustering), you simply create an RFM coding and separate into the three bins your desire. Otherwise, cluster analysis on the data is a basic method for customer segmentation based on transactional variables (of course your dates have to become measures such as distance between purchases, tenure and recency of purchase).
What is the best tool for customer segmentation? I would suggest with your limited data (and perhaps limited experience with clustering), you simply create an RFM coding and separate into the three bins your desire. Otherwise, cluster analysis on th
43,857
What is the best tool for customer segmentation?
Generally I would agree with rolando2. However, if you interested in unsupervised categorization, there are methods that exist that can provide you with unlabeled groups of your data. One such method is latent dirichlet process (LDA) which has been used for automatic topic discovery. K-Means might be a better fit for your needs, especially since you know the number of categories you expect.
What is the best tool for customer segmentation?
Generally I would agree with rolando2. However, if you interested in unsupervised categorization, there are methods that exist that can provide you with unlabeled groups of your data. One such method
What is the best tool for customer segmentation? Generally I would agree with rolando2. However, if you interested in unsupervised categorization, there are methods that exist that can provide you with unlabeled groups of your data. One such method is latent dirichlet process (LDA) which has been used for automatic topic discovery. K-Means might be a better fit for your needs, especially since you know the number of categories you expect.
What is the best tool for customer segmentation? Generally I would agree with rolando2. However, if you interested in unsupervised categorization, there are methods that exist that can provide you with unlabeled groups of your data. One such method
43,858
What is the best tool for customer segmentation?
One way to approach this is to build a probability model of the customer data. If you have some understanding of the customer level behavior, you can model this and make predictions of who are your most valuable customers. For example, you could assume that customers make purchases at a constant rate until they 'die.' This is the sort of survival analysis that Brandon Mentioned. You could also build more sophisticated models allowing for heterogeneity in purchasing and death rates. Since you ask about software tools, I'd also like to suggest you check out my company, Custora. We use some more sophisticated versions of the models I described above to predict customer lifetime value based on transaction logs. One of the analyses that we provide is customer segmentation.
What is the best tool for customer segmentation?
One way to approach this is to build a probability model of the customer data. If you have some understanding of the customer level behavior, you can model this and make predictions of who are your m
What is the best tool for customer segmentation? One way to approach this is to build a probability model of the customer data. If you have some understanding of the customer level behavior, you can model this and make predictions of who are your most valuable customers. For example, you could assume that customers make purchases at a constant rate until they 'die.' This is the sort of survival analysis that Brandon Mentioned. You could also build more sophisticated models allowing for heterogeneity in purchasing and death rates. Since you ask about software tools, I'd also like to suggest you check out my company, Custora. We use some more sophisticated versions of the models I described above to predict customer lifetime value based on transaction logs. One of the analyses that we provide is customer segmentation.
What is the best tool for customer segmentation? One way to approach this is to build a probability model of the customer data. If you have some understanding of the customer level behavior, you can model this and make predictions of who are your m
43,859
What is the best tool for customer segmentation?
You can look at the problem as one with multiple objectives. Let's say a good customer is one who: Spends a high average amount per purchase (Brings in money) Makes many purchases (Shows trust) Makes purchases over a long duration of time (Shows loyalty) The corresponding objectives are therefore: Maximize $Average Amount Spent Per Purchase$ Maximize $TotalNumberOfPurchases$ Maximize $AverageTimeIntervalBetweenPurchases$ Treat all customers are solutions and sort them using non-dominated sorting. Note that you need not run the genetic algorithm, just sort the solutions once. Say the non-dominated sorting gives you 5 ranks. You can assign ranks 1 and 2 as good customers, rank 3 as ok customers and remaining as bad customers.
What is the best tool for customer segmentation?
You can look at the problem as one with multiple objectives. Let's say a good customer is one who: Spends a high average amount per purchase (Brings in money) Makes many purchases (Shows trust) Makes
What is the best tool for customer segmentation? You can look at the problem as one with multiple objectives. Let's say a good customer is one who: Spends a high average amount per purchase (Brings in money) Makes many purchases (Shows trust) Makes purchases over a long duration of time (Shows loyalty) The corresponding objectives are therefore: Maximize $Average Amount Spent Per Purchase$ Maximize $TotalNumberOfPurchases$ Maximize $AverageTimeIntervalBetweenPurchases$ Treat all customers are solutions and sort them using non-dominated sorting. Note that you need not run the genetic algorithm, just sort the solutions once. Say the non-dominated sorting gives you 5 ranks. You can assign ranks 1 and 2 as good customers, rank 3 as ok customers and remaining as bad customers.
What is the best tool for customer segmentation? You can look at the problem as one with multiple objectives. Let's say a good customer is one who: Spends a high average amount per purchase (Brings in money) Makes many purchases (Shows trust) Makes
43,860
What is the best tool for customer segmentation?
If you want to use a probablistic approach which has already been mentioned by aaronjg, have a look at the R package CLVTools (https://cran.r-project.org/web/packages/CLVTools/index.html). As an output, you basically get an estimate for every customer in terms of his/her future value to a business. Based on this variable you can have a look at any percentile which you might be interested in, e.g. top 10% best future customers. This tutorial might be a good starting point: https://www.clvtools.com/articles/CLVTools.html
What is the best tool for customer segmentation?
If you want to use a probablistic approach which has already been mentioned by aaronjg, have a look at the R package CLVTools (https://cran.r-project.org/web/packages/CLVTools/index.html). As an outpu
What is the best tool for customer segmentation? If you want to use a probablistic approach which has already been mentioned by aaronjg, have a look at the R package CLVTools (https://cran.r-project.org/web/packages/CLVTools/index.html). As an output, you basically get an estimate for every customer in terms of his/her future value to a business. Based on this variable you can have a look at any percentile which you might be interested in, e.g. top 10% best future customers. This tutorial might be a good starting point: https://www.clvtools.com/articles/CLVTools.html
What is the best tool for customer segmentation? If you want to use a probablistic approach which has already been mentioned by aaronjg, have a look at the R package CLVTools (https://cran.r-project.org/web/packages/CLVTools/index.html). As an outpu
43,861
Exponentially weighted moving linear regression
Sounds like what you want to do is a two-stage model. First transform your data into exponentially smoothed form using a specified smoothing factor, and then input the transformed data into your linear regression formula. http://www.jstor.org/pss/2627674 http://en.wikipedia.org/wiki/Exponential_smoothing
Exponentially weighted moving linear regression
Sounds like what you want to do is a two-stage model. First transform your data into exponentially smoothed form using a specified smoothing factor, and then input the transformed data into your line
Exponentially weighted moving linear regression Sounds like what you want to do is a two-stage model. First transform your data into exponentially smoothed form using a specified smoothing factor, and then input the transformed data into your linear regression formula. http://www.jstor.org/pss/2627674 http://en.wikipedia.org/wiki/Exponential_smoothing
Exponentially weighted moving linear regression Sounds like what you want to do is a two-stage model. First transform your data into exponentially smoothed form using a specified smoothing factor, and then input the transformed data into your line
43,862
Exponentially weighted moving linear regression
Sure, just add a weights= argument to lm() (in case of R): R> x <- 1:10 ## mean of this is 5.5 R> lm(x ~ 1) ## regression on constant computes mean Call: lm(formula = x ~ 1) Coefficients: (Intercept) 5.5 R> lm(x ~ 1, weights=0.9^(seq(10,1,by=-1))) Call: lm(formula = x ~ 1, weights = 0.9^(seq(10, 1, by = -1))) Coefficients: (Intercept) 6.35 R> Here is give 'more recent' (i.e., higher) values more weight and the mean shifts from 5.5 to 6.35. The key, if any, is the $\lambda ^ \tau$ exponential weight I compute on the fly; you can change the weight factor to any value you choose and depending on how you order your data you can also have the exponent run the other way. You can do the same with regression models involving whichever regressors you have.
Exponentially weighted moving linear regression
Sure, just add a weights= argument to lm() (in case of R): R> x <- 1:10 ## mean of this is 5.5 R> lm(x ~ 1) ## regression on constant computes mean Call: lm(formula = x ~ 1) Coefficients: (Int
Exponentially weighted moving linear regression Sure, just add a weights= argument to lm() (in case of R): R> x <- 1:10 ## mean of this is 5.5 R> lm(x ~ 1) ## regression on constant computes mean Call: lm(formula = x ~ 1) Coefficients: (Intercept) 5.5 R> lm(x ~ 1, weights=0.9^(seq(10,1,by=-1))) Call: lm(formula = x ~ 1, weights = 0.9^(seq(10, 1, by = -1))) Coefficients: (Intercept) 6.35 R> Here is give 'more recent' (i.e., higher) values more weight and the mean shifts from 5.5 to 6.35. The key, if any, is the $\lambda ^ \tau$ exponential weight I compute on the fly; you can change the weight factor to any value you choose and depending on how you order your data you can also have the exponent run the other way. You can do the same with regression models involving whichever regressors you have.
Exponentially weighted moving linear regression Sure, just add a weights= argument to lm() (in case of R): R> x <- 1:10 ## mean of this is 5.5 R> lm(x ~ 1) ## regression on constant computes mean Call: lm(formula = x ~ 1) Coefficients: (Int
43,863
Exponentially weighted moving linear regression
If you are looking for an equation of the form $$y=\alpha_n + \beta_n x$$ after $n$ pieces of data have come in, and you are using an exponential factor $k \ge 1$ then you could use $$\beta_n = \frac{\left(\sum_{i=1}^n k^i\right) \left(\sum_{i=1}^n k^i X_i Y_i\right) - \left(\sum_{i=1}^n k^i X_i\right) \left(\sum_{i=1}^n k^i Y_i\right) }{ \left(\sum_{i=1}^n k^i\right) \left(\sum_{i=1}^n k^i X_i^2\right) - \left(\sum_{i=1}^n k^i X_i \right)^2}$$ and $$\alpha_n = \frac{\left(\sum_{i=1}^n k^i Y_i\right) - \beta_n \left(\sum_{i=1}^n k^i X_i\right)}{\sum_{i=1}^n k^i} .$$ If rounding or speed become issues, this can be recast in other forms. It may also be worth knowing that for $k>1$ you have $\sum_{i=1}^n k^i = \frac{k(k^n - 1)}{k-1}$.
Exponentially weighted moving linear regression
If you are looking for an equation of the form $$y=\alpha_n + \beta_n x$$ after $n$ pieces of data have come in, and you are using an exponential factor $k \ge 1$ then you could use $$\beta_n = \fr
Exponentially weighted moving linear regression If you are looking for an equation of the form $$y=\alpha_n + \beta_n x$$ after $n$ pieces of data have come in, and you are using an exponential factor $k \ge 1$ then you could use $$\beta_n = \frac{\left(\sum_{i=1}^n k^i\right) \left(\sum_{i=1}^n k^i X_i Y_i\right) - \left(\sum_{i=1}^n k^i X_i\right) \left(\sum_{i=1}^n k^i Y_i\right) }{ \left(\sum_{i=1}^n k^i\right) \left(\sum_{i=1}^n k^i X_i^2\right) - \left(\sum_{i=1}^n k^i X_i \right)^2}$$ and $$\alpha_n = \frac{\left(\sum_{i=1}^n k^i Y_i\right) - \beta_n \left(\sum_{i=1}^n k^i X_i\right)}{\sum_{i=1}^n k^i} .$$ If rounding or speed become issues, this can be recast in other forms. It may also be worth knowing that for $k>1$ you have $\sum_{i=1}^n k^i = \frac{k(k^n - 1)}{k-1}$.
Exponentially weighted moving linear regression If you are looking for an equation of the form $$y=\alpha_n + \beta_n x$$ after $n$ pieces of data have come in, and you are using an exponential factor $k \ge 1$ then you could use $$\beta_n = \fr
43,864
Exponentially weighted moving linear regression
Yes you can. The method you are looking for is called exponentially weighted least squares method. It is a variation on the recursive least squares method: \begin{align} Θ ̂(k+1)&=Θ ̂(k)+K[z(k+1)-x^T (k+1) Θ ̂(k)] \\ K(k+1) &= D(k) x(k+1) [λ+x^T (k+1)D(k)x(k+1)]^(-1) \\ D(k+1) &=\frac 1 λ \bigg(D(k)-D(k)x(k+1)\bigg[λ+x^T (k+1)D(k)x(k+1)\bigg]^{-1} x^T (k+1)D(k)\bigg) \end{align} $0.9<λ<1$ typically. Its a method developed to account for time varying parameters but are still in a linear format. which comes from the cost function: $$J(Θ)=1/2 ∑_(i=k-m)^k▒〖λ^(k-i) [z(i)-x^T (i)Θ]〗^2 $$ Ordinary Least squares is calculated from the following for comparison: the cost function being: $$J(Θ)=1/2 ∑_(i=i)^k▒[z(i)-x^T (i)Θ]^2 $$ with \begin{align} Θ(k) &= D(k) X_k^T Z_k \\ Cov[Θ ̂(k)] &= σ^2 D(k) \\ D(k) &= [X_k^T X_k ]^{-1} \end{align}
Exponentially weighted moving linear regression
Yes you can. The method you are looking for is called exponentially weighted least squares method. It is a variation on the recursive least squares method: \begin{align} Θ ̂(k+1)&=Θ ̂(k)+K[z(k+1)-x^T
Exponentially weighted moving linear regression Yes you can. The method you are looking for is called exponentially weighted least squares method. It is a variation on the recursive least squares method: \begin{align} Θ ̂(k+1)&=Θ ̂(k)+K[z(k+1)-x^T (k+1) Θ ̂(k)] \\ K(k+1) &= D(k) x(k+1) [λ+x^T (k+1)D(k)x(k+1)]^(-1) \\ D(k+1) &=\frac 1 λ \bigg(D(k)-D(k)x(k+1)\bigg[λ+x^T (k+1)D(k)x(k+1)\bigg]^{-1} x^T (k+1)D(k)\bigg) \end{align} $0.9<λ<1$ typically. Its a method developed to account for time varying parameters but are still in a linear format. which comes from the cost function: $$J(Θ)=1/2 ∑_(i=k-m)^k▒〖λ^(k-i) [z(i)-x^T (i)Θ]〗^2 $$ Ordinary Least squares is calculated from the following for comparison: the cost function being: $$J(Θ)=1/2 ∑_(i=i)^k▒[z(i)-x^T (i)Θ]^2 $$ with \begin{align} Θ(k) &= D(k) X_k^T Z_k \\ Cov[Θ ̂(k)] &= σ^2 D(k) \\ D(k) &= [X_k^T X_k ]^{-1} \end{align}
Exponentially weighted moving linear regression Yes you can. The method you are looking for is called exponentially weighted least squares method. It is a variation on the recursive least squares method: \begin{align} Θ ̂(k+1)&=Θ ̂(k)+K[z(k+1)-x^T
43,865
Exponentially weighted moving linear regression
I'm not sure of the actual relationship of this to exponentially weighted moving linear regression, but a simple online formula for estimating an exponentially-weighted slope and offset is called Holt-Winters double exponential smoothing. From the Wikipedia page: Given a time series $x_0 ... x_t$, and smoothing parameters $\alpha \in (0,1], \beta \in (0, 1]$, Initialize with: \begin{align} s_1 &= x_1 \\ b_1 &= x_1 - x_0 \end{align} And then for $t>1$: \begin{align} s_t &= (1-\alpha) (s_{t-1}+b_{t-1}) + \alpha x_t \\ b_t &= (1-\beta) b_{t-1} + \beta (s_t - s_{t-1}) \end{align} Where $b_t$ is an estimated slope and $s_t$ is an estimated y-intercept at time t. Maybe a statistically-inclined person can comment on how close this is to the solution of exponentially weighted moving linear regression.
Exponentially weighted moving linear regression
I'm not sure of the actual relationship of this to exponentially weighted moving linear regression, but a simple online formula for estimating an exponentially-weighted slope and offset is called Holt
Exponentially weighted moving linear regression I'm not sure of the actual relationship of this to exponentially weighted moving linear regression, but a simple online formula for estimating an exponentially-weighted slope and offset is called Holt-Winters double exponential smoothing. From the Wikipedia page: Given a time series $x_0 ... x_t$, and smoothing parameters $\alpha \in (0,1], \beta \in (0, 1]$, Initialize with: \begin{align} s_1 &= x_1 \\ b_1 &= x_1 - x_0 \end{align} And then for $t>1$: \begin{align} s_t &= (1-\alpha) (s_{t-1}+b_{t-1}) + \alpha x_t \\ b_t &= (1-\beta) b_{t-1} + \beta (s_t - s_{t-1}) \end{align} Where $b_t$ is an estimated slope and $s_t$ is an estimated y-intercept at time t. Maybe a statistically-inclined person can comment on how close this is to the solution of exponentially weighted moving linear regression.
Exponentially weighted moving linear regression I'm not sure of the actual relationship of this to exponentially weighted moving linear regression, but a simple online formula for estimating an exponentially-weighted slope and offset is called Holt
43,866
Exponentially weighted moving linear regression
If you form the Transfer Function Model y(t)=W(B)*X(t)+[THETA(B)/PHI(B)]*a(t) the operator [THETA(B)/PHI(B)] is the "smoothing component". For examnple if PHI(B)=1.0 and THETA(B)=1-.5B this would imply a set of weights of .5,.25,.125,... . in this way you could provide the answer to optimizing the "weighted moving linear regression" rather than assuming it's form.
Exponentially weighted moving linear regression
If you form the Transfer Function Model y(t)=W(B)*X(t)+[THETA(B)/PHI(B)]*a(t) the operator [THETA(B)/PHI(B)] is the "smoothing component". For examnple if PHI(B)=1.0 and THETA(B)=1-.5B this would impl
Exponentially weighted moving linear regression If you form the Transfer Function Model y(t)=W(B)*X(t)+[THETA(B)/PHI(B)]*a(t) the operator [THETA(B)/PHI(B)] is the "smoothing component". For examnple if PHI(B)=1.0 and THETA(B)=1-.5B this would imply a set of weights of .5,.25,.125,... . in this way you could provide the answer to optimizing the "weighted moving linear regression" rather than assuming it's form.
Exponentially weighted moving linear regression If you form the Transfer Function Model y(t)=W(B)*X(t)+[THETA(B)/PHI(B)]*a(t) the operator [THETA(B)/PHI(B)] is the "smoothing component". For examnple if PHI(B)=1.0 and THETA(B)=1-.5B this would impl
43,867
Exponentially weighted moving linear regression
First time here, first time posting, probably incorrect, but bare with me. So the classical linear regression calculation is as follows: \begin{align} y=\alpha + \beta \cdot x \\\\ \alpha=\frac{\left(\sum_{i}^N Y_i\right)\left(\sum_{i}^N X_i^2\right) - \left(\sum_{i}^N X_i\right)\left(\sum_{i}^N X_i\cdot Y_i\right)}{N\left(\sum_{i}^N X_i^2\right)-\left(\sum_{i}^N X_i\right)^2} \\ \beta =\frac{N\left(\sum_{i}^N X_i\cdot Y_i\right) - \left(\sum_{i}^N X_i\right)\left(\sum_{i}^N Y_i\right)}{N\left(\sum_{i}^N X_i^2\right)-\left(\sum_{i}^N X_i\right)^2} \end{align} I used the assumption the sums in the aforementioned equations could be estimated with there individual EMA's. \begin{align} \tilde x_n= \lambda \cdot x_n + (1-\lambda)\cdot \tilde x_{n-1} \rightarrow N_{ema}\cdot\tilde x_n\approx \sum_i^N x_i\\ \tilde y_n= \lambda \cdot y_n + (1-\lambda)\cdot \tilde y_{n-1} \rightarrow N_{ema}\cdot\tilde y_n \approx \sum_i^N y_i \\ \tilde {\psi}_n= \lambda \cdot x_n^2 + (1-\lambda)\cdot \tilde \psi_{n-1} \rightarrow N_{ema}\cdot\tilde x_n\approx \sum_i^N x_i^2\\ \tilde {\gamma}_n= \lambda \cdot y_n^2 + (1-\lambda)\cdot \tilde \gamma_{n-1} \rightarrow N_{ema}\cdot\tilde y_n\approx \sum_i^N y_i^2\\ \tilde {p}_n= \lambda \cdot (x_n\cdot y_n) + (1-\lambda)\cdot \tilde p_{n-1} \rightarrow N_{ema}\cdot\tilde p_n\approx \sum_i^N x_i\cdot y_i\\ \end{align} Where $N_{ema}$ is the approximated windowed sample size with following estimate: $$ N\approx N_{ema}=2/\lambda - 1$$ Substitution into the classical equation, the $N_{ema}$ cancel and out and give: \begin{align} \alpha=\frac{\tilde y_n \cdot \tilde \psi_n - \tilde x_n\tilde p_n}{\tilde \psi_n-\tilde x_n^2} \\ \beta =\frac{\tilde p_n - \tilde x_n \cdot \tilde y_n}{\tilde \psi_n-\tilde x_n^2} \end{align} Python code comparing the two online methods is below: import matplotlib.pyplot as plt import numpy as np def np_arange_fix(a, b, step): b += (lambda x: step*max(0.1, x) if x < 0.5 else 0)((lambda n: n-int(n))((b - a)/step+1)) return np.arange(a, b, step) if __name__ == "__main__": fig1 = plt.figure() m, bx, by = 1.0, 1.0, 2.0 mu, sigma = 0, 0.1 t = np_arange_fix(0, 3, 0.01) x = bx + m * t y = by + m * t xr = x + np.random.normal(mu, sigma, len(t)) yr = y + np.random.normal(mu, sigma, len(t)) plt.plot(t, x) plt.plot(t, xr) plt.plot(t, y) plt.plot(t, yr) Nsma = 500 alpha = 2/(Nsma + 1) print('Alpha= {:.5f}'.format(alpha)) x_sma, x_ema = np.zeros(len(t)), np.zeros(len(t)) y_sma, y_ema = np.zeros(len(t)), np.zeros(len(t)) xy_sma, xy_ema = np.zeros(len(t)), np.zeros(len(t)) xsq_sma, xsq_ema = np.zeros(len(t)), np.zeros(len(t)) ysq_sma, ysq_ema = np.zeros(len(t)), np.zeros(len(t)) r_sma, r_ema = np.zeros(len(t)), np.zeros(len(t)) x_sma_buff = np.zeros(Nsma) y_sma_buff = np.zeros(Nsma) xy_sma_buff = np.zeros(Nsma) xsq_sma_buff = np.zeros(Nsma) ysq_sma_buff = np.zeros(Nsma) for i in range(len(t)): xn = xr[i] yn = yr[i] xyn = xn * yn x2n = xn * xn y2n = yn * yn # Buffering for sma x_sma_buff = np.roll(x_sma_buff, -1, 0) y_sma_buff = np.roll(y_sma_buff, -1, 0) xy_sma_buff = np.roll(xy_sma_buff, -1, 0) xsq_sma_buff = np.roll(xsq_sma_buff, -1, 0) ysq_sma_buff = np.roll(ysq_sma_buff, -1, 0) if i == 0: x_sma_buff = np.ones(Nsma) * xn y_sma_buff = np.ones(Nsma) * yn xy_sma_buff = np.ones(Nsma) * xyn xsq_sma_buff = np.ones(Nsma) * x2n ysq_sma_buff = np.ones(Nsma) * y2n x_sma_buff[-1] = xn y_sma_buff[-1] = yn xy_sma_buff[-1] = xyn xsq_sma_buff[-1] = x2n ysq_sma_buff[-1] = y2n x_sma[i] = sum(x_sma_buff)/Nsma y_sma[i] = sum(y_sma_buff)/Nsma xy_sma[i] = sum(xy_sma_buff)/Nsma xsq_sma[i] = sum(xsq_sma_buff)/Nsma ysq_sma[i] = sum(ysq_sma_buff)/Nsma x_ema[i] = alpha * xn + (1-alpha) * x_ema[i-1] if i >= 1 else xn y_ema[i] = alpha * yn + (1-alpha) * y_ema[i-1] if i >= 1 else yn xy_ema[i] = alpha * xyn + (1-alpha) * xy_ema[i-1] if i >= 1 else xyn xsq_ema[i] = alpha * x2n + (1-alpha) * xsq_ema[i-1] if i >= 1 else x2n ysq_ema[i] = alpha * y2n + (1-alpha) * ysq_ema[i-1] if i >= 1 else y2n num = xy_sma[i] - x_sma[i] * y_sma[i] den = np.sqrt((xsq_sma[i] - x_sma[i]*x_sma[i]) * (ysq_sma[i] - y_sma[i]*y_sma[i])) r_sma[i] = num / den if abs(den) > 1e-4 else 0 num = xy_ema[i] - x_ema[i] * y_ema[i] den = np.sqrt((xsq_ema[i] - x_ema[i]**2) * (ysq_ema[i] - y_ema[i]**2)) r_ema[i] = num / den if abs(den) > 1e-4 else 0 fig2 = plt.figure() plt.subplot(4, 1, 1) plt.plot(t, x_sma, label='x_sma') plt.plot(t, x_ema, label='x_ema') plt.legend() plt.subplot(4, 1, 2) plt.plot(t, y_sma, label='y_sma') plt.plot(t, y_ema, label='y_ema') plt.legend() plt.subplot(4, 1, 3) plt.plot(t, xy_sma, label='xy_sma') plt.plot(t, xy_ema, label='xy_ema') plt.legend() plt.subplot(4, 1, 4) plt.plot(t, xsq_sma, label='xsq_sma') plt.plot(t, xsq_ema, label='xsq_ema') plt.legend() m_sma, b_sma = [], [] m_ema, b_ema = [], [] for i in range(len(t)): sum_x = x_sma[i] * Nsma sum_y = y_sma[i] * Nsma sum_xy = xy_sma[i] * Nsma sum_x2 = xsq_sma[i] * Nsma den = Nsma * sum_x2 - sum_x * sum_x m_num = Nsma * sum_xy - sum_x * sum_y b_num = sum_y * sum_x2 - sum_x * sum_xy if abs(den) > 1e-4: m_sma.append(m_num/den) b_sma.append(b_num/den) else: m_sma.append(0) b_sma.append(0) xn = x_ema[i] yn = y_ema[i] xyn = xy_ema[i] x2n = xsq_ema[i] den = x2n - xn*xn m_num = xyn - xn * yn b_num = yn * x2n - xn * xyn if abs(den) > 1e-4: m_ema.append(m_num/den) b_ema.append(b_num/den) else: m_ema.append(0) b_ema.append(0) fig3 = plt.figure() ax1 = plt.subplot(2, 2, 1) plt.plot(t, b_sma, label='b_sma') plt.plot(t, b_ema, label='b_ema') plt.legend() ax2 = plt.subplot(2, 2, 3, sharex=ax1) plt.plot(t, m_sma, label='m_sma') plt.plot(t, m_ema, label='m_ema') plt.legend() ax3 = plt.subplot(2, 2, 2) plt.plot(t, x, label='x={:.1f}*t+{:.1f}'.format(m, bx)) plt.plot(t, xr, label='x={:.1f}*t+{:.1f}+e'.format(m, bx)) plt.plot(t, y, label='y={:.1f}*t+{:.1f}'.format(m, by)) plt.plot(t, yr, label='y={:.1f}*t+{:.1f}+e'.format(m, by)) plt.legend() ax4 = plt.subplot(2, 2, 4, sharex=ax2) plt.plot(t, r_sma, label='r_sma') plt.plot(t, r_ema, label='r_ema') plt.legend() # fig4 = plt.figure() # plt.plot(xr, yr) plt.show() Would be interesting to compare @Peter answer using double exponential smoothing with this as it avoids more calculations and less variables..
Exponentially weighted moving linear regression
First time here, first time posting, probably incorrect, but bare with me. So the classical linear regression calculation is as follows: \begin{align} y=\alpha + \beta \cdot x \\\\ \alpha=\frac{\left(
Exponentially weighted moving linear regression First time here, first time posting, probably incorrect, but bare with me. So the classical linear regression calculation is as follows: \begin{align} y=\alpha + \beta \cdot x \\\\ \alpha=\frac{\left(\sum_{i}^N Y_i\right)\left(\sum_{i}^N X_i^2\right) - \left(\sum_{i}^N X_i\right)\left(\sum_{i}^N X_i\cdot Y_i\right)}{N\left(\sum_{i}^N X_i^2\right)-\left(\sum_{i}^N X_i\right)^2} \\ \beta =\frac{N\left(\sum_{i}^N X_i\cdot Y_i\right) - \left(\sum_{i}^N X_i\right)\left(\sum_{i}^N Y_i\right)}{N\left(\sum_{i}^N X_i^2\right)-\left(\sum_{i}^N X_i\right)^2} \end{align} I used the assumption the sums in the aforementioned equations could be estimated with there individual EMA's. \begin{align} \tilde x_n= \lambda \cdot x_n + (1-\lambda)\cdot \tilde x_{n-1} \rightarrow N_{ema}\cdot\tilde x_n\approx \sum_i^N x_i\\ \tilde y_n= \lambda \cdot y_n + (1-\lambda)\cdot \tilde y_{n-1} \rightarrow N_{ema}\cdot\tilde y_n \approx \sum_i^N y_i \\ \tilde {\psi}_n= \lambda \cdot x_n^2 + (1-\lambda)\cdot \tilde \psi_{n-1} \rightarrow N_{ema}\cdot\tilde x_n\approx \sum_i^N x_i^2\\ \tilde {\gamma}_n= \lambda \cdot y_n^2 + (1-\lambda)\cdot \tilde \gamma_{n-1} \rightarrow N_{ema}\cdot\tilde y_n\approx \sum_i^N y_i^2\\ \tilde {p}_n= \lambda \cdot (x_n\cdot y_n) + (1-\lambda)\cdot \tilde p_{n-1} \rightarrow N_{ema}\cdot\tilde p_n\approx \sum_i^N x_i\cdot y_i\\ \end{align} Where $N_{ema}$ is the approximated windowed sample size with following estimate: $$ N\approx N_{ema}=2/\lambda - 1$$ Substitution into the classical equation, the $N_{ema}$ cancel and out and give: \begin{align} \alpha=\frac{\tilde y_n \cdot \tilde \psi_n - \tilde x_n\tilde p_n}{\tilde \psi_n-\tilde x_n^2} \\ \beta =\frac{\tilde p_n - \tilde x_n \cdot \tilde y_n}{\tilde \psi_n-\tilde x_n^2} \end{align} Python code comparing the two online methods is below: import matplotlib.pyplot as plt import numpy as np def np_arange_fix(a, b, step): b += (lambda x: step*max(0.1, x) if x < 0.5 else 0)((lambda n: n-int(n))((b - a)/step+1)) return np.arange(a, b, step) if __name__ == "__main__": fig1 = plt.figure() m, bx, by = 1.0, 1.0, 2.0 mu, sigma = 0, 0.1 t = np_arange_fix(0, 3, 0.01) x = bx + m * t y = by + m * t xr = x + np.random.normal(mu, sigma, len(t)) yr = y + np.random.normal(mu, sigma, len(t)) plt.plot(t, x) plt.plot(t, xr) plt.plot(t, y) plt.plot(t, yr) Nsma = 500 alpha = 2/(Nsma + 1) print('Alpha= {:.5f}'.format(alpha)) x_sma, x_ema = np.zeros(len(t)), np.zeros(len(t)) y_sma, y_ema = np.zeros(len(t)), np.zeros(len(t)) xy_sma, xy_ema = np.zeros(len(t)), np.zeros(len(t)) xsq_sma, xsq_ema = np.zeros(len(t)), np.zeros(len(t)) ysq_sma, ysq_ema = np.zeros(len(t)), np.zeros(len(t)) r_sma, r_ema = np.zeros(len(t)), np.zeros(len(t)) x_sma_buff = np.zeros(Nsma) y_sma_buff = np.zeros(Nsma) xy_sma_buff = np.zeros(Nsma) xsq_sma_buff = np.zeros(Nsma) ysq_sma_buff = np.zeros(Nsma) for i in range(len(t)): xn = xr[i] yn = yr[i] xyn = xn * yn x2n = xn * xn y2n = yn * yn # Buffering for sma x_sma_buff = np.roll(x_sma_buff, -1, 0) y_sma_buff = np.roll(y_sma_buff, -1, 0) xy_sma_buff = np.roll(xy_sma_buff, -1, 0) xsq_sma_buff = np.roll(xsq_sma_buff, -1, 0) ysq_sma_buff = np.roll(ysq_sma_buff, -1, 0) if i == 0: x_sma_buff = np.ones(Nsma) * xn y_sma_buff = np.ones(Nsma) * yn xy_sma_buff = np.ones(Nsma) * xyn xsq_sma_buff = np.ones(Nsma) * x2n ysq_sma_buff = np.ones(Nsma) * y2n x_sma_buff[-1] = xn y_sma_buff[-1] = yn xy_sma_buff[-1] = xyn xsq_sma_buff[-1] = x2n ysq_sma_buff[-1] = y2n x_sma[i] = sum(x_sma_buff)/Nsma y_sma[i] = sum(y_sma_buff)/Nsma xy_sma[i] = sum(xy_sma_buff)/Nsma xsq_sma[i] = sum(xsq_sma_buff)/Nsma ysq_sma[i] = sum(ysq_sma_buff)/Nsma x_ema[i] = alpha * xn + (1-alpha) * x_ema[i-1] if i >= 1 else xn y_ema[i] = alpha * yn + (1-alpha) * y_ema[i-1] if i >= 1 else yn xy_ema[i] = alpha * xyn + (1-alpha) * xy_ema[i-1] if i >= 1 else xyn xsq_ema[i] = alpha * x2n + (1-alpha) * xsq_ema[i-1] if i >= 1 else x2n ysq_ema[i] = alpha * y2n + (1-alpha) * ysq_ema[i-1] if i >= 1 else y2n num = xy_sma[i] - x_sma[i] * y_sma[i] den = np.sqrt((xsq_sma[i] - x_sma[i]*x_sma[i]) * (ysq_sma[i] - y_sma[i]*y_sma[i])) r_sma[i] = num / den if abs(den) > 1e-4 else 0 num = xy_ema[i] - x_ema[i] * y_ema[i] den = np.sqrt((xsq_ema[i] - x_ema[i]**2) * (ysq_ema[i] - y_ema[i]**2)) r_ema[i] = num / den if abs(den) > 1e-4 else 0 fig2 = plt.figure() plt.subplot(4, 1, 1) plt.plot(t, x_sma, label='x_sma') plt.plot(t, x_ema, label='x_ema') plt.legend() plt.subplot(4, 1, 2) plt.plot(t, y_sma, label='y_sma') plt.plot(t, y_ema, label='y_ema') plt.legend() plt.subplot(4, 1, 3) plt.plot(t, xy_sma, label='xy_sma') plt.plot(t, xy_ema, label='xy_ema') plt.legend() plt.subplot(4, 1, 4) plt.plot(t, xsq_sma, label='xsq_sma') plt.plot(t, xsq_ema, label='xsq_ema') plt.legend() m_sma, b_sma = [], [] m_ema, b_ema = [], [] for i in range(len(t)): sum_x = x_sma[i] * Nsma sum_y = y_sma[i] * Nsma sum_xy = xy_sma[i] * Nsma sum_x2 = xsq_sma[i] * Nsma den = Nsma * sum_x2 - sum_x * sum_x m_num = Nsma * sum_xy - sum_x * sum_y b_num = sum_y * sum_x2 - sum_x * sum_xy if abs(den) > 1e-4: m_sma.append(m_num/den) b_sma.append(b_num/den) else: m_sma.append(0) b_sma.append(0) xn = x_ema[i] yn = y_ema[i] xyn = xy_ema[i] x2n = xsq_ema[i] den = x2n - xn*xn m_num = xyn - xn * yn b_num = yn * x2n - xn * xyn if abs(den) > 1e-4: m_ema.append(m_num/den) b_ema.append(b_num/den) else: m_ema.append(0) b_ema.append(0) fig3 = plt.figure() ax1 = plt.subplot(2, 2, 1) plt.plot(t, b_sma, label='b_sma') plt.plot(t, b_ema, label='b_ema') plt.legend() ax2 = plt.subplot(2, 2, 3, sharex=ax1) plt.plot(t, m_sma, label='m_sma') plt.plot(t, m_ema, label='m_ema') plt.legend() ax3 = plt.subplot(2, 2, 2) plt.plot(t, x, label='x={:.1f}*t+{:.1f}'.format(m, bx)) plt.plot(t, xr, label='x={:.1f}*t+{:.1f}+e'.format(m, bx)) plt.plot(t, y, label='y={:.1f}*t+{:.1f}'.format(m, by)) plt.plot(t, yr, label='y={:.1f}*t+{:.1f}+e'.format(m, by)) plt.legend() ax4 = plt.subplot(2, 2, 4, sharex=ax2) plt.plot(t, r_sma, label='r_sma') plt.plot(t, r_ema, label='r_ema') plt.legend() # fig4 = plt.figure() # plt.plot(xr, yr) plt.show() Would be interesting to compare @Peter answer using double exponential smoothing with this as it avoids more calculations and less variables..
Exponentially weighted moving linear regression First time here, first time posting, probably incorrect, but bare with me. So the classical linear regression calculation is as follows: \begin{align} y=\alpha + \beta \cdot x \\\\ \alpha=\frac{\left(
43,868
Why not use the same distribution for the prior in Bayesian statistics?
For example, the binomial distribution has the Beta distribution as the prior. They are very similar except for a normalization constant due to the Beta distribution. Why not use another binomial distribution (which can be also uninformative) as the prior? Actually, it's a great counterexample. The beta-binomial model is $$\begin{align} p &\sim \mathsf{Beta}(\alpha, \beta) \\ X &\sim \mathsf{Bin}(p, n) \end{align}$$ where $X$ is a discrete random variable $X \in \{ 0, 1, 2, 3, \dots , n\}$, and the binomial distribution is parametrized by probability of success $p$ and the sample size $n$. We cannot use binomial distribution as a prior for $p$, because $p$ is continuous and bounded $p \in (0, 1)$. The same applies to many other distributions, for example, a prior for the Poisson's $\lambda$ parameter would be continuous and non-negative, unlike discrete Poisson distribution.
Why not use the same distribution for the prior in Bayesian statistics?
For example, the binomial distribution has the Beta distribution as the prior. They are very similar except for a normalization constant due to the Beta distribution. Why not use another binomial dist
Why not use the same distribution for the prior in Bayesian statistics? For example, the binomial distribution has the Beta distribution as the prior. They are very similar except for a normalization constant due to the Beta distribution. Why not use another binomial distribution (which can be also uninformative) as the prior? Actually, it's a great counterexample. The beta-binomial model is $$\begin{align} p &\sim \mathsf{Beta}(\alpha, \beta) \\ X &\sim \mathsf{Bin}(p, n) \end{align}$$ where $X$ is a discrete random variable $X \in \{ 0, 1, 2, 3, \dots , n\}$, and the binomial distribution is parametrized by probability of success $p$ and the sample size $n$. We cannot use binomial distribution as a prior for $p$, because $p$ is continuous and bounded $p \in (0, 1)$. The same applies to many other distributions, for example, a prior for the Poisson's $\lambda$ parameter would be continuous and non-negative, unlike discrete Poisson distribution.
Why not use the same distribution for the prior in Bayesian statistics? For example, the binomial distribution has the Beta distribution as the prior. They are very similar except for a normalization constant due to the Beta distribution. Why not use another binomial dist
43,869
Why not use the same distribution for the prior in Bayesian statistics?
The nature of your question itself suggests a conceptual misunderstanding. When we consider a binomial PMF, e.g. $$X \sim \operatorname{Binomial}(n, p)$$ with $$\Pr[X = x] = \binom{n}{x} p^x (1-p)^{n-x}, \quad x \in \{0, 1, \ldots, n\},$$ the support of this random variable is $X \in \{0, 1, 2, \ldots, n\}$. This represents the set of possible elementary outcomes of $X$, and it is in this regard that the sum of the probabilities of all such outcomes equals unity: $$\sum_{x=0}^n \Pr[X = x] = \sum_{x=0}^n \binom{n}{x} p^x (1-p)^{n-x} = (p + (1-p))^n = 1^n = 1$$ by the binomial theorem. However, for a beta distributed random variable, say $P \sim \operatorname{Beta}(a,b)$, the probability density is $$f_P(p) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} p^{a-1} (1-p)^{b-1}, \quad 0 < p < 1$$ where $a$ and $b$ are shape parameters. Here, $0 < P < 1$ is the support representing the set of elementary outcomes of $P$, and the "sum" of the probabilities of all such outcomes is $$\int_{p=0}^1 f_P(p) \, dp = 1.$$ These distributions do not have the same behavior at all. As other answers have pointed out, it makes no sense to model the (Bayesian) prior $p$ in a binomial likelihood with another binomial distribution because $p$ is a probability, not a count. The notion that $\binom{n}{x}$ and $\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}$ are just "normalization constants" reflects a fundamental misunderstanding that occasionally occurs among students of Bayesian statistics. The idea behind conjugate distributions really has to do with the concept of the kernel of a probability function. The kernel is the part that depends on the parameter(s), and excludes any multiplicative factors that are constant with respect to those parameter(s). For instance, with respect to the parameter $p$, the kernel of the binomial PMF is $$\ker(\Pr[X=x]) = p^x (1-p)^{n-x}.$$ The factor $\binom{n}{x}$ is excluded because it does not depend on $p$. The kernel is the basis for the likelihood function with respect to those same parameter(s); e.g., $$\mathcal L(p \mid x) \propto \ker(\Pr[X = x]).$$ The essence of this idea is that a likelihood is a function of the parameter(s) for some observed data $x$; as such, it is only uniquely determined up to a constant of proportionality. For instance, if $X \sim \operatorname{Binomial}(n = 5, p)$ and we observed $X = 3$, we could write the likelihood function of $p$ as $$\mathcal L(p \mid X = 3) = p^3 (1-p)^2, \quad 0 < p < 1,$$ or we could write it as $$\mathcal L(p \mid X = 3) = 157839027384 p^3 (1-p)^2, \quad 0 < p < 1.$$ It doesn't matter because $\mathcal L$ need not satisfy $\int_{p=0}^1 \mathcal L(p) \, dp = 1$. There is a choice that makes this true for general $n, x$, and when we do choose this, we get a beta distribution over $p$. This is why the beta distribution is the conjugate prior for a binomial likelihood. As another example, if we have a Poisson distributed random variable $\Pr[Y = y] = e^{-\lambda} \lambda^y/y!$ with unknown rate $\lambda$, its kernel with respect to $\lambda$ is $$\ker(\Pr[Y = y]) = e^{-\lambda} \lambda^y, \quad y > 0.$$ So its likelihood is $$\mathcal L(\lambda \mid y) \propto e^{-\lambda} \lambda^y$$ which is proportional to a gamma density with shape $y+1$ and rate $1$; hence the gamma distribution is the conjugate prior for a Poisson likelihood.
Why not use the same distribution for the prior in Bayesian statistics?
The nature of your question itself suggests a conceptual misunderstanding. When we consider a binomial PMF, e.g. $$X \sim \operatorname{Binomial}(n, p)$$ with $$\Pr[X = x] = \binom{n}{x} p^x (1-p)^{n-
Why not use the same distribution for the prior in Bayesian statistics? The nature of your question itself suggests a conceptual misunderstanding. When we consider a binomial PMF, e.g. $$X \sim \operatorname{Binomial}(n, p)$$ with $$\Pr[X = x] = \binom{n}{x} p^x (1-p)^{n-x}, \quad x \in \{0, 1, \ldots, n\},$$ the support of this random variable is $X \in \{0, 1, 2, \ldots, n\}$. This represents the set of possible elementary outcomes of $X$, and it is in this regard that the sum of the probabilities of all such outcomes equals unity: $$\sum_{x=0}^n \Pr[X = x] = \sum_{x=0}^n \binom{n}{x} p^x (1-p)^{n-x} = (p + (1-p))^n = 1^n = 1$$ by the binomial theorem. However, for a beta distributed random variable, say $P \sim \operatorname{Beta}(a,b)$, the probability density is $$f_P(p) = \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} p^{a-1} (1-p)^{b-1}, \quad 0 < p < 1$$ where $a$ and $b$ are shape parameters. Here, $0 < P < 1$ is the support representing the set of elementary outcomes of $P$, and the "sum" of the probabilities of all such outcomes is $$\int_{p=0}^1 f_P(p) \, dp = 1.$$ These distributions do not have the same behavior at all. As other answers have pointed out, it makes no sense to model the (Bayesian) prior $p$ in a binomial likelihood with another binomial distribution because $p$ is a probability, not a count. The notion that $\binom{n}{x}$ and $\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}$ are just "normalization constants" reflects a fundamental misunderstanding that occasionally occurs among students of Bayesian statistics. The idea behind conjugate distributions really has to do with the concept of the kernel of a probability function. The kernel is the part that depends on the parameter(s), and excludes any multiplicative factors that are constant with respect to those parameter(s). For instance, with respect to the parameter $p$, the kernel of the binomial PMF is $$\ker(\Pr[X=x]) = p^x (1-p)^{n-x}.$$ The factor $\binom{n}{x}$ is excluded because it does not depend on $p$. The kernel is the basis for the likelihood function with respect to those same parameter(s); e.g., $$\mathcal L(p \mid x) \propto \ker(\Pr[X = x]).$$ The essence of this idea is that a likelihood is a function of the parameter(s) for some observed data $x$; as such, it is only uniquely determined up to a constant of proportionality. For instance, if $X \sim \operatorname{Binomial}(n = 5, p)$ and we observed $X = 3$, we could write the likelihood function of $p$ as $$\mathcal L(p \mid X = 3) = p^3 (1-p)^2, \quad 0 < p < 1,$$ or we could write it as $$\mathcal L(p \mid X = 3) = 157839027384 p^3 (1-p)^2, \quad 0 < p < 1.$$ It doesn't matter because $\mathcal L$ need not satisfy $\int_{p=0}^1 \mathcal L(p) \, dp = 1$. There is a choice that makes this true for general $n, x$, and when we do choose this, we get a beta distribution over $p$. This is why the beta distribution is the conjugate prior for a binomial likelihood. As another example, if we have a Poisson distributed random variable $\Pr[Y = y] = e^{-\lambda} \lambda^y/y!$ with unknown rate $\lambda$, its kernel with respect to $\lambda$ is $$\ker(\Pr[Y = y]) = e^{-\lambda} \lambda^y, \quad y > 0.$$ So its likelihood is $$\mathcal L(\lambda \mid y) \propto e^{-\lambda} \lambda^y$$ which is proportional to a gamma density with shape $y+1$ and rate $1$; hence the gamma distribution is the conjugate prior for a Poisson likelihood.
Why not use the same distribution for the prior in Bayesian statistics? The nature of your question itself suggests a conceptual misunderstanding. When we consider a binomial PMF, e.g. $$X \sim \operatorname{Binomial}(n, p)$$ with $$\Pr[X = x] = \binom{n}{x} p^x (1-p)^{n-
43,870
Why not use the same distribution for the prior in Bayesian statistics?
While I can't speak for textbook authors, I can think of two reasons why they might choose to do this. Both come from the fact that a conjugate prior will lead to a posterior distribution of a known distribution family. (1) Simplicity: A well-written textbook should distill the content to the key points, and an example where the posterior does not simplify to a convenient form would add clutter that isn't relevant to discussion. Perhaps the main point could be: the posterior distribution will be a valid pdf or pmf (oh hey, it's a distribution we recognize!) (2) Computational convenience: With conjugate distributions, algorithms such as Gibbs sampling will be more efficient, as samples can be drawn directly from target distributions without using approximate methods like slice or rejection sampling. (bonus reason) If the posterior distribution simplifies to a known distribution, closed-form methods can be used rather than MCMC. In regard to your beta-binomial example, a beta distribution is continuous and bounded on (0,1), which matches the target distribution of the binomial parameter $p$. Using a binomial distribution as a prior for $p$ wouldn't make sense, because its support is discrete, whole-number values up to and including some parameter $n$. This is by no means a complete answer, and others are welcome to chime in!
Why not use the same distribution for the prior in Bayesian statistics?
While I can't speak for textbook authors, I can think of two reasons why they might choose to do this. Both come from the fact that a conjugate prior will lead to a posterior distribution of a known
Why not use the same distribution for the prior in Bayesian statistics? While I can't speak for textbook authors, I can think of two reasons why they might choose to do this. Both come from the fact that a conjugate prior will lead to a posterior distribution of a known distribution family. (1) Simplicity: A well-written textbook should distill the content to the key points, and an example where the posterior does not simplify to a convenient form would add clutter that isn't relevant to discussion. Perhaps the main point could be: the posterior distribution will be a valid pdf or pmf (oh hey, it's a distribution we recognize!) (2) Computational convenience: With conjugate distributions, algorithms such as Gibbs sampling will be more efficient, as samples can be drawn directly from target distributions without using approximate methods like slice or rejection sampling. (bonus reason) If the posterior distribution simplifies to a known distribution, closed-form methods can be used rather than MCMC. In regard to your beta-binomial example, a beta distribution is continuous and bounded on (0,1), which matches the target distribution of the binomial parameter $p$. Using a binomial distribution as a prior for $p$ wouldn't make sense, because its support is discrete, whole-number values up to and including some parameter $n$. This is by no means a complete answer, and others are welcome to chime in!
Why not use the same distribution for the prior in Bayesian statistics? While I can't speak for textbook authors, I can think of two reasons why they might choose to do this. Both come from the fact that a conjugate prior will lead to a posterior distribution of a known
43,871
What does standard deviation mean in this case?
Interpretation of the Mean When we say that the average value spent on meals was 50 USD - it means that if we take the total amount spent on fast foods and equally divide the sum among all the people who made the purchase - each person would get 50 USD. However, this number hides a lot of information. We can get an average of 50 USD in a lot of different situations. One extreme is when everyone spends exactly 50 USD. Another extreme is when half the people spend 0 USD and another half spend 100 USD. And there are infinite number of situations in between that would give us a mean value of 50. Average Deviation Hence, we are interested in the variability of those amounts. One intuitive way to quantify how much variability there is is to calculate the average deviation from that mean value. So when we know the mean value, for each person we can calculate the difference between their spent amount and the mean value, and get the average of that: $$MAD = \frac{\sum_i | x_i - \bar{x} |}{n}$$ This is "Mean Absolute Deviation" (MAD). It answers the question: among the customers - what is the average difference between their purchase and the average? We can check what this score would be in the two extreme scenarios. If every purchase was equal to 50 USD then the average would be 50, and the MAD would be 0. And if half of the purchases were 0 and another half 100 then the mean would be 50 and the MAD would be 50. Standard Deviation Standard deviation is a variant of the MAD, but it's harder to interpret. Note that when we look for averages differences from the mean in MAD calculation - we take the absolute value. We want to get rid of the sign, because otherwise roughly half the deviations will be negative and half - positive, and so they would cancel out. Standard deviation, instead of taking the absolute value, uses the square, which, just like absolute value, transforms negative numbers into positive. And then transforms-back by taking the square root: $$SD = \sqrt{\frac{\sum_i ( x_i - \bar{x} )^2}{n}}$$ The idea is the same. It is harder to interpret, but it has some nice properties. The reasons why standard deviation is used more often are discussed here: Why square the difference instead of taking the absolute value in standard deviation? Questions Does SD show that, on average, people spend between USD 43 and USD 57 on meals? No. What would "on average people spend between X and Y" mean, exactly? Average is a point estimate, not a range. If the amount spent followed a normal distribution that we could derive that around 68% of customers spent between 43 and 57 USD. However, dollar amounts certainly do not follow normal distributions (i.e. they don't have negative values). Or, on average, they spend USD 50 per purchase but their purchase amount has a relatively large standard deviation of USD 7? This is correct. But does this answer your question? It restates that the average was 50, and SD was 7. And only adds some external interpretation that 7 is relatively large. Or, on average, they spend USD 50 per purchase but my estimate has a relatively large standard deviation of USD 7? No, there is a separate measure for that, called Standard Error.
What does standard deviation mean in this case?
Interpretation of the Mean When we say that the average value spent on meals was 50 USD - it means that if we take the total amount spent on fast foods and equally divide the sum among all the people
What does standard deviation mean in this case? Interpretation of the Mean When we say that the average value spent on meals was 50 USD - it means that if we take the total amount spent on fast foods and equally divide the sum among all the people who made the purchase - each person would get 50 USD. However, this number hides a lot of information. We can get an average of 50 USD in a lot of different situations. One extreme is when everyone spends exactly 50 USD. Another extreme is when half the people spend 0 USD and another half spend 100 USD. And there are infinite number of situations in between that would give us a mean value of 50. Average Deviation Hence, we are interested in the variability of those amounts. One intuitive way to quantify how much variability there is is to calculate the average deviation from that mean value. So when we know the mean value, for each person we can calculate the difference between their spent amount and the mean value, and get the average of that: $$MAD = \frac{\sum_i | x_i - \bar{x} |}{n}$$ This is "Mean Absolute Deviation" (MAD). It answers the question: among the customers - what is the average difference between their purchase and the average? We can check what this score would be in the two extreme scenarios. If every purchase was equal to 50 USD then the average would be 50, and the MAD would be 0. And if half of the purchases were 0 and another half 100 then the mean would be 50 and the MAD would be 50. Standard Deviation Standard deviation is a variant of the MAD, but it's harder to interpret. Note that when we look for averages differences from the mean in MAD calculation - we take the absolute value. We want to get rid of the sign, because otherwise roughly half the deviations will be negative and half - positive, and so they would cancel out. Standard deviation, instead of taking the absolute value, uses the square, which, just like absolute value, transforms negative numbers into positive. And then transforms-back by taking the square root: $$SD = \sqrt{\frac{\sum_i ( x_i - \bar{x} )^2}{n}}$$ The idea is the same. It is harder to interpret, but it has some nice properties. The reasons why standard deviation is used more often are discussed here: Why square the difference instead of taking the absolute value in standard deviation? Questions Does SD show that, on average, people spend between USD 43 and USD 57 on meals? No. What would "on average people spend between X and Y" mean, exactly? Average is a point estimate, not a range. If the amount spent followed a normal distribution that we could derive that around 68% of customers spent between 43 and 57 USD. However, dollar amounts certainly do not follow normal distributions (i.e. they don't have negative values). Or, on average, they spend USD 50 per purchase but their purchase amount has a relatively large standard deviation of USD 7? This is correct. But does this answer your question? It restates that the average was 50, and SD was 7. And only adds some external interpretation that 7 is relatively large. Or, on average, they spend USD 50 per purchase but my estimate has a relatively large standard deviation of USD 7? No, there is a separate measure for that, called Standard Error.
What does standard deviation mean in this case? Interpretation of the Mean When we say that the average value spent on meals was 50 USD - it means that if we take the total amount spent on fast foods and equally divide the sum among all the people
43,872
What does standard deviation mean in this case?
I'm surprised no one answered with the rule-of-thumb for regarding the standard deviation in data with normal distributions: The 68-95-99.7 rule. (See Wikipedia article. If you have normally-distributed data, about 68% of observations fall within the range of the mean ± the standard deviation. And about 95% of observations fall within the mean ± two standard deviations. As far as I can tell, for a uniform distribution, about 58% of observations fall within μ ± σ, and 100% fall within μ ± 2σ. It appears that for skewed distributions, more of the data would fall within μ ± σ, so that for a common log-normal distribution, perhaps 75% of observations fall within μ ± σ. The data could also have a bimodal distribution. For a pretty obviously bimodal distribution, perhaps more that 50% of observations fall within μ ± σ. EDIT: To make these observations more explicitly tied to the question: It depends on the distribution of the data, and on what you mean by "on average", but probably more than 50% of observations fall within μ ± σ , so "on average, people spend between USD 43 and USD 57 on meals" isn't a bad interpretation of the statistics presented. EDIT 2: I bolded the mentioned distributions to make the logic of my answer more apparent.
What does standard deviation mean in this case?
I'm surprised no one answered with the rule-of-thumb for regarding the standard deviation in data with normal distributions: The 68-95-99.7 rule. (See Wikipedia article. If you have normally-distrib
What does standard deviation mean in this case? I'm surprised no one answered with the rule-of-thumb for regarding the standard deviation in data with normal distributions: The 68-95-99.7 rule. (See Wikipedia article. If you have normally-distributed data, about 68% of observations fall within the range of the mean ± the standard deviation. And about 95% of observations fall within the mean ± two standard deviations. As far as I can tell, for a uniform distribution, about 58% of observations fall within μ ± σ, and 100% fall within μ ± 2σ. It appears that for skewed distributions, more of the data would fall within μ ± σ, so that for a common log-normal distribution, perhaps 75% of observations fall within μ ± σ. The data could also have a bimodal distribution. For a pretty obviously bimodal distribution, perhaps more that 50% of observations fall within μ ± σ. EDIT: To make these observations more explicitly tied to the question: It depends on the distribution of the data, and on what you mean by "on average", but probably more than 50% of observations fall within μ ± σ , so "on average, people spend between USD 43 and USD 57 on meals" isn't a bad interpretation of the statistics presented. EDIT 2: I bolded the mentioned distributions to make the logic of my answer more apparent.
What does standard deviation mean in this case? I'm surprised no one answered with the rule-of-thumb for regarding the standard deviation in data with normal distributions: The 68-95-99.7 rule. (See Wikipedia article. If you have normally-distrib
43,873
What does standard deviation mean in this case?
Standard deviation refers to the distribution of the data (or the distribution from which the data were drawn). Standard error refers to estimating a parameter. It is not quite right to say that people tend to spend between 43 and 57, but that is closer to the correct interpretation. Some of the confusion comes from the fact that the terms have similar names and that beginning students only see the standard error of the mean, the calculation of which involves the standard deviation. However, you can have a standard error of any parameter you estimate, and the calculation may not involve the standard deviation of the distribution (such as a correlation coefficient).
What does standard deviation mean in this case?
Standard deviation refers to the distribution of the data (or the distribution from which the data were drawn). Standard error refers to estimating a parameter. It is not quite right to say that peopl
What does standard deviation mean in this case? Standard deviation refers to the distribution of the data (or the distribution from which the data were drawn). Standard error refers to estimating a parameter. It is not quite right to say that people tend to spend between 43 and 57, but that is closer to the correct interpretation. Some of the confusion comes from the fact that the terms have similar names and that beginning students only see the standard error of the mean, the calculation of which involves the standard deviation. However, you can have a standard error of any parameter you estimate, and the calculation may not involve the standard deviation of the distribution (such as a correlation coefficient).
What does standard deviation mean in this case? Standard deviation refers to the distribution of the data (or the distribution from which the data were drawn). Standard error refers to estimating a parameter. It is not quite right to say that peopl
43,874
What does standard deviation mean in this case?
Suppose that someone was collecting samples and he was trying to estimate the average amount of money people spend on purchasing fast food meals. The calculated mean was USD 50 and the standard deviation was USD 7. This doesn't tell us enough information. But that is ok, we can tease out the likely answer. So, our problem is decoding the calculated mean of what was USD 50? Was it some sampling of people spending money on fast food meals? Or, was it every single fast food meal purchased? In the first case, 50 USD is the sample mean. They checked 10 people, and the average spend was 50 USD. In the second case, 50 USD is the population mean. They checked every person, and the average spend was 50 USD. Now, the SD probably means the standard deviation of the points that are averaged. But in the first case, statisticians sometimes get fancy, and attempt to calculate the distribution of the actual population mean given the sampling data gathered. Those statisticians, trying to produce useful information. Here, 50 USD is the mean of the estimate of the population mean, and 7 USD is the standard deviation on the population mean given the sample data. Does SD show that, on average, people spend between USD 43 and USD 57 on meals? If 50 is the population mean, and the SD is 7, then we are pretty certain that a good percentage of the population spends between USD 43 and 57 on meals; that is 1 SD away from the mean. As it is almost certain that the distribution of meal purchases is going to be somewhat normal, this is a safe bet. Or, on average, they spend USD 50 per purchase but their purchase amount has a relatively large standard deviation of USD 7? This again is a population mean of 50 USD. It is another way to say the previous point, with more precision and less assumptions. Or, on average, they spend USD 50 per purchase but my estimate has a relatively large standard deviation of USD 7? This is a case where we read the USD 50 as an estimate of the population mean. Which of these is in play is not actually described well by the question. But based on the test taking strategy (first two answers are variations on each other) and the fact that the initial paragraph talked about estimating the average, the difficulty of actually getting data for the entire population, and the fact that statisticians do this operation a lot, I'd go with this one. Now, statisticians attempt to estimate the actual average based on the sample data; but in doing so, they make assumptions about the underlying distribution (quite reasonable ones). As an example of how you might do this, you might use Student's T distribution, which assumes a-priori that the purchases made are normal, but with unknown mean and standard deviation. Then from a set of samples, you can generate an estimate of the population mean and a standard deviation of the error in your estimate. I'm guessing this is what the situation is being described.
What does standard deviation mean in this case?
Suppose that someone was collecting samples and he was trying to estimate the average amount of money people spend on purchasing fast food meals. The calculated mean was USD 50 and the standard deviat
What does standard deviation mean in this case? Suppose that someone was collecting samples and he was trying to estimate the average amount of money people spend on purchasing fast food meals. The calculated mean was USD 50 and the standard deviation was USD 7. This doesn't tell us enough information. But that is ok, we can tease out the likely answer. So, our problem is decoding the calculated mean of what was USD 50? Was it some sampling of people spending money on fast food meals? Or, was it every single fast food meal purchased? In the first case, 50 USD is the sample mean. They checked 10 people, and the average spend was 50 USD. In the second case, 50 USD is the population mean. They checked every person, and the average spend was 50 USD. Now, the SD probably means the standard deviation of the points that are averaged. But in the first case, statisticians sometimes get fancy, and attempt to calculate the distribution of the actual population mean given the sampling data gathered. Those statisticians, trying to produce useful information. Here, 50 USD is the mean of the estimate of the population mean, and 7 USD is the standard deviation on the population mean given the sample data. Does SD show that, on average, people spend between USD 43 and USD 57 on meals? If 50 is the population mean, and the SD is 7, then we are pretty certain that a good percentage of the population spends between USD 43 and 57 on meals; that is 1 SD away from the mean. As it is almost certain that the distribution of meal purchases is going to be somewhat normal, this is a safe bet. Or, on average, they spend USD 50 per purchase but their purchase amount has a relatively large standard deviation of USD 7? This again is a population mean of 50 USD. It is another way to say the previous point, with more precision and less assumptions. Or, on average, they spend USD 50 per purchase but my estimate has a relatively large standard deviation of USD 7? This is a case where we read the USD 50 as an estimate of the population mean. Which of these is in play is not actually described well by the question. But based on the test taking strategy (first two answers are variations on each other) and the fact that the initial paragraph talked about estimating the average, the difficulty of actually getting data for the entire population, and the fact that statisticians do this operation a lot, I'd go with this one. Now, statisticians attempt to estimate the actual average based on the sample data; but in doing so, they make assumptions about the underlying distribution (quite reasonable ones). As an example of how you might do this, you might use Student's T distribution, which assumes a-priori that the purchases made are normal, but with unknown mean and standard deviation. Then from a set of samples, you can generate an estimate of the population mean and a standard deviation of the error in your estimate. I'm guessing this is what the situation is being described.
What does standard deviation mean in this case? Suppose that someone was collecting samples and he was trying to estimate the average amount of money people spend on purchasing fast food meals. The calculated mean was USD 50 and the standard deviat
43,875
Why is the intercept changing in a logistic regression when all predictors are standardized?
As Noah says but just with formulas ... Consider logistic regression $$ \Pr(Y=1) = \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)}$$ and then offcourse $$ \Pr(Y=0) = 1- \Pr(Y=1)=1 - \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)} = \frac{1}{1+\exp(\beta_0 + \mathbf x^\top\beta)}$$ Assuming that you are using demeaned raw variables $\mathbf z$ to get covariates $$\mathbf x = \mathbf z - \mathbf{ \bar z}$$ then $\mathbf x= 0$ is equivalent to $\mathbf z = \mathbf {\bar z}$. Inserting $\mathbf x = 0$ in the formulas above the probabilities reduce to $$\Pr(Y=1) = \exp(\beta_0) /(1+\exp(\beta_0)) \phantom{xxx}\wedge \phantom{xxx}\Pr(Y=0) = 1 /(1+\exp(\beta_0))$$ hence odds at the mean $$\frac{\Pr(Y=1)}{\Pr(Y=0)}\biggr\rvert_{\mathbf z=\mathbf { \bar z}} = \exp(\beta_0)$$ and log odds at the mean $$\log \frac{\Pr(Y=1)}{\Pr(Y=0)}\biggr\rvert_{\mathbf z=\mathbf { \bar z}} =\beta_0$$ Compare this to the case where evaluation is not at the mean and assume for simplicity that $\mathbf x$ only includes one covariate such that $$\log \frac{\Pr(Y=1)}{\Pr(Y=0)}=\beta_0 + \beta_1 x_1$$ it then makes sense in the case where $x_1$ is a continuous covariate to differentiate the log odds with respect to $x_1$ to get $\beta_1$. This is never the case with the intercept because it is not a coefficient of a continuous regressor, hence it never makes sense to speak of the intercept as marginal log odds in the sense here used.
Why is the intercept changing in a logistic regression when all predictors are standardized?
As Noah says but just with formulas ... Consider logistic regression $$ \Pr(Y=1) = \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)}$$ and then offcourse $$ \Pr(Y=0) =
Why is the intercept changing in a logistic regression when all predictors are standardized? As Noah says but just with formulas ... Consider logistic regression $$ \Pr(Y=1) = \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)}$$ and then offcourse $$ \Pr(Y=0) = 1- \Pr(Y=1)=1 - \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)} = \frac{1}{1+\exp(\beta_0 + \mathbf x^\top\beta)}$$ Assuming that you are using demeaned raw variables $\mathbf z$ to get covariates $$\mathbf x = \mathbf z - \mathbf{ \bar z}$$ then $\mathbf x= 0$ is equivalent to $\mathbf z = \mathbf {\bar z}$. Inserting $\mathbf x = 0$ in the formulas above the probabilities reduce to $$\Pr(Y=1) = \exp(\beta_0) /(1+\exp(\beta_0)) \phantom{xxx}\wedge \phantom{xxx}\Pr(Y=0) = 1 /(1+\exp(\beta_0))$$ hence odds at the mean $$\frac{\Pr(Y=1)}{\Pr(Y=0)}\biggr\rvert_{\mathbf z=\mathbf { \bar z}} = \exp(\beta_0)$$ and log odds at the mean $$\log \frac{\Pr(Y=1)}{\Pr(Y=0)}\biggr\rvert_{\mathbf z=\mathbf { \bar z}} =\beta_0$$ Compare this to the case where evaluation is not at the mean and assume for simplicity that $\mathbf x$ only includes one covariate such that $$\log \frac{\Pr(Y=1)}{\Pr(Y=0)}=\beta_0 + \beta_1 x_1$$ it then makes sense in the case where $x_1$ is a continuous covariate to differentiate the log odds with respect to $x_1$ to get $\beta_1$. This is never the case with the intercept because it is not a coefficient of a continuous regressor, hence it never makes sense to speak of the intercept as marginal log odds in the sense here used.
Why is the intercept changing in a logistic regression when all predictors are standardized? As Noah says but just with formulas ... Consider logistic regression $$ \Pr(Y=1) = \frac{\exp(\beta_0 + \mathbf x^\top\beta)}{1+ \exp(\beta_0 + \mathbf x^\top\beta)}$$ and then offcourse $$ \Pr(Y=0) =
43,876
Why is the intercept changing in a logistic regression when all predictors are standardized?
Welcome to CV. You have misunderstood the interpretation of the intercept. The intercept is the log odds (not the odds ratio) of the outcome when all the predictors are at 0 (not the marginal log odds, as you described). When the predictors are standardized, this corresponds to when all the raw predictors are at their mean. So, for an individual with average levels of each of the predictors, the intercept is the log odds of the outcome. This may not be an interpretable value because it might not make sense to think of an individual with average levels of all the predictors.
Why is the intercept changing in a logistic regression when all predictors are standardized?
Welcome to CV. You have misunderstood the interpretation of the intercept. The intercept is the log odds (not the odds ratio) of the outcome when all the predictors are at 0 (not the marginal log odds
Why is the intercept changing in a logistic regression when all predictors are standardized? Welcome to CV. You have misunderstood the interpretation of the intercept. The intercept is the log odds (not the odds ratio) of the outcome when all the predictors are at 0 (not the marginal log odds, as you described). When the predictors are standardized, this corresponds to when all the raw predictors are at their mean. So, for an individual with average levels of each of the predictors, the intercept is the log odds of the outcome. This may not be an interpretable value because it might not make sense to think of an individual with average levels of all the predictors.
Why is the intercept changing in a logistic regression when all predictors are standardized? Welcome to CV. You have misunderstood the interpretation of the intercept. The intercept is the log odds (not the odds ratio) of the outcome when all the predictors are at 0 (not the marginal log odds
43,877
Why is the intercept changing in a logistic regression when all predictors are standardized?
an alternative explanation is the margin odds are incorporated into your fitted values. The ML gradient equations (set to 0) are equal to the following constraints.... $$\sum_i p_i = \sum_i y_i$$ $$\sum_i x_{1i}p_i = \sum_i x_{1i}y_i$$ ... $$\sum_i x_{ki}p_i = \sum_i x_{ki}y_i$$ Where $p_i$ is the fitted probability, $y_i$ is the 0-1 indicator you are modelling, and $x_{ji}$ is the jth predictor (with k predictors in total). The first constraint means for your data, the fitted probabilities always add up to 245 - this is regardless of what else you include in the model. So the "marginal log-odds" should be more like this... $$\log\left[\sum_i p_i\right] -\log\left[\sum_i (1-p_i)\right]$$ This will always equal to $\log\left[\frac{f}{1-f}\right]$ with $f$ being the total proportion of $y_i$ equal to 1 in the sample. whether the predictors are standardised or not
Why is the intercept changing in a logistic regression when all predictors are standardized?
an alternative explanation is the margin odds are incorporated into your fitted values. The ML gradient equations (set to 0) are equal to the following constraints.... $$\sum_i p_i = \sum_i y_i$$ $$\s
Why is the intercept changing in a logistic regression when all predictors are standardized? an alternative explanation is the margin odds are incorporated into your fitted values. The ML gradient equations (set to 0) are equal to the following constraints.... $$\sum_i p_i = \sum_i y_i$$ $$\sum_i x_{1i}p_i = \sum_i x_{1i}y_i$$ ... $$\sum_i x_{ki}p_i = \sum_i x_{ki}y_i$$ Where $p_i$ is the fitted probability, $y_i$ is the 0-1 indicator you are modelling, and $x_{ji}$ is the jth predictor (with k predictors in total). The first constraint means for your data, the fitted probabilities always add up to 245 - this is regardless of what else you include in the model. So the "marginal log-odds" should be more like this... $$\log\left[\sum_i p_i\right] -\log\left[\sum_i (1-p_i)\right]$$ This will always equal to $\log\left[\frac{f}{1-f}\right]$ with $f$ being the total proportion of $y_i$ equal to 1 in the sample. whether the predictors are standardised or not
Why is the intercept changing in a logistic regression when all predictors are standardized? an alternative explanation is the margin odds are incorporated into your fitted values. The ML gradient equations (set to 0) are equal to the following constraints.... $$\sum_i p_i = \sum_i y_i$$ $$\s
43,878
Why is the empirical cumulative distribution of 1:1000 a straight line?
The cumulative distribution function of a random variable $X$ has nothing to do with summing the random variable. It is the probability that $X$ will take a value less than or equal to $x$. And of course, the probability that a value randomly sampled from your vector $(1, \dots, 1000)$ is less than or equal to 200 is exactly half the probability that it is less than or equal to 400.
Why is the empirical cumulative distribution of 1:1000 a straight line?
The cumulative distribution function of a random variable $X$ has nothing to do with summing the random variable. It is the probability that $X$ will take a value less than or equal to $x$. And of c
Why is the empirical cumulative distribution of 1:1000 a straight line? The cumulative distribution function of a random variable $X$ has nothing to do with summing the random variable. It is the probability that $X$ will take a value less than or equal to $x$. And of course, the probability that a value randomly sampled from your vector $(1, \dots, 1000)$ is less than or equal to 200 is exactly half the probability that it is less than or equal to 400.
Why is the empirical cumulative distribution of 1:1000 a straight line? The cumulative distribution function of a random variable $X$ has nothing to do with summing the random variable. It is the probability that $X$ will take a value less than or equal to $x$. And of c
43,879
Why is the empirical cumulative distribution of 1:1000 a straight line?
Empirical cumulative distribution function is a cumulative sum of frequencies of observed $x_i$'s divided by total sample size. Your data is a vector of values from $1$ to $1000$, where each of the values appears exactly once. This means that your "variable" follows a discrete uniform distribution, that has a flat CDF. As you can see on the example below, it'd be different if you used other imput data. set.seed(123) x <- sample(0:1000, 1e5, replace = TRUE) y <- rnorm(1e5) def <- par(mfrow = c(1,2)) plot(ecdf(x)) plot(ecdf(y)) par(def) or z <- c(1,2,5,7,12,14,19,25,100,250,300,301,500,800,900,901,1000) plot(ecdf(z)) Notice that in the second example distances between different values are different so no matter that each value appeared only once, the line is curved.
Why is the empirical cumulative distribution of 1:1000 a straight line?
Empirical cumulative distribution function is a cumulative sum of frequencies of observed $x_i$'s divided by total sample size. Your data is a vector of values from $1$ to $1000$, where each of the va
Why is the empirical cumulative distribution of 1:1000 a straight line? Empirical cumulative distribution function is a cumulative sum of frequencies of observed $x_i$'s divided by total sample size. Your data is a vector of values from $1$ to $1000$, where each of the values appears exactly once. This means that your "variable" follows a discrete uniform distribution, that has a flat CDF. As you can see on the example below, it'd be different if you used other imput data. set.seed(123) x <- sample(0:1000, 1e5, replace = TRUE) y <- rnorm(1e5) def <- par(mfrow = c(1,2)) plot(ecdf(x)) plot(ecdf(y)) par(def) or z <- c(1,2,5,7,12,14,19,25,100,250,300,301,500,800,900,901,1000) plot(ecdf(z)) Notice that in the second example distances between different values are different so no matter that each value appeared only once, the line is curved.
Why is the empirical cumulative distribution of 1:1000 a straight line? Empirical cumulative distribution function is a cumulative sum of frequencies of observed $x_i$'s divided by total sample size. Your data is a vector of values from $1$ to $1000$, where each of the va
43,880
Why is the empirical cumulative distribution of 1:1000 a straight line?
You can think about it mechanically, too. The ECDF $\hat F$ evaluated at $x$ is the proportion of observations with value $x$ or below. Since you have exactly 1,000 observations $\{y_i\}_{i=i}^{1000}$, the difference between $\hat F(y_i)$ and $\hat F(y_{i+1})$ is always 0.001 for any $1 \le i < 1000$. Moreover, your sample values are evenly spaced, so the difference between $y_i$ and $y_{i+1}$ is always 1. Therefore, for any $1 \le i < 1000$, the slope between $\left(y_i, \hat F(y_i)\right)$ and $\left(y_{i+1}, \hat F(y_{i+1})\right)$ is always $\frac{0.001}{1}$. A curve with a constant slope is just a straight line. As for what you're misunderstanding, the $Fn$ you defined is definitely not the right formula. The denominator should be the number of observations, and the numerator should be the number of observations with value at or below $x_n$.
Why is the empirical cumulative distribution of 1:1000 a straight line?
You can think about it mechanically, too. The ECDF $\hat F$ evaluated at $x$ is the proportion of observations with value $x$ or below. Since you have exactly 1,000 observations $\{y_i\}_{i=i}^{1000}$
Why is the empirical cumulative distribution of 1:1000 a straight line? You can think about it mechanically, too. The ECDF $\hat F$ evaluated at $x$ is the proportion of observations with value $x$ or below. Since you have exactly 1,000 observations $\{y_i\}_{i=i}^{1000}$, the difference between $\hat F(y_i)$ and $\hat F(y_{i+1})$ is always 0.001 for any $1 \le i < 1000$. Moreover, your sample values are evenly spaced, so the difference between $y_i$ and $y_{i+1}$ is always 1. Therefore, for any $1 \le i < 1000$, the slope between $\left(y_i, \hat F(y_i)\right)$ and $\left(y_{i+1}, \hat F(y_{i+1})\right)$ is always $\frac{0.001}{1}$. A curve with a constant slope is just a straight line. As for what you're misunderstanding, the $Fn$ you defined is definitely not the right formula. The denominator should be the number of observations, and the numerator should be the number of observations with value at or below $x_n$.
Why is the empirical cumulative distribution of 1:1000 a straight line? You can think about it mechanically, too. The ECDF $\hat F$ evaluated at $x$ is the proportion of observations with value $x$ or below. Since you have exactly 1,000 observations $\{y_i\}_{i=i}^{1000}$
43,881
Why is the empirical cumulative distribution of 1:1000 a straight line?
The empirical distribution function of a sample $Y_1, ..., Y_n$ is defined as $$ \widehat{F}(x) = \frac{1}{n} \sum_{i=1}^{n} \mathcal{I} \{ Y_i \leq x \} $$ In your data set, $Y_i = i$. So, $ \widehat{F}(x) = x/n$, for $x = 1, 2, ..., 1000$. Plotted the way you did, this looks like a linear function of $x$.
Why is the empirical cumulative distribution of 1:1000 a straight line?
The empirical distribution function of a sample $Y_1, ..., Y_n$ is defined as $$ \widehat{F}(x) = \frac{1}{n} \sum_{i=1}^{n} \mathcal{I} \{ Y_i \leq x \} $$ In your data set, $Y_i = i$. So, $ \wideh
Why is the empirical cumulative distribution of 1:1000 a straight line? The empirical distribution function of a sample $Y_1, ..., Y_n$ is defined as $$ \widehat{F}(x) = \frac{1}{n} \sum_{i=1}^{n} \mathcal{I} \{ Y_i \leq x \} $$ In your data set, $Y_i = i$. So, $ \widehat{F}(x) = x/n$, for $x = 1, 2, ..., 1000$. Plotted the way you did, this looks like a linear function of $x$.
Why is the empirical cumulative distribution of 1:1000 a straight line? The empirical distribution function of a sample $Y_1, ..., Y_n$ is defined as $$ \widehat{F}(x) = \frac{1}{n} \sum_{i=1}^{n} \mathcal{I} \{ Y_i \leq x \} $$ In your data set, $Y_i = i$. So, $ \wideh
43,882
What is the optimal $k$ for the $k$ nearest neighbour classifier on the Iris dataset?
Lets say you want to use Accuracy (or % correct) to evaluate "optimal," and you have time to look at 25 values for k. The following R code will answer your question using 15 repeats of 10-fold cross-validation. It will also take a long time to run. library(caret) model <- train( Species~., data=iris, method='knn', tuneGrid=expand.grid(.k=1:25), metric='Accuracy', trControl=trainControl( method='repeatedcv', number=10, repeats=15)) model plot(model) > confusionMatrix(model) Cross-Validated (10 fold, repeated 15 times) Confusion Matrix (entries are percentages of table totals) Reference Prediction setosa versicolor virginica setosa 33.3 0.0 0.0 versicolor 0.0 31.9 1.2 virginica 0.0 1.4 32.1 So, by this criteria, I get an answer of 17, but it looks like the "true" value could lie anywhere between 5 and 20. You can substitute "Kappa" or some other metric if you want, and add more cv-folds as well. You can also try different methods of cross validation, such as leave-one-out, or bootstrap re-sampling. /Edit: in response for your request for variety, I wrote this function to calculate a variety of metrics for multi-class problems: #Multi-Class Summary Function #Based on caret:::twoClassSummary require(compiler) multiClassSummary <- cmpfun(function (data, lev = NULL, model = NULL){ #Load Libraries require(Metrics) require(caret) #Check data if (!all(levels(data[, "pred"]) == levels(data[, "obs"]))) stop("levels of observed and predicted data do not match") #Calculate custom one-vs-all stats for each class prob_stats <- lapply(levels(data[, "pred"]), function(class){ #Grab one-vs-all data for the class pred <- ifelse(data[, "pred"] == class, 1, 0) obs <- ifelse(data[, "obs"] == class, 1, 0) prob <- data[,class] #Calculate one-vs-all AUC and logLoss and return cap_prob <- pmin(pmax(prob, .000001), .999999) prob_stats <- c(auc(obs, prob), logLoss(obs, cap_prob)) names(prob_stats) <- c('ROC', 'logLoss') return(prob_stats) }) prob_stats <- do.call(rbind, prob_stats) rownames(prob_stats) <- paste('Class:', levels(data[, "pred"])) #Calculate confusion matrix-based statistics CM <- confusionMatrix(data[, "pred"], data[, "obs"]) #Aggregate and average class-wise stats #Todo: add weights class_stats <- cbind(CM$byClass, prob_stats) class_stats <- colMeans(class_stats) #Aggregate overall stats overall_stats <- c(CM$overall) #Combine overall with class-wise stats and remove some stats we don't want stats <- c(overall_stats, class_stats) stats <- stats[! names(stats) %in% c('AccuracyNull', 'Prevalence', 'Detection Prevalence')] #Clean names and return names(stats) <- gsub('[[:blank:]]+', '_', names(stats)) return(stats) }) It's a doozy of a function, so it's going to slow down caret a bit, but I'd be very happy if you posted the results of your 1000 repeats of 10-fold CV (I have neither the time not the computational capacity to attempt this at present). Here's my code for 15 repeats of 10-fold CV. Note that you can easily modify this code to try other re-sampling methods, such as bootstrap sampling: library(caret) set.seed(19556) model <- train( Species~., data=iris, method='knn', tuneGrid=expand.grid(.k=1:30), metric='Accuracy', trControl=trainControl( method='repeatedcv', number=10, repeats=15, classProbs=TRUE, summaryFunction=multiClassSummary)) Both ROC and LogLoss seem to peak around 8: While sensitivity and specificity seem to peak around 15: Here's some code to output all the plots as a pdf: dev.off() pdf('plots.pdf') for(stat in c('Accuracy', 'Kappa', 'AccuracyLower', 'AccuracyUpper', 'AccuracyPValue', 'Sensitivity', 'Specificity', 'Pos_Pred_Value', 'Neg_Pred_Value', 'Detection_Rate', 'ROC', 'logLoss')) { print(plot(model, metric=stat)) } dev.off() If you put a gun to my head, I'd probably say 8...
What is the optimal $k$ for the $k$ nearest neighbour classifier on the Iris dataset?
Lets say you want to use Accuracy (or % correct) to evaluate "optimal," and you have time to look at 25 values for k. The following R code will answer your question using 15 repeats of 10-fold cross-
What is the optimal $k$ for the $k$ nearest neighbour classifier on the Iris dataset? Lets say you want to use Accuracy (or % correct) to evaluate "optimal," and you have time to look at 25 values for k. The following R code will answer your question using 15 repeats of 10-fold cross-validation. It will also take a long time to run. library(caret) model <- train( Species~., data=iris, method='knn', tuneGrid=expand.grid(.k=1:25), metric='Accuracy', trControl=trainControl( method='repeatedcv', number=10, repeats=15)) model plot(model) > confusionMatrix(model) Cross-Validated (10 fold, repeated 15 times) Confusion Matrix (entries are percentages of table totals) Reference Prediction setosa versicolor virginica setosa 33.3 0.0 0.0 versicolor 0.0 31.9 1.2 virginica 0.0 1.4 32.1 So, by this criteria, I get an answer of 17, but it looks like the "true" value could lie anywhere between 5 and 20. You can substitute "Kappa" or some other metric if you want, and add more cv-folds as well. You can also try different methods of cross validation, such as leave-one-out, or bootstrap re-sampling. /Edit: in response for your request for variety, I wrote this function to calculate a variety of metrics for multi-class problems: #Multi-Class Summary Function #Based on caret:::twoClassSummary require(compiler) multiClassSummary <- cmpfun(function (data, lev = NULL, model = NULL){ #Load Libraries require(Metrics) require(caret) #Check data if (!all(levels(data[, "pred"]) == levels(data[, "obs"]))) stop("levels of observed and predicted data do not match") #Calculate custom one-vs-all stats for each class prob_stats <- lapply(levels(data[, "pred"]), function(class){ #Grab one-vs-all data for the class pred <- ifelse(data[, "pred"] == class, 1, 0) obs <- ifelse(data[, "obs"] == class, 1, 0) prob <- data[,class] #Calculate one-vs-all AUC and logLoss and return cap_prob <- pmin(pmax(prob, .000001), .999999) prob_stats <- c(auc(obs, prob), logLoss(obs, cap_prob)) names(prob_stats) <- c('ROC', 'logLoss') return(prob_stats) }) prob_stats <- do.call(rbind, prob_stats) rownames(prob_stats) <- paste('Class:', levels(data[, "pred"])) #Calculate confusion matrix-based statistics CM <- confusionMatrix(data[, "pred"], data[, "obs"]) #Aggregate and average class-wise stats #Todo: add weights class_stats <- cbind(CM$byClass, prob_stats) class_stats <- colMeans(class_stats) #Aggregate overall stats overall_stats <- c(CM$overall) #Combine overall with class-wise stats and remove some stats we don't want stats <- c(overall_stats, class_stats) stats <- stats[! names(stats) %in% c('AccuracyNull', 'Prevalence', 'Detection Prevalence')] #Clean names and return names(stats) <- gsub('[[:blank:]]+', '_', names(stats)) return(stats) }) It's a doozy of a function, so it's going to slow down caret a bit, but I'd be very happy if you posted the results of your 1000 repeats of 10-fold CV (I have neither the time not the computational capacity to attempt this at present). Here's my code for 15 repeats of 10-fold CV. Note that you can easily modify this code to try other re-sampling methods, such as bootstrap sampling: library(caret) set.seed(19556) model <- train( Species~., data=iris, method='knn', tuneGrid=expand.grid(.k=1:30), metric='Accuracy', trControl=trainControl( method='repeatedcv', number=10, repeats=15, classProbs=TRUE, summaryFunction=multiClassSummary)) Both ROC and LogLoss seem to peak around 8: While sensitivity and specificity seem to peak around 15: Here's some code to output all the plots as a pdf: dev.off() pdf('plots.pdf') for(stat in c('Accuracy', 'Kappa', 'AccuracyLower', 'AccuracyUpper', 'AccuracyPValue', 'Sensitivity', 'Specificity', 'Pos_Pred_Value', 'Neg_Pred_Value', 'Detection_Rate', 'ROC', 'logLoss')) { print(plot(model, metric=stat)) } dev.off() If you put a gun to my head, I'd probably say 8...
What is the optimal $k$ for the $k$ nearest neighbour classifier on the Iris dataset? Lets say you want to use Accuracy (or % correct) to evaluate "optimal," and you have time to look at 25 values for k. The following R code will answer your question using 15 repeats of 10-fold cross-
43,883
Can a binomial distribution have negative x values?
Poisson, binomial, Bernoulli, negative binomial, etc. are just model distributions - that is distributions that are analytically tractable and/or can be derived under rather simple assumptions. One could thus reformulate the question as: Are there known model discrete distributions with a support containing negative numbers? Then the question becomes obviously about how we define these discrete distributions - the most well-known ones are defined with support on non-negative integers. Specifically the binomial has support $$ k\in\{0,1,...,n\}$$ As @Tim pointed out in their answer, we can easily define a distribution with negative support, using the one with positive support. This brings us to the phenomena that we actually describe: thinking of a problem where negative counts arise naturally could suggest a distribution (which is not necessarily a known and/or model one.) However, many real counts are by nature positive - like the mentioned counts of monthly users (unless we explicitly shift the origin, just as in @Tim answer.) Remarks: Wikipedia has a list of discrete probability distributions, many of which are the distributions on integers. On a brief glance none of them has support extending to negative numbers. A similar question: Can the discrete variable be a negative number?
Can a binomial distribution have negative x values?
Poisson, binomial, Bernoulli, negative binomial, etc. are just model distributions - that is distributions that are analytically tractable and/or can be derived under rather simple assumptions. One co
Can a binomial distribution have negative x values? Poisson, binomial, Bernoulli, negative binomial, etc. are just model distributions - that is distributions that are analytically tractable and/or can be derived under rather simple assumptions. One could thus reformulate the question as: Are there known model discrete distributions with a support containing negative numbers? Then the question becomes obviously about how we define these discrete distributions - the most well-known ones are defined with support on non-negative integers. Specifically the binomial has support $$ k\in\{0,1,...,n\}$$ As @Tim pointed out in their answer, we can easily define a distribution with negative support, using the one with positive support. This brings us to the phenomena that we actually describe: thinking of a problem where negative counts arise naturally could suggest a distribution (which is not necessarily a known and/or model one.) However, many real counts are by nature positive - like the mentioned counts of monthly users (unless we explicitly shift the origin, just as in @Tim answer.) Remarks: Wikipedia has a list of discrete probability distributions, many of which are the distributions on integers. On a brief glance none of them has support extending to negative numbers. A similar question: Can the discrete variable be a negative number?
Can a binomial distribution have negative x values? Poisson, binomial, Bernoulli, negative binomial, etc. are just model distributions - that is distributions that are analytically tractable and/or can be derived under rather simple assumptions. One co
43,884
Can a binomial distribution have negative x values?
The binomial distribution is a distribution for a sum of Bernoulli trials: the sum of zeros and ones is non-negative. But it is not true that all discrete distributions are non-negative. For a trivial example, say that $X$ follows a Poisson distribution and you create another variable $Y = -X$. $Y$ would be discrete and all its values would be smaller than or equal to zero by definition. The distribution for $Y$ does not have a name (it's like a Poisson distribution, just look at the $-y$ values), but as noted in the comments, there are named examples like the Skellam distribution.
Can a binomial distribution have negative x values?
The binomial distribution is a distribution for a sum of Bernoulli trials: the sum of zeros and ones is non-negative. But it is not true that all discrete distributions are non-negative. For a trivial
Can a binomial distribution have negative x values? The binomial distribution is a distribution for a sum of Bernoulli trials: the sum of zeros and ones is non-negative. But it is not true that all discrete distributions are non-negative. For a trivial example, say that $X$ follows a Poisson distribution and you create another variable $Y = -X$. $Y$ would be discrete and all its values would be smaller than or equal to zero by definition. The distribution for $Y$ does not have a name (it's like a Poisson distribution, just look at the $-y$ values), but as noted in the comments, there are named examples like the Skellam distribution.
Can a binomial distribution have negative x values? The binomial distribution is a distribution for a sum of Bernoulli trials: the sum of zeros and ones is non-negative. But it is not true that all discrete distributions are non-negative. For a trivial
43,885
Can a binomial distribution have negative x values?
A less intuitive but important example for a discrete distribution with negative support would be the distribution of (unit or dollar) sales for a particular product at a given point of sale, conditional on various predictors like the day of the week, time of the year, promotions etc. This is discrete because most products are sold by units (and therefore, dollar sales are also discrete). It has potential negative support because of product returns. Anecdotally, US consumer electronics retailers have quite a problem with big screen TVs that are bought right before the Super Bowl and returned for a full refund right after the game.
Can a binomial distribution have negative x values?
A less intuitive but important example for a discrete distribution with negative support would be the distribution of (unit or dollar) sales for a particular product at a given point of sale, conditio
Can a binomial distribution have negative x values? A less intuitive but important example for a discrete distribution with negative support would be the distribution of (unit or dollar) sales for a particular product at a given point of sale, conditional on various predictors like the day of the week, time of the year, promotions etc. This is discrete because most products are sold by units (and therefore, dollar sales are also discrete). It has potential negative support because of product returns. Anecdotally, US consumer electronics retailers have quite a problem with big screen TVs that are bought right before the Super Bowl and returned for a full refund right after the game.
Can a binomial distribution have negative x values? A less intuitive but important example for a discrete distribution with negative support would be the distribution of (unit or dollar) sales for a particular product at a given point of sale, conditio
43,886
Coefficient of 0.001 with p < 0.005 [duplicate]
A simple thought experiment: suppose your predictor was a length, originally expressed in millimetres. If you express it instead in kilometres and fit the model again, you have not really changed anything meaningful about the relationship, but your coefficient will drop by several orders of magnitude. You can also get significant results with very low coefficients if you have a very large dataset.
Coefficient of 0.001 with p < 0.005 [duplicate]
A simple thought experiment: suppose your predictor was a length, originally expressed in millimetres. If you express it instead in kilometres and fit the model again, you have not really changed anyt
Coefficient of 0.001 with p < 0.005 [duplicate] A simple thought experiment: suppose your predictor was a length, originally expressed in millimetres. If you express it instead in kilometres and fit the model again, you have not really changed anything meaningful about the relationship, but your coefficient will drop by several orders of magnitude. You can also get significant results with very low coefficients if you have a very large dataset.
Coefficient of 0.001 with p < 0.005 [duplicate] A simple thought experiment: suppose your predictor was a length, originally expressed in millimetres. If you express it instead in kilometres and fit the model again, you have not really changed anyt
43,887
Coefficient of 0.001 with p < 0.005 [duplicate]
This is a known phenomenon, as p-values depend both on the effect size and the sample size. As you get many observations, you get convincing evidence that a tiny effect is real. In other words, that coefficient probably isn’t zero; you have a very unusual result for a situation where the coefficient isn’t zero. However, the effect isn’t necessarily enough to interest an investigator. “Yep, it’s not zero, but it’s not big enough to care.” What you say about scaling might matter. For instance, $0.001$ light years is still a pretty far distance if the other measurements are in centimeters.
Coefficient of 0.001 with p < 0.005 [duplicate]
This is a known phenomenon, as p-values depend both on the effect size and the sample size. As you get many observations, you get convincing evidence that a tiny effect is real. In other words, that c
Coefficient of 0.001 with p < 0.005 [duplicate] This is a known phenomenon, as p-values depend both on the effect size and the sample size. As you get many observations, you get convincing evidence that a tiny effect is real. In other words, that coefficient probably isn’t zero; you have a very unusual result for a situation where the coefficient isn’t zero. However, the effect isn’t necessarily enough to interest an investigator. “Yep, it’s not zero, but it’s not big enough to care.” What you say about scaling might matter. For instance, $0.001$ light years is still a pretty far distance if the other measurements are in centimeters.
Coefficient of 0.001 with p < 0.005 [duplicate] This is a known phenomenon, as p-values depend both on the effect size and the sample size. As you get many observations, you get convincing evidence that a tiny effect is real. In other words, that c
43,888
In ML, once we remove a feature, can we safely assume that feature will not be important again?
No, you cannot safely assume that. The reason is that conditional independence does not imply independence and vice versa (wiki). Moreover the forward selection style approach you follow suffers from a fundamental problem: model selection criteria like that usually rely on p-values/t-statistics/... To be based on the "correct" underlying model. This however can't be true if you do forward selection and a 'correct' feature is included only later on the process. That's why usually you should at least do backward selection - if you do any stepwise selection at all. That way the 'true' model is at least nested in the startimg model for selection. As has been mentioned in comments above, there are (much) better ways to do feature selection than a stepwise algorithm. At least try a LASSO approach.
In ML, once we remove a feature, can we safely assume that feature will not be important again?
No, you cannot safely assume that. The reason is that conditional independence does not imply independence and vice versa (wiki). Moreover the forward selection style approach you follow suffers from
In ML, once we remove a feature, can we safely assume that feature will not be important again? No, you cannot safely assume that. The reason is that conditional independence does not imply independence and vice versa (wiki). Moreover the forward selection style approach you follow suffers from a fundamental problem: model selection criteria like that usually rely on p-values/t-statistics/... To be based on the "correct" underlying model. This however can't be true if you do forward selection and a 'correct' feature is included only later on the process. That's why usually you should at least do backward selection - if you do any stepwise selection at all. That way the 'true' model is at least nested in the startimg model for selection. As has been mentioned in comments above, there are (much) better ways to do feature selection than a stepwise algorithm. At least try a LASSO approach.
In ML, once we remove a feature, can we safely assume that feature will not be important again? No, you cannot safely assume that. The reason is that conditional independence does not imply independence and vice versa (wiki). Moreover the forward selection style approach you follow suffers from
43,889
In ML, once we remove a feature, can we safely assume that feature will not be important again?
You seem to be assuming that the models work in additive fashion, so adding a feature to the model just "adds" some stuff related to this feature alone and does not influence the rest of the model, same with removing the feature. That is not the case. If machine learning models worked like this, then to build a model with $k$ features you would need only to build $k$ models with single feature and find a way of combining them. Here you can find a recent thread, and links to many other questions like this, where including new feature to regression model affects how the model uses the other features. This happens for linear regression, but will also be true for other machine learning algorithms. You say that you would assume this to be issue "only" when the variables are correlated, but with real-life data, there always will be some degree of correlation between the variables. Moreover, it is not only about correlations between pairs of variables, but also about relations between all of the variables, where those relations can be non-linear as well. You should be rather talking about independence, and seeing all variables independent is even less likely then seeing them all uncorrelated. More then this, by adding a new feature your algorithm needs to adapt. Imagine that you have a decision tree with the constraint to have not more then five samples in each final node. You cannot just add new feature to such tree without re-building it, because you already have not more then five samples in each final node, so you cannot split this node any further. In such case, you would need to re-build the whole tree, using different splits, or combinations of splits, so it would use your data in a different way then the initial tree. This would be the case even if the new feature that you are adding is independent of other features. What you propose is partially answered also in the Algorithms for automatic model selection thread, that discusses stepwise feature selection algorithms and the most upvoted answer shows how proceeding in such stepwise fashion by adding (or removing) variables leads to ending up with bad models. It simply doesn't work for the reasons discussed above.
In ML, once we remove a feature, can we safely assume that feature will not be important again?
You seem to be assuming that the models work in additive fashion, so adding a feature to the model just "adds" some stuff related to this feature alone and does not influence the rest of the model, sa
In ML, once we remove a feature, can we safely assume that feature will not be important again? You seem to be assuming that the models work in additive fashion, so adding a feature to the model just "adds" some stuff related to this feature alone and does not influence the rest of the model, same with removing the feature. That is not the case. If machine learning models worked like this, then to build a model with $k$ features you would need only to build $k$ models with single feature and find a way of combining them. Here you can find a recent thread, and links to many other questions like this, where including new feature to regression model affects how the model uses the other features. This happens for linear regression, but will also be true for other machine learning algorithms. You say that you would assume this to be issue "only" when the variables are correlated, but with real-life data, there always will be some degree of correlation between the variables. Moreover, it is not only about correlations between pairs of variables, but also about relations between all of the variables, where those relations can be non-linear as well. You should be rather talking about independence, and seeing all variables independent is even less likely then seeing them all uncorrelated. More then this, by adding a new feature your algorithm needs to adapt. Imagine that you have a decision tree with the constraint to have not more then five samples in each final node. You cannot just add new feature to such tree without re-building it, because you already have not more then five samples in each final node, so you cannot split this node any further. In such case, you would need to re-build the whole tree, using different splits, or combinations of splits, so it would use your data in a different way then the initial tree. This would be the case even if the new feature that you are adding is independent of other features. What you propose is partially answered also in the Algorithms for automatic model selection thread, that discusses stepwise feature selection algorithms and the most upvoted answer shows how proceeding in such stepwise fashion by adding (or removing) variables leads to ending up with bad models. It simply doesn't work for the reasons discussed above.
In ML, once we remove a feature, can we safely assume that feature will not be important again? You seem to be assuming that the models work in additive fashion, so adding a feature to the model just "adds" some stuff related to this feature alone and does not influence the rest of the model, sa
43,890
What's the event space of a single coin toss?
The event $\{H,T\}$ is that the result of the flip is either $H$ or $T$; this has probability $1$ The event $\emptyset = \{\,\}$ is that the result of the flip is neither $H$ nor $T$; this has probability $0$ So there is no problem; $\mathscr{F}= \{\emptyset,\{H\},\{T\},\{H,T\}\}$ as you might expect
What's the event space of a single coin toss?
The event $\{H,T\}$ is that the result of the flip is either $H$ or $T$; this has probability $1$ The event $\emptyset = \{\,\}$ is that the result of the flip is neither $H$ nor $T$; this has proba
What's the event space of a single coin toss? The event $\{H,T\}$ is that the result of the flip is either $H$ or $T$; this has probability $1$ The event $\emptyset = \{\,\}$ is that the result of the flip is neither $H$ nor $T$; this has probability $0$ So there is no problem; $\mathscr{F}= \{\emptyset,\{H\},\{T\},\{H,T\}\}$ as you might expect
What's the event space of a single coin toss? The event $\{H,T\}$ is that the result of the flip is either $H$ or $T$; this has probability $1$ The event $\emptyset = \{\,\}$ is that the result of the flip is neither $H$ nor $T$; this has proba
43,891
Probability that fewer than 24 people logging into the site will make a purchase [closed]
I agree with @whuber that none of the answers is exactly correct. However, if (oblivious to a continuity correction) you take the key probability to be $P(X < 24),$ round excessively, and do a normal approximation to binomial using printed tables, you get $0.8264.$ First, $\mu = np = 200(.1) = 20$ and $\sigma = \sqrt{np(1-p)} = 0.8250.$ Then $$P(X < 24) = P\left(\frac{X-\mu}{\sigma} < \frac{24-20}{0.8250}\right)\\ \approx P(Z < 0.94) = 0.8264,$$ where $Z$ is standard normal. You have to make just the right 'minor' errors in just the right order to get this answer. Unfortunately, there are textbooks that show these errors in examples. And there are multiple choice tests, in which one has to get used to picking the closest answer, instead of the exactly correct one.
Probability that fewer than 24 people logging into the site will make a purchase [closed]
I agree with @whuber that none of the answers is exactly correct. However, if (oblivious to a continuity correction) you take the key probability to be $P(X < 24),$ round excessively, and do a normal
Probability that fewer than 24 people logging into the site will make a purchase [closed] I agree with @whuber that none of the answers is exactly correct. However, if (oblivious to a continuity correction) you take the key probability to be $P(X < 24),$ round excessively, and do a normal approximation to binomial using printed tables, you get $0.8264.$ First, $\mu = np = 200(.1) = 20$ and $\sigma = \sqrt{np(1-p)} = 0.8250.$ Then $$P(X < 24) = P\left(\frac{X-\mu}{\sigma} < \frac{24-20}{0.8250}\right)\\ \approx P(Z < 0.94) = 0.8264,$$ where $Z$ is standard normal. You have to make just the right 'minor' errors in just the right order to get this answer. Unfortunately, there are textbooks that show these errors in examples. And there are multiple choice tests, in which one has to get used to picking the closest answer, instead of the exactly correct one.
Probability that fewer than 24 people logging into the site will make a purchase [closed] I agree with @whuber that none of the answers is exactly correct. However, if (oblivious to a continuity correction) you take the key probability to be $P(X < 24),$ round excessively, and do a normal
43,892
Probability that fewer than 24 people logging into the site will make a purchase [closed]
None of the answers is correct. Evidently the answer ought to be substantially greater than $1/2=0.5$ because the mean of this Binomial distribution is $20=200\times 0.1$ and the event "less than 24" includes all values less than the mean and a substantial number greater than it. This alone indicates (A) is the intended response. The correct probability is given by the cumulative value for the Binomial$(200, 0.1)$ distribution evaluated at $23.$ In R you can find this directly or add the individual probabilities, thus: > pbinom(23, 200, 0.1) [1] 0.7982976 or > sum(dbinom(0:23, 200, 0.1)) [1] 0.7982976 Often, textbook questions of this nature are expecting you to use a Normal approximation to the Binomial distribution. This approximation is based on matching the Binomial mean, $\mu=200\times 0.1,$ and the Binomial variance, $\sigma^2 = 200\times 0.1 \times (1-0.1),$ to a Normal distribution and evaluating its cumulative value at $23 + 1/2.$ In R this would be > pnorm(23 + 1/2, 200 * 0.1, sqrt(200 * 0.1 * (1-0.01))) [1] 0.7842322 As you can see, this is a good approximation but it still does not agree with any of the answer choices. I cannot find any variation of either approach that gives any of the answer choices. The closest I have been able to get is to use the exact Binomial calculation and average its values for $23$ and $24:$ > mean(pbinom(23:24, 200, 0.1)) [1] 0.8267018 However, this still does not agree with any of the choices exactly. As remarked in a comment, your method embodies a conceptual error: the event "less than 24" includes the possibility of zero, which you haven't included. However, zero is so unlikely that omitting it produces no appreciable error; its chance is > dbinom(0, 200, 0.1) [1] 7.055079e-10 This error could matter in other problems, though, so it's worth remembering.
Probability that fewer than 24 people logging into the site will make a purchase [closed]
None of the answers is correct. Evidently the answer ought to be substantially greater than $1/2=0.5$ because the mean of this Binomial distribution is $20=200\times 0.1$ and the event "less than 24"
Probability that fewer than 24 people logging into the site will make a purchase [closed] None of the answers is correct. Evidently the answer ought to be substantially greater than $1/2=0.5$ because the mean of this Binomial distribution is $20=200\times 0.1$ and the event "less than 24" includes all values less than the mean and a substantial number greater than it. This alone indicates (A) is the intended response. The correct probability is given by the cumulative value for the Binomial$(200, 0.1)$ distribution evaluated at $23.$ In R you can find this directly or add the individual probabilities, thus: > pbinom(23, 200, 0.1) [1] 0.7982976 or > sum(dbinom(0:23, 200, 0.1)) [1] 0.7982976 Often, textbook questions of this nature are expecting you to use a Normal approximation to the Binomial distribution. This approximation is based on matching the Binomial mean, $\mu=200\times 0.1,$ and the Binomial variance, $\sigma^2 = 200\times 0.1 \times (1-0.1),$ to a Normal distribution and evaluating its cumulative value at $23 + 1/2.$ In R this would be > pnorm(23 + 1/2, 200 * 0.1, sqrt(200 * 0.1 * (1-0.01))) [1] 0.7842322 As you can see, this is a good approximation but it still does not agree with any of the answer choices. I cannot find any variation of either approach that gives any of the answer choices. The closest I have been able to get is to use the exact Binomial calculation and average its values for $23$ and $24:$ > mean(pbinom(23:24, 200, 0.1)) [1] 0.8267018 However, this still does not agree with any of the choices exactly. As remarked in a comment, your method embodies a conceptual error: the event "less than 24" includes the possibility of zero, which you haven't included. However, zero is so unlikely that omitting it produces no appreciable error; its chance is > dbinom(0, 200, 0.1) [1] 7.055079e-10 This error could matter in other problems, though, so it's worth remembering.
Probability that fewer than 24 people logging into the site will make a purchase [closed] None of the answers is correct. Evidently the answer ought to be substantially greater than $1/2=0.5$ because the mean of this Binomial distribution is $20=200\times 0.1$ and the event "less than 24"
43,893
Negative relationship but regression analytics gives positive correlation coefficient
The correlation coefficient is $r$. $R^2$ is the square of $r$, and it is of course always positive, regardless of the sign of $r$. Taking the square root gives that $r= \pm 0.8489$, and since the relationship is negative, you can conclude that $r = -0.8489$.
Negative relationship but regression analytics gives positive correlation coefficient
The correlation coefficient is $r$. $R^2$ is the square of $r$, and it is of course always positive, regardless of the sign of $r$. Taking the square root gives that $r= \pm 0.8489$, and since the rel
Negative relationship but regression analytics gives positive correlation coefficient The correlation coefficient is $r$. $R^2$ is the square of $r$, and it is of course always positive, regardless of the sign of $r$. Taking the square root gives that $r= \pm 0.8489$, and since the relationship is negative, you can conclude that $r = -0.8489$.
Negative relationship but regression analytics gives positive correlation coefficient The correlation coefficient is $r$. $R^2$ is the square of $r$, and it is of course always positive, regardless of the sign of $r$. Taking the square root gives that $r= \pm 0.8489$, and since the rel
43,894
Negative relationship but regression analytics gives positive correlation coefficient
For additional context, $R^2$ is known as the coefficient of determination (often also called Pearson's R-squared) https://en.wikipedia.org/wiki/Coefficient_of_determination $R^2$ is a common measure of goodness of fit - it tells you something about how well your models predicts the test data. R in this interpretation is the correlation between the predicted y values (according to the line of best fit) and the test y values. In the single independent variable case, this is the same as the correlation between the independent and dependent variables, but this is not true in the multi regression.
Negative relationship but regression analytics gives positive correlation coefficient
For additional context, $R^2$ is known as the coefficient of determination (often also called Pearson's R-squared) https://en.wikipedia.org/wiki/Coefficient_of_determination $R^2$ is a common measure
Negative relationship but regression analytics gives positive correlation coefficient For additional context, $R^2$ is known as the coefficient of determination (often also called Pearson's R-squared) https://en.wikipedia.org/wiki/Coefficient_of_determination $R^2$ is a common measure of goodness of fit - it tells you something about how well your models predicts the test data. R in this interpretation is the correlation between the predicted y values (according to the line of best fit) and the test y values. In the single independent variable case, this is the same as the correlation between the independent and dependent variables, but this is not true in the multi regression.
Negative relationship but regression analytics gives positive correlation coefficient For additional context, $R^2$ is known as the coefficient of determination (often also called Pearson's R-squared) https://en.wikipedia.org/wiki/Coefficient_of_determination $R^2$ is a common measure
43,895
Negative relationship but regression analytics gives positive correlation coefficient
The other answers are correct, but I just wanted to add more detail in case you are interested in what is meant by these numbers. Suppose you were to draw a horizontal line on your graph which represented the average value of y, ie the average of the mortality rates in your data. For your example, 9.02 is approximately the average mortality. If you didn't have an explanatory variable (the proportion of women in parliament), the average of the mortality values (the horizontal line) would actually be your best guess for predicting a countries mortality. After all, if you didn't have any other data than the mortality values, what else could you do? The purpose of regression is to take one or more explanatory variables (the x variables) and find a better predictor of mortality for the country than simply the average of the mortality values. In other words, for your example, what you are saying is that if you know the countries proportion of women in parliament, you can make a much better guess of that countries mortality than simply saying "9.02". You instead give the value found on the dashed line. The value given by the dashed line is a much better estimate than simply using the horizontal line (the average value)! Thus, R^2 represents a percentage which can be thought of in this way: We can see there is a variation in the values of mortality for all the countries. How much of that variation in mortality values can we explain by using the dashed line instead of the horizontal line? In this case, we can explain about 72% of the variation in mortality values by also knowing the proportion of women in parliament. This is good, but not quite as good as an R^2 value of 1. If it was 1 then we would know exactly what the mortality value should be for each country by knowing the proportion of women in parliament, because the amount of variation explained would be 100%! Which is to say, if all the points fell on the dashed line there would be no variation from the points to the line. Further analysis and Conclusion Suppose that in addition to having the proportion of women in parliament, you also had a variable which represented the proportion of people in the country who are in poverty. One would suspect that using both of those variables together would give you an even better prediction of mortality rate for a country than either alone! And that's what regression hopes to accomplish. You consider all things which have a positive or negative correlation to the outcome variable of interest and come up with an equation that relates these explanatory variables to the outcome. As you add in more and more explanatory variables, you will find that you explain more and more of the variation in your outcome, which is to say your R^2 will be closer and closer to 1.
Negative relationship but regression analytics gives positive correlation coefficient
The other answers are correct, but I just wanted to add more detail in case you are interested in what is meant by these numbers. Suppose you were to draw a horizontal line on your graph which repre
Negative relationship but regression analytics gives positive correlation coefficient The other answers are correct, but I just wanted to add more detail in case you are interested in what is meant by these numbers. Suppose you were to draw a horizontal line on your graph which represented the average value of y, ie the average of the mortality rates in your data. For your example, 9.02 is approximately the average mortality. If you didn't have an explanatory variable (the proportion of women in parliament), the average of the mortality values (the horizontal line) would actually be your best guess for predicting a countries mortality. After all, if you didn't have any other data than the mortality values, what else could you do? The purpose of regression is to take one or more explanatory variables (the x variables) and find a better predictor of mortality for the country than simply the average of the mortality values. In other words, for your example, what you are saying is that if you know the countries proportion of women in parliament, you can make a much better guess of that countries mortality than simply saying "9.02". You instead give the value found on the dashed line. The value given by the dashed line is a much better estimate than simply using the horizontal line (the average value)! Thus, R^2 represents a percentage which can be thought of in this way: We can see there is a variation in the values of mortality for all the countries. How much of that variation in mortality values can we explain by using the dashed line instead of the horizontal line? In this case, we can explain about 72% of the variation in mortality values by also knowing the proportion of women in parliament. This is good, but not quite as good as an R^2 value of 1. If it was 1 then we would know exactly what the mortality value should be for each country by knowing the proportion of women in parliament, because the amount of variation explained would be 100%! Which is to say, if all the points fell on the dashed line there would be no variation from the points to the line. Further analysis and Conclusion Suppose that in addition to having the proportion of women in parliament, you also had a variable which represented the proportion of people in the country who are in poverty. One would suspect that using both of those variables together would give you an even better prediction of mortality rate for a country than either alone! And that's what regression hopes to accomplish. You consider all things which have a positive or negative correlation to the outcome variable of interest and come up with an equation that relates these explanatory variables to the outcome. As you add in more and more explanatory variables, you will find that you explain more and more of the variation in your outcome, which is to say your R^2 will be closer and closer to 1.
Negative relationship but regression analytics gives positive correlation coefficient The other answers are correct, but I just wanted to add more detail in case you are interested in what is meant by these numbers. Suppose you were to draw a horizontal line on your graph which repre
43,896
Why this simple mixed model fail to converge?
This is, in all likelihood, not a warning that you need to worry about. As you can see, the parameter estimates are the same in both cases. The version of lmer in lmertest apparently has a more conservative check for convergence than the current lme4 version. The problem in lmertest::lmer is caused by the variables being on vastly different scales, which can make some of the optimisation routines unstable, and thus generate the warning. If you re-scale, the problem vanishes: > df$value <- df$value / 10000 > lmerTest::lmer(value ~ factor(day_true) + (1 | culture), data = df) Linear mixed model fit by REML ['lmerModLmerTest'] Formula: value ~ factor(day_true) + (1 | culture) Data: df REML criterion at convergence: 29.1147 Random effects: Groups Name Std.Dev. culture (Intercept) 4.753 Residual 5.599 Number of obs: 6, groups: culture, 3 Fixed Effects: (Intercept) factor(day_true)83 75.315 -9.756 Note that, since you have only 3 groups, it may be better to model culture as fixed: > lm(value ~ factor(day_true) + culture, data = df) Coefficients: (Intercept) factor(day_true)83 culture 64.417 -9.756 5.449 Clearly the estimate for the fixed effect of day_true is the same in both analyses. The reason for not finding a statistically significant estimate, this is because the sample size is so small. It is highly preferable to run a "power analysis" prior to collecting data and fitting the model.
Why this simple mixed model fail to converge?
This is, in all likelihood, not a warning that you need to worry about. As you can see, the parameter estimates are the same in both cases. The version of lmer in lmertest apparently has a more conser
Why this simple mixed model fail to converge? This is, in all likelihood, not a warning that you need to worry about. As you can see, the parameter estimates are the same in both cases. The version of lmer in lmertest apparently has a more conservative check for convergence than the current lme4 version. The problem in lmertest::lmer is caused by the variables being on vastly different scales, which can make some of the optimisation routines unstable, and thus generate the warning. If you re-scale, the problem vanishes: > df$value <- df$value / 10000 > lmerTest::lmer(value ~ factor(day_true) + (1 | culture), data = df) Linear mixed model fit by REML ['lmerModLmerTest'] Formula: value ~ factor(day_true) + (1 | culture) Data: df REML criterion at convergence: 29.1147 Random effects: Groups Name Std.Dev. culture (Intercept) 4.753 Residual 5.599 Number of obs: 6, groups: culture, 3 Fixed Effects: (Intercept) factor(day_true)83 75.315 -9.756 Note that, since you have only 3 groups, it may be better to model culture as fixed: > lm(value ~ factor(day_true) + culture, data = df) Coefficients: (Intercept) factor(day_true)83 culture 64.417 -9.756 5.449 Clearly the estimate for the fixed effect of day_true is the same in both analyses. The reason for not finding a statistically significant estimate, this is because the sample size is so small. It is highly preferable to run a "power analysis" prior to collecting data and fitting the model.
Why this simple mixed model fail to converge? This is, in all likelihood, not a warning that you need to worry about. As you can see, the parameter estimates are the same in both cases. The version of lmer in lmertest apparently has a more conser
43,897
Why this simple mixed model fail to converge?
I can’t speak to the calculation issue, but six data points is not very much at all, much less if you want to fit random effects — of which you only have 2 and only 3 examples of each. The not-statistically-significant result makes a lot of sense here: you have a tiny amount of data that hints at something, but not enough to calculate anything well enough to draw any general conclusions. Your box plots are misleading you: it’s calculating means, quartiles, etc with only 3 numbers for each box. There are more visualized features than data in this case.
Why this simple mixed model fail to converge?
I can’t speak to the calculation issue, but six data points is not very much at all, much less if you want to fit random effects — of which you only have 2 and only 3 examples of each. The not-statist
Why this simple mixed model fail to converge? I can’t speak to the calculation issue, but six data points is not very much at all, much less if you want to fit random effects — of which you only have 2 and only 3 examples of each. The not-statistically-significant result makes a lot of sense here: you have a tiny amount of data that hints at something, but not enough to calculate anything well enough to draw any general conclusions. Your box plots are misleading you: it’s calculating means, quartiles, etc with only 3 numbers for each box. There are more visualized features than data in this case.
Why this simple mixed model fail to converge? I can’t speak to the calculation issue, but six data points is not very much at all, much less if you want to fit random effects — of which you only have 2 and only 3 examples of each. The not-statist
43,898
Why do we use the natural exponential in logistic regression?
Because base $e$ is convenient, and it doesn't matter if you can freely scale your coefficient estimate. Would using a functional form of $\frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} }$ change your explanatory power? No. Explanation: I gave basically the same answer here for the softmax function. Observe that $ e^ { \mathbf{x} \cdot \mathbf{b} \left( \ln a \right) } = a^ {\mathbf{x} \cdot \mathbf{b}}$. Hence: $$ \frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} } = \frac{e^\mathbf{x\cdot \tilde{b}}}{1 + e^\mathbf{x\cdot \tilde{b}} } $$ Where $\tilde{\mathbf{b}} = \left( \ln a \right) \mathbf{b} $. So using a different base than $e$ in the sigmoid function is the same as scaling your $\mathbf{b}$ vector.
Why do we use the natural exponential in logistic regression?
Because base $e$ is convenient, and it doesn't matter if you can freely scale your coefficient estimate. Would using a functional form of $\frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} }$ change
Why do we use the natural exponential in logistic regression? Because base $e$ is convenient, and it doesn't matter if you can freely scale your coefficient estimate. Would using a functional form of $\frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} }$ change your explanatory power? No. Explanation: I gave basically the same answer here for the softmax function. Observe that $ e^ { \mathbf{x} \cdot \mathbf{b} \left( \ln a \right) } = a^ {\mathbf{x} \cdot \mathbf{b}}$. Hence: $$ \frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} } = \frac{e^\mathbf{x\cdot \tilde{b}}}{1 + e^\mathbf{x\cdot \tilde{b}} } $$ Where $\tilde{\mathbf{b}} = \left( \ln a \right) \mathbf{b} $. So using a different base than $e$ in the sigmoid function is the same as scaling your $\mathbf{b}$ vector.
Why do we use the natural exponential in logistic regression? Because base $e$ is convenient, and it doesn't matter if you can freely scale your coefficient estimate. Would using a functional form of $\frac{a^\mathbf{x\cdot b}}{1 + a^\mathbf{x\cdot b} }$ change
43,899
Why do we use the natural exponential in logistic regression?
In binary regression, one can use any cdf to relate the probability $\mathbb{P}(Y=1|\mathbf{x})$ and $\mathbf{x}$ in a generalised linear way $$\mathbb{P}(Y=1|\mathbf{x})=\Phi(\mathbf{x}^\text{T}\beta)$$as in logistic cdf, $\Phi(t)=1/\{1+1/e^t\}$ probit (Normal) cdf, $\Phi(t)=\int_{-\infty}^t \varphi(x)\text{d}x$ log-log cdf, $\Phi(t)=\exp\{-\exp(-x)\}$ The logistic offers some advantages, as making the conditional regression an exponential family model.
Why do we use the natural exponential in logistic regression?
In binary regression, one can use any cdf to relate the probability $\mathbb{P}(Y=1|\mathbf{x})$ and $\mathbf{x}$ in a generalised linear way $$\mathbb{P}(Y=1|\mathbf{x})=\Phi(\mathbf{x}^\text{T}\beta
Why do we use the natural exponential in logistic regression? In binary regression, one can use any cdf to relate the probability $\mathbb{P}(Y=1|\mathbf{x})$ and $\mathbf{x}$ in a generalised linear way $$\mathbb{P}(Y=1|\mathbf{x})=\Phi(\mathbf{x}^\text{T}\beta)$$as in logistic cdf, $\Phi(t)=1/\{1+1/e^t\}$ probit (Normal) cdf, $\Phi(t)=\int_{-\infty}^t \varphi(x)\text{d}x$ log-log cdf, $\Phi(t)=\exp\{-\exp(-x)\}$ The logistic offers some advantages, as making the conditional regression an exponential family model.
Why do we use the natural exponential in logistic regression? In binary regression, one can use any cdf to relate the probability $\mathbb{P}(Y=1|\mathbf{x})$ and $\mathbf{x}$ in a generalised linear way $$\mathbb{P}(Y=1|\mathbf{x})=\Phi(\mathbf{x}^\text{T}\beta
43,900
Why do we use the natural exponential in logistic regression?
For a Bernoulli likelihood, the variance is a function of the mean such that: $$\text{var}(Y) = E(Y)(1-E(Y))$$ It turns out that a sigmoid function, also called the "inverse link" (for a logistic regression) function: $S(x) = \frac{\exp(x)}{1+\exp(x)}$ has the property that: $$\frac{\partial}{\partial x} S(X) = S(X)(1-S(X))$$ It turns out this property holds for all GLMs using canonical parametrizations for exponential families.
Why do we use the natural exponential in logistic regression?
For a Bernoulli likelihood, the variance is a function of the mean such that: $$\text{var}(Y) = E(Y)(1-E(Y))$$ It turns out that a sigmoid function, also called the "inverse link" (for a logistic regr
Why do we use the natural exponential in logistic regression? For a Bernoulli likelihood, the variance is a function of the mean such that: $$\text{var}(Y) = E(Y)(1-E(Y))$$ It turns out that a sigmoid function, also called the "inverse link" (for a logistic regression) function: $S(x) = \frac{\exp(x)}{1+\exp(x)}$ has the property that: $$\frac{\partial}{\partial x} S(X) = S(X)(1-S(X))$$ It turns out this property holds for all GLMs using canonical parametrizations for exponential families.
Why do we use the natural exponential in logistic regression? For a Bernoulli likelihood, the variance is a function of the mean such that: $$\text{var}(Y) = E(Y)(1-E(Y))$$ It turns out that a sigmoid function, also called the "inverse link" (for a logistic regr