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
42,501
Computing the Gini index
Gini index here ($G$, say) just calculates diversity or heterogeneity (or uncertainty if you will) from the sum of squared category probabilities. If every value is in the same category, then the measure is $1 - 1^2 = 0$. If every value of $n$ values is in a distinct category, then the measure is $1 - n(1/n)^2 = 1 - 1/n$. The complement is in some ways easier to think about, e.g. the reciprocal of the complement $1 / (1 - G)$ returns the "numbers equivalent", i.e. the equivalent number of equally common classes. Thus, the extremes for that are clearly $1/1$ and $1/(1/n)$, i.e. $1$ and $n$. Your columns $a_1$ and $a_2$ have 4 T and 5 F and 5T and 4F, respectively, which I get to be the same index, namely $1 - (4/9)^2 - (5/9)^2 = .4938271605$; that's a ridiculous number of decimal places, but it suggests that you have a gross error for one column and a rounding error for the other. With your $a_3$ the principle does not change, as the index ignores labels on the categories: whatever metric meaning they might have is not considered. By my calculation you have $1 - 5((1/9)^2) - 2 ((2/9)^2) = .8395061728$. Other names for this measure $G$ (or its complement, or the reciprocal of that) are Simpson, Herfindahl and repeat rate. Gini appears to have got there first, but its applications across ecology, economics, linguistics and many other fields are legion.
Computing the Gini index
Gini index here ($G$, say) just calculates diversity or heterogeneity (or uncertainty if you will) from the sum of squared category probabilities. If every value is in the same category, then the meas
Computing the Gini index Gini index here ($G$, say) just calculates diversity or heterogeneity (or uncertainty if you will) from the sum of squared category probabilities. If every value is in the same category, then the measure is $1 - 1^2 = 0$. If every value of $n$ values is in a distinct category, then the measure is $1 - n(1/n)^2 = 1 - 1/n$. The complement is in some ways easier to think about, e.g. the reciprocal of the complement $1 / (1 - G)$ returns the "numbers equivalent", i.e. the equivalent number of equally common classes. Thus, the extremes for that are clearly $1/1$ and $1/(1/n)$, i.e. $1$ and $n$. Your columns $a_1$ and $a_2$ have 4 T and 5 F and 5T and 4F, respectively, which I get to be the same index, namely $1 - (4/9)^2 - (5/9)^2 = .4938271605$; that's a ridiculous number of decimal places, but it suggests that you have a gross error for one column and a rounding error for the other. With your $a_3$ the principle does not change, as the index ignores labels on the categories: whatever metric meaning they might have is not considered. By my calculation you have $1 - 5((1/9)^2) - 2 ((2/9)^2) = .8395061728$. Other names for this measure $G$ (or its complement, or the reciprocal of that) are Simpson, Herfindahl and repeat rate. Gini appears to have got there first, but its applications across ecology, economics, linguistics and many other fields are legion.
Computing the Gini index Gini index here ($G$, say) just calculates diversity or heterogeneity (or uncertainty if you will) from the sum of squared category probabilities. If every value is in the same category, then the meas
42,502
Computing the Gini index
I'm sorry to bring back a question from ages ago, but it came as reference in a newer one and it looks to me like it might cause some misunderstandings. The calculations that Nick Cox gave are absolutely correct when computing the Gini index of the features, and help give us information about the features and their homogeneity. However, based on the fact that your dataset has a Target variable, that you speak of using Instance as attribute test condition and that you name at the end the information gain, it would be easy to think that you have a Classification Tree problem, and that the goal is finding the Gini decrease (equivalent to the Information Gain) when splitting (testing) on the features . I will therefore give an alternative answer to the question, that will serve as reference for Gini computation in case of Classification Trees. In this sense, the computations would be different. As a first step, you would need to compute the Gini index of the starting dataset. It has 4 positives and 5 negatives and therefore it is: $$GiniStart = 1-(\frac{4}{9})^2 - (\frac{5}{9})^2 \sim 0.4938$$ If we split on $a_1$ we obtain the node $T$ that has three positive instances and a negative one, and node $F$ that has one positive instance and four negative ones. $$Gini_T = 1-(\frac{3}{4})^2 - (\frac{1}{4})^2 = 0.375$$ $$Gini_F = 1-(\frac{1}{5})^2 - (\frac{4}{5})^2 = 0.32$$ $$\Delta Gini_{a_1} = GiniStart - \frac{4}{9}Gini_T -\frac{5}{9}Gini_N \sim 0.149 $$ If we split on $a_2$ we obtain the node $T$ that has 2 positive instances and 3 negative ones, and node $F$ that has 2 positive instances and 2 negative ones. $$Gini_T = 1-(\frac{2}{5})^2 - (\frac{3}{5})^2 = 0.48$$ $$Gini_F = 1-(\frac{2}{4})^2 - (\frac{2}{4})^2 = 0.5$$ $$\Delta Gini_{a_2} = GiniStart - \frac{5}{9}Gini_T -\frac{4}{9}Gini_N \sim 0.005$$ $a_3$ is instead a numeric variables (even though you could treat it as categorical), and as such we would need to evaluate every possible split in their range (which I am of course not going to do) and choose the best one. As an example, imagine splitting $a_3$ in $4.5$. Then we would have the "Low Values" node, with 2 positives and a negative, and the "High Values" node, with 2 poisitives and 4 negatives. $$Gini_{LV} = 1-(\frac{2}{3})^2 - (\frac{1}{3})^2 = 0.44$$ $$Gini_{HV} = 1-(\frac{2}{6})^2 - (\frac{4}{6})^2 = 0.44$$ $$\Delta Gini_{a_3} = GiniStart - \frac{3}{9}Gini_{LV} -\frac{6}{9}Gini_{HV} \sim 0.049$$ Finally $Instance$. If we consider it as categorical, the variable is totally sparse, and it allows us to split it into groups ${1,2,4,8}$ and ${3,5,6,7,9}$, that would both have a Gini of $0$ since they are pure. The Gini increase would therefore be the Gini of the parent node. However, attributes like $Instance$ are completely sparse and have no predicting power on new data (every new entry will have a different instance number), and for this reason are usually excluded. Alternatively, one can use the Gini ratio for the splits. That is, weight the Gini decreases by the inverse of the Gini coefficient of the attributes (this time, it's the ones computed by Nick!). This way, importance of sparse variables such as $Instance$ is reduced by the fact that their Gini coefficient is very high. Please mind that my answer is not in contradiction with Nick's, but it is simply answering a different question, since it might have been also interpreted differently. PS: just for clarification, as the information gain term was used: Information Gain is almost equivalent to difference in Gini index, and it is computed as difference in Entropy.
Computing the Gini index
I'm sorry to bring back a question from ages ago, but it came as reference in a newer one and it looks to me like it might cause some misunderstandings. The calculations that Nick Cox gave are absolu
Computing the Gini index I'm sorry to bring back a question from ages ago, but it came as reference in a newer one and it looks to me like it might cause some misunderstandings. The calculations that Nick Cox gave are absolutely correct when computing the Gini index of the features, and help give us information about the features and their homogeneity. However, based on the fact that your dataset has a Target variable, that you speak of using Instance as attribute test condition and that you name at the end the information gain, it would be easy to think that you have a Classification Tree problem, and that the goal is finding the Gini decrease (equivalent to the Information Gain) when splitting (testing) on the features . I will therefore give an alternative answer to the question, that will serve as reference for Gini computation in case of Classification Trees. In this sense, the computations would be different. As a first step, you would need to compute the Gini index of the starting dataset. It has 4 positives and 5 negatives and therefore it is: $$GiniStart = 1-(\frac{4}{9})^2 - (\frac{5}{9})^2 \sim 0.4938$$ If we split on $a_1$ we obtain the node $T$ that has three positive instances and a negative one, and node $F$ that has one positive instance and four negative ones. $$Gini_T = 1-(\frac{3}{4})^2 - (\frac{1}{4})^2 = 0.375$$ $$Gini_F = 1-(\frac{1}{5})^2 - (\frac{4}{5})^2 = 0.32$$ $$\Delta Gini_{a_1} = GiniStart - \frac{4}{9}Gini_T -\frac{5}{9}Gini_N \sim 0.149 $$ If we split on $a_2$ we obtain the node $T$ that has 2 positive instances and 3 negative ones, and node $F$ that has 2 positive instances and 2 negative ones. $$Gini_T = 1-(\frac{2}{5})^2 - (\frac{3}{5})^2 = 0.48$$ $$Gini_F = 1-(\frac{2}{4})^2 - (\frac{2}{4})^2 = 0.5$$ $$\Delta Gini_{a_2} = GiniStart - \frac{5}{9}Gini_T -\frac{4}{9}Gini_N \sim 0.005$$ $a_3$ is instead a numeric variables (even though you could treat it as categorical), and as such we would need to evaluate every possible split in their range (which I am of course not going to do) and choose the best one. As an example, imagine splitting $a_3$ in $4.5$. Then we would have the "Low Values" node, with 2 positives and a negative, and the "High Values" node, with 2 poisitives and 4 negatives. $$Gini_{LV} = 1-(\frac{2}{3})^2 - (\frac{1}{3})^2 = 0.44$$ $$Gini_{HV} = 1-(\frac{2}{6})^2 - (\frac{4}{6})^2 = 0.44$$ $$\Delta Gini_{a_3} = GiniStart - \frac{3}{9}Gini_{LV} -\frac{6}{9}Gini_{HV} \sim 0.049$$ Finally $Instance$. If we consider it as categorical, the variable is totally sparse, and it allows us to split it into groups ${1,2,4,8}$ and ${3,5,6,7,9}$, that would both have a Gini of $0$ since they are pure. The Gini increase would therefore be the Gini of the parent node. However, attributes like $Instance$ are completely sparse and have no predicting power on new data (every new entry will have a different instance number), and for this reason are usually excluded. Alternatively, one can use the Gini ratio for the splits. That is, weight the Gini decreases by the inverse of the Gini coefficient of the attributes (this time, it's the ones computed by Nick!). This way, importance of sparse variables such as $Instance$ is reduced by the fact that their Gini coefficient is very high. Please mind that my answer is not in contradiction with Nick's, but it is simply answering a different question, since it might have been also interpreted differently. PS: just for clarification, as the information gain term was used: Information Gain is almost equivalent to difference in Gini index, and it is computed as difference in Entropy.
Computing the Gini index I'm sorry to bring back a question from ages ago, but it came as reference in a newer one and it looks to me like it might cause some misunderstandings. The calculations that Nick Cox gave are absolu
42,503
Cronbach's Alpha with missing data
If data are MCAR, one would like to find an unbiased estimated of alpha. This could possibly be done via multiple imputation or listwise deletion. However, the latter might lead to severe loss of data. A third way is something like pairwise deletion which is implemented via an na.rm option in alpha() of the ltm package and in cronbach.alpha() of the psych package. At least IMHO, the former estimate of unstandardized alpha with missing data is biased (see below). This is due to the calculation of the total variance $\sigma^2_x$ via var(rowSums(dat, na.rm = TRUE)). If the data are centered around 0, positive and negative values cancel each other out in the calculation of rowSums. With missing data, this leads to a bias of rowSums towards 0 and therefore to an underestimation of $\sigma^2_x$ (and alpha, in turn). Contrarily, if the data are mostly positive (or negative), missings will lead to a bias of rowSums towards zero this time resulting in an overestimation of $\sigma^2_x$ (and alpha, in turn). require("MASS"); require("ltm"); require("psych") n <- 10000 it <- 20 V <- matrix(.4, ncol = it, nrow = it) diag(V) <- 1 dat <- mvrnorm(n, rep(0, it), V) # mean of 0!!! p <- c(0, .1, .2, .3) names(p) <- paste("% miss=", p, sep="") cols <- c("alpha.ltm", "var.tot.ltm", "alpha.psych", "var.tot.psych") names(cols) <- cols res <- matrix(nrow = length(p), ncol = length(cols), dimnames = list(names(p), names(cols))) for(i in 1:length(p)){ m1 <- matrix(rbinom(n * it, 1, p[i]), nrow = n, ncol = it) dat1 <- dat dat1[m1 == 1] <- NA res[i, 1] <- cronbach.alpha(dat1, standardized = FALSE, na.rm = TRUE)$alpha res[i, 2] <- var(rowSums(dat1, na.rm = TRUE)) res[i, 3] <- alpha(as.data.frame(dat1), na.rm = TRUE)$total[[1]] res[i, 4] <- sum(cov(dat1, use = "pairwise")) } round(res, 2) ## alpha.ltm var.tot.ltm alpha.psych var.tot.psych ## % miss=0 0.93 168.35 0.93 168.35 ## % miss=0.1 0.90 138.21 0.93 168.32 ## % miss=0.2 0.86 110.34 0.93 167.88 ## % miss=0.3 0.81 86.26 0.93 167.41 dat <- mvrnorm(n, rep(10, it), V) # this time, mean of 10!!! for(i in 1:length(p)){ m1 <- matrix(rbinom(n * it, 1, p[i]), nrow = n, ncol = it) dat1 <- dat dat1[m1 == 1] <- NA res[i, 1] <- cronbach.alpha(dat1, standardized = FALSE, na.rm = TRUE)$alpha res[i, 2] <- var(rowSums(dat1, na.rm = TRUE)) res[i, 3] <- alpha(as.data.frame(dat1), na.rm = TRUE)$total[[1]] res[i, 4] <- sum(cov(dat1, use = "pairwise")) } round(res, 2) ## alpha.ltm var.tot.ltm alpha.psych var.tot.psych ## % miss=0 0.93 168.31 0.93 168.31 ## % miss=0.1 0.99 316.27 0.93 168.60 ## % miss=0.2 1.00 430.78 0.93 167.61 ## % miss=0.3 1.01 511.30 0.93 167.43
Cronbach's Alpha with missing data
If data are MCAR, one would like to find an unbiased estimated of alpha. This could possibly be done via multiple imputation or listwise deletion. However, the latter might lead to severe loss of data
Cronbach's Alpha with missing data If data are MCAR, one would like to find an unbiased estimated of alpha. This could possibly be done via multiple imputation or listwise deletion. However, the latter might lead to severe loss of data. A third way is something like pairwise deletion which is implemented via an na.rm option in alpha() of the ltm package and in cronbach.alpha() of the psych package. At least IMHO, the former estimate of unstandardized alpha with missing data is biased (see below). This is due to the calculation of the total variance $\sigma^2_x$ via var(rowSums(dat, na.rm = TRUE)). If the data are centered around 0, positive and negative values cancel each other out in the calculation of rowSums. With missing data, this leads to a bias of rowSums towards 0 and therefore to an underestimation of $\sigma^2_x$ (and alpha, in turn). Contrarily, if the data are mostly positive (or negative), missings will lead to a bias of rowSums towards zero this time resulting in an overestimation of $\sigma^2_x$ (and alpha, in turn). require("MASS"); require("ltm"); require("psych") n <- 10000 it <- 20 V <- matrix(.4, ncol = it, nrow = it) diag(V) <- 1 dat <- mvrnorm(n, rep(0, it), V) # mean of 0!!! p <- c(0, .1, .2, .3) names(p) <- paste("% miss=", p, sep="") cols <- c("alpha.ltm", "var.tot.ltm", "alpha.psych", "var.tot.psych") names(cols) <- cols res <- matrix(nrow = length(p), ncol = length(cols), dimnames = list(names(p), names(cols))) for(i in 1:length(p)){ m1 <- matrix(rbinom(n * it, 1, p[i]), nrow = n, ncol = it) dat1 <- dat dat1[m1 == 1] <- NA res[i, 1] <- cronbach.alpha(dat1, standardized = FALSE, na.rm = TRUE)$alpha res[i, 2] <- var(rowSums(dat1, na.rm = TRUE)) res[i, 3] <- alpha(as.data.frame(dat1), na.rm = TRUE)$total[[1]] res[i, 4] <- sum(cov(dat1, use = "pairwise")) } round(res, 2) ## alpha.ltm var.tot.ltm alpha.psych var.tot.psych ## % miss=0 0.93 168.35 0.93 168.35 ## % miss=0.1 0.90 138.21 0.93 168.32 ## % miss=0.2 0.86 110.34 0.93 167.88 ## % miss=0.3 0.81 86.26 0.93 167.41 dat <- mvrnorm(n, rep(10, it), V) # this time, mean of 10!!! for(i in 1:length(p)){ m1 <- matrix(rbinom(n * it, 1, p[i]), nrow = n, ncol = it) dat1 <- dat dat1[m1 == 1] <- NA res[i, 1] <- cronbach.alpha(dat1, standardized = FALSE, na.rm = TRUE)$alpha res[i, 2] <- var(rowSums(dat1, na.rm = TRUE)) res[i, 3] <- alpha(as.data.frame(dat1), na.rm = TRUE)$total[[1]] res[i, 4] <- sum(cov(dat1, use = "pairwise")) } round(res, 2) ## alpha.ltm var.tot.ltm alpha.psych var.tot.psych ## % miss=0 0.93 168.31 0.93 168.31 ## % miss=0.1 0.99 316.27 0.93 168.60 ## % miss=0.2 1.00 430.78 0.93 167.61 ## % miss=0.3 1.01 511.30 0.93 167.43
Cronbach's Alpha with missing data If data are MCAR, one would like to find an unbiased estimated of alpha. This could possibly be done via multiple imputation or listwise deletion. However, the latter might lead to severe loss of data
42,504
What diagnostics for random effects logistic regression?
It is true that there is not much information about diagnostics for random effects logistic models. R package influence.ME provides tools for detecting influential data in mixed effects models, e.g. DFBETAS, Cook's Distance. There is a similar function in Stata, gllamm, including DFBETAS and Cook's Distance to detect influence points, empirical Bayes (EB) prediction of higher-level residuals, and detecting outliers by cross-validation. For population average models, e.g. generalized estimating equations (GEE) models, there is a section "13.3 Residual analysis and diagnostics" in the book Applied Longitudinal Analysis by Garrett M. Fitzmaurice, Nan M. Laird, James H. Ware. There is also an example of using cumulative sums of residuals to assess the adequacy of the model.
What diagnostics for random effects logistic regression?
It is true that there is not much information about diagnostics for random effects logistic models. R package influence.ME provides tools for detecting influential data in mixed effects models, e.g.
What diagnostics for random effects logistic regression? It is true that there is not much information about diagnostics for random effects logistic models. R package influence.ME provides tools for detecting influential data in mixed effects models, e.g. DFBETAS, Cook's Distance. There is a similar function in Stata, gllamm, including DFBETAS and Cook's Distance to detect influence points, empirical Bayes (EB) prediction of higher-level residuals, and detecting outliers by cross-validation. For population average models, e.g. generalized estimating equations (GEE) models, there is a section "13.3 Residual analysis and diagnostics" in the book Applied Longitudinal Analysis by Garrett M. Fitzmaurice, Nan M. Laird, James H. Ware. There is also an example of using cumulative sums of residuals to assess the adequacy of the model.
What diagnostics for random effects logistic regression? It is true that there is not much information about diagnostics for random effects logistic models. R package influence.ME provides tools for detecting influential data in mixed effects models, e.g.
42,505
Is Hoeffding's bound tight in any way?
A trivial example would be if $X_i$ is deterministic (say always equal to 0). The right hand side would then be the dirac mass at 0 (as seen in the proof of Hoeffding's inequality). There can't be any other example as that would contradict the hypothesis that $\bar{X}$ is bounded, since $$ 0 < C \exp\left( -\frac{2n^2 t^2}{\sum_{i=1}^n (b_i-a_i)}\right) \leq P( \bar{X} \geq E[\bar{X}] + t) \qquad \forall t \geq 0 $$
Is Hoeffding's bound tight in any way?
A trivial example would be if $X_i$ is deterministic (say always equal to 0). The right hand side would then be the dirac mass at 0 (as seen in the proof of Hoeffding's inequality). There can't be an
Is Hoeffding's bound tight in any way? A trivial example would be if $X_i$ is deterministic (say always equal to 0). The right hand side would then be the dirac mass at 0 (as seen in the proof of Hoeffding's inequality). There can't be any other example as that would contradict the hypothesis that $\bar{X}$ is bounded, since $$ 0 < C \exp\left( -\frac{2n^2 t^2}{\sum_{i=1}^n (b_i-a_i)}\right) \leq P( \bar{X} \geq E[\bar{X}] + t) \qquad \forall t \geq 0 $$
Is Hoeffding's bound tight in any way? A trivial example would be if $X_i$ is deterministic (say always equal to 0). The right hand side would then be the dirac mass at 0 (as seen in the proof of Hoeffding's inequality). There can't be an
42,506
Is Hoeffding's bound tight in any way?
I'm not sure if you can say something for every $n$ (and all distributions) for Hoeffding precisely. For Chernoff you can say that the moment bound is tighter than the Chernoff bound. In the linked paper the author also notes (but defers the proof to the citation, that for large $t$, if $C(t)$ is the Chernoff bound then, $$\Pr(X>t) \leq C(t)exp(-\mathcal{o}(t)) $$ where $\mathcal{o}(t)$ is the usual 'little oh' notation (value going to 0 as $t \to \infty$) implying that $\Pr(X>t) \leq C(t)$ for large $t$. The proof method in the linked Philips and Nelson paper would apply for the Hoeffding case as well. The reference cited in the paper for this proof is is the Large Deviations books by Bucklew, here is a link to the google books page for the book. If you want the proof hopefully you can find a copy via your local university library.
Is Hoeffding's bound tight in any way?
I'm not sure if you can say something for every $n$ (and all distributions) for Hoeffding precisely. For Chernoff you can say that the moment bound is tighter than the Chernoff bound. In the linked pa
Is Hoeffding's bound tight in any way? I'm not sure if you can say something for every $n$ (and all distributions) for Hoeffding precisely. For Chernoff you can say that the moment bound is tighter than the Chernoff bound. In the linked paper the author also notes (but defers the proof to the citation, that for large $t$, if $C(t)$ is the Chernoff bound then, $$\Pr(X>t) \leq C(t)exp(-\mathcal{o}(t)) $$ where $\mathcal{o}(t)$ is the usual 'little oh' notation (value going to 0 as $t \to \infty$) implying that $\Pr(X>t) \leq C(t)$ for large $t$. The proof method in the linked Philips and Nelson paper would apply for the Hoeffding case as well. The reference cited in the paper for this proof is is the Large Deviations books by Bucklew, here is a link to the google books page for the book. If you want the proof hopefully you can find a copy via your local university library.
Is Hoeffding's bound tight in any way? I'm not sure if you can say something for every $n$ (and all distributions) for Hoeffding precisely. For Chernoff you can say that the moment bound is tighter than the Chernoff bound. In the linked pa
42,507
Fitting a "sigmoid" function: Why is my fit so bad?
It appears that you have a misspecified functional form in your model. You are fitting a particular type of sigmoid function, but there are lots of types of sigmoid functions besides that one. Sigmoid functions are mostly discussed in the context of link functions for the regression of binary data. You can get some information about the different possibilities that exist from my answer here: Is the logit function always the best for regression modeling of binary data? A particular link / sigmoid function that looks like it might be appropriate is the complementary log log. You can see a picture of how that compares to the logit and probit links (with a little discussion) in my answer here: Difference between logit and probit models. I would suggest trying the cloglog.
Fitting a "sigmoid" function: Why is my fit so bad?
It appears that you have a misspecified functional form in your model. You are fitting a particular type of sigmoid function, but there are lots of types of sigmoid functions besides that one. Sigmo
Fitting a "sigmoid" function: Why is my fit so bad? It appears that you have a misspecified functional form in your model. You are fitting a particular type of sigmoid function, but there are lots of types of sigmoid functions besides that one. Sigmoid functions are mostly discussed in the context of link functions for the regression of binary data. You can get some information about the different possibilities that exist from my answer here: Is the logit function always the best for regression modeling of binary data? A particular link / sigmoid function that looks like it might be appropriate is the complementary log log. You can see a picture of how that compares to the logit and probit links (with a little discussion) in my answer here: Difference between logit and probit models. I would suggest trying the cloglog.
Fitting a "sigmoid" function: Why is my fit so bad? It appears that you have a misspecified functional form in your model. You are fitting a particular type of sigmoid function, but there are lots of types of sigmoid functions besides that one. Sigmo
42,508
Simple linear regression with a random predictor
The answer to 1 is no which makes the answers to all the others not applicable. Let me start with your last equation: \begin{align} y_i = \alpha + \beta w_i + \epsilon_i \end{align} Now, let's assume that your earlier equations for $y$ and $w$ are valid classical linear regression models, so that $Cov(x,\epsilon_1)=0$ and $Cov(x,\epsilon_2)=0$. I'm not sure what SLR stands for---Simple Linear Regression? Anyway, now let's calculate $Cov(w,\epsilon)$ in order to verify whether your new equation is part of a valid classical linear regression model (recall that we need this to be zero): \begin{align} Cov(w,\epsilon) &= Cov(w,\epsilon_1-\frac{\beta_1}{\beta_2}\epsilon_2) \\ \strut \\ &= Cov(w,\epsilon_1) - \frac{\beta_1}{\beta_2}Cov(w,\epsilon_2) \\ \strut \\ &= Cov(\epsilon_2,\epsilon_1) - \frac{\beta_1}{\beta_2}V(\epsilon_2) \end{align} The second term is not zero unless $\beta_1=0$, and that would make the example pretty silly. Even the first term is not likely to be zero in most physical applications. For that term to be zero, you would have to make the additional assumption that the errors made by the two instruments were completely uncorrelated. You could get wildly lucky (in a stopped-clock-is-right-twice-a-day kind of sense) and the two terms could magically cancel out, but there is no systematic tendency of the two terms to cancel out. The bias in estimating $\beta$ will be: \begin{align} \frac{Cov(\epsilon_2,\epsilon_1) - \frac{\beta_1}{\beta_2}V(\epsilon_2)}{V(w)} \end{align} Below, I attach a bit of R code which makes a toy monte carlo to demonstrate the effect. The theoretical bias in the monte carlo is -0.25 and the answer we get in the monte carlo is too low by 0.23. So, demonstrates the point pretty well. In general, even if you can't see how to evaluate the bias in an example like this, you can always run a little monte carlo to see what is going on. This is one of the great things about statistical software languages. Monte Carlo simulations are amazingly powerful tools to give you feedback as to whether your ideas are really good or really not. # This program written in response to a Cross Validated question # http://stats.stackexchange.com/questions/74527/simple-linear-regression-with-a-random-predictor # The program is a toy monte carlo. # It generates a "true" but unobservable-to-the-analyst physical state x. # Then it generates two measurements of that state from different instruments. # Then it regresses one measurement on the other. set.seed(12344321) # True state, 1000 runs of the experiment x <- rnorm(1000) # Set the various parameters of the monte carlo # Play with these for fun and profit: alpha_1 <- 0 alpha_2 <- 0 beta_1 <- 1 beta_2 <- 1 stddev_e1 <- 1 stddev_e2 <- 1 corr_e1e2 <- 0.5 # Fallible measurements e_1 <- stddev_e1*rnorm(1000) e_2 <- stddev_e2*(corr_e1e2*e_1+sqrt(1-corr_e1e2^2)*rnorm(1000)) y <- alpha_1 + beta_1*x + e_1 w <- alpha_2 + beta_2*x + e_2 var(data.frame(e_1,e_2)) var(data.frame(x,w,y)) lm(y~x) lm(w~x) # By the bias formula in the answer, this regression should have a bias of # -0.25 = (0.5-1*1)/2. That is, the coefficient should not be close to 1, # the correct value of beta_1/beta_2. Instead, it should be close # to 0.75 - 1-0.25 lm(y~w)
Simple linear regression with a random predictor
The answer to 1 is no which makes the answers to all the others not applicable. Let me start with your last equation: \begin{align} y_i = \alpha + \beta w_i + \epsilon_i \end{align} Now, let's assume
Simple linear regression with a random predictor The answer to 1 is no which makes the answers to all the others not applicable. Let me start with your last equation: \begin{align} y_i = \alpha + \beta w_i + \epsilon_i \end{align} Now, let's assume that your earlier equations for $y$ and $w$ are valid classical linear regression models, so that $Cov(x,\epsilon_1)=0$ and $Cov(x,\epsilon_2)=0$. I'm not sure what SLR stands for---Simple Linear Regression? Anyway, now let's calculate $Cov(w,\epsilon)$ in order to verify whether your new equation is part of a valid classical linear regression model (recall that we need this to be zero): \begin{align} Cov(w,\epsilon) &= Cov(w,\epsilon_1-\frac{\beta_1}{\beta_2}\epsilon_2) \\ \strut \\ &= Cov(w,\epsilon_1) - \frac{\beta_1}{\beta_2}Cov(w,\epsilon_2) \\ \strut \\ &= Cov(\epsilon_2,\epsilon_1) - \frac{\beta_1}{\beta_2}V(\epsilon_2) \end{align} The second term is not zero unless $\beta_1=0$, and that would make the example pretty silly. Even the first term is not likely to be zero in most physical applications. For that term to be zero, you would have to make the additional assumption that the errors made by the two instruments were completely uncorrelated. You could get wildly lucky (in a stopped-clock-is-right-twice-a-day kind of sense) and the two terms could magically cancel out, but there is no systematic tendency of the two terms to cancel out. The bias in estimating $\beta$ will be: \begin{align} \frac{Cov(\epsilon_2,\epsilon_1) - \frac{\beta_1}{\beta_2}V(\epsilon_2)}{V(w)} \end{align} Below, I attach a bit of R code which makes a toy monte carlo to demonstrate the effect. The theoretical bias in the monte carlo is -0.25 and the answer we get in the monte carlo is too low by 0.23. So, demonstrates the point pretty well. In general, even if you can't see how to evaluate the bias in an example like this, you can always run a little monte carlo to see what is going on. This is one of the great things about statistical software languages. Monte Carlo simulations are amazingly powerful tools to give you feedback as to whether your ideas are really good or really not. # This program written in response to a Cross Validated question # http://stats.stackexchange.com/questions/74527/simple-linear-regression-with-a-random-predictor # The program is a toy monte carlo. # It generates a "true" but unobservable-to-the-analyst physical state x. # Then it generates two measurements of that state from different instruments. # Then it regresses one measurement on the other. set.seed(12344321) # True state, 1000 runs of the experiment x <- rnorm(1000) # Set the various parameters of the monte carlo # Play with these for fun and profit: alpha_1 <- 0 alpha_2 <- 0 beta_1 <- 1 beta_2 <- 1 stddev_e1 <- 1 stddev_e2 <- 1 corr_e1e2 <- 0.5 # Fallible measurements e_1 <- stddev_e1*rnorm(1000) e_2 <- stddev_e2*(corr_e1e2*e_1+sqrt(1-corr_e1e2^2)*rnorm(1000)) y <- alpha_1 + beta_1*x + e_1 w <- alpha_2 + beta_2*x + e_2 var(data.frame(e_1,e_2)) var(data.frame(x,w,y)) lm(y~x) lm(w~x) # By the bias formula in the answer, this regression should have a bias of # -0.25 = (0.5-1*1)/2. That is, the coefficient should not be close to 1, # the correct value of beta_1/beta_2. Instead, it should be close # to 0.75 - 1-0.25 lm(y~w)
Simple linear regression with a random predictor The answer to 1 is no which makes the answers to all the others not applicable. Let me start with your last equation: \begin{align} y_i = \alpha + \beta w_i + \epsilon_i \end{align} Now, let's assume
42,509
Conditional Logit for recommender systems?
Preface I work with recommender systems on daily basis and have also never heard of the application of such a model as recommender system. I can only speculate about the reasons though. The main overall reason might be that recommender systems are often applied in a domain where the price/cost of an item is too small to force the customer to invest time into making a nearly-optimal decision, maximizing his utility. This should be kept in mind in the following section. Such domains include e-commerce or news portals (where articles are recommended) or sites like tastekid.com, where the decision at this step costs only a click, i.e. virtually nothing. Reasoning The described conditional multinomial model requires (or works best) with ... characteristics of the customer characteristics of the items assumed rationality when it comes to the decision Let's step through every point Characteristics of the customers Beside some basic demographic information like gender, address and (may be) age, little is known. The less the price of an item (see above), the harder it is to request a survey before the selection process starts. Activity data (bought items, ratings etc.) on the other hand can be collected without any work from the customer and can be used to describe the customer, following the motto "you are what you are interested in". The items the customer is interested in (the preferences) implicitly capture what is important to the customer. Characteristics of the items Building a model based on the characteristics of a item is already done, either via "content based collaborative filtering" or a model based approach. These are e.g. used to solve the cold-start-problem, i.e. the fresh new recommender system has not (enough) preferences yet. The drawback here however is that is hard to automatically collect the properties of an item. Imagine the case of fashion: Some are easy (color, brand), some are very hard (how does the cloth feels like on skin, how does it look if my hip is broader than average). Sometime it is completely impossible because it entirely depends on the reception of the product, e.g. in case of movies. For certain items, such information can be collected by humans or by a very very sophisticated system understanding semantics and language. It is not clear that the resulting improvement will outweigh the costs. So instead of saying: "Item A is similar to item B due to the properties p1,p2,...," it is easier to say "a lot of people have both bought item A and item B. I don't know why, but they are similar enough for the purpose of a recommender system". So the preferences implicitly capture how similar to items are. Assumed rationality when it comes to the decision We are humans and we pretend to be rational all the time. If e.g. the price or other circumstances forces us to think hard about it a decision, it might be the case that the rational part of a decision is higher than average. But when it comes to utilize advertising to sell people stuff (and yes, recommendations can be seen as advertising), marketing will tell that rationality plays a lesser role. Additionally, people are often do not know beforehand which properties are most important to them in order to maximize their personal utility function. If this would be the case, all buying processes could be described via the usage of a search engine, where a) all relevant properties are listed b) the customer selects all properties relevant to him and name the product of interest and the search engine delivers exactly the right results. Instead, people have a basic goal (e.g. buying a suit), but then are browsing around to see how products appeal to them and / or to get inspired. Making a buy decision is still partially rational (budget, invested time) but often comes down to "what feels right". Of course, every domain has its own distribution of rationality and emotionality. The more technical, the more facts do play an important role. But even than the customer might select a brand due to the curtain fire of advertising, which he would not have named as primary criterion beforehand. So building a economic model here might be still be working and it surely correct, buth might be entirely over the top. Additionally, one might have to build a separate model for each type of item a shop is selling. Summary Building a recommender system entirely based on preferences is often done because ... it is simple (=> cheap) it can be done automatically, no extra work from the customer is required (=> cheap) it works (good enough), so that a more complicated model might not outweigh the additional costs. But: There are domains, where such a economic model will be better. I do not doubt, that a good estate agent and hence a good expert system based on a economic model will easily outperform a recommender system based on preferences. I have regularly observed that recommendations made by human experts are often better than automatic ones. However, the automatics are still good and can produced en mass without too much costs, so that an expert can focus on more sophisticated tasks.
Conditional Logit for recommender systems?
Preface I work with recommender systems on daily basis and have also never heard of the application of such a model as recommender system. I can only speculate about the reasons though. The main overa
Conditional Logit for recommender systems? Preface I work with recommender systems on daily basis and have also never heard of the application of such a model as recommender system. I can only speculate about the reasons though. The main overall reason might be that recommender systems are often applied in a domain where the price/cost of an item is too small to force the customer to invest time into making a nearly-optimal decision, maximizing his utility. This should be kept in mind in the following section. Such domains include e-commerce or news portals (where articles are recommended) or sites like tastekid.com, where the decision at this step costs only a click, i.e. virtually nothing. Reasoning The described conditional multinomial model requires (or works best) with ... characteristics of the customer characteristics of the items assumed rationality when it comes to the decision Let's step through every point Characteristics of the customers Beside some basic demographic information like gender, address and (may be) age, little is known. The less the price of an item (see above), the harder it is to request a survey before the selection process starts. Activity data (bought items, ratings etc.) on the other hand can be collected without any work from the customer and can be used to describe the customer, following the motto "you are what you are interested in". The items the customer is interested in (the preferences) implicitly capture what is important to the customer. Characteristics of the items Building a model based on the characteristics of a item is already done, either via "content based collaborative filtering" or a model based approach. These are e.g. used to solve the cold-start-problem, i.e. the fresh new recommender system has not (enough) preferences yet. The drawback here however is that is hard to automatically collect the properties of an item. Imagine the case of fashion: Some are easy (color, brand), some are very hard (how does the cloth feels like on skin, how does it look if my hip is broader than average). Sometime it is completely impossible because it entirely depends on the reception of the product, e.g. in case of movies. For certain items, such information can be collected by humans or by a very very sophisticated system understanding semantics and language. It is not clear that the resulting improvement will outweigh the costs. So instead of saying: "Item A is similar to item B due to the properties p1,p2,...," it is easier to say "a lot of people have both bought item A and item B. I don't know why, but they are similar enough for the purpose of a recommender system". So the preferences implicitly capture how similar to items are. Assumed rationality when it comes to the decision We are humans and we pretend to be rational all the time. If e.g. the price or other circumstances forces us to think hard about it a decision, it might be the case that the rational part of a decision is higher than average. But when it comes to utilize advertising to sell people stuff (and yes, recommendations can be seen as advertising), marketing will tell that rationality plays a lesser role. Additionally, people are often do not know beforehand which properties are most important to them in order to maximize their personal utility function. If this would be the case, all buying processes could be described via the usage of a search engine, where a) all relevant properties are listed b) the customer selects all properties relevant to him and name the product of interest and the search engine delivers exactly the right results. Instead, people have a basic goal (e.g. buying a suit), but then are browsing around to see how products appeal to them and / or to get inspired. Making a buy decision is still partially rational (budget, invested time) but often comes down to "what feels right". Of course, every domain has its own distribution of rationality and emotionality. The more technical, the more facts do play an important role. But even than the customer might select a brand due to the curtain fire of advertising, which he would not have named as primary criterion beforehand. So building a economic model here might be still be working and it surely correct, buth might be entirely over the top. Additionally, one might have to build a separate model for each type of item a shop is selling. Summary Building a recommender system entirely based on preferences is often done because ... it is simple (=> cheap) it can be done automatically, no extra work from the customer is required (=> cheap) it works (good enough), so that a more complicated model might not outweigh the additional costs. But: There are domains, where such a economic model will be better. I do not doubt, that a good estate agent and hence a good expert system based on a economic model will easily outperform a recommender system based on preferences. I have regularly observed that recommendations made by human experts are often better than automatic ones. However, the automatics are still good and can produced en mass without too much costs, so that an expert can focus on more sophisticated tasks.
Conditional Logit for recommender systems? Preface I work with recommender systems on daily basis and have also never heard of the application of such a model as recommender system. I can only speculate about the reasons though. The main overa
42,510
What are some examples of problems for which various techniques are well suited
This is an interesting question - in a lot of ways, it's really the question in Machine Learning. The short version of the answer is something like this: your choice of model is very important, but there are no silver bullets or magic hammers to be had; with a few notable exceptions, it's worth thinking of all of the techniques that you've learned as tools to be used in the right situation. The actual choice that takes place usually involves some analysis, some visualization, some intuition, some experience, and a little bit of voodoo (which is to say, luck). I'll answer you in two parts: One, I'll give examples of problems suited to particular models, and two, I'll outline some approaches that I take when I'm first setting things up. Consider the problem of image recognition in a complex environment. It's not an easy problem to solve; it can often deal with rich features and different levels of abstraction. In this case, one might try a neural network of some variety(let's say something fancy, like a convolutional net): this has the advantage of being a very expressive model, which might be just the power tools needed to model the complex interrelationships of the variables. Of course, the penalty paid is that the algorithm can be rather expensive; however, it might be that this slowness is justified given the advantage conferred by the richness of the model. Now, consider the very different problem of finding the general trend in noisy time-series data over a long span of time; let's say our choices are "going up" or "going down". In this case, one might be tempted to use a very complicated solution like the neural net above; as we mentioned, it would be a powerful tool, which could explain complicated relationships in the data. On the other hand, for a question with such a limited scope, it might be useful to simply use OLS regression and look at the slope of a linear equation fit to the data. It would be quick and dirty, but it would probably do the job. In this situation, the Neural Network might be monstrous overkill. You'll probably notice that there is a lot of "maybe" and "may" and "it's possible" in my answer above. Unfortunately, there tend to be no hard and fast rules. When I think about what model to use, I think of the following criteria, which at least puts me in the right direction (hopefully): What are the computational constraints? (For example, if I need to provide fast estimates to a user on a webpage based on dynamic inputs, I won't be using a deep network). What does the data look like when it's visualized? For regression problems, does the input resemble any mathematical functions I know? Can any transformations be applied to it? For clustering, are there any obvious patterns? How are the clusters shaped, approximately? How sparse or dense is the data set? What is the propensity for overfitting? How easy would it be to perform cross-validation? After that, it's a matter of using experience and doing some experimental tests, then improving on it. It's just as much an art as it is a science, which makes it as tough as it is exciting. I hoped that helped; tell me if you have any questions. Good luck! EDIT: As a short addendum, and in answer to the specific questions you posed: expressive models such as NN are useful when the data contains many rich relationships; however, the models you call "rigid" can be very useful when complexity is a major issue and/or when the general form of the data can be predicted in some way (for example, "the data looks like a linear function with some noise"). Edit edit: Wait, one more thing - I've never found the approach of "unleash all the algorithms and see what sticks" to be useful. In my opinion, the single most important skills one can cultivate in this field is to understand why certain problems are best solved by certain solutions; it'll save you huge amounts of time.
What are some examples of problems for which various techniques are well suited
This is an interesting question - in a lot of ways, it's really the question in Machine Learning. The short version of the answer is something like this: your choice of model is very important, but th
What are some examples of problems for which various techniques are well suited This is an interesting question - in a lot of ways, it's really the question in Machine Learning. The short version of the answer is something like this: your choice of model is very important, but there are no silver bullets or magic hammers to be had; with a few notable exceptions, it's worth thinking of all of the techniques that you've learned as tools to be used in the right situation. The actual choice that takes place usually involves some analysis, some visualization, some intuition, some experience, and a little bit of voodoo (which is to say, luck). I'll answer you in two parts: One, I'll give examples of problems suited to particular models, and two, I'll outline some approaches that I take when I'm first setting things up. Consider the problem of image recognition in a complex environment. It's not an easy problem to solve; it can often deal with rich features and different levels of abstraction. In this case, one might try a neural network of some variety(let's say something fancy, like a convolutional net): this has the advantage of being a very expressive model, which might be just the power tools needed to model the complex interrelationships of the variables. Of course, the penalty paid is that the algorithm can be rather expensive; however, it might be that this slowness is justified given the advantage conferred by the richness of the model. Now, consider the very different problem of finding the general trend in noisy time-series data over a long span of time; let's say our choices are "going up" or "going down". In this case, one might be tempted to use a very complicated solution like the neural net above; as we mentioned, it would be a powerful tool, which could explain complicated relationships in the data. On the other hand, for a question with such a limited scope, it might be useful to simply use OLS regression and look at the slope of a linear equation fit to the data. It would be quick and dirty, but it would probably do the job. In this situation, the Neural Network might be monstrous overkill. You'll probably notice that there is a lot of "maybe" and "may" and "it's possible" in my answer above. Unfortunately, there tend to be no hard and fast rules. When I think about what model to use, I think of the following criteria, which at least puts me in the right direction (hopefully): What are the computational constraints? (For example, if I need to provide fast estimates to a user on a webpage based on dynamic inputs, I won't be using a deep network). What does the data look like when it's visualized? For regression problems, does the input resemble any mathematical functions I know? Can any transformations be applied to it? For clustering, are there any obvious patterns? How are the clusters shaped, approximately? How sparse or dense is the data set? What is the propensity for overfitting? How easy would it be to perform cross-validation? After that, it's a matter of using experience and doing some experimental tests, then improving on it. It's just as much an art as it is a science, which makes it as tough as it is exciting. I hoped that helped; tell me if you have any questions. Good luck! EDIT: As a short addendum, and in answer to the specific questions you posed: expressive models such as NN are useful when the data contains many rich relationships; however, the models you call "rigid" can be very useful when complexity is a major issue and/or when the general form of the data can be predicted in some way (for example, "the data looks like a linear function with some noise"). Edit edit: Wait, one more thing - I've never found the approach of "unleash all the algorithms and see what sticks" to be useful. In my opinion, the single most important skills one can cultivate in this field is to understand why certain problems are best solved by certain solutions; it'll save you huge amounts of time.
What are some examples of problems for which various techniques are well suited This is an interesting question - in a lot of ways, it's really the question in Machine Learning. The short version of the answer is something like this: your choice of model is very important, but th
42,511
Finding the highest probability balls
While the problem is in general intractable, your motivating example assumes independent events, which provides more than enough structure to solve this problem. Let me restate what you are trying to show to make sure that I understand: You have $n$ independent Binomial random variables $X_i\sim \mathrm{Binomial}(p_i)$, $i=1,\dotsc,n$. Your goal is to find a point $\hat x \in \{0, 1\}^n$ that maximizes the probability $$\mathbb{P}\{\mathrm{d}_H(\hat x, {X})\le k\},$$ where $\mathrm{d}_H$ denotes the Hamming metric and ${X}=(X_1,\dotsc,X_n)$ is the vector of binomial random variables. Because of independence, the answer is trivial: Choose the most likely point, i.e., set $$ \hat{x}_i = \begin{cases} 0,& p_i \le 0.5 \\ 1, &p_i >0.5.\end{cases}$$ Let's see why this is true using induction. The recipe above is trivially true for $n=1$. Let $n>1$ and suppose that the recipe holds for $n-1$. Then by independence, $$ \mathbb{P}\{ \mathrm{d}_H(x,X)\le k\} = \mathbb{P}\{x_n = X_n\} \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k\} + \mathbb{P}\{x_n \ne X_n\} \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k-1\}$$ where we use the shorthand $x^{(n-1)} = (x_1,\dotsc,x_{n-1})$. By the induction hypothesis, our best possible choice of $x^{(n-1)}$ is $\hat{x}^{(n-1)}$, the most likely point of $X^{(n-1)}$. Moreover, since we always have $$\mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k\} \ge \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)})\le k-1\},$$ we should always choose ${x}_n$ to maximize $\mathbb{P}\{\hat x_n = X_n\}$, which is the claimed recipe. # Near independence? Independence is clearly a very strong assumption, but in many cases we have reason to believe that the elements are nearly independent. On common way to measure the "nearness" of (say, binary) random variables $X$ and $Y$ is the total variation metric: $$ d_{TV}(X,Y):= \sup_{A \subset \{0,1\}^n} | \mathbb{P}\{ X \in A\} - \mathbb{P}\{Y\in A\} | $$ Taking, for example, $A:= \{y \mid d_H(x,y) \le k\}$, we find that for any binary random variables $X$, $Y$ $$ |\mathbb{P}\{ d_H(x, X) \le k\} - \mathbb{P}\{d_H(x,Y)\le k\}| \le d_{TV}(X,Y).$$ We conclude that when $Y$ is "almost independent" in the sense that the TV norm distance to an RV variable $X$ with independent entries is very small, then it is possible to argue that taking $\hat x$ to be the most likely vector for $X$ is a also a good choice for $Y$. Care must be taken to apply this logic, however. First of all, I've given no clue how to compute a TV metric; you'll need to use the specific facts at hand and some ingenuity. A more subtle danger lies in the fact that the TV norm estimate will typically be useless unless $k$ is large. This is because the supremum in the TV will often occur for sets $A$ with measure near $1/2$. Unless $k$ is large, it is likely that the Hamming ball of width $k$ has miniscule measure compared to the TV norm. You may be able to refine your arguments somewhat, but the ability to control the error using this approach is (once again) strongly dependent on your particular situation.
Finding the highest probability balls
While the problem is in general intractable, your motivating example assumes independent events, which provides more than enough structure to solve this problem. Let me restate what you are trying to
Finding the highest probability balls While the problem is in general intractable, your motivating example assumes independent events, which provides more than enough structure to solve this problem. Let me restate what you are trying to show to make sure that I understand: You have $n$ independent Binomial random variables $X_i\sim \mathrm{Binomial}(p_i)$, $i=1,\dotsc,n$. Your goal is to find a point $\hat x \in \{0, 1\}^n$ that maximizes the probability $$\mathbb{P}\{\mathrm{d}_H(\hat x, {X})\le k\},$$ where $\mathrm{d}_H$ denotes the Hamming metric and ${X}=(X_1,\dotsc,X_n)$ is the vector of binomial random variables. Because of independence, the answer is trivial: Choose the most likely point, i.e., set $$ \hat{x}_i = \begin{cases} 0,& p_i \le 0.5 \\ 1, &p_i >0.5.\end{cases}$$ Let's see why this is true using induction. The recipe above is trivially true for $n=1$. Let $n>1$ and suppose that the recipe holds for $n-1$. Then by independence, $$ \mathbb{P}\{ \mathrm{d}_H(x,X)\le k\} = \mathbb{P}\{x_n = X_n\} \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k\} + \mathbb{P}\{x_n \ne X_n\} \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k-1\}$$ where we use the shorthand $x^{(n-1)} = (x_1,\dotsc,x_{n-1})$. By the induction hypothesis, our best possible choice of $x^{(n-1)}$ is $\hat{x}^{(n-1)}$, the most likely point of $X^{(n-1)}$. Moreover, since we always have $$\mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)}) \le k\} \ge \mathbb{P}\{\mathrm{d}_H({x}^{(n-1)}, X^{(n-1)})\le k-1\},$$ we should always choose ${x}_n$ to maximize $\mathbb{P}\{\hat x_n = X_n\}$, which is the claimed recipe. # Near independence? Independence is clearly a very strong assumption, but in many cases we have reason to believe that the elements are nearly independent. On common way to measure the "nearness" of (say, binary) random variables $X$ and $Y$ is the total variation metric: $$ d_{TV}(X,Y):= \sup_{A \subset \{0,1\}^n} | \mathbb{P}\{ X \in A\} - \mathbb{P}\{Y\in A\} | $$ Taking, for example, $A:= \{y \mid d_H(x,y) \le k\}$, we find that for any binary random variables $X$, $Y$ $$ |\mathbb{P}\{ d_H(x, X) \le k\} - \mathbb{P}\{d_H(x,Y)\le k\}| \le d_{TV}(X,Y).$$ We conclude that when $Y$ is "almost independent" in the sense that the TV norm distance to an RV variable $X$ with independent entries is very small, then it is possible to argue that taking $\hat x$ to be the most likely vector for $X$ is a also a good choice for $Y$. Care must be taken to apply this logic, however. First of all, I've given no clue how to compute a TV metric; you'll need to use the specific facts at hand and some ingenuity. A more subtle danger lies in the fact that the TV norm estimate will typically be useless unless $k$ is large. This is because the supremum in the TV will often occur for sets $A$ with measure near $1/2$. Unless $k$ is large, it is likely that the Hamming ball of width $k$ has miniscule measure compared to the TV norm. You may be able to refine your arguments somewhat, but the ability to control the error using this approach is (once again) strongly dependent on your particular situation.
Finding the highest probability balls While the problem is in general intractable, your motivating example assumes independent events, which provides more than enough structure to solve this problem. Let me restate what you are trying to
42,512
Weighted least squares to correct for heteroscedasticity
It appears you know the whole technique, so I will only deal with the specific question - and the answer is: You should use the sample sizes that relate to the "explanatory" variables - I guess this is what you mean by "independent", i.e. of the regressors. This comes out of the following: In a regression setting, we make assumptions about the error term conditional on the regressors: namely in a (matrix notation) model $$ \mathbf y = \mathbf X\beta + \mathbf u$$ we specify $E(\mathbf u \mid \mathbf X) = 0,\; E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf I$. In a heteroskedastic setting, we essentially think of conditional heteroskedasticity, namely, we assume (or suspect) that $$E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf \Omega $$ Since the expected value is conditional on $\mathbf X$, it will be a function of $\mathbf X$, (and not of $\mathbf y$ which is included in the error term), i.e. $\mathbf \Omega = g(\mathbf X) $. So for logical consistency, you must use characteristics related to the regressors in order to theoretically model heteroskedasticity, and then apply weighted least-squares.
Weighted least squares to correct for heteroscedasticity
It appears you know the whole technique, so I will only deal with the specific question - and the answer is: You should use the sample sizes that relate to the "explanatory" variables - I guess this i
Weighted least squares to correct for heteroscedasticity It appears you know the whole technique, so I will only deal with the specific question - and the answer is: You should use the sample sizes that relate to the "explanatory" variables - I guess this is what you mean by "independent", i.e. of the regressors. This comes out of the following: In a regression setting, we make assumptions about the error term conditional on the regressors: namely in a (matrix notation) model $$ \mathbf y = \mathbf X\beta + \mathbf u$$ we specify $E(\mathbf u \mid \mathbf X) = 0,\; E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf I$. In a heteroskedastic setting, we essentially think of conditional heteroskedasticity, namely, we assume (or suspect) that $$E(\mathbf u \mathbf u'\mid \mathbf X) = \sigma^2\mathbf \Omega $$ Since the expected value is conditional on $\mathbf X$, it will be a function of $\mathbf X$, (and not of $\mathbf y$ which is included in the error term), i.e. $\mathbf \Omega = g(\mathbf X) $. So for logical consistency, you must use characteristics related to the regressors in order to theoretically model heteroskedasticity, and then apply weighted least-squares.
Weighted least squares to correct for heteroscedasticity It appears you know the whole technique, so I will only deal with the specific question - and the answer is: You should use the sample sizes that relate to the "explanatory" variables - I guess this i
42,513
Performing "all-possible regressions" in R
After re-reading your question, I believe you mean to ask about model selection among your candidate predictor variables, and not actually running all possible regressions. Fitting all possible models from a given set of predictors is subject to a high degree of data-mining bias. Since many such sub-models will be highly correlated with each other (because they include almost entirely the same set of factors) you would need to adjust your t-statistics to account for the probability that, among the entire set of correlated models, some models just randomly look successful within the particular sample data you have. Adjusting for so many models would imply that you'd need an unrealistically high t-statistic to have any confidence in coefficients from the model that you finally select. Some better approaches might be Bayesian linear regression where you specify what prior distribution you think is realistic for the coefficient on each of the predictors, or regularized regression like Lasso or Ridge, where you impose some penalty term for how dense or big the set of estimated coefficients is (e.g. the fitting procedure will try to favor models with fewer terms in a suitable sense). If you start out from one of these perspectives, then there is less risk in testing a couple of models that you think have strong prior evidence. But in general, if you simply look at all n-choose-k subsets of factors, for k = 1 through n, then by simple random chance, some model will appear very strong but not due to actual forecast efficacy. You should avoid this.
Performing "all-possible regressions" in R
After re-reading your question, I believe you mean to ask about model selection among your candidate predictor variables, and not actually running all possible regressions. Fitting all possible models
Performing "all-possible regressions" in R After re-reading your question, I believe you mean to ask about model selection among your candidate predictor variables, and not actually running all possible regressions. Fitting all possible models from a given set of predictors is subject to a high degree of data-mining bias. Since many such sub-models will be highly correlated with each other (because they include almost entirely the same set of factors) you would need to adjust your t-statistics to account for the probability that, among the entire set of correlated models, some models just randomly look successful within the particular sample data you have. Adjusting for so many models would imply that you'd need an unrealistically high t-statistic to have any confidence in coefficients from the model that you finally select. Some better approaches might be Bayesian linear regression where you specify what prior distribution you think is realistic for the coefficient on each of the predictors, or regularized regression like Lasso or Ridge, where you impose some penalty term for how dense or big the set of estimated coefficients is (e.g. the fitting procedure will try to favor models with fewer terms in a suitable sense). If you start out from one of these perspectives, then there is less risk in testing a couple of models that you think have strong prior evidence. But in general, if you simply look at all n-choose-k subsets of factors, for k = 1 through n, then by simple random chance, some model will appear very strong but not due to actual forecast efficacy. You should avoid this.
Performing "all-possible regressions" in R After re-reading your question, I believe you mean to ask about model selection among your candidate predictor variables, and not actually running all possible regressions. Fitting all possible models
42,514
Performing "all-possible regressions" in R
I suggest you to use usual panel data analysis approach [in R this involves the use of plm package). There are three categories of explanatory variables (observed or unobserved) that this approach takes into account. First, the variable which is same across each stock but varies over time (economic fundamentals), second is the variable which varies across each stock but doesn't change over the time (e.g., management style), and third includes the variable which varies over time and also across stock (firm's earnings). If the first two variables are unobserved, they are taken into account by using two-way fixed effects (stock effects and year effects), thus use of panel data avoids omitted variable bias arising from the exclusion of these two categories of variables. So, the only bias that arises from the exclusion is due to the omission of last category of variable. If you are sure that your model includes all that belonging to last category, then there is no omitted variable bias. The significance of these variables indicate that they might be important in influencing the stock returns. That being said, which approach to use depends on the purpose of your research.
Performing "all-possible regressions" in R
I suggest you to use usual panel data analysis approach [in R this involves the use of plm package). There are three categories of explanatory variables (observed or unobserved) that this approach tak
Performing "all-possible regressions" in R I suggest you to use usual panel data analysis approach [in R this involves the use of plm package). There are three categories of explanatory variables (observed or unobserved) that this approach takes into account. First, the variable which is same across each stock but varies over time (economic fundamentals), second is the variable which varies across each stock but doesn't change over the time (e.g., management style), and third includes the variable which varies over time and also across stock (firm's earnings). If the first two variables are unobserved, they are taken into account by using two-way fixed effects (stock effects and year effects), thus use of panel data avoids omitted variable bias arising from the exclusion of these two categories of variables. So, the only bias that arises from the exclusion is due to the omission of last category of variable. If you are sure that your model includes all that belonging to last category, then there is no omitted variable bias. The significance of these variables indicate that they might be important in influencing the stock returns. That being said, which approach to use depends on the purpose of your research.
Performing "all-possible regressions" in R I suggest you to use usual panel data analysis approach [in R this involves the use of plm package). There are three categories of explanatory variables (observed or unobserved) that this approach tak
42,515
How to include level-2 variables in a random intercept model when fitting HLM with lme4?
If they are level-2 predictors ("group characteristics" as you say), then they cannot have random effects. We would need to be able to compute separate slopes of the predictors for each group, but this doesn't make sense because the slope can only be computed across groups, not within a group. So the model that you have written already is correct.
How to include level-2 variables in a random intercept model when fitting HLM with lme4?
If they are level-2 predictors ("group characteristics" as you say), then they cannot have random effects. We would need to be able to compute separate slopes of the predictors for each group, but thi
How to include level-2 variables in a random intercept model when fitting HLM with lme4? If they are level-2 predictors ("group characteristics" as you say), then they cannot have random effects. We would need to be able to compute separate slopes of the predictors for each group, but this doesn't make sense because the slope can only be computed across groups, not within a group. So the model that you have written already is correct.
How to include level-2 variables in a random intercept model when fitting HLM with lme4? If they are level-2 predictors ("group characteristics" as you say), then they cannot have random effects. We would need to be able to compute separate slopes of the predictors for each group, but thi
42,516
What is the $\mu^2$ squared effect size?
I can only think of this referring to $\eta^2$, computed as: $\eta^2={SS_{effect} \over SS_{total}}$ This is the proportion of variance explained in the dependent variable by the grouping variable (in this case, a binary variable). This would be indeed the same value as the $R^2$ obtained if the difference between the two groups was estimated using simple linear regression: $y_i=\beta_0+\beta_1group_i+\epsilon_i$ I can see from the paper that the second F test is actually that of an interaction term, and since it has 1 degree of freedom, I am deducing that the second factor was also a binary variable. In this case, the $\eta^2$'s are partial $\eta^2$'s, which are the proportion of variance explained by the grouping variable (or the interaction term) controlling for the other grouping variable. In this more complex case, the partial $\eta^2$'s are the same as the partial $R^2$'s obtained from the multiple linear regression: $y_i=\beta_0+\beta_1group_{1i}+\beta_2group_{1i}+\beta_3 \cdot group_{1i} \cdot group_{2i} + \epsilon_i$
What is the $\mu^2$ squared effect size?
I can only think of this referring to $\eta^2$, computed as: $\eta^2={SS_{effect} \over SS_{total}}$ This is the proportion of variance explained in the dependent variable by the grouping variable (in
What is the $\mu^2$ squared effect size? I can only think of this referring to $\eta^2$, computed as: $\eta^2={SS_{effect} \over SS_{total}}$ This is the proportion of variance explained in the dependent variable by the grouping variable (in this case, a binary variable). This would be indeed the same value as the $R^2$ obtained if the difference between the two groups was estimated using simple linear regression: $y_i=\beta_0+\beta_1group_i+\epsilon_i$ I can see from the paper that the second F test is actually that of an interaction term, and since it has 1 degree of freedom, I am deducing that the second factor was also a binary variable. In this case, the $\eta^2$'s are partial $\eta^2$'s, which are the proportion of variance explained by the grouping variable (or the interaction term) controlling for the other grouping variable. In this more complex case, the partial $\eta^2$'s are the same as the partial $R^2$'s obtained from the multiple linear regression: $y_i=\beta_0+\beta_1group_{1i}+\beta_2group_{1i}+\beta_3 \cdot group_{1i} \cdot group_{2i} + \epsilon_i$
What is the $\mu^2$ squared effect size? I can only think of this referring to $\eta^2$, computed as: $\eta^2={SS_{effect} \over SS_{total}}$ This is the proportion of variance explained in the dependent variable by the grouping variable (in
42,517
What is the $\mu^2$ squared effect size?
This is eta-squared and it is a fairly poor measure of effect size (partial eta-squared is often reported in statistical software such as SPSS when calculating ANOVA)
What is the $\mu^2$ squared effect size?
This is eta-squared and it is a fairly poor measure of effect size (partial eta-squared is often reported in statistical software such as SPSS when calculating ANOVA)
What is the $\mu^2$ squared effect size? This is eta-squared and it is a fairly poor measure of effect size (partial eta-squared is often reported in statistical software such as SPSS when calculating ANOVA)
What is the $\mu^2$ squared effect size? This is eta-squared and it is a fairly poor measure of effect size (partial eta-squared is often reported in statistical software such as SPSS when calculating ANOVA)
42,518
What is the $\mu^2$ squared effect size?
My apologies, I misread Patrick's response above; I now see he also indicated it was $_{partial}\eta^2$. I added the formulas for finding $_{partial}\eta^2$ should any need those. I am posting on this old thread to clarify should others visit in the future. The value reported is $_{partial}\eta^2$, not $\eta^2$. Since the analysis is a two-way ANOVA, the formula $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ (where $df_a$ is df for the predictor and $df_e$ is the error df) which normally provides $\eta^2$ for a one-way ANOVA, instead produces the $_{partial}\eta^2$ for a multi-way ANOVA. Thus $_{partial}\eta^2$ = $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ = $\frac{4.5}{4.5+71}$ = .059 ~ .06 and $_{partial}\eta^2$ = $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ = $\frac{.08}{.08+71}$ = .001 The authors mislabeled the effect, rather than $\mu^2$ it should be $_{partial}\eta^2$. It is also possible the authors meant to report Cohen's $f^2$ effect size since the results of these two F-ratios provide both $_{partial}\eta^2$ and $f^2$ that are within rounding error, but I have never seen Cohen $f^2$ reported like this. Bryan
What is the $\mu^2$ squared effect size?
My apologies, I misread Patrick's response above; I now see he also indicated it was $_{partial}\eta^2$. I added the formulas for finding $_{partial}\eta^2$ should any need those. I am posting on thi
What is the $\mu^2$ squared effect size? My apologies, I misread Patrick's response above; I now see he also indicated it was $_{partial}\eta^2$. I added the formulas for finding $_{partial}\eta^2$ should any need those. I am posting on this old thread to clarify should others visit in the future. The value reported is $_{partial}\eta^2$, not $\eta^2$. Since the analysis is a two-way ANOVA, the formula $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ (where $df_a$ is df for the predictor and $df_e$ is the error df) which normally provides $\eta^2$ for a one-way ANOVA, instead produces the $_{partial}\eta^2$ for a multi-way ANOVA. Thus $_{partial}\eta^2$ = $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ = $\frac{4.5}{4.5+71}$ = .059 ~ .06 and $_{partial}\eta^2$ = $\frac{(F)(df_a)}{(F)(df_a)+df_e}$ = $\frac{.08}{.08+71}$ = .001 The authors mislabeled the effect, rather than $\mu^2$ it should be $_{partial}\eta^2$. It is also possible the authors meant to report Cohen's $f^2$ effect size since the results of these two F-ratios provide both $_{partial}\eta^2$ and $f^2$ that are within rounding error, but I have never seen Cohen $f^2$ reported like this. Bryan
What is the $\mu^2$ squared effect size? My apologies, I misread Patrick's response above; I now see he also indicated it was $_{partial}\eta^2$. I added the formulas for finding $_{partial}\eta^2$ should any need those. I am posting on thi
42,519
Interpretation of null and alternative hypotheses
If "the claim" is "that it takes at least 10 years", and you want to test this, then that is your alternative hypothesis. The null hypothesis negates the alternative. Thus: $$ H_0: \mu\le10 \\ H_a: \mu>10 $$ A way to think about these things is that the alternative hypothesis is what the researcher really believes, but she is worried that there is someone who is so skeptical that they won't believe her unless the evidence against the null is sufficiently strong.
Interpretation of null and alternative hypotheses
If "the claim" is "that it takes at least 10 years", and you want to test this, then that is your alternative hypothesis. The null hypothesis negates the alternative. Thus: $$ H_0: \mu\le10 \\ H_a:
Interpretation of null and alternative hypotheses If "the claim" is "that it takes at least 10 years", and you want to test this, then that is your alternative hypothesis. The null hypothesis negates the alternative. Thus: $$ H_0: \mu\le10 \\ H_a: \mu>10 $$ A way to think about these things is that the alternative hypothesis is what the researcher really believes, but she is worried that there is someone who is so skeptical that they won't believe her unless the evidence against the null is sufficiently strong.
Interpretation of null and alternative hypotheses If "the claim" is "that it takes at least 10 years", and you want to test this, then that is your alternative hypothesis. The null hypothesis negates the alternative. Thus: $$ H_0: \mu\le10 \\ H_a:
42,520
Interpretation of null and alternative hypotheses
I am bit confused with gung's interpretation. Please correct me if I am wrong. Since the claim is that it takes 'at least 10 years', then we should state this claim as mu>=10, and the other hypothesis should be the complementary of this one, so it is mu<10. To my understanding, the claim of 'mu>=10' has to be the null hypothesis because it contains '=' sign. This is important when we calculate the maximum value of restricted likelihood, because the maximum value will lie on the boundary of the support, so the boundary value (10 in this case), needs to be contained in the support. Thus we need the '=' sign in the null hypothesis. So I tend to agree with user28884's original interpretation.
Interpretation of null and alternative hypotheses
I am bit confused with gung's interpretation. Please correct me if I am wrong. Since the claim is that it takes 'at least 10 years', then we should state this claim as mu>=10, and the other hypothesi
Interpretation of null and alternative hypotheses I am bit confused with gung's interpretation. Please correct me if I am wrong. Since the claim is that it takes 'at least 10 years', then we should state this claim as mu>=10, and the other hypothesis should be the complementary of this one, so it is mu<10. To my understanding, the claim of 'mu>=10' has to be the null hypothesis because it contains '=' sign. This is important when we calculate the maximum value of restricted likelihood, because the maximum value will lie on the boundary of the support, so the boundary value (10 in this case), needs to be contained in the support. Thus we need the '=' sign in the null hypothesis. So I tend to agree with user28884's original interpretation.
Interpretation of null and alternative hypotheses I am bit confused with gung's interpretation. Please correct me if I am wrong. Since the claim is that it takes 'at least 10 years', then we should state this claim as mu>=10, and the other hypothesi
42,521
Interpretation of null and alternative hypotheses
Ho : mu > = 10 Ha: mu < 10 Descriptive Statistics Column 1 Sample Size, n: 10 Mean: 11.72 Variance, s^2: 8.179556 St Dev, s: 2.859992 test statistics , t = (11.72 - 10)/(2.86/sqrt(10)) = 1.9017 critical t (9, 0.05)= - 1.833. hence, computed t (1.9017) > critical t (-1.833) . Fail to reject Ho. http://tutorteddy.com/site/free_statistics_help.php
Interpretation of null and alternative hypotheses
Ho : mu > = 10 Ha: mu < 10 Descriptive Statistics Column 1 Sample Size, n: 10 Mean: 11.72 Variance, s^2: 8.179556 St Dev, s: 2.859992 test statistics , t = (11.72 - 10)/(2.86/sqrt(10)
Interpretation of null and alternative hypotheses Ho : mu > = 10 Ha: mu < 10 Descriptive Statistics Column 1 Sample Size, n: 10 Mean: 11.72 Variance, s^2: 8.179556 St Dev, s: 2.859992 test statistics , t = (11.72 - 10)/(2.86/sqrt(10)) = 1.9017 critical t (9, 0.05)= - 1.833. hence, computed t (1.9017) > critical t (-1.833) . Fail to reject Ho. http://tutorteddy.com/site/free_statistics_help.php
Interpretation of null and alternative hypotheses Ho : mu > = 10 Ha: mu < 10 Descriptive Statistics Column 1 Sample Size, n: 10 Mean: 11.72 Variance, s^2: 8.179556 St Dev, s: 2.859992 test statistics , t = (11.72 - 10)/(2.86/sqrt(10)
42,522
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval?
It depends on what you mean by performance - in terms of computing power DTW suffers from computational lethargy and Euclidean distance method dosnt. DTW is superior when it comes to classification and clustering. Euclidean distance, which assumes the ith point in one sequence is aligned with the ith point in the other, will produce a pessimistic dissimilarity measure. The non-linear Dynamic Time Warped alignment allows a more intuitive distance measure to be calculated. see Making Time-series Classification More Accurate Using Learned Constraints I have used both DTW and Euclidean Happy clustering !!!!
Does it make sense to use dynamic time warping when clustering time series that all have the same le
It depends on what you mean by performance - in terms of computing power DTW suffers from computational lethargy and Euclidean distance method dosnt. DTW is superior when it comes to classification an
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval? It depends on what you mean by performance - in terms of computing power DTW suffers from computational lethargy and Euclidean distance method dosnt. DTW is superior when it comes to classification and clustering. Euclidean distance, which assumes the ith point in one sequence is aligned with the ith point in the other, will produce a pessimistic dissimilarity measure. The non-linear Dynamic Time Warped alignment allows a more intuitive distance measure to be calculated. see Making Time-series Classification More Accurate Using Learned Constraints I have used both DTW and Euclidean Happy clustering !!!!
Does it make sense to use dynamic time warping when clustering time series that all have the same le It depends on what you mean by performance - in terms of computing power DTW suffers from computational lethargy and Euclidean distance method dosnt. DTW is superior when it comes to classification an
42,523
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval?
It totally depends on if you want your clustering to be invariant to dilation in time. For example if you have a speech signal we often want to be invariant to the speed at which people speak. If you're clustering music maybe you wouldn't want to use DTW.
Does it make sense to use dynamic time warping when clustering time series that all have the same le
It totally depends on if you want your clustering to be invariant to dilation in time. For example if you have a speech signal we often want to be invariant to the speed at which people speak. If you'
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval? It totally depends on if you want your clustering to be invariant to dilation in time. For example if you have a speech signal we often want to be invariant to the speed at which people speak. If you're clustering music maybe you wouldn't want to use DTW.
Does it make sense to use dynamic time warping when clustering time series that all have the same le It totally depends on if you want your clustering to be invariant to dilation in time. For example if you have a speech signal we often want to be invariant to the speed at which people speak. If you'
42,524
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval?
You can check this great answer here: https://stats.stackexchange.com/a/22228/193114. In general, it depends on the application you are working on. Euclidean distance is better than DTW when temporal alignment is not what you want. Euclidean distance is better than DTW when you wish to group time series that behave exactly the same at each time.
Does it make sense to use dynamic time warping when clustering time series that all have the same le
You can check this great answer here: https://stats.stackexchange.com/a/22228/193114. In general, it depends on the application you are working on. Euclidean distance is better than DTW when temporal
Does it make sense to use dynamic time warping when clustering time series that all have the same length and sampling interval? You can check this great answer here: https://stats.stackexchange.com/a/22228/193114. In general, it depends on the application you are working on. Euclidean distance is better than DTW when temporal alignment is not what you want. Euclidean distance is better than DTW when you wish to group time series that behave exactly the same at each time.
Does it make sense to use dynamic time warping when clustering time series that all have the same le You can check this great answer here: https://stats.stackexchange.com/a/22228/193114. In general, it depends on the application you are working on. Euclidean distance is better than DTW when temporal
42,525
Are sample statistics relevant when comparing census data across time periods?
The problem with studying the change of observables in time (such dataset is formally called "time series"), is that for each case observations in different points in time are dependent, which forces us at least to use tests that are valid for paired data (when comparing two data points), or VECM if you want to analyze all time points at once. In particular, significance test of regressions are invalid in such setup. When you treat each time point as a separate independent group, you are likely to greatly exaggerate significance. The question whether use statistical tests or not for census data depends on what is your hypothesis. If you want to infer for this particular group of people in this particular point of time (if the census actually concerns people), than there is no need for significance indeed. But very often we want implicitly to make an inference about some bigger population, e.g. whole Europe. In that case we need to treat our dataset as a sample. Or we want to make inference about our population in future; in this case we would use VECM or similar technique valid for time series.
Are sample statistics relevant when comparing census data across time periods?
The problem with studying the change of observables in time (such dataset is formally called "time series"), is that for each case observations in different points in time are dependent, which forces
Are sample statistics relevant when comparing census data across time periods? The problem with studying the change of observables in time (such dataset is formally called "time series"), is that for each case observations in different points in time are dependent, which forces us at least to use tests that are valid for paired data (when comparing two data points), or VECM if you want to analyze all time points at once. In particular, significance test of regressions are invalid in such setup. When you treat each time point as a separate independent group, you are likely to greatly exaggerate significance. The question whether use statistical tests or not for census data depends on what is your hypothesis. If you want to infer for this particular group of people in this particular point of time (if the census actually concerns people), than there is no need for significance indeed. But very often we want implicitly to make an inference about some bigger population, e.g. whole Europe. In that case we need to treat our dataset as a sample. Or we want to make inference about our population in future; in this case we would use VECM or similar technique valid for time series.
Are sample statistics relevant when comparing census data across time periods? The problem with studying the change of observables in time (such dataset is formally called "time series"), is that for each case observations in different points in time are dependent, which forces
42,526
Are sample statistics relevant when comparing census data across time periods?
Sampling variability is only one possible source of error in the estimate of the quantity you are interested in. When you have a census, error due to sampling variability might be null, but there might be other sources of error, like measurement error. So if you compare two estimates from two censuses and the difference turns out to be 3%, this is not necessarily the 'true' difference between the two populations (or the same population at the two periods of time), because of, for example, measurement error. The tools of statistical inference which have been developed for inference from sample to population might or might not be useful when you want to take into account other sources of error than sampling error. If you can directly model measurement error (and other sources of error that might be relevant), do that. I know from experience that many people would still conduct (and ask for) hypothesis tests and report p-values and the like with census data, but I can see no justification for such practices. This is not to say that the data should be treated as 'perfect', but the uncertainty better be modeled/discussed directly.
Are sample statistics relevant when comparing census data across time periods?
Sampling variability is only one possible source of error in the estimate of the quantity you are interested in. When you have a census, error due to sampling variability might be null, but there migh
Are sample statistics relevant when comparing census data across time periods? Sampling variability is only one possible source of error in the estimate of the quantity you are interested in. When you have a census, error due to sampling variability might be null, but there might be other sources of error, like measurement error. So if you compare two estimates from two censuses and the difference turns out to be 3%, this is not necessarily the 'true' difference between the two populations (or the same population at the two periods of time), because of, for example, measurement error. The tools of statistical inference which have been developed for inference from sample to population might or might not be useful when you want to take into account other sources of error than sampling error. If you can directly model measurement error (and other sources of error that might be relevant), do that. I know from experience that many people would still conduct (and ask for) hypothesis tests and report p-values and the like with census data, but I can see no justification for such practices. This is not to say that the data should be treated as 'perfect', but the uncertainty better be modeled/discussed directly.
Are sample statistics relevant when comparing census data across time periods? Sampling variability is only one possible source of error in the estimate of the quantity you are interested in. When you have a census, error due to sampling variability might be null, but there migh
42,527
Interpreting matrices of SVD in practical applications [duplicate]
I think I have an answer. If you notice a mistake, let me know. One interpretation explained in the book suggested by Cam.Davidson.Pilon is the factor interpretation. This tells you that a matrix $A$ with n rows and m columns can be decomposed into a matrix $C$ with $n$ rows and $r$ columns, a matrix $W$ with r rows and r columns and a matrix $F$ with $r$ rows and $m$ columns. So suppose that your matrix $A$ contains $n$ objects and m attributes. As a consequence of this decomposition, you can think of $C$ as a different view of the $n$ objects, except that instead of using $m$ pieces of information, you use r pieces of information (usually, $r < n$). Similarly, $F$ can be thought as a different view of the attributes of $A$, again using $r$ pieces instead of $n$. This description applies to general decomposition. The difference in SVD is that the matrices $W$ and $F$ have $r=n$, but the same interpretation is possible. Therefore, in the example I described in the question, the matrix $A$ looks like this: $$ A = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} $$ in which the rows are attributes (in this case, pixels) and the columns are objects (dogs and cats). An SVD decomposition of this matrix would like this: $$ A = U\Sigma V^{*} $$ $$ A = \begin{pmatrix} u_{1,1} & u_{1,2} & \cdots & u_{1,n} \\\ u_{2,1} & u_{2,2} & \cdots & u_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ u_{m,1} & u_{m,2} & \cdots & u_{m,n} \end{pmatrix} \begin{pmatrix} \sigma_{1} & 0 & \cdots & 0 \\\ 0 & \sigma_{2} & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & \cdots & \sigma_{n} \end{pmatrix} \begin{pmatrix} v_{1,1} & v_{1,2} & \cdots & v_{1,n} \\\ v_{2,1} & v_{2,2} & \cdots & v_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ v_{n,1} & v_{n,2} & \cdots & v_{n,n} \end{pmatrix} $$ Following this factor interpretation, every row of $V^{*}$ corresponds to a factor, the first columns correspond to dogs and the last ones to cats. So, let's take the first 40 columns of $V^{*}$ of the first factor. This should be: fig = figure() ax = fig.add_subplot(1,1,1) ax.plot(V[0, 0:40], 'o-', markersize=3) ax.set_xlabel('Dogs') ax.set_title('Mode 1') This plot describes the value of the first factor for the first 40 dogs. Since these values $v_{1,1}, ... v_{1,n}$ are going to be multiplied by $\sigma_{1}$, they are associated to the first mode: $$\Sigma V^{*} = \begin{pmatrix} \sigma_{1} v_{1,1} & \sigma_{1}v_{1,2} & \cdots & \sigma_{n} v_{1,n} \\\ \sigma_{2} v_{2,1} & \sigma_{2}v_{2,2} & \cdots & \sigma_{2}v_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ \sigma_{n}v_{n,1} & \sigma_{n}v_{n,2} & \cdots & \sigma_{n}v_{n,n} \end{pmatrix}$$ Likewise, V[0, 40:80] produces the first factor for the first 40 cats. Don't read too much into the values because I used a low quality dataset just to reproduce this part of the course.
Interpreting matrices of SVD in practical applications [duplicate]
I think I have an answer. If you notice a mistake, let me know. One interpretation explained in the book suggested by Cam.Davidson.Pilon is the factor interpretation. This tells you that a matrix $A$
Interpreting matrices of SVD in practical applications [duplicate] I think I have an answer. If you notice a mistake, let me know. One interpretation explained in the book suggested by Cam.Davidson.Pilon is the factor interpretation. This tells you that a matrix $A$ with n rows and m columns can be decomposed into a matrix $C$ with $n$ rows and $r$ columns, a matrix $W$ with r rows and r columns and a matrix $F$ with $r$ rows and $m$ columns. So suppose that your matrix $A$ contains $n$ objects and m attributes. As a consequence of this decomposition, you can think of $C$ as a different view of the $n$ objects, except that instead of using $m$ pieces of information, you use r pieces of information (usually, $r < n$). Similarly, $F$ can be thought as a different view of the attributes of $A$, again using $r$ pieces instead of $n$. This description applies to general decomposition. The difference in SVD is that the matrices $W$ and $F$ have $r=n$, but the same interpretation is possible. Therefore, in the example I described in the question, the matrix $A$ looks like this: $$ A = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} $$ in which the rows are attributes (in this case, pixels) and the columns are objects (dogs and cats). An SVD decomposition of this matrix would like this: $$ A = U\Sigma V^{*} $$ $$ A = \begin{pmatrix} u_{1,1} & u_{1,2} & \cdots & u_{1,n} \\\ u_{2,1} & u_{2,2} & \cdots & u_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ u_{m,1} & u_{m,2} & \cdots & u_{m,n} \end{pmatrix} \begin{pmatrix} \sigma_{1} & 0 & \cdots & 0 \\\ 0 & \sigma_{2} & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & \cdots & \sigma_{n} \end{pmatrix} \begin{pmatrix} v_{1,1} & v_{1,2} & \cdots & v_{1,n} \\\ v_{2,1} & v_{2,2} & \cdots & v_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ v_{n,1} & v_{n,2} & \cdots & v_{n,n} \end{pmatrix} $$ Following this factor interpretation, every row of $V^{*}$ corresponds to a factor, the first columns correspond to dogs and the last ones to cats. So, let's take the first 40 columns of $V^{*}$ of the first factor. This should be: fig = figure() ax = fig.add_subplot(1,1,1) ax.plot(V[0, 0:40], 'o-', markersize=3) ax.set_xlabel('Dogs') ax.set_title('Mode 1') This plot describes the value of the first factor for the first 40 dogs. Since these values $v_{1,1}, ... v_{1,n}$ are going to be multiplied by $\sigma_{1}$, they are associated to the first mode: $$\Sigma V^{*} = \begin{pmatrix} \sigma_{1} v_{1,1} & \sigma_{1}v_{1,2} & \cdots & \sigma_{n} v_{1,n} \\\ \sigma_{2} v_{2,1} & \sigma_{2}v_{2,2} & \cdots & \sigma_{2}v_{2,n} \\\ \vdots & \vdots & \ddots & \vdots \\\ \sigma_{n}v_{n,1} & \sigma_{n}v_{n,2} & \cdots & \sigma_{n}v_{n,n} \end{pmatrix}$$ Likewise, V[0, 40:80] produces the first factor for the first 40 cats. Don't read too much into the values because I used a low quality dataset just to reproduce this part of the course.
Interpreting matrices of SVD in practical applications [duplicate] I think I have an answer. If you notice a mistake, let me know. One interpretation explained in the book suggested by Cam.Davidson.Pilon is the factor interpretation. This tells you that a matrix $A$
42,528
How to do 4-parametric regression for ELISA data in R
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. The 2nd answer to a Google search for 4 parameter logistic r is this promising paper in which the authors have developed and implemented methods for analysis of assays such as ELISA in the R package drc. Specifically, the authors have developed a function LL.4() which implements the 4 paramater logistic regression function, for use with the general dose response modeling function drm. Christian Ritz, Jens Streiberg. Bioassay Analysis Using R. Journal of Statistical Software, 2005, Vol. 12, No. 5. Ritz et al have published a new paper that covers improvements to the 'drc' R package. Dose Response Analysis using R (PLOS ONE, 2015)
How to do 4-parametric regression for ELISA data in R
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
How to do 4-parametric regression for ELISA data in R Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. The 2nd answer to a Google search for 4 parameter logistic r is this promising paper in which the authors have developed and implemented methods for analysis of assays such as ELISA in the R package drc. Specifically, the authors have developed a function LL.4() which implements the 4 paramater logistic regression function, for use with the general dose response modeling function drm. Christian Ritz, Jens Streiberg. Bioassay Analysis Using R. Journal of Statistical Software, 2005, Vol. 12, No. 5. Ritz et al have published a new paper that covers improvements to the 'drc' R package. Dose Response Analysis using R (PLOS ONE, 2015)
How to do 4-parametric regression for ELISA data in R Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
42,529
How to do 4-parametric regression for ELISA data in R
After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) summary(model1) plot(model1) If I wanna predict the dose from observation. model2 <- drm(DOSE~SLOPE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) predict(model2, newdata, type="response") newdata is a dataframe 'predict' is not the best way to estimate the DOSE from SLOPE in this case, because you have to reverse them in your model2, which doesn't work in this example. If you want to estimate the DOSE from SLOPE, or 'Concentration' from 'OD' in case of an ELISA, just use the ED function of the 'drc' package EXAMPLE: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) plot(model1) # the ED function is used to give the EDx value. For example, the ED50 is the # DOSE value for the 50% response ED(model1,50) # check ?ED ?ED # The result is a matrix, from which the Estimate values can be extracted using # the index (display=F is a good option also) ED(model1,50,display=F)[1:5] # type="absolute" gives you the ability to use absolute values for the response, to # estimate the DOSE response<-0.5 #lets use 0.5 for the response DOSEx<-ED(model1,response,type="absolute",display=F)[1:5] # the estimated DOSE points(y=rep(response,5),x=DOSEx,col="blue",pch=1:5)
How to do 4-parametric regression for ELISA data in R
After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, C
How to do 4-parametric regression for ELISA data in R After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) summary(model1) plot(model1) If I wanna predict the dose from observation. model2 <- drm(DOSE~SLOPE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) predict(model2, newdata, type="response") newdata is a dataframe 'predict' is not the best way to estimate the DOSE from SLOPE in this case, because you have to reverse them in your model2, which doesn't work in this example. If you want to estimate the DOSE from SLOPE, or 'Concentration' from 'OD' in case of an ELISA, just use the ED function of the 'drc' package EXAMPLE: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) plot(model1) # the ED function is used to give the EDx value. For example, the ED50 is the # DOSE value for the 50% response ED(model1,50) # check ?ED ?ED # The result is a matrix, from which the Estimate values can be extracted using # the index (display=F is a good option also) ED(model1,50,display=F)[1:5] # type="absolute" gives you the ability to use absolute values for the response, to # estimate the DOSE response<-0.5 #lets use 0.5 for the response DOSEx<-ED(model1,response,type="absolute",display=F)[1:5] # the estimated DOSE points(y=rep(response,5),x=DOSEx,col="blue",pch=1:5)
How to do 4-parametric regression for ELISA data in R After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, C
42,530
How to do 4-parametric regression for ELISA data in R
You can find the least-square estimate of the parameters using nonlinear regression. Example: f=function(B,x) (B[1]-B[4])/(1+(x/B[3])^B[2])+B[4] LS=function(B,y,x) sum((y-f(B,x))^2) x=runif(100,0,5) B=c(1,5,2.5,5) y=f(B,x) plot(x,y) ### Estimate should be very close to B nlm(LS,c(1,1,1,1),x=x,y=y)
How to do 4-parametric regression for ELISA data in R
You can find the least-square estimate of the parameters using nonlinear regression. Example: f=function(B,x) (B[1]-B[4])/(1+(x/B[3])^B[2])+B[4] LS=function(B,y,x) sum((y-f(B,x))^2) x=runif(100
How to do 4-parametric regression for ELISA data in R You can find the least-square estimate of the parameters using nonlinear regression. Example: f=function(B,x) (B[1]-B[4])/(1+(x/B[3])^B[2])+B[4] LS=function(B,y,x) sum((y-f(B,x))^2) x=runif(100,0,5) B=c(1,5,2.5,5) y=f(B,x) plot(x,y) ### Estimate should be very close to B nlm(LS,c(1,1,1,1),x=x,y=y)
How to do 4-parametric regression for ELISA data in R You can find the least-square estimate of the parameters using nonlinear regression. Example: f=function(B,x) (B[1]-B[4])/(1+(x/B[3])^B[2])+B[4] LS=function(B,y,x) sum((y-f(B,x))^2) x=runif(100
42,531
How to do 4-parametric regression for ELISA data in R
There is an excellent R tutorial on fitting the 4 parameter logistic model for calibration purposes (e.g. on ELISA data) here: http://weightinginbayesianmodels.github.io/poctcalibration/over_tutorials.html http://weightinginbayesianmodels.github.io/poctcalibration/calib_tut4_curve_ocon.html http://weightinginbayesianmodels.github.io/poctcalibration/calib_tut5_precision_ocon.html http://weightinginbayesianmodels.github.io/poctcalibration/AMfunctions.html#sdXhat They just use the nlsLM function in the minpack.lm package. I.e. they fit a a model of the form x <- c(478, 525, 580, 650, 700, 720, 780, 825, 850, 900, 930, 980, 1020, 1040, 1050, 1075, 1081, 1100, 1160, 1180, 1200) y <- c(1.70, 1.45, 1.50, 1.42, 1.39, 1.90, 2.49, 2.21, 2.57, 2.90, 3.55, 3.80, 4.27, 4.10, 4.60, 4.42, 4.30, 4.52, 4.40, 4.50, 4.15) M.4pl <- function(x, lower.asymp, upper.asymp, inflec, hill){ f <- lower.asymp + ((upper.asymp - lower.asymp)/ (1 + (x / inflec)^-hill)) return(f) } require(minpack.lm) nlslmfit = nlsLM(y ~ M.4pl(x, lower.asymp, upper.asymp, inflec, hill), data = data.frame(x=x, y=y), start = c(lower.asymp=min(y)+1E-10, upper.asymp=max(y)-1E-10, inflec=mean(x), hill=1), control = nls.control(maxiter=1000, warnOnly=TRUE) ) summary(nlslmfit) # Parameters: # Estimate Std. Error t value Pr(>|t|) # lower.asymp 1.5371 0.1080 14.24 7.06e-11 *** # upper.asymp 4.5508 0.1497 30.40 2.93e-16 *** # inflec 889.1543 14.0924 63.09 < 2e-16 *** # hill 13.1717 2.5475 5.17 7.68e-05 *** require(investr) xvals=seq(min(x),max(x),length.out=100) predintervals = data.frame(x=xvals,predFit(nlslmfit, newdata=data.frame(x=xvals), interval="prediction")) confintervals = data.frame(x=xvals,predFit(nlslmfit, newdata=data.frame(x=xvals), interval="confidence")) require(ggplot2) qplot(data=predintervals, x=x, y=fit, ymin=lwr, ymax=upr, geom="ribbon", fill=I("red"), alpha=I(0.2)) + geom_ribbon(data=confintervals, aes(x=x, ymin=lwr, ymax=upr), fill=I("blue"), alpha=I(0.2)) + geom_line(data=confintervals, aes(x=x, y=fit), colour=I("blue"), lwd=2) + geom_point(data=data.frame(x=x,y=y), aes(x=x, y=y, ymin=NULL, ymax=NULL), size=5, col="blue") + ylab("y") They also show how one could use weights and iteratively refitted least squares to allow for non-homogeneous variance. And it also covers how to do inverse prediction and calculating derived statistics like determining the limit of detection, limit of quantification and working range. Myself I had more luck using a constrained strictly monotone P spline fit though, fitted using the scam package, to do calibration curves, as that resulted in much narrower 95% confidence intervals and prediction intervals than using the four parameter logistic model... I.e. a model of the form require(scam) nknots = 20 # desired nr of knots fit = scam(y~s(conc,k=nknots,bs="mpi",m=2), family=gaussian, data=data) If your data are discrete counts as opposed to some continuous measure you could also use family=poisson with a log link, or work with a log(y+1) transformed dependent variable. You could also use log(conc+1) in your formula as well, as concentration can never go negative.
How to do 4-parametric regression for ELISA data in R
There is an excellent R tutorial on fitting the 4 parameter logistic model for calibration purposes (e.g. on ELISA data) here: http://weightinginbayesianmodels.github.io/poctcalibration/over_tutorials
How to do 4-parametric regression for ELISA data in R There is an excellent R tutorial on fitting the 4 parameter logistic model for calibration purposes (e.g. on ELISA data) here: http://weightinginbayesianmodels.github.io/poctcalibration/over_tutorials.html http://weightinginbayesianmodels.github.io/poctcalibration/calib_tut4_curve_ocon.html http://weightinginbayesianmodels.github.io/poctcalibration/calib_tut5_precision_ocon.html http://weightinginbayesianmodels.github.io/poctcalibration/AMfunctions.html#sdXhat They just use the nlsLM function in the minpack.lm package. I.e. they fit a a model of the form x <- c(478, 525, 580, 650, 700, 720, 780, 825, 850, 900, 930, 980, 1020, 1040, 1050, 1075, 1081, 1100, 1160, 1180, 1200) y <- c(1.70, 1.45, 1.50, 1.42, 1.39, 1.90, 2.49, 2.21, 2.57, 2.90, 3.55, 3.80, 4.27, 4.10, 4.60, 4.42, 4.30, 4.52, 4.40, 4.50, 4.15) M.4pl <- function(x, lower.asymp, upper.asymp, inflec, hill){ f <- lower.asymp + ((upper.asymp - lower.asymp)/ (1 + (x / inflec)^-hill)) return(f) } require(minpack.lm) nlslmfit = nlsLM(y ~ M.4pl(x, lower.asymp, upper.asymp, inflec, hill), data = data.frame(x=x, y=y), start = c(lower.asymp=min(y)+1E-10, upper.asymp=max(y)-1E-10, inflec=mean(x), hill=1), control = nls.control(maxiter=1000, warnOnly=TRUE) ) summary(nlslmfit) # Parameters: # Estimate Std. Error t value Pr(>|t|) # lower.asymp 1.5371 0.1080 14.24 7.06e-11 *** # upper.asymp 4.5508 0.1497 30.40 2.93e-16 *** # inflec 889.1543 14.0924 63.09 < 2e-16 *** # hill 13.1717 2.5475 5.17 7.68e-05 *** require(investr) xvals=seq(min(x),max(x),length.out=100) predintervals = data.frame(x=xvals,predFit(nlslmfit, newdata=data.frame(x=xvals), interval="prediction")) confintervals = data.frame(x=xvals,predFit(nlslmfit, newdata=data.frame(x=xvals), interval="confidence")) require(ggplot2) qplot(data=predintervals, x=x, y=fit, ymin=lwr, ymax=upr, geom="ribbon", fill=I("red"), alpha=I(0.2)) + geom_ribbon(data=confintervals, aes(x=x, ymin=lwr, ymax=upr), fill=I("blue"), alpha=I(0.2)) + geom_line(data=confintervals, aes(x=x, y=fit), colour=I("blue"), lwd=2) + geom_point(data=data.frame(x=x,y=y), aes(x=x, y=y, ymin=NULL, ymax=NULL), size=5, col="blue") + ylab("y") They also show how one could use weights and iteratively refitted least squares to allow for non-homogeneous variance. And it also covers how to do inverse prediction and calculating derived statistics like determining the limit of detection, limit of quantification and working range. Myself I had more luck using a constrained strictly monotone P spline fit though, fitted using the scam package, to do calibration curves, as that resulted in much narrower 95% confidence intervals and prediction intervals than using the four parameter logistic model... I.e. a model of the form require(scam) nknots = 20 # desired nr of knots fit = scam(y~s(conc,k=nknots,bs="mpi",m=2), family=gaussian, data=data) If your data are discrete counts as opposed to some continuous measure you could also use family=poisson with a log link, or work with a log(y+1) transformed dependent variable. You could also use log(conc+1) in your formula as well, as concentration can never go negative.
How to do 4-parametric regression for ELISA data in R There is an excellent R tutorial on fitting the 4 parameter logistic model for calibration purposes (e.g. on ELISA data) here: http://weightinginbayesianmodels.github.io/poctcalibration/over_tutorials
42,532
How to do 4-parametric regression for ELISA data in R
After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) summary(model1) plot(model1) If I wanna predict the dose from observation. model2 <- drm(DOSE~SLOPE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) predict(model2, newdata, type="response") newdata is a dataframe If I wanna check the regression, R square is not good for nonlinear regression RSD <- abs(sqrt(summary(model1)$"resVar") / mean(fitted(model1))) Thanks for Christian Ritz and my father's help.
How to do 4-parametric regression for ELISA data in R
After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CUR
How to do 4-parametric regression for ELISA data in R After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) summary(model1) plot(model1) If I wanna predict the dose from observation. model2 <- drm(DOSE~SLOPE, CURVE, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")),data=spinach) predict(model2, newdata, type="response") newdata is a dataframe If I wanna check the regression, R square is not good for nonlinear regression RSD <- abs(sqrt(summary(model1)$"resVar") / mean(fitted(model1))) Thanks for Christian Ritz and my father's help.
How to do 4-parametric regression for ELISA data in R After days, I record my found here: http://www.bioassay.dk/index-filer/start/DraftDrcManual.pdf gives me the current manual of drc package in R. For example: library(drc) model1 <- drm(SLOPE~DOSE, CUR
42,533
How to do 4-parametric regression for ELISA data in R
For what it's worth, below is an example comparing drc::drm() and gnlm::gnlr(): library(drc) spinach1 <- subset(spinach, CURVE==1) model.drm <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("B", "D", "A","C")),data=spinach1) summary(model.drm) library(gnlm) attach(spinach1) model.gnlr <- gnlr(y = SLOPE, mu =~ (A-D)/(1+(DOSE/C)^B) + D, pmu = list(A=0.1,B=0.1,C=0.1,D=0.1), pshape=log(0.05)) model.gnlr
How to do 4-parametric regression for ELISA data in R
For what it's worth, below is an example comparing drc::drm() and gnlm::gnlr(): library(drc) spinach1 <- subset(spinach, CURVE==1) model.drm <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("B
How to do 4-parametric regression for ELISA data in R For what it's worth, below is an example comparing drc::drm() and gnlm::gnlr(): library(drc) spinach1 <- subset(spinach, CURVE==1) model.drm <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("B", "D", "A","C")),data=spinach1) summary(model.drm) library(gnlm) attach(spinach1) model.gnlr <- gnlr(y = SLOPE, mu =~ (A-D)/(1+(DOSE/C)^B) + D, pmu = list(A=0.1,B=0.1,C=0.1,D=0.1), pshape=log(0.05)) model.gnlr
How to do 4-parametric regression for ELISA data in R For what it's worth, below is an example comparing drc::drm() and gnlm::gnlr(): library(drc) spinach1 <- subset(spinach, CURVE==1) model.drm <- drm(SLOPE~DOSE, CURVE, fct=LL.4(names=c("B
42,534
What's the problem with model identifiability?
I recommend you read Andrew Gelman's blog post Think identifiability Bayesian inference. Right off the bat, I can tell you that identifiability does not have to do with a model by itself (as in "an unidentifiable model"), rather than with the combination of this model with some data. That is to say, it has to do with the data also. The same model may be identifiable with some data, and unidentifiable with some other data. In a Bayesian context, it is not clear as to what exactly identifiability means. As the link I provided says, it is not a "black-or-white" case. Rather, it has to with the amount of information learned from the data, or the "distance" of the posterior from the prior. A perhaps suitable measure of information might be the Information Entropy, and while you are at it, the "distance" between two probability distributions (prior and posterior in this case) may be quantified by the Kullback-Leibler divergence, both of which can be found in the Wikipedia page on information theory. So you could say that, for a given model and data, if the posterior carries the same amount of information as the prior, then nothing was learned about the model from this data, and the case is unidentifiable. If on the other hand, the data are informative about the model parameters, then the posterior will be more informative than the prior (less information entropy than the prior, and KL divergence is positive) and the case is identifiable. Based on all the intermediate states, that is, how much information gain happened, we can talk about more or less identifiable cases when the information gain from the prior to the posterior is more or less respectively.
What's the problem with model identifiability?
I recommend you read Andrew Gelman's blog post Think identifiability Bayesian inference. Right off the bat, I can tell you that identifiability does not have to do with a model by itself (as in "an u
What's the problem with model identifiability? I recommend you read Andrew Gelman's blog post Think identifiability Bayesian inference. Right off the bat, I can tell you that identifiability does not have to do with a model by itself (as in "an unidentifiable model"), rather than with the combination of this model with some data. That is to say, it has to do with the data also. The same model may be identifiable with some data, and unidentifiable with some other data. In a Bayesian context, it is not clear as to what exactly identifiability means. As the link I provided says, it is not a "black-or-white" case. Rather, it has to with the amount of information learned from the data, or the "distance" of the posterior from the prior. A perhaps suitable measure of information might be the Information Entropy, and while you are at it, the "distance" between two probability distributions (prior and posterior in this case) may be quantified by the Kullback-Leibler divergence, both of which can be found in the Wikipedia page on information theory. So you could say that, for a given model and data, if the posterior carries the same amount of information as the prior, then nothing was learned about the model from this data, and the case is unidentifiable. If on the other hand, the data are informative about the model parameters, then the posterior will be more informative than the prior (less information entropy than the prior, and KL divergence is positive) and the case is identifiable. Based on all the intermediate states, that is, how much information gain happened, we can talk about more or less identifiable cases when the information gain from the prior to the posterior is more or less respectively.
What's the problem with model identifiability? I recommend you read Andrew Gelman's blog post Think identifiability Bayesian inference. Right off the bat, I can tell you that identifiability does not have to do with a model by itself (as in "an u
42,535
Difference between "estimated" and "fitted"?
I think the term "fitted" is mostly used in regression frameworks where you fit a line through data. For example: $\hat{y}=\beta_{0}+\beta_{1}x$. The value of the fitted line at the data point $x_{i}$ is then called the fitted value or the predicted value at this point ($\hat{y_{i}}$). The term estimate is in generally used whenever you estimate a population parameter - that might be a slope, mean, standard deviation etc. - from a sample. For example: we say we estimate the population mean $\mu$ by the sample mean $\bar{x}$, so $\hat{\mu}=\bar{x}$. Parameter estimates are usually denoted by a hat operator: $\hat{\sigma}$, $\hat{y_{i}}$, $\hat{\mu}$ etc. So the predicted value in a regression ($\hat{y_{i}}$) can also be seen as an estimate at the point $y_{i}$.
Difference between "estimated" and "fitted"?
I think the term "fitted" is mostly used in regression frameworks where you fit a line through data. For example: $\hat{y}=\beta_{0}+\beta_{1}x$. The value of the fitted line at the data point $x_{i}$
Difference between "estimated" and "fitted"? I think the term "fitted" is mostly used in regression frameworks where you fit a line through data. For example: $\hat{y}=\beta_{0}+\beta_{1}x$. The value of the fitted line at the data point $x_{i}$ is then called the fitted value or the predicted value at this point ($\hat{y_{i}}$). The term estimate is in generally used whenever you estimate a population parameter - that might be a slope, mean, standard deviation etc. - from a sample. For example: we say we estimate the population mean $\mu$ by the sample mean $\bar{x}$, so $\hat{\mu}=\bar{x}$. Parameter estimates are usually denoted by a hat operator: $\hat{\sigma}$, $\hat{y_{i}}$, $\hat{\mu}$ etc. So the predicted value in a regression ($\hat{y_{i}}$) can also be seen as an estimate at the point $y_{i}$.
Difference between "estimated" and "fitted"? I think the term "fitted" is mostly used in regression frameworks where you fit a line through data. For example: $\hat{y}=\beta_{0}+\beta_{1}x$. The value of the fitted line at the data point $x_{i}$
42,536
Difference between "estimated" and "fitted"?
Often you want to fit a model, not values. The estimate of parameters of this model are then estimated using an estimator, that is a specific estimation technique. For example in Tsay, the standard deviation (volatility) is a parameter that is estimated. It sounds clear to me. In the R manual, "fitted values" sounds very unclear. Are they speaking about evaluations from an already fitted model?
Difference between "estimated" and "fitted"?
Often you want to fit a model, not values. The estimate of parameters of this model are then estimated using an estimator, that is a specific estimation technique. For example in Tsay, the standard de
Difference between "estimated" and "fitted"? Often you want to fit a model, not values. The estimate of parameters of this model are then estimated using an estimator, that is a specific estimation technique. For example in Tsay, the standard deviation (volatility) is a parameter that is estimated. It sounds clear to me. In the R manual, "fitted values" sounds very unclear. Are they speaking about evaluations from an already fitted model?
Difference between "estimated" and "fitted"? Often you want to fit a model, not values. The estimate of parameters of this model are then estimated using an estimator, that is a specific estimation technique. For example in Tsay, the standard de
42,537
What does the Semivariance tell me?
The context is a stationary spatial random process ("random field"). Imagine--quite hypothetically--that this process is infinite in extent and that you can take arbitrarily large samples of the point locations and observe the field's values there. Consider such a sample where all points are further apart than the range of the variogram: by definition of the range, this means the observations are uncorrelated. The sill estimates the variance of such large samples. Because the sill is a variance, its units of measurement are the squares of the units of observation: counts of people in this case. Therefore, $4300$ is squared numbers of people. It becomes a little more interpretable when you take its square root: that's $66$ people. One way in which this number can be used is that if you have a reasonable (unbiased and accurate) estimate of the overall mean of the process, then--within the kinds of large, spatially sparse samples I have described--you should expect most of the observations to be within $66$ of that mean and the large majority to be within two or three multiples of $66$ of that mean. (See the 68-95-99.7 rule.) In this sense, the sill tells you how much variation there is overall in the data, after adjusting for possible correlations among the more closely-spaced points. As an example of how the sill might be used in practice, consider the problem of fitting a variogram model to the empirical variogram. To do this, one typically chooses a model type (which determines the possible shapes of the empirical variogram) and then determines three parameters: the nugget, range, and sill. (Conventions vary: I have used "sill" here to mean the asymptotic level of the variogram, which therefore includes any contribution by a nugget.) If you first compute the variance of the data, disregarding their locations, and if your variogram shape is a typical one without any "hole effect" that allows for negative correlations, then you will want to make sure to estimate a sill that is slightly larger than the variance. This preliminary estimate lets you focus on the more important problems of estimating the shape, nugget, and range, which have far more influence on the kriging predictor. In this particular application (population) there are two important complications that ought to be addressed. The first is that population is not a function of a point, but of a spatial region. Unless those regions have approximately the same areas, the variogram will be deceptive and steps should be taken to effect a "change of support.". The use of a grid (as mentioned in a comment) is one way to deal with this, provided the population can be accurately estimated within the grid cells (which is often not the case). The second complication is that such data cannot be expected to be stationary at all: at a minimum, we would anticipate that their variance would be proportional to the population (as it is for a Poisson random field). This can be handled in various ad hoc ways, such as by analyzing the square root of the values, or more formally with a spatial generalized linear model as described by Diggle & Ribeiro Jr. in Model-Based Geostatistics (with free R code available).
What does the Semivariance tell me?
The context is a stationary spatial random process ("random field"). Imagine--quite hypothetically--that this process is infinite in extent and that you can take arbitrarily large samples of the poin
What does the Semivariance tell me? The context is a stationary spatial random process ("random field"). Imagine--quite hypothetically--that this process is infinite in extent and that you can take arbitrarily large samples of the point locations and observe the field's values there. Consider such a sample where all points are further apart than the range of the variogram: by definition of the range, this means the observations are uncorrelated. The sill estimates the variance of such large samples. Because the sill is a variance, its units of measurement are the squares of the units of observation: counts of people in this case. Therefore, $4300$ is squared numbers of people. It becomes a little more interpretable when you take its square root: that's $66$ people. One way in which this number can be used is that if you have a reasonable (unbiased and accurate) estimate of the overall mean of the process, then--within the kinds of large, spatially sparse samples I have described--you should expect most of the observations to be within $66$ of that mean and the large majority to be within two or three multiples of $66$ of that mean. (See the 68-95-99.7 rule.) In this sense, the sill tells you how much variation there is overall in the data, after adjusting for possible correlations among the more closely-spaced points. As an example of how the sill might be used in practice, consider the problem of fitting a variogram model to the empirical variogram. To do this, one typically chooses a model type (which determines the possible shapes of the empirical variogram) and then determines three parameters: the nugget, range, and sill. (Conventions vary: I have used "sill" here to mean the asymptotic level of the variogram, which therefore includes any contribution by a nugget.) If you first compute the variance of the data, disregarding their locations, and if your variogram shape is a typical one without any "hole effect" that allows for negative correlations, then you will want to make sure to estimate a sill that is slightly larger than the variance. This preliminary estimate lets you focus on the more important problems of estimating the shape, nugget, and range, which have far more influence on the kriging predictor. In this particular application (population) there are two important complications that ought to be addressed. The first is that population is not a function of a point, but of a spatial region. Unless those regions have approximately the same areas, the variogram will be deceptive and steps should be taken to effect a "change of support.". The use of a grid (as mentioned in a comment) is one way to deal with this, provided the population can be accurately estimated within the grid cells (which is often not the case). The second complication is that such data cannot be expected to be stationary at all: at a minimum, we would anticipate that their variance would be proportional to the population (as it is for a Poisson random field). This can be handled in various ad hoc ways, such as by analyzing the square root of the values, or more formally with a spatial generalized linear model as described by Diggle & Ribeiro Jr. in Model-Based Geostatistics (with free R code available).
What does the Semivariance tell me? The context is a stationary spatial random process ("random field"). Imagine--quite hypothetically--that this process is infinite in extent and that you can take arbitrarily large samples of the poin
42,538
What does the Semivariance tell me?
from Wikipedia: $\hat{\gamma}(h):=\frac{1}{|N(h)|}\sum_{(i,j)\in N(h)} |z_i-z_j|^2$ where $N(h)$ denotes the set of pairs of observations $i,\;j$ such that $|x_i-x_j| = h$, and $|N(h)|$ is the number of pairs in the set. Your sill is the limit for $\hat{\gamma} (h)$ you observe. According to the formula, it is the mean squared difference in $z$ you observe for points that are at least $h \geq range$ apart from each other. Wikipedia goes on saying: If the random field is stationary and ergodic, the $\lim_{h\to \infty} \gamma_s(h) = var(Z(x))$ corresponds to the variance of the field. A value of 4300 doesn't tell much without its unit. With the unit it tells you how much your $z$ varies between points that are far enough apart to be considered independent. You may find $\sqrt{sill}$ convenient as it has the same unit as your $z$ (under the conditions given above, it is your estimate of the standard deviation of $Z$). In any case (without the assumptions, i.e. there may be a difference in the mean), you can think of the sill as behaving like a mean squared difference.
What does the Semivariance tell me?
from Wikipedia: $\hat{\gamma}(h):=\frac{1}{|N(h)|}\sum_{(i,j)\in N(h)} |z_i-z_j|^2$ where $N(h)$ denotes the set of pairs of observations $i,\;j$ such that $|x_i-x_j| = h$, and $|N(h)|$ is th
What does the Semivariance tell me? from Wikipedia: $\hat{\gamma}(h):=\frac{1}{|N(h)|}\sum_{(i,j)\in N(h)} |z_i-z_j|^2$ where $N(h)$ denotes the set of pairs of observations $i,\;j$ such that $|x_i-x_j| = h$, and $|N(h)|$ is the number of pairs in the set. Your sill is the limit for $\hat{\gamma} (h)$ you observe. According to the formula, it is the mean squared difference in $z$ you observe for points that are at least $h \geq range$ apart from each other. Wikipedia goes on saying: If the random field is stationary and ergodic, the $\lim_{h\to \infty} \gamma_s(h) = var(Z(x))$ corresponds to the variance of the field. A value of 4300 doesn't tell much without its unit. With the unit it tells you how much your $z$ varies between points that are far enough apart to be considered independent. You may find $\sqrt{sill}$ convenient as it has the same unit as your $z$ (under the conditions given above, it is your estimate of the standard deviation of $Z$). In any case (without the assumptions, i.e. there may be a difference in the mean), you can think of the sill as behaving like a mean squared difference.
What does the Semivariance tell me? from Wikipedia: $\hat{\gamma}(h):=\frac{1}{|N(h)|}\sum_{(i,j)\in N(h)} |z_i-z_j|^2$ where $N(h)$ denotes the set of pairs of observations $i,\;j$ such that $|x_i-x_j| = h$, and $|N(h)|$ is th
42,539
Confidence intervals based on the CLT: ever useful?
The speed of convergence towards Gaussian depends on the exact laws, and in particular on the values of the cumulants: if there are no cumulant of order 1 or 2, i.e. no mean or no variance, you cannnot expect convergence to the normal; if cumulants of order 1 and 2 exist, it all depends on the cumulants of higher order. The smaller they are, the faster the sum converges to the normal, because the starting law is already close to the normal. For instance, it is generally considered that a $Poi(20)$ law can be well approximated by a $N(20,20)$. However, $\sqrt{20}$ is still non-negligible compared to $20$. Bounds for the difference between normal and exact are given by the Berry - Esseen theorem, but I am not sure they would be applicable in practice because you would need to know the third moment, which is difficult to estimate from the data. In practice, judgment is required, and the approximation must be avoided whenever laws show a strong difference with normality: very non-centered or heavy tails (see for instance a qq plot). Bootstrapping might also help: if your empirical data is close enough to normal, then bootstrapping and reestimating should give something close again to the approximate formula.
Confidence intervals based on the CLT: ever useful?
The speed of convergence towards Gaussian depends on the exact laws, and in particular on the values of the cumulants: if there are no cumulant of order 1 or 2, i.e. no mean or no variance, you cannn
Confidence intervals based on the CLT: ever useful? The speed of convergence towards Gaussian depends on the exact laws, and in particular on the values of the cumulants: if there are no cumulant of order 1 or 2, i.e. no mean or no variance, you cannnot expect convergence to the normal; if cumulants of order 1 and 2 exist, it all depends on the cumulants of higher order. The smaller they are, the faster the sum converges to the normal, because the starting law is already close to the normal. For instance, it is generally considered that a $Poi(20)$ law can be well approximated by a $N(20,20)$. However, $\sqrt{20}$ is still non-negligible compared to $20$. Bounds for the difference between normal and exact are given by the Berry - Esseen theorem, but I am not sure they would be applicable in practice because you would need to know the third moment, which is difficult to estimate from the data. In practice, judgment is required, and the approximation must be avoided whenever laws show a strong difference with normality: very non-centered or heavy tails (see for instance a qq plot). Bootstrapping might also help: if your empirical data is close enough to normal, then bootstrapping and reestimating should give something close again to the approximate formula.
Confidence intervals based on the CLT: ever useful? The speed of convergence towards Gaussian depends on the exact laws, and in particular on the values of the cumulants: if there are no cumulant of order 1 or 2, i.e. no mean or no variance, you cannn
42,540
Which performance measure for unbalanced binary classification without an 'active' class?
Have a look at the Matthews Correlation Coefficient $$MCC = \frac{TP \cdot TN - FP \cdot FN}{\sqrt{ (TP + FP)(TP + FN)(TN + FP)(TN + FN) }}$$ I have seen it pretty often as performance metrix in classification of SNPs dataset. Have a look at this link as well, they discuss the difference between AUC and MCC Otherwise you can just compute an average accuracy (average error rate), I have seen people using it in multiclass problems as well. $$AAcc = \frac{1}{2} \bigg( \frac{TP}{TP + FN} + \frac{TN}{TN + FP} \bigg) $$ Usually it is used in authentication systems under the form of Half Total Error Rate. E.g. here they provided a statistical test for that.
Which performance measure for unbalanced binary classification without an 'active' class?
Have a look at the Matthews Correlation Coefficient $$MCC = \frac{TP \cdot TN - FP \cdot FN}{\sqrt{ (TP + FP)(TP + FN)(TN + FP)(TN + FN) }}$$ I have seen it pretty often as performance metrix in clas
Which performance measure for unbalanced binary classification without an 'active' class? Have a look at the Matthews Correlation Coefficient $$MCC = \frac{TP \cdot TN - FP \cdot FN}{\sqrt{ (TP + FP)(TP + FN)(TN + FP)(TN + FN) }}$$ I have seen it pretty often as performance metrix in classification of SNPs dataset. Have a look at this link as well, they discuss the difference between AUC and MCC Otherwise you can just compute an average accuracy (average error rate), I have seen people using it in multiclass problems as well. $$AAcc = \frac{1}{2} \bigg( \frac{TP}{TP + FN} + \frac{TN}{TN + FP} \bigg) $$ Usually it is used in authentication systems under the form of Half Total Error Rate. E.g. here they provided a statistical test for that.
Which performance measure for unbalanced binary classification without an 'active' class? Have a look at the Matthews Correlation Coefficient $$MCC = \frac{TP \cdot TN - FP \cdot FN}{\sqrt{ (TP + FP)(TP + FN)(TN + FP)(TN + FN) }}$$ I have seen it pretty often as performance metrix in clas
42,541
What is better to transform doing linear regression, response or explanatory variable(s)?
It depends on the situation. When you have multiple independent variables, sometimes only one of them has a nonlinear relationship - in this case, transforming the dependent variable may cause problems with the other variables. In some cases, a log transform makes more substantive sense for one or the other variable. If you log transform the DV only then you are saying that arithmetic changes in the IVs relate to geometric changes in the DV. If you transform (some or all) IVs, then just the reverse. Often, variables related to income or other amounts make more sense log transformed. That is, a change in income from \$20,000 per year to \$40,000 is more like (in some sense) a change from \$200,000 to \$400,000 than a change from \$200,000 to \$220,000. If NONE of your variables can be sensibly log-transformed, it might be better to pursue some non-linear regression such as splines.
What is better to transform doing linear regression, response or explanatory variable(s)?
It depends on the situation. When you have multiple independent variables, sometimes only one of them has a nonlinear relationship - in this case, transforming the dependent variable may cause problem
What is better to transform doing linear regression, response or explanatory variable(s)? It depends on the situation. When you have multiple independent variables, sometimes only one of them has a nonlinear relationship - in this case, transforming the dependent variable may cause problems with the other variables. In some cases, a log transform makes more substantive sense for one or the other variable. If you log transform the DV only then you are saying that arithmetic changes in the IVs relate to geometric changes in the DV. If you transform (some or all) IVs, then just the reverse. Often, variables related to income or other amounts make more sense log transformed. That is, a change in income from \$20,000 per year to \$40,000 is more like (in some sense) a change from \$200,000 to \$400,000 than a change from \$200,000 to \$220,000. If NONE of your variables can be sensibly log-transformed, it might be better to pursue some non-linear regression such as splines.
What is better to transform doing linear regression, response or explanatory variable(s)? It depends on the situation. When you have multiple independent variables, sometimes only one of them has a nonlinear relationship - in this case, transforming the dependent variable may cause problem
42,542
What is better to transform doing linear regression, response or explanatory variable(s)?
Doing linear reg. its better to tranform the independent (explanatory ) variable and use the tranformation methods according to your data and cheak r-square for the model and MSE(mean square of error) for the modle if r-square is higher and MSE is mininmum you can say tranformation is appropriate..
What is better to transform doing linear regression, response or explanatory variable(s)?
Doing linear reg. its better to tranform the independent (explanatory ) variable and use the tranformation methods according to your data and cheak r-square for the model and MSE(mean square of error)
What is better to transform doing linear regression, response or explanatory variable(s)? Doing linear reg. its better to tranform the independent (explanatory ) variable and use the tranformation methods according to your data and cheak r-square for the model and MSE(mean square of error) for the modle if r-square is higher and MSE is mininmum you can say tranformation is appropriate..
What is better to transform doing linear regression, response or explanatory variable(s)? Doing linear reg. its better to tranform the independent (explanatory ) variable and use the tranformation methods according to your data and cheak r-square for the model and MSE(mean square of error)
42,543
Confusion about scatter matrices
What @whuber and I were saying to you in the comments are equivalent things. @whuber pointed out that the text you were reading makes points column vectors. I stuck to your own original notation where points are row vectors (this way of presenting is more common). When points are columns, thansposed ("T", or just ' in my notation) multiplier is the right one; when they are rows, it is the left one. Instead of multiplying separate vectors, it's more convenient to multiply whole matrices. See it with your data (matrix A = your "Ck"): ****** Points are rows, variables are columns [more common] ****** A 1 2 3 4 5 6 Column-centered A -1.500000000 -1.500000000 -1.500000000 1.500000000 1.500000000 1.500000000 A'A, the scatter matrix 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 ****** Points are columns, variables are rows [that's how in your book] ****** A 1 4 2 5 3 6 Row-centered A -1.500000000 1.500000000 -1.500000000 1.500000000 -1.500000000 1.500000000 AA', the scatter matrix 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000
Confusion about scatter matrices
What @whuber and I were saying to you in the comments are equivalent things. @whuber pointed out that the text you were reading makes points column vectors. I stuck to your own original notation where
Confusion about scatter matrices What @whuber and I were saying to you in the comments are equivalent things. @whuber pointed out that the text you were reading makes points column vectors. I stuck to your own original notation where points are row vectors (this way of presenting is more common). When points are columns, thansposed ("T", or just ' in my notation) multiplier is the right one; when they are rows, it is the left one. Instead of multiplying separate vectors, it's more convenient to multiply whole matrices. See it with your data (matrix A = your "Ck"): ****** Points are rows, variables are columns [more common] ****** A 1 2 3 4 5 6 Column-centered A -1.500000000 -1.500000000 -1.500000000 1.500000000 1.500000000 1.500000000 A'A, the scatter matrix 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 ****** Points are columns, variables are rows [that's how in your book] ****** A 1 4 2 5 3 6 Row-centered A -1.500000000 1.500000000 -1.500000000 1.500000000 -1.500000000 1.500000000 AA', the scatter matrix 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000 4.500000000
Confusion about scatter matrices What @whuber and I were saying to you in the comments are equivalent things. @whuber pointed out that the text you were reading makes points column vectors. I stuck to your own original notation where
42,544
How bad is considering a random effect as a fixed effect?
Doug Bates (author of R package lme4) writes in his unpublished book (available online) that 6 levels are the minimum number required for obtaining reasonable estimates of variance components. By treating the technician effect as fixed, one loses the interpretation of the regression generalizing to a population of technicians. The strict interpretation is that the regression applies only to those samples. So you have a trade-off between these ideas. Also note that PROC GLIMMIX in SAS will fit multinomial models with random effects.
How bad is considering a random effect as a fixed effect?
Doug Bates (author of R package lme4) writes in his unpublished book (available online) that 6 levels are the minimum number required for obtaining reasonable estimates of variance components. By trea
How bad is considering a random effect as a fixed effect? Doug Bates (author of R package lme4) writes in his unpublished book (available online) that 6 levels are the minimum number required for obtaining reasonable estimates of variance components. By treating the technician effect as fixed, one loses the interpretation of the regression generalizing to a population of technicians. The strict interpretation is that the regression applies only to those samples. So you have a trade-off between these ideas. Also note that PROC GLIMMIX in SAS will fit multinomial models with random effects.
How bad is considering a random effect as a fixed effect? Doug Bates (author of R package lme4) writes in his unpublished book (available online) that 6 levels are the minimum number required for obtaining reasonable estimates of variance components. By trea
42,545
Nearest Neighbor Algorithm for Circular dimensions
How many circular dimensions are there? Two of the tricks described below trade off resources for representational convenience, unfortunately exponentially on the number of circular dimensions. There are at least three tricks you can use: Use coordinate patches: create many small kd-trees, overlapping so that they are locally continuous. This will not work if your range queries are wide enough to go past the boundaries of the patch. You can manually glue the pieces of the space by making extra queries across the boundaries and adding a post-processing pass. This will be exponential in the dimension of the corner the point is closest to, but will use no extra memory. Use multiple covering. In other words, unwrap the space along every border, and make each point have many representations so the boundaries "are invisible". With one circular dimension, :01 would be stored as three points: :-59, :01, :61 With two circular dimensions, you'd have 00:01 stored as -24:-59, 00:-59, 24:-59 -24:01, 00:01, 24:01 -24:61, 00:61: 24:61 You can see that the space blowup increases exponentially with the number of circular dimensions. The advantage is that with this representation, the querying is exactly the same as before. (Of course, this is just a materialization of trick 2). If you know how far back your range queries work, then you might be able to prevent multiplication of some of the points (if they're sufficiently deep in the interior of the space)
Nearest Neighbor Algorithm for Circular dimensions
How many circular dimensions are there? Two of the tricks described below trade off resources for representational convenience, unfortunately exponentially on the number of circular dimensions. There
Nearest Neighbor Algorithm for Circular dimensions How many circular dimensions are there? Two of the tricks described below trade off resources for representational convenience, unfortunately exponentially on the number of circular dimensions. There are at least three tricks you can use: Use coordinate patches: create many small kd-trees, overlapping so that they are locally continuous. This will not work if your range queries are wide enough to go past the boundaries of the patch. You can manually glue the pieces of the space by making extra queries across the boundaries and adding a post-processing pass. This will be exponential in the dimension of the corner the point is closest to, but will use no extra memory. Use multiple covering. In other words, unwrap the space along every border, and make each point have many representations so the boundaries "are invisible". With one circular dimension, :01 would be stored as three points: :-59, :01, :61 With two circular dimensions, you'd have 00:01 stored as -24:-59, 00:-59, 24:-59 -24:01, 00:01, 24:01 -24:61, 00:61: 24:61 You can see that the space blowup increases exponentially with the number of circular dimensions. The advantage is that with this representation, the querying is exactly the same as before. (Of course, this is just a materialization of trick 2). If you know how far back your range queries work, then you might be able to prevent multiplication of some of the points (if they're sufficiently deep in the interior of the space)
Nearest Neighbor Algorithm for Circular dimensions How many circular dimensions are there? Two of the tricks described below trade off resources for representational convenience, unfortunately exponentially on the number of circular dimensions. There
42,546
Nearest Neighbor Algorithm for Circular dimensions
Try a clustering algorithm like DBScan. R and Weka both have this algo. It's density based. So if the clusters are continuous in nature for the day, it should do a good job of making a cluster for a day.
Nearest Neighbor Algorithm for Circular dimensions
Try a clustering algorithm like DBScan. R and Weka both have this algo. It's density based. So if the clusters are continuous in nature for the day, it should do a good job of making a cluster for a
Nearest Neighbor Algorithm for Circular dimensions Try a clustering algorithm like DBScan. R and Weka both have this algo. It's density based. So if the clusters are continuous in nature for the day, it should do a good job of making a cluster for a day.
Nearest Neighbor Algorithm for Circular dimensions Try a clustering algorithm like DBScan. R and Weka both have this algo. It's density based. So if the clusters are continuous in nature for the day, it should do a good job of making a cluster for a
42,547
Can one compute confidence intervals for a census with high nonresponse rates?
In general, no, you cannot do this. More detail: The problem is that the 32% may be different from the 68%. If all you know is that they are missing then you have no way of saying in what way they may be different. But it's complex. With any missing data problem, even one with a census, one key thing is to determine (if you can) why there are missing data. The standard classification is: Missing completely at random (MCAR)- that is, there is no particular reason why they are missing. Perhaps coffee spilled on their records. Or perhaps a random computer glitch did not send them the questionnaire. Missing at random (MAR: The reasons for the missingness are captured by data that you do have. E.g., it is known that people at both ends of the income scale are less likely to answer the phone which would give missing data on a phone interview. But if you know the income of people who don't respond, then the data may be MAR. Not missing at random (NMAR): Neither of the above. If data is MCAR then your 68% results can be used "as is" as estimates of the population values. If data are MAR then there are various approaches; probably the most popular now is multiple imputation. If data are NMAR then there is no perfect solution, but I have seen some work showing that multiple imputation works reasonably well unless the data are "REALLY NMAR" (I saw a presentation by Joe Schafer, who is one of the real experts on this).
Can one compute confidence intervals for a census with high nonresponse rates?
In general, no, you cannot do this. More detail: The problem is that the 32% may be different from the 68%. If all you know is that they are missing then you have no way of saying in what way they may
Can one compute confidence intervals for a census with high nonresponse rates? In general, no, you cannot do this. More detail: The problem is that the 32% may be different from the 68%. If all you know is that they are missing then you have no way of saying in what way they may be different. But it's complex. With any missing data problem, even one with a census, one key thing is to determine (if you can) why there are missing data. The standard classification is: Missing completely at random (MCAR)- that is, there is no particular reason why they are missing. Perhaps coffee spilled on their records. Or perhaps a random computer glitch did not send them the questionnaire. Missing at random (MAR: The reasons for the missingness are captured by data that you do have. E.g., it is known that people at both ends of the income scale are less likely to answer the phone which would give missing data on a phone interview. But if you know the income of people who don't respond, then the data may be MAR. Not missing at random (NMAR): Neither of the above. If data is MCAR then your 68% results can be used "as is" as estimates of the population values. If data are MAR then there are various approaches; probably the most popular now is multiple imputation. If data are NMAR then there is no perfect solution, but I have seen some work showing that multiple imputation works reasonably well unless the data are "REALLY NMAR" (I saw a presentation by Joe Schafer, who is one of the real experts on this).
Can one compute confidence intervals for a census with high nonresponse rates? In general, no, you cannot do this. More detail: The problem is that the 32% may be different from the 68%. If all you know is that they are missing then you have no way of saying in what way they may
42,548
Method of p value correction for a set of dependent p values
You should definitely correct for multiple comparisons! There are a huge number of strategies for this, many of which are suitable for dependent data. The Benjamini–Hochberg–Yekutieli procedure is computationally simple approach to setting the false discovery rate and works under arbitrary dependence assumptions; your tests don't need to be independent for it to be appropriate. In brief, perform all $m$ of your individual tests, recording the $p$-values as you go. Sort them from smallest to largest, creating a list $p_1 \ldots p_m.$ Find the largest value of $k$ such that: $$ p_k \le \alpha \cdot \frac{k}{m \cdot c(m)}$$ where $c(m)=1$ if the tests are independent or positively correlated, or for arbitrary dependence $c(m) = \sum_i^m \frac{1}{i} \approx \ln(m) + \gamma$, where $\gamma$ is the Euler–Mascheroni constant (0.5772...). Accept as significant all the $p$-values less than or equal to $p_k$, but reject the rest as non-significant. Note that this is somewhat more liberal (i.e., has better power, but more Type I errors) than something which controls the Familywise Error Rate. However, people typically use the same $\alpha$ value (0.05, 0.01, etc). Setting $\alpha=0.2$ seems like it would be asking for a lot of spurious calls! Further reading: Wikipedia Page on FDR Benjamini and Yekutieli (2001). "The control of the false discovery rate in multiple testing under dependency" Annals of Statistics 29 (4): 1165–1188. "Comparison Shopping" for False Discovery Rate packages in R
Method of p value correction for a set of dependent p values
You should definitely correct for multiple comparisons! There are a huge number of strategies for this, many of which are suitable for dependent data. The Benjamini–Hochberg–Yekutieli procedure is com
Method of p value correction for a set of dependent p values You should definitely correct for multiple comparisons! There are a huge number of strategies for this, many of which are suitable for dependent data. The Benjamini–Hochberg–Yekutieli procedure is computationally simple approach to setting the false discovery rate and works under arbitrary dependence assumptions; your tests don't need to be independent for it to be appropriate. In brief, perform all $m$ of your individual tests, recording the $p$-values as you go. Sort them from smallest to largest, creating a list $p_1 \ldots p_m.$ Find the largest value of $k$ such that: $$ p_k \le \alpha \cdot \frac{k}{m \cdot c(m)}$$ where $c(m)=1$ if the tests are independent or positively correlated, or for arbitrary dependence $c(m) = \sum_i^m \frac{1}{i} \approx \ln(m) + \gamma$, where $\gamma$ is the Euler–Mascheroni constant (0.5772...). Accept as significant all the $p$-values less than or equal to $p_k$, but reject the rest as non-significant. Note that this is somewhat more liberal (i.e., has better power, but more Type I errors) than something which controls the Familywise Error Rate. However, people typically use the same $\alpha$ value (0.05, 0.01, etc). Setting $\alpha=0.2$ seems like it would be asking for a lot of spurious calls! Further reading: Wikipedia Page on FDR Benjamini and Yekutieli (2001). "The control of the false discovery rate in multiple testing under dependency" Annals of Statistics 29 (4): 1165–1188. "Comparison Shopping" for False Discovery Rate packages in R
Method of p value correction for a set of dependent p values You should definitely correct for multiple comparisons! There are a huge number of strategies for this, many of which are suitable for dependent data. The Benjamini–Hochberg–Yekutieli procedure is com
42,549
When is blocked Metropolis sampling more efficient?
I don't have references on hand, unfortunately, but generally the more dependence there is between $X$ and $Y$, the more efficient it will be to update them jointly. In your example $X$ and $Y$ are independent; if, for example, $X$ and $Y$ were still jointly Gaussian but had a correlation of .99, updating them separately would be much worse. Updating them jointly will also not be very efficient unless your proposal distribution has roughly the same shape as the distribution you're sampling from, which motivated the development of adaptive MCMC methods which change the proposal distribution over time. The best-known paper on this is Haario et al. (2001), but there has been significant work in the area since then. With a good proposal distribution (either by making it adaptive or just by having a lucky guess), joint updating in the highly correlated case is just as efficient as joint updating in the independent case, while individual updating is still horribly slow.
When is blocked Metropolis sampling more efficient?
I don't have references on hand, unfortunately, but generally the more dependence there is between $X$ and $Y$, the more efficient it will be to update them jointly. In your example $X$ and $Y$ are in
When is blocked Metropolis sampling more efficient? I don't have references on hand, unfortunately, but generally the more dependence there is between $X$ and $Y$, the more efficient it will be to update them jointly. In your example $X$ and $Y$ are independent; if, for example, $X$ and $Y$ were still jointly Gaussian but had a correlation of .99, updating them separately would be much worse. Updating them jointly will also not be very efficient unless your proposal distribution has roughly the same shape as the distribution you're sampling from, which motivated the development of adaptive MCMC methods which change the proposal distribution over time. The best-known paper on this is Haario et al. (2001), but there has been significant work in the area since then. With a good proposal distribution (either by making it adaptive or just by having a lucky guess), joint updating in the highly correlated case is just as efficient as joint updating in the independent case, while individual updating is still horribly slow.
When is blocked Metropolis sampling more efficient? I don't have references on hand, unfortunately, but generally the more dependence there is between $X$ and $Y$, the more efficient it will be to update them jointly. In your example $X$ and $Y$ are in
42,550
Exponent for non-linear regression (in R)?
In order that this receive an answer (though it may not add a heck of a lot to whuber's comment): I want to find the best way to determine the value for the exponent $\gamma$ in the following regression: $y = \beta x^\gamma$ The observed $y$ will not actually be $\beta x^\gamma$; if it were there'd be no need for statistics. We might say $E(y)=\beta x^\gamma$, for example, but it's not sufficient. To address this problem we would normally consider the distribution of $y$ given $x$, and describe how the distribution - or at least parameters that describe the distribution, such as at least the mean and variance - relates to $x$. In particular, we would (at least) consider the way the error term enters the relationship, such as: $y=\beta x^\gamma+\varepsilon\,$, or $y=\beta x^\gamma\times\eta$ If it's of the first form, and the (zero-mean) error terms are independent with $\text{Var}(\varepsilon)$ constant, then we'd use ordinary nonlinear least squares to estimate $\beta$ and $\gamma$. If it's of the second form, and the error terms are independent, $\eta$ is positive (such that $\log(\eta)$ is zero mean and constant variance), then we might take logs and estimate $\beta$ and $\gamma$ using linear regression. If, on the other hand, we assumed that the $\eta$ were gamma-distributed, then we might fit a gamma-family GLM with log-link. In some situations, it doesn't make sense to specify an error term at all; consider the situation where $y\sim \text{Poisson}(\beta x^\gamma)$; the specification $E(y)=\beta x^\gamma$ is correct, but to deal with things from there we're best leaving the model as $y\sim \text{Poisson}(\beta x^\gamma)$. Again, this would be fitted via a GLM with log-link. There are a number of other possibilities. If you really do need the nonlinear regression option (additive error, constant variance), then this is done using nls in R. This works a little differently to lm, because lm can simply assume one coefficient for every predictor. By contrast, nls needs us to specify the form of the model including the parameters. Here's an example (the data comes with R. It isn't necessarily suited to this model). carsfit=nls(dist~beta*speed^gamma,data=cars,start=list(beta=exp(-.73),gamma=1.6)) The start values came from an OLS regression on the logs of the y and x variables. summary(carsfit) Formula: dist ~ beta * speed^gamma Parameters: Estimate Std. Error t value Pr(>|t|) beta 0.5897 0.3357 1.757 0.0853 . gamma 1.5493 0.1920 8.068 1.74e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 15.06 on 48 degrees of freedom Number of iterations to convergence: 3 Achieved convergence tolerance: 4.979e-07
Exponent for non-linear regression (in R)?
In order that this receive an answer (though it may not add a heck of a lot to whuber's comment): I want to find the best way to determine the value for the exponent $\gamma$ in the following regress
Exponent for non-linear regression (in R)? In order that this receive an answer (though it may not add a heck of a lot to whuber's comment): I want to find the best way to determine the value for the exponent $\gamma$ in the following regression: $y = \beta x^\gamma$ The observed $y$ will not actually be $\beta x^\gamma$; if it were there'd be no need for statistics. We might say $E(y)=\beta x^\gamma$, for example, but it's not sufficient. To address this problem we would normally consider the distribution of $y$ given $x$, and describe how the distribution - or at least parameters that describe the distribution, such as at least the mean and variance - relates to $x$. In particular, we would (at least) consider the way the error term enters the relationship, such as: $y=\beta x^\gamma+\varepsilon\,$, or $y=\beta x^\gamma\times\eta$ If it's of the first form, and the (zero-mean) error terms are independent with $\text{Var}(\varepsilon)$ constant, then we'd use ordinary nonlinear least squares to estimate $\beta$ and $\gamma$. If it's of the second form, and the error terms are independent, $\eta$ is positive (such that $\log(\eta)$ is zero mean and constant variance), then we might take logs and estimate $\beta$ and $\gamma$ using linear regression. If, on the other hand, we assumed that the $\eta$ were gamma-distributed, then we might fit a gamma-family GLM with log-link. In some situations, it doesn't make sense to specify an error term at all; consider the situation where $y\sim \text{Poisson}(\beta x^\gamma)$; the specification $E(y)=\beta x^\gamma$ is correct, but to deal with things from there we're best leaving the model as $y\sim \text{Poisson}(\beta x^\gamma)$. Again, this would be fitted via a GLM with log-link. There are a number of other possibilities. If you really do need the nonlinear regression option (additive error, constant variance), then this is done using nls in R. This works a little differently to lm, because lm can simply assume one coefficient for every predictor. By contrast, nls needs us to specify the form of the model including the parameters. Here's an example (the data comes with R. It isn't necessarily suited to this model). carsfit=nls(dist~beta*speed^gamma,data=cars,start=list(beta=exp(-.73),gamma=1.6)) The start values came from an OLS regression on the logs of the y and x variables. summary(carsfit) Formula: dist ~ beta * speed^gamma Parameters: Estimate Std. Error t value Pr(>|t|) beta 0.5897 0.3357 1.757 0.0853 . gamma 1.5493 0.1920 8.068 1.74e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 15.06 on 48 degrees of freedom Number of iterations to convergence: 3 Achieved convergence tolerance: 4.979e-07
Exponent for non-linear regression (in R)? In order that this receive an answer (though it may not add a heck of a lot to whuber's comment): I want to find the best way to determine the value for the exponent $\gamma$ in the following regress
42,551
Is significance of the p-value reliable with extremely small sample sizes? [duplicate]
If you know that they are distributed normally you are right (with the addition, as @gung points out, that the variances need to be qual). The use of the t statistic with the appropriate degrees of freedom means that this approach is alright despite the tiny sample size. On your secondary question about what to do if the population distribution is not known, it would depend on which nonparametric test you used.
Is significance of the p-value reliable with extremely small sample sizes? [duplicate]
If you know that they are distributed normally you are right (with the addition, as @gung points out, that the variances need to be qual). The use of the t statistic with the appropriate degrees of f
Is significance of the p-value reliable with extremely small sample sizes? [duplicate] If you know that they are distributed normally you are right (with the addition, as @gung points out, that the variances need to be qual). The use of the t statistic with the appropriate degrees of freedom means that this approach is alright despite the tiny sample size. On your secondary question about what to do if the population distribution is not known, it would depend on which nonparametric test you used.
Is significance of the p-value reliable with extremely small sample sizes? [duplicate] If you know that they are distributed normally you are right (with the addition, as @gung points out, that the variances need to be qual). The use of the t statistic with the appropriate degrees of f
42,552
Definition of "optimal" instruments
I haven't read the particular page in the book, but here is my take on that. $\bar X = E(X|\Omega)$ $\rightarrow$ that's your 'ideal' first stage regression here. $\bar X$ is the set of all variables that are informative after controlling for everything else ($\Omega$) that determines Y. $E(V|\Omega) = 0$ $\rightarrow$ that's the validity assumption. The unobserved factors of $\bar X$ are not correlated with the determinants of Y. I provide you an example, Card (1992) instruments "years of education" with "travel distance to school" to determine the return on wages. He assumes that "intelligence" or "ability" is an unobserved factor that has not been controlled for. "Education" is therefore assumed endogenous as it relates to "ability". What is the set of optimal instruments? It is the set that fulfills the definition by Davidson and MacKinnon. Although Card uses only one instrument, the intuition can be exemplified here. In the first stage regression, $\bar X = E(X|\Omega)$, you would regress education on "distance to school" AND anything else that determines wages, e.g. age, grades, experience etc. If you can safely assume that after doing so, $E(V|\Omega) = 0$, then you have found your proper instrument. That the first assumption includes the whole information set $\Omega$ is necessary. It is wickedly conceivable that "distance to school" is related with "age" which is assumed to be related with "wage" but also "ability", as for example, older people live farther away from cities where schools were built but may be less/more able as they are a different generation. Failing to control for that, would invalidate your second assumption, $E(V|\Omega) = 0$. So the ideal set of instruments, needs to be correlated with your regression after 'partialling out' anything else that is known determine Y.
Definition of "optimal" instruments
I haven't read the particular page in the book, but here is my take on that. $\bar X = E(X|\Omega)$ $\rightarrow$ that's your 'ideal' first stage regression here. $\bar X$ is the set of all variables
Definition of "optimal" instruments I haven't read the particular page in the book, but here is my take on that. $\bar X = E(X|\Omega)$ $\rightarrow$ that's your 'ideal' first stage regression here. $\bar X$ is the set of all variables that are informative after controlling for everything else ($\Omega$) that determines Y. $E(V|\Omega) = 0$ $\rightarrow$ that's the validity assumption. The unobserved factors of $\bar X$ are not correlated with the determinants of Y. I provide you an example, Card (1992) instruments "years of education" with "travel distance to school" to determine the return on wages. He assumes that "intelligence" or "ability" is an unobserved factor that has not been controlled for. "Education" is therefore assumed endogenous as it relates to "ability". What is the set of optimal instruments? It is the set that fulfills the definition by Davidson and MacKinnon. Although Card uses only one instrument, the intuition can be exemplified here. In the first stage regression, $\bar X = E(X|\Omega)$, you would regress education on "distance to school" AND anything else that determines wages, e.g. age, grades, experience etc. If you can safely assume that after doing so, $E(V|\Omega) = 0$, then you have found your proper instrument. That the first assumption includes the whole information set $\Omega$ is necessary. It is wickedly conceivable that "distance to school" is related with "age" which is assumed to be related with "wage" but also "ability", as for example, older people live farther away from cities where schools were built but may be less/more able as they are a different generation. Failing to control for that, would invalidate your second assumption, $E(V|\Omega) = 0$. So the ideal set of instruments, needs to be correlated with your regression after 'partialling out' anything else that is known determine Y.
Definition of "optimal" instruments I haven't read the particular page in the book, but here is my take on that. $\bar X = E(X|\Omega)$ $\rightarrow$ that's your 'ideal' first stage regression here. $\bar X$ is the set of all variables
42,553
Optimal sampling to estimate a quadratic function
Let $y_i$ denote the random variable $\hat{f}(x_i)$ and $Y_n$ denote $\{y_i\}_{i \leq n}$, In the case where you have to fix all your points $\{x_i\}_{i \leq n}$ before you get any observation $y_i$, I suggest you to consider points which maximize some optimal design criterion. Like StasK said, D-optimality is a common criterion. Latin Hypercube Sampling is a simple way to approximate these designs, and is often implemented in software like Matlab. If your procedure is sequential, i.e. you know $Y_i$ before to choose $x_{i+1}$, you may want to include your prior knowledge about $f$. A good criterion is then Information Gain (a.k.a Mutual Information). $$I(y_{i+1} \mid Y_i) = H(y_{i+1}) - H(y_{i+1} \mid Y_i)$$ where $H(X)$ denote the differential entropy of the variable $X$. You can then choose the $x$ maximising the information gain at each step, $$x_{i+1} = \underset{x \in S^n}{argmax}\ I(x \mid Y_i)$$
Optimal sampling to estimate a quadratic function
Let $y_i$ denote the random variable $\hat{f}(x_i)$ and $Y_n$ denote $\{y_i\}_{i \leq n}$, In the case where you have to fix all your points $\{x_i\}_{i \leq n}$ before you get any observation $y_i$,
Optimal sampling to estimate a quadratic function Let $y_i$ denote the random variable $\hat{f}(x_i)$ and $Y_n$ denote $\{y_i\}_{i \leq n}$, In the case where you have to fix all your points $\{x_i\}_{i \leq n}$ before you get any observation $y_i$, I suggest you to consider points which maximize some optimal design criterion. Like StasK said, D-optimality is a common criterion. Latin Hypercube Sampling is a simple way to approximate these designs, and is often implemented in software like Matlab. If your procedure is sequential, i.e. you know $Y_i$ before to choose $x_{i+1}$, you may want to include your prior knowledge about $f$. A good criterion is then Information Gain (a.k.a Mutual Information). $$I(y_{i+1} \mid Y_i) = H(y_{i+1}) - H(y_{i+1} \mid Y_i)$$ where $H(X)$ denote the differential entropy of the variable $X$. You can then choose the $x$ maximising the information gain at each step, $$x_{i+1} = \underset{x \in S^n}{argmax}\ I(x \mid Y_i)$$
Optimal sampling to estimate a quadratic function Let $y_i$ denote the random variable $\hat{f}(x_i)$ and $Y_n$ denote $\{y_i\}_{i \leq n}$, In the case where you have to fix all your points $\{x_i\}_{i \leq n}$ before you get any observation $y_i$,
42,554
A "Gambler's Loss function"?
I imagine it would depend on the payout scheme. For example if being wrong isn't a continuum but a binary either/or, then you would probably want to pick a loss function like mean absolute error or accuracy so that all incorrect answers are treated equally. On the other hand, if being overconfident -- saying something has a high probability, and then being wrong -- is exponentially bad, you would want to use log loss as a loss function, since log loss has an exponential penalty and an infinite penalty if you say something is 100% likely and you're wrong. I imagine that if you sold derivatives / options (gambling in my opinion), you would want to use log loss since offering someone the option to buy stock ABC at 100.00 when it is currently at 80.00, and then seeing the price shoot up to 10,000.00 would be really bad and could bankrupt your company if sold in sufficiently large volumes. Getting wiped out (bankruptcy) would be considered infinitely bad.
A "Gambler's Loss function"?
I imagine it would depend on the payout scheme. For example if being wrong isn't a continuum but a binary either/or, then you would probably want to pick a loss function like mean absolute error or ac
A "Gambler's Loss function"? I imagine it would depend on the payout scheme. For example if being wrong isn't a continuum but a binary either/or, then you would probably want to pick a loss function like mean absolute error or accuracy so that all incorrect answers are treated equally. On the other hand, if being overconfident -- saying something has a high probability, and then being wrong -- is exponentially bad, you would want to use log loss as a loss function, since log loss has an exponential penalty and an infinite penalty if you say something is 100% likely and you're wrong. I imagine that if you sold derivatives / options (gambling in my opinion), you would want to use log loss since offering someone the option to buy stock ABC at 100.00 when it is currently at 80.00, and then seeing the price shoot up to 10,000.00 would be really bad and could bankrupt your company if sold in sufficiently large volumes. Getting wiped out (bankruptcy) would be considered infinitely bad.
A "Gambler's Loss function"? I imagine it would depend on the payout scheme. For example if being wrong isn't a continuum but a binary either/or, then you would probably want to pick a loss function like mean absolute error or ac
42,555
A "Gambler's Loss function"?
First a comment on the previous answer and then the answer. On derivatives/options it is more complicated than that. You would likely not sell short or sell a call without a stop loss order and/or a hedge. Let's say you sold an option to buy (a call) at 100, and bought a call at 200. A good loss function might be exponential up to 200, but after that it would be flat for you. So I think the best answer is similar to the previous, but to have a maximum penalty, (which unfortunately) makes the penalty function non-continuous.
A "Gambler's Loss function"?
First a comment on the previous answer and then the answer. On derivatives/options it is more complicated than that. You would likely not sell short or sell a call without a stop loss order and/or a h
A "Gambler's Loss function"? First a comment on the previous answer and then the answer. On derivatives/options it is more complicated than that. You would likely not sell short or sell a call without a stop loss order and/or a hedge. Let's say you sold an option to buy (a call) at 100, and bought a call at 200. A good loss function might be exponential up to 200, but after that it would be flat for you. So I think the best answer is similar to the previous, but to have a maximum penalty, (which unfortunately) makes the penalty function non-continuous.
A "Gambler's Loss function"? First a comment on the previous answer and then the answer. On derivatives/options it is more complicated than that. You would likely not sell short or sell a call without a stop loss order and/or a h
42,556
Small n: non-parametric or parametric tests?
The data were collected using Likert scales in a questionnaire. From the moment you decided to use Likert scales, the issue of whether or not the data were actually from a normal distribution was decided (in the negative). It's pointless to test (and answer with chance of error) a question to which you already know the answer with certainty (a large enough sample would always lead to rejection by a suitable test, but you can tell it is the case with no data at all). Your data are not from a normal distribution normal; that was already certain. [However, it's also not a useful question to answer; a better question to answer is not 'are the data from a normal distribution?' (are they ever?) but 'how much impact does it have on my inference?', a question not answered by hypothesis tests.] So now I am unsure whether or not I can use a parametric test That depends on the parametric test. Parametric doesn't necessarily imply "normal"; you may be able to make some other distributional assumption that will be consistent enough with your situation that you would be content with the impact of whatever deviation from assumptions you have. or whether I need to use non-parametric tests. Beware - nonparametric tests also have assumptions, and in some cases may be somewhat sensitive to them. Many nonparametric tests assume continuous data, for example, and if you don't account for heavy discreteness you may get tests with quite different properties from their nominal ones. Some assume symmetry. In addition, suitability of particular tests may depend on the precise hypothesis you're interested in - you may need some additional assumptions (or perhaps a somewhat different nonparametric procedure) to get a test of your actual hypothesis. I have found books stating that if you have a small n, you should always use non-parametric tests. For very small $n$, that's not necessarily useful advice, since you may have no useful significance levels available to you. At larger (but still small) $n$, in cases where the assumptions of a suitable nonparametric procedure are tenable, it sometimes makes sense to avoid making parametric assumptions to which your inferences may be sensitive (though there's sometimes the possibility of choosing different, less sensitive procedures). However I have also found citations Which citations? What did they actually say? stating that the choice between parametric and non-parametric tests depends on the level of your data (Likert can be seen as nominal) No. A single item intended as part of a Likert scale is at least ordinal. If you have constructed a Likert scale by adding a number of such questions you have already assumed it was interval - by assuming things like '5'+'2' = '4'+'3' (which must be the case if you're able to add the scores and treat every '7' as the same), every component item had to have been interval. If they're interval, their sum certainly is. so I should use parametric tests. I don't see how "use a parametric test" follows from that. You say very little about what kind of hypotheses you have (what are you trying to find out?); more might be said in those circumstances.
Small n: non-parametric or parametric tests?
The data were collected using Likert scales in a questionnaire. From the moment you decided to use Likert scales, the issue of whether or not the data were actually from a normal distribution was dec
Small n: non-parametric or parametric tests? The data were collected using Likert scales in a questionnaire. From the moment you decided to use Likert scales, the issue of whether or not the data were actually from a normal distribution was decided (in the negative). It's pointless to test (and answer with chance of error) a question to which you already know the answer with certainty (a large enough sample would always lead to rejection by a suitable test, but you can tell it is the case with no data at all). Your data are not from a normal distribution normal; that was already certain. [However, it's also not a useful question to answer; a better question to answer is not 'are the data from a normal distribution?' (are they ever?) but 'how much impact does it have on my inference?', a question not answered by hypothesis tests.] So now I am unsure whether or not I can use a parametric test That depends on the parametric test. Parametric doesn't necessarily imply "normal"; you may be able to make some other distributional assumption that will be consistent enough with your situation that you would be content with the impact of whatever deviation from assumptions you have. or whether I need to use non-parametric tests. Beware - nonparametric tests also have assumptions, and in some cases may be somewhat sensitive to them. Many nonparametric tests assume continuous data, for example, and if you don't account for heavy discreteness you may get tests with quite different properties from their nominal ones. Some assume symmetry. In addition, suitability of particular tests may depend on the precise hypothesis you're interested in - you may need some additional assumptions (or perhaps a somewhat different nonparametric procedure) to get a test of your actual hypothesis. I have found books stating that if you have a small n, you should always use non-parametric tests. For very small $n$, that's not necessarily useful advice, since you may have no useful significance levels available to you. At larger (but still small) $n$, in cases where the assumptions of a suitable nonparametric procedure are tenable, it sometimes makes sense to avoid making parametric assumptions to which your inferences may be sensitive (though there's sometimes the possibility of choosing different, less sensitive procedures). However I have also found citations Which citations? What did they actually say? stating that the choice between parametric and non-parametric tests depends on the level of your data (Likert can be seen as nominal) No. A single item intended as part of a Likert scale is at least ordinal. If you have constructed a Likert scale by adding a number of such questions you have already assumed it was interval - by assuming things like '5'+'2' = '4'+'3' (which must be the case if you're able to add the scores and treat every '7' as the same), every component item had to have been interval. If they're interval, their sum certainly is. so I should use parametric tests. I don't see how "use a parametric test" follows from that. You say very little about what kind of hypotheses you have (what are you trying to find out?); more might be said in those circumstances.
Small n: non-parametric or parametric tests? The data were collected using Likert scales in a questionnaire. From the moment you decided to use Likert scales, the issue of whether or not the data were actually from a normal distribution was dec
42,557
Small n: non-parametric or parametric tests?
The sample size is not an issue here. You can only use nonparametric procedures (depending on the particular question Wilcoxon test, rank correlation, Kruskal-Wallis test or others) with Likert scale data due to their ordinal scale. Parametric procedures use the spaceing between different levels. But on a Likert scale, this spaceing is not informative: You could code five levels by "1,2,3,4,5" or you could code them without changeing information by "1,10,20,34,100" or by "10,Jack,Queen,King,Ace". So parametric tests that would include this arbitrary information do not yield reproducible results (and in the latter case none at all). Sometimes however, the sample size is a criterion to decide between parametric and nonparametric tests. Namely, if you are unsure if the assumptions for one or another parametric test hold, but you have a large sample size, you can cross fingers that by the central limit theorem, the mean is approximately normally distributed. For small sample sizes, this approximation is rather not so good (e.g. if your data are exponentially distributed, you need really huge sample sizes for the t-test to be usable), so you can only rely on nonparametric tests. This way you would sacrifice the information about the spaceings between the observations and keep only their ranks. But this is better than a parametric test that is liberal because you unintentionally chose the wrong assumptions.
Small n: non-parametric or parametric tests?
The sample size is not an issue here. You can only use nonparametric procedures (depending on the particular question Wilcoxon test, rank correlation, Kruskal-Wallis test or others) with Likert scale
Small n: non-parametric or parametric tests? The sample size is not an issue here. You can only use nonparametric procedures (depending on the particular question Wilcoxon test, rank correlation, Kruskal-Wallis test or others) with Likert scale data due to their ordinal scale. Parametric procedures use the spaceing between different levels. But on a Likert scale, this spaceing is not informative: You could code five levels by "1,2,3,4,5" or you could code them without changeing information by "1,10,20,34,100" or by "10,Jack,Queen,King,Ace". So parametric tests that would include this arbitrary information do not yield reproducible results (and in the latter case none at all). Sometimes however, the sample size is a criterion to decide between parametric and nonparametric tests. Namely, if you are unsure if the assumptions for one or another parametric test hold, but you have a large sample size, you can cross fingers that by the central limit theorem, the mean is approximately normally distributed. For small sample sizes, this approximation is rather not so good (e.g. if your data are exponentially distributed, you need really huge sample sizes for the t-test to be usable), so you can only rely on nonparametric tests. This way you would sacrifice the information about the spaceings between the observations and keep only their ranks. But this is better than a parametric test that is liberal because you unintentionally chose the wrong assumptions.
Small n: non-parametric or parametric tests? The sample size is not an issue here. You can only use nonparametric procedures (depending on the particular question Wilcoxon test, rank correlation, Kruskal-Wallis test or others) with Likert scale
42,558
Permutation test to test significance of skewness/kurtosis of two distributions?
Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted. Yes, this method is correct, assuming you do not care about the direction of the difference.
Permutation test to test significance of skewness/kurtosis of two distributions?
Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted.
Permutation test to test significance of skewness/kurtosis of two distributions? Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted. Yes, this method is correct, assuming you do not care about the direction of the difference.
Permutation test to test significance of skewness/kurtosis of two distributions? Want to improve this post? Add citations from reputable sources by editing the post. Posts with unsourced content may be edited or deleted.
42,559
How do you estimate correlations between ordinal and binary data in SPSS?
If you're comparing the correlation of two variables, just report the Spearman correlation coefficient. The Spearman correlation is recommended over Pearson correlation for this type of data: How to choose between Pearson and Spearman correlation?. If you want to know how multiple variables impact the answer to one of the binary questions, do a logit or probit model. I've never used SPSS, but I'm sure there's a menu option for it. Select the binary answer as the dependent variable in the model.
How do you estimate correlations between ordinal and binary data in SPSS?
If you're comparing the correlation of two variables, just report the Spearman correlation coefficient. The Spearman correlation is recommended over Pearson correlation for this type of data: How to c
How do you estimate correlations between ordinal and binary data in SPSS? If you're comparing the correlation of two variables, just report the Spearman correlation coefficient. The Spearman correlation is recommended over Pearson correlation for this type of data: How to choose between Pearson and Spearman correlation?. If you want to know how multiple variables impact the answer to one of the binary questions, do a logit or probit model. I've never used SPSS, but I'm sure there's a menu option for it. Select the binary answer as the dependent variable in the model.
How do you estimate correlations between ordinal and binary data in SPSS? If you're comparing the correlation of two variables, just report the Spearman correlation coefficient. The Spearman correlation is recommended over Pearson correlation for this type of data: How to c
42,560
How do you estimate correlations between ordinal and binary data in SPSS?
When one of the variables is binary (such as group membership) just any kind of correlation (whether the other variable is continuous, likert , ...) is not much more than some rescaled version of some difference of means between the two groups defined by the binary variable. So normally it is better to just focus on difference in mean (or some kind of mean, mean of ranks, ...). Se my answer to this question: Correlations between continuous and categorical (nominal) variables
How do you estimate correlations between ordinal and binary data in SPSS?
When one of the variables is binary (such as group membership) just any kind of correlation (whether the other variable is continuous, likert , ...) is not much more than some rescaled version of som
How do you estimate correlations between ordinal and binary data in SPSS? When one of the variables is binary (such as group membership) just any kind of correlation (whether the other variable is continuous, likert , ...) is not much more than some rescaled version of some difference of means between the two groups defined by the binary variable. So normally it is better to just focus on difference in mean (or some kind of mean, mean of ranks, ...). Se my answer to this question: Correlations between continuous and categorical (nominal) variables
How do you estimate correlations between ordinal and binary data in SPSS? When one of the variables is binary (such as group membership) just any kind of correlation (whether the other variable is continuous, likert , ...) is not much more than some rescaled version of som
42,561
Why is tf-idf used in conjunction with SVMs for classifying documents?
If you only multiply each feature by some weight that correspond to the term's rarity (i.e. $log(\frac{M}{a_i})$ where $M$ is the total number of documents and $a_i$ is the number of documents with the considered term), and then use SVM, then the feature scaling you have performed is useless (as you have observed). However, if after the scaling you also normalize your data, and then perform an SVM,then you get different result from what you would get, if you simply used SVM or used SVM on normalized data without feature scaling. This can have possibly positive effects, for two reasons: 1) Normalization sounds reasonable, because word counts would be very different for long and short document, while normalized word counts reflect the frequency of the word in the document, and it's importance. 2) If you perform the feature scaling by rarity terms before normalization, the normalized vectors will be longer in the direction of rare words, which are possibly of bigger importance for distinguishing between documents.
Why is tf-idf used in conjunction with SVMs for classifying documents?
If you only multiply each feature by some weight that correspond to the term's rarity (i.e. $log(\frac{M}{a_i})$ where $M$ is the total number of documents and $a_i$ is the number of documents with th
Why is tf-idf used in conjunction with SVMs for classifying documents? If you only multiply each feature by some weight that correspond to the term's rarity (i.e. $log(\frac{M}{a_i})$ where $M$ is the total number of documents and $a_i$ is the number of documents with the considered term), and then use SVM, then the feature scaling you have performed is useless (as you have observed). However, if after the scaling you also normalize your data, and then perform an SVM,then you get different result from what you would get, if you simply used SVM or used SVM on normalized data without feature scaling. This can have possibly positive effects, for two reasons: 1) Normalization sounds reasonable, because word counts would be very different for long and short document, while normalized word counts reflect the frequency of the word in the document, and it's importance. 2) If you perform the feature scaling by rarity terms before normalization, the normalized vectors will be longer in the direction of rare words, which are possibly of bigger importance for distinguishing between documents.
Why is tf-idf used in conjunction with SVMs for classifying documents? If you only multiply each feature by some weight that correspond to the term's rarity (i.e. $log(\frac{M}{a_i})$ where $M$ is the total number of documents and $a_i$ is the number of documents with th
42,562
Is there any test for a null hypothesis of non-normality?
I think the question is the same whether normality is the null hypothesis or the alternative. the test is a measure of goodness of fit. If the test is based on the traditional approach then you look for how large the test statistic should be to reject normality. If the you make normality the alternative then you are asking how small this statistic needs to be to say the distribution is close enough to normal. I have not seen this done but it is very much akin to equivalence testing which is done a lot in the pharmaceutical industry. For equivalence testing you want to show that your drug perform similarly to the competitor drug. This is often done when trying to find a generic replacement for a marketed drug. You define a small distance from 0 that you call the window of equivalence and you reject the null hypothesis when you have high confidence that the true mean difference in the performance measure is within the window of equivalence. The method is well defined in Bill Blackwelder's paper "Proving the Null Hypothesis." The test statistics are the same or similar it is just executed differently. For example instead of using a two-tailed t test to show that the mean difference is different from 0, you do two one-sided t tests where you need to reject both to claim equivalence. The sample size is determined such that the power of rejecting nonequivalence when the actual mean differnce is less than some specified small value. I think that a test to reject nonnormality could be posed in the same way.
Is there any test for a null hypothesis of non-normality?
I think the question is the same whether normality is the null hypothesis or the alternative. the test is a measure of goodness of fit. If the test is based on the traditional approach then you look
Is there any test for a null hypothesis of non-normality? I think the question is the same whether normality is the null hypothesis or the alternative. the test is a measure of goodness of fit. If the test is based on the traditional approach then you look for how large the test statistic should be to reject normality. If the you make normality the alternative then you are asking how small this statistic needs to be to say the distribution is close enough to normal. I have not seen this done but it is very much akin to equivalence testing which is done a lot in the pharmaceutical industry. For equivalence testing you want to show that your drug perform similarly to the competitor drug. This is often done when trying to find a generic replacement for a marketed drug. You define a small distance from 0 that you call the window of equivalence and you reject the null hypothesis when you have high confidence that the true mean difference in the performance measure is within the window of equivalence. The method is well defined in Bill Blackwelder's paper "Proving the Null Hypothesis." The test statistics are the same or similar it is just executed differently. For example instead of using a two-tailed t test to show that the mean difference is different from 0, you do two one-sided t tests where you need to reject both to claim equivalence. The sample size is determined such that the power of rejecting nonequivalence when the actual mean differnce is less than some specified small value. I think that a test to reject nonnormality could be posed in the same way.
Is there any test for a null hypothesis of non-normality? I think the question is the same whether normality is the null hypothesis or the alternative. the test is a measure of goodness of fit. If the test is based on the traditional approach then you look
42,563
Is there any test for a null hypothesis of non-normality?
I think the problem is not well defined! You want to proove the data "do not come from a normal distribution". That is easy, accept! NO data "comes from a normal distribution", the normal distribution is at best an approximation. But you could, of course, have goodness-of-fit tests for other distributions, say the Poisson. I don't know if there is a lot published, but what you can do, is to make a qq-plot for the choosen distribution. For the Poisson case, what you can doo is (R code): dat <- rpois(200,10) p <- qpois(ppoints(200), 10) qqplot(p,dat) and a test statistic could be the correlation in the qqplot: cor(p,sort(dat)) Now you can find the null distribution of this statistic by simulation: cors <- vector(mode="numeric", length=1000) for (i in 1:1000) { cors[i] <- cor(qpois(ppoints(200), 10), sort(rpois(200, 10)) } hist(cors) In practice, you will presumably estimate the poisson mean, so you must redo the simulation incorporating estimation of the mean. You will also probably want to increase the number of simulated samples from 1000! The simulation incorporating estimation of the mean could be: NSIM <- 1000 SAMPSIZE <- 200 MEAN <- 10 cors <- vector(mode="numeric", length=NSIM) for (i in 1:NSIM) { samp <- rpois(SAMPSIZE, MEAN) m <- mean(samp) cors[i] <- cor(qpois(ppoints(SAMPSIZE), m), sort(samp)) } hist(cors)
Is there any test for a null hypothesis of non-normality?
I think the problem is not well defined! You want to proove the data "do not come from a normal distribution". That is easy, accept! NO data "comes from a normal distribution", the normal distribution
Is there any test for a null hypothesis of non-normality? I think the problem is not well defined! You want to proove the data "do not come from a normal distribution". That is easy, accept! NO data "comes from a normal distribution", the normal distribution is at best an approximation. But you could, of course, have goodness-of-fit tests for other distributions, say the Poisson. I don't know if there is a lot published, but what you can do, is to make a qq-plot for the choosen distribution. For the Poisson case, what you can doo is (R code): dat <- rpois(200,10) p <- qpois(ppoints(200), 10) qqplot(p,dat) and a test statistic could be the correlation in the qqplot: cor(p,sort(dat)) Now you can find the null distribution of this statistic by simulation: cors <- vector(mode="numeric", length=1000) for (i in 1:1000) { cors[i] <- cor(qpois(ppoints(200), 10), sort(rpois(200, 10)) } hist(cors) In practice, you will presumably estimate the poisson mean, so you must redo the simulation incorporating estimation of the mean. You will also probably want to increase the number of simulated samples from 1000! The simulation incorporating estimation of the mean could be: NSIM <- 1000 SAMPSIZE <- 200 MEAN <- 10 cors <- vector(mode="numeric", length=NSIM) for (i in 1:NSIM) { samp <- rpois(SAMPSIZE, MEAN) m <- mean(samp) cors[i] <- cor(qpois(ppoints(SAMPSIZE), m), sort(samp)) } hist(cors)
Is there any test for a null hypothesis of non-normality? I think the problem is not well defined! You want to proove the data "do not come from a normal distribution". That is easy, accept! NO data "comes from a normal distribution", the normal distribution
42,564
Is there any test for a null hypothesis of non-normality?
The answer is Chi square Goodness of fit test for normal distribution Here you can see the example http://www.stat.yale.edu/Courses/1997-98/101/chigf.htm
Is there any test for a null hypothesis of non-normality?
The answer is Chi square Goodness of fit test for normal distribution Here you can see the example http://www.stat.yale.edu/Courses/1997-98/101/chigf.htm
Is there any test for a null hypothesis of non-normality? The answer is Chi square Goodness of fit test for normal distribution Here you can see the example http://www.stat.yale.edu/Courses/1997-98/101/chigf.htm
Is there any test for a null hypothesis of non-normality? The answer is Chi square Goodness of fit test for normal distribution Here you can see the example http://www.stat.yale.edu/Courses/1997-98/101/chigf.htm
42,565
Is Ye Shiwen's 400m IM performance in Olympics "anomalous" statistically?
In the 1968 games in Mexico City Bob Beamon shattered the world record in the long jump with a jump of 29 ft 2 inches topping a world record that was under 28 ft at the time. It took decades for any one to come close and finally break Beamon's record. What explains it? The high altitude meant thin air and less air resistence. Yet no one else went over 28 ft that day including Beamon on his other jumps. No one suggested that Beamon took performance enhancing drugs. It was a statistical outlier. Outliers happen. Statistical analysis won't explain it. But in your case it seems that you have taken a very sensible and pragmatic approach. You look at similar performers over the same time period for the same event and found many that improved their best times by more than what this chinese swimmer did. I think that supports the view that her accomplishment is not very unusual and should not be attributed to any external reason such as some form of doping which is what I imagine some people may have been intimidating.
Is Ye Shiwen's 400m IM performance in Olympics "anomalous" statistically?
In the 1968 games in Mexico City Bob Beamon shattered the world record in the long jump with a jump of 29 ft 2 inches topping a world record that was under 28 ft at the time. It took decades for any
Is Ye Shiwen's 400m IM performance in Olympics "anomalous" statistically? In the 1968 games in Mexico City Bob Beamon shattered the world record in the long jump with a jump of 29 ft 2 inches topping a world record that was under 28 ft at the time. It took decades for any one to come close and finally break Beamon's record. What explains it? The high altitude meant thin air and less air resistence. Yet no one else went over 28 ft that day including Beamon on his other jumps. No one suggested that Beamon took performance enhancing drugs. It was a statistical outlier. Outliers happen. Statistical analysis won't explain it. But in your case it seems that you have taken a very sensible and pragmatic approach. You look at similar performers over the same time period for the same event and found many that improved their best times by more than what this chinese swimmer did. I think that supports the view that her accomplishment is not very unusual and should not be attributed to any external reason such as some form of doping which is what I imagine some people may have been intimidating.
Is Ye Shiwen's 400m IM performance in Olympics "anomalous" statistically? In the 1968 games in Mexico City Bob Beamon shattered the world record in the long jump with a jump of 29 ft 2 inches topping a world record that was under 28 ft at the time. It took decades for any
42,566
Logistic regression with an log transformed variable, how to determine economic significance
The interpretation you want to put on the covariate change makes sense in a simple model with one covariate. If you have two or more there could be some interaction and the best you can say in general is that x% is the magnitude of change when you change variable U by one standard deviation with the others held fixed at a particular value. At other places in the covariate space the magnitude of change could be different. If a variable is changed you can still talk about this amount of change on the log scale, but if you want to make the claim on the original scale you would have to figure out how the change on the log scale translates to a change on the original scale.
Logistic regression with an log transformed variable, how to determine economic significance
The interpretation you want to put on the covariate change makes sense in a simple model with one covariate. If you have two or more there could be some interaction and the best you can say in gener
Logistic regression with an log transformed variable, how to determine economic significance The interpretation you want to put on the covariate change makes sense in a simple model with one covariate. If you have two or more there could be some interaction and the best you can say in general is that x% is the magnitude of change when you change variable U by one standard deviation with the others held fixed at a particular value. At other places in the covariate space the magnitude of change could be different. If a variable is changed you can still talk about this amount of change on the log scale, but if you want to make the claim on the original scale you would have to figure out how the change on the log scale translates to a change on the original scale.
Logistic regression with an log transformed variable, how to determine economic significance The interpretation you want to put on the covariate change makes sense in a simple model with one covariate. If you have two or more there could be some interaction and the best you can say in gener
42,567
Logistic regression with an log transformed variable, how to determine economic significance
Please disregard my answer if it repeats what it has been suggested to you in linked posts... With log variables, your interpretation of the mfx $dy/dx$ becomes: $\frac{dy}{d\log x}$ which is equivalent to $\frac{dy}{dx/x}$ so the interpretation implies that 1% variation in $X$ causes a $\frac{dy}{d\log x}$ variation on $y$ In your case the std. deviation(2.79) is still an average variation of the log scale so: $\frac{dy}{d\log x}\Delta(\log x) = -0.029*2.79= -0.08 $ a 279% (2.79) variation (or one standard deviation) of $X$ causes the probability to decrease in $8\%$. A very small effect indeed.
Logistic regression with an log transformed variable, how to determine economic significance
Please disregard my answer if it repeats what it has been suggested to you in linked posts... With log variables, your interpretation of the mfx $dy/dx$ becomes: $\frac{dy}{d\log x}$ which is equival
Logistic regression with an log transformed variable, how to determine economic significance Please disregard my answer if it repeats what it has been suggested to you in linked posts... With log variables, your interpretation of the mfx $dy/dx$ becomes: $\frac{dy}{d\log x}$ which is equivalent to $\frac{dy}{dx/x}$ so the interpretation implies that 1% variation in $X$ causes a $\frac{dy}{d\log x}$ variation on $y$ In your case the std. deviation(2.79) is still an average variation of the log scale so: $\frac{dy}{d\log x}\Delta(\log x) = -0.029*2.79= -0.08 $ a 279% (2.79) variation (or one standard deviation) of $X$ causes the probability to decrease in $8\%$. A very small effect indeed.
Logistic regression with an log transformed variable, how to determine economic significance Please disregard my answer if it repeats what it has been suggested to you in linked posts... With log variables, your interpretation of the mfx $dy/dx$ becomes: $\frac{dy}{d\log x}$ which is equival
42,568
How to statistically test whether there is any nesting effect in the data?
Goal: To calculate ICC and to test whether the resulted ICC is big enough to account for the clustering effect in the study. My Study: All students within 52 schools followed longitudinally over three years. Schools are randomly assigned to Treatment or control. My question is do we need to account for school clustering effect? ICC is a measurement that can help us figuring out whether clustering effect is important or not. How to calculate ICC? 1) Looking at students scores in the baseline year where no one used the treatment and calculating: $$MS_{between} / (MS_{between} + MS_{Err})$$ 2) Another way is to calculate ICC by using random effects model framework and by use the variance of the random effect (for school). This is what is most commonly done with varying group sizes.In this case, ICC is $$\sigma_b^2 / (\sigma_b^2 + \sigma_e^2)$$ where $\sigma_b^2$ is the variance of the random effect and $\sigma_e^2$ is the residual variance. How to fit the random effect model in R? library(nlme) schRandModel <- lme(StudScoresBaseline ~ 1, data = data, random = ~ 1 | SCHOOL) SchRandModel.LogLiklihood <- schRandModel$logLik The model above assumes random intercepts for the schools. Now we fit the model without schools as random effect (groups are students rather than schools): simpleModel <- lme(StudScoresBaseline ~ 1, data = data, random = ~ 1 | StudentID) simpleModel.LogLiklihood <- simpleModel$logLik Finally, using the likelihood ratio test, we test the difference between likelihoods: logLikDiff = SchRandModel.LogLiklihood-simpleModel.LogLiklihood 1-pchisq(2*logLikDiff,df=1) my resulted p-value is less than <0.0001 indicating that we have enough evidence that random effect model is a better fit. Therefore, school clustering effect is important in this study . I'd like to thank Macro for guiding me step by step to write the answer.
How to statistically test whether there is any nesting effect in the data?
Goal: To calculate ICC and to test whether the resulted ICC is big enough to account for the clustering effect in the study. My Study: All students within 52 schools followed longitudinally over three
How to statistically test whether there is any nesting effect in the data? Goal: To calculate ICC and to test whether the resulted ICC is big enough to account for the clustering effect in the study. My Study: All students within 52 schools followed longitudinally over three years. Schools are randomly assigned to Treatment or control. My question is do we need to account for school clustering effect? ICC is a measurement that can help us figuring out whether clustering effect is important or not. How to calculate ICC? 1) Looking at students scores in the baseline year where no one used the treatment and calculating: $$MS_{between} / (MS_{between} + MS_{Err})$$ 2) Another way is to calculate ICC by using random effects model framework and by use the variance of the random effect (for school). This is what is most commonly done with varying group sizes.In this case, ICC is $$\sigma_b^2 / (\sigma_b^2 + \sigma_e^2)$$ where $\sigma_b^2$ is the variance of the random effect and $\sigma_e^2$ is the residual variance. How to fit the random effect model in R? library(nlme) schRandModel <- lme(StudScoresBaseline ~ 1, data = data, random = ~ 1 | SCHOOL) SchRandModel.LogLiklihood <- schRandModel$logLik The model above assumes random intercepts for the schools. Now we fit the model without schools as random effect (groups are students rather than schools): simpleModel <- lme(StudScoresBaseline ~ 1, data = data, random = ~ 1 | StudentID) simpleModel.LogLiklihood <- simpleModel$logLik Finally, using the likelihood ratio test, we test the difference between likelihoods: logLikDiff = SchRandModel.LogLiklihood-simpleModel.LogLiklihood 1-pchisq(2*logLikDiff,df=1) my resulted p-value is less than <0.0001 indicating that we have enough evidence that random effect model is a better fit. Therefore, school clustering effect is important in this study . I'd like to thank Macro for guiding me step by step to write the answer.
How to statistically test whether there is any nesting effect in the data? Goal: To calculate ICC and to test whether the resulted ICC is big enough to account for the clustering effect in the study. My Study: All students within 52 schools followed longitudinally over three
42,569
How to calculate precision and recall when some of the test data remains unclassified
It's useful to keep in mind that precision/recall are inherently tied to a particular state or label of interest. In information retrieval that label might be "relevant" as opposed to "not relevant," whereas in cancer that label might be "malignant" as opposed to "benign." As @Thomas Jungblut mentions, it would be valid to treat this not as a binary classification problem ("A" or "B") but instead as a multiclass classification problem ("A," "B," or "Unclassified"). There are other metrics besides precision/recall that can be of interest in multiclass classification. However, if you insist on precision/recall then you must pick your label of interest and then this sort of becomes de facto binary classification once again. You have various options for how to frame the problem ("A" vs "B or unclassified" is not the same as "A or unclassified" vs "B", etc.). However, effectively these are the same as simply picking a default label. Since you seem to impart special meaning to the classification score of 0, it seems that perhaps it would be appropriate to also apply some domain knowledge or some knowledge of the specific classification algorithm being used. In the general case there's nothing really magical about a score of 0, but perhaps you really have a specific problem in mind where this is not the case.
How to calculate precision and recall when some of the test data remains unclassified
It's useful to keep in mind that precision/recall are inherently tied to a particular state or label of interest. In information retrieval that label might be "relevant" as opposed to "not relevant,"
How to calculate precision and recall when some of the test data remains unclassified It's useful to keep in mind that precision/recall are inherently tied to a particular state or label of interest. In information retrieval that label might be "relevant" as opposed to "not relevant," whereas in cancer that label might be "malignant" as opposed to "benign." As @Thomas Jungblut mentions, it would be valid to treat this not as a binary classification problem ("A" or "B") but instead as a multiclass classification problem ("A," "B," or "Unclassified"). There are other metrics besides precision/recall that can be of interest in multiclass classification. However, if you insist on precision/recall then you must pick your label of interest and then this sort of becomes de facto binary classification once again. You have various options for how to frame the problem ("A" vs "B or unclassified" is not the same as "A or unclassified" vs "B", etc.). However, effectively these are the same as simply picking a default label. Since you seem to impart special meaning to the classification score of 0, it seems that perhaps it would be appropriate to also apply some domain knowledge or some knowledge of the specific classification algorithm being used. In the general case there's nothing really magical about a score of 0, but perhaps you really have a specific problem in mind where this is not the case.
How to calculate precision and recall when some of the test data remains unclassified It's useful to keep in mind that precision/recall are inherently tied to a particular state or label of interest. In information retrieval that label might be "relevant" as opposed to "not relevant,"
42,570
How to compare loess models from related datasets?
Unfortunately loess fits are not comparable. A loess (or lowess) curve is not like one based on a linear or quadratic or cubic equation. I know of no statistial package that will provide an equation that defines a loess curve, nor a fit statistic such as R-squared for it. Such a curve is completely opportunistic and therefore unique to each dataset. A loess fit is atheoretical; one would not want to use it to try to formally replicate a pattern across datasets. You might say it's "for exploratory purposes only," and even there one must use care, as you can see if you read through threads such as this one.
How to compare loess models from related datasets?
Unfortunately loess fits are not comparable. A loess (or lowess) curve is not like one based on a linear or quadratic or cubic equation. I know of no statistial package that will provide an equation
How to compare loess models from related datasets? Unfortunately loess fits are not comparable. A loess (or lowess) curve is not like one based on a linear or quadratic or cubic equation. I know of no statistial package that will provide an equation that defines a loess curve, nor a fit statistic such as R-squared for it. Such a curve is completely opportunistic and therefore unique to each dataset. A loess fit is atheoretical; one would not want to use it to try to formally replicate a pattern across datasets. You might say it's "for exploratory purposes only," and even there one must use care, as you can see if you read through threads such as this one.
How to compare loess models from related datasets? Unfortunately loess fits are not comparable. A loess (or lowess) curve is not like one based on a linear or quadratic or cubic equation. I know of no statistial package that will provide an equation
42,571
How to compare loess models from related datasets?
Is the variance between the data and the curve bigger than the variance between the two curves, averaged over patients? If you want a p-value I suppose you could assume normality of errors and use the F-test on ratio of variances. The loess fit isn't a formal fit, so this is not a formal test. Could you use a formal fit? Have a look at the graphs. Do they look the same across patients?
How to compare loess models from related datasets?
Is the variance between the data and the curve bigger than the variance between the two curves, averaged over patients? If you want a p-value I suppose you could assume normality of errors and use the
How to compare loess models from related datasets? Is the variance between the data and the curve bigger than the variance between the two curves, averaged over patients? If you want a p-value I suppose you could assume normality of errors and use the F-test on ratio of variances. The loess fit isn't a formal fit, so this is not a formal test. Could you use a formal fit? Have a look at the graphs. Do they look the same across patients?
How to compare loess models from related datasets? Is the variance between the data and the curve bigger than the variance between the two curves, averaged over patients? If you want a p-value I suppose you could assume normality of errors and use the
42,572
How to compare loess models from related datasets?
predict.loess in R has an se parameter which if TRUE returns standard errors for all predicted points. These are the usual standard errors of residuals. One can, as well, simply take the absolute value of difference between predicted values and originals and so get a sequence of absolute errors. These are often more robust than standard errors. In any case, with these in hand you are set up for doing cross validation or jackknifing to get some notion of which of a set of parameters describe a dataset better. Note that in time series applications, these are dependent data so cross validating or jackknifing points is not appropriate: You need to pick random subsequences of the original parent in some principled way and cross validate over those. The lengths or windows of these should tie to some phenomenon horizon in the original dataset or problem. Failing that, could look at using the stationary bootstrap of Politis and Romano as implemented in the tsbootstrap function of the tseries package. That gives a bit more flexibility for dependent sequences, but the analyst still needs to specify a mean block length.
How to compare loess models from related datasets?
predict.loess in R has an se parameter which if TRUE returns standard errors for all predicted points. These are the usual standard errors of residuals. One can, as well, simply take the absolute va
How to compare loess models from related datasets? predict.loess in R has an se parameter which if TRUE returns standard errors for all predicted points. These are the usual standard errors of residuals. One can, as well, simply take the absolute value of difference between predicted values and originals and so get a sequence of absolute errors. These are often more robust than standard errors. In any case, with these in hand you are set up for doing cross validation or jackknifing to get some notion of which of a set of parameters describe a dataset better. Note that in time series applications, these are dependent data so cross validating or jackknifing points is not appropriate: You need to pick random subsequences of the original parent in some principled way and cross validate over those. The lengths or windows of these should tie to some phenomenon horizon in the original dataset or problem. Failing that, could look at using the stationary bootstrap of Politis and Romano as implemented in the tsbootstrap function of the tseries package. That gives a bit more flexibility for dependent sequences, but the analyst still needs to specify a mean block length.
How to compare loess models from related datasets? predict.loess in R has an se parameter which if TRUE returns standard errors for all predicted points. These are the usual standard errors of residuals. One can, as well, simply take the absolute va
42,573
How to compare loess models from related datasets?
In general when comparing two different fitting curves the way to go is a performance measure. It does not allow you to draw strong conclusions, but if you have two options you can calculate the R squared for example and at least have an idea of how good your fit can be.
How to compare loess models from related datasets?
In general when comparing two different fitting curves the way to go is a performance measure. It does not allow you to draw strong conclusions, but if you have two options you can calculate the R squ
How to compare loess models from related datasets? In general when comparing two different fitting curves the way to go is a performance measure. It does not allow you to draw strong conclusions, but if you have two options you can calculate the R squared for example and at least have an idea of how good your fit can be.
How to compare loess models from related datasets? In general when comparing two different fitting curves the way to go is a performance measure. It does not allow you to draw strong conclusions, but if you have two options you can calculate the R squ
42,574
What to conclude when you fail to find an association in an epidemiological study?
Yes, the weaknesses of associations found in epidemiological studies also apply to a failure to find an association. You've already eliminated the first go-to problem, that of a study being underpowered, so at the moment we're just talking about bias. Two issues that may mean your study is failing to find a true association: Confounding. There are conditions where a confounding variable will drive a result toward the null. For positive effects, this is the confounding variable being negatively associated with both the exposure and the outcome. For negative effects, the reverse. This could easily drive, depending on the strength of the confounding, a real relationship downward enough that you cannot find it. Misclassification. Non-differential misclassification is when everyone in your study has an equal probability of being in the wrong category. This tends to drive estimates toward the null. Differential misclassification, where particular categories are more prone to being misclassified, can drive results toward or away from the null. So no, the results of a single study should never be taken as definitive "proof", one way or the other, of a causal relationship.
What to conclude when you fail to find an association in an epidemiological study?
Yes, the weaknesses of associations found in epidemiological studies also apply to a failure to find an association. You've already eliminated the first go-to problem, that of a study being underpower
What to conclude when you fail to find an association in an epidemiological study? Yes, the weaknesses of associations found in epidemiological studies also apply to a failure to find an association. You've already eliminated the first go-to problem, that of a study being underpowered, so at the moment we're just talking about bias. Two issues that may mean your study is failing to find a true association: Confounding. There are conditions where a confounding variable will drive a result toward the null. For positive effects, this is the confounding variable being negatively associated with both the exposure and the outcome. For negative effects, the reverse. This could easily drive, depending on the strength of the confounding, a real relationship downward enough that you cannot find it. Misclassification. Non-differential misclassification is when everyone in your study has an equal probability of being in the wrong category. This tends to drive estimates toward the null. Differential misclassification, where particular categories are more prone to being misclassified, can drive results toward or away from the null. So no, the results of a single study should never be taken as definitive "proof", one way or the other, of a causal relationship.
What to conclude when you fail to find an association in an epidemiological study? Yes, the weaknesses of associations found in epidemiological studies also apply to a failure to find an association. You've already eliminated the first go-to problem, that of a study being underpower
42,575
What to conclude when you fail to find an association in an epidemiological study?
I think it's worth distinguishing a few aspects of the problem: Precision: If you have a bigger sample size, you will typically be able to estimate parameters with greater precision whether you define this in a frequentist sense in terms of smaller confidence intervals or in a Bayesian sense in terms of smaller credibility intervals. Thus, if you conduct an epidemiological observational study with a bigger sample you will have greater precision in describing the magnitude of a parameter of interest. This is true whether the parameter is a simple correlation coefficient or a regression coefficient in a broader model with many other predictors. It's also true whether the parameter of interest is derived from an observational study or an experimental study. So for example, you might get a very accurate estimate of the correlation between eating chocolate and Body Mass Index. Associations, whether causal or not, are real and interesting. Generalisation: However, even if you know the value of a parameter in your particular sample, there are still issues of generalisation. In epidemiology there are plenty of issues related to generalising across time, culture, social groups, and so on. Often we have theories and empirical evidence to guide us in this process of generalising. For example, we may argue that is safe to generalise a chocolate-BMI association over reasonable periods of time, but that perhaps across nations it is more complex, perhaps because of different eating and exercise habits, etc. Causality versus association: However, you seem to be particular interested in causal inference. At a basic level, the absence of an association in an observational study does not prove the absence of causality, just as the presence of an association in an observational study does not prove causality. Even if observational studies showed no relationship between, for example, chocolate and BMI, this would not prevent experimental studies from showing that when kids were fed more chocolate, they put on weight. The association or lack of association in an observational study may be informative as to causal processes, but it is not definitive. You still need to think hard about the theorised underlying causal processes.
What to conclude when you fail to find an association in an epidemiological study?
I think it's worth distinguishing a few aspects of the problem: Precision: If you have a bigger sample size, you will typically be able to estimate parameters with greater precision whether you defin
What to conclude when you fail to find an association in an epidemiological study? I think it's worth distinguishing a few aspects of the problem: Precision: If you have a bigger sample size, you will typically be able to estimate parameters with greater precision whether you define this in a frequentist sense in terms of smaller confidence intervals or in a Bayesian sense in terms of smaller credibility intervals. Thus, if you conduct an epidemiological observational study with a bigger sample you will have greater precision in describing the magnitude of a parameter of interest. This is true whether the parameter is a simple correlation coefficient or a regression coefficient in a broader model with many other predictors. It's also true whether the parameter of interest is derived from an observational study or an experimental study. So for example, you might get a very accurate estimate of the correlation between eating chocolate and Body Mass Index. Associations, whether causal or not, are real and interesting. Generalisation: However, even if you know the value of a parameter in your particular sample, there are still issues of generalisation. In epidemiology there are plenty of issues related to generalising across time, culture, social groups, and so on. Often we have theories and empirical evidence to guide us in this process of generalising. For example, we may argue that is safe to generalise a chocolate-BMI association over reasonable periods of time, but that perhaps across nations it is more complex, perhaps because of different eating and exercise habits, etc. Causality versus association: However, you seem to be particular interested in causal inference. At a basic level, the absence of an association in an observational study does not prove the absence of causality, just as the presence of an association in an observational study does not prove causality. Even if observational studies showed no relationship between, for example, chocolate and BMI, this would not prevent experimental studies from showing that when kids were fed more chocolate, they put on weight. The association or lack of association in an observational study may be informative as to causal processes, but it is not definitive. You still need to think hard about the theorised underlying causal processes.
What to conclude when you fail to find an association in an epidemiological study? I think it's worth distinguishing a few aspects of the problem: Precision: If you have a bigger sample size, you will typically be able to estimate parameters with greater precision whether you defin
42,576
What to conclude when you fail to find an association in an epidemiological study?
Well, in physics we are very used to what you are saying and, to me at least, it is in fact far more exciting when this happens that when some researcher confirms theory. In these cases you just report that: you've found no evidence of what the theory predicts. After checking your results and the possibe flaws of your study, it is also good practice to elaborate (at least qualitatively) your own guesses about why theory fails in your case.
What to conclude when you fail to find an association in an epidemiological study?
Well, in physics we are very used to what you are saying and, to me at least, it is in fact far more exciting when this happens that when some researcher confirms theory. In these cases you just repor
What to conclude when you fail to find an association in an epidemiological study? Well, in physics we are very used to what you are saying and, to me at least, it is in fact far more exciting when this happens that when some researcher confirms theory. In these cases you just report that: you've found no evidence of what the theory predicts. After checking your results and the possibe flaws of your study, it is also good practice to elaborate (at least qualitatively) your own guesses about why theory fails in your case.
What to conclude when you fail to find an association in an epidemiological study? Well, in physics we are very used to what you are saying and, to me at least, it is in fact far more exciting when this happens that when some researcher confirms theory. In these cases you just repor
42,577
Hyperparameter estimation in Gaussian process
It would be a good idea to get the optimisation code to print out the hyper-parameters each time it performs a function evaluation. Usually you can work out what is going wrong once you know what the model decides about the hyper-parameter values. I suspect what is happening is that the model has decided that an essentially linear classifier would be best, and has set $\sigma_n$ to zero, as the noise component is not seen as necessary (which is a shame as it adds a ridge to the covariance matrix, which helps ensure that it is p.d.). In that case, only the SEiso bit is used, so $\sigma_f$ will probably be much larger than $\sigma_n$, however to make a linear classifier it will try and make $l$ as large as possible, which seems to end up resulting in numerical problems when evaluating the bit inside the exponential. I'm a pretty heavy user of GPML and have seen this a fair bit. One solution is to limit the magnitudes of the logarithms of the hyper-parameters during the search (which is equivalent to having a hyper-prior on the hyper-parameters), which tends to prevent this from happening. If you print out the values of the hyper-parameters, then the last ones that get printed before it goes "bang" will give you a good idea where to place the limits. This tends not to affect performance very much, the generalisation error at such points in hyper-parameter tends to be fairly flat, which causes gradient descent methods to take large steps that put you far enough from the origin that you get numerical accuracy problems. In short print out the hyper-parameter values at each step, whenever you run into numerical issues in model selection.
Hyperparameter estimation in Gaussian process
It would be a good idea to get the optimisation code to print out the hyper-parameters each time it performs a function evaluation. Usually you can work out what is going wrong once you know what the
Hyperparameter estimation in Gaussian process It would be a good idea to get the optimisation code to print out the hyper-parameters each time it performs a function evaluation. Usually you can work out what is going wrong once you know what the model decides about the hyper-parameter values. I suspect what is happening is that the model has decided that an essentially linear classifier would be best, and has set $\sigma_n$ to zero, as the noise component is not seen as necessary (which is a shame as it adds a ridge to the covariance matrix, which helps ensure that it is p.d.). In that case, only the SEiso bit is used, so $\sigma_f$ will probably be much larger than $\sigma_n$, however to make a linear classifier it will try and make $l$ as large as possible, which seems to end up resulting in numerical problems when evaluating the bit inside the exponential. I'm a pretty heavy user of GPML and have seen this a fair bit. One solution is to limit the magnitudes of the logarithms of the hyper-parameters during the search (which is equivalent to having a hyper-prior on the hyper-parameters), which tends to prevent this from happening. If you print out the values of the hyper-parameters, then the last ones that get printed before it goes "bang" will give you a good idea where to place the limits. This tends not to affect performance very much, the generalisation error at such points in hyper-parameter tends to be fairly flat, which causes gradient descent methods to take large steps that put you far enough from the origin that you get numerical accuracy problems. In short print out the hyper-parameter values at each step, whenever you run into numerical issues in model selection.
Hyperparameter estimation in Gaussian process It would be a good idea to get the optimisation code to print out the hyper-parameters each time it performs a function evaluation. Usually you can work out what is going wrong once you know what the
42,578
Variance-gamma distribution: parameter estimation
1. In pp. 16 they mention that the package uses "BFGS" or "Nelder-Mead". The second one is the default option. Please, take a look at these links to see their differences. Optimisation is actually made on the likelihood function. This is, the fitted parameters in the output of vgFit are actually the maximum likelihood estimators. 2. It is difficult to tell which optimisation method is better in general. You can instead compare different methods and see if the results coincide using the command optim and the command vgFit. Next, I present a code for maximising the likelihood function, you can choose between 6 different optimisation methods. library("VarianceGamma") # Simulate 100 observations from a variance-gamma distribution with parameters (0,1,0,1) data = rvg(100, vgC = 0, sigma = 1, theta = 0, nu = 1) # -log-likelihood function using the Variance-Gamma package ll = function(par){ if(par[2]>0&par[4]>0) return( - sum(log(dvg(data, vgC = par[1], sigma=par[2], theta=par[3], nu = par[4]) ))) else return(Inf)} # Direct maximisation/minimisation using the command optim optim(c(0,1,0,1),ll,method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent")) # Maximisation using the command vgFit vgFit(data) The advantage of vgFit is that you do not need to specify the starting value for searching the optimum. It implements three different methods for doing so: "US", "SL" and "MoM". "SL" is the default method. I would not trust blindly on these methods, I would rather compare the results from vgFit and optim. 3. You can check the references in the manual. For example Seneta, E. (2004). Fitting the variance-gamma model to financial data. J. Appl. Prob., 41A:177– 187. Kotz, S, Kozubowski, T. J., and Podgórski, K. (2001). The Laplace Distribution and Generalizations. Birkhauser, Boston, 349 p. D.B. Madan and E. Seneta (1990): The variance gamma (V.G.) model for share market returns, Journal of Business, 63, pp. 511–524.
Variance-gamma distribution: parameter estimation
1. In pp. 16 they mention that the package uses "BFGS" or "Nelder-Mead". The second one is the default option. Please, take a look at these links to see their differences. Optimisation is actually mad
Variance-gamma distribution: parameter estimation 1. In pp. 16 they mention that the package uses "BFGS" or "Nelder-Mead". The second one is the default option. Please, take a look at these links to see their differences. Optimisation is actually made on the likelihood function. This is, the fitted parameters in the output of vgFit are actually the maximum likelihood estimators. 2. It is difficult to tell which optimisation method is better in general. You can instead compare different methods and see if the results coincide using the command optim and the command vgFit. Next, I present a code for maximising the likelihood function, you can choose between 6 different optimisation methods. library("VarianceGamma") # Simulate 100 observations from a variance-gamma distribution with parameters (0,1,0,1) data = rvg(100, vgC = 0, sigma = 1, theta = 0, nu = 1) # -log-likelihood function using the Variance-Gamma package ll = function(par){ if(par[2]>0&par[4]>0) return( - sum(log(dvg(data, vgC = par[1], sigma=par[2], theta=par[3], nu = par[4]) ))) else return(Inf)} # Direct maximisation/minimisation using the command optim optim(c(0,1,0,1),ll,method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent")) # Maximisation using the command vgFit vgFit(data) The advantage of vgFit is that you do not need to specify the starting value for searching the optimum. It implements three different methods for doing so: "US", "SL" and "MoM". "SL" is the default method. I would not trust blindly on these methods, I would rather compare the results from vgFit and optim. 3. You can check the references in the manual. For example Seneta, E. (2004). Fitting the variance-gamma model to financial data. J. Appl. Prob., 41A:177– 187. Kotz, S, Kozubowski, T. J., and Podgórski, K. (2001). The Laplace Distribution and Generalizations. Birkhauser, Boston, 349 p. D.B. Madan and E. Seneta (1990): The variance gamma (V.G.) model for share market returns, Journal of Business, 63, pp. 511–524.
Variance-gamma distribution: parameter estimation 1. In pp. 16 they mention that the package uses "BFGS" or "Nelder-Mead". The second one is the default option. Please, take a look at these links to see their differences. Optimisation is actually mad
42,579
Appropriateness of PCA to visualize clusters in genetic data
I do share your concern about the matter of visual rendering of clusters by means of PCA. If the 1st 2 or 3 principal components account for only small portion of multidimensional variability they are likely to miss most of the directions along which the clusters differentiate. Moreover, even when components are strong they can fail: just consider two oblong parallel clusters in 2 dimensions which are separated from each other by a slit along their length. The 1st pc will lie also along their length and won't show the presence of clusters. Your second question implies now that you know your clusters in advance (because you mention using t-test or similar comparison method). If you succeeded in selecting features (dimensions) which differentiate them most strongly, then using PCA on those selected features may turn meaningless - if the features don't correlate, or may turn valuable - if they all or some of them are pretty well correlated. If you speak of PCA and not of factor analysis in strict meaning and you do neither rotations nor interpretations of the extracted PCs then %Variance is the only important statistic to report, for me. You could also show the scree-plot.
Appropriateness of PCA to visualize clusters in genetic data
I do share your concern about the matter of visual rendering of clusters by means of PCA. If the 1st 2 or 3 principal components account for only small portion of multidimensional variability they are
Appropriateness of PCA to visualize clusters in genetic data I do share your concern about the matter of visual rendering of clusters by means of PCA. If the 1st 2 or 3 principal components account for only small portion of multidimensional variability they are likely to miss most of the directions along which the clusters differentiate. Moreover, even when components are strong they can fail: just consider two oblong parallel clusters in 2 dimensions which are separated from each other by a slit along their length. The 1st pc will lie also along their length and won't show the presence of clusters. Your second question implies now that you know your clusters in advance (because you mention using t-test or similar comparison method). If you succeeded in selecting features (dimensions) which differentiate them most strongly, then using PCA on those selected features may turn meaningless - if the features don't correlate, or may turn valuable - if they all or some of them are pretty well correlated. If you speak of PCA and not of factor analysis in strict meaning and you do neither rotations nor interpretations of the extracted PCs then %Variance is the only important statistic to report, for me. You could also show the scree-plot.
Appropriateness of PCA to visualize clusters in genetic data I do share your concern about the matter of visual rendering of clusters by means of PCA. If the 1st 2 or 3 principal components account for only small portion of multidimensional variability they are
42,580
Appropriateness of PCA to visualize clusters in genetic data
As your data likely is very noisy, you can try to improve the PCA performance using a robust variation of it, see Wikipedia for details. But in general I do share your concern. Because in complex data sets such as genetic data, different clusters may show different correlations that cannot be adequately represented by global PCA. The quality of using PCA for dimensionality reduction (e.g. to 2D or 3D for visualization) does depend a lot on the amount of variance captured. But you can't go by the direct relative shares. If we have 1000 dimensions, and the first two explain $10\%$ this can (I did not test this) be quite significant. In 10 dimensions, it is completely meaningless, for uniform i.i.d. data the first single eigenvector will necessarily already explain more than this. A better control is the value $$\frac{\text{explained variance}}{\text{expected explained variance}}$$. Just a few days ago I posted a question here about the expected distribution of eigenvalues. If we find some distribution for this, we can test whether the result is significant: Estimated distribution of eigenvalues for i.i.d. (uniform or normal) data If you look at the example I posted, it is not unusual to see eigenvalues range from $0.119$ to $0.006$ (a difference of factor 20!) in a uniform i.i.d. dataset with just 20 dimensions, at least when the sample is small. So the eigenvalues seem to be rather unreliable when it comes to indicating whether the projection is actually capturing something. Feature selection will not cover rotations. Which is when PCA gets interesting: did it actually rotate the data much, or did it just select a number of features (i.e. low angle between one of the axes and one of the eigenvectors)? Try plotting the axes of the original attributes in your visualization to show the relationship to the original data and the attributes used by PCA.
Appropriateness of PCA to visualize clusters in genetic data
As your data likely is very noisy, you can try to improve the PCA performance using a robust variation of it, see Wikipedia for details. But in general I do share your concern. Because in complex data
Appropriateness of PCA to visualize clusters in genetic data As your data likely is very noisy, you can try to improve the PCA performance using a robust variation of it, see Wikipedia for details. But in general I do share your concern. Because in complex data sets such as genetic data, different clusters may show different correlations that cannot be adequately represented by global PCA. The quality of using PCA for dimensionality reduction (e.g. to 2D or 3D for visualization) does depend a lot on the amount of variance captured. But you can't go by the direct relative shares. If we have 1000 dimensions, and the first two explain $10\%$ this can (I did not test this) be quite significant. In 10 dimensions, it is completely meaningless, for uniform i.i.d. data the first single eigenvector will necessarily already explain more than this. A better control is the value $$\frac{\text{explained variance}}{\text{expected explained variance}}$$. Just a few days ago I posted a question here about the expected distribution of eigenvalues. If we find some distribution for this, we can test whether the result is significant: Estimated distribution of eigenvalues for i.i.d. (uniform or normal) data If you look at the example I posted, it is not unusual to see eigenvalues range from $0.119$ to $0.006$ (a difference of factor 20!) in a uniform i.i.d. dataset with just 20 dimensions, at least when the sample is small. So the eigenvalues seem to be rather unreliable when it comes to indicating whether the projection is actually capturing something. Feature selection will not cover rotations. Which is when PCA gets interesting: did it actually rotate the data much, or did it just select a number of features (i.e. low angle between one of the axes and one of the eigenvectors)? Try plotting the axes of the original attributes in your visualization to show the relationship to the original data and the attributes used by PCA.
Appropriateness of PCA to visualize clusters in genetic data As your data likely is very noisy, you can try to improve the PCA performance using a robust variation of it, see Wikipedia for details. But in general I do share your concern. Because in complex data
42,581
Appropriateness of PCA to visualize clusters in genetic data
One theory. For human, the proportion of variation within groups (i.e. same ethnic group) account for ~85% of the genetic variation within individuals. Conversely, the variation within populations (i.e. continental scale) account for only ~15% of the genetic variation within individuals. Even though the first three components (i.e. PC1, PC2, PC3) contained only a small fraction of the total variance, most often the magnitude of associated eigenvalues can be 50 to 70 times that of higher components. In other words, the first three components can explain substantially more (50x-70x) variance than any other component when comparing by individual basis. While sometimes these higher components do explain hidden substructure within groups, bear in mind that individuals from the same group has ~85% genetic variation among themselves. Hence, most of the higher components might just be explaining this within groups variation. For analysis of genetic clusters, this is of no interest to geneticists. These higher components can thus be treated as background noises. Geneticists are mainly interested in variation within populations, which often is very ancient and strongly separated. Thus, when population clusters are formed in the first three components, it can be argued that they form mainly due to the variation within populations. Summary: The low variance (<10%) cumulatively accounted by the first three components can be justified by the fact that variation within populations is only ~15% of the genetic variation within individuals.
Appropriateness of PCA to visualize clusters in genetic data
One theory. For human, the proportion of variation within groups (i.e. same ethnic group) account for ~85% of the genetic variation within individuals. Conversely, the variation within populations (i.
Appropriateness of PCA to visualize clusters in genetic data One theory. For human, the proportion of variation within groups (i.e. same ethnic group) account for ~85% of the genetic variation within individuals. Conversely, the variation within populations (i.e. continental scale) account for only ~15% of the genetic variation within individuals. Even though the first three components (i.e. PC1, PC2, PC3) contained only a small fraction of the total variance, most often the magnitude of associated eigenvalues can be 50 to 70 times that of higher components. In other words, the first three components can explain substantially more (50x-70x) variance than any other component when comparing by individual basis. While sometimes these higher components do explain hidden substructure within groups, bear in mind that individuals from the same group has ~85% genetic variation among themselves. Hence, most of the higher components might just be explaining this within groups variation. For analysis of genetic clusters, this is of no interest to geneticists. These higher components can thus be treated as background noises. Geneticists are mainly interested in variation within populations, which often is very ancient and strongly separated. Thus, when population clusters are formed in the first three components, it can be argued that they form mainly due to the variation within populations. Summary: The low variance (<10%) cumulatively accounted by the first three components can be justified by the fact that variation within populations is only ~15% of the genetic variation within individuals.
Appropriateness of PCA to visualize clusters in genetic data One theory. For human, the proportion of variation within groups (i.e. same ethnic group) account for ~85% of the genetic variation within individuals. Conversely, the variation within populations (i.
42,582
Support vector regression in R
For selecting parameters (such as the C parameter) I have no great advice. I have found I just need to try different values and using bootstrap or cross-validation to select the best ones. One useful nugget I picked up along the way though is the concept of calibrating the predictions from the SVM output for regression. If for example you are trying to find the probability of a binary outcome occurring (Bernoulli trial) using SVM, then the quantity returned from the algorithm will not be the probability, but will be monotonically related to it. In order to calibrate the response, you can use e.g. logistic regression $p = \frac{1}{1+e^{(-g(f))}}$ where $g(f)$ is some function of the SVM predictions $f$. I've found that a simple linear function $g(f) = a + bf$ usually does the job.
Support vector regression in R
For selecting parameters (such as the C parameter) I have no great advice. I have found I just need to try different values and using bootstrap or cross-validation to select the best ones. One useful
Support vector regression in R For selecting parameters (such as the C parameter) I have no great advice. I have found I just need to try different values and using bootstrap or cross-validation to select the best ones. One useful nugget I picked up along the way though is the concept of calibrating the predictions from the SVM output for regression. If for example you are trying to find the probability of a binary outcome occurring (Bernoulli trial) using SVM, then the quantity returned from the algorithm will not be the probability, but will be monotonically related to it. In order to calibrate the response, you can use e.g. logistic regression $p = \frac{1}{1+e^{(-g(f))}}$ where $g(f)$ is some function of the SVM predictions $f$. I've found that a simple linear function $g(f) = a + bf$ usually does the job.
Support vector regression in R For selecting parameters (such as the C parameter) I have no great advice. I have found I just need to try different values and using bootstrap or cross-validation to select the best ones. One useful
42,583
Support vector regression in R
Try using the kernlab package, you can use ksvm(...,type='eps-svr') to get regression. It's smart enough to automatically select regression if given a continuous variable. A grid search for parameters usually works reasonably well. Choice of kernel can have a big impact on performance. One rules of thumb I've found is that linear kernels or lower order polynomials work ok with high dimension problems, but RBFs work better with low dimension problems. But you're still best trying everything.
Support vector regression in R
Try using the kernlab package, you can use ksvm(...,type='eps-svr') to get regression. It's smart enough to automatically select regression if given a continuous variable. A grid search for parameter
Support vector regression in R Try using the kernlab package, you can use ksvm(...,type='eps-svr') to get regression. It's smart enough to automatically select regression if given a continuous variable. A grid search for parameters usually works reasonably well. Choice of kernel can have a big impact on performance. One rules of thumb I've found is that linear kernels or lower order polynomials work ok with high dimension problems, but RBFs work better with low dimension problems. But you're still best trying everything.
Support vector regression in R Try using the kernlab package, you can use ksvm(...,type='eps-svr') to get regression. It's smart enough to automatically select regression if given a continuous variable. A grid search for parameter
42,584
Mean squared error for data with skewed distribution
One possible pragmatic response is inspired by the motivation behind the logit transformation used in logistic regression. In that situation, the original response is constrained between 0 and 1 and hence treating it as though it has a normal distribution causes all sorts of problems. Part of the response is to transform by log(y/(1-y)), where y is the modelled response. Your problem is comparable, just that the limits are 1 and 5 rather than 0 and 1. If you want to analyse your data using methods motivated by Normal-distribution assumptions (into which I would categorise use of squared errors), you could consider transforming it on to a scale with no upper or lower bounds as below (in R, but the code should make sense if you're not familiar with it; the key line is the one that creates the "z" variable from the original "y"): # generate some skewed data in the [1,5] space: y <- rnorm(1000,4,1) y[y<1] <- runif(sum(y<1),1,3) y[y>5] <- runif(sum(y>5),3.5,5) # transform it similar to logit transform z <- log((y-1)/4 / (1-(y-1)/4)) # plot the results par(mfrow=c(1,2)) hist(y); hist(z) The new z variable is much more suited for OLS or whatever other similar techniques you might want to try.
Mean squared error for data with skewed distribution
One possible pragmatic response is inspired by the motivation behind the logit transformation used in logistic regression. In that situation, the original response is constrained between 0 and 1 and
Mean squared error for data with skewed distribution One possible pragmatic response is inspired by the motivation behind the logit transformation used in logistic regression. In that situation, the original response is constrained between 0 and 1 and hence treating it as though it has a normal distribution causes all sorts of problems. Part of the response is to transform by log(y/(1-y)), where y is the modelled response. Your problem is comparable, just that the limits are 1 and 5 rather than 0 and 1. If you want to analyse your data using methods motivated by Normal-distribution assumptions (into which I would categorise use of squared errors), you could consider transforming it on to a scale with no upper or lower bounds as below (in R, but the code should make sense if you're not familiar with it; the key line is the one that creates the "z" variable from the original "y"): # generate some skewed data in the [1,5] space: y <- rnorm(1000,4,1) y[y<1] <- runif(sum(y<1),1,3) y[y>5] <- runif(sum(y>5),3.5,5) # transform it similar to logit transform z <- log((y-1)/4 / (1-(y-1)/4)) # plot the results par(mfrow=c(1,2)) hist(y); hist(z) The new z variable is much more suited for OLS or whatever other similar techniques you might want to try.
Mean squared error for data with skewed distribution One possible pragmatic response is inspired by the motivation behind the logit transformation used in logistic regression. In that situation, the original response is constrained between 0 and 1 and
42,585
Mean squared error for data with skewed distribution
If I understand correctly, the problem you are facing is that by using MSE you are developing a poor predictor. This is a common issue on skewed-population problems. For example, if you were trying to predict if a person has cancer or not (binary) in a popluation where 99% of people dont have cancer, by analyzing a routine blood exam, a model trained by minimizing MSE would say that nobody has cancer, and would by 99% precise. One way to address this issue is to use Fscore instead of Precision, or MSE. Fscore is an error metric that uses both Precision and Recall. http://en.wikipedia.org/wiki/F1_score I learnt this in Andrew Ng's Machine Learning Course on Coursera. Here is a video of the specific class on error metrics for skewed classes. http://www.youtube.com/watch?v=uj605bVFH8Y Hope this helps!
Mean squared error for data with skewed distribution
If I understand correctly, the problem you are facing is that by using MSE you are developing a poor predictor. This is a common issue on skewed-population problems. For example, if you were trying to
Mean squared error for data with skewed distribution If I understand correctly, the problem you are facing is that by using MSE you are developing a poor predictor. This is a common issue on skewed-population problems. For example, if you were trying to predict if a person has cancer or not (binary) in a popluation where 99% of people dont have cancer, by analyzing a routine blood exam, a model trained by minimizing MSE would say that nobody has cancer, and would by 99% precise. One way to address this issue is to use Fscore instead of Precision, or MSE. Fscore is an error metric that uses both Precision and Recall. http://en.wikipedia.org/wiki/F1_score I learnt this in Andrew Ng's Machine Learning Course on Coursera. Here is a video of the specific class on error metrics for skewed classes. http://www.youtube.com/watch?v=uj605bVFH8Y Hope this helps!
Mean squared error for data with skewed distribution If I understand correctly, the problem you are facing is that by using MSE you are developing a poor predictor. This is a common issue on skewed-population problems. For example, if you were trying to
42,586
Looking for an efficient algorithm to detect Tomek links
The problem of detecting Tomek links is the same as identifying any nearest neighbor (the class label does not help here, you have to check every data point no matter which label it has). My personal preference is to go for kd-trees (as long as the dimension is not too high). The stackoverflow - question Nearest neighbors in high-dimensional data? provides more ideas.
Looking for an efficient algorithm to detect Tomek links
The problem of detecting Tomek links is the same as identifying any nearest neighbor (the class label does not help here, you have to check every data point no matter which label it has). My personal
Looking for an efficient algorithm to detect Tomek links The problem of detecting Tomek links is the same as identifying any nearest neighbor (the class label does not help here, you have to check every data point no matter which label it has). My personal preference is to go for kd-trees (as long as the dimension is not too high). The stackoverflow - question Nearest neighbors in high-dimensional data? provides more ideas.
Looking for an efficient algorithm to detect Tomek links The problem of detecting Tomek links is the same as identifying any nearest neighbor (the class label does not help here, you have to check every data point no matter which label it has). My personal
42,587
Looking for an efficient algorithm to detect Tomek links
If you can accept approximate answers (up to a controllable error rate) you can also have a look at approximate nearest neighbors search methods such as Locality Sensitive Hashing and more advanced methods implemented in the flann library.
Looking for an efficient algorithm to detect Tomek links
If you can accept approximate answers (up to a controllable error rate) you can also have a look at approximate nearest neighbors search methods such as Locality Sensitive Hashing and more advanced me
Looking for an efficient algorithm to detect Tomek links If you can accept approximate answers (up to a controllable error rate) you can also have a look at approximate nearest neighbors search methods such as Locality Sensitive Hashing and more advanced methods implemented in the flann library.
Looking for an efficient algorithm to detect Tomek links If you can accept approximate answers (up to a controllable error rate) you can also have a look at approximate nearest neighbors search methods such as Locality Sensitive Hashing and more advanced me
42,588
Looking for an efficient algorithm to detect Tomek links
The imbalanced-learn package provides many re-sampling techniques for working with imbalanced datasets: https://github.com/scikit-learn-contrib/imbalanced-learn See this example for an implementation of the Tomek links re-sampling.
Looking for an efficient algorithm to detect Tomek links
The imbalanced-learn package provides many re-sampling techniques for working with imbalanced datasets: https://github.com/scikit-learn-contrib/imbalanced-learn See this example for an implementation
Looking for an efficient algorithm to detect Tomek links The imbalanced-learn package provides many re-sampling techniques for working with imbalanced datasets: https://github.com/scikit-learn-contrib/imbalanced-learn See this example for an implementation of the Tomek links re-sampling.
Looking for an efficient algorithm to detect Tomek links The imbalanced-learn package provides many re-sampling techniques for working with imbalanced datasets: https://github.com/scikit-learn-contrib/imbalanced-learn See this example for an implementation
42,589
How do I estimate the parameters of a log-normal distribution from the sample mean and sample variance
Suppose that $X = \ln(Y)$ follows a Normal distribuion with mean $\mu$ and variance $\sigma^2$ ($N(\mu,\sigma^2)$). Using $$ E(g(X)) = \int_{-\infty}^{+\infty}g(x)p(x)dx$$ (where $p(x)$ is the pdf of the Normal distribution), we have that $$E(Y) = E(\exp(X)) = \int_{-\infty}^{+\infty}\exp(x)p(x)dx=\exp(\sigma^2/2+\mu)$$ $$E(Y^2) = E(\exp(X)^2) = \int_{-\infty}^{+\infty}\exp(x)^2p(x)dx=\exp(2\sigma^2+2\mu)$$ from which we conclude that the variance is $$V(Y) = \exp(2\mu+2\sigma^2)-\exp(2\mu+\sigma^2)$$
How do I estimate the parameters of a log-normal distribution from the sample mean and sample varian
Suppose that $X = \ln(Y)$ follows a Normal distribuion with mean $\mu$ and variance $\sigma^2$ ($N(\mu,\sigma^2)$). Using $$ E(g(X)) = \int_{-\infty}^{+\infty}g(x)p(x)dx$$ (where $p(x)$ is the pdf of
How do I estimate the parameters of a log-normal distribution from the sample mean and sample variance Suppose that $X = \ln(Y)$ follows a Normal distribuion with mean $\mu$ and variance $\sigma^2$ ($N(\mu,\sigma^2)$). Using $$ E(g(X)) = \int_{-\infty}^{+\infty}g(x)p(x)dx$$ (where $p(x)$ is the pdf of the Normal distribution), we have that $$E(Y) = E(\exp(X)) = \int_{-\infty}^{+\infty}\exp(x)p(x)dx=\exp(\sigma^2/2+\mu)$$ $$E(Y^2) = E(\exp(X)^2) = \int_{-\infty}^{+\infty}\exp(x)^2p(x)dx=\exp(2\sigma^2+2\mu)$$ from which we conclude that the variance is $$V(Y) = \exp(2\mu+2\sigma^2)-\exp(2\mu+\sigma^2)$$
How do I estimate the parameters of a log-normal distribution from the sample mean and sample varian Suppose that $X = \ln(Y)$ follows a Normal distribuion with mean $\mu$ and variance $\sigma^2$ ($N(\mu,\sigma^2)$). Using $$ E(g(X)) = \int_{-\infty}^{+\infty}g(x)p(x)dx$$ (where $p(x)$ is the pdf of
42,590
How do I estimate the parameters of a log-normal distribution from the sample mean and sample variance
This is not directly an answer to your question: But if you can instead get the mean and standard deviation of log X then you should be able to reuse the existing estimators for the normal distribution. That seems to be the most simple method, actually, unless there is additionally a location parameter.
How do I estimate the parameters of a log-normal distribution from the sample mean and sample varian
This is not directly an answer to your question: But if you can instead get the mean and standard deviation of log X then you should be able to reuse the existing estimators for the normal distributio
How do I estimate the parameters of a log-normal distribution from the sample mean and sample variance This is not directly an answer to your question: But if you can instead get the mean and standard deviation of log X then you should be able to reuse the existing estimators for the normal distribution. That seems to be the most simple method, actually, unless there is additionally a location parameter.
How do I estimate the parameters of a log-normal distribution from the sample mean and sample varian This is not directly an answer to your question: But if you can instead get the mean and standard deviation of log X then you should be able to reuse the existing estimators for the normal distributio
42,591
Combined odds ratio
It sounds like you only have p-values for each SNP. In this case you can use Fisher's method, but it is a rather crude analysis. Not only will meta-analyzing betas and SEs give you better power, but it also permits estimation of an overall effect, which will be useful in many ways, not least planning replication studies.
Combined odds ratio
It sounds like you only have p-values for each SNP. In this case you can use Fisher's method, but it is a rather crude analysis. Not only will meta-analyzing betas and SEs give you better power, but i
Combined odds ratio It sounds like you only have p-values for each SNP. In this case you can use Fisher's method, but it is a rather crude analysis. Not only will meta-analyzing betas and SEs give you better power, but it also permits estimation of an overall effect, which will be useful in many ways, not least planning replication studies.
Combined odds ratio It sounds like you only have p-values for each SNP. In this case you can use Fisher's method, but it is a rather crude analysis. Not only will meta-analyzing betas and SEs give you better power, but i
42,592
Where do I find large face datasets?
If you can handle unconstrained imaging conditions you should perhaps look at LFW and PubFig. If you need controlled imaging conditions you should perhaps look at MultiPIE.
Where do I find large face datasets?
If you can handle unconstrained imaging conditions you should perhaps look at LFW and PubFig. If you need controlled imaging conditions you should perhaps look at MultiPIE.
Where do I find large face datasets? If you can handle unconstrained imaging conditions you should perhaps look at LFW and PubFig. If you need controlled imaging conditions you should perhaps look at MultiPIE.
Where do I find large face datasets? If you can handle unconstrained imaging conditions you should perhaps look at LFW and PubFig. If you need controlled imaging conditions you should perhaps look at MultiPIE.
42,593
Survival analysis with categorical variable
You can split each of your patients up into multiple records. For example, if Patient Joe is followed for 5 years, switching from A to B two years in, and B to C two years after that, he'd be three records. Joe # 1 who entered at Year 0, and left at year 2. Joe #2 who enters at year 2 and leaves at year 4, and Joe #3, who enters at year 4 and leaves at year 5. You then use a robust variance estimator that takes care of the fact that you have some non-independence in your data, and you can run any survival analysis you want. I suspect if you're looking for a 1 year probability of failure, you'd use some parametric estimator of the survival curve, or a Kaplan-Meyer type analysis.
Survival analysis with categorical variable
You can split each of your patients up into multiple records. For example, if Patient Joe is followed for 5 years, switching from A to B two years in, and B to C two years after that, he'd be three re
Survival analysis with categorical variable You can split each of your patients up into multiple records. For example, if Patient Joe is followed for 5 years, switching from A to B two years in, and B to C two years after that, he'd be three records. Joe # 1 who entered at Year 0, and left at year 2. Joe #2 who enters at year 2 and leaves at year 4, and Joe #3, who enters at year 4 and leaves at year 5. You then use a robust variance estimator that takes care of the fact that you have some non-independence in your data, and you can run any survival analysis you want. I suspect if you're looking for a 1 year probability of failure, you'd use some parametric estimator of the survival curve, or a Kaplan-Meyer type analysis.
Survival analysis with categorical variable You can split each of your patients up into multiple records. For example, if Patient Joe is followed for 5 years, switching from A to B two years in, and B to C two years after that, he'd be three re
42,594
Survival analysis with categorical variable
The simplest approach is to break up each subject into multiple person-years with each year associated with only one category and an event yes/no indicator. You can get yearly probabilities from this without difficulties. Note that this would assume that the probabilities are constant over time. Poisson regression can be used for inference.
Survival analysis with categorical variable
The simplest approach is to break up each subject into multiple person-years with each year associated with only one category and an event yes/no indicator. You can get yearly probabilities from this
Survival analysis with categorical variable The simplest approach is to break up each subject into multiple person-years with each year associated with only one category and an event yes/no indicator. You can get yearly probabilities from this without difficulties. Note that this would assume that the probabilities are constant over time. Poisson regression can be used for inference.
Survival analysis with categorical variable The simplest approach is to break up each subject into multiple person-years with each year associated with only one category and an event yes/no indicator. You can get yearly probabilities from this
42,595
Survival analysis with categorical variable
If I understand you description correctly, you case falls within discrete time survival/hazard analysis (discrete time in the sense of discretized intervals of a continuous process, not in the sense that events only happen after fixed intervals). In that case I would follow Aniko's suggestion and use a logistic regression model with person-years as observations, with event occurrence as a dependent variable and category as a time-variant explanatory variable (together with time of course). An applied handbook recommended for this case is Applied Longitudinal Data Analysis by Singer & Willett, ch. 10-12. See here for worked examples/syntax for different programs.
Survival analysis with categorical variable
If I understand you description correctly, you case falls within discrete time survival/hazard analysis (discrete time in the sense of discretized intervals of a continuous process, not in the sense t
Survival analysis with categorical variable If I understand you description correctly, you case falls within discrete time survival/hazard analysis (discrete time in the sense of discretized intervals of a continuous process, not in the sense that events only happen after fixed intervals). In that case I would follow Aniko's suggestion and use a logistic regression model with person-years as observations, with event occurrence as a dependent variable and category as a time-variant explanatory variable (together with time of course). An applied handbook recommended for this case is Applied Longitudinal Data Analysis by Singer & Willett, ch. 10-12. See here for worked examples/syntax for different programs.
Survival analysis with categorical variable If I understand you description correctly, you case falls within discrete time survival/hazard analysis (discrete time in the sense of discretized intervals of a continuous process, not in the sense t
42,596
Mixed model with repeated measures and both of two treatments with lme or lmer in R
Many years late, but for completeness' sake, I will attempt to answer this. As noted in the question, the main complication is that there is variance in the data explainable by the fact that there are multiple measurements on each individual. You can account for this with a random effect. The simplest model that you might use to address this above question (in R) is: library(lme4) lmer(distance_estimate ~ condition + measurement_occasion + actual_distance + (1|participant)) Things to note: 1) I have assumed no interactions here but several are plausible. For example, condition and actual_distance might interact, as might condition and measurement_occasion. Which ones are included depends on your hypotheses. 2) I've also used just a random intercept here, but you might well include a random slope, or both random intercepts and slopes. Again, this will depend on your hypotheses and domain knowledge.
Mixed model with repeated measures and both of two treatments with lme or lmer in R
Many years late, but for completeness' sake, I will attempt to answer this. As noted in the question, the main complication is that there is variance in the data explainable by the fact that there ar
Mixed model with repeated measures and both of two treatments with lme or lmer in R Many years late, but for completeness' sake, I will attempt to answer this. As noted in the question, the main complication is that there is variance in the data explainable by the fact that there are multiple measurements on each individual. You can account for this with a random effect. The simplest model that you might use to address this above question (in R) is: library(lme4) lmer(distance_estimate ~ condition + measurement_occasion + actual_distance + (1|participant)) Things to note: 1) I have assumed no interactions here but several are plausible. For example, condition and actual_distance might interact, as might condition and measurement_occasion. Which ones are included depends on your hypotheses. 2) I've also used just a random intercept here, but you might well include a random slope, or both random intercepts and slopes. Again, this will depend on your hypotheses and domain knowledge.
Mixed model with repeated measures and both of two treatments with lme or lmer in R Many years late, but for completeness' sake, I will attempt to answer this. As noted in the question, the main complication is that there is variance in the data explainable by the fact that there ar
42,597
Readdressing the semantics of multivariate and multivariable analysis
I found this to be the most useful response: The distinction is important, but we have no way of imposing a terminology on "the world" (except, perhaps, by writing seminal papers). Just make sure that when you read a paper, you know which interpretation of the terms the author means, and make sure to explain to your own readers which one you mean.
Readdressing the semantics of multivariate and multivariable analysis
I found this to be the most useful response: The distinction is important, but we have no way of imposing a terminology on "the world" (except, perhaps, by writing seminal papers). Just make sure that
Readdressing the semantics of multivariate and multivariable analysis I found this to be the most useful response: The distinction is important, but we have no way of imposing a terminology on "the world" (except, perhaps, by writing seminal papers). Just make sure that when you read a paper, you know which interpretation of the terms the author means, and make sure to explain to your own readers which one you mean.
Readdressing the semantics of multivariate and multivariable analysis I found this to be the most useful response: The distinction is important, but we have no way of imposing a terminology on "the world" (except, perhaps, by writing seminal papers). Just make sure that
42,598
In spatial regression, what is a spherical autocorrelation structure?
I'll make a leap of faith, and assume that you are referring to a spherical spatial correlation structure. A spherical spatial correlation structure has two parameters: $n$, the "nugget" effect, which acts to reduce all the correlations between two observations more than 0 distance apart, and $d$, the range (distance) over which the correlations will be nonzero. Slightly rephrasing the documentation from R's nlme package: The correlation between two observations a distance $r < d$ apart is, if the nugget effect is zero, $1 - 1.5(r/d) + 0.5(r/d)^3$. If $r\ge d$ the correlation is zero. If there is a nugget effect $n$, the correlation is just $(1-n)(1 - 1.5(r/d) + 0.5(r/d)^3)$ for all observations for which $r > 0$. The "spherical" refers to its symmetry with respect to direction, like a sphere with respect to the origin, rather than to the shape of the surface from which the data was collected, although, confusingly, it is also the name of the structure. However, it does seem to me that, if there is correlation between your observations that is related to distance between them regardless of direction, a spherical spatial correlation structure would be a reasonable first try. There are other spatial correlation structures, though, e.g., Gaussian or exponential (which also are symmetric with respect to direction.) A reference is "Statistics for Spatial Data", by N. A. C. Cressie, 1993.
In spatial regression, what is a spherical autocorrelation structure?
I'll make a leap of faith, and assume that you are referring to a spherical spatial correlation structure. A spherical spatial correlation structure has two parameters: $n$, the "nugget" effect, whic
In spatial regression, what is a spherical autocorrelation structure? I'll make a leap of faith, and assume that you are referring to a spherical spatial correlation structure. A spherical spatial correlation structure has two parameters: $n$, the "nugget" effect, which acts to reduce all the correlations between two observations more than 0 distance apart, and $d$, the range (distance) over which the correlations will be nonzero. Slightly rephrasing the documentation from R's nlme package: The correlation between two observations a distance $r < d$ apart is, if the nugget effect is zero, $1 - 1.5(r/d) + 0.5(r/d)^3$. If $r\ge d$ the correlation is zero. If there is a nugget effect $n$, the correlation is just $(1-n)(1 - 1.5(r/d) + 0.5(r/d)^3)$ for all observations for which $r > 0$. The "spherical" refers to its symmetry with respect to direction, like a sphere with respect to the origin, rather than to the shape of the surface from which the data was collected, although, confusingly, it is also the name of the structure. However, it does seem to me that, if there is correlation between your observations that is related to distance between them regardless of direction, a spherical spatial correlation structure would be a reasonable first try. There are other spatial correlation structures, though, e.g., Gaussian or exponential (which also are symmetric with respect to direction.) A reference is "Statistics for Spatial Data", by N. A. C. Cressie, 1993.
In spatial regression, what is a spherical autocorrelation structure? I'll make a leap of faith, and assume that you are referring to a spherical spatial correlation structure. A spherical spatial correlation structure has two parameters: $n$, the "nugget" effect, whic
42,599
What is a good source to learn about multidimensional scaling?
A good textbook on multivariate data analysis, mixing introductory material and more advanced theory, is Modern Multivariate Statistical Techniques, by Alan J. Izenman (Springer, 2008). A review by John Maindonald was published in the JSS. It features a complete chapter dedicated to MDS (chapter 13), with a lot of illustration using the open-source R statistical software. More on R packages can be found on CRAN Multivariate Task View, among others. As an alternative, I would suggest the Handbook of Applied Multivariate Statistics and Mathematical Modeling, by Howard E. A. Tinsley and Steven D. Brown (Academic Press, 2000). Again, a complete chapter is devoted to MDS. Less mathematical background is required. As for online reference, I can also recommend Forrest W. Young's course on Multidimensional Scaling.
What is a good source to learn about multidimensional scaling?
A good textbook on multivariate data analysis, mixing introductory material and more advanced theory, is Modern Multivariate Statistical Techniques, by Alan J. Izenman (Springer, 2008). A review by Jo
What is a good source to learn about multidimensional scaling? A good textbook on multivariate data analysis, mixing introductory material and more advanced theory, is Modern Multivariate Statistical Techniques, by Alan J. Izenman (Springer, 2008). A review by John Maindonald was published in the JSS. It features a complete chapter dedicated to MDS (chapter 13), with a lot of illustration using the open-source R statistical software. More on R packages can be found on CRAN Multivariate Task View, among others. As an alternative, I would suggest the Handbook of Applied Multivariate Statistics and Mathematical Modeling, by Howard E. A. Tinsley and Steven D. Brown (Academic Press, 2000). Again, a complete chapter is devoted to MDS. Less mathematical background is required. As for online reference, I can also recommend Forrest W. Young's course on Multidimensional Scaling.
What is a good source to learn about multidimensional scaling? A good textbook on multivariate data analysis, mixing introductory material and more advanced theory, is Modern Multivariate Statistical Techniques, by Alan J. Izenman (Springer, 2008). A review by Jo
42,600
Why are degrees of freedom so high in repeated measures mixed models?
Unless I'm reading you incorrectly you would have approximately this many degrees of freedom in a standard repeated measures ANOVA. The ANOVA error is the interaction between subjects and the effect and requires degrees of freedom from both. However, if you are making multiple measures at each time interval then yes, the degrees for freedom are much higher for the mixed effects model. It's not the standard pseudoreplication problem you'd have if you were doing a repeated measures ANOVA. With the ANOVA you are only modelling the effects in question and should aggregate your data to get better estimates of each effect for each S. With mixed effects modelling you are potentially modelling each data point, even those pseudoreplicated measurements you take for accuracies sake. You can do that because you're explicitly saying these individual measures are grouped within subjects and within this factor, etc. Therefore, you can often have more degrees of freedom. Although, as I stated before, it doesn't sound like that's the case here anyway.
Why are degrees of freedom so high in repeated measures mixed models?
Unless I'm reading you incorrectly you would have approximately this many degrees of freedom in a standard repeated measures ANOVA. The ANOVA error is the interaction between subjects and the effect
Why are degrees of freedom so high in repeated measures mixed models? Unless I'm reading you incorrectly you would have approximately this many degrees of freedom in a standard repeated measures ANOVA. The ANOVA error is the interaction between subjects and the effect and requires degrees of freedom from both. However, if you are making multiple measures at each time interval then yes, the degrees for freedom are much higher for the mixed effects model. It's not the standard pseudoreplication problem you'd have if you were doing a repeated measures ANOVA. With the ANOVA you are only modelling the effects in question and should aggregate your data to get better estimates of each effect for each S. With mixed effects modelling you are potentially modelling each data point, even those pseudoreplicated measurements you take for accuracies sake. You can do that because you're explicitly saying these individual measures are grouped within subjects and within this factor, etc. Therefore, you can often have more degrees of freedom. Although, as I stated before, it doesn't sound like that's the case here anyway.
Why are degrees of freedom so high in repeated measures mixed models? Unless I'm reading you incorrectly you would have approximately this many degrees of freedom in a standard repeated measures ANOVA. The ANOVA error is the interaction between subjects and the effect