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
47,201
Why I am getting different $R^2$ from R LM and manual calculation?
I found the problem. I am not adding the intercept in the model and without intercept SST is calculated differently, where it should be crossprod(diamonds$price) but not crossprod(diamonds$price-mean(diamonds$price)) I think most books are confusing that just give us the formula to SST as $$ \|y-\bar y\|^2 $$ but not mention such formula only holds for model with intercept term.
Why I am getting different $R^2$ from R LM and manual calculation?
I found the problem. I am not adding the intercept in the model and without intercept SST is calculated differently, where it should be crossprod(diamonds$price) but not crossprod(diamonds$price-me
Why I am getting different $R^2$ from R LM and manual calculation? I found the problem. I am not adding the intercept in the model and without intercept SST is calculated differently, where it should be crossprod(diamonds$price) but not crossprod(diamonds$price-mean(diamonds$price)) I think most books are confusing that just give us the formula to SST as $$ \|y-\bar y\|^2 $$ but not mention such formula only holds for model with intercept term.
Why I am getting different $R^2$ from R LM and manual calculation? I found the problem. I am not adding the intercept in the model and without intercept SST is calculated differently, where it should be crossprod(diamonds$price) but not crossprod(diamonds$price-me
47,202
Something more powerful than Kruskal-Wallis Test?
I think the issue you're having is both one of sample size and the nature of the alternative hypothesis for the particular test you're using. The Kruskal-Wallis test tries to determine if the distributions are equal, or if one stochastically dominates another. This means that the probability that one quantity is larger than $t$ is greater than that of another distribution for every $t$ (or less precisely the probability that one quantity is "big" is larger than another). The point is that the Kruskal-Wallis test isn't sensitive to any differences whatsoever between the distributions. If we take your example and plot the empirical distribution functions we will see that the times when the test rejects roughly coincide with the cases where the empirical distribution functions don't overlap. If you're interested not just in stochastic domination but differences in shape as well, you might consider a $k$-sample Kolmogorov-Smirnov test which is discussed in this post: Is there a multiple-sample version or alternative to the Kolmogorov-Smirnov Test?. library(ggplot2) n <- 10 y <- c(sort(rchisq(n, df=1)), sort(rnorm(n)), sort(runif(n)) x <- rep(1:3, c(n, n, n)) # calculate empirical distribution functions f <- rep(1:n / n, 3) df <- data.frame(x, y, f) rm(x, y, f, n) kruskal.test(y ~ x, data=df) # plot empirical distribution functions qplot(y, f, data=df, geom="step", colour=as.factor(x))
Something more powerful than Kruskal-Wallis Test?
I think the issue you're having is both one of sample size and the nature of the alternative hypothesis for the particular test you're using. The Kruskal-Wallis test tries to determine if the distrib
Something more powerful than Kruskal-Wallis Test? I think the issue you're having is both one of sample size and the nature of the alternative hypothesis for the particular test you're using. The Kruskal-Wallis test tries to determine if the distributions are equal, or if one stochastically dominates another. This means that the probability that one quantity is larger than $t$ is greater than that of another distribution for every $t$ (or less precisely the probability that one quantity is "big" is larger than another). The point is that the Kruskal-Wallis test isn't sensitive to any differences whatsoever between the distributions. If we take your example and plot the empirical distribution functions we will see that the times when the test rejects roughly coincide with the cases where the empirical distribution functions don't overlap. If you're interested not just in stochastic domination but differences in shape as well, you might consider a $k$-sample Kolmogorov-Smirnov test which is discussed in this post: Is there a multiple-sample version or alternative to the Kolmogorov-Smirnov Test?. library(ggplot2) n <- 10 y <- c(sort(rchisq(n, df=1)), sort(rnorm(n)), sort(runif(n)) x <- rep(1:3, c(n, n, n)) # calculate empirical distribution functions f <- rep(1:n / n, 3) df <- data.frame(x, y, f) rm(x, y, f, n) kruskal.test(y ~ x, data=df) # plot empirical distribution functions qplot(y, f, data=df, geom="step", colour=as.factor(x))
Something more powerful than Kruskal-Wallis Test? I think the issue you're having is both one of sample size and the nature of the alternative hypothesis for the particular test you're using. The Kruskal-Wallis test tries to determine if the distrib
47,203
Something more powerful than Kruskal-Wallis Test?
(A little less formal that dsaxton's analysis... but a quick way to judge in this case) It's not at all clear to me that these are different: For a rough pairwise comparison, at sample size 10, the uncertainty in the median (since we're looking at boxplots here) is about the size that if the boxes overlap, the two aren't significantly different (though it depends partly on the relative spreads). [Where does this "at n=10 see if the boxes overlap" idea come from? See the analysis here and then note the neat coincidence that $1.58$ is almost exactly $\sqrt{10}/2$, which means that, at least when the median is toward the middle of the box, the problem reduces to checking for overlapping boxes. I noticed this back in the 80s and it's a rule of thumb that's come in pretty handy. It's not hard to adjust for other sample sizes from there -- e.g. if n is 40, the complete notch interval will be half a box-width] As we see here, the boxes for groups 1 and 3 overlap almost completely (in that the interval for group 3 is almost entirely contained in that for group 1), and group 2 just overlaps group 3, while groups 1 and 2 just fail to overlap. Now note that the median for the low group (group 2) is high in its box, not symmetric, while the median for the high group (group 1) is low, so the indication of a difference in location is even less strong there. So at least looking at the information from the boxplots alone, I see little reason to think there's necessarily anything different here -- far from being obvious, this is pretty equivocal evidence of a difference. (In fact if you look at notched boxplots, all the pairwise notch intervals overlap substantially.) So if I were to guess just from the boxplot, I'd think that Kruskal-Wallis test would perhaps be around the border of rejection at the 5% level, but I wouldn't actually expect it to reject. (It might, depending on the specifics of the sample -- it doesn't quite do the same thing as comparing boxplots -- but we really shouldn't be surprised if it doesn't) So it's not that the Kruskal-Wallis is missing anything here -- I'd say your judgement about what would "appear quite different" (as you put it in the original post) is miscalibrated for this small sample size. The indication of location difference is simply not clear in the data. If you're interested in more general differences than location differences (such as differences in spread or shape), you might consider other tests than this one... but with an even broader class of alternatives at n=10 you generally won't be able to say much.
Something more powerful than Kruskal-Wallis Test?
(A little less formal that dsaxton's analysis... but a quick way to judge in this case) It's not at all clear to me that these are different: For a rough pairwise comparison, at sample size 10, the u
Something more powerful than Kruskal-Wallis Test? (A little less formal that dsaxton's analysis... but a quick way to judge in this case) It's not at all clear to me that these are different: For a rough pairwise comparison, at sample size 10, the uncertainty in the median (since we're looking at boxplots here) is about the size that if the boxes overlap, the two aren't significantly different (though it depends partly on the relative spreads). [Where does this "at n=10 see if the boxes overlap" idea come from? See the analysis here and then note the neat coincidence that $1.58$ is almost exactly $\sqrt{10}/2$, which means that, at least when the median is toward the middle of the box, the problem reduces to checking for overlapping boxes. I noticed this back in the 80s and it's a rule of thumb that's come in pretty handy. It's not hard to adjust for other sample sizes from there -- e.g. if n is 40, the complete notch interval will be half a box-width] As we see here, the boxes for groups 1 and 3 overlap almost completely (in that the interval for group 3 is almost entirely contained in that for group 1), and group 2 just overlaps group 3, while groups 1 and 2 just fail to overlap. Now note that the median for the low group (group 2) is high in its box, not symmetric, while the median for the high group (group 1) is low, so the indication of a difference in location is even less strong there. So at least looking at the information from the boxplots alone, I see little reason to think there's necessarily anything different here -- far from being obvious, this is pretty equivocal evidence of a difference. (In fact if you look at notched boxplots, all the pairwise notch intervals overlap substantially.) So if I were to guess just from the boxplot, I'd think that Kruskal-Wallis test would perhaps be around the border of rejection at the 5% level, but I wouldn't actually expect it to reject. (It might, depending on the specifics of the sample -- it doesn't quite do the same thing as comparing boxplots -- but we really shouldn't be surprised if it doesn't) So it's not that the Kruskal-Wallis is missing anything here -- I'd say your judgement about what would "appear quite different" (as you put it in the original post) is miscalibrated for this small sample size. The indication of location difference is simply not clear in the data. If you're interested in more general differences than location differences (such as differences in spread or shape), you might consider other tests than this one... but with an even broader class of alternatives at n=10 you generally won't be able to say much.
Something more powerful than Kruskal-Wallis Test? (A little less formal that dsaxton's analysis... but a quick way to judge in this case) It's not at all clear to me that these are different: For a rough pairwise comparison, at sample size 10, the u
47,204
Causal Markov condition simple explanation
One way to think about the Causal Markov Condition (CMC) is giving a rule for "screening off": once you know the values of $X$'s parents, all other variables in $V$ become irrelevant for predicting $X$, except for $X$'s descendants. I find examples make the CMC easiest to understand. I did a quick google image search for "mechanism of cardiovascular disease" so I can give you a medical example. Take this graph (let's call it $G$): Say you have a probability distribution $P$ over the variables in $G$. If the CMC holds in $P$ (relative to $G$), then you can infer that: If I know the patient's amount of Oxidative stress and inflammation, then learning the patient's degree of Plaque progression won't give me any extra information about the patient's Platelets. If I know the patient's amount of Atheroma, then learning the amount of Oxidative stress and inflammation won't help me predict Plaque progression. However, the CMC allows the following possibilities: If I know the patient's amount of Atheroma, then learning the patient's degree of Plaque rupture might still tell me something more about Plaque progression. (I'm learning from a descendant variable.) If I don't know the patient's amount of Oxidative stress and inflammation, then learning the patient's degree of Plaque progression might well give me some extra information that helps me predict the patient's Platelets. (I'm not conditioning on the parents.)
Causal Markov condition simple explanation
One way to think about the Causal Markov Condition (CMC) is giving a rule for "screening off": once you know the values of $X$'s parents, all other variables in $V$ become irrelevant for predicting $X
Causal Markov condition simple explanation One way to think about the Causal Markov Condition (CMC) is giving a rule for "screening off": once you know the values of $X$'s parents, all other variables in $V$ become irrelevant for predicting $X$, except for $X$'s descendants. I find examples make the CMC easiest to understand. I did a quick google image search for "mechanism of cardiovascular disease" so I can give you a medical example. Take this graph (let's call it $G$): Say you have a probability distribution $P$ over the variables in $G$. If the CMC holds in $P$ (relative to $G$), then you can infer that: If I know the patient's amount of Oxidative stress and inflammation, then learning the patient's degree of Plaque progression won't give me any extra information about the patient's Platelets. If I know the patient's amount of Atheroma, then learning the amount of Oxidative stress and inflammation won't help me predict Plaque progression. However, the CMC allows the following possibilities: If I know the patient's amount of Atheroma, then learning the patient's degree of Plaque rupture might still tell me something more about Plaque progression. (I'm learning from a descendant variable.) If I don't know the patient's amount of Oxidative stress and inflammation, then learning the patient's degree of Plaque progression might well give me some extra information that helps me predict the patient's Platelets. (I'm not conditioning on the parents.)
Causal Markov condition simple explanation One way to think about the Causal Markov Condition (CMC) is giving a rule for "screening off": once you know the values of $X$'s parents, all other variables in $V$ become irrelevant for predicting $X
47,205
R using GLM and manual solve logistic regression have different (close but not exactly the same) results
Short answer: Optimise harder. Your loss function is fine, no numeric issues there. For instance you can easily check that: all.equal( lossLogistic(coef(fit)), as.numeric(-logLik(fit)), check.attributes = FALSE) [1] TRUE What happens is that you assume that optim's BFGS implementation can get as good as an routine that use actual gradient information - remember Fisher scoring is essentially a Newton-Raphson routine. BFGS converged ( opt$convergence equals 0) but the best of BFGS was not the best you could get because as you did not provide a gradient function the routine had to numerically approximate the gradient. If you used a better optimisation procedure that could use more gradient-like information you would get the same results. Here, because the log-likelihood is actually a very well behaved function I can even use a quadratic approximation procedure to "fake" gradient information. library(minqa) optQ= minqa::uobyqa(c(1,1),lossLogistic) all.equal( optQ$par, coef(fit), check.attributes = FALSE) [1] TRUE all.equal( optQ$fval, as.numeric(-logLik(fit)), check.attributes = FALSE) [1] TRUE It works.
R using GLM and manual solve logistic regression have different (close but not exactly the same) res
Short answer: Optimise harder. Your loss function is fine, no numeric issues there. For instance you can easily check that: all.equal( lossLogistic(coef(fit)), as.numeric(-logLik(fit)), c
R using GLM and manual solve logistic regression have different (close but not exactly the same) results Short answer: Optimise harder. Your loss function is fine, no numeric issues there. For instance you can easily check that: all.equal( lossLogistic(coef(fit)), as.numeric(-logLik(fit)), check.attributes = FALSE) [1] TRUE What happens is that you assume that optim's BFGS implementation can get as good as an routine that use actual gradient information - remember Fisher scoring is essentially a Newton-Raphson routine. BFGS converged ( opt$convergence equals 0) but the best of BFGS was not the best you could get because as you did not provide a gradient function the routine had to numerically approximate the gradient. If you used a better optimisation procedure that could use more gradient-like information you would get the same results. Here, because the log-likelihood is actually a very well behaved function I can even use a quadratic approximation procedure to "fake" gradient information. library(minqa) optQ= minqa::uobyqa(c(1,1),lossLogistic) all.equal( optQ$par, coef(fit), check.attributes = FALSE) [1] TRUE all.equal( optQ$fval, as.numeric(-logLik(fit)), check.attributes = FALSE) [1] TRUE It works.
R using GLM and manual solve logistic regression have different (close but not exactly the same) res Short answer: Optimise harder. Your loss function is fine, no numeric issues there. For instance you can easily check that: all.equal( lossLogistic(coef(fit)), as.numeric(-logLik(fit)), c
47,206
Formulation of states for this RL problem and other questions.
Summary The state space follows from the problem. "Niceness" depends on the method, as does "too big." You can alter the reward function to speed learning if you know the optimal policy is invariant to the transformation. Tractable depends on more than just state space. RL has been applied to much larger problems, though those methods aren't exactly out-of-the-box. Defining the state space It's unclear what you mean by "nice." Consider what you know: The goal is in the center. The agent starts in the bottom left. The first subgoal appears somewhere other than these two spaces. Sometimes upon reaching a subgoal, another appears; sometimes not. So long as a subgoal is present, the agent must reach it prior to reaching the goal. Meaning, the number of subgoals doesn't seem particularly material to the optimal policy. In a discrete representation, the agent can be in one of $10,000$ positions, and if a subgoal is present it can appear in any of $9,998$. (Assuming it can never be in the goal state, and knowing it can never be in the agent's starting position, which follows from knowing that subgoals only get closer to the goal.) Big? Sure. Too big for standard Q-learning? Likely, if you'd like your learner to return a policy before the heat death of the universe. But this would seem to be the full, irreducible representation of your problem. My idea would be to choose the 'relative' position between the agent and the goal. Something like: $(x,y)$, $x = \{ -1, 0, 1\}$. $-1$ if the goal is to the left of the agent, 1 if the goal is to the right, and 0 if the goal is at the same $x$ coordinate as the agent. $y = \{ -1,0,1\}$, $-1$ if the goal is below, $1$ if above the agent. 0 if they the same $y-$coordinate. I sense what you're getting at here: You'd like to map a large state space $S$ to smaller one $\hat S$ such that $\pi^*_{S}(s) = \pi^*_{\hat S}(\hat s)$. This makes intuitive sense, as relative distance to subgoals and goal are just about all the agent needs to make optimal decisions. This is basically handcrafting a policy; it's fine if that suits your problem, but then one wonders if you need RL at all. Is this tractable? Well, it's learnable, in the sense that it's well within the current state of the art. Consider the state space described in the paper on learning to play Atari games via deep neural networks and Q-learning: Working directly with raw Atari frames, which are 210 × 160 pixel images with a 128 color palette, can be computationally demanding, so we apply a basic preprocessing step aimed at reducing the input dimensionality. The raw frames are preprocessed by first converting their RGB representation to gray-scale and down-sampling it to a 110×84 image. The final input representation is obtained by cropping an 84 × 84 region of the image that roughly captures the playing area. [...] For the experiments in this paper, the function $\phi$ from algorithm 1 applies this preprocessing to the last 4 frames of a history and stacks them to produce the input to the Q-function. You could view your state space as a subset of the $100 \times 100$ images, and the state space above dwarfs yours. All to say that likely solutions exist even for bigger state spaces, but in this you probably needn't get that fancy. On 'cheating' I believe it is standard in RL that the reward is given at the end of the task. I'd urge you to quickly disabuse yourself of this notion: It simply isn't true. Firstly because the reward function follows from the application, full stop. If an application entails different rewards, they should naturally be included, i.e. a single reward is hardly standard. Secondly because optimal policies are invariant under certain transformations of the reward function, which can speed learning (emphasis mine): This paper investigates conditions under which modifications to the reward function of a Markov decision process preserve the optimal policy. It is shown that [...] one can add a reward for transitions between states that is expressible as the difference in value of an arbitrary potential function applied to those states. [...] In particular, some well-known "bugs" in reward shaping procedures are shown to arise from non-potential-based rewards, and methods are given for constructing shaping potentials corresponding to distance-based and subgoal-based heuristics. We show that such potentials can lead to substantial reductions in learning time. If your problem has one goal state, a single reward is a natural representation, and you're right that arbitrarily adding rewards to states is a bad idea. But it's only so when one cannot show policy invariance under the transformation; otherwise it's fair game. What should you actually do? As you know, you can expect any action under the optimal policy to generally either be moving toward the subgoal or moving toward the goal. I think you'll find that you can create potential-based reward shaping functions from these facts, ones that would quickly speed learning. You could also view this as an option learning problem, wherein one option was to pursue the subgoal, the other to pursue the goal. (Option is a term used to describe temporally extended actions. You can view it as using a certain policy until a certain state is reached.) You could also just initialize $Q$ such that the starting policy was close to optimal. Addenda Is there a way to write the states to include the subgoal positions without giving multiple rewards? No representation of the state space requires a certain reward function. It's unclear what this means. References Playing Atari with Deep Reinforcement Learning by Mnih et al Policy invariance under reward transformations: Theory and application to reward shaping by Ng et al. Learning Options in Reinforcement Learning by Stolle and Precup
Formulation of states for this RL problem and other questions.
Summary The state space follows from the problem. "Niceness" depends on the method, as does "too big." You can alter the reward function to speed learning if you know the optimal policy is invariant
Formulation of states for this RL problem and other questions. Summary The state space follows from the problem. "Niceness" depends on the method, as does "too big." You can alter the reward function to speed learning if you know the optimal policy is invariant to the transformation. Tractable depends on more than just state space. RL has been applied to much larger problems, though those methods aren't exactly out-of-the-box. Defining the state space It's unclear what you mean by "nice." Consider what you know: The goal is in the center. The agent starts in the bottom left. The first subgoal appears somewhere other than these two spaces. Sometimes upon reaching a subgoal, another appears; sometimes not. So long as a subgoal is present, the agent must reach it prior to reaching the goal. Meaning, the number of subgoals doesn't seem particularly material to the optimal policy. In a discrete representation, the agent can be in one of $10,000$ positions, and if a subgoal is present it can appear in any of $9,998$. (Assuming it can never be in the goal state, and knowing it can never be in the agent's starting position, which follows from knowing that subgoals only get closer to the goal.) Big? Sure. Too big for standard Q-learning? Likely, if you'd like your learner to return a policy before the heat death of the universe. But this would seem to be the full, irreducible representation of your problem. My idea would be to choose the 'relative' position between the agent and the goal. Something like: $(x,y)$, $x = \{ -1, 0, 1\}$. $-1$ if the goal is to the left of the agent, 1 if the goal is to the right, and 0 if the goal is at the same $x$ coordinate as the agent. $y = \{ -1,0,1\}$, $-1$ if the goal is below, $1$ if above the agent. 0 if they the same $y-$coordinate. I sense what you're getting at here: You'd like to map a large state space $S$ to smaller one $\hat S$ such that $\pi^*_{S}(s) = \pi^*_{\hat S}(\hat s)$. This makes intuitive sense, as relative distance to subgoals and goal are just about all the agent needs to make optimal decisions. This is basically handcrafting a policy; it's fine if that suits your problem, but then one wonders if you need RL at all. Is this tractable? Well, it's learnable, in the sense that it's well within the current state of the art. Consider the state space described in the paper on learning to play Atari games via deep neural networks and Q-learning: Working directly with raw Atari frames, which are 210 × 160 pixel images with a 128 color palette, can be computationally demanding, so we apply a basic preprocessing step aimed at reducing the input dimensionality. The raw frames are preprocessed by first converting their RGB representation to gray-scale and down-sampling it to a 110×84 image. The final input representation is obtained by cropping an 84 × 84 region of the image that roughly captures the playing area. [...] For the experiments in this paper, the function $\phi$ from algorithm 1 applies this preprocessing to the last 4 frames of a history and stacks them to produce the input to the Q-function. You could view your state space as a subset of the $100 \times 100$ images, and the state space above dwarfs yours. All to say that likely solutions exist even for bigger state spaces, but in this you probably needn't get that fancy. On 'cheating' I believe it is standard in RL that the reward is given at the end of the task. I'd urge you to quickly disabuse yourself of this notion: It simply isn't true. Firstly because the reward function follows from the application, full stop. If an application entails different rewards, they should naturally be included, i.e. a single reward is hardly standard. Secondly because optimal policies are invariant under certain transformations of the reward function, which can speed learning (emphasis mine): This paper investigates conditions under which modifications to the reward function of a Markov decision process preserve the optimal policy. It is shown that [...] one can add a reward for transitions between states that is expressible as the difference in value of an arbitrary potential function applied to those states. [...] In particular, some well-known "bugs" in reward shaping procedures are shown to arise from non-potential-based rewards, and methods are given for constructing shaping potentials corresponding to distance-based and subgoal-based heuristics. We show that such potentials can lead to substantial reductions in learning time. If your problem has one goal state, a single reward is a natural representation, and you're right that arbitrarily adding rewards to states is a bad idea. But it's only so when one cannot show policy invariance under the transformation; otherwise it's fair game. What should you actually do? As you know, you can expect any action under the optimal policy to generally either be moving toward the subgoal or moving toward the goal. I think you'll find that you can create potential-based reward shaping functions from these facts, ones that would quickly speed learning. You could also view this as an option learning problem, wherein one option was to pursue the subgoal, the other to pursue the goal. (Option is a term used to describe temporally extended actions. You can view it as using a certain policy until a certain state is reached.) You could also just initialize $Q$ such that the starting policy was close to optimal. Addenda Is there a way to write the states to include the subgoal positions without giving multiple rewards? No representation of the state space requires a certain reward function. It's unclear what this means. References Playing Atari with Deep Reinforcement Learning by Mnih et al Policy invariance under reward transformations: Theory and application to reward shaping by Ng et al. Learning Options in Reinforcement Learning by Stolle and Precup
Formulation of states for this RL problem and other questions. Summary The state space follows from the problem. "Niceness" depends on the method, as does "too big." You can alter the reward function to speed learning if you know the optimal policy is invariant
47,207
Improving the speed of XGBoost CV
The "tricks" I am familiar with are : Sparse matrices, which you already used. However, you need to make sure that the percentage of non zero values in your matrix is low (otherwise, it could actually take longer to run) Grow the trees one by one and observe the performance after each batch I once used the following (with sklearn's implementation of GBMs) def heldout_auc(model, X_test, y_test): score = np.zeros((model.get_params()["n_estimators"],), dtype=np.float64) for i, y_pred in enumerate(model.staged_decision_function(X_test)): score[i] = auc(y_test, y_pred) return score def cv_boost_estimate(X,y,model,n_folds=3): cv = cross_validation.StratifiedKFold(y, n_folds=n_folds, shuffle=True, random_state=11) val_scores = np.zeros((model.get_params()["n_estimators"],), dtype=np.float64) t = time() i = 0 for train, test in cv: i = i + 1 print('FOLD : ' + str(i) + '-' + str(n_folds)) model.fit(X.iloc[train,], y.iloc[train]) val_scores += heldout_auc(model, X.iloc[test,], y.iloc[test]) val_scores /= n_folds return val_scores,(time()-t) Reduce the number of folds of your CV (which can harm performance). This is close to what you describe with a validation set : "Last resort is to make a validation set and try to use that set for parameter tuning". However, I would not recommend this approach. As boosting involves a lot of parameters, you could easily be trapped in overfitting the validation set. Focus on some parameters Disclaimer, this is highly empirical ! In my experience, the most important parameters are max_depth, $\eta$ and $n_{trees}$. And the last two "work together" : decreasing $\eta$ and increasing $n_{trees}$ can help you improve the performance of the model. Whereas it seems that there is an "optimal" max depth parameter. The other parameters (colsample_bytree, subsample) are usually less relevant. Have a look at the python implementation I observed a better usage of my processors with python than with R. Maybe this has been fixed since though...
Improving the speed of XGBoost CV
The "tricks" I am familiar with are : Sparse matrices, which you already used. However, you need to make sure that the percentage of non zero values in your matrix is low (otherwise, it could actually
Improving the speed of XGBoost CV The "tricks" I am familiar with are : Sparse matrices, which you already used. However, you need to make sure that the percentage of non zero values in your matrix is low (otherwise, it could actually take longer to run) Grow the trees one by one and observe the performance after each batch I once used the following (with sklearn's implementation of GBMs) def heldout_auc(model, X_test, y_test): score = np.zeros((model.get_params()["n_estimators"],), dtype=np.float64) for i, y_pred in enumerate(model.staged_decision_function(X_test)): score[i] = auc(y_test, y_pred) return score def cv_boost_estimate(X,y,model,n_folds=3): cv = cross_validation.StratifiedKFold(y, n_folds=n_folds, shuffle=True, random_state=11) val_scores = np.zeros((model.get_params()["n_estimators"],), dtype=np.float64) t = time() i = 0 for train, test in cv: i = i + 1 print('FOLD : ' + str(i) + '-' + str(n_folds)) model.fit(X.iloc[train,], y.iloc[train]) val_scores += heldout_auc(model, X.iloc[test,], y.iloc[test]) val_scores /= n_folds return val_scores,(time()-t) Reduce the number of folds of your CV (which can harm performance). This is close to what you describe with a validation set : "Last resort is to make a validation set and try to use that set for parameter tuning". However, I would not recommend this approach. As boosting involves a lot of parameters, you could easily be trapped in overfitting the validation set. Focus on some parameters Disclaimer, this is highly empirical ! In my experience, the most important parameters are max_depth, $\eta$ and $n_{trees}$. And the last two "work together" : decreasing $\eta$ and increasing $n_{trees}$ can help you improve the performance of the model. Whereas it seems that there is an "optimal" max depth parameter. The other parameters (colsample_bytree, subsample) are usually less relevant. Have a look at the python implementation I observed a better usage of my processors with python than with R. Maybe this has been fixed since though...
Improving the speed of XGBoost CV The "tricks" I am familiar with are : Sparse matrices, which you already used. However, you need to make sure that the percentage of non zero values in your matrix is low (otherwise, it could actually
47,208
perform Random Forest AFTER multiple imputation with MICE
This is not a direct answer to your question, and I don't have enough reputation to comment, but one thing you can do is use the Machine Learning in R package. There are many random forest learner implementations there that can use data with missing values. You can also tune the learners based on what your dataset is. Links to the package and documentation are on the main tutorial page, here: https://mlr-org.github.io/mlr-tutorial/release/html/index.html Also, consider that answering your question becomes much easier if you provide a sample of your dataset. If you need a direct answer, looping a series of RF calls on the imputed datasets might work. E.g. if you have five imputations: res = data.frame(matrix(0,nrow=nrow(test),ncol=5) for (i in 1:5){ data = complete(miceResult, 1) rf.res = cforest(data,formula ~ [which formula?]) res[,i] = predict(rf.res, test) } Then you can pool the results by majority voting or averaging, depending on your dataset. You can also group the 5 imputations together and train the learner with the combined dataset. Both methods are suboptimal, however. Hope this helps.
perform Random Forest AFTER multiple imputation with MICE
This is not a direct answer to your question, and I don't have enough reputation to comment, but one thing you can do is use the Machine Learning in R package. There are many random forest learner im
perform Random Forest AFTER multiple imputation with MICE This is not a direct answer to your question, and I don't have enough reputation to comment, but one thing you can do is use the Machine Learning in R package. There are many random forest learner implementations there that can use data with missing values. You can also tune the learners based on what your dataset is. Links to the package and documentation are on the main tutorial page, here: https://mlr-org.github.io/mlr-tutorial/release/html/index.html Also, consider that answering your question becomes much easier if you provide a sample of your dataset. If you need a direct answer, looping a series of RF calls on the imputed datasets might work. E.g. if you have five imputations: res = data.frame(matrix(0,nrow=nrow(test),ncol=5) for (i in 1:5){ data = complete(miceResult, 1) rf.res = cforest(data,formula ~ [which formula?]) res[,i] = predict(rf.res, test) } Then you can pool the results by majority voting or averaging, depending on your dataset. You can also group the 5 imputations together and train the learner with the combined dataset. Both methods are suboptimal, however. Hope this helps.
perform Random Forest AFTER multiple imputation with MICE This is not a direct answer to your question, and I don't have enough reputation to comment, but one thing you can do is use the Machine Learning in R package. There are many random forest learner im
47,209
perform Random Forest AFTER multiple imputation with MICE
The combine function in randomForest makes it possible to combine multiple randomForest objects. Prepare data: set.seed(1234) X1 <- rnorm(100, 120, 16) X2 <- X1 + rnorm(100, 200, 10) X3 <- 0.8*X2 + rnorm(100, 140, 12) Y <- factor(as.numeric(X1 > 125)) dat.test <- data.frame(Y, X1, X2, X3) # Impose missingness Y[runif(100) < 0.5] <- NA X1[runif(100) < 0.5] <- NA X2[runif(100) < 0.5] <- NA X3[runif(100) < 0.5] <- NA dat <- data.frame(Y, X1, X2, X3) Impute missing data: library(mice) mice <- mice(dat, m = 10, method = "rf") impdat <- NULL # allocate empty list of imputations for (m in 1:10){impdat[[m]] <- complete(mice, m)} # export imputations Now train m models on m complete data sets: library(randomForest) rf <- NULL for (m in 1:10){rf[[m]] <- randomForest(Y ~ ., data = impdat[[m]])} Option 1 The combine function in randomForest can aggregate same-size trees: body(combine)[[4]] <- substitute(rflist <- (...)) rf.all <- combine(rf) Where rf.all is your 'pooled' model. If we test it: predictions <- predict(rf.all, within(dat.test, rm("Y"))) table(dat.test$Y, predictions) 0 1 0 70 1 1 2 27 We find the predictions are quite accurate. Option 2 A second option is to pool together the votes from each model: votes <- list() for (m in 1:10){votes[[m]] <- predict(rf[[m]], within(dat.test, rm("Y")), type = "vote")} votes <- Reduce('+', votes) predictions <- NULL for (i in 1:nrow(votes)) {if (votes[i,1] < votes[i,2]) {predictions[i] = 1} else {predictions[i] = 0}} Note the choice of type = "vote" in the argument of predict. Other functions might require type = "prob". > table(dat.test$Y, predictions) # mostly accurate predictions 0 1 0 70 1 1 2 27 The confusion matrix is the same. Pooling votes is a general approach for tree-based models that should satisfy for ranger objects and gbm objects. If the goal is regression rather than classification, pooling the votes is very similar, but set type = "response" in predict (the default). rf <- NULL for (m in 1:10){rf[[m]] <- randomForest(X1 ~ ., data = impdat[[m]])} predictions <- list() for (m in 1:10){predictions[[m]] <- predict(rf[[m]], within(dat.test, rm("X1")), type = "response")} predictions <- Reduce('+', predictions)/10 # divide by m Calculate mean square error: > mean((predictions - dat.test$X1)^2) [1] 64.78884
perform Random Forest AFTER multiple imputation with MICE
The combine function in randomForest makes it possible to combine multiple randomForest objects. Prepare data: set.seed(1234) X1 <- rnorm(100, 120, 16) X2 <- X1 + rnorm(100, 200, 10) X3 <- 0.8*X2 + r
perform Random Forest AFTER multiple imputation with MICE The combine function in randomForest makes it possible to combine multiple randomForest objects. Prepare data: set.seed(1234) X1 <- rnorm(100, 120, 16) X2 <- X1 + rnorm(100, 200, 10) X3 <- 0.8*X2 + rnorm(100, 140, 12) Y <- factor(as.numeric(X1 > 125)) dat.test <- data.frame(Y, X1, X2, X3) # Impose missingness Y[runif(100) < 0.5] <- NA X1[runif(100) < 0.5] <- NA X2[runif(100) < 0.5] <- NA X3[runif(100) < 0.5] <- NA dat <- data.frame(Y, X1, X2, X3) Impute missing data: library(mice) mice <- mice(dat, m = 10, method = "rf") impdat <- NULL # allocate empty list of imputations for (m in 1:10){impdat[[m]] <- complete(mice, m)} # export imputations Now train m models on m complete data sets: library(randomForest) rf <- NULL for (m in 1:10){rf[[m]] <- randomForest(Y ~ ., data = impdat[[m]])} Option 1 The combine function in randomForest can aggregate same-size trees: body(combine)[[4]] <- substitute(rflist <- (...)) rf.all <- combine(rf) Where rf.all is your 'pooled' model. If we test it: predictions <- predict(rf.all, within(dat.test, rm("Y"))) table(dat.test$Y, predictions) 0 1 0 70 1 1 2 27 We find the predictions are quite accurate. Option 2 A second option is to pool together the votes from each model: votes <- list() for (m in 1:10){votes[[m]] <- predict(rf[[m]], within(dat.test, rm("Y")), type = "vote")} votes <- Reduce('+', votes) predictions <- NULL for (i in 1:nrow(votes)) {if (votes[i,1] < votes[i,2]) {predictions[i] = 1} else {predictions[i] = 0}} Note the choice of type = "vote" in the argument of predict. Other functions might require type = "prob". > table(dat.test$Y, predictions) # mostly accurate predictions 0 1 0 70 1 1 2 27 The confusion matrix is the same. Pooling votes is a general approach for tree-based models that should satisfy for ranger objects and gbm objects. If the goal is regression rather than classification, pooling the votes is very similar, but set type = "response" in predict (the default). rf <- NULL for (m in 1:10){rf[[m]] <- randomForest(X1 ~ ., data = impdat[[m]])} predictions <- list() for (m in 1:10){predictions[[m]] <- predict(rf[[m]], within(dat.test, rm("X1")), type = "response")} predictions <- Reduce('+', predictions)/10 # divide by m Calculate mean square error: > mean((predictions - dat.test$X1)^2) [1] 64.78884
perform Random Forest AFTER multiple imputation with MICE The combine function in randomForest makes it possible to combine multiple randomForest objects. Prepare data: set.seed(1234) X1 <- rnorm(100, 120, 16) X2 <- X1 + rnorm(100, 200, 10) X3 <- 0.8*X2 + r
47,210
Difference between a mixture of distributions and a convolution. Interpretation in a applied setting
The mathematical difference is simple (and you probably got that already). A mixture distribution has a density which is a weighted sum of other probability densities (often from the same class) whereas a convolution is a sum of random variables. The intuition for a mixture can be illustrated (in line with your example) as follows: Let's say you have $k$ sensors each of which draws an independent measurement $X_i\sim f_i$ (for $i=1,\ldots,k$). Furthermore, let's say that you are only observing the measurement $W$ of one of these sensors $s$, i.e. $W=X_s$ by choosing the sensor s randomly (from $1,\ldots,k$) using a discrete uniform distribution. Then, the density of $W$ given that $s$ is known corresponds to $f_s$. Now, as $s$ is not known, we can consider all possible values for s and we obtain for the density a mixture distribution $$f_W(x) = P(s=1)\cdot f_1(x) + \ldots + P(s=k)\cdot f_k(x)=\frac{1}{k}\sum_{i=1}^k f_i(x)$$ In the sensor example you would have a convolution if you would take all measurements (assuming them to be independent) and sum them up,i.e., $W=X_1+\ldots+X_k$. This may happen as part of averaging the sensor measurements. Then, the resulting density is $$f_W(x) = f_{X_1+\ldots+X_k}(x) = (f_1 * f_2 * \ldots*f_k)(x)\ ,$$ where $*$ denotes the convolution operation. Side note: For the actual averaging procedure, we would have to divide the sum by the number of sensors. That is $W=k^{-1}(X_1+\ldots+X_k)$ and $$f_W(x) = f_{k^{-1}(X_1+\ldots+X_k)}(x) = k^{-1}(f_1 * f_2 * \ldots*f_k)(k\cdot x)\ .$$
Difference between a mixture of distributions and a convolution. Interpretation in a applied setting
The mathematical difference is simple (and you probably got that already). A mixture distribution has a density which is a weighted sum of other probability densities (often from the same class) where
Difference between a mixture of distributions and a convolution. Interpretation in a applied setting The mathematical difference is simple (and you probably got that already). A mixture distribution has a density which is a weighted sum of other probability densities (often from the same class) whereas a convolution is a sum of random variables. The intuition for a mixture can be illustrated (in line with your example) as follows: Let's say you have $k$ sensors each of which draws an independent measurement $X_i\sim f_i$ (for $i=1,\ldots,k$). Furthermore, let's say that you are only observing the measurement $W$ of one of these sensors $s$, i.e. $W=X_s$ by choosing the sensor s randomly (from $1,\ldots,k$) using a discrete uniform distribution. Then, the density of $W$ given that $s$ is known corresponds to $f_s$. Now, as $s$ is not known, we can consider all possible values for s and we obtain for the density a mixture distribution $$f_W(x) = P(s=1)\cdot f_1(x) + \ldots + P(s=k)\cdot f_k(x)=\frac{1}{k}\sum_{i=1}^k f_i(x)$$ In the sensor example you would have a convolution if you would take all measurements (assuming them to be independent) and sum them up,i.e., $W=X_1+\ldots+X_k$. This may happen as part of averaging the sensor measurements. Then, the resulting density is $$f_W(x) = f_{X_1+\ldots+X_k}(x) = (f_1 * f_2 * \ldots*f_k)(x)\ ,$$ where $*$ denotes the convolution operation. Side note: For the actual averaging procedure, we would have to divide the sum by the number of sensors. That is $W=k^{-1}(X_1+\ldots+X_k)$ and $$f_W(x) = f_{k^{-1}(X_1+\ldots+X_k)}(x) = k^{-1}(f_1 * f_2 * \ldots*f_k)(k\cdot x)\ .$$
Difference between a mixture of distributions and a convolution. Interpretation in a applied setting The mathematical difference is simple (and you probably got that already). A mixture distribution has a density which is a weighted sum of other probability densities (often from the same class) where
47,211
Reversibility in MCMC
I am interpreting your question as much more general in that "Is there any gain to using a reversible Markov chain over a non-reversible Markov chain?". Here are two reasons I can think of off the top of my head: Standard errors: If the chain is reversible, then a Markov chain CLT can hold for geometrically ergodic Markov chains while assuming only a finite second moment. If the chain is not reversible, then you have to assume $2 + \delta$ for $\delta > 0$ finite moments. So if you are estimating the posterior mean, and have only two finite moments available, then only a nonreversible Markov chain might not allow analysis of standard errors. You can find more information here. Spectral Gap: Often analysis of the convergence rates of MCMC samplers is done by looking at the spectral gap of the Markov chain. For a reversible Markov chain, the second largest eigenvalue determines the mixing time, and there are many known bounds for this. Maybe see a review here. So if your Markov chain is reversible, it is likely easier to study its convergence rates. There is also some work that has been done for non-reversible Markov chains (see this), but the literature is not as rich. This is some more discussion on this in Mathoverflow. Overall, if you don't have a need to study the exact convergence rate for your sampler, and your distribution is well behaved enough that it has larger than 2 moments for most functions of interest, then there should be no reason to restrict yourself to just reversible Markov chains. This is part of the reason why fixed-scan Gibbs sampler are so often used; in practice nothing is lost.
Reversibility in MCMC
I am interpreting your question as much more general in that "Is there any gain to using a reversible Markov chain over a non-reversible Markov chain?". Here are two reasons I can think of off the top
Reversibility in MCMC I am interpreting your question as much more general in that "Is there any gain to using a reversible Markov chain over a non-reversible Markov chain?". Here are two reasons I can think of off the top of my head: Standard errors: If the chain is reversible, then a Markov chain CLT can hold for geometrically ergodic Markov chains while assuming only a finite second moment. If the chain is not reversible, then you have to assume $2 + \delta$ for $\delta > 0$ finite moments. So if you are estimating the posterior mean, and have only two finite moments available, then only a nonreversible Markov chain might not allow analysis of standard errors. You can find more information here. Spectral Gap: Often analysis of the convergence rates of MCMC samplers is done by looking at the spectral gap of the Markov chain. For a reversible Markov chain, the second largest eigenvalue determines the mixing time, and there are many known bounds for this. Maybe see a review here. So if your Markov chain is reversible, it is likely easier to study its convergence rates. There is also some work that has been done for non-reversible Markov chains (see this), but the literature is not as rich. This is some more discussion on this in Mathoverflow. Overall, if you don't have a need to study the exact convergence rate for your sampler, and your distribution is well behaved enough that it has larger than 2 moments for most functions of interest, then there should be no reason to restrict yourself to just reversible Markov chains. This is part of the reason why fixed-scan Gibbs sampler are so often used; in practice nothing is lost.
Reversibility in MCMC I am interpreting your question as much more general in that "Is there any gain to using a reversible Markov chain over a non-reversible Markov chain?". Here are two reasons I can think of off the top
47,212
Should standardization be done using leave-one-out?
If the goal is to standardize the data set (mean center and measure distance from the mean in standard deviation units), then the leave-one-out (LOO) approach simply is not correct. This can be best seen with a simple data set (with an outlier, to exaggerate the point). $$\{47.5,50.7,55.7,58,42.1,51.8,40.8,39.9,45.6,95\}$$ If you convert to standardized ($z$) scores, then you obtain a new data set with a mean of zero and a standard deviation of one. If, on the other hand, you Studentize (standardize with LOO) the scores, you obtain a data set with a mean of 0.437±2.417. Thus, you have failed to "standardize" the data set. Now, if there is a broader goal that you are attempting to achieve via standardizing the data set, then it may be the case that you want to studentize. For example, if you wish to assess to what degree the outlier in the data set above is actually "not following the pattern" of the rest of the data, the standardized value is $z_{(10)}=2.63$ but the studentized value is $z_{(10)}=7.22$. Note, one might argue that the outlier is so extreme that either approach should flag it. However, if you have multiple outliers, this may not always be the case (particularly if they occur on both ends of the distribution). To see this, you can change the first value to $x_{(1)} = 97.5$ to see how you might miss outliers with standardized scores. You can also change the first value to $x_{(1)}=7.5$ to see how you might be able to detect more extreme trends away from "the rest of the data".
Should standardization be done using leave-one-out?
If the goal is to standardize the data set (mean center and measure distance from the mean in standard deviation units), then the leave-one-out (LOO) approach simply is not correct. This can be best
Should standardization be done using leave-one-out? If the goal is to standardize the data set (mean center and measure distance from the mean in standard deviation units), then the leave-one-out (LOO) approach simply is not correct. This can be best seen with a simple data set (with an outlier, to exaggerate the point). $$\{47.5,50.7,55.7,58,42.1,51.8,40.8,39.9,45.6,95\}$$ If you convert to standardized ($z$) scores, then you obtain a new data set with a mean of zero and a standard deviation of one. If, on the other hand, you Studentize (standardize with LOO) the scores, you obtain a data set with a mean of 0.437±2.417. Thus, you have failed to "standardize" the data set. Now, if there is a broader goal that you are attempting to achieve via standardizing the data set, then it may be the case that you want to studentize. For example, if you wish to assess to what degree the outlier in the data set above is actually "not following the pattern" of the rest of the data, the standardized value is $z_{(10)}=2.63$ but the studentized value is $z_{(10)}=7.22$. Note, one might argue that the outlier is so extreme that either approach should flag it. However, if you have multiple outliers, this may not always be the case (particularly if they occur on both ends of the distribution). To see this, you can change the first value to $x_{(1)} = 97.5$ to see how you might miss outliers with standardized scores. You can also change the first value to $x_{(1)}=7.5$ to see how you might be able to detect more extreme trends away from "the rest of the data".
Should standardization be done using leave-one-out? If the goal is to standardize the data set (mean center and measure distance from the mean in standard deviation units), then the leave-one-out (LOO) approach simply is not correct. This can be best
47,213
Should standardization be done using leave-one-out?
Given that you used the term leave-one-out, I think what is implied by the question is that you want to do a LOO cross-validation. That is, you want to train on n-1 examples and test your model on the remaining example. In that case, being very methodologically strict, you are correct. The standardization is performed only on the training set, in this case, the n-1 examples. The for the test example, you subtract the mean of the training set and divide by the standard deviation of the training set. This will true for any cross-validation you choose. Standardization is part of the model you are creating, and you learn the standardization using only the training set, as you learn any other parameters using only the training set. And you apply the model on the test set. In practice, almost never you need to be so strict. You can learn the standardization parameters (mean and standard deviation) on the whole set, and only then use the cross-validation. What is the consequence of doing this? What is happening is that once you define the cross-validation, you are using some information of the test set (its contribution to the general mean and standard deviation) in the training. That will usually result in a cross-validation measurement that is somewhat optimistic. If you are measuring X and the higher the X the better, using some information of the test set in learning step will result in a higher X measured on the test set that the "true" one. If your final goal is to report the X itself, then your measurement will be a little bit inflated. This will be worse if you have few data points. But if your goal is to use the measure X to select among different models, then most likely the inflated X will be "the same" for all the models, and the order will be preserved, or, at least, most likely the best model will be the same in both cases. Again this will be more likely the more data you have. To summarize, if you have a lot of data, do not worry, perform the standardization on the whole data set. If you have little data (and that will be a good reason to use LOO instead of other cross-validation schemes) then do perform the standardization as you described.
Should standardization be done using leave-one-out?
Given that you used the term leave-one-out, I think what is implied by the question is that you want to do a LOO cross-validation. That is, you want to train on n-1 examples and test your model on the
Should standardization be done using leave-one-out? Given that you used the term leave-one-out, I think what is implied by the question is that you want to do a LOO cross-validation. That is, you want to train on n-1 examples and test your model on the remaining example. In that case, being very methodologically strict, you are correct. The standardization is performed only on the training set, in this case, the n-1 examples. The for the test example, you subtract the mean of the training set and divide by the standard deviation of the training set. This will true for any cross-validation you choose. Standardization is part of the model you are creating, and you learn the standardization using only the training set, as you learn any other parameters using only the training set. And you apply the model on the test set. In practice, almost never you need to be so strict. You can learn the standardization parameters (mean and standard deviation) on the whole set, and only then use the cross-validation. What is the consequence of doing this? What is happening is that once you define the cross-validation, you are using some information of the test set (its contribution to the general mean and standard deviation) in the training. That will usually result in a cross-validation measurement that is somewhat optimistic. If you are measuring X and the higher the X the better, using some information of the test set in learning step will result in a higher X measured on the test set that the "true" one. If your final goal is to report the X itself, then your measurement will be a little bit inflated. This will be worse if you have few data points. But if your goal is to use the measure X to select among different models, then most likely the inflated X will be "the same" for all the models, and the order will be preserved, or, at least, most likely the best model will be the same in both cases. Again this will be more likely the more data you have. To summarize, if you have a lot of data, do not worry, perform the standardization on the whole data set. If you have little data (and that will be a good reason to use LOO instead of other cross-validation schemes) then do perform the standardization as you described.
Should standardization be done using leave-one-out? Given that you used the term leave-one-out, I think what is implied by the question is that you want to do a LOO cross-validation. That is, you want to train on n-1 examples and test your model on the
47,214
Constrained optimization algorithm in linear regression
The so-called local linear approximation (LLA) algorithm described in One-step sparse estimates in nonconcave penalized likelihood models by Zou and Li solves the optimization problem for certain concave choices of $f$. Specifically, for $$f(s) = p(|s|)$$ and a concave function $p : [0,\infty) \to [0,\infty)$, which is differentiable on $(0,\infty)$. The algorithm works by iteratively solving a weighted $\ell_1$-penalized optimization problem. In iteration $k+1$ the solution is given as $$\arg \min \sum_{i=1}^n (y_i - x_i^T \beta)^2 + \lambda \sum_{j=1}^p p'(|\beta_j^{(k)}|) |\beta_j|.$$ Each iteration can be solved using e.g. glmnet or lars in R or another standard implementation that computes the lasso solution and allows for weights. The algorithm is an MM-algorithm (it can actually in some cases be interpreted as an EM-algorithm), and it is shown in the paper that it has the descent property. Precise convergence results are given. The paper does, by the way, advocate a one-step estimator, where only one step of the algorithm is taken from the OLS solution. This is computationally cheaper but statistically as efficient as running the algorithm until convergence.
Constrained optimization algorithm in linear regression
The so-called local linear approximation (LLA) algorithm described in One-step sparse estimates in nonconcave penalized likelihood models by Zou and Li solves the optimization problem for certain conc
Constrained optimization algorithm in linear regression The so-called local linear approximation (LLA) algorithm described in One-step sparse estimates in nonconcave penalized likelihood models by Zou and Li solves the optimization problem for certain concave choices of $f$. Specifically, for $$f(s) = p(|s|)$$ and a concave function $p : [0,\infty) \to [0,\infty)$, which is differentiable on $(0,\infty)$. The algorithm works by iteratively solving a weighted $\ell_1$-penalized optimization problem. In iteration $k+1$ the solution is given as $$\arg \min \sum_{i=1}^n (y_i - x_i^T \beta)^2 + \lambda \sum_{j=1}^p p'(|\beta_j^{(k)}|) |\beta_j|.$$ Each iteration can be solved using e.g. glmnet or lars in R or another standard implementation that computes the lasso solution and allows for weights. The algorithm is an MM-algorithm (it can actually in some cases be interpreted as an EM-algorithm), and it is shown in the paper that it has the descent property. Precise convergence results are given. The paper does, by the way, advocate a one-step estimator, where only one step of the algorithm is taken from the OLS solution. This is computationally cheaper but statistically as efficient as running the algorithm until convergence.
Constrained optimization algorithm in linear regression The so-called local linear approximation (LLA) algorithm described in One-step sparse estimates in nonconcave penalized likelihood models by Zou and Li solves the optimization problem for certain conc
47,215
What's the difference between concordance correlation and intraclass correlation?
The modern definition of intraclass correlation (ICC) is a biased estimate of the fraction of the total variance that is due to variation between groups as pertains to the framework of analysis of variance (ANOVA), and random effects models. What would we use this for? An intraclass correlation (ICC) can be a useful estimate of inter-rater reliability on quantitative data because it is highly flexible. A Pearson correlation can be a valid estimator of interrater reliability, but only when you have meaningful pairings between two and only two raters. What if you have more? What if your raters differ by ratee? This is where ICC comes in (note that if you have qualitative data, e.g. categorical data or ranks, you would not use ICC). Lin's concordance correlation coefficient (CCC) measures agreement between two variables as a departure from perfect linearity of the $y=x$ type. $\rho_c = 1 - \frac{{\rm Expected\ orthogonal\ squared\ distance\ from\ the\ diagonal\ }x=y} {{\rm Expected\ orthogonal\ squared\ distance\ from\ the\ diagonal\ }x=y{\rm \ assuming\ independence}}$ CCC is also an inter-rater measurement called an "agreement concordance" rather than an inter-rater "reliability". However, numerically, ICC and CCC can be quite close, sometimes differing in the third decimal place. One notable difference between ICC and CCC is that CCC can also be used in ordinal (whole number) or nominal scales (named categories), and ICC cannot. However, ICC can be used for more than two raters, and CCC cannot.
What's the difference between concordance correlation and intraclass correlation?
The modern definition of intraclass correlation (ICC) is a biased estimate of the fraction of the total variance that is due to variation between groups as pertains to the framework of analysis of var
What's the difference between concordance correlation and intraclass correlation? The modern definition of intraclass correlation (ICC) is a biased estimate of the fraction of the total variance that is due to variation between groups as pertains to the framework of analysis of variance (ANOVA), and random effects models. What would we use this for? An intraclass correlation (ICC) can be a useful estimate of inter-rater reliability on quantitative data because it is highly flexible. A Pearson correlation can be a valid estimator of interrater reliability, but only when you have meaningful pairings between two and only two raters. What if you have more? What if your raters differ by ratee? This is where ICC comes in (note that if you have qualitative data, e.g. categorical data or ranks, you would not use ICC). Lin's concordance correlation coefficient (CCC) measures agreement between two variables as a departure from perfect linearity of the $y=x$ type. $\rho_c = 1 - \frac{{\rm Expected\ orthogonal\ squared\ distance\ from\ the\ diagonal\ }x=y} {{\rm Expected\ orthogonal\ squared\ distance\ from\ the\ diagonal\ }x=y{\rm \ assuming\ independence}}$ CCC is also an inter-rater measurement called an "agreement concordance" rather than an inter-rater "reliability". However, numerically, ICC and CCC can be quite close, sometimes differing in the third decimal place. One notable difference between ICC and CCC is that CCC can also be used in ordinal (whole number) or nominal scales (named categories), and ICC cannot. However, ICC can be used for more than two raters, and CCC cannot.
What's the difference between concordance correlation and intraclass correlation? The modern definition of intraclass correlation (ICC) is a biased estimate of the fraction of the total variance that is due to variation between groups as pertains to the framework of analysis of var
47,216
Is there a non-boostrap way to estimate confidence intervals for Kernel regression predictions?
Under non-fixed-design $x$'s, [Härdle][1] (p136) gives an asymptotic distributional approximation relating to the Nadaraya-Watson estimator $\hat{m}(x_j)$: $(nh)^\frac12 \frac{\hat{m}_h(x_j)-m(x_j)}{V(x_j)^\frac12} \stackrel{.}{\sim} N(B(x_j),1)$ where $V(x_j) = \sigma^2(x_j)||K||_2^2/f(x_j)$ and $B(x_j) = \mu_2(K)[m''(x_j)+2m'(x_j)f'(x_j)/f(x_j)]$, with $\sigma^2(x_j)$ being the conditional noise variance, $f(x_j)$ being the density of $X$ at $x_j$, $||K||_2^2 = \int K^2(u) du$, $\mu_2(K) = \int u^2 K(u) du$. (Actually he gives the multivariate distribution over $k$ different locations but since you seem to only need it pointwise, I believe the univariate case suffices) Note that $V$ is the variance of the estimate of $m$. The approximate predictive variance would then add the observation noise variance $\sigma^2(x_j)$ to give $V^p(x_j)=\sigma^2(x_j)+V(x_j)$. The MSPE at $x_j$ is the sum of the variance and the square of the bias, so an asymptotic approximation for that is $V^p(x_j)+B(x_j)^2$. The bias term, $B$ involves derivatives of both $m$ and $f$ and so is somewhat complicated to evaluate/estimate (but should be doable, nonetheless). Some people make the assumption that $B$ is small relative to the variance and ignore it; this would give a lower bound on the prediction error variance. Härdle gives estimators for $\sigma^2(x)$ and $f(x)$ based on NW-kernel regression from the squared error and kernel density estimation respectively (all using the same bandwidth) and he gives tables for $\mu_2(K)$ and $||K||_2^2$ on p220 (the kernels themselves are defined on p45). For the Gaussian case $\mu_2(K)=1$ and $||K||_2^2=\frac{1}{2\sqrt{\pi}}$. [1]: Härdle, W. (1991), Smoothing Techniques - With Implementation in S, Springer Series in Statistics, Springer-Verlag New York
Is there a non-boostrap way to estimate confidence intervals for Kernel regression predictions?
Under non-fixed-design $x$'s, [Härdle][1] (p136) gives an asymptotic distributional approximation relating to the Nadaraya-Watson estimator $\hat{m}(x_j)$: $(nh)^\frac12 \frac{\hat{m}_h(x_j)-m(x_j)}{V
Is there a non-boostrap way to estimate confidence intervals for Kernel regression predictions? Under non-fixed-design $x$'s, [Härdle][1] (p136) gives an asymptotic distributional approximation relating to the Nadaraya-Watson estimator $\hat{m}(x_j)$: $(nh)^\frac12 \frac{\hat{m}_h(x_j)-m(x_j)}{V(x_j)^\frac12} \stackrel{.}{\sim} N(B(x_j),1)$ where $V(x_j) = \sigma^2(x_j)||K||_2^2/f(x_j)$ and $B(x_j) = \mu_2(K)[m''(x_j)+2m'(x_j)f'(x_j)/f(x_j)]$, with $\sigma^2(x_j)$ being the conditional noise variance, $f(x_j)$ being the density of $X$ at $x_j$, $||K||_2^2 = \int K^2(u) du$, $\mu_2(K) = \int u^2 K(u) du$. (Actually he gives the multivariate distribution over $k$ different locations but since you seem to only need it pointwise, I believe the univariate case suffices) Note that $V$ is the variance of the estimate of $m$. The approximate predictive variance would then add the observation noise variance $\sigma^2(x_j)$ to give $V^p(x_j)=\sigma^2(x_j)+V(x_j)$. The MSPE at $x_j$ is the sum of the variance and the square of the bias, so an asymptotic approximation for that is $V^p(x_j)+B(x_j)^2$. The bias term, $B$ involves derivatives of both $m$ and $f$ and so is somewhat complicated to evaluate/estimate (but should be doable, nonetheless). Some people make the assumption that $B$ is small relative to the variance and ignore it; this would give a lower bound on the prediction error variance. Härdle gives estimators for $\sigma^2(x)$ and $f(x)$ based on NW-kernel regression from the squared error and kernel density estimation respectively (all using the same bandwidth) and he gives tables for $\mu_2(K)$ and $||K||_2^2$ on p220 (the kernels themselves are defined on p45). For the Gaussian case $\mu_2(K)=1$ and $||K||_2^2=\frac{1}{2\sqrt{\pi}}$. [1]: Härdle, W. (1991), Smoothing Techniques - With Implementation in S, Springer Series in Statistics, Springer-Verlag New York
Is there a non-boostrap way to estimate confidence intervals for Kernel regression predictions? Under non-fixed-design $x$'s, [Härdle][1] (p136) gives an asymptotic distributional approximation relating to the Nadaraya-Watson estimator $\hat{m}(x_j)$: $(nh)^\frac12 \frac{\hat{m}_h(x_j)-m(x_j)}{V
47,217
Time series and instrumental variables
Consider a series $Y_t$ generated as an $ARMA(1,1)$ process $$ Y_t=\phi Y_{t-1}+\epsilon_t+\theta\epsilon_{t-1} $$ Suppose our interest centers on estimating $\phi$. We have an endogeneity issue here, as the error term $\epsilon_t+\theta\epsilon_{t-1}$ is correlated with the regressor $Y_{t-1}$, so OLS of $Y_{t}$ on $Y_{t-1}$ would not consistently estimate $\phi$: $$ \hat{\phi}_{OLS}=\frac{\sum_tY_{t-1}Y_{t}}{\sum_tY_{t-1}^2}=\frac{\frac{1}{T}\sum_tY_{t-1}Y_{t}}{\frac{1}{T}\sum_tY_{t-1}^2}\to_p\frac{\gamma_1}{\gamma_0}, $$ where the convergence in probability follows from standard arguments about plims of $\frac{1}{T}\sum_tY_{t-j}Y_{t-l}$ and the continuous mapping theorem. Now, it is known that $\gamma_0=\sigma^2\frac{1+\theta^2+2\phi\theta}{1-\phi^2}$ and $\gamma_1=\sigma^2\frac{(\phi+\theta)(1+\phi\theta)}{1-\phi^2}$. Hence, \begin{eqnarray*} \hat{\phi}&\to_p&\frac{\sigma^2\frac{(\phi+\theta)(1+\phi\theta)}{1-\phi^2}}{\sigma^2\frac{1+\theta^2+2\phi\theta}{1-\phi^2}}\\ &=&\frac{(\phi+\theta)(1+\phi\theta)}{1+\theta^2+2\phi\theta}\neq\phi, \end{eqnarray*} unless the process is an $AR(1)$, i.e. unless $\theta=0$. Instrumental variables estimation of $\phi$ using $Y_{t-2}$ as an instrument for $Y_{t-1}$, in turn, is consistent for $\phi$: the IV estimator is $$ \hat{\phi}_{IV}=\frac{\sum_tY_{t-2}Y_{t}}{\sum_tY_{t-2}Y_{t-1}}=\frac{\frac{1}{T}\sum_tY_{t-2}Y_{t}}{\frac{1}{T}\sum_tY_{t-2}Y_{t-1}}\to_p\frac{\gamma_2}{\gamma_1} $$ We furthermore know that the autocovariance function of an $ARMA(1,1)$ is such that $\gamma_2=\phi\gamma_1$. Hence, $$\hat{\phi}_{IV}\to_p\phi$$ This works because the error term in this IV model, $\epsilon_t+\theta\epsilon_{t-1}$, is uncorrelated with the instrument, which itself is correlated with the regressor $Y_{t-1}$ due to the autoregressive structure of the process. While this simple example (and I think simple examples are useful) shows how to use instruments in time series analysis, it is somewhat artificial in that if one knew that the process is $ARMA(1,1)$ one could estimate such a process directly. And it is somewhat fragile in that if the process were $ARMA(1,2)$, $Y_{t-2}$ would no longer be a valid instrument, as it would now be correlated with the new error $\epsilon_t+\theta_1\epsilon_{t-1}+\theta_2\epsilon_{t-2}$.
Time series and instrumental variables
Consider a series $Y_t$ generated as an $ARMA(1,1)$ process $$ Y_t=\phi Y_{t-1}+\epsilon_t+\theta\epsilon_{t-1} $$ Suppose our interest centers on estimating $\phi$. We have an endogeneity issue here,
Time series and instrumental variables Consider a series $Y_t$ generated as an $ARMA(1,1)$ process $$ Y_t=\phi Y_{t-1}+\epsilon_t+\theta\epsilon_{t-1} $$ Suppose our interest centers on estimating $\phi$. We have an endogeneity issue here, as the error term $\epsilon_t+\theta\epsilon_{t-1}$ is correlated with the regressor $Y_{t-1}$, so OLS of $Y_{t}$ on $Y_{t-1}$ would not consistently estimate $\phi$: $$ \hat{\phi}_{OLS}=\frac{\sum_tY_{t-1}Y_{t}}{\sum_tY_{t-1}^2}=\frac{\frac{1}{T}\sum_tY_{t-1}Y_{t}}{\frac{1}{T}\sum_tY_{t-1}^2}\to_p\frac{\gamma_1}{\gamma_0}, $$ where the convergence in probability follows from standard arguments about plims of $\frac{1}{T}\sum_tY_{t-j}Y_{t-l}$ and the continuous mapping theorem. Now, it is known that $\gamma_0=\sigma^2\frac{1+\theta^2+2\phi\theta}{1-\phi^2}$ and $\gamma_1=\sigma^2\frac{(\phi+\theta)(1+\phi\theta)}{1-\phi^2}$. Hence, \begin{eqnarray*} \hat{\phi}&\to_p&\frac{\sigma^2\frac{(\phi+\theta)(1+\phi\theta)}{1-\phi^2}}{\sigma^2\frac{1+\theta^2+2\phi\theta}{1-\phi^2}}\\ &=&\frac{(\phi+\theta)(1+\phi\theta)}{1+\theta^2+2\phi\theta}\neq\phi, \end{eqnarray*} unless the process is an $AR(1)$, i.e. unless $\theta=0$. Instrumental variables estimation of $\phi$ using $Y_{t-2}$ as an instrument for $Y_{t-1}$, in turn, is consistent for $\phi$: the IV estimator is $$ \hat{\phi}_{IV}=\frac{\sum_tY_{t-2}Y_{t}}{\sum_tY_{t-2}Y_{t-1}}=\frac{\frac{1}{T}\sum_tY_{t-2}Y_{t}}{\frac{1}{T}\sum_tY_{t-2}Y_{t-1}}\to_p\frac{\gamma_2}{\gamma_1} $$ We furthermore know that the autocovariance function of an $ARMA(1,1)$ is such that $\gamma_2=\phi\gamma_1$. Hence, $$\hat{\phi}_{IV}\to_p\phi$$ This works because the error term in this IV model, $\epsilon_t+\theta\epsilon_{t-1}$, is uncorrelated with the instrument, which itself is correlated with the regressor $Y_{t-1}$ due to the autoregressive structure of the process. While this simple example (and I think simple examples are useful) shows how to use instruments in time series analysis, it is somewhat artificial in that if one knew that the process is $ARMA(1,1)$ one could estimate such a process directly. And it is somewhat fragile in that if the process were $ARMA(1,2)$, $Y_{t-2}$ would no longer be a valid instrument, as it would now be correlated with the new error $\epsilon_t+\theta_1\epsilon_{t-1}+\theta_2\epsilon_{t-2}$.
Time series and instrumental variables Consider a series $Y_t$ generated as an $ARMA(1,1)$ process $$ Y_t=\phi Y_{t-1}+\epsilon_t+\theta\epsilon_{t-1} $$ Suppose our interest centers on estimating $\phi$. We have an endogeneity issue here,
47,218
Optimize starting parameters for Bayesian Linear Regression?
I'll illustrate my answer with a simple example. Imagine that your data $X_1,\dots,X_n$ are counts that follow a Poisson distribution. Poisson distributtion is described using a single parameter $\lambda$ that we want to estimate given the data we have. To set up a Bayesian model we use Bayes theorem $$ \underbrace{p(\lambda| X)}_{\text{posterior}} \propto \underbrace{p(X | \lambda)}_{\text{likelihood}} \underbrace{p(\lambda)}_{\text{prior}} $$ where we define likelihood function as a Poisson distributtion parametrized by $\lambda$ and we use as a prior another Poisson distributtion parametrized using hyperparameter $\theta$: $$X_i \sim \mathrm{Poisson}(\lambda) \\ \lambda \sim \mathrm{Poisson}(\theta) $$ Your question is basically about how to find "optimal" $\theta$. Recall that Poisson's distributions parameter is also it's mean. It's maximum likelihood estimator is sample mean, so the "optimal" value for $\theta$ after looking at the data would be to use sample mean. If you did so, than what you would be calculating is given that prior mean is $\theta$ find the optimal value of $\lambda$ such that it maximizes the likelihood -- can you see the circularity? $\theta$ is already an optimal value given the data we have and then we use it to find the optimal value... In such case wouldn't maximum likelihood estimation be more honest way to go? To learn more about choosing priors check How to choose prior in Bayesian parameter estimation that goes into more details about choosing informative priors, i.e. priors based on some knowledge that we had before seeing the data. If we don't have such information, we use weekly informative priors that say very little about what we assume about the parameter of interest (e.g. uniform distribution over some reasonable range). Finally, if you have no ideas about the parameters of your priors you can use hyper-priors, i.e. priors for parameters of priors, and then the Bayesian machinery will find the "optimal" parameters for priors for you (but yes, you need to decide about the values of hyperpriors and this is not always that obvious). Finally, there is an approach called empirical Bayesian method, but as you can see from the example, the risk in here is that we can end up with estimates that are overconfident since we used the same data twice. Check "Bayesian Data Analysis" by Andrew Gelman, John Carlin, Hal Stern, David Dunson, Aki Vehtari, and Donald Rubin for great introduction and multiple examples about choosing priors. "Doing Bayesian Data Analysis" by John K. Kruschke provides nice introduction about hierarchical models and hyperpriors. Finally, "Data Analysis: A Bayesian Tutorial" by Devinderjit Sivia and John Skilling give some discussion about "using the same data twice".
Optimize starting parameters for Bayesian Linear Regression?
I'll illustrate my answer with a simple example. Imagine that your data $X_1,\dots,X_n$ are counts that follow a Poisson distribution. Poisson distributtion is described using a single parameter $\lam
Optimize starting parameters for Bayesian Linear Regression? I'll illustrate my answer with a simple example. Imagine that your data $X_1,\dots,X_n$ are counts that follow a Poisson distribution. Poisson distributtion is described using a single parameter $\lambda$ that we want to estimate given the data we have. To set up a Bayesian model we use Bayes theorem $$ \underbrace{p(\lambda| X)}_{\text{posterior}} \propto \underbrace{p(X | \lambda)}_{\text{likelihood}} \underbrace{p(\lambda)}_{\text{prior}} $$ where we define likelihood function as a Poisson distributtion parametrized by $\lambda$ and we use as a prior another Poisson distributtion parametrized using hyperparameter $\theta$: $$X_i \sim \mathrm{Poisson}(\lambda) \\ \lambda \sim \mathrm{Poisson}(\theta) $$ Your question is basically about how to find "optimal" $\theta$. Recall that Poisson's distributions parameter is also it's mean. It's maximum likelihood estimator is sample mean, so the "optimal" value for $\theta$ after looking at the data would be to use sample mean. If you did so, than what you would be calculating is given that prior mean is $\theta$ find the optimal value of $\lambda$ such that it maximizes the likelihood -- can you see the circularity? $\theta$ is already an optimal value given the data we have and then we use it to find the optimal value... In such case wouldn't maximum likelihood estimation be more honest way to go? To learn more about choosing priors check How to choose prior in Bayesian parameter estimation that goes into more details about choosing informative priors, i.e. priors based on some knowledge that we had before seeing the data. If we don't have such information, we use weekly informative priors that say very little about what we assume about the parameter of interest (e.g. uniform distribution over some reasonable range). Finally, if you have no ideas about the parameters of your priors you can use hyper-priors, i.e. priors for parameters of priors, and then the Bayesian machinery will find the "optimal" parameters for priors for you (but yes, you need to decide about the values of hyperpriors and this is not always that obvious). Finally, there is an approach called empirical Bayesian method, but as you can see from the example, the risk in here is that we can end up with estimates that are overconfident since we used the same data twice. Check "Bayesian Data Analysis" by Andrew Gelman, John Carlin, Hal Stern, David Dunson, Aki Vehtari, and Donald Rubin for great introduction and multiple examples about choosing priors. "Doing Bayesian Data Analysis" by John K. Kruschke provides nice introduction about hierarchical models and hyperpriors. Finally, "Data Analysis: A Bayesian Tutorial" by Devinderjit Sivia and John Skilling give some discussion about "using the same data twice".
Optimize starting parameters for Bayesian Linear Regression? I'll illustrate my answer with a simple example. Imagine that your data $X_1,\dots,X_n$ are counts that follow a Poisson distribution. Poisson distributtion is described using a single parameter $\lam
47,219
Optimize starting parameters for Bayesian Linear Regression?
Intuitively, the one on the left seems to give you unreasonably large coefficients. To be more quantitative, you can do model comparison. Cross-validation is one way to compare them, but there exist various other measures that estimate the result you would get in a cross-validation. PyMC3 has various model comparison measures, including DIC, WAIC and LOO: http://pymc-devs.github.io/pymc3/api.html#pymc3.stats.loo
Optimize starting parameters for Bayesian Linear Regression?
Intuitively, the one on the left seems to give you unreasonably large coefficients. To be more quantitative, you can do model comparison. Cross-validation is one way to compare them, but there exist v
Optimize starting parameters for Bayesian Linear Regression? Intuitively, the one on the left seems to give you unreasonably large coefficients. To be more quantitative, you can do model comparison. Cross-validation is one way to compare them, but there exist various other measures that estimate the result you would get in a cross-validation. PyMC3 has various model comparison measures, including DIC, WAIC and LOO: http://pymc-devs.github.io/pymc3/api.html#pymc3.stats.loo
Optimize starting parameters for Bayesian Linear Regression? Intuitively, the one on the left seems to give you unreasonably large coefficients. To be more quantitative, you can do model comparison. Cross-validation is one way to compare them, but there exist v
47,220
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$?
Since the wikipedia article https://en.wikipedia.org/wiki/Fisher_information do not contain a proof, I will write one here. Let $X_1, X_2, \dotsc, X_n$ be independent random variables with density function $f(x;\theta)$ (which might in addition depend on known covariates, so this covers more than the iid case). Then the loglikelihood function is $$ \ell(\theta) = \sum_i \log f(X_i;\theta) $$ and the score function is $$ s(\theta) = \frac{\partial \ell(\theta)}{\partial \theta}= \sum_i\frac{\partial}{\partial\theta}\log f(X;\theta) $$ The Fisher information matrix then can be written $$ \DeclareMathOperator{\E}{\mathbb{E}} I(\theta) = \E\left[\sum_i \left( \frac{\partial}{\partial\theta}\log f(X_i;\theta) \right)\left( \frac{\partial}{\partial\theta}\log f(X_i;\theta) \right)^T \mid \theta\right] $$ and now the result follows by moving the summation sign outside the expectation operator, which shows that $I(\theta)=\sum_i I_i(\theta)$ where $I_i(\theta)$ is the Fisher information from variable $X_i$. In the iid case that becomes $I(\theta)=n I_1(\theta)$.
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1
Since the wikipedia article https://en.wikipedia.org/wiki/Fisher_information do not contain a proof, I will write one here. Let $X_1, X_2, \dotsc, X_n$ be independent random variables with density fu
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$? Since the wikipedia article https://en.wikipedia.org/wiki/Fisher_information do not contain a proof, I will write one here. Let $X_1, X_2, \dotsc, X_n$ be independent random variables with density function $f(x;\theta)$ (which might in addition depend on known covariates, so this covers more than the iid case). Then the loglikelihood function is $$ \ell(\theta) = \sum_i \log f(X_i;\theta) $$ and the score function is $$ s(\theta) = \frac{\partial \ell(\theta)}{\partial \theta}= \sum_i\frac{\partial}{\partial\theta}\log f(X;\theta) $$ The Fisher information matrix then can be written $$ \DeclareMathOperator{\E}{\mathbb{E}} I(\theta) = \E\left[\sum_i \left( \frac{\partial}{\partial\theta}\log f(X_i;\theta) \right)\left( \frac{\partial}{\partial\theta}\log f(X_i;\theta) \right)^T \mid \theta\right] $$ and now the result follows by moving the summation sign outside the expectation operator, which shows that $I(\theta)=\sum_i I_i(\theta)$ where $I_i(\theta)$ is the Fisher information from variable $X_i$. In the iid case that becomes $I(\theta)=n I_1(\theta)$.
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1 Since the wikipedia article https://en.wikipedia.org/wiki/Fisher_information do not contain a proof, I will write one here. Let $X_1, X_2, \dotsc, X_n$ be independent random variables with density fu
47,221
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$?
Let $X$ be a random variable with probability density function $f(x;\theta)$. Assume that the observations $x_1,\ldots,x_n$ are independent realizations of $X$. Let us prove that the Fisher matrix is: \begin{align} I(\theta) = n I_1(\theta) \end{align} where $I_1(\theta)$ is the Fisher matrix for one single observation: \begin{align} I_1(\theta)_{jk} = \mathbb{E}\left[\left(\frac{\partial \log(f(X_1 ; \theta))}{\partial \theta_j}\right) \left(\frac{\partial \log(f(X_1 ; \theta))}{\partial \theta_k}\right)\right] \end{align} for any $j,k=1,\ldots, m$ and any $\theta \in \mathbb{R}^m$. Since the observations are independent and have the same PDF, the log-likelihood is: \begin{align} \ell(\theta) = \sum_{i=1}^n \log(f(x_i;\theta)) \end{align} for any $\theta\in\mathbb{R}^m$. Let $s$ be the score, defined as the gradient of the log-likelihood: \begin{align} s(\theta) = \frac{\partial \ell(\theta)}{\partial \theta} \end{align} for any $\theta\in\mathbb{R}^m$. Indeed, for any $j,k=1,\ldots, m$, the equation $\mathbb{E}(s(\theta)) = 0$ implies: \begin{align*} I(\theta)_{jk} &= \textbf{Cov}(s(\theta)_j, s(\theta_k)) \\ &= \textbf{Cov}\left(\frac{\partial \ell(\theta)}{\partial \theta_j}, \frac{\partial \ell(\theta)}{\partial \theta_k}\right). \end{align*} The independence of the realizations implies: \begin{align*} I(\theta)_{jk} &= \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \sum_{i_1=1}^n \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \sum_{i_2=1}^n \log(f(X_{i_2};\theta))\right) \\ &= \textbf{Cov}\left(\sum_{i_1=1}^n \frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \sum_{i_2=1}^n \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right) \\ &= \sum_{i_1=1}^n \sum_{i_2=1}^n \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right), \end{align*} for any $j,k=1,\ldots, m$, where the last equation uses the linearity properties of the covariance. However, the observations are independent, therefore, $$ \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right) = 0 $$ if $i_1 \neq i_2$. Hence, \begin{align*} I(\theta)_{jk} &= \sum_{i=1}^n \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_i;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_i;\theta))\right). \end{align*} Moreover, since all the observations have the same distribution, \begin{align*} &\textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_i;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_i;\theta))\right) \\ &= \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_1;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_1;\theta))\right) \\ &= I_1(\theta) \end{align*} for any $i=1,\ldots, n$. Hence, \begin{align*} I(\theta)_{jk} &= \sum_{i=1}^n I_1(\theta) \end{align*} which concludes the proof.
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1
Let $X$ be a random variable with probability density function $f(x;\theta)$. Assume that the observations $x_1,\ldots,x_n$ are independent realizations of $X$. Let us prove that the Fisher matrix is:
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$? Let $X$ be a random variable with probability density function $f(x;\theta)$. Assume that the observations $x_1,\ldots,x_n$ are independent realizations of $X$. Let us prove that the Fisher matrix is: \begin{align} I(\theta) = n I_1(\theta) \end{align} where $I_1(\theta)$ is the Fisher matrix for one single observation: \begin{align} I_1(\theta)_{jk} = \mathbb{E}\left[\left(\frac{\partial \log(f(X_1 ; \theta))}{\partial \theta_j}\right) \left(\frac{\partial \log(f(X_1 ; \theta))}{\partial \theta_k}\right)\right] \end{align} for any $j,k=1,\ldots, m$ and any $\theta \in \mathbb{R}^m$. Since the observations are independent and have the same PDF, the log-likelihood is: \begin{align} \ell(\theta) = \sum_{i=1}^n \log(f(x_i;\theta)) \end{align} for any $\theta\in\mathbb{R}^m$. Let $s$ be the score, defined as the gradient of the log-likelihood: \begin{align} s(\theta) = \frac{\partial \ell(\theta)}{\partial \theta} \end{align} for any $\theta\in\mathbb{R}^m$. Indeed, for any $j,k=1,\ldots, m$, the equation $\mathbb{E}(s(\theta)) = 0$ implies: \begin{align*} I(\theta)_{jk} &= \textbf{Cov}(s(\theta)_j, s(\theta_k)) \\ &= \textbf{Cov}\left(\frac{\partial \ell(\theta)}{\partial \theta_j}, \frac{\partial \ell(\theta)}{\partial \theta_k}\right). \end{align*} The independence of the realizations implies: \begin{align*} I(\theta)_{jk} &= \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \sum_{i_1=1}^n \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \sum_{i_2=1}^n \log(f(X_{i_2};\theta))\right) \\ &= \textbf{Cov}\left(\sum_{i_1=1}^n \frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \sum_{i_2=1}^n \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right) \\ &= \sum_{i_1=1}^n \sum_{i_2=1}^n \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right), \end{align*} for any $j,k=1,\ldots, m$, where the last equation uses the linearity properties of the covariance. However, the observations are independent, therefore, $$ \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_{i_1};\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_{i_2};\theta))\right) = 0 $$ if $i_1 \neq i_2$. Hence, \begin{align*} I(\theta)_{jk} &= \sum_{i=1}^n \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_i;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_i;\theta))\right). \end{align*} Moreover, since all the observations have the same distribution, \begin{align*} &\textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_i;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_i;\theta))\right) \\ &= \textbf{Cov}\left(\frac{\partial}{\partial \theta_j} \log(f(X_1;\theta)), \frac{\partial}{\partial \theta_k} \log(f(X_1;\theta))\right) \\ &= I_1(\theta) \end{align*} for any $i=1,\ldots, n$. Hence, \begin{align*} I(\theta)_{jk} &= \sum_{i=1}^n I_1(\theta) \end{align*} which concludes the proof.
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1 Let $X$ be a random variable with probability density function $f(x;\theta)$. Assume that the observations $x_1,\ldots,x_n$ are independent realizations of $X$. Let us prove that the Fisher matrix is:
47,222
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$?
The proof by kjetil b halvorsen is incorrect, you missed the cross-terms. The correct equation for the $I(\theta)$ should read something like this: $$ I(\theta) = \mathbb{E}\left[\left(\sum\limits_i\frac{\partial}{\partial\theta}\log f(X_i;\theta)\right)\left(\sum\limits_j\frac{\partial}{\partial\theta}\log f(X_j;\theta)\right)^T | \theta\right] $$
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1
The proof by kjetil b halvorsen is incorrect, you missed the cross-terms. The correct equation for the $I(\theta)$ should read something like this: $$ I(\theta) = \mathbb{E}\left[\left(\sum\limits_i
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1(\theta)$? The proof by kjetil b halvorsen is incorrect, you missed the cross-terms. The correct equation for the $I(\theta)$ should read something like this: $$ I(\theta) = \mathbb{E}\left[\left(\sum\limits_i\frac{\partial}{\partial\theta}\log f(X_i;\theta)\right)\left(\sum\limits_j\frac{\partial}{\partial\theta}\log f(X_j;\theta)\right)^T | \theta\right] $$
For a Fisher Information matrix $I(\theta)$ of multiple variables, is it true that $I(\theta) = nI_1 The proof by kjetil b halvorsen is incorrect, you missed the cross-terms. The correct equation for the $I(\theta)$ should read something like this: $$ I(\theta) = \mathbb{E}\left[\left(\sum\limits_i
47,223
Test for whether two data sets are significantly different
This can be approached like a chi square test of homogeneity. You want to see if there are differences from a theoretical uniform distribution across parks in the counts of snails coming from different populations or groups (colors). The margins of the tabulated data are considered random variables, and used to cross multiply and get the expected counts in each cell. Here is your tabulated data with actual and expected counts: > addmargins(round(snails, 0)) park snails A B C Sum red 800 200 400 1400 blue 100 600 100 800 green 400 50 50 500 Sum 1300 850 550 2700 > addmargins(round(chisq.test(snails)$expected,0)) park snails A B C Sum red 674 441 285 1400 blue 385 252 163 800 green 241 157 102 500 Sum 1300 850 550 2700 The chi square test can be run in R as follows: chisq.test(snails) Pearson's Chi-squared test data: snails X-squared = 1123, df = 4, p-value < 2.2e-16 So there is evidence that the distribution of the different snail types across parks is not homogeneous. Here is some plotting of the results and standardized residuals: Perhaps the most interesting part of your question is to discuss what to do with the results of an omnibus test on a larger than $2 \times 2$ contingency table. On this the jury is still out (amazingly) - on this you can check this very helpful reference. But the residuals, or standardized residuals are a start, and you can find them graphically plotted, and color coded. A lot of conclusions can be drawn from looking at the residuals mosaic plot, and after all, it seems like at least some authors are still condoning some post-chi "eye-balling." On the article I link there are procedures for a more detailed post-hoc analysis of the data. A different approach altogether could be a generalized linear regression model. Here is the interpretation, and the code: snails <- matrix(c(800, 200, 400, 100, 600, 100, 400, 50, 50), nrow = 3, byrow = T) dimnames(snails) = list(snails = c("red", "blue", "green"), park = c("A", "B", "C")) snails addmargins(round(snails, 0)) addmargins(round(chisq.test(snails)$expected,0)) chisq.test(snails) library(vcd) mosaic(snails, shade=TRUE, legend=TRUE)
Test for whether two data sets are significantly different
This can be approached like a chi square test of homogeneity. You want to see if there are differences from a theoretical uniform distribution across parks in the counts of snails coming from differen
Test for whether two data sets are significantly different This can be approached like a chi square test of homogeneity. You want to see if there are differences from a theoretical uniform distribution across parks in the counts of snails coming from different populations or groups (colors). The margins of the tabulated data are considered random variables, and used to cross multiply and get the expected counts in each cell. Here is your tabulated data with actual and expected counts: > addmargins(round(snails, 0)) park snails A B C Sum red 800 200 400 1400 blue 100 600 100 800 green 400 50 50 500 Sum 1300 850 550 2700 > addmargins(round(chisq.test(snails)$expected,0)) park snails A B C Sum red 674 441 285 1400 blue 385 252 163 800 green 241 157 102 500 Sum 1300 850 550 2700 The chi square test can be run in R as follows: chisq.test(snails) Pearson's Chi-squared test data: snails X-squared = 1123, df = 4, p-value < 2.2e-16 So there is evidence that the distribution of the different snail types across parks is not homogeneous. Here is some plotting of the results and standardized residuals: Perhaps the most interesting part of your question is to discuss what to do with the results of an omnibus test on a larger than $2 \times 2$ contingency table. On this the jury is still out (amazingly) - on this you can check this very helpful reference. But the residuals, or standardized residuals are a start, and you can find them graphically plotted, and color coded. A lot of conclusions can be drawn from looking at the residuals mosaic plot, and after all, it seems like at least some authors are still condoning some post-chi "eye-balling." On the article I link there are procedures for a more detailed post-hoc analysis of the data. A different approach altogether could be a generalized linear regression model. Here is the interpretation, and the code: snails <- matrix(c(800, 200, 400, 100, 600, 100, 400, 50, 50), nrow = 3, byrow = T) dimnames(snails) = list(snails = c("red", "blue", "green"), park = c("A", "B", "C")) snails addmargins(round(snails, 0)) addmargins(round(chisq.test(snails)$expected,0)) chisq.test(snails) library(vcd) mosaic(snails, shade=TRUE, legend=TRUE)
Test for whether two data sets are significantly different This can be approached like a chi square test of homogeneity. You want to see if there are differences from a theoretical uniform distribution across parks in the counts of snails coming from differen
47,224
Difference between rulefit and random forest
In fact, RuleFit does excessive pruning on a random forest. It tries to find a set of rules generated by random forest to obtain accuracy as close as possible to the accuracy of random forest while reducing the number of rules tremendously. Finally, it builds a model consisting of simple and short rules which are extracted from random forest and builds a comprehensive and understandable model from random forest which is a black box model. How ? It builds a linear model from random forest rules and using an optimization method (Lasso) finds a sparse weight vector that determines which rules are the most important ones. At the end few rules have non-zero weights and the rest of the rules are removed from the ensemble. There are also similar methods with the same aim such as NodeHarvest, but RuleFit has better performance.
Difference between rulefit and random forest
In fact, RuleFit does excessive pruning on a random forest. It tries to find a set of rules generated by random forest to obtain accuracy as close as possible to the accuracy of random forest while re
Difference between rulefit and random forest In fact, RuleFit does excessive pruning on a random forest. It tries to find a set of rules generated by random forest to obtain accuracy as close as possible to the accuracy of random forest while reducing the number of rules tremendously. Finally, it builds a model consisting of simple and short rules which are extracted from random forest and builds a comprehensive and understandable model from random forest which is a black box model. How ? It builds a linear model from random forest rules and using an optimization method (Lasso) finds a sparse weight vector that determines which rules are the most important ones. At the end few rules have non-zero weights and the rest of the rules are removed from the ensemble. There are also similar methods with the same aim such as NodeHarvest, but RuleFit has better performance.
Difference between rulefit and random forest In fact, RuleFit does excessive pruning on a random forest. It tries to find a set of rules generated by random forest to obtain accuracy as close as possible to the accuracy of random forest while re
47,225
Difference between rulefit and random forest
They differ in their approaches to tree generation and selection of baselearners to retain for the predictive model: RuleFit first generates a boosted decision tree ensemble. That is: It sequentially grows trees on a pseudo response variable, where the pseudo response for each tree is corrected for the predictions of earlier trees. The amount of correction for earlier trees is controlled by the learning rate (.01, by default). For induction of each tree, a random (sub or bootstrap) sample of the training data is selected (same as random forest). After generating the boosted decision tree ensemble, all nodes from all trees in the decision tree ensemble are transformed into dummy coded rule variables (taking a value of 0 if the conditions of the rule do not apply, a value of 1 if they do). The final predictive model is selected through sparse regression on the rule variables and the original predictor variables. A random forest is a decision tree ensemble, in which The trees are not induced sequentially, i.e., the response variable is not corrected for predictions of earlier trees. For every split in every tree, a random subset of mtry predictor variables are selected as potential candidates for the split. For induction of each tree, a random (sub or bootstrap) sample of the training data is selected (same as in boosting and RuleFit). The final predictive model averages over the predictions of each tree in the ensemble. Btw, R package pre also supports fitting prediction rule ensembles using a random-forest-type approach.
Difference between rulefit and random forest
They differ in their approaches to tree generation and selection of baselearners to retain for the predictive model: RuleFit first generates a boosted decision tree ensemble. That is: It sequentially
Difference between rulefit and random forest They differ in their approaches to tree generation and selection of baselearners to retain for the predictive model: RuleFit first generates a boosted decision tree ensemble. That is: It sequentially grows trees on a pseudo response variable, where the pseudo response for each tree is corrected for the predictions of earlier trees. The amount of correction for earlier trees is controlled by the learning rate (.01, by default). For induction of each tree, a random (sub or bootstrap) sample of the training data is selected (same as random forest). After generating the boosted decision tree ensemble, all nodes from all trees in the decision tree ensemble are transformed into dummy coded rule variables (taking a value of 0 if the conditions of the rule do not apply, a value of 1 if they do). The final predictive model is selected through sparse regression on the rule variables and the original predictor variables. A random forest is a decision tree ensemble, in which The trees are not induced sequentially, i.e., the response variable is not corrected for predictions of earlier trees. For every split in every tree, a random subset of mtry predictor variables are selected as potential candidates for the split. For induction of each tree, a random (sub or bootstrap) sample of the training data is selected (same as in boosting and RuleFit). The final predictive model averages over the predictions of each tree in the ensemble. Btw, R package pre also supports fitting prediction rule ensembles using a random-forest-type approach.
Difference between rulefit and random forest They differ in their approaches to tree generation and selection of baselearners to retain for the predictive model: RuleFit first generates a boosted decision tree ensemble. That is: It sequentially
47,226
Overview of predictive modelling, machine learning, etc.
I don't understand this phrase: In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. It doesn't make sense to me, because if I were to build a regression model I would still need to think about my samples and population. I don't understand why I should just plug my sample data into R and hope for the best without any idea my sample is about. The sentence doesn't add anything, it's confusing and technically incorrect. Instead the goal is to simply find an equation or algorithm that makes reasonably correct predictons sounds doggy to me. What do you mean by reasonably correct? Your users are probably not very mathematical (otherwise they wouldn't buy your book), they would't understand anything like R2. To them, a model is either good or bad. I think you should rephrase it. neutral networks. I think you should drop it, it doesn't add anything. Maybe add some diagrams to illustrate your idea? A simple linear regression for plotting the expected gene expression against measured gene expression? A decision tree for classifying type of cancer in the clinical setting is also not bad.
Overview of predictive modelling, machine learning, etc.
I don't understand this phrase: In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. It doesn't make sens
Overview of predictive modelling, machine learning, etc. I don't understand this phrase: In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. It doesn't make sense to me, because if I were to build a regression model I would still need to think about my samples and population. I don't understand why I should just plug my sample data into R and hope for the best without any idea my sample is about. The sentence doesn't add anything, it's confusing and technically incorrect. Instead the goal is to simply find an equation or algorithm that makes reasonably correct predictons sounds doggy to me. What do you mean by reasonably correct? Your users are probably not very mathematical (otherwise they wouldn't buy your book), they would't understand anything like R2. To them, a model is either good or bad. I think you should rephrase it. neutral networks. I think you should drop it, it doesn't add anything. Maybe add some diagrams to illustrate your idea? A simple linear regression for plotting the expected gene expression against measured gene expression? A decision tree for classifying type of cancer in the clinical setting is also not bad.
Overview of predictive modelling, machine learning, etc. I don't understand this phrase: In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. It doesn't make sens
47,227
Overview of predictive modelling, machine learning, etc.
Are not all (or nearly) all approaches in some sense trying to deduce something that generalizes and thus predicts what will happen? There is not so much of a distinction in this respect and it is not an entirely different goal. The sentence In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. seems wrong. These things are still very important. However, I would agree that the emphasis in these areas is more on prediction rather than e.g. hypothesis testing (which you might say was about proving/disproving scientific ideas). The bit about finding an algorithm (equation less often) that makes reasonably good predictions is a key bit. Predictions are not always evaluated on different data (see cross-validation). It may also be worthwhile to mention that some different terminology (e.g. "learning" instead of "fitting") has developed in these areas due to their historical origin, but that many of the same ideas and issues apply. In fact, not commenting on some of the issues in prediction would seem like a major omission. E.g. in our first Phase 2 trial in 20 patients our drug has a huge efficacy, can we expect the same efficacy in Phase 3? Or we test 10 doses in a dose finding study and simply pick the best one in terms of the point estimate, should we expect to see the same efficacy in Phase 3? The overall trial failed to show that the drug works, but we looked at 20 subgroups and decided that in one of them the drug works. How likely is it that a new trial would show this? These questions involve many of the same issues as one gets in machine learning - the more naïve things I describe above (which are sort of cases of over-fitting on your training data) are avoided to some extent by the more reliable machine learning approaches.
Overview of predictive modelling, machine learning, etc.
Are not all (or nearly) all approaches in some sense trying to deduce something that generalizes and thus predicts what will happen? There is not so much of a distinction in this respect and it is not
Overview of predictive modelling, machine learning, etc. Are not all (or nearly) all approaches in some sense trying to deduce something that generalizes and thus predicts what will happen? There is not so much of a distinction in this respect and it is not an entirely different goal. The sentence In these situations, it is not always necessary to think about samples and populations, or to think about a model that expresses a scientific idea. seems wrong. These things are still very important. However, I would agree that the emphasis in these areas is more on prediction rather than e.g. hypothesis testing (which you might say was about proving/disproving scientific ideas). The bit about finding an algorithm (equation less often) that makes reasonably good predictions is a key bit. Predictions are not always evaluated on different data (see cross-validation). It may also be worthwhile to mention that some different terminology (e.g. "learning" instead of "fitting") has developed in these areas due to their historical origin, but that many of the same ideas and issues apply. In fact, not commenting on some of the issues in prediction would seem like a major omission. E.g. in our first Phase 2 trial in 20 patients our drug has a huge efficacy, can we expect the same efficacy in Phase 3? Or we test 10 doses in a dose finding study and simply pick the best one in terms of the point estimate, should we expect to see the same efficacy in Phase 3? The overall trial failed to show that the drug works, but we looked at 20 subgroups and decided that in one of them the drug works. How likely is it that a new trial would show this? These questions involve many of the same issues as one gets in machine learning - the more naïve things I describe above (which are sort of cases of over-fitting on your training data) are avoided to some extent by the more reliable machine learning approaches.
Overview of predictive modelling, machine learning, etc. Are not all (or nearly) all approaches in some sense trying to deduce something that generalizes and thus predicts what will happen? There is not so much of a distinction in this respect and it is not
47,228
Overview of predictive modelling, machine learning, etc.
A few thoughts beyond those from @Björn and @StudentT that wouldn't fit into a comment on either of their answers. It seems that the distinction you are trying to draw is between testing hypotheses on data (traditional statistical inference, the topic of your book) and gleaning relationships from data (machine learning, not covered in your book). But that distinction can be hard to make. For example, your book does seem to cover genome-wide association studies (GWAS). I would generally think of GWAS more in the latter category, gleaning relationships from data rather than testing pre-specified hypotheses. The issues of multiple comparisons that you cover so thoroughly in your book are essentially the same for GWAS as for many data-mining/machine-learning situations. There's also a slight danger that the reader will interpret this as a distinction between traditional inference as causal inference versus machine learning as pattern recognition, even though traditional inference often has no more true information on causal relations than does machine learning. You certainly discuss the fallacy of such interpretation of traditional inference in the book, but it might be safer not even to raise this possibility in the reader's mind at this point. Furthermore, there's the interesting take on hypothesis testing and prediction in Frank Harrell's Regression Modeling Strategies. In the introduction to this book with its emphasis on prediction, he argues (page 1, second edition): Prediction could be considered a superset of hypothesis testing and estimation. As an example (page 2): It is often useful to think of effect estimates as differences between two predicted values from a model. Or more generally (page 3): Thus when one develops a reasonable multivariable predictive model, hypothesis testing and estimation of effects are byproducts of the fitted model. So predictive modeling is often desirable even when prediction is not the main goal. So for your purpose it might be better to downplay this distinction as all-or-none, as hypothesis testing and prediction do not necessarily "have entirely different goal[s]." What you cover in your book will also be of great value to anyone trying to make sense of many machine learning approaches. You can point out instead how readers of your book will be able to apply what they have learned from you when they set out to explore the other end of the spectrum of data analysis methods.
Overview of predictive modelling, machine learning, etc.
A few thoughts beyond those from @Björn and @StudentT that wouldn't fit into a comment on either of their answers. It seems that the distinction you are trying to draw is between testing hypotheses on
Overview of predictive modelling, machine learning, etc. A few thoughts beyond those from @Björn and @StudentT that wouldn't fit into a comment on either of their answers. It seems that the distinction you are trying to draw is between testing hypotheses on data (traditional statistical inference, the topic of your book) and gleaning relationships from data (machine learning, not covered in your book). But that distinction can be hard to make. For example, your book does seem to cover genome-wide association studies (GWAS). I would generally think of GWAS more in the latter category, gleaning relationships from data rather than testing pre-specified hypotheses. The issues of multiple comparisons that you cover so thoroughly in your book are essentially the same for GWAS as for many data-mining/machine-learning situations. There's also a slight danger that the reader will interpret this as a distinction between traditional inference as causal inference versus machine learning as pattern recognition, even though traditional inference often has no more true information on causal relations than does machine learning. You certainly discuss the fallacy of such interpretation of traditional inference in the book, but it might be safer not even to raise this possibility in the reader's mind at this point. Furthermore, there's the interesting take on hypothesis testing and prediction in Frank Harrell's Regression Modeling Strategies. In the introduction to this book with its emphasis on prediction, he argues (page 1, second edition): Prediction could be considered a superset of hypothesis testing and estimation. As an example (page 2): It is often useful to think of effect estimates as differences between two predicted values from a model. Or more generally (page 3): Thus when one develops a reasonable multivariable predictive model, hypothesis testing and estimation of effects are byproducts of the fitted model. So predictive modeling is often desirable even when prediction is not the main goal. So for your purpose it might be better to downplay this distinction as all-or-none, as hypothesis testing and prediction do not necessarily "have entirely different goal[s]." What you cover in your book will also be of great value to anyone trying to make sense of many machine learning approaches. You can point out instead how readers of your book will be able to apply what they have learned from you when they set out to explore the other end of the spectrum of data analysis methods.
Overview of predictive modelling, machine learning, etc. A few thoughts beyond those from @Björn and @StudentT that wouldn't fit into a comment on either of their answers. It seems that the distinction you are trying to draw is between testing hypotheses on
47,229
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R
It is a tall order to get a book that reviews basic statistics, introduces R, and takes you down the path to "advanced pattern recognition." I think that is a lot for one book. :-) One of the best books on intermediate statistics in R, with discussions of both the statistics (and math) and R is Maindonald and Braun Data Analysis and Graphics Using R: An Example-Based Approach. If you have a good grounding in the topics you listed, this may be an excellent place to start. If your statistics are weaker that may be too much. For pattern recognition and machine learning the book by James, Witten, Hastie, and Tibshirani, An Introduction to Statistical Learning with Applications in R probably is exactly what you want to consolidate the topics you listed in R and move toward machine learning. It is very elementary. If you are better prepared, Hastie, Tibshirani, and Friedman's The Elements of Statistical Learning: Data Mining, Inference, and Prediction is considered by many to be the bible of statistical machine learning. Both of these books are available from the authors for free as downloads from their websites. Sorry, I am not up on really basic books that cover stats and R. But it is likely this questions will be closed as inappropriate soon (it is an opinion question and this site strives to avoid these), so good luck!
Statistics books for someone who has a conceptual base in introductory statistics but little program
It is a tall order to get a book that reviews basic statistics, introduces R, and takes you down the path to "advanced pattern recognition." I think that is a lot for one book. :-) One of the best boo
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R It is a tall order to get a book that reviews basic statistics, introduces R, and takes you down the path to "advanced pattern recognition." I think that is a lot for one book. :-) One of the best books on intermediate statistics in R, with discussions of both the statistics (and math) and R is Maindonald and Braun Data Analysis and Graphics Using R: An Example-Based Approach. If you have a good grounding in the topics you listed, this may be an excellent place to start. If your statistics are weaker that may be too much. For pattern recognition and machine learning the book by James, Witten, Hastie, and Tibshirani, An Introduction to Statistical Learning with Applications in R probably is exactly what you want to consolidate the topics you listed in R and move toward machine learning. It is very elementary. If you are better prepared, Hastie, Tibshirani, and Friedman's The Elements of Statistical Learning: Data Mining, Inference, and Prediction is considered by many to be the bible of statistical machine learning. Both of these books are available from the authors for free as downloads from their websites. Sorry, I am not up on really basic books that cover stats and R. But it is likely this questions will be closed as inappropriate soon (it is an opinion question and this site strives to avoid these), so good luck!
Statistics books for someone who has a conceptual base in introductory statistics but little program It is a tall order to get a book that reviews basic statistics, introduces R, and takes you down the path to "advanced pattern recognition." I think that is a lot for one book. :-) One of the best boo
47,230
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R
These books have a lot of examples that cover basic topics as well as more advanced techniques used in machine learning. Statistics and Data with R: An Applied Approach Through Examples by Yosef Cohen, Jeremiah Y. Cohen Data Mining and Business Analytics with R by Johannes Ledolter R and Data Mining: Examples and Case Studies by Yanchang Zhao
Statistics books for someone who has a conceptual base in introductory statistics but little program
These books have a lot of examples that cover basic topics as well as more advanced techniques used in machine learning. Statistics and Data with R: An Applied Approach Through Examples by Yosef Coh
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R These books have a lot of examples that cover basic topics as well as more advanced techniques used in machine learning. Statistics and Data with R: An Applied Approach Through Examples by Yosef Cohen, Jeremiah Y. Cohen Data Mining and Business Analytics with R by Johannes Ledolter R and Data Mining: Examples and Case Studies by Yanchang Zhao
Statistics books for someone who has a conceptual base in introductory statistics but little program These books have a lot of examples that cover basic topics as well as more advanced techniques used in machine learning. Statistics and Data with R: An Applied Approach Through Examples by Yosef Coh
47,231
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R
you may want to check this website, which lists books on R categorised into topics e.g. statistics, machine learning, data science, finance (it also shows required level of statistic and programming knowledge for each book): https://www.rbookshub.co.uk/
Statistics books for someone who has a conceptual base in introductory statistics but little program
you may want to check this website, which lists books on R categorised into topics e.g. statistics, machine learning, data science, finance (it also shows required level of statistic and programming k
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R you may want to check this website, which lists books on R categorised into topics e.g. statistics, machine learning, data science, finance (it also shows required level of statistic and programming knowledge for each book): https://www.rbookshub.co.uk/
Statistics books for someone who has a conceptual base in introductory statistics but little program you may want to check this website, which lists books on R categorised into topics e.g. statistics, machine learning, data science, finance (it also shows required level of statistic and programming k
47,232
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R
There's an awesome guy on YouTube who does quick 2 minute videos on R programming to learn the basics very fast. I've learned so much from this playlist, I can really recommend watching that. You'll have a fast introduction on what you can do with R.
Statistics books for someone who has a conceptual base in introductory statistics but little program
There's an awesome guy on YouTube who does quick 2 minute videos on R programming to learn the basics very fast. I've learned so much from this playlist, I can really recommend watching that. You'll h
Statistics books for someone who has a conceptual base in introductory statistics but little programming background in R There's an awesome guy on YouTube who does quick 2 minute videos on R programming to learn the basics very fast. I've learned so much from this playlist, I can really recommend watching that. You'll have a fast introduction on what you can do with R.
Statistics books for someone who has a conceptual base in introductory statistics but little program There's an awesome guy on YouTube who does quick 2 minute videos on R programming to learn the basics very fast. I've learned so much from this playlist, I can really recommend watching that. You'll h
47,233
Repeated Measures ANOVA in python
I also think your best (and probably only) bet is the library Statsmodels. Statsmodels contains a linear mixed effects model routine. Having said that you can bite the bullet now and look into calling R from within Python. The package rpy2 seems to be the basic computational bed-rock for this. Good luck!
Repeated Measures ANOVA in python
I also think your best (and probably only) bet is the library Statsmodels. Statsmodels contains a linear mixed effects model routine. Having said that you can bite the bullet now and look into calling
Repeated Measures ANOVA in python I also think your best (and probably only) bet is the library Statsmodels. Statsmodels contains a linear mixed effects model routine. Having said that you can bite the bullet now and look into calling R from within Python. The package rpy2 seems to be the basic computational bed-rock for this. Good luck!
Repeated Measures ANOVA in python I also think your best (and probably only) bet is the library Statsmodels. Statsmodels contains a linear mixed effects model routine. Having said that you can bite the bullet now and look into calling
47,234
Interpreting VAR impulse response
When you conduct VAR all variables should be on the same scale or same variable transformation basis (or as close as possible). It makes perfect sense that when you multiply your original variables by a 100, the IRF graph also reflects responses that are 100 times greater than in the original. The revised graph proportionally has not changed the response (visually the graphs will look identical). You are just using a different scale (i.e. 1 instead of 1% or something similar). An IRF indicates what is the impact of an upward unanticipated one-unit change in the "impulse" variable on the "response" variable over the next several periods (typically 10). IRFs do not have coefficients. The original regressions as you specified them have the coefficients. The IRFs has three main outputs: the expected level of the shock in a given period surrounded by a 95% Confidence Interval (a low estimate and a high estimate). And, all those also generate the IRF graphs.
Interpreting VAR impulse response
When you conduct VAR all variables should be on the same scale or same variable transformation basis (or as close as possible). It makes perfect sense that when you multiply your original variables b
Interpreting VAR impulse response When you conduct VAR all variables should be on the same scale or same variable transformation basis (or as close as possible). It makes perfect sense that when you multiply your original variables by a 100, the IRF graph also reflects responses that are 100 times greater than in the original. The revised graph proportionally has not changed the response (visually the graphs will look identical). You are just using a different scale (i.e. 1 instead of 1% or something similar). An IRF indicates what is the impact of an upward unanticipated one-unit change in the "impulse" variable on the "response" variable over the next several periods (typically 10). IRFs do not have coefficients. The original regressions as you specified them have the coefficients. The IRFs has three main outputs: the expected level of the shock in a given period surrounded by a 95% Confidence Interval (a low estimate and a high estimate). And, all those also generate the IRF graphs.
Interpreting VAR impulse response When you conduct VAR all variables should be on the same scale or same variable transformation basis (or as close as possible). It makes perfect sense that when you multiply your original variables b
47,235
Calculating MAPE [closed]
From the name Mean Absolute Percentage Error, there needs to be an absolute value in the calculation of MAPE: rowMeans(abs((actual-predicted)/actual) * 100) This matches the formula for MAPE at, for instance, https://en.wikipedia.org/wiki/Mean_absolute_percentage_error
Calculating MAPE [closed]
From the name Mean Absolute Percentage Error, there needs to be an absolute value in the calculation of MAPE: rowMeans(abs((actual-predicted)/actual) * 100) This matches the formula for MAPE at, for
Calculating MAPE [closed] From the name Mean Absolute Percentage Error, there needs to be an absolute value in the calculation of MAPE: rowMeans(abs((actual-predicted)/actual) * 100) This matches the formula for MAPE at, for instance, https://en.wikipedia.org/wiki/Mean_absolute_percentage_error
Calculating MAPE [closed] From the name Mean Absolute Percentage Error, there needs to be an absolute value in the calculation of MAPE: rowMeans(abs((actual-predicted)/actual) * 100) This matches the formula for MAPE at, for
47,236
Probability of n-bit sequence appearing at least twice in m-bit sequence
As @NeilG stated in the comments, the desired probability can still be computed exactly by defining a (2n+1)-state markov chain and computing the probability of having seen 2 copies of $\alpha$ after m iterations. The states in the markov chain will be of the form $(a, b)$, where $a$ is the number of times we have already seen $\alpha$ (0, 1, or 2), and $b$ is our progress in seeing $\alpha$ at the current position. For the small example provided with pattern 0111, the states are: \begin{align*} (0,&~-) \\ (0,&~0) \\ (0,&~01) \\ (0,&~011) \\ (1,&~-) \\ (1,&~0) \\ (1,&~01) \\ (1,&~011) \\ (2,&~-) \\ \end{align*} The transition probabilities are defined quite naturally. For pattern 0111, if we see a 0 from state $(0,~-)$ then we transition to $(0,~0)$ and otherwise we stay in $(0,~-)$. If we see a 1 from state $(0,~0)$ then we transition to $(0,~01)$ and otherwise we stay in $(0,~0)$, as we still have the first 0 in the pattern despite not getting a 1. If we see a 1 from state $(0,~01)$ then we transition to $(0,~011)$ and otherwise we go back to state $(0,~0)$. Finally, if we see a 1 from state $(0,~011)$ then we transition to $(1,~-)$, and otherwise we go back to $(0,~0)$. State $(2,~-)$ is an absorbing state. This cleanly handles overlapping patterns. If we were searching for pattern 00010000, then upon getting a 0 from $(0,~0001000)$ we would transition to $(1,~000)$. Computing the transition probabilities and iterating the markov chain from the initial state of $(0,~-)$ can be implemented without too much trouble in your favorite programming language (I'll use R here): library(expm) best.match <- function(pattern, partial) { to.match <- sapply(seq_len(nchar(pattern)+1), function(s) substr(pattern, s, nchar(pattern))) matches <- match(to.match, partial) matches <- matches[!is.na(matches)] partial[matches[1]] } get.prob <- function(alpha, m) { n <- nchar(alpha) partial <- sapply(0:(n-1), function(k) substr(alpha, 1, k)) state.match <- rep(0:2, c(n, n, 1)) state.pattern <- c(partial, partial, "") mat <- sapply(seq_along(state.match), function(i) { this.match <- state.match[i] this.pattern <- state.pattern[i] if (this.match == 2) { as.numeric(state.match == 2) # Absorbing state } else { rowMeans(sapply(paste0(this.pattern, c("0", "1")), function(new.pattern) { if (new.pattern == alpha && this.match == 0) { as.numeric(state.match == 1 & state.pattern == best.match(substr(new.pattern, 2, nchar(new.pattern)), partial)) } else if (new.pattern == alpha && this.match == 1) { as.numeric(state.match == 2) } else { as.numeric(state.match == this.match & state.pattern == best.match(new.pattern, partial)) } })) } }) tail((mat %^% m)[,1], 1) } You can invoke the function by passing the pattern (as a string) and the number of iterations m: get.prob("0111", 10) # [1] 0.0234375 get.prob("00010000", 200) # [1] 0.177094 Though this is not a closed form solution, it does give the exact desired probabilities, so it can be used to evaluate the quality of any other bounds that are derived.
Probability of n-bit sequence appearing at least twice in m-bit sequence
As @NeilG stated in the comments, the desired probability can still be computed exactly by defining a (2n+1)-state markov chain and computing the probability of having seen 2 copies of $\alpha$ after
Probability of n-bit sequence appearing at least twice in m-bit sequence As @NeilG stated in the comments, the desired probability can still be computed exactly by defining a (2n+1)-state markov chain and computing the probability of having seen 2 copies of $\alpha$ after m iterations. The states in the markov chain will be of the form $(a, b)$, where $a$ is the number of times we have already seen $\alpha$ (0, 1, or 2), and $b$ is our progress in seeing $\alpha$ at the current position. For the small example provided with pattern 0111, the states are: \begin{align*} (0,&~-) \\ (0,&~0) \\ (0,&~01) \\ (0,&~011) \\ (1,&~-) \\ (1,&~0) \\ (1,&~01) \\ (1,&~011) \\ (2,&~-) \\ \end{align*} The transition probabilities are defined quite naturally. For pattern 0111, if we see a 0 from state $(0,~-)$ then we transition to $(0,~0)$ and otherwise we stay in $(0,~-)$. If we see a 1 from state $(0,~0)$ then we transition to $(0,~01)$ and otherwise we stay in $(0,~0)$, as we still have the first 0 in the pattern despite not getting a 1. If we see a 1 from state $(0,~01)$ then we transition to $(0,~011)$ and otherwise we go back to state $(0,~0)$. Finally, if we see a 1 from state $(0,~011)$ then we transition to $(1,~-)$, and otherwise we go back to $(0,~0)$. State $(2,~-)$ is an absorbing state. This cleanly handles overlapping patterns. If we were searching for pattern 00010000, then upon getting a 0 from $(0,~0001000)$ we would transition to $(1,~000)$. Computing the transition probabilities and iterating the markov chain from the initial state of $(0,~-)$ can be implemented without too much trouble in your favorite programming language (I'll use R here): library(expm) best.match <- function(pattern, partial) { to.match <- sapply(seq_len(nchar(pattern)+1), function(s) substr(pattern, s, nchar(pattern))) matches <- match(to.match, partial) matches <- matches[!is.na(matches)] partial[matches[1]] } get.prob <- function(alpha, m) { n <- nchar(alpha) partial <- sapply(0:(n-1), function(k) substr(alpha, 1, k)) state.match <- rep(0:2, c(n, n, 1)) state.pattern <- c(partial, partial, "") mat <- sapply(seq_along(state.match), function(i) { this.match <- state.match[i] this.pattern <- state.pattern[i] if (this.match == 2) { as.numeric(state.match == 2) # Absorbing state } else { rowMeans(sapply(paste0(this.pattern, c("0", "1")), function(new.pattern) { if (new.pattern == alpha && this.match == 0) { as.numeric(state.match == 1 & state.pattern == best.match(substr(new.pattern, 2, nchar(new.pattern)), partial)) } else if (new.pattern == alpha && this.match == 1) { as.numeric(state.match == 2) } else { as.numeric(state.match == this.match & state.pattern == best.match(new.pattern, partial)) } })) } }) tail((mat %^% m)[,1], 1) } You can invoke the function by passing the pattern (as a string) and the number of iterations m: get.prob("0111", 10) # [1] 0.0234375 get.prob("00010000", 200) # [1] 0.177094 Though this is not a closed form solution, it does give the exact desired probabilities, so it can be used to evaluate the quality of any other bounds that are derived.
Probability of n-bit sequence appearing at least twice in m-bit sequence As @NeilG stated in the comments, the desired probability can still be computed exactly by defining a (2n+1)-state markov chain and computing the probability of having seen 2 copies of $\alpha$ after
47,237
Probability of n-bit sequence appearing at least twice in m-bit sequence
Part 1: The occurrences of $\alpha$ are disjoint First consider the case where the two occurrences of $\alpha$ are non-overlapping. Then we could lay out the m bits as: ******alpha*****alpha**** Basically there are three regions of bits that can take any value -- before the first $\alpha$, between the two occurrences, and after the second occurrence. Let's call the number of bits in these regions $n_1$, $n_2$, and $n_3$. We know $n_1+n_2+n_3 = m-2n$, so for a fixed set of values $(n_1, n_2, n_3)$, there are $2^{m-2n}$ ways we could select these bits. The number of all sets $(n_1, n_2, n_3)$ that are non-negative and sum to $m-2n$ is the number of 3-multipartitions of a set of size $m-2n$, which is ${m-2n+2 \choose m-2n} = \frac{(m-2n+2)(m-2n+1)}{2}$. Thus we approximate the number of configurations with non-overlapping occurrences of $\alpha$ to be $2^{m-2n-1}(m-2n+2)(m-2n+1)$ and the proportion of all $2^m$ configurations to be $2^{-2n-1}(m-2n+2)(m-2n+1)$. Note that this is an upper bound for the number of non-overlapping configurations, because if $\alpha$ also appears in the ****** bits then we will count the same configuration multiple times; we would expect the upper bound to be accurate if $\alpha$ is unlikely to occur frequently within the m bits. For the simple example with pattern 0111 and $m=10$, this is actually exactly correct, as verified using the get.prob function from my other answer: approx.part1 <- function(pattern, m) { n <- nchar(pattern) 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) } approx.part1("0111", 10) # [1] 0.0234375 get.prob("0111", 10) # [1] 0.0234375 Piece 2: Overlapping occurrences of $\alpha$ We need to further account for the fact that the two occurrences $\alpha$ may be overlapping. To do so, let $S$ be the set of all non-redundant suffixes that could be added to $\alpha$ to achieve a second copy of $\alpha$ at the end. As an example, consider the pattern 0101110101. The suffix 110101 could be added to get another copy of $\alpha$, as could 01110101. For pattern 000000, the only non-redundant suffix that could be added to get a second version of $\alpha$ is 0. Consider a particular suffix $s\in S$ of length $|s|$. We could add it to the end of the first occurrence of $\alpha$ to get a second occurrence; the remaining $m-n-|s|$ bits can be set in any way desired, and there are $m-n-|s|$ positions to place this object among the $m$ total bits. As a result, the total number of configurations with this suffix are $2^{m-n-|s|}(m-n-|s|)$, which out of the $2^m$ configurations is proportion $2^{-n-|s|}(m-n-|s|)$. Summing over all suffixes, we get the following upper bound expression for the probability of at least two occurrences of $\alpha$: $$2^{-2n-1}(m-2n+2)(m-2n+1) + \sum_{s\in S} 2^{-n-|s|}(m-n-|s|)$$ This is quite simple to code up in R: s.sizes <- function(pattern) { n <- nchar(pattern) suffixes <- sapply(2:n, function(i) substr(pattern, i, n)) ok.suffixes <- suffixes[suffixes == sapply(nchar(suffixes), function(i) substr(pattern, 1, i))] needed <- sapply(nchar(ok.suffixes), function(i) substr(pattern, i+1, n)) if (length(needed) == 0) { return(NULL) } block <- rowSums(sapply(seq_along(needed), function(i) { nchar(needed) > nchar(needed[i]) & substr(needed, 1, nchar(needed[i])) == needed[i] })) > 0 nchar(needed)[!block] } full.approx <- function(pattern, m) { s <- s.sizes(pattern) n <- nchar(pattern) if (length(s) > 0) { 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) + sum(sapply(s, function(i) 2^(-n-i)*(m-n-i))) } else { 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) } } With a few examples we can see that it is a reasonable upper bound in cases where we have a low probability of seeing the outcome (recall that get.prob returns the exact correct solution): full.approx("0111", 10) # [1] 0.0234375 get.prob("0111", 10) # [1] 0.0234375 full.approx("0101110101", 50) # [1] 0.001113892 get.prob("0101110101", 50) # [1] 0.00108631 However the upper bound can be rather loose in cases where we have a high probability of seeing two occurrences of $\alpha$: full.approx("00010000", 200) # [1] 0.3023529 get.prob("00010000", 200) # [1] 0.177094
Probability of n-bit sequence appearing at least twice in m-bit sequence
Part 1: The occurrences of $\alpha$ are disjoint First consider the case where the two occurrences of $\alpha$ are non-overlapping. Then we could lay out the m bits as: ******alpha*****alpha**** Basi
Probability of n-bit sequence appearing at least twice in m-bit sequence Part 1: The occurrences of $\alpha$ are disjoint First consider the case where the two occurrences of $\alpha$ are non-overlapping. Then we could lay out the m bits as: ******alpha*****alpha**** Basically there are three regions of bits that can take any value -- before the first $\alpha$, between the two occurrences, and after the second occurrence. Let's call the number of bits in these regions $n_1$, $n_2$, and $n_3$. We know $n_1+n_2+n_3 = m-2n$, so for a fixed set of values $(n_1, n_2, n_3)$, there are $2^{m-2n}$ ways we could select these bits. The number of all sets $(n_1, n_2, n_3)$ that are non-negative and sum to $m-2n$ is the number of 3-multipartitions of a set of size $m-2n$, which is ${m-2n+2 \choose m-2n} = \frac{(m-2n+2)(m-2n+1)}{2}$. Thus we approximate the number of configurations with non-overlapping occurrences of $\alpha$ to be $2^{m-2n-1}(m-2n+2)(m-2n+1)$ and the proportion of all $2^m$ configurations to be $2^{-2n-1}(m-2n+2)(m-2n+1)$. Note that this is an upper bound for the number of non-overlapping configurations, because if $\alpha$ also appears in the ****** bits then we will count the same configuration multiple times; we would expect the upper bound to be accurate if $\alpha$ is unlikely to occur frequently within the m bits. For the simple example with pattern 0111 and $m=10$, this is actually exactly correct, as verified using the get.prob function from my other answer: approx.part1 <- function(pattern, m) { n <- nchar(pattern) 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) } approx.part1("0111", 10) # [1] 0.0234375 get.prob("0111", 10) # [1] 0.0234375 Piece 2: Overlapping occurrences of $\alpha$ We need to further account for the fact that the two occurrences $\alpha$ may be overlapping. To do so, let $S$ be the set of all non-redundant suffixes that could be added to $\alpha$ to achieve a second copy of $\alpha$ at the end. As an example, consider the pattern 0101110101. The suffix 110101 could be added to get another copy of $\alpha$, as could 01110101. For pattern 000000, the only non-redundant suffix that could be added to get a second version of $\alpha$ is 0. Consider a particular suffix $s\in S$ of length $|s|$. We could add it to the end of the first occurrence of $\alpha$ to get a second occurrence; the remaining $m-n-|s|$ bits can be set in any way desired, and there are $m-n-|s|$ positions to place this object among the $m$ total bits. As a result, the total number of configurations with this suffix are $2^{m-n-|s|}(m-n-|s|)$, which out of the $2^m$ configurations is proportion $2^{-n-|s|}(m-n-|s|)$. Summing over all suffixes, we get the following upper bound expression for the probability of at least two occurrences of $\alpha$: $$2^{-2n-1}(m-2n+2)(m-2n+1) + \sum_{s\in S} 2^{-n-|s|}(m-n-|s|)$$ This is quite simple to code up in R: s.sizes <- function(pattern) { n <- nchar(pattern) suffixes <- sapply(2:n, function(i) substr(pattern, i, n)) ok.suffixes <- suffixes[suffixes == sapply(nchar(suffixes), function(i) substr(pattern, 1, i))] needed <- sapply(nchar(ok.suffixes), function(i) substr(pattern, i+1, n)) if (length(needed) == 0) { return(NULL) } block <- rowSums(sapply(seq_along(needed), function(i) { nchar(needed) > nchar(needed[i]) & substr(needed, 1, nchar(needed[i])) == needed[i] })) > 0 nchar(needed)[!block] } full.approx <- function(pattern, m) { s <- s.sizes(pattern) n <- nchar(pattern) if (length(s) > 0) { 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) + sum(sapply(s, function(i) 2^(-n-i)*(m-n-i))) } else { 2^(-2*n-1)*(m-2*n+2)*(m-2*n+1) } } With a few examples we can see that it is a reasonable upper bound in cases where we have a low probability of seeing the outcome (recall that get.prob returns the exact correct solution): full.approx("0111", 10) # [1] 0.0234375 get.prob("0111", 10) # [1] 0.0234375 full.approx("0101110101", 50) # [1] 0.001113892 get.prob("0101110101", 50) # [1] 0.00108631 However the upper bound can be rather loose in cases where we have a high probability of seeing two occurrences of $\alpha$: full.approx("00010000", 200) # [1] 0.3023529 get.prob("00010000", 200) # [1] 0.177094
Probability of n-bit sequence appearing at least twice in m-bit sequence Part 1: The occurrences of $\alpha$ are disjoint First consider the case where the two occurrences of $\alpha$ are non-overlapping. Then we could lay out the m bits as: ******alpha*****alpha**** Basi
47,238
Probability of n-bit sequence appearing at least twice in m-bit sequence
If we assume that the two substrings are disjoint (i.e. $s_1=s[i,i+n]$ $s_2=s[j,j+n]$ such that $0<i<i+n<j<m$), Then $\alpha$ doesn't matter, (because $0$ and $1$ have equal chance of being chosen) So lets assume $\alpha$ is all zeros and rephrase the question as: Given a random binary string of length $m$, what is the probability it has $n$ consequent 0s ? The number of possible binary strings with $m$ bits is $2^m$ The number of strings with $n$ zeros is approximately $2^{m-2n}\times\binom{n-2m+2}{2}$ constructing a string of length $m-2n$, and then choosing two positions where to append the $n$ zeros. (This is actually only an upper bound, for the exact number we need to apply Inclusion-Exclusion) So the probability is $$p\approx\frac{\binom{m-2n+2}{2}2^{m-2n}}{2^m}=\frac{(m-2n+2)(m-2n+1)}{2^{2n+1}}$$
Probability of n-bit sequence appearing at least twice in m-bit sequence
If we assume that the two substrings are disjoint (i.e. $s_1=s[i,i+n]$ $s_2=s[j,j+n]$ such that $0<i<i+n<j<m$), Then $\alpha$ doesn't matter, (because $0$ and $1$ have equal chance of being chosen) So
Probability of n-bit sequence appearing at least twice in m-bit sequence If we assume that the two substrings are disjoint (i.e. $s_1=s[i,i+n]$ $s_2=s[j,j+n]$ such that $0<i<i+n<j<m$), Then $\alpha$ doesn't matter, (because $0$ and $1$ have equal chance of being chosen) So lets assume $\alpha$ is all zeros and rephrase the question as: Given a random binary string of length $m$, what is the probability it has $n$ consequent 0s ? The number of possible binary strings with $m$ bits is $2^m$ The number of strings with $n$ zeros is approximately $2^{m-2n}\times\binom{n-2m+2}{2}$ constructing a string of length $m-2n$, and then choosing two positions where to append the $n$ zeros. (This is actually only an upper bound, for the exact number we need to apply Inclusion-Exclusion) So the probability is $$p\approx\frac{\binom{m-2n+2}{2}2^{m-2n}}{2^m}=\frac{(m-2n+2)(m-2n+1)}{2^{2n+1}}$$
Probability of n-bit sequence appearing at least twice in m-bit sequence If we assume that the two substrings are disjoint (i.e. $s_1=s[i,i+n]$ $s_2=s[j,j+n]$ such that $0<i<i+n<j<m$), Then $\alpha$ doesn't matter, (because $0$ and $1$ have equal chance of being chosen) So
47,239
Intuitive example for MLE, MAP and Naive Bayes classifier
You find a coin, and want to check what are the chances (probability) that if you flip it, it would land on the "Heads" side. You flip it 10 times (a sample of 10 observations) and count the number of times if landed on "Heads", e.g. $X=3$. You assume that what you just done is a sample from a Binomial distribution $B(10, p_0)$ - so what we're after is the parameter $p_0$ which can get values between $[0,1]$. The likelihood function is the probability of observing $X=3$ for each possible value of $p_0$. The MLE estimator is the value that is the most likely = we could find that by the usual method of locating the point where the derivative is 0, but its easier to do that for the log-likelihood, which has a maximum at the same point since applying log is applying a monotonically increasing transformation. So log + derive + find the root of this: $$f(p) = \binom{10}{3}p^3(1-p)^7$$ and get $p_{MLE} = 0.3$ The MAP estimator is a Bayesian estimator. These guys don't consider $p_0$ as a simple parameter, but rather as another random variable with its own distribution called the prior distribution, which is our prior belief about what the value of $p_0$ should be. In our example, I would probably be inclined to believe that $p_0 = 0.5$, as most of the coins I saw in my life were balanced (or so I thought). So let's say that our prior for p is $p \sim Normal(0.5,1)$. Our posterior probability will look like: $$ Pr[X|p]Pr[p] = \binom{10}{3}p^3(1-p)^7\frac{1}{\sqrt{2\pi}}exp(-\frac{(p-0.5)^2}{2})$$ log, derive, find root and get $p_{MAP} = 0.304$ Naive Bayes is a classifier which gives a binary prediction. Assuming there are 2 classes of coins in the world - 95% are balanced ($p=0.5$) and 5% are rigged ($p=0.7$). Naive Bayes would use that prior distribution, apply it to your sample of $X=3$, and help you decide if its more likely that your coin is balanced or rigged. You can see it as an instantiation of the MAP estimator for the 2 classes, and selecting the more probable one. We denote balanced as $y=1$ and rigged as $y=0$, and we will predict $y=1$ if: $$ \frac{Pr[y=1|X=3]}{Pr[y=0|X=3]} > 1 $$ More on inference here.
Intuitive example for MLE, MAP and Naive Bayes classifier
You find a coin, and want to check what are the chances (probability) that if you flip it, it would land on the "Heads" side. You flip it 10 times (a sample of 10 observations) and count the number of
Intuitive example for MLE, MAP and Naive Bayes classifier You find a coin, and want to check what are the chances (probability) that if you flip it, it would land on the "Heads" side. You flip it 10 times (a sample of 10 observations) and count the number of times if landed on "Heads", e.g. $X=3$. You assume that what you just done is a sample from a Binomial distribution $B(10, p_0)$ - so what we're after is the parameter $p_0$ which can get values between $[0,1]$. The likelihood function is the probability of observing $X=3$ for each possible value of $p_0$. The MLE estimator is the value that is the most likely = we could find that by the usual method of locating the point where the derivative is 0, but its easier to do that for the log-likelihood, which has a maximum at the same point since applying log is applying a monotonically increasing transformation. So log + derive + find the root of this: $$f(p) = \binom{10}{3}p^3(1-p)^7$$ and get $p_{MLE} = 0.3$ The MAP estimator is a Bayesian estimator. These guys don't consider $p_0$ as a simple parameter, but rather as another random variable with its own distribution called the prior distribution, which is our prior belief about what the value of $p_0$ should be. In our example, I would probably be inclined to believe that $p_0 = 0.5$, as most of the coins I saw in my life were balanced (or so I thought). So let's say that our prior for p is $p \sim Normal(0.5,1)$. Our posterior probability will look like: $$ Pr[X|p]Pr[p] = \binom{10}{3}p^3(1-p)^7\frac{1}{\sqrt{2\pi}}exp(-\frac{(p-0.5)^2}{2})$$ log, derive, find root and get $p_{MAP} = 0.304$ Naive Bayes is a classifier which gives a binary prediction. Assuming there are 2 classes of coins in the world - 95% are balanced ($p=0.5$) and 5% are rigged ($p=0.7$). Naive Bayes would use that prior distribution, apply it to your sample of $X=3$, and help you decide if its more likely that your coin is balanced or rigged. You can see it as an instantiation of the MAP estimator for the 2 classes, and selecting the more probable one. We denote balanced as $y=1$ and rigged as $y=0$, and we will predict $y=1$ if: $$ \frac{Pr[y=1|X=3]}{Pr[y=0|X=3]} > 1 $$ More on inference here.
Intuitive example for MLE, MAP and Naive Bayes classifier You find a coin, and want to check what are the chances (probability) that if you flip it, it would land on the "Heads" side. You flip it 10 times (a sample of 10 observations) and count the number of
47,240
Role of Central Limit Theorem in one-way ANOVA
That is not a correct interpretation of the CLT. The CLT is a limiting argument and only helps you with respect to type I error, not type II error. Confidence intervals using the CLT can be horrendously inaccurate for sample sizes in the thousands when the data distribution is very skewed (e.g., lognormal distribution). If the 2-sample $t$-test doesn't work in the face of much asymmetry, ANOVA will not fare any better. Note also that the CLT in how it's usually invoked only works when the population variance is known. Rand Wilcox has written nice papers showing that with data distributions that are only slightly non-normal the distribution of the $t$ statistic can be very far from the $t$ distribution. Note that it is not relevant that critical values of the $t$ distribution are very close to $z$ critical values for $n\geq 20$ or $30$; these both pertain to Gaussian data. Perhaps the easiest way to understand why the CLT is irrelevant to the real world is to remember that the standard deviation is only a very good measure of dispersion if the data distribution is symmetric and not too heavy tailed, and to note that a single outlier can destroy the standard deviation estimate.
Role of Central Limit Theorem in one-way ANOVA
That is not a correct interpretation of the CLT. The CLT is a limiting argument and only helps you with respect to type I error, not type II error. Confidence intervals using the CLT can be horrendo
Role of Central Limit Theorem in one-way ANOVA That is not a correct interpretation of the CLT. The CLT is a limiting argument and only helps you with respect to type I error, not type II error. Confidence intervals using the CLT can be horrendously inaccurate for sample sizes in the thousands when the data distribution is very skewed (e.g., lognormal distribution). If the 2-sample $t$-test doesn't work in the face of much asymmetry, ANOVA will not fare any better. Note also that the CLT in how it's usually invoked only works when the population variance is known. Rand Wilcox has written nice papers showing that with data distributions that are only slightly non-normal the distribution of the $t$ statistic can be very far from the $t$ distribution. Note that it is not relevant that critical values of the $t$ distribution are very close to $z$ critical values for $n\geq 20$ or $30$; these both pertain to Gaussian data. Perhaps the easiest way to understand why the CLT is irrelevant to the real world is to remember that the standard deviation is only a very good measure of dispersion if the data distribution is symmetric and not too heavy tailed, and to note that a single outlier can destroy the standard deviation estimate.
Role of Central Limit Theorem in one-way ANOVA That is not a correct interpretation of the CLT. The CLT is a limiting argument and only helps you with respect to type I error, not type II error. Confidence intervals using the CLT can be horrendo
47,241
Role of Central Limit Theorem in one-way ANOVA
The t-statistic has a numerator and a denominator. For this discussion, assume both numerator and denominator are now divided by $\sigma/\sqrt{n}$. The numerator is then of the standardized form required for the CLT. The CLT only gives you that (under certain conditions) as $n\to\infty$ a standardized numerator will go to standard normal. the CLT does not addresss the denominator and it does not address the rate at which normality is approached. You can invoke Slutsky's theorem for a ratio to get an asymptotic normal distribution for the t-statistic, but that's still not saying anything about the rate. For that you need something like Berry-Esseen (which does at least tell us something about how quickly the numerator might go toward the normal); a quick glance at that theorem will show you why a rule like "n=30" doesn't make sense. Note that Berry-Esseen also tells us that the quote in your question "not too asymmetric" still isn't quite getting at the issue even so, since one may have a symmetric distribution for which the absolute third moment is not small. However even with all that extra machinery we still haven't dealt with the rate at which the entire statistic goes to normal. What is clear at least is that "n=30" isn't any use unless we restrict consideration to cases which would make the rule reasonable, but I've seen no suitable rule of thumb which is useful for deciding when the original rule of thumb (if it deserves the name at all) applies. (My suggestion is to use simulation to investigate the behavior of the statistic under a variety of conditions relevant to the kinds of problems once faces; these will tend to be different in different areas of application.)
Role of Central Limit Theorem in one-way ANOVA
The t-statistic has a numerator and a denominator. For this discussion, assume both numerator and denominator are now divided by $\sigma/\sqrt{n}$. The numerator is then of the standardized form requ
Role of Central Limit Theorem in one-way ANOVA The t-statistic has a numerator and a denominator. For this discussion, assume both numerator and denominator are now divided by $\sigma/\sqrt{n}$. The numerator is then of the standardized form required for the CLT. The CLT only gives you that (under certain conditions) as $n\to\infty$ a standardized numerator will go to standard normal. the CLT does not addresss the denominator and it does not address the rate at which normality is approached. You can invoke Slutsky's theorem for a ratio to get an asymptotic normal distribution for the t-statistic, but that's still not saying anything about the rate. For that you need something like Berry-Esseen (which does at least tell us something about how quickly the numerator might go toward the normal); a quick glance at that theorem will show you why a rule like "n=30" doesn't make sense. Note that Berry-Esseen also tells us that the quote in your question "not too asymmetric" still isn't quite getting at the issue even so, since one may have a symmetric distribution for which the absolute third moment is not small. However even with all that extra machinery we still haven't dealt with the rate at which the entire statistic goes to normal. What is clear at least is that "n=30" isn't any use unless we restrict consideration to cases which would make the rule reasonable, but I've seen no suitable rule of thumb which is useful for deciding when the original rule of thumb (if it deserves the name at all) applies. (My suggestion is to use simulation to investigate the behavior of the statistic under a variety of conditions relevant to the kinds of problems once faces; these will tend to be different in different areas of application.)
Role of Central Limit Theorem in one-way ANOVA The t-statistic has a numerator and a denominator. For this discussion, assume both numerator and denominator are now divided by $\sigma/\sqrt{n}$. The numerator is then of the standardized form requ
47,242
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum
You can use a sum-of-squares argument to see this. $$\sum_i (x_i-\theta)^2 = \sum_i (x_i - \bar{x}+\bar{x}-\theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2+\\\color{red}{2(\bar{x}-\theta)\sum_i(x_i-\bar{x})}$$ Now, $\bar{x}$ is defined so that the cross term becomes zero since $\sum_i x_i = \sum_i \bar{x}$. We are therefore left with: $$\sum_i (x_i - \theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2$$ This is the variance/bias decomposition of the squared-error associated with estimator $\theta$. Since both terms on the RHS are positive and only the bias term depends on $\theta$, we have: $$\sum_i (x_i - \theta)^2 > \sum_i (x_i - \bar{x})^2$$
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum
You can use a sum-of-squares argument to see this. $$\sum_i (x_i-\theta)^2 = \sum_i (x_i - \bar{x}+\bar{x}-\theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2+\\\color{red}{2(\bar{x}-\theta)\sum_i(
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum You can use a sum-of-squares argument to see this. $$\sum_i (x_i-\theta)^2 = \sum_i (x_i - \bar{x}+\bar{x}-\theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2+\\\color{red}{2(\bar{x}-\theta)\sum_i(x_i-\bar{x})}$$ Now, $\bar{x}$ is defined so that the cross term becomes zero since $\sum_i x_i = \sum_i \bar{x}$. We are therefore left with: $$\sum_i (x_i - \theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2$$ This is the variance/bias decomposition of the squared-error associated with estimator $\theta$. Since both terms on the RHS are positive and only the bias term depends on $\theta$, we have: $$\sum_i (x_i - \theta)^2 > \sum_i (x_i - \bar{x})^2$$
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum You can use a sum-of-squares argument to see this. $$\sum_i (x_i-\theta)^2 = \sum_i (x_i - \bar{x}+\bar{x}-\theta)^2 = \sum_i (x_i-\bar{x})^2+n(\bar{x}-\theta)^2+\\\color{red}{2(\bar{x}-\theta)\sum_i(
47,243
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum
$\theta\mapsto \sum (x_i-\theta)^2$ is a quadratic function in $\theta$ that opens upwards. It has a unique minimum where its derivative is $0$, that is to say when $2\sum (x_i-\theta)=0$ ie $\theta = \hat x$.
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum
$\theta\mapsto \sum (x_i-\theta)^2$ is a quadratic function in $\theta$ that opens upwards. It has a unique minimum where its derivative is $0$, that is to say when $2\sum (x_i-\theta)=0$ ie $\theta =
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum $\theta\mapsto \sum (x_i-\theta)^2$ is a quadratic function in $\theta$ that opens upwards. It has a unique minimum where its derivative is $0$, that is to say when $2\sum (x_i-\theta)=0$ ie $\theta = \hat x$.
Prove that maximum likelihood estimators for Gaussian distribution are a global maximum $\theta\mapsto \sum (x_i-\theta)^2$ is a quadratic function in $\theta$ that opens upwards. It has a unique minimum where its derivative is $0$, that is to say when $2\sum (x_i-\theta)=0$ ie $\theta =
47,244
Classifying time-series similarity - what variable should I train on?
hard to say from just two examples. is the amplitude important? If so, try the area under the curves as a feature. if not, you need to z-normalize the data. This paper lists many many possible time series features http://arxiv.org/pdf/1401.3531.pdf I could help you more, if you showed many more examples. eamonn keogh
Classifying time-series similarity - what variable should I train on?
hard to say from just two examples. is the amplitude important? If so, try the area under the curves as a feature. if not, you need to z-normalize the data. This paper lists many many possible time se
Classifying time-series similarity - what variable should I train on? hard to say from just two examples. is the amplitude important? If so, try the area under the curves as a feature. if not, you need to z-normalize the data. This paper lists many many possible time series features http://arxiv.org/pdf/1401.3531.pdf I could help you more, if you showed many more examples. eamonn keogh
Classifying time-series similarity - what variable should I train on? hard to say from just two examples. is the amplitude important? If so, try the area under the curves as a feature. if not, you need to z-normalize the data. This paper lists many many possible time se
47,245
Classifying time-series similarity - what variable should I train on?
Based on the examples you show, simple Euclidean distance will get you 100% accuracy. This appears to be VERY easy.
Classifying time-series similarity - what variable should I train on?
Based on the examples you show, simple Euclidean distance will get you 100% accuracy. This appears to be VERY easy.
Classifying time-series similarity - what variable should I train on? Based on the examples you show, simple Euclidean distance will get you 100% accuracy. This appears to be VERY easy.
Classifying time-series similarity - what variable should I train on? Based on the examples you show, simple Euclidean distance will get you 100% accuracy. This appears to be VERY easy.
47,246
Marginal normality and joint normality
A bivariate normal, centered anywhere in the YZ-plane, must exist over the entire plane...that is, in quadrants I, II, III, and IV because its domain is infinite in both variables. But for it to exist in Quadrants II and IV, Y and Z must be oppositely-signed. If they cannot be, then the joint distribution cannot be a bivariate normal.
Marginal normality and joint normality
A bivariate normal, centered anywhere in the YZ-plane, must exist over the entire plane...that is, in quadrants I, II, III, and IV because its domain is infinite in both variables. But for it to exis
Marginal normality and joint normality A bivariate normal, centered anywhere in the YZ-plane, must exist over the entire plane...that is, in quadrants I, II, III, and IV because its domain is infinite in both variables. But for it to exist in Quadrants II and IV, Y and Z must be oppositely-signed. If they cannot be, then the joint distribution cannot be a bivariate normal.
Marginal normality and joint normality A bivariate normal, centered anywhere in the YZ-plane, must exist over the entire plane...that is, in quadrants I, II, III, and IV because its domain is infinite in both variables. But for it to exis
47,247
RMSE is scale-dependent; is RMSE%?
A function $f(\cdot)$ is scale-invariant if it yields the same result for argument $x$ as it does for argument $cx$, where $c$ is some positive constant. Let us see whether supplying $(cy_i,c\hat{y}_i)$ in place of $(y_i,\hat{y}_i)$ for $i=1,\dotsc,n$ will change the value of $\text{RMSE%}$: $$ \begin{equation} \begin{aligned} \text{RMSE%}(cy_i,c\hat{y}_i) &= 100\% \cdot \frac{\sqrt{\frac{1}{n}\Sigma_{i=1}^n (cy_i - c\hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{\sqrt{c^2\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{c\sqrt{\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{\sqrt{\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{\bar{y}} = \text{RMSE%}(y_i,\hat{y}_i) \end{aligned} \end{equation} $$ On the way I used the obvious property that $\bar{y}$ gets multiplied by $c$ when $y_i$ is replaced by $cy_i$: if $\bar{y}=\frac{1}{n}\sum_{i=1}^n y_i$, then when scaled by $c$ you get $\frac{1}{n}\sum_{i=1}^n (cy_i)=c\frac{1}{n}\sum_{i=1}^n y_i=c\bar{y}$. You see that $\text{RMSE%}$ yields the same result for $(cy_i,c\hat{y}_i)$ as it does for $(y_i,\hat{y}_i)$; hence, it is scale invariant.
RMSE is scale-dependent; is RMSE%?
A function $f(\cdot)$ is scale-invariant if it yields the same result for argument $x$ as it does for argument $cx$, where $c$ is some positive constant. Let us see whether supplying $(cy_i,c\hat{y}_i
RMSE is scale-dependent; is RMSE%? A function $f(\cdot)$ is scale-invariant if it yields the same result for argument $x$ as it does for argument $cx$, where $c$ is some positive constant. Let us see whether supplying $(cy_i,c\hat{y}_i)$ in place of $(y_i,\hat{y}_i)$ for $i=1,\dotsc,n$ will change the value of $\text{RMSE%}$: $$ \begin{equation} \begin{aligned} \text{RMSE%}(cy_i,c\hat{y}_i) &= 100\% \cdot \frac{\sqrt{\frac{1}{n}\Sigma_{i=1}^n (cy_i - c\hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{\sqrt{c^2\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{c\sqrt{\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{c\bar{y}} \\ &= 100\% \cdot \frac{\sqrt{\frac{1}{n}\Sigma_{i=1}^n (y_i - \hat{y}_i)^2}}{\bar{y}} = \text{RMSE%}(y_i,\hat{y}_i) \end{aligned} \end{equation} $$ On the way I used the obvious property that $\bar{y}$ gets multiplied by $c$ when $y_i$ is replaced by $cy_i$: if $\bar{y}=\frac{1}{n}\sum_{i=1}^n y_i$, then when scaled by $c$ you get $\frac{1}{n}\sum_{i=1}^n (cy_i)=c\frac{1}{n}\sum_{i=1}^n y_i=c\bar{y}$. You see that $\text{RMSE%}$ yields the same result for $(cy_i,c\hat{y}_i)$ as it does for $(y_i,\hat{y}_i)$; hence, it is scale invariant.
RMSE is scale-dependent; is RMSE%? A function $f(\cdot)$ is scale-invariant if it yields the same result for argument $x$ as it does for argument $cx$, where $c$ is some positive constant. Let us see whether supplying $(cy_i,c\hat{y}_i
47,248
Conditional variance in OLS regression
The title of your question "Conditional variance in OLS regression" gives a clue. The first expression $$\text{Var}(y_{it})=\beta^{2}\sigma_{x}^{2}+\sigma_{\epsilon}^{2}$$ gives the unconditional variance ($x$ is not "conditioned away" and remains in the expression) while the second one $$\text{E}\left[y_{it}-\text{E}\{y_{it}\}\right]^2 =\sigma_{\epsilon}^{2}$$ gives the conditional variance (conditional on $x$).
Conditional variance in OLS regression
The title of your question "Conditional variance in OLS regression" gives a clue. The first expression $$\text{Var}(y_{it})=\beta^{2}\sigma_{x}^{2}+\sigma_{\epsilon}^{2}$$ gives the unconditional va
Conditional variance in OLS regression The title of your question "Conditional variance in OLS regression" gives a clue. The first expression $$\text{Var}(y_{it})=\beta^{2}\sigma_{x}^{2}+\sigma_{\epsilon}^{2}$$ gives the unconditional variance ($x$ is not "conditioned away" and remains in the expression) while the second one $$\text{E}\left[y_{it}-\text{E}\{y_{it}\}\right]^2 =\sigma_{\epsilon}^{2}$$ gives the conditional variance (conditional on $x$).
Conditional variance in OLS regression The title of your question "Conditional variance in OLS regression" gives a clue. The first expression $$\text{Var}(y_{it})=\beta^{2}\sigma_{x}^{2}+\sigma_{\epsilon}^{2}$$ gives the unconditional va
47,249
Conditional variance in OLS regression
But your final equation cannot be right if you are not treating the predictors as fixed. For $$y_i = \beta x_i + \epsilon_i$$ recalling that $$E\left(Y \right) = E\left[ E \left(Y|X \right) \right]$$ we have $$E(y_i) =E\left( E\left(\beta x_i + \epsilon_i|x_i \right) \right) = \beta \mu_x$$ and so \begin{align} Var(y_i) = E\left(y_i ^2\right) - \left(E(y_i) \right)^2 &= E \left(\beta x_i + \epsilon_i \right)^2 - \beta^2 \mu_x^2 \\ &= \beta^2 E\left(x_i^2 \right) + E(\epsilon^2_i) + 2 E\left( \beta x_i \epsilon_i \right) - \beta^2 \mu_x^2 \\ & = \beta^2 \left(\sigma_x^2 + \mu^2_x \right) + \sigma^2 -\beta^2 \mu_x^2 \\ & = \beta^2 \sigma^2_x + \sigma^2 \end{align} assuming that the $x_i$ are iid. This is similar to what you obtained in your third equation of course.
Conditional variance in OLS regression
But your final equation cannot be right if you are not treating the predictors as fixed. For $$y_i = \beta x_i + \epsilon_i$$ recalling that $$E\left(Y \right) = E\left[ E \left(Y|X \right) \right]$$
Conditional variance in OLS regression But your final equation cannot be right if you are not treating the predictors as fixed. For $$y_i = \beta x_i + \epsilon_i$$ recalling that $$E\left(Y \right) = E\left[ E \left(Y|X \right) \right]$$ we have $$E(y_i) =E\left( E\left(\beta x_i + \epsilon_i|x_i \right) \right) = \beta \mu_x$$ and so \begin{align} Var(y_i) = E\left(y_i ^2\right) - \left(E(y_i) \right)^2 &= E \left(\beta x_i + \epsilon_i \right)^2 - \beta^2 \mu_x^2 \\ &= \beta^2 E\left(x_i^2 \right) + E(\epsilon^2_i) + 2 E\left( \beta x_i \epsilon_i \right) - \beta^2 \mu_x^2 \\ & = \beta^2 \left(\sigma_x^2 + \mu^2_x \right) + \sigma^2 -\beta^2 \mu_x^2 \\ & = \beta^2 \sigma^2_x + \sigma^2 \end{align} assuming that the $x_i$ are iid. This is similar to what you obtained in your third equation of course.
Conditional variance in OLS regression But your final equation cannot be right if you are not treating the predictors as fixed. For $$y_i = \beta x_i + \epsilon_i$$ recalling that $$E\left(Y \right) = E\left[ E \left(Y|X \right) \right]$$
47,250
Does multicollinearity affect performance of a classifier?
There is an important qualifier in the continuation of the first cited quote from Wikipedia: "Multicollinearity does not reduce the predictive power or reliability of the model as a whole, at least within the sample data set" (emphasis added). Unless there is a singular design matrix, multicollinearity does not prevent fitting a model to an individual data sample. I take that to be the point of the first Wikipedia quote. A regression model can capture the data sample well, including all of the peculiarities and noise of the particular data sample, in the presence of multicollinearity. The problems arise when you try to apply the model outside the original data set to the underlying population. Multicollinearity will severely affect performance outside of the original data sample, as you recognize.
Does multicollinearity affect performance of a classifier?
There is an important qualifier in the continuation of the first cited quote from Wikipedia: "Multicollinearity does not reduce the predictive power or reliability of the model as a whole, at least wi
Does multicollinearity affect performance of a classifier? There is an important qualifier in the continuation of the first cited quote from Wikipedia: "Multicollinearity does not reduce the predictive power or reliability of the model as a whole, at least within the sample data set" (emphasis added). Unless there is a singular design matrix, multicollinearity does not prevent fitting a model to an individual data sample. I take that to be the point of the first Wikipedia quote. A regression model can capture the data sample well, including all of the peculiarities and noise of the particular data sample, in the presence of multicollinearity. The problems arise when you try to apply the model outside the original data set to the underlying population. Multicollinearity will severely affect performance outside of the original data sample, as you recognize.
Does multicollinearity affect performance of a classifier? There is an important qualifier in the continuation of the first cited quote from Wikipedia: "Multicollinearity does not reduce the predictive power or reliability of the model as a whole, at least wi
47,251
Does multicollinearity affect performance of a classifier?
Contrary to @EdM's answer, based on the answer here, the performance will not degrade if the test set has the same covariance matrix. In different words, if the correlation between the variables in the test set is the same, the combination of the coefficients and the feature vectors will lead to a valid result. Often this is the case.
Does multicollinearity affect performance of a classifier?
Contrary to @EdM's answer, based on the answer here, the performance will not degrade if the test set has the same covariance matrix. In different words, if the correlation between the variables in th
Does multicollinearity affect performance of a classifier? Contrary to @EdM's answer, based on the answer here, the performance will not degrade if the test set has the same covariance matrix. In different words, if the correlation between the variables in the test set is the same, the combination of the coefficients and the feature vectors will lead to a valid result. Often this is the case.
Does multicollinearity affect performance of a classifier? Contrary to @EdM's answer, based on the answer here, the performance will not degrade if the test set has the same covariance matrix. In different words, if the correlation between the variables in th
47,252
Why do we need to normalize data before applying penalizing methods in the framework of regression? [duplicate]
The reason to normalise your variables beforehand is to ensure that the regularisation term $\lambda$ regularises/affects the variable involved in a (somewhat) similar manner. A very interesting thread touching on this issue appeared is here where the regularisation was imposed to normalised and unnormalised data and unsurprisingly the results where quite different. In brief when you impose something like : $(X^TX + \lambda \Omega)^{-1}$ instead of the usual $(X^TX)^{-1}$ you want the effect of $\lambda$ to even across all variables constituting $X$. If the variables are of significantly different scales (think $x_1$ as being of the order $1e1$ and $x_2$ being of the order $1e{5}$, so for example age in years and weight in grams respectively) regularizing (roughly speaking accepting some degree of error in the measurements) the two by the same magnitude is nonsensical. The well-referenced Wikipedia lemmas on Tikhonov regularization and Matrix regularization are good places to follow up on this in more theoretical manner if you are interested.
Why do we need to normalize data before applying penalizing methods in the framework of regression?
The reason to normalise your variables beforehand is to ensure that the regularisation term $\lambda$ regularises/affects the variable involved in a (somewhat) similar manner. A very interesting threa
Why do we need to normalize data before applying penalizing methods in the framework of regression? [duplicate] The reason to normalise your variables beforehand is to ensure that the regularisation term $\lambda$ regularises/affects the variable involved in a (somewhat) similar manner. A very interesting thread touching on this issue appeared is here where the regularisation was imposed to normalised and unnormalised data and unsurprisingly the results where quite different. In brief when you impose something like : $(X^TX + \lambda \Omega)^{-1}$ instead of the usual $(X^TX)^{-1}$ you want the effect of $\lambda$ to even across all variables constituting $X$. If the variables are of significantly different scales (think $x_1$ as being of the order $1e1$ and $x_2$ being of the order $1e{5}$, so for example age in years and weight in grams respectively) regularizing (roughly speaking accepting some degree of error in the measurements) the two by the same magnitude is nonsensical. The well-referenced Wikipedia lemmas on Tikhonov regularization and Matrix regularization are good places to follow up on this in more theoretical manner if you are interested.
Why do we need to normalize data before applying penalizing methods in the framework of regression? The reason to normalise your variables beforehand is to ensure that the regularisation term $\lambda$ regularises/affects the variable involved in a (somewhat) similar manner. A very interesting threa
47,253
Exercise on Chebyshev inequality compared to the Central Limit Theorem
Chebyshev's inequality works for any probability distribution (or large enough empirical data) while the CLT has stronger assumptions (independence, existence of moments, etc.). Its a good rule of thumb that if you want to reduce the number of assumptions in your model (or use a parametric model) you'll need more data in comparison and vice versa. In this case, you can use the CLT and use less data.
Exercise on Chebyshev inequality compared to the Central Limit Theorem
Chebyshev's inequality works for any probability distribution (or large enough empirical data) while the CLT has stronger assumptions (independence, existence of moments, etc.). Its a good rule of thu
Exercise on Chebyshev inequality compared to the Central Limit Theorem Chebyshev's inequality works for any probability distribution (or large enough empirical data) while the CLT has stronger assumptions (independence, existence of moments, etc.). Its a good rule of thumb that if you want to reduce the number of assumptions in your model (or use a parametric model) you'll need more data in comparison and vice versa. In this case, you can use the CLT and use less data.
Exercise on Chebyshev inequality compared to the Central Limit Theorem Chebyshev's inequality works for any probability distribution (or large enough empirical data) while the CLT has stronger assumptions (independence, existence of moments, etc.). Its a good rule of thu
47,254
How to compute expectation of square of Riemann integral of a random variable?
Assuming that $E[W_tW_s]=\sigma^2\min(t,s)$, \begin{align} E\left[\left(\int_0^TW_s\,\mathrm ds\right)^2\right]&=E\left[\int_0^TW_t\,\mathrm dt\int_0^TW_s\,\mathrm ds\right]\\ &=E\left[\int_0^T\int_0^TW_t\,W_s\,\mathrm dt\mathrm ds\right]\\ &=\int_0^T\int_0^T E[W_tW_s]\,\mathrm dt\,\mathrm ds\\ &=\int_0^T\int_0^T \sigma^2\min(t,s)\,\mathrm dt\,\mathrm ds\\ &=\int_0^T\left[\int_0^T\sigma^2\min(t,s)\,\mathrm dt\right]\,\mathrm ds\\ &=\int_0^T\left[\int_0^s\sigma^2 \min(t,s)\,\mathrm dt + \int_s^T\sigma^2 \min(t,s)\,\mathrm dt\right]\,\mathrm ds\\ &=\int_0^T \int_0^s\sigma^2 \min(t,s)\,\mathrm dt\,\mathrm ds + \int_0^T\int_s^T\sigma^2 \min(t,s)\,\mathrm dt\,\mathrm ds\tag{1}\\ &= \int_0^T\int_0^s\sigma^2 t\,\mathrm dt\,\mathrm ds + \int_0^T\int_s^T\sigma^2 s\,\mathrm dt\,\mathrm ds\tag{2}\\ &=\int_0^T\sigma^2\frac{s^2}{2}\,\mathrm ds + \int_0^T\sigma^2(T-s)s\,\mathrm ds\\ &= \sigma^2\left(\frac{T^3}{6}+\frac{T^3}{2}-\frac{T^3}{3}\right)\\ &= \sigma^2\frac{T^3}{3}<\infty \end{align} I hope that the answer above is understandable and acceptable to most readers, but for the benefit of @youpilat13 and any others confused as to how $(2)$ follows from $(1)$, I add the following explanation. There are two double integrals in $(1)$ and they are over disjoint right triangular regions, separated by the line $s=t$, in the plane. As to why the two integrals are being summed, we are trying to compute the integral over a square region and we are breaking up the integral over the square into the sum of integrals over two disjoint subsets (right triangles), computing each integral separately, and then adding the results together to determine the integral over the square region. In the inner integral in the first double integral in $(1)$, $s$ is a constant with respect to $t$, the variable of integration, but since $t$ varies from $0$ to $s$ only, it must be that $\min(t,s)$ equals $t$. Similarly, in the inner integral in the second double integral in $(1)$, $s$ is a constant with respect to $t$, the variable of integration, but since $t$ varies from $s$ to $T$ only, it must be that $\min(t,s)$ equals $s$.
How to compute expectation of square of Riemann integral of a random variable?
Assuming that $E[W_tW_s]=\sigma^2\min(t,s)$, \begin{align} E\left[\left(\int_0^TW_s\,\mathrm ds\right)^2\right]&=E\left[\int_0^TW_t\,\mathrm dt\int_0^TW_s\,\mathrm ds\right]\\ &=E\left[\int_0^T\int_0^
How to compute expectation of square of Riemann integral of a random variable? Assuming that $E[W_tW_s]=\sigma^2\min(t,s)$, \begin{align} E\left[\left(\int_0^TW_s\,\mathrm ds\right)^2\right]&=E\left[\int_0^TW_t\,\mathrm dt\int_0^TW_s\,\mathrm ds\right]\\ &=E\left[\int_0^T\int_0^TW_t\,W_s\,\mathrm dt\mathrm ds\right]\\ &=\int_0^T\int_0^T E[W_tW_s]\,\mathrm dt\,\mathrm ds\\ &=\int_0^T\int_0^T \sigma^2\min(t,s)\,\mathrm dt\,\mathrm ds\\ &=\int_0^T\left[\int_0^T\sigma^2\min(t,s)\,\mathrm dt\right]\,\mathrm ds\\ &=\int_0^T\left[\int_0^s\sigma^2 \min(t,s)\,\mathrm dt + \int_s^T\sigma^2 \min(t,s)\,\mathrm dt\right]\,\mathrm ds\\ &=\int_0^T \int_0^s\sigma^2 \min(t,s)\,\mathrm dt\,\mathrm ds + \int_0^T\int_s^T\sigma^2 \min(t,s)\,\mathrm dt\,\mathrm ds\tag{1}\\ &= \int_0^T\int_0^s\sigma^2 t\,\mathrm dt\,\mathrm ds + \int_0^T\int_s^T\sigma^2 s\,\mathrm dt\,\mathrm ds\tag{2}\\ &=\int_0^T\sigma^2\frac{s^2}{2}\,\mathrm ds + \int_0^T\sigma^2(T-s)s\,\mathrm ds\\ &= \sigma^2\left(\frac{T^3}{6}+\frac{T^3}{2}-\frac{T^3}{3}\right)\\ &= \sigma^2\frac{T^3}{3}<\infty \end{align} I hope that the answer above is understandable and acceptable to most readers, but for the benefit of @youpilat13 and any others confused as to how $(2)$ follows from $(1)$, I add the following explanation. There are two double integrals in $(1)$ and they are over disjoint right triangular regions, separated by the line $s=t$, in the plane. As to why the two integrals are being summed, we are trying to compute the integral over a square region and we are breaking up the integral over the square into the sum of integrals over two disjoint subsets (right triangles), computing each integral separately, and then adding the results together to determine the integral over the square region. In the inner integral in the first double integral in $(1)$, $s$ is a constant with respect to $t$, the variable of integration, but since $t$ varies from $0$ to $s$ only, it must be that $\min(t,s)$ equals $t$. Similarly, in the inner integral in the second double integral in $(1)$, $s$ is a constant with respect to $t$, the variable of integration, but since $t$ varies from $s$ to $T$ only, it must be that $\min(t,s)$ equals $s$.
How to compute expectation of square of Riemann integral of a random variable? Assuming that $E[W_tW_s]=\sigma^2\min(t,s)$, \begin{align} E\left[\left(\int_0^TW_s\,\mathrm ds\right)^2\right]&=E\left[\int_0^TW_t\,\mathrm dt\int_0^TW_s\,\mathrm ds\right]\\ &=E\left[\int_0^T\int_0^
47,255
Exponentially decaying integral of a Poisson process
The answer may be surprising. Here is a brief sketch of a solution. As with a somewhat related problem, the idea is to obtain a recurrence relation for a quantity related to the asymptotic distribution and then solve that relation. Since all uniform distributions are symmetric, the sum can equally well be expressed by changing each $s$ into $t-s$, producing an expression with the same distribution as $Y_t$, $$Y^\prime_t = \sum_{s\in X_t} e^{-s}.$$ Reorder this sum (which, because it is almost surely finite, will not change its value) so that the $s = s_1 \le s_2 \le \cdots \le s_N$ are ascending. Letting $u_1 = s_1,$ $u_2 = s_2 - s_1, \ldots,$ $u_{i+1} = s_{i+1}-s_i$ for $i=1, 2, \ldots, N-1$ enables us to rewrite $u_i = s_1 + s_2 + \cdots + s_i$, thereby putting this sum into the form $$\eqalign{ Y^\prime_t &= \sum_{i=1}^N e^{-(u_1 + u_2 + \cdots + u_i)} \\ &=\sum_{i=1}^N e^{-u_1}e^{-u_2}\cdots e^{-u_i}\\ &=e^{-u_1}\left(1 + \sum_{i=2}^N e^{-u_2}\cdots e^{-u_i}\right)\\ &=\cdots\\ &= e^{-u_1}\left(1 + e^{-u_2}\left(1 + \cdots + \left(1 + e^{-u_N}\right)\cdots \right)\right). }$$ If we were to fix $N$ (rather than let it have a Poisson distribution), the exponentials of the gaps $U_i=e^{-u_i}$ would be uniformly distributed. In the limit there is no difference between fixing $N$ and allowing it to have a Poisson distribution (up to a factor of $N^{-1/2}$), so the asymptotic distribution of $Y_t$ must be that of the infinite product $$U_1(1 + U_2(1 + U_3(1 + \cdots )\cdots))$$ where the $U_i$ are independently uniformly distributed on $[0,1]$. Therefore, if the random variable $X$ has the limiting distribution of $Y_t$, then $U(1+X)$ must also have this distribution for an independent uniform variate $U$. This is the desired recurrence relation. It remains to exploit it. Let $X$ be a random variable with the limiting distribution function $F$ (of density $f$) and let $y \ge 0$. By definition, $$F(y) = \Pr(U(1+X) \le y) = \Pr(U \le \frac{y}{1+X}).$$ This breaks into two parts depending on whether $y/(1+X)$ exceeds $1$, for when it is less than $1$ this probability equals $y/(1+X)$ and otherwise it equals $1$. We need to integrate this probability over all possible values of $X$, which can range from $0$ on up. This yields $$F(y) = y \int_{\max(y-1,0)}^\infty \frac{f(x)}{1+x}dx + F(y-1).$$ For $0 \le y \le 1$, this shows $F$ is linear in $y$, whence $f$ is a constant in this interval. Let's rescale $F$ to make this constant unity--we'll renormalize afterwards. Thus, using the rescaled $F$, we obtain the recurrence relation $$F(y) - F(y-1) = y \int_{\max(y-1,0)}^\infty \frac{f(x)}{1+x}dx.$$ By differentiating both sides with respect to $y$ we obtain a comparable recurrence for the density. It can be simplified to $$f(y) = 1 - \int_1^y \frac{f(x-1)dx}{x}.$$ The solution breaks into functions defined piecewise on the intervals $[0,1]$, $[1,2]$, and so on. It can be obtained by starting with a constant value of $f$ on $[0,1]$, integrating the right hand side of the recurrence to obtain the values of $f$ on $[1,2]$, and repeating ad infinitum. The resulting function on $[0,\infty)$ is then integrated to find the normalizing constant. Only the first few expressions can be integrated exactly in any nice form--repeated logarithmic integrals show up immediately. Here is a histogram of a simulation of the 100th partial product, iterated 10,000 times. Over it is plotted an approximation of $f$ obtained as described above using numerical integration. It closely agrees with the simulation. These calculations were carried out in Mathematica (due to the need for repeated numerical integration). A quick simulation of the problem--as originally formulated--can be performed in R as a check. This example performs 100,000 iterations, drawing a Poisson $N$, conditionally drawing the $X_t$, and computing $Y_t$ each time: s <- 100 # Plays the role of "t" in the question sim <- replicate(1e5, sum(exp(-s+runif(rpois(1, s), 0, s)))) hist(sim, freq=FALSE, breaks=50)
Exponentially decaying integral of a Poisson process
The answer may be surprising. Here is a brief sketch of a solution. As with a somewhat related problem, the idea is to obtain a recurrence relation for a quantity related to the asymptotic distribut
Exponentially decaying integral of a Poisson process The answer may be surprising. Here is a brief sketch of a solution. As with a somewhat related problem, the idea is to obtain a recurrence relation for a quantity related to the asymptotic distribution and then solve that relation. Since all uniform distributions are symmetric, the sum can equally well be expressed by changing each $s$ into $t-s$, producing an expression with the same distribution as $Y_t$, $$Y^\prime_t = \sum_{s\in X_t} e^{-s}.$$ Reorder this sum (which, because it is almost surely finite, will not change its value) so that the $s = s_1 \le s_2 \le \cdots \le s_N$ are ascending. Letting $u_1 = s_1,$ $u_2 = s_2 - s_1, \ldots,$ $u_{i+1} = s_{i+1}-s_i$ for $i=1, 2, \ldots, N-1$ enables us to rewrite $u_i = s_1 + s_2 + \cdots + s_i$, thereby putting this sum into the form $$\eqalign{ Y^\prime_t &= \sum_{i=1}^N e^{-(u_1 + u_2 + \cdots + u_i)} \\ &=\sum_{i=1}^N e^{-u_1}e^{-u_2}\cdots e^{-u_i}\\ &=e^{-u_1}\left(1 + \sum_{i=2}^N e^{-u_2}\cdots e^{-u_i}\right)\\ &=\cdots\\ &= e^{-u_1}\left(1 + e^{-u_2}\left(1 + \cdots + \left(1 + e^{-u_N}\right)\cdots \right)\right). }$$ If we were to fix $N$ (rather than let it have a Poisson distribution), the exponentials of the gaps $U_i=e^{-u_i}$ would be uniformly distributed. In the limit there is no difference between fixing $N$ and allowing it to have a Poisson distribution (up to a factor of $N^{-1/2}$), so the asymptotic distribution of $Y_t$ must be that of the infinite product $$U_1(1 + U_2(1 + U_3(1 + \cdots )\cdots))$$ where the $U_i$ are independently uniformly distributed on $[0,1]$. Therefore, if the random variable $X$ has the limiting distribution of $Y_t$, then $U(1+X)$ must also have this distribution for an independent uniform variate $U$. This is the desired recurrence relation. It remains to exploit it. Let $X$ be a random variable with the limiting distribution function $F$ (of density $f$) and let $y \ge 0$. By definition, $$F(y) = \Pr(U(1+X) \le y) = \Pr(U \le \frac{y}{1+X}).$$ This breaks into two parts depending on whether $y/(1+X)$ exceeds $1$, for when it is less than $1$ this probability equals $y/(1+X)$ and otherwise it equals $1$. We need to integrate this probability over all possible values of $X$, which can range from $0$ on up. This yields $$F(y) = y \int_{\max(y-1,0)}^\infty \frac{f(x)}{1+x}dx + F(y-1).$$ For $0 \le y \le 1$, this shows $F$ is linear in $y$, whence $f$ is a constant in this interval. Let's rescale $F$ to make this constant unity--we'll renormalize afterwards. Thus, using the rescaled $F$, we obtain the recurrence relation $$F(y) - F(y-1) = y \int_{\max(y-1,0)}^\infty \frac{f(x)}{1+x}dx.$$ By differentiating both sides with respect to $y$ we obtain a comparable recurrence for the density. It can be simplified to $$f(y) = 1 - \int_1^y \frac{f(x-1)dx}{x}.$$ The solution breaks into functions defined piecewise on the intervals $[0,1]$, $[1,2]$, and so on. It can be obtained by starting with a constant value of $f$ on $[0,1]$, integrating the right hand side of the recurrence to obtain the values of $f$ on $[1,2]$, and repeating ad infinitum. The resulting function on $[0,\infty)$ is then integrated to find the normalizing constant. Only the first few expressions can be integrated exactly in any nice form--repeated logarithmic integrals show up immediately. Here is a histogram of a simulation of the 100th partial product, iterated 10,000 times. Over it is plotted an approximation of $f$ obtained as described above using numerical integration. It closely agrees with the simulation. These calculations were carried out in Mathematica (due to the need for repeated numerical integration). A quick simulation of the problem--as originally formulated--can be performed in R as a check. This example performs 100,000 iterations, drawing a Poisson $N$, conditionally drawing the $X_t$, and computing $Y_t$ each time: s <- 100 # Plays the role of "t" in the question sim <- replicate(1e5, sum(exp(-s+runif(rpois(1, s), 0, s)))) hist(sim, freq=FALSE, breaks=50)
Exponentially decaying integral of a Poisson process The answer may be surprising. Here is a brief sketch of a solution. As with a somewhat related problem, the idea is to obtain a recurrence relation for a quantity related to the asymptotic distribut
47,256
How to read the Interaction effect in multiple linear regression with continuous regressors?
There seems to be one single intercept 49.80842, whereas it would make sense to have two different intercepts No, it usually wouldn't make sense to have two intercepts; that only makes sense when you have a factor with two levels (and even then only if you regard the relationship holding factor levels constant). The population intercept, strictly speaking, is $E(Y)$ for the population model when all the predictors are 0, and the estimate of it is whatever our fitted value is when all the predictors are zero. In that sense - whether we have factor variables or numerical variables - there's only one intercept for the whole equation. Unless, that is, you're considering different parts of the model as separate equations. Imagine that we had one factor with three levels, and one continuous variable - for now without the interaction: For the equation as a whole, there's one intercept, but if you think of it as a different relationship within each subgroup (level of the factor), there's three, one for each level of the factor ($a$) -- by considering a specific value of $a$, we get a specific straight line that is shifted by the effect of $a$, giving a different intercept for each group. But now let's consider the relationship with $a$. Now for each level of $a$, if $x$ had no impact, there'd be a very simple relationship $E(Y|a=j)=\mu_j$. There's one intercept, the baseline mean (or if you conceive it that way, three, one for each subgroup -- where the intercept would be the average value in that subgroup). (nb It may be hard to see here but the means are not equally spaced; don't be tempted by this plot to think of $y$ as linear in $a$ considered as a numeric variable.) But now if we consider $x$ does have an impact and look at the relationship at a specific value of $x$ ($x=x_0$), as a function of $a$, $E(Y|a=j)=\mu_j(x_0)$ -- each group has a different mean, but those means are shifted by the effect of $x$ at $x_0$. So that would be one intercept (the black dot if it's the baseline group) ... at each value of $x$. For each of infinite number of different values that $x$ might take, there's a new intercept. So depending on how we look at it, there's one intercept, or three, or an infinite number... but not two. Now if we introduce an $x:a$ interaction, nothing changes but the slopes! We still can conceive of this as having one intercept, or perhaps three, or perhaps an infinite number. So how does this all relate to two numeric variables? Even though we didn't have it in this case, imagine that the levels of $a$ were numeric and that the fitted model was linear in $a$ (perhaps $a$ is discrete, like the number of phones owned collectively by a household). [i.e. we're now doing what I said earlier not to do, taking $a$ to be numeric and (conditionally) linearly related to $y$] Then we'd still have one intercept in the strict sense, the value taken by the model when $x=a=0$ (even though neither variable is 0 in our sample), or one for each possible value taken by $a$ (in our sample, three different values occurred, but maybe 0, 4, 5 ... are also possible), or one for each value taken by $x$ (an infinity of possible values since $x$ is discrete). It doesn't matter if our model has an interaction, it doesn't change that consideration about how we count intercepts. So how do we interpret the interaction term when both variables are numeric? You can consider it as providing for a different slope in the relationship between $y$ and $x$, at each $a$ (three different slopes in all, one for the baseline and two more via interaction), or you can consider it as providing for a different slope between $y$ and (the now-numeric) $a$ at each value of $x$. Now if we replace this now numeric but discrete $a$ with a continuous variate, you'd have an infinite number of slopes for both one-on-one relationships, one at each value of the third variable. You effectively say as much in your question of course. are we constrained to expressing this with absurd scenarios, such as if we had cars with 1hp we would have a modified slope for the weight equal to (−8.21662+0.02785)∗1∗weight? Or is there a more sensible way to look at this term? Sure there is, consider values more like the mean. So for a typical relationship between mpg and wt, hold horsepower at some value near the mean. To see how much the slope changes, consider two values of horsepower, one below the mean and one above it. Where the variable-values aren't especially meaningful in themselves (like score on some Likert-scale-based instrument say) you might go up or down by a standard deviation on the third variable, or pick the lower and upper quartile. Where they are meaningful (like hp) you can pick two more or less typical values (100 and 200 seem like sensible choices for hp for the mtcars data, and if you also want to look at something near the mean, 150 will serve quite well, but you might choose a typical value for a particular kind of car for each choice instead) So you could draw a fitted mpg-vs-wt line for a 100hp car and a 150hp car and a 200 hp car. You could also draw a mpg-vs-hp line for a car that weighs 2.0 (that's 2.0 thousand-pounds) and 4.0 or (or 2.5 & 3.5 if you want something nearer to quartiles).
How to read the Interaction effect in multiple linear regression with continuous regressors?
There seems to be one single intercept 49.80842, whereas it would make sense to have two different intercepts No, it usually wouldn't make sense to have two intercepts; that only makes sense when yo
How to read the Interaction effect in multiple linear regression with continuous regressors? There seems to be one single intercept 49.80842, whereas it would make sense to have two different intercepts No, it usually wouldn't make sense to have two intercepts; that only makes sense when you have a factor with two levels (and even then only if you regard the relationship holding factor levels constant). The population intercept, strictly speaking, is $E(Y)$ for the population model when all the predictors are 0, and the estimate of it is whatever our fitted value is when all the predictors are zero. In that sense - whether we have factor variables or numerical variables - there's only one intercept for the whole equation. Unless, that is, you're considering different parts of the model as separate equations. Imagine that we had one factor with three levels, and one continuous variable - for now without the interaction: For the equation as a whole, there's one intercept, but if you think of it as a different relationship within each subgroup (level of the factor), there's three, one for each level of the factor ($a$) -- by considering a specific value of $a$, we get a specific straight line that is shifted by the effect of $a$, giving a different intercept for each group. But now let's consider the relationship with $a$. Now for each level of $a$, if $x$ had no impact, there'd be a very simple relationship $E(Y|a=j)=\mu_j$. There's one intercept, the baseline mean (or if you conceive it that way, three, one for each subgroup -- where the intercept would be the average value in that subgroup). (nb It may be hard to see here but the means are not equally spaced; don't be tempted by this plot to think of $y$ as linear in $a$ considered as a numeric variable.) But now if we consider $x$ does have an impact and look at the relationship at a specific value of $x$ ($x=x_0$), as a function of $a$, $E(Y|a=j)=\mu_j(x_0)$ -- each group has a different mean, but those means are shifted by the effect of $x$ at $x_0$. So that would be one intercept (the black dot if it's the baseline group) ... at each value of $x$. For each of infinite number of different values that $x$ might take, there's a new intercept. So depending on how we look at it, there's one intercept, or three, or an infinite number... but not two. Now if we introduce an $x:a$ interaction, nothing changes but the slopes! We still can conceive of this as having one intercept, or perhaps three, or perhaps an infinite number. So how does this all relate to two numeric variables? Even though we didn't have it in this case, imagine that the levels of $a$ were numeric and that the fitted model was linear in $a$ (perhaps $a$ is discrete, like the number of phones owned collectively by a household). [i.e. we're now doing what I said earlier not to do, taking $a$ to be numeric and (conditionally) linearly related to $y$] Then we'd still have one intercept in the strict sense, the value taken by the model when $x=a=0$ (even though neither variable is 0 in our sample), or one for each possible value taken by $a$ (in our sample, three different values occurred, but maybe 0, 4, 5 ... are also possible), or one for each value taken by $x$ (an infinity of possible values since $x$ is discrete). It doesn't matter if our model has an interaction, it doesn't change that consideration about how we count intercepts. So how do we interpret the interaction term when both variables are numeric? You can consider it as providing for a different slope in the relationship between $y$ and $x$, at each $a$ (three different slopes in all, one for the baseline and two more via interaction), or you can consider it as providing for a different slope between $y$ and (the now-numeric) $a$ at each value of $x$. Now if we replace this now numeric but discrete $a$ with a continuous variate, you'd have an infinite number of slopes for both one-on-one relationships, one at each value of the third variable. You effectively say as much in your question of course. are we constrained to expressing this with absurd scenarios, such as if we had cars with 1hp we would have a modified slope for the weight equal to (−8.21662+0.02785)∗1∗weight? Or is there a more sensible way to look at this term? Sure there is, consider values more like the mean. So for a typical relationship between mpg and wt, hold horsepower at some value near the mean. To see how much the slope changes, consider two values of horsepower, one below the mean and one above it. Where the variable-values aren't especially meaningful in themselves (like score on some Likert-scale-based instrument say) you might go up or down by a standard deviation on the third variable, or pick the lower and upper quartile. Where they are meaningful (like hp) you can pick two more or less typical values (100 and 200 seem like sensible choices for hp for the mtcars data, and if you also want to look at something near the mean, 150 will serve quite well, but you might choose a typical value for a particular kind of car for each choice instead) So you could draw a fitted mpg-vs-wt line for a 100hp car and a 150hp car and a 200 hp car. You could also draw a mpg-vs-hp line for a car that weighs 2.0 (that's 2.0 thousand-pounds) and 4.0 or (or 2.5 & 3.5 if you want something nearer to quartiles).
How to read the Interaction effect in multiple linear regression with continuous regressors? There seems to be one single intercept 49.80842, whereas it would make sense to have two different intercepts No, it usually wouldn't make sense to have two intercepts; that only makes sense when yo
47,257
How to read the Interaction effect in multiple linear regression with continuous regressors?
Output Coefficients: (Intercept) wt hp wt:hp 49.80842 -8.21662 -0.12010 0.02785 How do we read this output? ... We have a slope for wt and a slope for hp (-8.21662 -0.12010 = -8.33672, is that right?). Nope. Some calculus should confirm that the derivative of mpg with respect to wt, which is the only kind of slope you should be interested in, is -8.21662 + 0.02785 x hp That whole expression is the expected increase in mpg from increasing wt by one. Similarly the derivative of mpg with respect to hp is -8.21662 + 0.02785 x wt because interactions are symmetric. So, yes, are we constrained to expressing this with absurd scenarios, such as if we had cars with 1hp we would have a modified slope for the weight equal to (−8.21662+0.02785) * 1 * weight? Or is there a more sensible way to look at this term? I'm not sure what you mean here. If you're worried about talking about cars with zero hp or wt or whatnot, then it's probably just easier to redefine those variables to have a zero that's more meaningful. For example, subtract the Mazda RX4 from each row. Now you have a rotary-engined early seventies zero point to compare to. That is, you are no longer considering cars with an hp of one, but rather cars an hp one higher than that of a Mazda RX4.
How to read the Interaction effect in multiple linear regression with continuous regressors?
Output Coefficients: (Intercept) wt hp wt:hp 49.80842 -8.21662 -0.12010 0.02785 How do we read this output? ... We have a slope for wt and a slope for
How to read the Interaction effect in multiple linear regression with continuous regressors? Output Coefficients: (Intercept) wt hp wt:hp 49.80842 -8.21662 -0.12010 0.02785 How do we read this output? ... We have a slope for wt and a slope for hp (-8.21662 -0.12010 = -8.33672, is that right?). Nope. Some calculus should confirm that the derivative of mpg with respect to wt, which is the only kind of slope you should be interested in, is -8.21662 + 0.02785 x hp That whole expression is the expected increase in mpg from increasing wt by one. Similarly the derivative of mpg with respect to hp is -8.21662 + 0.02785 x wt because interactions are symmetric. So, yes, are we constrained to expressing this with absurd scenarios, such as if we had cars with 1hp we would have a modified slope for the weight equal to (−8.21662+0.02785) * 1 * weight? Or is there a more sensible way to look at this term? I'm not sure what you mean here. If you're worried about talking about cars with zero hp or wt or whatnot, then it's probably just easier to redefine those variables to have a zero that's more meaningful. For example, subtract the Mazda RX4 from each row. Now you have a rotary-engined early seventies zero point to compare to. That is, you are no longer considering cars with an hp of one, but rather cars an hp one higher than that of a Mazda RX4.
How to read the Interaction effect in multiple linear regression with continuous regressors? Output Coefficients: (Intercept) wt hp wt:hp 49.80842 -8.21662 -0.12010 0.02785 How do we read this output? ... We have a slope for wt and a slope for
47,258
How to read the Interaction effect in multiple linear regression with continuous regressors?
The easiest way is to have a look at different quantiles of one of your variables of interest, depending on your research question. Assuming that you want to know the effect of one additional unit of horse power on the miles per gallon a car uses, you look at the distribution of the weight and use e.g. the percentiles 1, 10, 25, 50, 75, 90 and 99. For each of these percentiles you compute the effect of hp on mpg. Concerning interaction terms and parent variables (variables which are interacted) Chipman put forward the Heredity principle (http://arxiv.org/abs/bayes-an/9510001). Basically he differentiates between strong and weak heredity, depending on how much parent variables are included in the regression. From a statistical point of view it would also be correct to just add the interaction term, without the variables themselves. But this makes the results hard (/impossible) to interpret.
How to read the Interaction effect in multiple linear regression with continuous regressors?
The easiest way is to have a look at different quantiles of one of your variables of interest, depending on your research question. Assuming that you want to know the effect of one additional unit of
How to read the Interaction effect in multiple linear regression with continuous regressors? The easiest way is to have a look at different quantiles of one of your variables of interest, depending on your research question. Assuming that you want to know the effect of one additional unit of horse power on the miles per gallon a car uses, you look at the distribution of the weight and use e.g. the percentiles 1, 10, 25, 50, 75, 90 and 99. For each of these percentiles you compute the effect of hp on mpg. Concerning interaction terms and parent variables (variables which are interacted) Chipman put forward the Heredity principle (http://arxiv.org/abs/bayes-an/9510001). Basically he differentiates between strong and weak heredity, depending on how much parent variables are included in the regression. From a statistical point of view it would also be correct to just add the interaction term, without the variables themselves. But this makes the results hard (/impossible) to interpret.
How to read the Interaction effect in multiple linear regression with continuous regressors? The easiest way is to have a look at different quantiles of one of your variables of interest, depending on your research question. Assuming that you want to know the effect of one additional unit of
47,259
Interpret multidimensional scaling plot
Despite having 24 original variables, you can perfectly fit the distances amongst your data with 3 dimensions because you have only 4 points. It is possible that your points lie exactly on a 2D plane through the original 24D space, but that is incredibly unlikely, in my opinion. It is reasonable to imagine that the variation on the third dimension is inconsequential and/or unreliable, but I don't have any information about that. I am assuming that there is a third dimension that isn't represented in your plot. You can infer that 1 and 3 do not vary on dimension 2, but you have no information here about whether they vary on dimension 3. Thus, you cannot necessarily assume that they vary on dimension 1 only. Likewise, you can infer that 1 and 2 do not vary on dimension 1, but again you have no information about whether they vary on dimension 3. So, you cannot necessarily assume that they vary on dimension 2 only. Point 4 differs from 1, 2, and 3 on both dimensions 1 and 2. Its relationship to them on dimension 3 is unknown. Ignoring dimension 3 for a moment, you could think of point 4 as the medoid of your dataset.
Interpret multidimensional scaling plot
Despite having 24 original variables, you can perfectly fit the distances amongst your data with 3 dimensions because you have only 4 points. It is possible that your points lie exactly on a 2D plane
Interpret multidimensional scaling plot Despite having 24 original variables, you can perfectly fit the distances amongst your data with 3 dimensions because you have only 4 points. It is possible that your points lie exactly on a 2D plane through the original 24D space, but that is incredibly unlikely, in my opinion. It is reasonable to imagine that the variation on the third dimension is inconsequential and/or unreliable, but I don't have any information about that. I am assuming that there is a third dimension that isn't represented in your plot. You can infer that 1 and 3 do not vary on dimension 2, but you have no information here about whether they vary on dimension 3. Thus, you cannot necessarily assume that they vary on dimension 1 only. Likewise, you can infer that 1 and 2 do not vary on dimension 1, but again you have no information about whether they vary on dimension 3. So, you cannot necessarily assume that they vary on dimension 2 only. Point 4 differs from 1, 2, and 3 on both dimensions 1 and 2. Its relationship to them on dimension 3 is unknown. Ignoring dimension 3 for a moment, you could think of point 4 as the medoid of your dataset.
Interpret multidimensional scaling plot Despite having 24 original variables, you can perfectly fit the distances amongst your data with 3 dimensions because you have only 4 points. It is possible that your points lie exactly on a 2D plane
47,260
Interpret multidimensional scaling plot
Sorry to necro, but found this through a search and thought I could help others. The correct answer is that there is no interpretability to the MDS1 and MDS2 dimensions with respect to your original 24-space points. This is because MDS performs a nonparametric transformations from the original 24-space into 2-space. The only interpretation that you can take from the resulting plot is from the distances between points. The further away two points are the more dissimilar they are in 24-space, and conversely the closer two points are the more similar they are in 24-space.
Interpret multidimensional scaling plot
Sorry to necro, but found this through a search and thought I could help others. The correct answer is that there is no interpretability to the MDS1 and MDS2 dimensions with respect to your original 2
Interpret multidimensional scaling plot Sorry to necro, but found this through a search and thought I could help others. The correct answer is that there is no interpretability to the MDS1 and MDS2 dimensions with respect to your original 24-space points. This is because MDS performs a nonparametric transformations from the original 24-space into 2-space. The only interpretation that you can take from the resulting plot is from the distances between points. The further away two points are the more dissimilar they are in 24-space, and conversely the closer two points are the more similar they are in 24-space.
Interpret multidimensional scaling plot Sorry to necro, but found this through a search and thought I could help others. The correct answer is that there is no interpretability to the MDS1 and MDS2 dimensions with respect to your original 2
47,261
machine learning for panel data in Python?
If you are considering to apply machine learning to temporal (i.e. panel data) then I recommend to use a recurrent neural network (RNN) for the tasks at hand. Python offers several excellent neural networks libraries, such as Caffe, Brainstorm and Theano. Note that when applying neural networks it is of importance that you have sufficient data available. If this is not the case then I do not recommend machine learning techniques, but in stead would recommend ARMA based models
machine learning for panel data in Python?
If you are considering to apply machine learning to temporal (i.e. panel data) then I recommend to use a recurrent neural network (RNN) for the tasks at hand. Python offers several excellent neural ne
machine learning for panel data in Python? If you are considering to apply machine learning to temporal (i.e. panel data) then I recommend to use a recurrent neural network (RNN) for the tasks at hand. Python offers several excellent neural networks libraries, such as Caffe, Brainstorm and Theano. Note that when applying neural networks it is of importance that you have sufficient data available. If this is not the case then I do not recommend machine learning techniques, but in stead would recommend ARMA based models
machine learning for panel data in Python? If you are considering to apply machine learning to temporal (i.e. panel data) then I recommend to use a recurrent neural network (RNN) for the tasks at hand. Python offers several excellent neural ne
47,262
machine learning for panel data in Python?
If you define panel data as 'grouped' data where the intra-group observations are correlated, see sklearn leave P groups out. See my answer here.
machine learning for panel data in Python?
If you define panel data as 'grouped' data where the intra-group observations are correlated, see sklearn leave P groups out. See my answer here.
machine learning for panel data in Python? If you define panel data as 'grouped' data where the intra-group observations are correlated, see sklearn leave P groups out. See my answer here.
machine learning for panel data in Python? If you define panel data as 'grouped' data where the intra-group observations are correlated, see sklearn leave P groups out. See my answer here.
47,263
multivariate transformation of random variable
I have two suggestions: Use differential algebra instead of Jacobians. It's a simpler, more reliable way to keep track of the derivatives. Draw a picture. Often the trickiest part of such calculations is to determine what the domain of the new variables is. Pictures help. Details and supporting code follow. Two things need to be found: the probability element of $(U,V)$ and the domain (set of possible values) of $(U,V)$. (The reason for choosing to write the distribution in terms of probability density, rather than a probability function, is that the probability function is somewhat messy to describe.) The probability element Using differential algebra it is straightforward to compute that The probability element of the uniform distribution of $(X,Y)$ is $$f_{XY}(x,y)dx dy = \frac{1}{2}dx dy = \frac{1}{2}|dx\wedge dy|.$$ Computing the differentials of $u = xy$ and $v=y$, we easily obtain $$du = y\,dx + x\,dy;\ dv = dy,$$ whence $$du \wedge dv = (y\,dx + x\,dy)\wedge dy =y\,dx\wedge dy + x\,dy\wedge dy= y\,dx\wedge dy.$$ Comparing the two results, and recalling that $y = v$, shows immediately that $$f_{UV}(u,v)du dv = \frac{1}{2v} |du \wedge dv| = \frac{1}{2v} du dv.$$ The domain Since $-1 \le X \le 1$ and $0 \le Y \le 1$, it follows that $0 \le Y = V \le 1$ and $-1 \le X = U/V \le 1$, whence $|U| \le V.$ The transformation from $(X,Y)$ to $(U,V)$ can be visualized by drawing a large number of random values from $(X,Y)$ and coloring them according to $X$ and $Y$. The figure uses hue to represent $X$ and lightness to represent $Y$, with lighter points indicating smaller values of $Y$. On the left the points are plotted in $(X,Y)$ coordinates while on the right the same points are plotted in $(U,V)$ coordinates: The points are squeezed towards the vertical axis, in proportion to their height above the horizontal axis. Each vertical line segment $X = x, 0 \le Y \le 1,$ is mapped to a radial line segment $V = \frac{1}{x}U, 0 \le V \le 1.$ Putting them together Consequently, the probability density function for $(U,V)$ can be written in terms of indicator functions for its domain as $$f_{UV}(u,v) = \frac{1}{2v} I(0 \le v \le 1) I(|u| \le v) du\,dv.$$ Code As a check, we may integrate $f_{UV}$ over $\mathbb{R}^2$. It would be done in (say) Mathematica as $$\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\frac{\text{Boole}[0\leq v\leq 1] \text{Boole}[\left| u\right| \leq v]}{2 v}dvdu$$ which, in response to this command, returns $1$ as the answer. Along with the evident fact that $f_{UV}$ is never negative, that verifies this actually is a probability density function. The figure was drawn in R 3.1.3: n <- 5e4 x <- runif(n, -1, 1) y <- runif(n) u <- x*y v <- y par(mfrow=c(1,2)) colors <- hsv((x+1)/2, .8, 1 - 0.8*y, .1) plot(x, y, pch=16, col=colors, cex=3/8, asp=1) plot(u, v, pch=16, col=colors, cex=1/4, asp=1)
multivariate transformation of random variable
I have two suggestions: Use differential algebra instead of Jacobians. It's a simpler, more reliable way to keep track of the derivatives. Draw a picture. Often the trickiest part of such calculat
multivariate transformation of random variable I have two suggestions: Use differential algebra instead of Jacobians. It's a simpler, more reliable way to keep track of the derivatives. Draw a picture. Often the trickiest part of such calculations is to determine what the domain of the new variables is. Pictures help. Details and supporting code follow. Two things need to be found: the probability element of $(U,V)$ and the domain (set of possible values) of $(U,V)$. (The reason for choosing to write the distribution in terms of probability density, rather than a probability function, is that the probability function is somewhat messy to describe.) The probability element Using differential algebra it is straightforward to compute that The probability element of the uniform distribution of $(X,Y)$ is $$f_{XY}(x,y)dx dy = \frac{1}{2}dx dy = \frac{1}{2}|dx\wedge dy|.$$ Computing the differentials of $u = xy$ and $v=y$, we easily obtain $$du = y\,dx + x\,dy;\ dv = dy,$$ whence $$du \wedge dv = (y\,dx + x\,dy)\wedge dy =y\,dx\wedge dy + x\,dy\wedge dy= y\,dx\wedge dy.$$ Comparing the two results, and recalling that $y = v$, shows immediately that $$f_{UV}(u,v)du dv = \frac{1}{2v} |du \wedge dv| = \frac{1}{2v} du dv.$$ The domain Since $-1 \le X \le 1$ and $0 \le Y \le 1$, it follows that $0 \le Y = V \le 1$ and $-1 \le X = U/V \le 1$, whence $|U| \le V.$ The transformation from $(X,Y)$ to $(U,V)$ can be visualized by drawing a large number of random values from $(X,Y)$ and coloring them according to $X$ and $Y$. The figure uses hue to represent $X$ and lightness to represent $Y$, with lighter points indicating smaller values of $Y$. On the left the points are plotted in $(X,Y)$ coordinates while on the right the same points are plotted in $(U,V)$ coordinates: The points are squeezed towards the vertical axis, in proportion to their height above the horizontal axis. Each vertical line segment $X = x, 0 \le Y \le 1,$ is mapped to a radial line segment $V = \frac{1}{x}U, 0 \le V \le 1.$ Putting them together Consequently, the probability density function for $(U,V)$ can be written in terms of indicator functions for its domain as $$f_{UV}(u,v) = \frac{1}{2v} I(0 \le v \le 1) I(|u| \le v) du\,dv.$$ Code As a check, we may integrate $f_{UV}$ over $\mathbb{R}^2$. It would be done in (say) Mathematica as $$\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\frac{\text{Boole}[0\leq v\leq 1] \text{Boole}[\left| u\right| \leq v]}{2 v}dvdu$$ which, in response to this command, returns $1$ as the answer. Along with the evident fact that $f_{UV}$ is never negative, that verifies this actually is a probability density function. The figure was drawn in R 3.1.3: n <- 5e4 x <- runif(n, -1, 1) y <- runif(n) u <- x*y v <- y par(mfrow=c(1,2)) colors <- hsv((x+1)/2, .8, 1 - 0.8*y, .1) plot(x, y, pch=16, col=colors, cex=3/8, asp=1) plot(u, v, pch=16, col=colors, cex=1/4, asp=1)
multivariate transformation of random variable I have two suggestions: Use differential algebra instead of Jacobians. It's a simpler, more reliable way to keep track of the derivatives. Draw a picture. Often the trickiest part of such calculat
47,264
What statistics can I use to combine multiple rankings in order to create a final ranking?
Let $r_{g,i}$ be the rank of gene $g$ in ranking $i$ (out of a total of $k$ rankings). Then a statistic which pools these ranks together is the rank product statistic, which is just the geometric mean of the ranks: $$RP(g) = \left(\prod_{i=1}^k r_{g,i}\right)^{\frac{1}{k}}$$ The rank product statistic was mainly developed to pool together independent replicates, but I think it should work nicely for your use case as well, since you claim that the different scores are independent. There also exists a R package, which implements this statistic (as well as calculates significance/p-values), though I have never used it.
What statistics can I use to combine multiple rankings in order to create a final ranking?
Let $r_{g,i}$ be the rank of gene $g$ in ranking $i$ (out of a total of $k$ rankings). Then a statistic which pools these ranks together is the rank product statistic, which is just the geometric mean
What statistics can I use to combine multiple rankings in order to create a final ranking? Let $r_{g,i}$ be the rank of gene $g$ in ranking $i$ (out of a total of $k$ rankings). Then a statistic which pools these ranks together is the rank product statistic, which is just the geometric mean of the ranks: $$RP(g) = \left(\prod_{i=1}^k r_{g,i}\right)^{\frac{1}{k}}$$ The rank product statistic was mainly developed to pool together independent replicates, but I think it should work nicely for your use case as well, since you claim that the different scores are independent. There also exists a R package, which implements this statistic (as well as calculates significance/p-values), though I have never used it.
What statistics can I use to combine multiple rankings in order to create a final ranking? Let $r_{g,i}$ be the rank of gene $g$ in ranking $i$ (out of a total of $k$ rankings). Then a statistic which pools these ranks together is the rank product statistic, which is just the geometric mean
47,265
Interpreting logistic regression with an interaction and a quadratic term?
The only model that would really make sense is $$Y = \beta_{0} + \beta_{1}X + \beta_{2}X^{2} + \beta_{3}(Z=b) + \beta_{4}(Z=c) + \beta_{5}X(Z=b) + \beta_{6}X(Z=c) + \beta_{7}X^{2}(Z=b) + \beta_{8}X^{2}(Z=c)$$ where $(Z=k)$ denotes 1 if $Z=k$ and 0 otherwise. In this model the test for interaction is $H_{0}: \beta_{5}\dots \beta_{8} = 0$. The $X$-effect depends on $Z$ and on the starting point for $X$ since $X$ is nonlinear. To get the effect of $X$ going from $u$ to $v$ when $Z=k$ write down the special case of the above formula when $X=v, Z=k$ then evaluate it when $X=u, Z=k$ and subtract term by term. What is left is the formula for that $X$ effect at $Z=k$ which you estimate by plugging in the the $\beta$ estimates from the model fit. Anti-log and you have the odds ratio. When $k=a$ the result is $\beta_{2}(v^{2} - u^{2}) + \beta_{1}(v - u)$. Note that it is not common that $v-u = 1$, i.e., to get a meaningful $X$ effect you might use the quartiles of $X$ and not assume that a 1-unit change is that meaningful for the scale of $X$. Note also that there is no such thing as the $X$ effect when $Z$ is not set. Using the R rms package one can get any contrast of interest easily. To get the above use this example for comparing 30 year olds with 20 year olds for the first race group, where race has 3 categories a, b, c: require(rms) f <- lrm(y ~ pol(age, 2) * race) # quadratic with interaction contrast(f, list(age=30, race='a'), list(age=20, race='a'))
Interpreting logistic regression with an interaction and a quadratic term?
The only model that would really make sense is $$Y = \beta_{0} + \beta_{1}X + \beta_{2}X^{2} + \beta_{3}(Z=b) + \beta_{4}(Z=c) + \beta_{5}X(Z=b) + \beta_{6}X(Z=c) + \beta_{7}X^{2}(Z=b) + \beta_{8}X^{
Interpreting logistic regression with an interaction and a quadratic term? The only model that would really make sense is $$Y = \beta_{0} + \beta_{1}X + \beta_{2}X^{2} + \beta_{3}(Z=b) + \beta_{4}(Z=c) + \beta_{5}X(Z=b) + \beta_{6}X(Z=c) + \beta_{7}X^{2}(Z=b) + \beta_{8}X^{2}(Z=c)$$ where $(Z=k)$ denotes 1 if $Z=k$ and 0 otherwise. In this model the test for interaction is $H_{0}: \beta_{5}\dots \beta_{8} = 0$. The $X$-effect depends on $Z$ and on the starting point for $X$ since $X$ is nonlinear. To get the effect of $X$ going from $u$ to $v$ when $Z=k$ write down the special case of the above formula when $X=v, Z=k$ then evaluate it when $X=u, Z=k$ and subtract term by term. What is left is the formula for that $X$ effect at $Z=k$ which you estimate by plugging in the the $\beta$ estimates from the model fit. Anti-log and you have the odds ratio. When $k=a$ the result is $\beta_{2}(v^{2} - u^{2}) + \beta_{1}(v - u)$. Note that it is not common that $v-u = 1$, i.e., to get a meaningful $X$ effect you might use the quartiles of $X$ and not assume that a 1-unit change is that meaningful for the scale of $X$. Note also that there is no such thing as the $X$ effect when $Z$ is not set. Using the R rms package one can get any contrast of interest easily. To get the above use this example for comparing 30 year olds with 20 year olds for the first race group, where race has 3 categories a, b, c: require(rms) f <- lrm(y ~ pol(age, 2) * race) # quadratic with interaction contrast(f, list(age=30, race='a'), list(age=20, race='a'))
Interpreting logistic regression with an interaction and a quadratic term? The only model that would really make sense is $$Y = \beta_{0} + \beta_{1}X + \beta_{2}X^{2} + \beta_{3}(Z=b) + \beta_{4}(Z=c) + \beta_{5}X(Z=b) + \beta_{6}X(Z=c) + \beta_{7}X^{2}(Z=b) + \beta_{8}X^{
47,266
Sum of Gaussian mixture and Gaussian scale mixture
Let $X$ has the mixture distribution with density $f(x)=\sum \pi_i f_i(x)$ and $Y$ the mixture distribition with density $g(x) = \sum \phi_i g_i(x)$, and suppose $X$ and $Y$ are independent. A useful tool for analyzing distribution of sums of independent random variables is the moment generating function (look it upon wikipedia if you didn't see it yet). That is given by $\DeclareMathOperator{\E}{E} M_X(t) = \E e^{tX}$. Then the moment generating function of $X+Y$ is the product $M_X(t) M_Y(t)$. Let the moment generating functions for $X$ mixture component $i$ be $M_i$, for $Y$ mixture component $j$ be $G_j$. Then, by linearity of the expectation operator, we have $$ M_X(t) = \E e^{tX} = \int e^{tx} f(x)\; dx \\ = \int e^{tx} \sum_i \pi_i f_i(x)\; dx \\ = \sum_i \pi_i M_i(t) $$ and likewise for $Y$ $G_Y(t) = \sum_j G_j(t)$ and then the moment generating function for $X+Y$ is $$ M_X(t)G_Y(t)=\sum_i \pi_i M_i(t) \cdot \sum_j \phi_j G_j(t) \\ = \sum_i \sum_j \pi_i \phi_j M_i(t) G_j(t) $$ so the distribution of the sum is a new mixture distribution with $nm$ component (where $X$ has $n$ components, $Y$ has $m$ components), the weights are the products of the old weights $\pi_i \phi_j$, and the distribution of the component $(ij)$ is the distribution of the sum of independent random variables $X_i+Y_j$. In your case all of those will be normal distributions, but I leave for you to work out the details. Observe that only the very last step of the argument (that left for you) pends on thse being a normal mixture. So what we have shown is a quite gneral result about the istribution of sums of random variables, each one with a mixture distribution.
Sum of Gaussian mixture and Gaussian scale mixture
Let $X$ has the mixture distribution with density $f(x)=\sum \pi_i f_i(x)$ and $Y$ the mixture distribition with density $g(x) = \sum \phi_i g_i(x)$, and suppose $X$ and $Y$ are independent. A useful
Sum of Gaussian mixture and Gaussian scale mixture Let $X$ has the mixture distribution with density $f(x)=\sum \pi_i f_i(x)$ and $Y$ the mixture distribition with density $g(x) = \sum \phi_i g_i(x)$, and suppose $X$ and $Y$ are independent. A useful tool for analyzing distribution of sums of independent random variables is the moment generating function (look it upon wikipedia if you didn't see it yet). That is given by $\DeclareMathOperator{\E}{E} M_X(t) = \E e^{tX}$. Then the moment generating function of $X+Y$ is the product $M_X(t) M_Y(t)$. Let the moment generating functions for $X$ mixture component $i$ be $M_i$, for $Y$ mixture component $j$ be $G_j$. Then, by linearity of the expectation operator, we have $$ M_X(t) = \E e^{tX} = \int e^{tx} f(x)\; dx \\ = \int e^{tx} \sum_i \pi_i f_i(x)\; dx \\ = \sum_i \pi_i M_i(t) $$ and likewise for $Y$ $G_Y(t) = \sum_j G_j(t)$ and then the moment generating function for $X+Y$ is $$ M_X(t)G_Y(t)=\sum_i \pi_i M_i(t) \cdot \sum_j \phi_j G_j(t) \\ = \sum_i \sum_j \pi_i \phi_j M_i(t) G_j(t) $$ so the distribution of the sum is a new mixture distribution with $nm$ component (where $X$ has $n$ components, $Y$ has $m$ components), the weights are the products of the old weights $\pi_i \phi_j$, and the distribution of the component $(ij)$ is the distribution of the sum of independent random variables $X_i+Y_j$. In your case all of those will be normal distributions, but I leave for you to work out the details. Observe that only the very last step of the argument (that left for you) pends on thse being a normal mixture. So what we have shown is a quite gneral result about the istribution of sums of random variables, each one with a mixture distribution.
Sum of Gaussian mixture and Gaussian scale mixture Let $X$ has the mixture distribution with density $f(x)=\sum \pi_i f_i(x)$ and $Y$ the mixture distribition with density $g(x) = \sum \phi_i g_i(x)$, and suppose $X$ and $Y$ are independent. A useful
47,267
Sum of Gaussian mixture and Gaussian scale mixture
If I understand your notation you are asking about the distribution of $Y$ when $Y = X + Z$ where $X \sim \mathcal N(a,b)$, $Z \sim \mathcal N(c,d)$. In this case $Y$ is Gaussian if $Z$ and $X$ are independent or jointly normal, with mean $a+b$ and a covariance matrix dependent on the relationship between $X$ and $Z$. Using the word mixture to describe the above arrangement will lead to confusion.
Sum of Gaussian mixture and Gaussian scale mixture
If I understand your notation you are asking about the distribution of $Y$ when $Y = X + Z$ where $X \sim \mathcal N(a,b)$, $Z \sim \mathcal N(c,d)$. In this case $Y$ is Gaussian if $Z$ and $X$ are i
Sum of Gaussian mixture and Gaussian scale mixture If I understand your notation you are asking about the distribution of $Y$ when $Y = X + Z$ where $X \sim \mathcal N(a,b)$, $Z \sim \mathcal N(c,d)$. In this case $Y$ is Gaussian if $Z$ and $X$ are independent or jointly normal, with mean $a+b$ and a covariance matrix dependent on the relationship between $X$ and $Z$. Using the word mixture to describe the above arrangement will lead to confusion.
Sum of Gaussian mixture and Gaussian scale mixture If I understand your notation you are asking about the distribution of $Y$ when $Y = X + Z$ where $X \sim \mathcal N(a,b)$, $Z \sim \mathcal N(c,d)$. In this case $Y$ is Gaussian if $Z$ and $X$ are i
47,268
Generating a sample from Epanechnikov's kernel
Consider this alternative description of the same algorithm: Generate iid $X_1, X_2, X_3$ with Uniform$(0,1)$ distributions. Select one of the two smallest of the $X_i$ at random, with equal probability. Call this value $X$. Randomly negate $X$ with probability $1/2$. Parts (1) and (3) reflect the fact that a Uniform$(-1,1)$ variate is the random negation of a Uniform$(0,1)$ variate. Part (2) is a restatement of step (2) in the question. It comes down to computing the distribution of $X$. To this end, let $0 \le t \le 1$. The event that $X \le t$ decomposes into two disjoint possibilities: At least two of the $X_i$ lie in $[0, t]$, guaranteeing that $X$ (which must be among them) will lie in $[0, t]$. This is a binomial probability given by $$\binom{3}{2}t^2(1-t) + \binom{3}{3}t^3 = t^2(3-2t).$$ Exactly one of the $X_i$ lies in $[0, t]$ and it is the one randomly chosen. The random choice multiplies the chance (another binomial probability) by $1/2$, giving $$\binom{3}{1}t(1-t)^2 \times \frac{1}{2} = \frac{3}{2}t(1-t)^2.$$ Therefore the distribution function is $$F(t) = t^2(3-2t) + \frac{3}{2}t(1-t)^2 = \frac{3}{2} t - \frac{1}{2}t^3,$$ whence the density function is $$f(t) = F^\prime(t) = \frac{3}{2}(1 - t^2).$$ The blue shaded area represents $f$ while the red shaded area shows how it is extended symmetrically about $0$ to define a distribution supported on the interval $[-1,1]$ with density $f_e = \frac{1}{2}f$. Extending $f$ to the domain $[-1,1]$ by symmetry (which is what part (3) does) will not change its functional form (which is already symmetric about $0$, since $(-t)^2 = t^2$) but must halve the height to maintain its normalization, whence $$f_e(t) = \frac{1}{2}\left(\frac{3}{2}(1 - t^2)\right) = \frac{3}{4}(1-t^2).$$ By the way, a simpler way to generate such a sample is to take the median of three iid Uniform$(0,2)$ variates. Here's R code: n <- 1e5 x <- apply(matrix(runif(3*n, -1, 1), 3), 2, median) (It takes two or three seconds to generate 100,000 values.) Comparing the histogram of this sample to the kernel confirms its accuracy:
Generating a sample from Epanechnikov's kernel
Consider this alternative description of the same algorithm: Generate iid $X_1, X_2, X_3$ with Uniform$(0,1)$ distributions. Select one of the two smallest of the $X_i$ at random, with equal probabil
Generating a sample from Epanechnikov's kernel Consider this alternative description of the same algorithm: Generate iid $X_1, X_2, X_3$ with Uniform$(0,1)$ distributions. Select one of the two smallest of the $X_i$ at random, with equal probability. Call this value $X$. Randomly negate $X$ with probability $1/2$. Parts (1) and (3) reflect the fact that a Uniform$(-1,1)$ variate is the random negation of a Uniform$(0,1)$ variate. Part (2) is a restatement of step (2) in the question. It comes down to computing the distribution of $X$. To this end, let $0 \le t \le 1$. The event that $X \le t$ decomposes into two disjoint possibilities: At least two of the $X_i$ lie in $[0, t]$, guaranteeing that $X$ (which must be among them) will lie in $[0, t]$. This is a binomial probability given by $$\binom{3}{2}t^2(1-t) + \binom{3}{3}t^3 = t^2(3-2t).$$ Exactly one of the $X_i$ lies in $[0, t]$ and it is the one randomly chosen. The random choice multiplies the chance (another binomial probability) by $1/2$, giving $$\binom{3}{1}t(1-t)^2 \times \frac{1}{2} = \frac{3}{2}t(1-t)^2.$$ Therefore the distribution function is $$F(t) = t^2(3-2t) + \frac{3}{2}t(1-t)^2 = \frac{3}{2} t - \frac{1}{2}t^3,$$ whence the density function is $$f(t) = F^\prime(t) = \frac{3}{2}(1 - t^2).$$ The blue shaded area represents $f$ while the red shaded area shows how it is extended symmetrically about $0$ to define a distribution supported on the interval $[-1,1]$ with density $f_e = \frac{1}{2}f$. Extending $f$ to the domain $[-1,1]$ by symmetry (which is what part (3) does) will not change its functional form (which is already symmetric about $0$, since $(-t)^2 = t^2$) but must halve the height to maintain its normalization, whence $$f_e(t) = \frac{1}{2}\left(\frac{3}{2}(1 - t^2)\right) = \frac{3}{4}(1-t^2).$$ By the way, a simpler way to generate such a sample is to take the median of three iid Uniform$(0,2)$ variates. Here's R code: n <- 1e5 x <- apply(matrix(runif(3*n, -1, 1), 3), 2, median) (It takes two or three seconds to generate 100,000 values.) Comparing the histogram of this sample to the kernel confirms its accuracy:
Generating a sample from Epanechnikov's kernel Consider this alternative description of the same algorithm: Generate iid $X_1, X_2, X_3$ with Uniform$(0,1)$ distributions. Select one of the two smallest of the $X_i$ at random, with equal probabil
47,269
Generating a sample from Epanechnikov's kernel
Although it only is a too long comment that comes a day late and a dollar short, my explanation, which is highly related to the more detailed and to the point answer by whuber, is that the outcome of Devroye's algorithm with those three uniforms is indeed distributed from the mixture of the distributions of the first order statistic and of the second order statistic for three uniforms on (0,1), since it is not the third order statistic,$$f^*(u)=\frac{1}{2}f_{(1:3)}(u)+\frac{1}{2}f_{(2:3)}(u)$$Given that the generic density for an order statistic is$$f_{(k:n)}(x)=(k-1)!(n-k-1)!\,F(x)^{k-1}\,(1-F(x))^{n-k-1}(x)\,f(x),$$we get$$f^*(u)=\frac{1}{2} 3(1-x)^2 + \frac{1}{2} 6x(1-x)=\frac{3}{2}-\frac{3x^2}{2}$$
Generating a sample from Epanechnikov's kernel
Although it only is a too long comment that comes a day late and a dollar short, my explanation, which is highly related to the more detailed and to the point answer by whuber, is that the outcome of
Generating a sample from Epanechnikov's kernel Although it only is a too long comment that comes a day late and a dollar short, my explanation, which is highly related to the more detailed and to the point answer by whuber, is that the outcome of Devroye's algorithm with those three uniforms is indeed distributed from the mixture of the distributions of the first order statistic and of the second order statistic for three uniforms on (0,1), since it is not the third order statistic,$$f^*(u)=\frac{1}{2}f_{(1:3)}(u)+\frac{1}{2}f_{(2:3)}(u)$$Given that the generic density for an order statistic is$$f_{(k:n)}(x)=(k-1)!(n-k-1)!\,F(x)^{k-1}\,(1-F(x))^{n-k-1}(x)\,f(x),$$we get$$f^*(u)=\frac{1}{2} 3(1-x)^2 + \frac{1}{2} 6x(1-x)=\frac{3}{2}-\frac{3x^2}{2}$$
Generating a sample from Epanechnikov's kernel Although it only is a too long comment that comes a day late and a dollar short, my explanation, which is highly related to the more detailed and to the point answer by whuber, is that the outcome of
47,270
How to get the standard error of linear regression parameters?
Hint: Write $$\widehat{\beta_1}= \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i $$ and you can check that these two expressions are equivalent, as the sum of mean deviations is zero. Since we are treating the predictors as fixed, you can use the properties of the variance to get what you want. Now for the intercept, again using the standard rules of variance, we have $$Var\left\{\widehat{\beta_0}\right\}=Var\left\{\bar{y} \right\}+\bar{x}^2 Var\left\{ \widehat{\beta}_1 \right\}-2\bar{x} Cov\left\{\bar{y},\widehat{\beta}_1 \right\}$$ But now note that $$Cov\left\{\bar{y}. \widehat{\beta}_1\right\}=Cov\left\{\frac{1}{n}\sum_{i=1}^n y_i, \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i \right\} $$ and since the $y_i$s are independent this reduces to zero. I leave to you the details of this computation. Thus the variance of $\widehat{\beta}_0$ is the sum of the first two components and if you plug in everything, you should get what you are looking for. Hope this helps.
How to get the standard error of linear regression parameters?
Hint: Write $$\widehat{\beta_1}= \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i $$ and you can check that these two expressions are equivalent, as the sum
How to get the standard error of linear regression parameters? Hint: Write $$\widehat{\beta_1}= \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i $$ and you can check that these two expressions are equivalent, as the sum of mean deviations is zero. Since we are treating the predictors as fixed, you can use the properties of the variance to get what you want. Now for the intercept, again using the standard rules of variance, we have $$Var\left\{\widehat{\beta_0}\right\}=Var\left\{\bar{y} \right\}+\bar{x}^2 Var\left\{ \widehat{\beta}_1 \right\}-2\bar{x} Cov\left\{\bar{y},\widehat{\beta}_1 \right\}$$ But now note that $$Cov\left\{\bar{y}. \widehat{\beta}_1\right\}=Cov\left\{\frac{1}{n}\sum_{i=1}^n y_i, \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i \right\} $$ and since the $y_i$s are independent this reduces to zero. I leave to you the details of this computation. Thus the variance of $\widehat{\beta}_0$ is the sum of the first two components and if you plug in everything, you should get what you are looking for. Hope this helps.
How to get the standard error of linear regression parameters? Hint: Write $$\widehat{\beta_1}= \frac{\sum_{i=1}^n \left( x_i-\bar{x} \right)}{\sum_{i=1}^n \left(x_i-\bar{x} \right)^2} y_i $$ and you can check that these two expressions are equivalent, as the sum
47,271
How to get the standard error of linear regression parameters?
The long algebraic manipulations involved in standard demonstrations are bothersome. There ought to be a demonstration that is simple, direct, and provides insight into what the terms in the formulas mean. By "simple" I will allow liberal use of substitution in formulas and application of the most straightforward algebraic reductions, along with solving linear equations in one unknown. Even square roots are to be avoided. I also count as simple the basic manipulations of variances and covariances that go under the concept of bilinearity. Sequences of simple manipulations that one can easily make mentally are placed together on single lines below. Neither variance calculation takes more than one line. One way to accomplish this simplification employs a useful statistical principle: choose suitable units of measurement adapted to the data. Because we posit a specific way in which $y$ depends on $x,$ let's focus on how to measure $x.$ A good unit of measurement of the $x_i$ is one that standardizes them. This means we will want to write $$x_i = \sigma_x \xi_i + \bar x$$ where $\bar x$ is the usual arithmetic mean of the $x_i$ and $\sigma_x$ is their standard deviation (not an estimate!) defined by $$\sigma_x^2 = \frac{1}{n}\sum_{i=1}^n \left(x_i - \bar x\right)^2.$$ In these units, the sum of the $\xi_i$ is zero and the sum of their squares is $n.$ The model is $$y_i = \beta_0 + \beta_1 x_i \ =\ (\beta_0 + \beta_1 \bar x) + (\beta_1 \sigma_x)\xi_i + \varepsilon_i.\tag{1}$$ This says that in the new units the slope is $\beta_1 \sigma_x$ and the intercept is $\beta_0 + \beta_1 \bar x.$ Variance of the slope estimate The Ordinary Least Squares estimate of the slope in these new units is simply the average product of the $\xi_i$ and $y_i,$ $$\hat\beta_1\,\sigma_x = \widehat{\beta_1\sigma_x} = \frac{1}{n}\sum_{i=1}^n \xi_i y_i = \sum_{i=1}^n \frac{\xi_i}{n} y_i.\tag{2}$$ To find its variance, look at the model $(1):$ the only parts of this that are random variables are the $\varepsilon_i$ terms. In $(2)$ they are multiplied by $\xi/n.$ Assuming these random variables are uncorrelated and each has a variance $\sigma^2,$ it is immediate that $$\sigma_x^2 \operatorname{Var}\left(\hat\beta_1\right) = \operatorname{Var}\left(\widehat{\beta_1\sigma_x}\right) = \sum_{i=1}^n \operatorname{Var}\left(\frac{\xi_i}{n}y_i\right) = \sum_{i=1}^n \left(\frac{\xi_i}{n}\right)^2 \sigma^2 = \frac{1}{n}\sigma^2.$$ (The last simplification equated the sum of squares of the $\xi$ with $n,$ as noted before.) The solution is just as simple, $$ \operatorname{Var}\left(\hat\beta_1\right) = \color{Red}{\frac{1}{\sigma_x^2}\left(\frac{1}{n}\sigma^2\right)} = \frac{\sigma^2}{\sum_{i=1}^n (x_i-\bar x)^2},$$ as claimed. However, it is the middle expression that is interpretable. It is the product of three factors: The factor $\frac{1}{\sigma_x^2}$ is due to the units of measurement of the $x_i.$ The factor $\frac{1}{n}$ is the reduction in variance achieved by averaging $n$ uncorrelated random values in equation $(2).$ The factor $\sigma^2$ is the common variance of all those deviations. Let us note in passing that the slope estimate is uncorrelated with the mean of the $y$ values. This follows from an easy calculation of the covariance, $$\operatorname{Cov}\left(\hat\beta_1, \bar y\right) =\operatorname{Cov}\left(\sum_{i=1}^n \frac{\xi_i}{n\sigma_x} y_i, \frac{1}{n}\sum_{j=1}^n y_j\right) = \left(\frac{1}{n\sigma_x}\right)\left(\frac{1}{n}\right)\sum_{i=1}^n \xi_i \sigma^2 = 0.$$ The reduction from a double sum to a single sum is due to the zero correlation of $y_i$ and $y_j$ for $i\ne j$ (as well as the constant variance of the $\varepsilon_i$) and the final simplification is due to the sum-to-zero identity of the standardized variables $\xi_i.$ Variance of the intercept estimate The estimated intercept when the explanatory variables $x_i$ are centered at zero is just the mean of the $y_i.$ Upon recentering--which subtracts $\bar x$ from all $x$ values--the estimate is thereby changed by $\hat\beta_1$ times $-\bar x.$ Thus, $$\hat \beta_0 = \frac{1}{n}\sum_{i=1}^n y_i - \bar x\hat\beta_1.$$ Taking variances (and exploiting the zero correlation of the two terms) gives $$\begin{aligned} \operatorname{Var}\left(\hat \beta_0\right) &= \operatorname{Var}\left(\frac{1}{n}\sum_{i=1}^n y_i\right) + \operatorname{Var}\left(-\bar x\hat\beta_1\right) = \color{Red}{\left(\frac{1}{n}\right)^2\left(n\sigma^2\right) + \left(-\bar x\right)^2 \operatorname{Var}\left(\hat\beta_1\right)}\\&= \sigma^2\left[\frac{1}{n} + \frac{\left(\bar x\right)^2}{n\sigma_x^2}\right]. \end{aligned}$$ The unsimplified result (on the top line) exposes a statistical interpretation: The result, as before, is proportional to the common variance of all the error terms $\varepsilon_i.$ The proportionality is a sum of two pieces. The $1/n$ piece comes from averaging the $y_i$ to estimate the intercept for standardized $x$ values. The other piece accounts for shifting the $x$ values by the amount $-\bar x$ to center them. It, in turn, is the product of two quantities: the factor $(-\bar x)^2$ accounts for that shift (squared, because it appears in a variance) while the factor $1/(n\sigma_x^2)$ accounts for how the estimated slope translates that into a shift in $y.$
How to get the standard error of linear regression parameters?
The long algebraic manipulations involved in standard demonstrations are bothersome. There ought to be a demonstration that is simple, direct, and provides insight into what the terms in the formulas
How to get the standard error of linear regression parameters? The long algebraic manipulations involved in standard demonstrations are bothersome. There ought to be a demonstration that is simple, direct, and provides insight into what the terms in the formulas mean. By "simple" I will allow liberal use of substitution in formulas and application of the most straightforward algebraic reductions, along with solving linear equations in one unknown. Even square roots are to be avoided. I also count as simple the basic manipulations of variances and covariances that go under the concept of bilinearity. Sequences of simple manipulations that one can easily make mentally are placed together on single lines below. Neither variance calculation takes more than one line. One way to accomplish this simplification employs a useful statistical principle: choose suitable units of measurement adapted to the data. Because we posit a specific way in which $y$ depends on $x,$ let's focus on how to measure $x.$ A good unit of measurement of the $x_i$ is one that standardizes them. This means we will want to write $$x_i = \sigma_x \xi_i + \bar x$$ where $\bar x$ is the usual arithmetic mean of the $x_i$ and $\sigma_x$ is their standard deviation (not an estimate!) defined by $$\sigma_x^2 = \frac{1}{n}\sum_{i=1}^n \left(x_i - \bar x\right)^2.$$ In these units, the sum of the $\xi_i$ is zero and the sum of their squares is $n.$ The model is $$y_i = \beta_0 + \beta_1 x_i \ =\ (\beta_0 + \beta_1 \bar x) + (\beta_1 \sigma_x)\xi_i + \varepsilon_i.\tag{1}$$ This says that in the new units the slope is $\beta_1 \sigma_x$ and the intercept is $\beta_0 + \beta_1 \bar x.$ Variance of the slope estimate The Ordinary Least Squares estimate of the slope in these new units is simply the average product of the $\xi_i$ and $y_i,$ $$\hat\beta_1\,\sigma_x = \widehat{\beta_1\sigma_x} = \frac{1}{n}\sum_{i=1}^n \xi_i y_i = \sum_{i=1}^n \frac{\xi_i}{n} y_i.\tag{2}$$ To find its variance, look at the model $(1):$ the only parts of this that are random variables are the $\varepsilon_i$ terms. In $(2)$ they are multiplied by $\xi/n.$ Assuming these random variables are uncorrelated and each has a variance $\sigma^2,$ it is immediate that $$\sigma_x^2 \operatorname{Var}\left(\hat\beta_1\right) = \operatorname{Var}\left(\widehat{\beta_1\sigma_x}\right) = \sum_{i=1}^n \operatorname{Var}\left(\frac{\xi_i}{n}y_i\right) = \sum_{i=1}^n \left(\frac{\xi_i}{n}\right)^2 \sigma^2 = \frac{1}{n}\sigma^2.$$ (The last simplification equated the sum of squares of the $\xi$ with $n,$ as noted before.) The solution is just as simple, $$ \operatorname{Var}\left(\hat\beta_1\right) = \color{Red}{\frac{1}{\sigma_x^2}\left(\frac{1}{n}\sigma^2\right)} = \frac{\sigma^2}{\sum_{i=1}^n (x_i-\bar x)^2},$$ as claimed. However, it is the middle expression that is interpretable. It is the product of three factors: The factor $\frac{1}{\sigma_x^2}$ is due to the units of measurement of the $x_i.$ The factor $\frac{1}{n}$ is the reduction in variance achieved by averaging $n$ uncorrelated random values in equation $(2).$ The factor $\sigma^2$ is the common variance of all those deviations. Let us note in passing that the slope estimate is uncorrelated with the mean of the $y$ values. This follows from an easy calculation of the covariance, $$\operatorname{Cov}\left(\hat\beta_1, \bar y\right) =\operatorname{Cov}\left(\sum_{i=1}^n \frac{\xi_i}{n\sigma_x} y_i, \frac{1}{n}\sum_{j=1}^n y_j\right) = \left(\frac{1}{n\sigma_x}\right)\left(\frac{1}{n}\right)\sum_{i=1}^n \xi_i \sigma^2 = 0.$$ The reduction from a double sum to a single sum is due to the zero correlation of $y_i$ and $y_j$ for $i\ne j$ (as well as the constant variance of the $\varepsilon_i$) and the final simplification is due to the sum-to-zero identity of the standardized variables $\xi_i.$ Variance of the intercept estimate The estimated intercept when the explanatory variables $x_i$ are centered at zero is just the mean of the $y_i.$ Upon recentering--which subtracts $\bar x$ from all $x$ values--the estimate is thereby changed by $\hat\beta_1$ times $-\bar x.$ Thus, $$\hat \beta_0 = \frac{1}{n}\sum_{i=1}^n y_i - \bar x\hat\beta_1.$$ Taking variances (and exploiting the zero correlation of the two terms) gives $$\begin{aligned} \operatorname{Var}\left(\hat \beta_0\right) &= \operatorname{Var}\left(\frac{1}{n}\sum_{i=1}^n y_i\right) + \operatorname{Var}\left(-\bar x\hat\beta_1\right) = \color{Red}{\left(\frac{1}{n}\right)^2\left(n\sigma^2\right) + \left(-\bar x\right)^2 \operatorname{Var}\left(\hat\beta_1\right)}\\&= \sigma^2\left[\frac{1}{n} + \frac{\left(\bar x\right)^2}{n\sigma_x^2}\right]. \end{aligned}$$ The unsimplified result (on the top line) exposes a statistical interpretation: The result, as before, is proportional to the common variance of all the error terms $\varepsilon_i.$ The proportionality is a sum of two pieces. The $1/n$ piece comes from averaging the $y_i$ to estimate the intercept for standardized $x$ values. The other piece accounts for shifting the $x$ values by the amount $-\bar x$ to center them. It, in turn, is the product of two quantities: the factor $(-\bar x)^2$ accounts for that shift (squared, because it appears in a variance) while the factor $1/(n\sigma_x^2)$ accounts for how the estimated slope translates that into a shift in $y.$
How to get the standard error of linear regression parameters? The long algebraic manipulations involved in standard demonstrations are bothersome. There ought to be a demonstration that is simple, direct, and provides insight into what the terms in the formulas
47,272
How to get the standard error of linear regression parameters?
The principle for derivation below The estimators $\beta_0$ and $\beta_1$ are linear estimators. That means that you can write it as a weighted sum of the observations $y_i$. $$\hat\beta_ 0 = \sum b_{0i} y_i\\\hat\beta_ 1 = \sum b_{1i} y_i$$ As a consequence, we see that the sampling distribution of the estimators corresponds to the distribution of the sum of variables $y_i$. If we assume that the $y_i$ are independently distributed and with variance $\sigma^2$ then the variance of the estimators will be $$\begin{array}{} \text{var}(\hat\beta_0) &=& \sum (b_{0i})^2 \text{var}\left(y_i\right) &=& \sigma^2 \sum (b_{0i})^2\\ \text{var}(\hat\beta_1) &=& \sum (b_{1i})^2 \text{var}\left(y_i\right) &=& \sigma^2 \sum (b_{1i})^2 \end{array}$$ Working it out The $b_{0i}$ and $b_{1i}$ can be found by rewriting your formulas for the estimators. $$\begin{array} \hat{\beta}_1 &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i - \overline{y})}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i) - \sum_{i = 1}^{n}(x_i - \overline{x})(\overline{y})}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i)}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=&\sum_{i = 1}^{n} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) (y_i)\\ \end{array} $$ and $$\begin{array} \hat{\beta}_0 &=& \overline{y} - \hat{\beta}_1 \overline{x}\\ &=& \frac{1}{n} \sum y_i - \sum_{i = 1}^{n} \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) (y_i)\\ &=& \sum_{i = 1}^{n} \left[\frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\right] (y_i)\\ \end{array} $$ Which gives $$\begin{array}\\ b_{0i} &=& \frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\\ b_{1i} &=& \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \end{array}$$ If you take the sum of squares of these $b_{0i}$ and $b_{1i}$ you get $$\begin{array}\\ \sum_{i=1}^n (b_{1i})^2 &=& \sum_{i=1}^n \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2\\ &=& \left( \dfrac{1}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \right)^2 \cdot \sum_{i=1}^n \left( x_i - \overline{x}\right)^2\\ &=& \dfrac{1}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \end{array}$$ and $$\begin{array}\\ \sum_{i=1}^n (b_{0i})^2 &=& \sum_{i=1}^n \left[ \frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\right]^2\\ &=& \sum_{i=1}^n \left[ \frac{1}{n^2} + \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 - 2 \frac{1}{n} \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) \right]\\ &=& \sum_{i=1}^n \left[ \frac{1}{n^2} + \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 \right]\\ &=& \sum_{i=1}^n \frac{1}{n^2} + \sum_{i=1}^n \left[ \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 \right]\\ &=& \frac{1}{n} + \dfrac{\overline{x}^2}{ \sum_{j = 1}^{n}(x_j - \overline{x})^2 } \end{array}$$
How to get the standard error of linear regression parameters?
The principle for derivation below The estimators $\beta_0$ and $\beta_1$ are linear estimators. That means that you can write it as a weighted sum of the observations $y_i$. $$\hat\beta_ 0 = \sum b_{
How to get the standard error of linear regression parameters? The principle for derivation below The estimators $\beta_0$ and $\beta_1$ are linear estimators. That means that you can write it as a weighted sum of the observations $y_i$. $$\hat\beta_ 0 = \sum b_{0i} y_i\\\hat\beta_ 1 = \sum b_{1i} y_i$$ As a consequence, we see that the sampling distribution of the estimators corresponds to the distribution of the sum of variables $y_i$. If we assume that the $y_i$ are independently distributed and with variance $\sigma^2$ then the variance of the estimators will be $$\begin{array}{} \text{var}(\hat\beta_0) &=& \sum (b_{0i})^2 \text{var}\left(y_i\right) &=& \sigma^2 \sum (b_{0i})^2\\ \text{var}(\hat\beta_1) &=& \sum (b_{1i})^2 \text{var}\left(y_i\right) &=& \sigma^2 \sum (b_{1i})^2 \end{array}$$ Working it out The $b_{0i}$ and $b_{1i}$ can be found by rewriting your formulas for the estimators. $$\begin{array} \hat{\beta}_1 &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i - \overline{y})}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i) - \sum_{i = 1}^{n}(x_i - \overline{x})(\overline{y})}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=& \dfrac{\sum_{i = 1}^{n}(x_i - \overline{x})(y_i)}{\sum_{i = 1}^{n}(x_i - \overline{x})^2}\\ &=&\sum_{i = 1}^{n} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) (y_i)\\ \end{array} $$ and $$\begin{array} \hat{\beta}_0 &=& \overline{y} - \hat{\beta}_1 \overline{x}\\ &=& \frac{1}{n} \sum y_i - \sum_{i = 1}^{n} \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) (y_i)\\ &=& \sum_{i = 1}^{n} \left[\frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\right] (y_i)\\ \end{array} $$ Which gives $$\begin{array}\\ b_{0i} &=& \frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\\ b_{1i} &=& \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \end{array}$$ If you take the sum of squares of these $b_{0i}$ and $b_{1i}$ you get $$\begin{array}\\ \sum_{i=1}^n (b_{1i})^2 &=& \sum_{i=1}^n \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2\\ &=& \left( \dfrac{1}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \right)^2 \cdot \sum_{i=1}^n \left( x_i - \overline{x}\right)^2\\ &=& \dfrac{1}{\sum_{j = 1}^{n}(x_j - \overline{x})^2} \end{array}$$ and $$\begin{array}\\ \sum_{i=1}^n (b_{0i})^2 &=& \sum_{i=1}^n \left[ \frac{1}{n} - \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)\right]^2\\ &=& \sum_{i=1}^n \left[ \frac{1}{n^2} + \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 - 2 \frac{1}{n} \overline{x} \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right) \right]\\ &=& \sum_{i=1}^n \left[ \frac{1}{n^2} + \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 \right]\\ &=& \sum_{i=1}^n \frac{1}{n^2} + \sum_{i=1}^n \left[ \overline{x}^2 \left( \dfrac{(x_i - \overline{x})}{\sum_{j = 1}^{n}(x_j - \overline{x})^2}\right)^2 \right]\\ &=& \frac{1}{n} + \dfrac{\overline{x}^2}{ \sum_{j = 1}^{n}(x_j - \overline{x})^2 } \end{array}$$
How to get the standard error of linear regression parameters? The principle for derivation below The estimators $\beta_0$ and $\beta_1$ are linear estimators. That means that you can write it as a weighted sum of the observations $y_i$. $$\hat\beta_ 0 = \sum b_{
47,273
How to use PCA for prediction?
It seems that you have 418 cases, divided into a training set of 318 cases and a test set of 100 cases. I'll answer your question and suggest a closely related but potentially better approach to your problem. As noted on the MATLAB help page, for PCR it's best if the predictors are both centered and scaled to unit variance so that differences in scales don't unduly weight the results. They didn't do that in their example, but if your predictors are on different scales then you might consider scaling in addition to centering. The code you adapted from that page apparently returns the regression to the original scales of both $x$ and $y$, according to how the plot on that page was obtained (although my memory of MATLAB syntax is too rusty to verify that directly). Replacing the $X$ in the last line of code with your matrix of test data should give you the predicted $y$ values for those test data. To verify, try using a small sample of your original data for $X$ and see if the predictions make sense. But PCR with a training set and a separate test set might not be the best approach to your problem. PCR picks the principal components that capture the most variance in the predictor variables, but not necessarily those most related to the response variable. The partial least squares approach illustrated on the same help page can be better related to outcomes. Also, the separation into training and test sets, if that's what you've done, doesn't efficiently use all the information in your data. Ridge regression, provided by the ridge function in MATLAB, is essentially PCR but with different weights placed on the components instead of the all-or-none selection in PCR. Large regression coefficients that don't help much with predicting outcomes are penalized. This helps bring the coefficients better in line with relations to the outcome variable and helps correct for overfitting. You can start with all of your data to set up the model (if my understanding of what you've done is correct), then use cross validation or bootstrapping to choose the penalty that minimizes prediction error.
How to use PCA for prediction?
It seems that you have 418 cases, divided into a training set of 318 cases and a test set of 100 cases. I'll answer your question and suggest a closely related but potentially better approach to your
How to use PCA for prediction? It seems that you have 418 cases, divided into a training set of 318 cases and a test set of 100 cases. I'll answer your question and suggest a closely related but potentially better approach to your problem. As noted on the MATLAB help page, for PCR it's best if the predictors are both centered and scaled to unit variance so that differences in scales don't unduly weight the results. They didn't do that in their example, but if your predictors are on different scales then you might consider scaling in addition to centering. The code you adapted from that page apparently returns the regression to the original scales of both $x$ and $y$, according to how the plot on that page was obtained (although my memory of MATLAB syntax is too rusty to verify that directly). Replacing the $X$ in the last line of code with your matrix of test data should give you the predicted $y$ values for those test data. To verify, try using a small sample of your original data for $X$ and see if the predictions make sense. But PCR with a training set and a separate test set might not be the best approach to your problem. PCR picks the principal components that capture the most variance in the predictor variables, but not necessarily those most related to the response variable. The partial least squares approach illustrated on the same help page can be better related to outcomes. Also, the separation into training and test sets, if that's what you've done, doesn't efficiently use all the information in your data. Ridge regression, provided by the ridge function in MATLAB, is essentially PCR but with different weights placed on the components instead of the all-or-none selection in PCR. Large regression coefficients that don't help much with predicting outcomes are penalized. This helps bring the coefficients better in line with relations to the outcome variable and helps correct for overfitting. You can start with all of your data to set up the model (if my understanding of what you've done is correct), then use cross validation or bootstrapping to choose the penalty that minimizes prediction error.
How to use PCA for prediction? It seems that you have 418 cases, divided into a training set of 318 cases and a test set of 100 cases. I'll answer your question and suggest a closely related but potentially better approach to your
47,274
How to use PCA for prediction?
Here are some ways to test whether your understanding of the calculations is correct: Take a few of the training cases and calculate the prediction as you think. Then compare with the fitted values from the help page. If you use the full PCA model (all loadings), the PCA performs only a rotation of the data. The predictions based on all scores should match the predictions by least squares regression on the original data. You can do the PCR in one or two steps: to find out whether your one-step prediction directly from original data to the fitted value is correct, compare it with the two step procedure of first calculating scores for the new data followed by predicting y from the scores. Note that if the PCA fitting routine centers (and possibly scales) the data, you need to do that with your new cases as well. And yes, if the regression is set up to predict y - mean (y), then the predicted values will be centered by the mean of the ys. You then need to center and possibly scale X by the center and scaling calculated on the training X, the same applies to y.
How to use PCA for prediction?
Here are some ways to test whether your understanding of the calculations is correct: Take a few of the training cases and calculate the prediction as you think. Then compare with the fitted values
How to use PCA for prediction? Here are some ways to test whether your understanding of the calculations is correct: Take a few of the training cases and calculate the prediction as you think. Then compare with the fitted values from the help page. If you use the full PCA model (all loadings), the PCA performs only a rotation of the data. The predictions based on all scores should match the predictions by least squares regression on the original data. You can do the PCR in one or two steps: to find out whether your one-step prediction directly from original data to the fitted value is correct, compare it with the two step procedure of first calculating scores for the new data followed by predicting y from the scores. Note that if the PCA fitting routine centers (and possibly scales) the data, you need to do that with your new cases as well. And yes, if the regression is set up to predict y - mean (y), then the predicted values will be centered by the mean of the ys. You then need to center and possibly scale X by the center and scaling calculated on the training X, the same applies to y.
How to use PCA for prediction? Here are some ways to test whether your understanding of the calculations is correct: Take a few of the training cases and calculate the prediction as you think. Then compare with the fitted values
47,275
How to use PCA for prediction?
I am not a Matlab user, but you are approaching the problem from the wrong angle. PCA should not be used to help with overfitting - regularization is a proper tool for it. This way you are not throwing data away, and you will most likely end up with a model that is easier to explain (e.g. feature importance or weights, for your original variables, not transformed ones).
How to use PCA for prediction?
I am not a Matlab user, but you are approaching the problem from the wrong angle. PCA should not be used to help with overfitting - regularization is a proper tool for it. This way you are not throwin
How to use PCA for prediction? I am not a Matlab user, but you are approaching the problem from the wrong angle. PCA should not be used to help with overfitting - regularization is a proper tool for it. This way you are not throwing data away, and you will most likely end up with a model that is easier to explain (e.g. feature importance or weights, for your original variables, not transformed ones).
How to use PCA for prediction? I am not a Matlab user, but you are approaching the problem from the wrong angle. PCA should not be used to help with overfitting - regularization is a proper tool for it. This way you are not throwin
47,276
Is the Fisher's exact test "parametric" or "non-parametric"?
tl;dr: Fisher's Exact Test is nonparametric in the sense that it does not assume that the population is based on theoretical probability distributions (normal/geometric/exponential etc.), but that the data itself reflects the parameters, which is why it proceeds with the assumption that the row/col totals are fixed. Fisher's exact test, as its name suggests, gives the exact p-value rather than an estimation based on a particular sampling distribution thought to be aligning with the variable(s). If you have two or more variables, all categorical/nominal, and your data consists of independent observations, then you can already intuitively create a cross-tabulation to assess conditional frequencies (akin to how you would want to see overlaps in a Venn diagram). For instance, say your independent variable is gender (M/F/O) and the dependent variable is party allegiance (D/R/I). Now let's say we do not know the probability distribution of either variable, which means that we can't just plug the data into any parametric test. (In the classical FET where it's only a 2x2 (two dichotomous variables) which you know are binomially distributed, you could proceed using the hypergeometric distribution to estimate the p-value.) Fisher's exact test directly gives us the probability of finding a result as extreme as the one we have. In other words, it reflects how far our observed frequencies are from the expected frequencies. If gender is truly independent of party membership, then there ought to be roughly uniform distribution. (Aside: you can use the 1 sample K-S test here to test for uniform distribution.) But Fisher's test takes all the discrete values <= the observed ones, calculates their probabilities, and adds them up to give you the p-value, which you then compare to your alpha (probability of a Type I error, i.e. mistakenly rejecting the null hypothesis of there being no association between gender and party membership). NB that although the FET is used as a recourse to the cross-tabbed chi square test when the sample size is low, the FET has its own assumptions -- I'd use it only for MECEly organised data such that the variables are 'really' nominal in a fundamental sense and not contrived for simplicity's sake (e.g. biological sex is 'truly' nominal if we use the usual definitions, whereas 'treatment status' must never be taken to be a true nominal variable) and where the individual instances are independently recorded. For an actual rigorous idea of what the FET entails mathematically, take a look at Weisstein's neat definition -- http://mathworld.wolfram.com/FishersExactTest.html.
Is the Fisher's exact test "parametric" or "non-parametric"?
tl;dr: Fisher's Exact Test is nonparametric in the sense that it does not assume that the population is based on theoretical probability distributions (normal/geometric/exponential etc.), but that the
Is the Fisher's exact test "parametric" or "non-parametric"? tl;dr: Fisher's Exact Test is nonparametric in the sense that it does not assume that the population is based on theoretical probability distributions (normal/geometric/exponential etc.), but that the data itself reflects the parameters, which is why it proceeds with the assumption that the row/col totals are fixed. Fisher's exact test, as its name suggests, gives the exact p-value rather than an estimation based on a particular sampling distribution thought to be aligning with the variable(s). If you have two or more variables, all categorical/nominal, and your data consists of independent observations, then you can already intuitively create a cross-tabulation to assess conditional frequencies (akin to how you would want to see overlaps in a Venn diagram). For instance, say your independent variable is gender (M/F/O) and the dependent variable is party allegiance (D/R/I). Now let's say we do not know the probability distribution of either variable, which means that we can't just plug the data into any parametric test. (In the classical FET where it's only a 2x2 (two dichotomous variables) which you know are binomially distributed, you could proceed using the hypergeometric distribution to estimate the p-value.) Fisher's exact test directly gives us the probability of finding a result as extreme as the one we have. In other words, it reflects how far our observed frequencies are from the expected frequencies. If gender is truly independent of party membership, then there ought to be roughly uniform distribution. (Aside: you can use the 1 sample K-S test here to test for uniform distribution.) But Fisher's test takes all the discrete values <= the observed ones, calculates their probabilities, and adds them up to give you the p-value, which you then compare to your alpha (probability of a Type I error, i.e. mistakenly rejecting the null hypothesis of there being no association between gender and party membership). NB that although the FET is used as a recourse to the cross-tabbed chi square test when the sample size is low, the FET has its own assumptions -- I'd use it only for MECEly organised data such that the variables are 'really' nominal in a fundamental sense and not contrived for simplicity's sake (e.g. biological sex is 'truly' nominal if we use the usual definitions, whereas 'treatment status' must never be taken to be a true nominal variable) and where the individual instances are independently recorded. For an actual rigorous idea of what the FET entails mathematically, take a look at Weisstein's neat definition -- http://mathworld.wolfram.com/FishersExactTest.html.
Is the Fisher's exact test "parametric" or "non-parametric"? tl;dr: Fisher's Exact Test is nonparametric in the sense that it does not assume that the population is based on theoretical probability distributions (normal/geometric/exponential etc.), but that the
47,277
Is the Fisher's exact test "parametric" or "non-parametric"?
Fisher's exact test is a parametric test, because it does assume an underlying binomial distribution for the $2\times 2$ table. The table probabilities are then calculated conditioning on the total number of successes in an exact fashion. The term parametric refers to whether distributional assumptions are made about how the data arises, rather than, say, to whether a test statistic is calculated and then compared to some distribution (e.g. normal, t, $\chi^2$ etc.).
Is the Fisher's exact test "parametric" or "non-parametric"?
Fisher's exact test is a parametric test, because it does assume an underlying binomial distribution for the $2\times 2$ table. The table probabilities are then calculated conditioning on the total n
Is the Fisher's exact test "parametric" or "non-parametric"? Fisher's exact test is a parametric test, because it does assume an underlying binomial distribution for the $2\times 2$ table. The table probabilities are then calculated conditioning on the total number of successes in an exact fashion. The term parametric refers to whether distributional assumptions are made about how the data arises, rather than, say, to whether a test statistic is calculated and then compared to some distribution (e.g. normal, t, $\chi^2$ etc.).
Is the Fisher's exact test "parametric" or "non-parametric"? Fisher's exact test is a parametric test, because it does assume an underlying binomial distribution for the $2\times 2$ table. The table probabilities are then calculated conditioning on the total n
47,278
Is the Fisher's exact test "parametric" or "non-parametric"?
Consider the case of comparing two samples of dichotomous observations ("success" & "failure"), & taking one of the following approaches to defining a test statistic & its sampling distribution: (1) Assume, under the null hypothesis, all observations are drawn independently from the same distribution & condition on the order statistic (sufficient for the distribution under the null). Decide that the count of "successes" in the first sample (or any equivalent) measures discrepancy with the null in the direction of the kind of alternatives you're interested in. (2) Assume the observations in each sample constitute independent Bernoulli random variates. The population odds ratio is the parameter of interest & the overall odds of "success" is a nuisance parameter; the counts of "successes" in each sample are jointly sufficient & constitute binomial random variates. Condition on the total count of "successes", which is sufficient for the nuisance parameter & almost ancillary for the parameter of interest. By now you're in the same place whether you've been shunning (1) or embracing (2) parametric assumptions while devising your test: with the count of "successes" in the first sample following a hypergeometric distribution under the null. (Putting to one side any subtle considerations that may arise from wanting to carry out a two-tailed test.) For observations that can take only two values the independently, identically distributed assumption alone entails a full parametrization of the distribution under the null after conditioning.
Is the Fisher's exact test "parametric" or "non-parametric"?
Consider the case of comparing two samples of dichotomous observations ("success" & "failure"), & taking one of the following approaches to defining a test statistic & its sampling distribution: (1) A
Is the Fisher's exact test "parametric" or "non-parametric"? Consider the case of comparing two samples of dichotomous observations ("success" & "failure"), & taking one of the following approaches to defining a test statistic & its sampling distribution: (1) Assume, under the null hypothesis, all observations are drawn independently from the same distribution & condition on the order statistic (sufficient for the distribution under the null). Decide that the count of "successes" in the first sample (or any equivalent) measures discrepancy with the null in the direction of the kind of alternatives you're interested in. (2) Assume the observations in each sample constitute independent Bernoulli random variates. The population odds ratio is the parameter of interest & the overall odds of "success" is a nuisance parameter; the counts of "successes" in each sample are jointly sufficient & constitute binomial random variates. Condition on the total count of "successes", which is sufficient for the nuisance parameter & almost ancillary for the parameter of interest. By now you're in the same place whether you've been shunning (1) or embracing (2) parametric assumptions while devising your test: with the count of "successes" in the first sample following a hypergeometric distribution under the null. (Putting to one side any subtle considerations that may arise from wanting to carry out a two-tailed test.) For observations that can take only two values the independently, identically distributed assumption alone entails a full parametrization of the distribution under the null after conditioning.
Is the Fisher's exact test "parametric" or "non-parametric"? Consider the case of comparing two samples of dichotomous observations ("success" & "failure"), & taking one of the following approaches to defining a test statistic & its sampling distribution: (1) A
47,279
Is the Fisher's exact test "parametric" or "non-parametric"?
Tests that are used on nonparametric data can be used on any data normal or not normal (it is just in comparison to tests that can only be used on normal data they are less reliable). Fishers test is one of the tests that is actually prefered to use over chi-squared when the data is too small.
Is the Fisher's exact test "parametric" or "non-parametric"?
Tests that are used on nonparametric data can be used on any data normal or not normal (it is just in comparison to tests that can only be used on normal data they are less reliable). Fishers test is
Is the Fisher's exact test "parametric" or "non-parametric"? Tests that are used on nonparametric data can be used on any data normal or not normal (it is just in comparison to tests that can only be used on normal data they are less reliable). Fishers test is one of the tests that is actually prefered to use over chi-squared when the data is too small.
Is the Fisher's exact test "parametric" or "non-parametric"? Tests that are used on nonparametric data can be used on any data normal or not normal (it is just in comparison to tests that can only be used on normal data they are less reliable). Fishers test is
47,280
What is the meaning of the term "stable" in relation to predictions?
The book Elements of Statistical Learning does not seem to give a formal definition of the concept of "stability" as it is used in this context. The words stable or stability do not occur in the index. However, the following quote seems to indicate the intended meaning (page 16 of second edition): The linear decision boundary from least squares is very smooth, and apparently stable to fit. It does appear to rely heavily on the assumption that a linear decision boundary is appropriate. In language we will develop shortly, it has low variance and potentially high bias. On the other hand, the $k$-nearest-neighbor procedures do not appear to rely on any stringent assumptions about the underlying data, and can adapt to any situation. However, any particular subregion of the decision boundary depends on a handful of input points and their particular positions, and is thus wiggly and unstable-high variance and low bias. With the linear model all of the data contributes to the predictions for any particular $x$. This gives low variance, hence its predictions can be stable — but high bias if the linear model is not a good approximation. With the $k$-nearest neighbors method, for any particular $x$ only the $k$-nearest neighbors contribute to the prediction. As a result the variance is higher, hence its predictions can be unstable — this is especially so if $k$ is much smaller than $n$.The gain is that by only using close points, the approximation could be better, so potentially lower bias. One problem is that if the ambient space of the $x$ is high-dimensional, there might be no really close neighbors anyhow. Furthermore, for defining neighbors we need a distance measure, a metric. The results of $k$-nearest neighbors depends critically on the definition of the metric, while the linear model does not use such information. The book elements of statistical learning do assume an euclidean metric, bit other choices are of course possible. For the euclidean metric to be meaningful, the different variables must be on comparable scales. If, for instance, you multiply one of the variables by 1000 (changing unit from km to m, for instance) that will change, maybe drastically, the $k$-nearest neighbors solution, while it has no impact on the linear model at all. Below is the original answer — as historical documentation: In this context it probably means that when the input data $x$ changes a little, then the predicted value also changes only a little bit, in an easily understood manner, while with $k$-means, this need not be true, some little change in $x$ could cause a surprisingly large change in the prediction.
What is the meaning of the term "stable" in relation to predictions?
The book Elements of Statistical Learning does not seem to give a formal definition of the concept of "stability" as it is used in this context. The words stable or stability do not occur in the index
What is the meaning of the term "stable" in relation to predictions? The book Elements of Statistical Learning does not seem to give a formal definition of the concept of "stability" as it is used in this context. The words stable or stability do not occur in the index. However, the following quote seems to indicate the intended meaning (page 16 of second edition): The linear decision boundary from least squares is very smooth, and apparently stable to fit. It does appear to rely heavily on the assumption that a linear decision boundary is appropriate. In language we will develop shortly, it has low variance and potentially high bias. On the other hand, the $k$-nearest-neighbor procedures do not appear to rely on any stringent assumptions about the underlying data, and can adapt to any situation. However, any particular subregion of the decision boundary depends on a handful of input points and their particular positions, and is thus wiggly and unstable-high variance and low bias. With the linear model all of the data contributes to the predictions for any particular $x$. This gives low variance, hence its predictions can be stable — but high bias if the linear model is not a good approximation. With the $k$-nearest neighbors method, for any particular $x$ only the $k$-nearest neighbors contribute to the prediction. As a result the variance is higher, hence its predictions can be unstable — this is especially so if $k$ is much smaller than $n$.The gain is that by only using close points, the approximation could be better, so potentially lower bias. One problem is that if the ambient space of the $x$ is high-dimensional, there might be no really close neighbors anyhow. Furthermore, for defining neighbors we need a distance measure, a metric. The results of $k$-nearest neighbors depends critically on the definition of the metric, while the linear model does not use such information. The book elements of statistical learning do assume an euclidean metric, bit other choices are of course possible. For the euclidean metric to be meaningful, the different variables must be on comparable scales. If, for instance, you multiply one of the variables by 1000 (changing unit from km to m, for instance) that will change, maybe drastically, the $k$-nearest neighbors solution, while it has no impact on the linear model at all. Below is the original answer — as historical documentation: In this context it probably means that when the input data $x$ changes a little, then the predicted value also changes only a little bit, in an easily understood manner, while with $k$-means, this need not be true, some little change in $x$ could cause a surprisingly large change in the prediction.
What is the meaning of the term "stable" in relation to predictions? The book Elements of Statistical Learning does not seem to give a formal definition of the concept of "stability" as it is used in this context. The words stable or stability do not occur in the index
47,281
What is the meaning of the term "stable" in relation to predictions?
I'd like to illustrate these two using the following comparison. As you can see the higher the variance the more unstable the prediction will be and the higher the bias the mean of the prediction will be more far away from the target. The linear regresson would be stable but its bias sometimes is high(overfitting); while the KNN might be accurate(low bias) but might be unstable(high variance).
What is the meaning of the term "stable" in relation to predictions?
I'd like to illustrate these two using the following comparison. As you can see the higher the variance the more unstable the prediction will be and the higher the bias the mean of the prediction wil
What is the meaning of the term "stable" in relation to predictions? I'd like to illustrate these two using the following comparison. As you can see the higher the variance the more unstable the prediction will be and the higher the bias the mean of the prediction will be more far away from the target. The linear regresson would be stable but its bias sometimes is high(overfitting); while the KNN might be accurate(low bias) but might be unstable(high variance).
What is the meaning of the term "stable" in relation to predictions? I'd like to illustrate these two using the following comparison. As you can see the higher the variance the more unstable the prediction will be and the higher the bias the mean of the prediction wil
47,282
Why are transitions and emissions in HMM assumed to be independent?
Yes, it's a limitation of the model. In most dynamical systems that you might care to think about using an HMM, the act of measurement or observation is usually conceived and/or constructed in such a way that it is assumed not to affect the system under observation. We want to imagine the observer as being passive and completely independent from the system, and then make inferences about how the hidden states would evolve, even if the observer were not present. An example might help to make this a bit more concrete. Imagine that you are tracking a satellite moving through the sky with a telescope. The "hidden states" in this case would be the position and velocity of the satellite at any given moment in time. The "transition process" is governed by whatever forces are acting on the satellite; certainly gravity at all times, but also possibly other things such as the thrusters in a reaction control system. The "observation" at any given moment consists of two angles, the altitude and azimuth with respect to the horizon. Now ask yourself, how weird would it be if the very act of observing the satellite through a telescope, hundreds or even thousands of miles away, could actually cause it to speed up or slow down (thereby impacting its hidden state) spontaneously? Lots of dynamical estimate problems are like the satellite and telescope problem: the act of observation itself doesn't affect the hidden states very much, or at all. HMMs, or similar/related concepts, are a perfectly valid and useful way of thinking about these kinds of systems. The independence of the observation and the state transition are a desirable feature of the model. It's worth noting that there are systems where the act of observation is presumed to affect the thing under observation. This kind of interdependence is actually an integral feature of quantum mechanics. The term of art in quantum mechanics for the moment when an observation actually affects the thing under observation is wave function collapse. To model a quantum mechanical dynamical system in a way that would be analogous to how we use HMMs, you would indeed need to assume that the observation and the state transition are coupled events. It's worth noting that if you google quantum filtering or quantum Markov filter, there are several hits, indicating that it does appear to be an active topic of current research.
Why are transitions and emissions in HMM assumed to be independent?
Yes, it's a limitation of the model. In most dynamical systems that you might care to think about using an HMM, the act of measurement or observation is usually conceived and/or constructed in such a
Why are transitions and emissions in HMM assumed to be independent? Yes, it's a limitation of the model. In most dynamical systems that you might care to think about using an HMM, the act of measurement or observation is usually conceived and/or constructed in such a way that it is assumed not to affect the system under observation. We want to imagine the observer as being passive and completely independent from the system, and then make inferences about how the hidden states would evolve, even if the observer were not present. An example might help to make this a bit more concrete. Imagine that you are tracking a satellite moving through the sky with a telescope. The "hidden states" in this case would be the position and velocity of the satellite at any given moment in time. The "transition process" is governed by whatever forces are acting on the satellite; certainly gravity at all times, but also possibly other things such as the thrusters in a reaction control system. The "observation" at any given moment consists of two angles, the altitude and azimuth with respect to the horizon. Now ask yourself, how weird would it be if the very act of observing the satellite through a telescope, hundreds or even thousands of miles away, could actually cause it to speed up or slow down (thereby impacting its hidden state) spontaneously? Lots of dynamical estimate problems are like the satellite and telescope problem: the act of observation itself doesn't affect the hidden states very much, or at all. HMMs, or similar/related concepts, are a perfectly valid and useful way of thinking about these kinds of systems. The independence of the observation and the state transition are a desirable feature of the model. It's worth noting that there are systems where the act of observation is presumed to affect the thing under observation. This kind of interdependence is actually an integral feature of quantum mechanics. The term of art in quantum mechanics for the moment when an observation actually affects the thing under observation is wave function collapse. To model a quantum mechanical dynamical system in a way that would be analogous to how we use HMMs, you would indeed need to assume that the observation and the state transition are coupled events. It's worth noting that if you google quantum filtering or quantum Markov filter, there are several hits, indicating that it does appear to be an active topic of current research.
Why are transitions and emissions in HMM assumed to be independent? Yes, it's a limitation of the model. In most dynamical systems that you might care to think about using an HMM, the act of measurement or observation is usually conceived and/or constructed in such a
47,283
Why are transitions and emissions in HMM assumed to be independent?
In wikipedia article it is stated that next hidden state $x(t+1)$ conditionally depends from previous hidden state $x(t)$: But we can't say that observation $y(t)$ and next hidden state $x(t+1)$ are independant. Because if you observe $y(t)$ then you have some knowledge about $x(t)$ probability distribution and then knowledge about $x(t+1)$ distribution. For example, if you have that $y(t)$ just equals hidden state: $y(t) = x(t)$ then knowing $y(t)$ value gives you $x(t)$ value. And then you can derive $x(t+1)$ distribution from $x(t)$ value. But you can say that $y(t)$ are independant with $x(t+1)$ given $x(t)$. If $x(t)$ is fixed (you don't know the exact value, you just know it is fixed) then $y(t)$ observation gives you nothing about $x(t+1)$.
Why are transitions and emissions in HMM assumed to be independent?
In wikipedia article it is stated that next hidden state $x(t+1)$ conditionally depends from previous hidden state $x(t)$: But we can't say that observation $y(t)$ and next hidden state $x(t+1)$ ar
Why are transitions and emissions in HMM assumed to be independent? In wikipedia article it is stated that next hidden state $x(t+1)$ conditionally depends from previous hidden state $x(t)$: But we can't say that observation $y(t)$ and next hidden state $x(t+1)$ are independant. Because if you observe $y(t)$ then you have some knowledge about $x(t)$ probability distribution and then knowledge about $x(t+1)$ distribution. For example, if you have that $y(t)$ just equals hidden state: $y(t) = x(t)$ then knowing $y(t)$ value gives you $x(t)$ value. And then you can derive $x(t+1)$ distribution from $x(t)$ value. But you can say that $y(t)$ are independant with $x(t+1)$ given $x(t)$. If $x(t)$ is fixed (you don't know the exact value, you just know it is fixed) then $y(t)$ observation gives you nothing about $x(t+1)$.
Why are transitions and emissions in HMM assumed to be independent? In wikipedia article it is stated that next hidden state $x(t+1)$ conditionally depends from previous hidden state $x(t)$: But we can't say that observation $y(t)$ and next hidden state $x(t+1)$ ar
47,284
How to compare (probability) predictive ability of models developed from logistic regression?
There are many good ways to do it. Here are some examples. These methods are implemented in the R rms package (functions val.prob, calibrate, validate): loess nonparametric full-resolution calibration curve (no binning) Spiegelhalter's test Brier score (a proper accuracy score - quadratic score) Generalized $R^2$ (a proper accuracy score related to deviance) Calibration slope and intercept For comparing two models with regard to discrimination, the likelihood ratio $\chi^2$ test is the gold standard. Four of the above approaches, and other approaches, are covered in the 2nd edition of my book Regression Modeling Strategies (coming in 2015-09) and in my course notes that go along with the book, available from the handouts link at https://biostat.app.vumc.org/wiki/Main/RmS . The Brier score can be decomposed into discrimination and calibration components. Along with the Brier score and Spiegelhalter's test, the nonparametric calibration curve can detect errors in the intercept.
How to compare (probability) predictive ability of models developed from logistic regression?
There are many good ways to do it. Here are some examples. These methods are implemented in the R rms package (functions val.prob, calibrate, validate): loess nonparametric full-resolution calibrat
How to compare (probability) predictive ability of models developed from logistic regression? There are many good ways to do it. Here are some examples. These methods are implemented in the R rms package (functions val.prob, calibrate, validate): loess nonparametric full-resolution calibration curve (no binning) Spiegelhalter's test Brier score (a proper accuracy score - quadratic score) Generalized $R^2$ (a proper accuracy score related to deviance) Calibration slope and intercept For comparing two models with regard to discrimination, the likelihood ratio $\chi^2$ test is the gold standard. Four of the above approaches, and other approaches, are covered in the 2nd edition of my book Regression Modeling Strategies (coming in 2015-09) and in my course notes that go along with the book, available from the handouts link at https://biostat.app.vumc.org/wiki/Main/RmS . The Brier score can be decomposed into discrimination and calibration components. Along with the Brier score and Spiegelhalter's test, the nonparametric calibration curve can detect errors in the intercept.
How to compare (probability) predictive ability of models developed from logistic regression? There are many good ways to do it. Here are some examples. These methods are implemented in the R rms package (functions val.prob, calibrate, validate): loess nonparametric full-resolution calibrat
47,285
How to compare (probability) predictive ability of models developed from logistic regression?
The AUROC (which is related to Kolmogorov Smirnov) is not only invariant to a change in coefficient, it is invariant for any order-preserving transformation and consequently it tells how well you predict the ranking of the subjects. A test for checking whether your probabilities are well predicted is e.g. the Hosmer-Lemeshow test (see e.g. http://media.hsph.edu.vn/sites/default/files/Statistics%20eBook%20-%20Hosmer,%20Lemeshow%20-%20Applied%20Logistic%20Regression.pdf). There may be other tests, but that depends on your problem. E.g. if you use the logistic regression in the context of predicting company failure and your goal is not to predict probabilities but to predict rating 'classes'.
How to compare (probability) predictive ability of models developed from logistic regression?
The AUROC (which is related to Kolmogorov Smirnov) is not only invariant to a change in coefficient, it is invariant for any order-preserving transformation and consequently it tells how well you pred
How to compare (probability) predictive ability of models developed from logistic regression? The AUROC (which is related to Kolmogorov Smirnov) is not only invariant to a change in coefficient, it is invariant for any order-preserving transformation and consequently it tells how well you predict the ranking of the subjects. A test for checking whether your probabilities are well predicted is e.g. the Hosmer-Lemeshow test (see e.g. http://media.hsph.edu.vn/sites/default/files/Statistics%20eBook%20-%20Hosmer,%20Lemeshow%20-%20Applied%20Logistic%20Regression.pdf). There may be other tests, but that depends on your problem. E.g. if you use the logistic regression in the context of predicting company failure and your goal is not to predict probabilities but to predict rating 'classes'.
How to compare (probability) predictive ability of models developed from logistic regression? The AUROC (which is related to Kolmogorov Smirnov) is not only invariant to a change in coefficient, it is invariant for any order-preserving transformation and consequently it tells how well you pred
47,286
Why SVM struggles to find good features among garbage?
TL;DR: Garbage in, garbage out. Selecting better features will promote a better model. (Sometimes the answer really is that simple!) What follows is a description of one path forward to selecting higher-quality features in the context of fitting an SVM. SVM performance can suffer when presented with many garbage features because the model only works with the data through the kernel function, rather than working with the features directly as in a more traditional regression analysis. I'll illustrate by comparison to the standard linear kernel and the so-called "automatic relevance determination" method. The standard linear kernel function is $K_1(x,x^\prime)=x^Tx^\prime.$ All features contribute to the output of $K_1$: first we compute the element-wise product, then we sum the products. There's no step that assesses which components of $x$ are more useful than others. We could, if we were so inclined, include a scalar factor $\gamma$ to yield $K_2(x,x^\prime)=x^T\gamma x^\prime,$ but a scalar $\gamma$ simply has the effect of re-scaling $C$, so there are contours of equal performance quality in $(\gamma,C)$ space. But if we replace $\gamma$ with diagonal, symmetric positive semi-definite (SPSD) $\Gamma$, we have $K_3(x,x^\prime)=x^T\Gamma x.$ We can think of this as estimating a coefficient for each entry in $x$, i.e. each feature. We may interpret diagonal elements of $\Gamma$ nearer to zero as contributing relatively little to the classification output, while diagonal elements larger in absolute value contribute more to the output. On the one hand, for $d$ features, you now have $d+1$ tuning parameters (each element of $\Gamma$ and $C$), but on the other, you may submit all features directly to the SVM. This procedure can be further generalized to non-diagonal, but still SPSD, $\Gamma$ to admit nonzero correlation among features. This will yield $\frac{d(d+1)}{2}+1$ tuning parameters, which rapidly becomes unattractive as $d$ grows. Finally, this ARD approach may be extended to other kernels. The RBF kernel varies through the squared Euclidean distance, so we may write $K_4=\exp\left(\frac{(x-x^\prime)^T\Gamma(x-x^\prime)}{\sigma}\right),$ and in general replace any squared Euclidean distance with $(x-x^\prime)^T\Gamma(x-x^\prime).$ P.S. I would like to solve the problem (if a solution exist) without feature selection So... you want to find a subset of features which have high predictive value, but you don't want to do "feature selection"? Perhaps I'm being dense, but it sounds like what you're after is a contradiction in terms. I suppose what an acceptable solution would look like to you depends on how expansive your definition of "feature selection" is.
Why SVM struggles to find good features among garbage?
TL;DR: Garbage in, garbage out. Selecting better features will promote a better model. (Sometimes the answer really is that simple!) What follows is a description of one path forward to selecting high
Why SVM struggles to find good features among garbage? TL;DR: Garbage in, garbage out. Selecting better features will promote a better model. (Sometimes the answer really is that simple!) What follows is a description of one path forward to selecting higher-quality features in the context of fitting an SVM. SVM performance can suffer when presented with many garbage features because the model only works with the data through the kernel function, rather than working with the features directly as in a more traditional regression analysis. I'll illustrate by comparison to the standard linear kernel and the so-called "automatic relevance determination" method. The standard linear kernel function is $K_1(x,x^\prime)=x^Tx^\prime.$ All features contribute to the output of $K_1$: first we compute the element-wise product, then we sum the products. There's no step that assesses which components of $x$ are more useful than others. We could, if we were so inclined, include a scalar factor $\gamma$ to yield $K_2(x,x^\prime)=x^T\gamma x^\prime,$ but a scalar $\gamma$ simply has the effect of re-scaling $C$, so there are contours of equal performance quality in $(\gamma,C)$ space. But if we replace $\gamma$ with diagonal, symmetric positive semi-definite (SPSD) $\Gamma$, we have $K_3(x,x^\prime)=x^T\Gamma x.$ We can think of this as estimating a coefficient for each entry in $x$, i.e. each feature. We may interpret diagonal elements of $\Gamma$ nearer to zero as contributing relatively little to the classification output, while diagonal elements larger in absolute value contribute more to the output. On the one hand, for $d$ features, you now have $d+1$ tuning parameters (each element of $\Gamma$ and $C$), but on the other, you may submit all features directly to the SVM. This procedure can be further generalized to non-diagonal, but still SPSD, $\Gamma$ to admit nonzero correlation among features. This will yield $\frac{d(d+1)}{2}+1$ tuning parameters, which rapidly becomes unattractive as $d$ grows. Finally, this ARD approach may be extended to other kernels. The RBF kernel varies through the squared Euclidean distance, so we may write $K_4=\exp\left(\frac{(x-x^\prime)^T\Gamma(x-x^\prime)}{\sigma}\right),$ and in general replace any squared Euclidean distance with $(x-x^\prime)^T\Gamma(x-x^\prime).$ P.S. I would like to solve the problem (if a solution exist) without feature selection So... you want to find a subset of features which have high predictive value, but you don't want to do "feature selection"? Perhaps I'm being dense, but it sounds like what you're after is a contradiction in terms. I suppose what an acceptable solution would look like to you depends on how expansive your definition of "feature selection" is.
Why SVM struggles to find good features among garbage? TL;DR: Garbage in, garbage out. Selecting better features will promote a better model. (Sometimes the answer really is that simple!) What follows is a description of one path forward to selecting high
47,287
How to identify the seasonality of a timeseries from the Periodogram?
Well, the periodogram after taking first differences doesn't indicate any clear periodicity. However, be aware that taking first differences amplifies high-frequency components, which should appear in the power spectrum as a quadratic trend, and in the log-power spectrum as a log-shaped trend (which is roughly compatible with what we see here). My recommendations: – First compute the periodogram without any preprocessing. – Then, remove the linear trend, but not by using first differences but by fitting a line by regression and subtracting the result from the data (there should also be a "detrend" function in R). – Use a proper spectral estimation function. I'm not familiar with R, but I'm sure it contains an implementation of Welch's modified periodogram method. Update for the updated question: The time series exhibits a dominant period of roughly 360 samples, which for a sampling rate of 1 per minute means 360 minutes. The dominant frequency should therefore be about 0.0028 min$^{-1}$. This seems to be consistent with the periodogram after subtracted trend. Try zooming into the low-frequency range to more precisely determine the peak location. Superimposed to that is a secondary oscillation of 180 samples period or 0.0056 min$^{-1}$ frequency. Analyzing your data myself I get a main peak at 0.0029 min$^{-1}$ and a secondary peak at 0.0059 min$^{-1}$ (factor 2, the first harmonic). The secondary peak is smaller by a factor of about 36, or by 16 dB. I can share my code, but I am using Matlab, not R. Btw., the frequency scale on your plots does not appear to be consistent; sometimes it goes up to 0.008, sometimes to 0.5? I think the former gives the frequency in Hz and the latter in min$^{-1}$.
How to identify the seasonality of a timeseries from the Periodogram?
Well, the periodogram after taking first differences doesn't indicate any clear periodicity. However, be aware that taking first differences amplifies high-frequency components, which should appear in
How to identify the seasonality of a timeseries from the Periodogram? Well, the periodogram after taking first differences doesn't indicate any clear periodicity. However, be aware that taking first differences amplifies high-frequency components, which should appear in the power spectrum as a quadratic trend, and in the log-power spectrum as a log-shaped trend (which is roughly compatible with what we see here). My recommendations: – First compute the periodogram without any preprocessing. – Then, remove the linear trend, but not by using first differences but by fitting a line by regression and subtracting the result from the data (there should also be a "detrend" function in R). – Use a proper spectral estimation function. I'm not familiar with R, but I'm sure it contains an implementation of Welch's modified periodogram method. Update for the updated question: The time series exhibits a dominant period of roughly 360 samples, which for a sampling rate of 1 per minute means 360 minutes. The dominant frequency should therefore be about 0.0028 min$^{-1}$. This seems to be consistent with the periodogram after subtracted trend. Try zooming into the low-frequency range to more precisely determine the peak location. Superimposed to that is a secondary oscillation of 180 samples period or 0.0056 min$^{-1}$ frequency. Analyzing your data myself I get a main peak at 0.0029 min$^{-1}$ and a secondary peak at 0.0059 min$^{-1}$ (factor 2, the first harmonic). The secondary peak is smaller by a factor of about 36, or by 16 dB. I can share my code, but I am using Matlab, not R. Btw., the frequency scale on your plots does not appear to be consistent; sometimes it goes up to 0.008, sometimes to 0.5? I think the former gives the frequency in Hz and the latter in min$^{-1}$.
How to identify the seasonality of a timeseries from the Periodogram? Well, the periodogram after taking first differences doesn't indicate any clear periodicity. However, be aware that taking first differences amplifies high-frequency components, which should appear in
47,288
Why is Moran's $I$ coming out greater than $1$?
Comparison of $I$ with correlation coefficients is good, but it has its limits. This answer uncovers what those limits are. It derives a tight upper bound for $|I|$ in terms of the weights matrix $W$ and shows that in ordinary applications, where $W$ is symmetric and row-normalized, this bound is $1$ (or less). For the extraordinary weights matrix in the question (which has some zero rows, making it impossible to row-normalize), it shows that $X=\pm(3,-1,-1,-1)$ achieves the most extreme value of $|I|$ possible, which is $3$. Analysis: Simplifying the Formula for $I$ The repeated appearances of $x_i - \bar x$ in the formula, along with the sum of their squares in the denominator, invite us to re-express $I$ in terms of the standardized variates $$z_i = \frac{(x_i - \bar x)}{\sqrt{\sum_{i=1}^n (x_i - \bar x)^2}};\quad \bar x = \frac{1}{n}\sum_{i=1}^n x_i,$$ which can be assembled into the column vector $z = (z_1, \ldots, z_n)^\prime$. Because the variables have been standardized, $z$ is a unit vector $$|z|^2 = z_1^2 + \cdots + z_n^2 = 1.$$ (This differs slightly from the usual statistical concept of "standardization," which recenters and rescales $x$ to have length $\sqrt{n}$.) Further simplicity is achieved by renormalizing the weights $\omega_{ij}$ so they sum to unity: $$\sum_{i,j} \omega_{ij} = 1.$$ When $S_0 = \sum_{i,j}\omega_{ij} \ne 0$, this can always be done by dividing every weight by $S_0$. (When the sum of the weights is zero, the formula for $I$ is undefined in the first place.) The renormalized weights form a matrix $W = (\omega_{ij} / S_0) = (w_{ij})$. In terms of $z$ and $W$, $$\eqalign{ I &= \sum_{i,j} \frac{n \omega_{ij}}{\sum_{i,j} \omega_{ij}} \left(\frac{(x_i-\bar x)}{\sqrt{\sum_i(x_i-\bar x)^2}}\right)\left(\frac{(x_j-\bar x)}{\sqrt{\sum_i(x_i-\bar x)^2}}\right) \\ &= \sum_{i,j} n w_{ij}z_i z_j = z^\prime (n W z). }$$ This is identical to the formula for the Pearson correlation $$\rho(z, w) =z^\prime w$$ between any two standardized variables $z$ and $w$. Comparison to Correlation Coefficients The difference between $I$ and a correlation is that $w = nWz$ might not be standardized: $|nWz| = \sqrt{(nWz)^\prime (nWz)}$ is not necessarily equal to $1$. To standardize, we must first subtract the mean of $w = nWz$, $$\bar{w} = \frac{1}{n}\mathbf{1}^\prime n W z = \mathbf{1}^\prime W z,$$ from each component of $n W z$. Let $V$ be the matrix for this transformation, $$V:z \to Vz = nWz - \mathbf{1}\bar w = \left(n\mathbb{I}_n - \mathbf{1}\mathbf{1}^\prime\right) W z.$$ (The vector $\mathbf{1}$ is the column vector $(1,1,\ldots,1)^\prime$, so the matrix $\mathbf{1}\mathbf{1}^\prime$ is the $n\times n$ matrix all of whose entries are ones.) By standardizing $Wz$ in this manner--subtracting $\bar w$ and dividing by the length of the resulting centered vector--we get an honest correlation coefficient whose size cannot exceed $1$ (by virtue of the Cauchy-Schwarz Inequality): $$1 \ge |\rho(z, Wz)| = \frac{|z^\prime Vz|}{|Vz|}.$$ This can be related to $I$ because $\mathbf{1}^\prime z = 0$, whence $z^\prime V z = z^\prime W z$. Clearing the denominator in the preceding inequality gives $$|I| = |z^\prime (nW z)| = n|z^\prime V z| \le |V z|.$$ Equality will hold if and only if $Vz \ne 0$ and $Vz$ is parallel to $z$: that is, when $z$ is an eigenvector of $V$ with nonzero eigenvalue. When such an eigenvector exists (and it almost always will), this shows that The size of $I$ is bounded by the largest eigenvalue (in absolute value) of $V = (n\mathbb{I} - \mathbf{1}\mathbf{1}^\prime)W$ and it can attain this bound. Whenever we can find a basis in which $V$ is diagonal the largest absolute entry of $V$ is its largest eigenvalue. In the question the unit-sum-normalized version of the weights matrix is $$W = \pmatrix{1&0&0&0 \\ 0&0&0&0 \\ 0&0&0&0 \\ 0&0&0&0}$$ whence $$V = \pmatrix{ 3&0&0&0 \\ -1&0&0&0 \\ -1&0&0&0 \\ -1&0&0&0 }.$$ It is simple to compute that the largest value attained by $|Vz|$ among all centered unit vectors $z$ (that is, $\mathbf{1}^\prime z = 0$ and $|z|=1$) is $3$, uniquely attained at $z=\pm(3,-1,-1,-1)/\sqrt{12}$. Consequently, all we can hope in general for this particular weights matrix $W$ is that $|I| \le 3$. Resolution of the Original Question Ordinarily, $W$ has nonnegative entries that originally are row standardized to sum to unity. This automatically makes the sum of each row in the unit-sum-normalized version of $W$ equal to $1/n$. Consequently $n W \mathbf{1} = \mathbf{1}$, making $\mathbf{1}$ an eigenvector of $n W$ with eigenvalue $1$. It is also well-known that in this case if $W$ is symmetric, all other eigenvectors $z$ will be orthogonal to $\mathbf{1}$--that is, $z$ will be zero-centered--and will have eigenvalue $\lambda$ between $0$ and $1$. Considering any such unit $z$, $$z^\prime V z = z^\prime\left(n\mathbb{I}_n - \mathbf{1}\mathbf{1}^\prime\right)W z = z^\prime (nW z) = z^\prime (\lambda z) = \lambda z^\prime z = \lambda \le 1.$$ In this ordinary application of Moran's I we may conclude that $\max{|I|} = 1$, as expected. But when $W$ is not symmetric and row-standardized--or cannot possibly be row-standardized because one or more rows are entirely zero--then the maximum has to be computed using the general result attained previously.
Why is Moran's $I$ coming out greater than $1$?
Comparison of $I$ with correlation coefficients is good, but it has its limits. This answer uncovers what those limits are. It derives a tight upper bound for $|I|$ in terms of the weights matrix $W
Why is Moran's $I$ coming out greater than $1$? Comparison of $I$ with correlation coefficients is good, but it has its limits. This answer uncovers what those limits are. It derives a tight upper bound for $|I|$ in terms of the weights matrix $W$ and shows that in ordinary applications, where $W$ is symmetric and row-normalized, this bound is $1$ (or less). For the extraordinary weights matrix in the question (which has some zero rows, making it impossible to row-normalize), it shows that $X=\pm(3,-1,-1,-1)$ achieves the most extreme value of $|I|$ possible, which is $3$. Analysis: Simplifying the Formula for $I$ The repeated appearances of $x_i - \bar x$ in the formula, along with the sum of their squares in the denominator, invite us to re-express $I$ in terms of the standardized variates $$z_i = \frac{(x_i - \bar x)}{\sqrt{\sum_{i=1}^n (x_i - \bar x)^2}};\quad \bar x = \frac{1}{n}\sum_{i=1}^n x_i,$$ which can be assembled into the column vector $z = (z_1, \ldots, z_n)^\prime$. Because the variables have been standardized, $z$ is a unit vector $$|z|^2 = z_1^2 + \cdots + z_n^2 = 1.$$ (This differs slightly from the usual statistical concept of "standardization," which recenters and rescales $x$ to have length $\sqrt{n}$.) Further simplicity is achieved by renormalizing the weights $\omega_{ij}$ so they sum to unity: $$\sum_{i,j} \omega_{ij} = 1.$$ When $S_0 = \sum_{i,j}\omega_{ij} \ne 0$, this can always be done by dividing every weight by $S_0$. (When the sum of the weights is zero, the formula for $I$ is undefined in the first place.) The renormalized weights form a matrix $W = (\omega_{ij} / S_0) = (w_{ij})$. In terms of $z$ and $W$, $$\eqalign{ I &= \sum_{i,j} \frac{n \omega_{ij}}{\sum_{i,j} \omega_{ij}} \left(\frac{(x_i-\bar x)}{\sqrt{\sum_i(x_i-\bar x)^2}}\right)\left(\frac{(x_j-\bar x)}{\sqrt{\sum_i(x_i-\bar x)^2}}\right) \\ &= \sum_{i,j} n w_{ij}z_i z_j = z^\prime (n W z). }$$ This is identical to the formula for the Pearson correlation $$\rho(z, w) =z^\prime w$$ between any two standardized variables $z$ and $w$. Comparison to Correlation Coefficients The difference between $I$ and a correlation is that $w = nWz$ might not be standardized: $|nWz| = \sqrt{(nWz)^\prime (nWz)}$ is not necessarily equal to $1$. To standardize, we must first subtract the mean of $w = nWz$, $$\bar{w} = \frac{1}{n}\mathbf{1}^\prime n W z = \mathbf{1}^\prime W z,$$ from each component of $n W z$. Let $V$ be the matrix for this transformation, $$V:z \to Vz = nWz - \mathbf{1}\bar w = \left(n\mathbb{I}_n - \mathbf{1}\mathbf{1}^\prime\right) W z.$$ (The vector $\mathbf{1}$ is the column vector $(1,1,\ldots,1)^\prime$, so the matrix $\mathbf{1}\mathbf{1}^\prime$ is the $n\times n$ matrix all of whose entries are ones.) By standardizing $Wz$ in this manner--subtracting $\bar w$ and dividing by the length of the resulting centered vector--we get an honest correlation coefficient whose size cannot exceed $1$ (by virtue of the Cauchy-Schwarz Inequality): $$1 \ge |\rho(z, Wz)| = \frac{|z^\prime Vz|}{|Vz|}.$$ This can be related to $I$ because $\mathbf{1}^\prime z = 0$, whence $z^\prime V z = z^\prime W z$. Clearing the denominator in the preceding inequality gives $$|I| = |z^\prime (nW z)| = n|z^\prime V z| \le |V z|.$$ Equality will hold if and only if $Vz \ne 0$ and $Vz$ is parallel to $z$: that is, when $z$ is an eigenvector of $V$ with nonzero eigenvalue. When such an eigenvector exists (and it almost always will), this shows that The size of $I$ is bounded by the largest eigenvalue (in absolute value) of $V = (n\mathbb{I} - \mathbf{1}\mathbf{1}^\prime)W$ and it can attain this bound. Whenever we can find a basis in which $V$ is diagonal the largest absolute entry of $V$ is its largest eigenvalue. In the question the unit-sum-normalized version of the weights matrix is $$W = \pmatrix{1&0&0&0 \\ 0&0&0&0 \\ 0&0&0&0 \\ 0&0&0&0}$$ whence $$V = \pmatrix{ 3&0&0&0 \\ -1&0&0&0 \\ -1&0&0&0 \\ -1&0&0&0 }.$$ It is simple to compute that the largest value attained by $|Vz|$ among all centered unit vectors $z$ (that is, $\mathbf{1}^\prime z = 0$ and $|z|=1$) is $3$, uniquely attained at $z=\pm(3,-1,-1,-1)/\sqrt{12}$. Consequently, all we can hope in general for this particular weights matrix $W$ is that $|I| \le 3$. Resolution of the Original Question Ordinarily, $W$ has nonnegative entries that originally are row standardized to sum to unity. This automatically makes the sum of each row in the unit-sum-normalized version of $W$ equal to $1/n$. Consequently $n W \mathbf{1} = \mathbf{1}$, making $\mathbf{1}$ an eigenvector of $n W$ with eigenvalue $1$. It is also well-known that in this case if $W$ is symmetric, all other eigenvectors $z$ will be orthogonal to $\mathbf{1}$--that is, $z$ will be zero-centered--and will have eigenvalue $\lambda$ between $0$ and $1$. Considering any such unit $z$, $$z^\prime V z = z^\prime\left(n\mathbb{I}_n - \mathbf{1}\mathbf{1}^\prime\right)W z = z^\prime (nW z) = z^\prime (\lambda z) = \lambda z^\prime z = \lambda \le 1.$$ In this ordinary application of Moran's I we may conclude that $\max{|I|} = 1$, as expected. But when $W$ is not symmetric and row-standardized--or cannot possibly be row-standardized because one or more rows are entirely zero--then the maximum has to be computed using the general result attained previously.
Why is Moran's $I$ coming out greater than $1$? Comparison of $I$ with correlation coefficients is good, but it has its limits. This answer uncovers what those limits are. It derives a tight upper bound for $|I|$ in terms of the weights matrix $W
47,289
Why is Moran's $I$ coming out greater than $1$?
That is true because you assume no variation(weight) on$X_i,i=2,\ldots,4$. In your case you have, \begin{align} I &=\frac{N}{1} \frac{(X_1-\bar{X})(X_1-\bar{X})}{\sum_i(X_i-\bar{X})^2}\\ &=\frac{(X_1-\bar{X})(X_1-\bar{X})}{\hat{\sigma}_X}\\ &=\frac{(X_1-\bar{X})^2}{\hat{\sigma}_X} \end{align} In this case $\mu_x=0$ and $\sigma_x=3$ then, $I=\frac{9}{3}=3$. As @Andy W mentioned (see) , Moran's $|I|$ can be greater that one in some cases. However, I am not sure your configuration about weight matrix $W$ is true because you assumed zero weights on some variables (that means you can remove them from analysis and just do the analysis on the rest).
Why is Moran's $I$ coming out greater than $1$?
That is true because you assume no variation(weight) on$X_i,i=2,\ldots,4$. In your case you have, \begin{align} I &=\frac{N}{1} \frac{(X_1-\bar{X})(X_1-\bar{X})}{\sum_i(X_i-\bar{X})^2}\\ &=\frac{(X_1-
Why is Moran's $I$ coming out greater than $1$? That is true because you assume no variation(weight) on$X_i,i=2,\ldots,4$. In your case you have, \begin{align} I &=\frac{N}{1} \frac{(X_1-\bar{X})(X_1-\bar{X})}{\sum_i(X_i-\bar{X})^2}\\ &=\frac{(X_1-\bar{X})(X_1-\bar{X})}{\hat{\sigma}_X}\\ &=\frac{(X_1-\bar{X})^2}{\hat{\sigma}_X} \end{align} In this case $\mu_x=0$ and $\sigma_x=3$ then, $I=\frac{9}{3}=3$. As @Andy W mentioned (see) , Moran's $|I|$ can be greater that one in some cases. However, I am not sure your configuration about weight matrix $W$ is true because you assumed zero weights on some variables (that means you can remove them from analysis and just do the analysis on the rest).
Why is Moran's $I$ coming out greater than $1$? That is true because you assume no variation(weight) on$X_i,i=2,\ldots,4$. In your case you have, \begin{align} I &=\frac{N}{1} \frac{(X_1-\bar{X})(X_1-\bar{X})}{\sum_i(X_i-\bar{X})^2}\\ &=\frac{(X_1-
47,290
Is there something called "mean coding" (like dummy coding & effect coding) in regression models?
Yes, that can be done, and is done occasionally. What you have is called "level means coding". For more on this, it may help you to read my answer here: How can logistic regression have a factorial predictor and no intercept? For an example of a case where I found it convenient to use level means coding, see: Why do the estimated values from a Best Linear Unbiased Predictor (BLUP) differ from a Best Linear Unbiased Estimator (BLUE)? There are a couple of things to be aware of when you use level means coding. First, you must suppress the intercept to avoid having perfect multicollinearity; see: Qualitative variable coding in regression leads to “singularities”). Second, the meaning of the hypothesis tests is different: they are now tests of whether the means differ from $0$, not whether they differ from each other; see: Understanding dummy (manual or automated) variable creation in GLM.
Is there something called "mean coding" (like dummy coding & effect coding) in regression models?
Yes, that can be done, and is done occasionally. What you have is called "level means coding". For more on this, it may help you to read my answer here: How can logistic regression have a factorial
Is there something called "mean coding" (like dummy coding & effect coding) in regression models? Yes, that can be done, and is done occasionally. What you have is called "level means coding". For more on this, it may help you to read my answer here: How can logistic regression have a factorial predictor and no intercept? For an example of a case where I found it convenient to use level means coding, see: Why do the estimated values from a Best Linear Unbiased Predictor (BLUP) differ from a Best Linear Unbiased Estimator (BLUE)? There are a couple of things to be aware of when you use level means coding. First, you must suppress the intercept to avoid having perfect multicollinearity; see: Qualitative variable coding in regression leads to “singularities”). Second, the meaning of the hypothesis tests is different: they are now tests of whether the means differ from $0$, not whether they differ from each other; see: Understanding dummy (manual or automated) variable creation in GLM.
Is there something called "mean coding" (like dummy coding & effect coding) in regression models? Yes, that can be done, and is done occasionally. What you have is called "level means coding". For more on this, it may help you to read my answer here: How can logistic regression have a factorial
47,291
A non parametric clustering algorithm suitable for high dimensional data
The most common clustering technique that meets your requirements would be DBSCAN. This finds points that are continuous by virtue of having shared nearest neighbors. There can be any number of clusters, and they can be of any shape. There are only two parameters to choose / enter: epsilon, a 'reachability' distance, and minpoints, the minimum number of points for the resulting set to be considered a cluster. The problem (potentially) in high-dimensional space is the curse of dimensionality. That is, all points can become equidistant from all other points. Since DBSCAN uses distance directly, this could become a problem and require you to explore distances other than Euclidean or other remedies. Note that high dimensionality does not necessitate this problem, however. For more, see this excellent CV answer: Euclidean distance is usually not good for sparse data?
A non parametric clustering algorithm suitable for high dimensional data
The most common clustering technique that meets your requirements would be DBSCAN. This finds points that are continuous by virtue of having shared nearest neighbors. There can be any number of clus
A non parametric clustering algorithm suitable for high dimensional data The most common clustering technique that meets your requirements would be DBSCAN. This finds points that are continuous by virtue of having shared nearest neighbors. There can be any number of clusters, and they can be of any shape. There are only two parameters to choose / enter: epsilon, a 'reachability' distance, and minpoints, the minimum number of points for the resulting set to be considered a cluster. The problem (potentially) in high-dimensional space is the curse of dimensionality. That is, all points can become equidistant from all other points. Since DBSCAN uses distance directly, this could become a problem and require you to explore distances other than Euclidean or other remedies. Note that high dimensionality does not necessitate this problem, however. For more, see this excellent CV answer: Euclidean distance is usually not good for sparse data?
A non parametric clustering algorithm suitable for high dimensional data The most common clustering technique that meets your requirements would be DBSCAN. This finds points that are continuous by virtue of having shared nearest neighbors. There can be any number of clus
47,292
Fourier transform and the multivariate normal
The multivariate normal has some nice properties. In particular, if $x\sim N(\mu,\Sigma)$, then, for any matrix $A$, $Ax \sim N(A\mu, A\Sigma A^T)$. Noting that a (discrete) Fourier transform can an be written in matrix form as $FT(x) = Fx$, we see that $FT(x) \sim N(F\mu, F\Sigma F^T)$. You can prove this by checking the first and second moments. $E(Fx) = FE(x)$ and similar for $E((x- F\mu)(x-F\mu)^T)$). This idea is particularly important when $\Sigma$ is a circulant matrix, in which case $F\Sigma F^T$ is diagonal (and hence easier to work with numerically and theoretically).
Fourier transform and the multivariate normal
The multivariate normal has some nice properties. In particular, if $x\sim N(\mu,\Sigma)$, then, for any matrix $A$, $Ax \sim N(A\mu, A\Sigma A^T)$. Noting that a (discrete) Fourier transform can an
Fourier transform and the multivariate normal The multivariate normal has some nice properties. In particular, if $x\sim N(\mu,\Sigma)$, then, for any matrix $A$, $Ax \sim N(A\mu, A\Sigma A^T)$. Noting that a (discrete) Fourier transform can an be written in matrix form as $FT(x) = Fx$, we see that $FT(x) \sim N(F\mu, F\Sigma F^T)$. You can prove this by checking the first and second moments. $E(Fx) = FE(x)$ and similar for $E((x- F\mu)(x-F\mu)^T)$). This idea is particularly important when $\Sigma$ is a circulant matrix, in which case $F\Sigma F^T$ is diagonal (and hence easier to work with numerically and theoretically).
Fourier transform and the multivariate normal The multivariate normal has some nice properties. In particular, if $x\sim N(\mu,\Sigma)$, then, for any matrix $A$, $Ax \sim N(A\mu, A\Sigma A^T)$. Noting that a (discrete) Fourier transform can an
47,293
Fourier transform and the multivariate normal
Unfortunately, the definition and conventions for complex Multivariate Normal is not completely standardized. Perhaps "yours" is consistent with equatoion 2 of http://cran.r-project.org/web/packages/cmvnorm/vignettes/complicator.pdf , which is different than https://en.wikipedia.org/wiki/Complex_normal_distribution . You can invert the Fourier transform of a real Multivariate Normal per 0.7 equation 9b of https://www.cs.nyu.edu/~roweis/notes/gaussid.pdf . That will leave you with a real Multivariate normal, plus your existing one; then simulate to your heart's content. Once you have the exact definition and convention used in your complex Multivariate Normal, equation 9b needs to be adapted accordingly. You ought to be able to handle it at that point. The other way of going is to use 0.7 equation 9a of https://www.cs.nyu.edu/~roweis/notes/gaussid.pdf on x. But no matter which way you go, you're living dangerously if you don't understand the conventions used in your Fourier transform of μ. You seem to be playing fast and loose, as evidenced by your terminology of μ as the mean of a Multivariate Normal, and also as something on which you are applying Fourier transform to get μ~. It doesn't mean anything is wrong, but you can easily mix up things which use different conventions, and wind up with the wrong answer.
Fourier transform and the multivariate normal
Unfortunately, the definition and conventions for complex Multivariate Normal is not completely standardized. Perhaps "yours" is consistent with equatoion 2 of http://cran.r-project.org/web/packages/c
Fourier transform and the multivariate normal Unfortunately, the definition and conventions for complex Multivariate Normal is not completely standardized. Perhaps "yours" is consistent with equatoion 2 of http://cran.r-project.org/web/packages/cmvnorm/vignettes/complicator.pdf , which is different than https://en.wikipedia.org/wiki/Complex_normal_distribution . You can invert the Fourier transform of a real Multivariate Normal per 0.7 equation 9b of https://www.cs.nyu.edu/~roweis/notes/gaussid.pdf . That will leave you with a real Multivariate normal, plus your existing one; then simulate to your heart's content. Once you have the exact definition and convention used in your complex Multivariate Normal, equation 9b needs to be adapted accordingly. You ought to be able to handle it at that point. The other way of going is to use 0.7 equation 9a of https://www.cs.nyu.edu/~roweis/notes/gaussid.pdf on x. But no matter which way you go, you're living dangerously if you don't understand the conventions used in your Fourier transform of μ. You seem to be playing fast and loose, as evidenced by your terminology of μ as the mean of a Multivariate Normal, and also as something on which you are applying Fourier transform to get μ~. It doesn't mean anything is wrong, but you can easily mix up things which use different conventions, and wind up with the wrong answer.
Fourier transform and the multivariate normal Unfortunately, the definition and conventions for complex Multivariate Normal is not completely standardized. Perhaps "yours" is consistent with equatoion 2 of http://cran.r-project.org/web/packages/c
47,294
Modeling prices with the Hedonic regression
This type of approach clearly can work (and has evidently been used by tax authorities to set property taxes on my house for many years), so there needs to be some investigation of the sources of this difficulty. Understanding the nature of this data set is very important. If it is to be used for predicting prices of properties not in the data set you must be very certain that it is adequately representative of the population of properties of interest. It's possible there is some peculiarity in the way this particular sample was collected, so that some particular combinations of co-linear factors are leading to things like the negative coefficients for bathroom numbers. Re-evaluate the sample collection and the data coding, an oft-overlooked source of difficulty. Also, for your PCA-based approaches, the signs of coefficients for principal components depend on the directions of the associated eigenvectors, making it all too easy to create errors when you try to go back to the space of the original factors. Check that, too. You didn't specify the standard errors of your coefficient estimates, so some of your apparently anomalous coefficients might not be significantly different from 0. For example, a -80K coefficient per bathroom with a standard error of +/- 100K would not really be an issue; that probably just means that the high co-linearity makes it difficult to determine a value per bathroom, given its high association with land area, numbers of bedrooms, and so forth. If that's the case you should retain the coefficient when making predictions, as the apparently anomalous coefficient for bathrooms is probably helping to correct for price over-estimates based on some of its co-linear factors alone. You could try to figure out which combinations of factors are leading to these problems. Although stepwise selection of factors is not wise for building a final model, for troubleshooting you might consider starting with a simple model of price-bathroom relations and adding more factors to see which combinations of factors are leading to your problem. You also should take advantage of information from structured re-sampling of your data set to evaluate these issues. You don't say whether or how you have approached this crucial aspect of model validation. If you have, then cross-validation or bootstrap resampling may have already provided insights into the sources of your difficulty. If you haven't, consult An Introduction to Statistical Learning or similar references to see how to proceed.
Modeling prices with the Hedonic regression
This type of approach clearly can work (and has evidently been used by tax authorities to set property taxes on my house for many years), so there needs to be some investigation of the sources of this
Modeling prices with the Hedonic regression This type of approach clearly can work (and has evidently been used by tax authorities to set property taxes on my house for many years), so there needs to be some investigation of the sources of this difficulty. Understanding the nature of this data set is very important. If it is to be used for predicting prices of properties not in the data set you must be very certain that it is adequately representative of the population of properties of interest. It's possible there is some peculiarity in the way this particular sample was collected, so that some particular combinations of co-linear factors are leading to things like the negative coefficients for bathroom numbers. Re-evaluate the sample collection and the data coding, an oft-overlooked source of difficulty. Also, for your PCA-based approaches, the signs of coefficients for principal components depend on the directions of the associated eigenvectors, making it all too easy to create errors when you try to go back to the space of the original factors. Check that, too. You didn't specify the standard errors of your coefficient estimates, so some of your apparently anomalous coefficients might not be significantly different from 0. For example, a -80K coefficient per bathroom with a standard error of +/- 100K would not really be an issue; that probably just means that the high co-linearity makes it difficult to determine a value per bathroom, given its high association with land area, numbers of bedrooms, and so forth. If that's the case you should retain the coefficient when making predictions, as the apparently anomalous coefficient for bathrooms is probably helping to correct for price over-estimates based on some of its co-linear factors alone. You could try to figure out which combinations of factors are leading to these problems. Although stepwise selection of factors is not wise for building a final model, for troubleshooting you might consider starting with a simple model of price-bathroom relations and adding more factors to see which combinations of factors are leading to your problem. You also should take advantage of information from structured re-sampling of your data set to evaluate these issues. You don't say whether or how you have approached this crucial aspect of model validation. If you have, then cross-validation or bootstrap resampling may have already provided insights into the sources of your difficulty. If you haven't, consult An Introduction to Statistical Learning or similar references to see how to proceed.
Modeling prices with the Hedonic regression This type of approach clearly can work (and has evidently been used by tax authorities to set property taxes on my house for many years), so there needs to be some investigation of the sources of this
47,295
Modeling prices with the Hedonic regression
I know this is an old post; hope the message helps someone reading this thread who might approach the same problem. The logical premise that 0 rooms; and 0 living area = zero value is improper because what the model is ignoring is the underlying value of land. This also affects the "geographic" dispersion characteristics because exactly equal home sizes; baths; beds, living area etc will still show value differences correlated to location (and underlying land value) - but as house gets old, smaller, etc - the value will converge at land value; not at zero.
Modeling prices with the Hedonic regression
I know this is an old post; hope the message helps someone reading this thread who might approach the same problem. The logical premise that 0 rooms; and 0 living area = zero value is improper becaus
Modeling prices with the Hedonic regression I know this is an old post; hope the message helps someone reading this thread who might approach the same problem. The logical premise that 0 rooms; and 0 living area = zero value is improper because what the model is ignoring is the underlying value of land. This also affects the "geographic" dispersion characteristics because exactly equal home sizes; baths; beds, living area etc will still show value differences correlated to location (and underlying land value) - but as house gets old, smaller, etc - the value will converge at land value; not at zero.
Modeling prices with the Hedonic regression I know this is an old post; hope the message helps someone reading this thread who might approach the same problem. The logical premise that 0 rooms; and 0 living area = zero value is improper becaus
47,296
Modeling prices with the Hedonic regression
I think your last remark ("I think that the big number of dummy variables damages a little bit the regression") is spot on. The very anormal values you observe for some regession coefficients clearly points to multicollinearity. You might want to try ridge regression or principal components regression.
Modeling prices with the Hedonic regression
I think your last remark ("I think that the big number of dummy variables damages a little bit the regression") is spot on. The very anormal values you observe for some regession coefficients clearly
Modeling prices with the Hedonic regression I think your last remark ("I think that the big number of dummy variables damages a little bit the regression") is spot on. The very anormal values you observe for some regession coefficients clearly points to multicollinearity. You might want to try ridge regression or principal components regression.
Modeling prices with the Hedonic regression I think your last remark ("I think that the big number of dummy variables damages a little bit the regression") is spot on. The very anormal values you observe for some regession coefficients clearly
47,297
Modeling prices with the Hedonic regression
Use intercept in your model. This is very strong assumption, that when all variables would equal 0, then predicted price should be zero and it is not required, especially, that such a real estate would not appear in a train or test data set. Even if it is true, that real estate with all characteristics equal to zero should have price equal to zero, it require assumption, that your model control all factors of estate price, which is rather false. If you think it is so obvious that only real estate with all characteristics equal to zero should have price equal to zero, how much would you pay for real estate with 5m squared area? Because I would still be able to pay zero dollars for such an estate. Am I unreasonable or this assumption is unreasonable? Use semi-logarithmic regression, that is predict logarithm of dependant variable. When you use normal linear regression, it is like assuming, that total value of estate is equal to sum of value of every single characteristic. This can be wrong assumption. I think, that for example, if estate is in quiet area it increases the value of estate by x%, let's say by 30%, no by x\$, not by certain fixed amount of dollars. That is however, what your model is assuming. It is unreasonable to assume, that values of two estates, that one of them have 100 m and second have 10000 m would be increased by the same amount of dollars, let's say by 10000$. It rather would be increased by certain percentage. Use semi-logarithmic model, by that your model will assume, that final value of estate can be reduced to multiplication of every of its properties. It usually works better in such a situations, and it is standard way of proceeding in real estate value model (look in literature, don't try to invent a wheel). Try to add other terms to your model: for example squares of variables and their interactions. Investigate outliers. At least two points looks like outliers, try to figure out what they are, and why they have strange variable values. Maybe you can find error in this data or you can add some feature or interactions to capture such cases.
Modeling prices with the Hedonic regression
Use intercept in your model. This is very strong assumption, that when all variables would equal 0, then predicted price should be zero and it is not required, especially, that such a real estate woul
Modeling prices with the Hedonic regression Use intercept in your model. This is very strong assumption, that when all variables would equal 0, then predicted price should be zero and it is not required, especially, that such a real estate would not appear in a train or test data set. Even if it is true, that real estate with all characteristics equal to zero should have price equal to zero, it require assumption, that your model control all factors of estate price, which is rather false. If you think it is so obvious that only real estate with all characteristics equal to zero should have price equal to zero, how much would you pay for real estate with 5m squared area? Because I would still be able to pay zero dollars for such an estate. Am I unreasonable or this assumption is unreasonable? Use semi-logarithmic regression, that is predict logarithm of dependant variable. When you use normal linear regression, it is like assuming, that total value of estate is equal to sum of value of every single characteristic. This can be wrong assumption. I think, that for example, if estate is in quiet area it increases the value of estate by x%, let's say by 30%, no by x\$, not by certain fixed amount of dollars. That is however, what your model is assuming. It is unreasonable to assume, that values of two estates, that one of them have 100 m and second have 10000 m would be increased by the same amount of dollars, let's say by 10000$. It rather would be increased by certain percentage. Use semi-logarithmic model, by that your model will assume, that final value of estate can be reduced to multiplication of every of its properties. It usually works better in such a situations, and it is standard way of proceeding in real estate value model (look in literature, don't try to invent a wheel). Try to add other terms to your model: for example squares of variables and their interactions. Investigate outliers. At least two points looks like outliers, try to figure out what they are, and why they have strange variable values. Maybe you can find error in this data or you can add some feature or interactions to capture such cases.
Modeling prices with the Hedonic regression Use intercept in your model. This is very strong assumption, that when all variables would equal 0, then predicted price should be zero and it is not required, especially, that such a real estate woul
47,298
Calculate prediction values for linear curve estimation for next 5 intervals
You can do this in R using the predict function. For ease I used Month as predictor and Value as outcome. In the vector new are the predicted values as a function of Month. Please see also the plot that shows the projected values on the regression line. data=data.frame(Month=c(21:33), Value=c(6591.69, 6579.62, 7133.84, 6955.89, 7573.27, 7556.87, 7751.17, 8001.76, 8399.5, 8560.36, 8517.53, 8602.57, 8575.81)) attach(data) fit1<-lm(Value~Month, data=data) new<-predict(fit1, data.frame(Month=(c(34,35,36)))) plot(Value~Month, data, col="red", xlim=c(20,36), ylim=c(6000,10000)) abline(fit1, col="orange", lwd=2) abline(v=c(34,35,36), lty=6) points(34, new[1], col="blue") points(35, new[2], col="blue") points(36, new[3], col="blue")
Calculate prediction values for linear curve estimation for next 5 intervals
You can do this in R using the predict function. For ease I used Month as predictor and Value as outcome. In the vector new are the predicted values as a function of Month. Please see also the plot th
Calculate prediction values for linear curve estimation for next 5 intervals You can do this in R using the predict function. For ease I used Month as predictor and Value as outcome. In the vector new are the predicted values as a function of Month. Please see also the plot that shows the projected values on the regression line. data=data.frame(Month=c(21:33), Value=c(6591.69, 6579.62, 7133.84, 6955.89, 7573.27, 7556.87, 7751.17, 8001.76, 8399.5, 8560.36, 8517.53, 8602.57, 8575.81)) attach(data) fit1<-lm(Value~Month, data=data) new<-predict(fit1, data.frame(Month=(c(34,35,36)))) plot(Value~Month, data, col="red", xlim=c(20,36), ylim=c(6000,10000)) abline(fit1, col="orange", lwd=2) abline(v=c(34,35,36), lty=6) points(34, new[1], col="blue") points(35, new[2], col="blue") points(36, new[3], col="blue")
Calculate prediction values for linear curve estimation for next 5 intervals You can do this in R using the predict function. For ease I used Month as predictor and Value as outcome. In the vector new are the predicted values as a function of Month. Please see also the plot th
47,299
Foundational sufficient statistics
It's just a matter of understanding the notation. Preliminaries A random variable, such as $\boldsymbol X$, is a measurable function on a probability space, $$\boldsymbol X: \Omega \to \mathbb{R}^n.$$ A statistic $T$ is a measurable function $$T: \mathbb{R}^n \to \mathbb{R}.$$ The composite function $$T\circ \boldsymbol{X}:\Omega \to \mathbb{R};\ T(\boldsymbol{X})(\omega) = T(\boldsymbol{X}(\omega))$$ is therefore also a random variable. Let $\boldsymbol{x}\in\mathbb{R}^n$: it is a possible value of $\boldsymbol X$. Therefore $t = T(\boldsymbol{x})\in \mathbb R$ is a possible value of the statistic $T$. Notation The set-building notation used in this context is a shorthand--some would say an abuse of--the more explicit mathematical notation $$\{T(\boldsymbol X) = T(\boldsymbol x)\} = \{\omega\in\Omega\,|\,T(\boldsymbol{X}(\omega)) = T(\boldsymbol{x})\}= \{\omega\in\Omega\,|\,T(\boldsymbol{X}(\omega)) = t\}.$$ Let's call this set $\mathcal T$. The mathematical notation clearly exhibits $\mathcal T$ as a subset of $\Omega$ and, because $T\circ \boldsymbol X$ is measurable, it is an event. It is the set of all outcomes where the value of $T\circ\boldsymbol{X}$ equals a given value of the statistic $T$, namely $T(\boldsymbol{x}) = t$. In other words, $\mathcal T$ consists of all outcomes where the statistic $T$ has the value $t$. Similarly, the other set-building notations used in the quotation should be interpreted as $$\boldsymbol{X}^{*}(\boldsymbol{x}) = \{\boldsymbol{X} = \boldsymbol{x}\} = \{\omega\in\Omega\,|\,\boldsymbol{X}(\omega) = \boldsymbol{x}\}$$ $$\boldsymbol{Y}^{*}(\boldsymbol{x}) =\{\boldsymbol{Y} = \boldsymbol{x}\} = \{\omega\in\Omega\,|\,\boldsymbol{Y}(\omega) = \boldsymbol{x}\}.$$ Both of these are events: $\boldsymbol{X}^{*}(\boldsymbol{x})$ is the event where the value of $\boldsymbol X$ is $\boldsymbol x$ and $\boldsymbol{Y}^{*}(\boldsymbol{x})$ is the event where the value of $\boldsymbol Y$ is $\boldsymbol x$. They needn't be the same event, because $X$ and $Y$ are not necessarily the same random variable. Solution By construction, if we apply $T\circ \boldsymbol{X}$ to any element $\omega$ of either of these sets, we will obtain the value $T(\boldsymbol{x}) = t$, which by definition means $\omega\in\mathcal T$. We have merely observed that $$\boldsymbol{X}(\omega) = \boldsymbol{x} \implies T(\boldsymbol{X}(\omega)) = t$$ and $$\boldsymbol{Y}(\omega) = \boldsymbol{x} \implies T(\boldsymbol{Y}(\omega)) = t,$$ immediately proving that $$\boldsymbol{X}^{*}(\boldsymbol{x}) \subset \mathcal T$$ and $$\boldsymbol{Y}^{*}(\boldsymbol{x}) \subset \mathcal T,$$ QED.
Foundational sufficient statistics
It's just a matter of understanding the notation. Preliminaries A random variable, such as $\boldsymbol X$, is a measurable function on a probability space, $$\boldsymbol X: \Omega \to \mathbb{R}^n.$$
Foundational sufficient statistics It's just a matter of understanding the notation. Preliminaries A random variable, such as $\boldsymbol X$, is a measurable function on a probability space, $$\boldsymbol X: \Omega \to \mathbb{R}^n.$$ A statistic $T$ is a measurable function $$T: \mathbb{R}^n \to \mathbb{R}.$$ The composite function $$T\circ \boldsymbol{X}:\Omega \to \mathbb{R};\ T(\boldsymbol{X})(\omega) = T(\boldsymbol{X}(\omega))$$ is therefore also a random variable. Let $\boldsymbol{x}\in\mathbb{R}^n$: it is a possible value of $\boldsymbol X$. Therefore $t = T(\boldsymbol{x})\in \mathbb R$ is a possible value of the statistic $T$. Notation The set-building notation used in this context is a shorthand--some would say an abuse of--the more explicit mathematical notation $$\{T(\boldsymbol X) = T(\boldsymbol x)\} = \{\omega\in\Omega\,|\,T(\boldsymbol{X}(\omega)) = T(\boldsymbol{x})\}= \{\omega\in\Omega\,|\,T(\boldsymbol{X}(\omega)) = t\}.$$ Let's call this set $\mathcal T$. The mathematical notation clearly exhibits $\mathcal T$ as a subset of $\Omega$ and, because $T\circ \boldsymbol X$ is measurable, it is an event. It is the set of all outcomes where the value of $T\circ\boldsymbol{X}$ equals a given value of the statistic $T$, namely $T(\boldsymbol{x}) = t$. In other words, $\mathcal T$ consists of all outcomes where the statistic $T$ has the value $t$. Similarly, the other set-building notations used in the quotation should be interpreted as $$\boldsymbol{X}^{*}(\boldsymbol{x}) = \{\boldsymbol{X} = \boldsymbol{x}\} = \{\omega\in\Omega\,|\,\boldsymbol{X}(\omega) = \boldsymbol{x}\}$$ $$\boldsymbol{Y}^{*}(\boldsymbol{x}) =\{\boldsymbol{Y} = \boldsymbol{x}\} = \{\omega\in\Omega\,|\,\boldsymbol{Y}(\omega) = \boldsymbol{x}\}.$$ Both of these are events: $\boldsymbol{X}^{*}(\boldsymbol{x})$ is the event where the value of $\boldsymbol X$ is $\boldsymbol x$ and $\boldsymbol{Y}^{*}(\boldsymbol{x})$ is the event where the value of $\boldsymbol Y$ is $\boldsymbol x$. They needn't be the same event, because $X$ and $Y$ are not necessarily the same random variable. Solution By construction, if we apply $T\circ \boldsymbol{X}$ to any element $\omega$ of either of these sets, we will obtain the value $T(\boldsymbol{x}) = t$, which by definition means $\omega\in\mathcal T$. We have merely observed that $$\boldsymbol{X}(\omega) = \boldsymbol{x} \implies T(\boldsymbol{X}(\omega)) = t$$ and $$\boldsymbol{Y}(\omega) = \boldsymbol{x} \implies T(\boldsymbol{Y}(\omega)) = t,$$ immediately proving that $$\boldsymbol{X}^{*}(\boldsymbol{x}) \subset \mathcal T$$ and $$\boldsymbol{Y}^{*}(\boldsymbol{x}) \subset \mathcal T,$$ QED.
Foundational sufficient statistics It's just a matter of understanding the notation. Preliminaries A random variable, such as $\boldsymbol X$, is a measurable function on a probability space, $$\boldsymbol X: \Omega \to \mathbb{R}^n.$$
47,300
When should I use k-means instead of Spectral Clustering?
k-means is much much much faster. K-means is hard to beat performance wise, so it will work on larger data sets. That is probably the key factor. K-means is $O(n.k.d.i)$, i.e. linear. For large data sets, anything of $O(n^2)$ or worse is prohibitive. Spectral clustering is in $O(n^3)$. Which means it won't work for any reasonably large data set. It took already 7 seconds on a strong CPU for that second image - don't try this on larger data, you will not be happy. P.S. that image is outdated. The current version can be found in the sklearn documentation (not embedding, as I don't know if the image is CC-BY-SA-3.0 licenseable or not... your image upload may be violating copyright, although I doubt you'll get into trouble ...) Note the runtime information. k-means and DBSCAN take <0.02s on each of these tiny toy data sets, whereas spectral clustering is 23-734 times slower. Only affinity propagation is similarly bad.
When should I use k-means instead of Spectral Clustering?
k-means is much much much faster. K-means is hard to beat performance wise, so it will work on larger data sets. That is probably the key factor. K-means is $O(n.k.d.i)$, i.e. linear. For large data s
When should I use k-means instead of Spectral Clustering? k-means is much much much faster. K-means is hard to beat performance wise, so it will work on larger data sets. That is probably the key factor. K-means is $O(n.k.d.i)$, i.e. linear. For large data sets, anything of $O(n^2)$ or worse is prohibitive. Spectral clustering is in $O(n^3)$. Which means it won't work for any reasonably large data set. It took already 7 seconds on a strong CPU for that second image - don't try this on larger data, you will not be happy. P.S. that image is outdated. The current version can be found in the sklearn documentation (not embedding, as I don't know if the image is CC-BY-SA-3.0 licenseable or not... your image upload may be violating copyright, although I doubt you'll get into trouble ...) Note the runtime information. k-means and DBSCAN take <0.02s on each of these tiny toy data sets, whereas spectral clustering is 23-734 times slower. Only affinity propagation is similarly bad.
When should I use k-means instead of Spectral Clustering? k-means is much much much faster. K-means is hard to beat performance wise, so it will work on larger data sets. That is probably the key factor. K-means is $O(n.k.d.i)$, i.e. linear. For large data s