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
41,201
Measuring the smoothness of time series
If you assume that the relationship is linear, you can use this trend estimator: $T_{n-1}=\frac{V(t_n)-V(t_{n-1})}{t_{n}-t_{n-1}}$ ,take the mean of these for each patient (which is the measure of linearity), calculate the sum of the residuals^2 (which gives an idea about how much you can trust this linearity. You can use Student t-test to measure the strength of the linearity in the same way it is used to test the strength of a trend in a linear regression in case you have a big enough sample size. It is easier if you have a data sample we can use . HTH
Measuring the smoothness of time series
If you assume that the relationship is linear, you can use this trend estimator: $T_{n-1}=\frac{V(t_n)-V(t_{n-1})}{t_{n}-t_{n-1}}$ ,take the mean of these for each patient (which is the measure of lin
Measuring the smoothness of time series If you assume that the relationship is linear, you can use this trend estimator: $T_{n-1}=\frac{V(t_n)-V(t_{n-1})}{t_{n}-t_{n-1}}$ ,take the mean of these for each patient (which is the measure of linearity), calculate the sum of the residuals^2 (which gives an idea about how much you can trust this linearity. You can use Student t-test to measure the strength of the linearity in the same way it is used to test the strength of a trend in a linear regression in case you have a big enough sample size. It is easier if you have a data sample we can use . HTH
Measuring the smoothness of time series If you assume that the relationship is linear, you can use this trend estimator: $T_{n-1}=\frac{V(t_n)-V(t_{n-1})}{t_{n}-t_{n-1}}$ ,take the mean of these for each patient (which is the measure of lin
41,202
Correct way to compare two (very) different regression models?
Since the two models are not nested (that is, the independent variables of one model are not a subset of independent variables of the other model), one cannot use a maximum likelihood test. However, you can consider the AIC (Akaike Information Criterion) or one of its variants. If you have likelihoods of your models, let's call them $\mathcal{L}_1$ and $\mathcal{L}_2$, you can easily calculate the AIC's of your models with $AIC_{1} = -2 \log(\mathcal{L}_1) + 2\cdot K_1$ where $K_1$ is the number of estimable parameters in the first model. Now, a single AIC value is not informative, or, rather, it is only informative relative to alternative models. Therefore often, when you have several models, one calculates the differences of the AICs of models relative to the AIC of the model with the smallest AIC: $\Delta_i = AIC_i - AIC_{min} $ Now, you will not have a statistical test to compare these values. This is the information-theoretic approach, which is a different thing from the Neyman-Pearson hypothesis testing framework, and the two should not be mixed (Anderson 2001). However, there are some rules of thumb as to what is the magnitute of a delta that one considers "significant" (but in the common meaning of the word, and not as in "statistically significant"). In "Model selection and multimodel inference", Burnham and Anderson present the following table: Delta_i Level of empirical support of model i 0-2 Substantial 4-7 Considerably less > 10 Essentially none That is, if the difference of AIC of your two models is 4-7, you can assume that one of the model is "considerably" better supported by evidence than the other one. In fact, the authors state that It seems best not to associate the words significant or rejected with results under an information-theoretic paradigm. Questions concerning the strength of evidence for the models in the set are best addressed using the evidence ratio as well as an analysis of residuals, adjusted $R^2$ and other model diagnostics or descriptive statistics. The variants of AIC include $AIC_c$ (or c-AIC) which is suitable for small sample sizes, and QAIC (for overdispersed count data). There are alternatives, of course, which allow you actually to do hypothesis testing. See for example this question.
Correct way to compare two (very) different regression models?
Since the two models are not nested (that is, the independent variables of one model are not a subset of independent variables of the other model), one cannot use a maximum likelihood test. However, y
Correct way to compare two (very) different regression models? Since the two models are not nested (that is, the independent variables of one model are not a subset of independent variables of the other model), one cannot use a maximum likelihood test. However, you can consider the AIC (Akaike Information Criterion) or one of its variants. If you have likelihoods of your models, let's call them $\mathcal{L}_1$ and $\mathcal{L}_2$, you can easily calculate the AIC's of your models with $AIC_{1} = -2 \log(\mathcal{L}_1) + 2\cdot K_1$ where $K_1$ is the number of estimable parameters in the first model. Now, a single AIC value is not informative, or, rather, it is only informative relative to alternative models. Therefore often, when you have several models, one calculates the differences of the AICs of models relative to the AIC of the model with the smallest AIC: $\Delta_i = AIC_i - AIC_{min} $ Now, you will not have a statistical test to compare these values. This is the information-theoretic approach, which is a different thing from the Neyman-Pearson hypothesis testing framework, and the two should not be mixed (Anderson 2001). However, there are some rules of thumb as to what is the magnitute of a delta that one considers "significant" (but in the common meaning of the word, and not as in "statistically significant"). In "Model selection and multimodel inference", Burnham and Anderson present the following table: Delta_i Level of empirical support of model i 0-2 Substantial 4-7 Considerably less > 10 Essentially none That is, if the difference of AIC of your two models is 4-7, you can assume that one of the model is "considerably" better supported by evidence than the other one. In fact, the authors state that It seems best not to associate the words significant or rejected with results under an information-theoretic paradigm. Questions concerning the strength of evidence for the models in the set are best addressed using the evidence ratio as well as an analysis of residuals, adjusted $R^2$ and other model diagnostics or descriptive statistics. The variants of AIC include $AIC_c$ (or c-AIC) which is suitable for small sample sizes, and QAIC (for overdispersed count data). There are alternatives, of course, which allow you actually to do hypothesis testing. See for example this question.
Correct way to compare two (very) different regression models? Since the two models are not nested (that is, the independent variables of one model are not a subset of independent variables of the other model), one cannot use a maximum likelihood test. However, y
41,203
Correct way to compare two (very) different regression models?
You might be interesting in taking a look at the Vuong's test and the subsequent literature.
Correct way to compare two (very) different regression models?
You might be interesting in taking a look at the Vuong's test and the subsequent literature.
Correct way to compare two (very) different regression models? You might be interesting in taking a look at the Vuong's test and the subsequent literature.
Correct way to compare two (very) different regression models? You might be interesting in taking a look at the Vuong's test and the subsequent literature.
41,204
Volume of the 95% confidence ellipsoid
Suppose $U$, $V$, and $W$ are independent and have a standard normal distribution. Then by definition of the chi-squared distribution (as a sum of squares of iid normal variables), the sum of squares $U^2 + V^2 + W^2$ has a chi-squared distribution with three degrees of freedom. We find (via tables or calculation) that its upper 95th percentile is $7.815$. This means that 95% of all the probability lies within the set $$R_{0.95}=\{(u,v,w)\vert u^2 +v^2+w^2 \le 7.815\}.$$ This is a ball of radius $r = \sqrt{7.815}=2.795$; accordingly we obtain its volume $V = 4\pi r^3/3 = 91.51.$ You believe your data are obtained by rescaling $U$ to $X'=e_1U$, $V$ to $Y'=e_2V$, and $Z'=e_3W$ where $e_1,$ $e_2,$ and $e_3$ are the PCA eigenvalues (not their squares!) and then rotating $(X',Y',Z')$ into $(X,Y,Z)$. The rotation does not change volumes, but the initial rescaling means $R_{0.95}$ corresponds to the set $$\{(x,y,z)\vert (x/e_1)^2 + (y/e_2)^2 + (z/e_3)^2 \le 7.815\}$$ before the rotation occurs. Up to rotation, this is the so-called "confidence ellipse" and therefore has the same shape and volume. Because the orthogonal axes have been separately scaled by $e_1,$ $e_2,$ and $e_3$ (a linear transformation with determinant $e_1e_2e_3$), the new volume is $e_1 e_2 e_3 V = 91.51 e_1 e_2 e_3.$ Similar calculations handle any other level of "confidence," with $7.815$ (and thence $V$) replaced by the associated percentile of a $\chi^2_{(3)}$ distribution. It may be worth pointing out that a trajectory of a continuously moving point rarely is approximated by a trivariate normal distribution, so this whole program has to be considered approximate and exploratory. As such you could just adopt some standard convenient value for $V$ ($100$ comes to mind, corresponding to $95.96$% of the probability) if your purpose is to compare spreads of trajectories.
Volume of the 95% confidence ellipsoid
Suppose $U$, $V$, and $W$ are independent and have a standard normal distribution. Then by definition of the chi-squared distribution (as a sum of squares of iid normal variables), the sum of squares
Volume of the 95% confidence ellipsoid Suppose $U$, $V$, and $W$ are independent and have a standard normal distribution. Then by definition of the chi-squared distribution (as a sum of squares of iid normal variables), the sum of squares $U^2 + V^2 + W^2$ has a chi-squared distribution with three degrees of freedom. We find (via tables or calculation) that its upper 95th percentile is $7.815$. This means that 95% of all the probability lies within the set $$R_{0.95}=\{(u,v,w)\vert u^2 +v^2+w^2 \le 7.815\}.$$ This is a ball of radius $r = \sqrt{7.815}=2.795$; accordingly we obtain its volume $V = 4\pi r^3/3 = 91.51.$ You believe your data are obtained by rescaling $U$ to $X'=e_1U$, $V$ to $Y'=e_2V$, and $Z'=e_3W$ where $e_1,$ $e_2,$ and $e_3$ are the PCA eigenvalues (not their squares!) and then rotating $(X',Y',Z')$ into $(X,Y,Z)$. The rotation does not change volumes, but the initial rescaling means $R_{0.95}$ corresponds to the set $$\{(x,y,z)\vert (x/e_1)^2 + (y/e_2)^2 + (z/e_3)^2 \le 7.815\}$$ before the rotation occurs. Up to rotation, this is the so-called "confidence ellipse" and therefore has the same shape and volume. Because the orthogonal axes have been separately scaled by $e_1,$ $e_2,$ and $e_3$ (a linear transformation with determinant $e_1e_2e_3$), the new volume is $e_1 e_2 e_3 V = 91.51 e_1 e_2 e_3.$ Similar calculations handle any other level of "confidence," with $7.815$ (and thence $V$) replaced by the associated percentile of a $\chi^2_{(3)}$ distribution. It may be worth pointing out that a trajectory of a continuously moving point rarely is approximated by a trivariate normal distribution, so this whole program has to be considered approximate and exploratory. As such you could just adopt some standard convenient value for $V$ ($100$ comes to mind, corresponding to $95.96$% of the probability) if your purpose is to compare spreads of trajectories.
Volume of the 95% confidence ellipsoid Suppose $U$, $V$, and $W$ are independent and have a standard normal distribution. Then by definition of the chi-squared distribution (as a sum of squares of iid normal variables), the sum of squares
41,205
Interpretation of weights in non-linear least squares regression
The weights should equal the counts, because those will be inversely proportional to the variances of the errors. Specifically, the model for the data $(x_i, y_i, n_i)$ is $$y_i \sim \lambda \Phi((\log(x_i) - \mu)/\sigma + \varepsilon_i$$ with $\mu, \sigma \gt 0,$ and $\lambda \gt 0$ the parameters and $\varepsilon_i$ are independent random variables with zero means and variances $$\text{Var}(\varepsilon(i)) = \sigma^2 / n_i$$ where $n_i$ are the counts. The fit to the logarithm of $x$ is visually ok: In this figure the x-axis is on a logarithmic scale, the point symbols have areas proportional to the counts (so that large circles will have more influence in the fitting than small ones), and the red line is a least-squares fit. It is clear the model is not really appropriate: the residuals for smaller values of $y$ tend to be small, regardless of the counts. Possibly the sum of squares of relative errors should be minimized to obtain an appropriate fit. It is evident that the fit is poor for the largest $x$, but those also have small counts. The R code with (my version of) the data and the fitting and plotting procedures follows. y <- c(1, 1, 2, 1, 2, 1, 3, 4, 22, 30, 44, 58, 68, 69, 71, 72, 75, 72, 80, 78, 87, 86, 80, 82, 92, 90, 85, 61, 38, 36) / 100 x <- ceiling(exp(seq(log(20), log(500), length.out=length(y)))) counts <- c( 10, 3, 17, 20, 38, 31, 44, 55, 58, 68, 77, 82, 86, 82, 77, 75, 70, 65, 68, 51, 47, 41, 38, 30, 22, 14, 9, 4, 2, 1) # # The least-squares criterion. # theta[1] is a location, theta[2] an x-scale, and theta[3] a y-scale. # f <- function(theta, x=x, y=y, n=counts) sum(n * (y - pnorm(x, theta[1], theta[2]) * theta[3])^2) / sum(n) # # Perform a count-weighted least-squares fit. # xi = log(x) fit <- optim(c(median(xi), sd(xi), max(y) * sd(xi)), f, x=xi, y=y, n=counts) # # Plot the result. # par(mfrow=c(1,1)) plot(x, y, log="x", xlog=TRUE, pch=19, col="Gray", cex=sqrt(counts/12)) points(x, y, cex=sqrt(counts/10)) curve(fit$par[3] * pnorm(log(x), fit$par[1], fit$par[2]), from=10, to=1000, col="Red", add=TRUE)
Interpretation of weights in non-linear least squares regression
The weights should equal the counts, because those will be inversely proportional to the variances of the errors. Specifically, the model for the data $(x_i, y_i, n_i)$ is $$y_i \sim \lambda \Phi((\l
Interpretation of weights in non-linear least squares regression The weights should equal the counts, because those will be inversely proportional to the variances of the errors. Specifically, the model for the data $(x_i, y_i, n_i)$ is $$y_i \sim \lambda \Phi((\log(x_i) - \mu)/\sigma + \varepsilon_i$$ with $\mu, \sigma \gt 0,$ and $\lambda \gt 0$ the parameters and $\varepsilon_i$ are independent random variables with zero means and variances $$\text{Var}(\varepsilon(i)) = \sigma^2 / n_i$$ where $n_i$ are the counts. The fit to the logarithm of $x$ is visually ok: In this figure the x-axis is on a logarithmic scale, the point symbols have areas proportional to the counts (so that large circles will have more influence in the fitting than small ones), and the red line is a least-squares fit. It is clear the model is not really appropriate: the residuals for smaller values of $y$ tend to be small, regardless of the counts. Possibly the sum of squares of relative errors should be minimized to obtain an appropriate fit. It is evident that the fit is poor for the largest $x$, but those also have small counts. The R code with (my version of) the data and the fitting and plotting procedures follows. y <- c(1, 1, 2, 1, 2, 1, 3, 4, 22, 30, 44, 58, 68, 69, 71, 72, 75, 72, 80, 78, 87, 86, 80, 82, 92, 90, 85, 61, 38, 36) / 100 x <- ceiling(exp(seq(log(20), log(500), length.out=length(y)))) counts <- c( 10, 3, 17, 20, 38, 31, 44, 55, 58, 68, 77, 82, 86, 82, 77, 75, 70, 65, 68, 51, 47, 41, 38, 30, 22, 14, 9, 4, 2, 1) # # The least-squares criterion. # theta[1] is a location, theta[2] an x-scale, and theta[3] a y-scale. # f <- function(theta, x=x, y=y, n=counts) sum(n * (y - pnorm(x, theta[1], theta[2]) * theta[3])^2) / sum(n) # # Perform a count-weighted least-squares fit. # xi = log(x) fit <- optim(c(median(xi), sd(xi), max(y) * sd(xi)), f, x=xi, y=y, n=counts) # # Plot the result. # par(mfrow=c(1,1)) plot(x, y, log="x", xlog=TRUE, pch=19, col="Gray", cex=sqrt(counts/12)) points(x, y, cex=sqrt(counts/10)) curve(fit$par[3] * pnorm(log(x), fit$par[1], fit$par[2]), from=10, to=1000, col="Red", add=TRUE)
Interpretation of weights in non-linear least squares regression The weights should equal the counts, because those will be inversely proportional to the variances of the errors. Specifically, the model for the data $(x_i, y_i, n_i)$ is $$y_i \sim \lambda \Phi((\l
41,206
Winning probability in a game with multiple players
If you assume that the weaker players won't gang up on the stronger player (a very strong assumption!), then a reasonable model would be the following. (I'm following the notation of the "theory" section of the Wikipedia article on ELO.) let $R_A, R_B, R_C$ be the ratings of the three players. let $Q_A = 10^{R_A/400}$; define $Q_B, Q_C$ similarly. the probability of $A$ winning is $Q_A/(Q_A + Q_B + Q_C)$ and similarly for the other two players. With the numbers you gave, $C$ has a probability of about $0.613$ of winning, and $A, B$ each have probability $0.194$ of winning. This seems like the "obvious" generalization of the Elo math. The most obvious problem, to me, is that I wouldn't know how to update these ratings after a multi-player game is played.
Winning probability in a game with multiple players
If you assume that the weaker players won't gang up on the stronger player (a very strong assumption!), then a reasonable model would be the following. (I'm following the notation of the "theory" sec
Winning probability in a game with multiple players If you assume that the weaker players won't gang up on the stronger player (a very strong assumption!), then a reasonable model would be the following. (I'm following the notation of the "theory" section of the Wikipedia article on ELO.) let $R_A, R_B, R_C$ be the ratings of the three players. let $Q_A = 10^{R_A/400}$; define $Q_B, Q_C$ similarly. the probability of $A$ winning is $Q_A/(Q_A + Q_B + Q_C)$ and similarly for the other two players. With the numbers you gave, $C$ has a probability of about $0.613$ of winning, and $A, B$ each have probability $0.194$ of winning. This seems like the "obvious" generalization of the Elo math. The most obvious problem, to me, is that I wouldn't know how to update these ratings after a multi-player game is played.
Winning probability in a game with multiple players If you assume that the weaker players won't gang up on the stronger player (a very strong assumption!), then a reasonable model would be the following. (I'm following the notation of the "theory" sec
41,207
Winning probability in a game with multiple players
Would the weaker players not band together against the stronger players? That is what happens in the truel (three player pistol fight with one shot per person). I observed that in monopoly and in three-player chess also. That said, if one assumes the winning or losing of A over B and C are independent, then with the probabilities you mentioned P(A wins against B and C) = P(A wins against B) * P(A wins against C) = .5 * .24 = .12 = P(B wins against A and C) and P(C wins against both A and B)= .76 * .76 = .5776 . The remainder is the probability of no-one winning. Note that in three-way chess, no-one winning because the situation "A wins against B, B wins against C and C wins against A" is not possible, as the first one to check-mate anyone is the overall winner, and the other two lose equally. So there the whole calculation would not hold. Summarizing I would say there is no unique answer to your question, you need to specify how ties are broken, if collaboration can occur, etc. This is not a statistics question, it is game theory.
Winning probability in a game with multiple players
Would the weaker players not band together against the stronger players? That is what happens in the truel (three player pistol fight with one shot per person). I observed that in monopoly and in thr
Winning probability in a game with multiple players Would the weaker players not band together against the stronger players? That is what happens in the truel (three player pistol fight with one shot per person). I observed that in monopoly and in three-player chess also. That said, if one assumes the winning or losing of A over B and C are independent, then with the probabilities you mentioned P(A wins against B and C) = P(A wins against B) * P(A wins against C) = .5 * .24 = .12 = P(B wins against A and C) and P(C wins against both A and B)= .76 * .76 = .5776 . The remainder is the probability of no-one winning. Note that in three-way chess, no-one winning because the situation "A wins against B, B wins against C and C wins against A" is not possible, as the first one to check-mate anyone is the overall winner, and the other two lose equally. So there the whole calculation would not hold. Summarizing I would say there is no unique answer to your question, you need to specify how ties are broken, if collaboration can occur, etc. This is not a statistics question, it is game theory.
Winning probability in a game with multiple players Would the weaker players not band together against the stronger players? That is what happens in the truel (three player pistol fight with one shot per person). I observed that in monopoly and in thr
41,208
Inverting a hypothesis test: nitpicky detail
First of all, welcome to the site! As Glen_b pointed out in a comment, for discrete distributions $P_\theta(\theta\in C(\mathbf{X}))$ won't be exactly equal to $1-\alpha$ for all $\theta$. You are however correct in that the classic defintion of a confidence interval is that $\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))=1-\alpha$ and not just that $\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))\geq 1-\alpha$. The tiny piece that is missing is the following. $R(\theta)$ is the rejection region of a level $\alpha$ test. This means that $$P_{\theta}(\mathbf{X}\in R(\theta))\leq \alpha\qquad\forall \theta\in\Theta,$$ a fact that is used in the proof. But, by definition, it also means that $$\sup_{\theta\in\Theta} P_{\theta}(\mathbf{X}\in R(\theta))=\alpha.$$ Consequently, it follows that $$\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))=\inf_{\theta\in\Theta}\Big(1- P_{\theta}(\mathbf{X}\in R(\theta))\Big)=1-\sup_{\theta\in\Theta} P_{\theta}(\mathbf{X}\in R(\theta))=1-\alpha,$$ just as we were hoping.
Inverting a hypothesis test: nitpicky detail
First of all, welcome to the site! As Glen_b pointed out in a comment, for discrete distributions $P_\theta(\theta\in C(\mathbf{X}))$ won't be exactly equal to $1-\alpha$ for all $\theta$. You are how
Inverting a hypothesis test: nitpicky detail First of all, welcome to the site! As Glen_b pointed out in a comment, for discrete distributions $P_\theta(\theta\in C(\mathbf{X}))$ won't be exactly equal to $1-\alpha$ for all $\theta$. You are however correct in that the classic defintion of a confidence interval is that $\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))=1-\alpha$ and not just that $\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))\geq 1-\alpha$. The tiny piece that is missing is the following. $R(\theta)$ is the rejection region of a level $\alpha$ test. This means that $$P_{\theta}(\mathbf{X}\in R(\theta))\leq \alpha\qquad\forall \theta\in\Theta,$$ a fact that is used in the proof. But, by definition, it also means that $$\sup_{\theta\in\Theta} P_{\theta}(\mathbf{X}\in R(\theta))=\alpha.$$ Consequently, it follows that $$\inf_{\theta\in\Theta}P_\theta(\theta\in C(\mathbf{X}))=\inf_{\theta\in\Theta}\Big(1- P_{\theta}(\mathbf{X}\in R(\theta))\Big)=1-\sup_{\theta\in\Theta} P_{\theta}(\mathbf{X}\in R(\theta))=1-\alpha,$$ just as we were hoping.
Inverting a hypothesis test: nitpicky detail First of all, welcome to the site! As Glen_b pointed out in a comment, for discrete distributions $P_\theta(\theta\in C(\mathbf{X}))$ won't be exactly equal to $1-\alpha$ for all $\theta$. You are how
41,209
MDS and PCA eigenvalues and eigenvectors
I find it helpful to consider the singular value decomposition for questions like this with the assumption that $X$ is a real matrix. Writing $X = UDV^T$, we can see that $XX^T = UD^2U^T$ and $X^TX = VD^2V^T$. As we can see, the eigenvalues of both $XX^T$ and $X^TX$ are contained in the diagonal matrix $D^2$ and are indeed equal. Also, we see that the matrix of eigenvectors of $XX^T$ is $U$, while the matrix of eigenvectors of $X^TX$ is $V$. Because $$ X^TU = VDU^TU = VD, $$ we have the relationship $X^TU = VD$, similar to that pointed out by whuber. Assuming $D$ is nonsingular, two additional properties that prove to be quite useful are: $$ \begin{align} U &= XVD^{-1}\\ V &= X^TUD^{-1}. \end{align} $$
MDS and PCA eigenvalues and eigenvectors
I find it helpful to consider the singular value decomposition for questions like this with the assumption that $X$ is a real matrix. Writing $X = UDV^T$, we can see that $XX^T = UD^2U^T$ and $X^TX =
MDS and PCA eigenvalues and eigenvectors I find it helpful to consider the singular value decomposition for questions like this with the assumption that $X$ is a real matrix. Writing $X = UDV^T$, we can see that $XX^T = UD^2U^T$ and $X^TX = VD^2V^T$. As we can see, the eigenvalues of both $XX^T$ and $X^TX$ are contained in the diagonal matrix $D^2$ and are indeed equal. Also, we see that the matrix of eigenvectors of $XX^T$ is $U$, while the matrix of eigenvectors of $X^TX$ is $V$. Because $$ X^TU = VDU^TU = VD, $$ we have the relationship $X^TU = VD$, similar to that pointed out by whuber. Assuming $D$ is nonsingular, two additional properties that prove to be quite useful are: $$ \begin{align} U &= XVD^{-1}\\ V &= X^TUD^{-1}. \end{align} $$
MDS and PCA eigenvalues and eigenvectors I find it helpful to consider the singular value decomposition for questions like this with the assumption that $X$ is a real matrix. Writing $X = UDV^T$, we can see that $XX^T = UD^2U^T$ and $X^TX =
41,210
Continuous Kolmogorov-Smirnov test?
Indeed. Check out Anderson-Darling, Cramér-von Mises tests, etc. http://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test is a start. All these tests seem problematic to me for other reasons, not least because they don't tell you directly what is wrong. Increasingly with bigger datasets they reject hypotheses that are practically acceptable on the basis of statistically significant but practically insignificant deviations from what distribution is being fitted. Quantile-quantile plots are a more practical technology.
Continuous Kolmogorov-Smirnov test?
Indeed. Check out Anderson-Darling, Cramér-von Mises tests, etc. http://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test is a start. All these tests seem problematic to me for other reasons, not l
Continuous Kolmogorov-Smirnov test? Indeed. Check out Anderson-Darling, Cramér-von Mises tests, etc. http://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test is a start. All these tests seem problematic to me for other reasons, not least because they don't tell you directly what is wrong. Increasingly with bigger datasets they reject hypotheses that are practically acceptable on the basis of statistically significant but practically insignificant deviations from what distribution is being fitted. Quantile-quantile plots are a more practical technology.
Continuous Kolmogorov-Smirnov test? Indeed. Check out Anderson-Darling, Cramér-von Mises tests, etc. http://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test is a start. All these tests seem problematic to me for other reasons, not l
41,211
Why do categorical predictor variables in regression need to be recoded as multiple predictors?
To elaborate on the answers of our colleagues above: say you map purple, blue, red to $x = 1, 2, 3$. Say $x$ represents the colour of a hat, and $y$ sales. Then if we have a model with an intercept, call it $a$ and the coefficient of $x$, call it $b$, then we'd be saying: $y = a + b x$ We only get to choose one $b$ here, which has to cater for all the different colours. Imagine more blue hats are sold than purple hats, and more blue are sold than red, then our model suits the purple-blue relationship ($1b<2b$), but not the blue-red relationship $2b<3b$ ! If we use dummy variables then we might have a model like: $y = a + b_{\mathrm{red}}x_{\mathrm{red}} + b_{\mathrm{purp}} x_{\mathrm{purp}}$ And this doesn't run into the same ordering problems as the first model. Note we only need two dummy variables if there is an intercept, as this becomes the baseline for blue.
Why do categorical predictor variables in regression need to be recoded as multiple predictors?
To elaborate on the answers of our colleagues above: say you map purple, blue, red to $x = 1, 2, 3$. Say $x$ represents the colour of a hat, and $y$ sales. Then if we have a model with an intercept, c
Why do categorical predictor variables in regression need to be recoded as multiple predictors? To elaborate on the answers of our colleagues above: say you map purple, blue, red to $x = 1, 2, 3$. Say $x$ represents the colour of a hat, and $y$ sales. Then if we have a model with an intercept, call it $a$ and the coefficient of $x$, call it $b$, then we'd be saying: $y = a + b x$ We only get to choose one $b$ here, which has to cater for all the different colours. Imagine more blue hats are sold than purple hats, and more blue are sold than red, then our model suits the purple-blue relationship ($1b<2b$), but not the blue-red relationship $2b<3b$ ! If we use dummy variables then we might have a model like: $y = a + b_{\mathrm{red}}x_{\mathrm{red}} + b_{\mathrm{purp}} x_{\mathrm{purp}}$ And this doesn't run into the same ordering problems as the first model. Note we only need two dummy variables if there is an intercept, as this becomes the baseline for blue.
Why do categorical predictor variables in regression need to be recoded as multiple predictors? To elaborate on the answers of our colleagues above: say you map purple, blue, red to $x = 1, 2, 3$. Say $x$ represents the colour of a hat, and $y$ sales. Then if we have a model with an intercept, c
41,212
Why do categorical predictor variables in regression need to be recoded as multiple predictors?
It depends what data are represented by colours. You can use colour as a single variable with colours expressed by numbers in regression if colours represent a scale for some data. For example, purple means wind speed 10 m/s, blue means 20 m/s, and red colour means wind speed 30 m/s. So we can say something (wind in example) is two times larger if the colour is blue compared if colour is purple, and so on. The usual practice is to code each colour as a dummy (boolean) variables for a regression if quantitative comparison of colours is not possible.
Why do categorical predictor variables in regression need to be recoded as multiple predictors?
It depends what data are represented by colours. You can use colour as a single variable with colours expressed by numbers in regression if colours represent a scale for some data. For example, purple
Why do categorical predictor variables in regression need to be recoded as multiple predictors? It depends what data are represented by colours. You can use colour as a single variable with colours expressed by numbers in regression if colours represent a scale for some data. For example, purple means wind speed 10 m/s, blue means 20 m/s, and red colour means wind speed 30 m/s. So we can say something (wind in example) is two times larger if the colour is blue compared if colour is purple, and so on. The usual practice is to code each colour as a dummy (boolean) variables for a regression if quantitative comparison of colours is not possible.
Why do categorical predictor variables in regression need to be recoded as multiple predictors? It depends what data are represented by colours. You can use colour as a single variable with colours expressed by numbers in regression if colours represent a scale for some data. For example, purple
41,213
Cluster analysis of ordinal variables (Likert scale)
You are trying to determine an appropriate distance measure, and clearly you are noticing how tricky this can be. Ordinal data is not interval data. You should consider: whether the distance between each category is the same (is the distance between 2 and 3 the same as the distance between 3 and 4?) whether special consideration needs to be given to the neutral/null category (in your case, 1: no effect). whether several of your causes variables need to be considered together. For example, you may decide to sum 2 related variables together and treat them as one (derivative) variable for purposes of clustering. These considerations have psychological roots. For example, people tend to give more weight to the difference between options at the ends of the scale than in the middle. You may decide on an approach based on these considerations that involves: - cleaning the data - transforming the current scale into one in Euclidean space. ... or, you may decide this is not necessary for your purposes. Existing research that uses the Likert scale often utilizes distance measures based on Cosine distance and Pearson Correlation. You may find the following useful: Under what conditions should Likert scales be used as ordinal or interval data? https://news.ycombinator.com/item?id=2423313
Cluster analysis of ordinal variables (Likert scale)
You are trying to determine an appropriate distance measure, and clearly you are noticing how tricky this can be. Ordinal data is not interval data. You should consider: whether the distance between
Cluster analysis of ordinal variables (Likert scale) You are trying to determine an appropriate distance measure, and clearly you are noticing how tricky this can be. Ordinal data is not interval data. You should consider: whether the distance between each category is the same (is the distance between 2 and 3 the same as the distance between 3 and 4?) whether special consideration needs to be given to the neutral/null category (in your case, 1: no effect). whether several of your causes variables need to be considered together. For example, you may decide to sum 2 related variables together and treat them as one (derivative) variable for purposes of clustering. These considerations have psychological roots. For example, people tend to give more weight to the difference between options at the ends of the scale than in the middle. You may decide on an approach based on these considerations that involves: - cleaning the data - transforming the current scale into one in Euclidean space. ... or, you may decide this is not necessary for your purposes. Existing research that uses the Likert scale often utilizes distance measures based on Cosine distance and Pearson Correlation. You may find the following useful: Under what conditions should Likert scales be used as ordinal or interval data? https://news.ycombinator.com/item?id=2423313
Cluster analysis of ordinal variables (Likert scale) You are trying to determine an appropriate distance measure, and clearly you are noticing how tricky this can be. Ordinal data is not interval data. You should consider: whether the distance between
41,214
Cluster analysis of ordinal variables (Likert scale)
I am not sure about the amount of data you need to fit the a model, but you are asking for a common usage of Factor Analysis. Check this page of Quick-R that will help you to deal with some initials examples on how to map your questions to a latent space. You can use it to see the relations among similar questions that will be loaded in the same factors http://www.statmethods.net/advstats/factor.html The previous technique is part of Exploratory Factor Analysis. I am not an expert, but summarizing what the link I mentioned says, for Confirmatory Factor Analysis you would try Structural Equation Modelling, which you can try with R via the sem package http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf Good luck.
Cluster analysis of ordinal variables (Likert scale)
I am not sure about the amount of data you need to fit the a model, but you are asking for a common usage of Factor Analysis. Check this page of Quick-R that will help you to deal with some initials e
Cluster analysis of ordinal variables (Likert scale) I am not sure about the amount of data you need to fit the a model, but you are asking for a common usage of Factor Analysis. Check this page of Quick-R that will help you to deal with some initials examples on how to map your questions to a latent space. You can use it to see the relations among similar questions that will be loaded in the same factors http://www.statmethods.net/advstats/factor.html The previous technique is part of Exploratory Factor Analysis. I am not an expert, but summarizing what the link I mentioned says, for Confirmatory Factor Analysis you would try Structural Equation Modelling, which you can try with R via the sem package http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf Good luck.
Cluster analysis of ordinal variables (Likert scale) I am not sure about the amount of data you need to fit the a model, but you are asking for a common usage of Factor Analysis. Check this page of Quick-R that will help you to deal with some initials e
41,215
Cluster analysis of ordinal variables (Likert scale)
You need multiple correspondence analysis (MCA). Check out this article: https://datascienceplus.com/using-mca-and-variable-clustering-in-r-for-insights-in-customer-attrition/
Cluster analysis of ordinal variables (Likert scale)
You need multiple correspondence analysis (MCA). Check out this article: https://datascienceplus.com/using-mca-and-variable-clustering-in-r-for-insights-in-customer-attrition/
Cluster analysis of ordinal variables (Likert scale) You need multiple correspondence analysis (MCA). Check out this article: https://datascienceplus.com/using-mca-and-variable-clustering-in-r-for-insights-in-customer-attrition/
Cluster analysis of ordinal variables (Likert scale) You need multiple correspondence analysis (MCA). Check out this article: https://datascienceplus.com/using-mca-and-variable-clustering-in-r-for-insights-in-customer-attrition/
41,216
Intuition behind Dvoretzky Kiefer Wolfowitz inequality
Consider an i.i.d. sample $X_{1}, \dots, X_{n}$ from a distribution with CDF $F\left(x\right)$, and let \begin{equation} \widehat{F}_{n}\left(x\right) = \dfrac{1}{n}\sum_{i = 1}^{n}\mathbb{I}_{X_{i} \leq x} \end{equation} denote the usual empirical distribution function. The Dvoretzky-Kiefer-Wolfowitz inequality states that \begin{equation} \operatorname{Pr}\left(\sup_{x\in\mathbb{R}}\left\{\sqrt{n}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right|\right\} > \epsilon\right) \leq 2e^{-2\epsilon^{2}} \end{equation} for all $\epsilon > 0$. To provide some intuition behind this result, first recognise that for any $x$ such that $F\left(x\right) \in \left(0, 1\right)$, the Central Limit Theorem (or alternatively using the weaker De Moivre–Laplace theorem) gives that \begin{equation} \sqrt{n}\left(\widehat{F}_{n}\left(x\right) - F\left(x\right)\right) \overset{\mathrm{d}}{\to} \mathcal{N}\left(0, F\left(x\right)\left(1 - F\left(x\right)\right)\right) \end{equation} since $\widehat{F}_{n}\left(x\right)$ is essentially the sample proportion of observations not greater than $x$, which we can compute to have variance \begin{equation} \operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right) = \dfrac{F\left(x\right)\left(1 - F\left(x\right)\right)}{n} \end{equation} (eg. by the binomial distribution). The takeaway here is that $\widehat{F}_{n}\left(x\right)$ will be approximately Gaussian for large $n$. Now, we use the fact that for a Gaussian random variable $Y \sim \mathcal{N}\left(\mu, \sigma^{2}\right)$, a well-known two-sided concentration inequality is given by \begin{equation} \operatorname{Pr}\left(\left|Y - \mu\right| > \varepsilon\right) \leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\sigma^{2}}\right) \end{equation} for all $\varepsilon > 0$. As an aside, this inequality can be proven using the moment generating function of a Gaussian distribution in combination with the Chernoff bound to obtain the one-sided tail inequality, and then Boole's inequality for the two-sided tail inequality. See for example (2.9) of here to obtain further details. Here is where the 'intuitive' step comes in. If we treat $\widehat{F}_{n}\left(x\right)$ as actually being Gaussian and apply the concentration inequality for Gaussians, we will recover the Dvoretzky-Kiefer-Wolfowitz inequality. Note that $F\left(x\right)\left(1 - F\left(x\right)\right)$ is maximised at $F\left(x\right) = 1/2$, hence $\sup_{x\in\mathbb{R}}F\left(x\right)\left(1 - F\left(x\right)\right) = 1/4$. So this gives \begin{align} \operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right) &= \dfrac{F\left(x\right)\left(1 - F\left(x\right)\right)}{n} \\ &\leq \dfrac{1}{4n} \end{align} Treating $\widehat{F}_{n}\left(x\right)$ as Gaussian and plugging it into the concentration inequality gives for any $x \in \mathbb{R}$: \begin{equation} \operatorname{Pr}\left(\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \varepsilon\right) \leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right)}\right) \end{equation} Taking the worst-case supremum over $x$ on either side separately: \begin{align} \operatorname{Pr}\left(\sup_{x\in\mathbb{R}}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \varepsilon\right) &\leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\sup_{x'\in\mathbb{R}}\operatorname{Var}\left(\widehat{F}_{n}\left(x'\right)\right)}\right) \\ &\leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2/\left(4n\right)}\right) \\ &= 2e^{-2n\varepsilon^{2}} \end{align} Applying the substitution $\epsilon = \sqrt{n}\varepsilon$ then yields the Dvoretzky-Kiefer-Wolfowitz inequality as originally claimed: \begin{equation} \operatorname{Pr}\left(\sqrt{n}\sup_{x\in\mathbb{R}}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \epsilon\right) \leq 2e^{-2\epsilon^{2}} \end{equation}
Intuition behind Dvoretzky Kiefer Wolfowitz inequality
Consider an i.i.d. sample $X_{1}, \dots, X_{n}$ from a distribution with CDF $F\left(x\right)$, and let \begin{equation} \widehat{F}_{n}\left(x\right) = \dfrac{1}{n}\sum_{i = 1}^{n}\mathbb{I}_{X_{i} \
Intuition behind Dvoretzky Kiefer Wolfowitz inequality Consider an i.i.d. sample $X_{1}, \dots, X_{n}$ from a distribution with CDF $F\left(x\right)$, and let \begin{equation} \widehat{F}_{n}\left(x\right) = \dfrac{1}{n}\sum_{i = 1}^{n}\mathbb{I}_{X_{i} \leq x} \end{equation} denote the usual empirical distribution function. The Dvoretzky-Kiefer-Wolfowitz inequality states that \begin{equation} \operatorname{Pr}\left(\sup_{x\in\mathbb{R}}\left\{\sqrt{n}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right|\right\} > \epsilon\right) \leq 2e^{-2\epsilon^{2}} \end{equation} for all $\epsilon > 0$. To provide some intuition behind this result, first recognise that for any $x$ such that $F\left(x\right) \in \left(0, 1\right)$, the Central Limit Theorem (or alternatively using the weaker De Moivre–Laplace theorem) gives that \begin{equation} \sqrt{n}\left(\widehat{F}_{n}\left(x\right) - F\left(x\right)\right) \overset{\mathrm{d}}{\to} \mathcal{N}\left(0, F\left(x\right)\left(1 - F\left(x\right)\right)\right) \end{equation} since $\widehat{F}_{n}\left(x\right)$ is essentially the sample proportion of observations not greater than $x$, which we can compute to have variance \begin{equation} \operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right) = \dfrac{F\left(x\right)\left(1 - F\left(x\right)\right)}{n} \end{equation} (eg. by the binomial distribution). The takeaway here is that $\widehat{F}_{n}\left(x\right)$ will be approximately Gaussian for large $n$. Now, we use the fact that for a Gaussian random variable $Y \sim \mathcal{N}\left(\mu, \sigma^{2}\right)$, a well-known two-sided concentration inequality is given by \begin{equation} \operatorname{Pr}\left(\left|Y - \mu\right| > \varepsilon\right) \leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\sigma^{2}}\right) \end{equation} for all $\varepsilon > 0$. As an aside, this inequality can be proven using the moment generating function of a Gaussian distribution in combination with the Chernoff bound to obtain the one-sided tail inequality, and then Boole's inequality for the two-sided tail inequality. See for example (2.9) of here to obtain further details. Here is where the 'intuitive' step comes in. If we treat $\widehat{F}_{n}\left(x\right)$ as actually being Gaussian and apply the concentration inequality for Gaussians, we will recover the Dvoretzky-Kiefer-Wolfowitz inequality. Note that $F\left(x\right)\left(1 - F\left(x\right)\right)$ is maximised at $F\left(x\right) = 1/2$, hence $\sup_{x\in\mathbb{R}}F\left(x\right)\left(1 - F\left(x\right)\right) = 1/4$. So this gives \begin{align} \operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right) &= \dfrac{F\left(x\right)\left(1 - F\left(x\right)\right)}{n} \\ &\leq \dfrac{1}{4n} \end{align} Treating $\widehat{F}_{n}\left(x\right)$ as Gaussian and plugging it into the concentration inequality gives for any $x \in \mathbb{R}$: \begin{equation} \operatorname{Pr}\left(\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \varepsilon\right) \leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\operatorname{Var}\left(\widehat{F}_{n}\left(x\right)\right)}\right) \end{equation} Taking the worst-case supremum over $x$ on either side separately: \begin{align} \operatorname{Pr}\left(\sup_{x\in\mathbb{R}}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \varepsilon\right) &\leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2\sup_{x'\in\mathbb{R}}\operatorname{Var}\left(\widehat{F}_{n}\left(x'\right)\right)}\right) \\ &\leq 2\exp\left(-\dfrac{\varepsilon^{2}}{2/\left(4n\right)}\right) \\ &= 2e^{-2n\varepsilon^{2}} \end{align} Applying the substitution $\epsilon = \sqrt{n}\varepsilon$ then yields the Dvoretzky-Kiefer-Wolfowitz inequality as originally claimed: \begin{equation} \operatorname{Pr}\left(\sqrt{n}\sup_{x\in\mathbb{R}}\left|\widehat{F}_{n}\left(x\right) - F\left(x\right)\right| > \epsilon\right) \leq 2e^{-2\epsilon^{2}} \end{equation}
Intuition behind Dvoretzky Kiefer Wolfowitz inequality Consider an i.i.d. sample $X_{1}, \dots, X_{n}$ from a distribution with CDF $F\left(x\right)$, and let \begin{equation} \widehat{F}_{n}\left(x\right) = \dfrac{1}{n}\sum_{i = 1}^{n}\mathbb{I}_{X_{i} \
41,217
Intuition behind Dvoretzky Kiefer Wolfowitz inequality
This answer might help you to understand its origin. You will need to fill some details up, though. Another reference of interest with a formal proof of an improved version of the inequallity is Massart, P. (1990). The Tight Constant in the Dvoretzky-Kiefer-Wolfowitz Inequality. Annals of Probability 18: 1269-1283. The Kolmogorov-Smirnov distribution is not as simple as one would love it were and the results involving this distribution tend to be not-straightforward.
Intuition behind Dvoretzky Kiefer Wolfowitz inequality
This answer might help you to understand its origin. You will need to fill some details up, though. Another reference of interest with a formal proof of an improved version of the inequallity is Mass
Intuition behind Dvoretzky Kiefer Wolfowitz inequality This answer might help you to understand its origin. You will need to fill some details up, though. Another reference of interest with a formal proof of an improved version of the inequallity is Massart, P. (1990). The Tight Constant in the Dvoretzky-Kiefer-Wolfowitz Inequality. Annals of Probability 18: 1269-1283. The Kolmogorov-Smirnov distribution is not as simple as one would love it were and the results involving this distribution tend to be not-straightforward.
Intuition behind Dvoretzky Kiefer Wolfowitz inequality This answer might help you to understand its origin. You will need to fill some details up, though. Another reference of interest with a formal proof of an improved version of the inequallity is Mass
41,218
Is there a multivariate version of logistic regression?
You can do this with a multilevel model or a regression which takes clustering into account, or a structural equation model. You convert your data from wide to long, so each person has two rows in the dataset, and you have a variable that identifies a person. You could also do it with multinomial logistic regression - predict member of (say) 4 groups - minority male, minority female, majority male, majority female.
Is there a multivariate version of logistic regression?
You can do this with a multilevel model or a regression which takes clustering into account, or a structural equation model. You convert your data from wide to long, so each person has two rows in th
Is there a multivariate version of logistic regression? You can do this with a multilevel model or a regression which takes clustering into account, or a structural equation model. You convert your data from wide to long, so each person has two rows in the dataset, and you have a variable that identifies a person. You could also do it with multinomial logistic regression - predict member of (say) 4 groups - minority male, minority female, majority male, majority female.
Is there a multivariate version of logistic regression? You can do this with a multilevel model or a regression which takes clustering into account, or a structural equation model. You convert your data from wide to long, so each person has two rows in th
41,219
Is there a multivariate version of logistic regression?
I don't know much about SEMs, but I've heard they're pretty complicated. An easy to understand alternative would be a multinomial logistic regression. In R, you can formulate this with the vglm() function from the VGAM package. Here's a quick gist: In binomial logistic regression, your model looks like this: $$\log\left(\frac{p}{1-p}\right) = \mathbf{X\beta}$$ In a multinomial logistic regression, you need to have a baseline factor level (I think R defaults to the last one alphabetically). So, if you have $k$ prediction factors, you predict $p_1, ..., p_k$, where $p_k = 1 - p_1 - ... - p_{k-1}$. Your model then looks like this: $$\log\left(\frac{p_i}{p_k}\right) = \mathbf{X\beta}_i$$ Notice here that $\mathbf{\beta}_i$ is itself a vector. So if you have $p$ predictor variables, you now have $p\times(k-1)$ slope estimates.
Is there a multivariate version of logistic regression?
I don't know much about SEMs, but I've heard they're pretty complicated. An easy to understand alternative would be a multinomial logistic regression. In R, you can formulate this with the vglm() fu
Is there a multivariate version of logistic regression? I don't know much about SEMs, but I've heard they're pretty complicated. An easy to understand alternative would be a multinomial logistic regression. In R, you can formulate this with the vglm() function from the VGAM package. Here's a quick gist: In binomial logistic regression, your model looks like this: $$\log\left(\frac{p}{1-p}\right) = \mathbf{X\beta}$$ In a multinomial logistic regression, you need to have a baseline factor level (I think R defaults to the last one alphabetically). So, if you have $k$ prediction factors, you predict $p_1, ..., p_k$, where $p_k = 1 - p_1 - ... - p_{k-1}$. Your model then looks like this: $$\log\left(\frac{p_i}{p_k}\right) = \mathbf{X\beta}_i$$ Notice here that $\mathbf{\beta}_i$ is itself a vector. So if you have $p$ predictor variables, you now have $p\times(k-1)$ slope estimates.
Is there a multivariate version of logistic regression? I don't know much about SEMs, but I've heard they're pretty complicated. An easy to understand alternative would be a multinomial logistic regression. In R, you can formulate this with the vglm() fu
41,220
Fitting t distribtution to financial data
The estimators correspond to $(\mu,\sigma,\nu)$, the parameters of a Student-$t$ distribution with location parameter $\mu\in{\mathbb R}$, scale parameter $\sigma>0$ and $\nu>0$ degrees of freedom. This density is simply given by $$f(x;\mu,\sigma,\nu)=\dfrac{1}{\sigma}\dfrac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi}\,\Gamma \left(\frac{\nu}{2} \right)} \left(1+\dfrac{(x-\mu)^2}{\nu \sigma^2} \right)^{-\frac{\nu+1}{2}}.$$ There seems to be no closed expression for these estimators. The warnings in this case are harmless. You can check this by finding the MLE using the command optim as follows # log-likelihood function loglik <-function(par){ if(par[2]>0 & par[3]>0) return(-sum(log(dt((alvsloss-par[1])/par[2],df=par[3])/par[2]))) else return(Inf) } # optimisation step optim(c(0,0.1,2.5),loglik) The following code shows how to plot the fitted density together with a kernel density estimator. # fitted density param = optim(c(0,0.01,2.5),loglik)$par fit.den <- function(x) dt((x-param[1])/param[2],df=param[3])/param[2] curve(fit.den,-0.15,0.15) points(density(alvsloss),type="l",col="red")
Fitting t distribtution to financial data
The estimators correspond to $(\mu,\sigma,\nu)$, the parameters of a Student-$t$ distribution with location parameter $\mu\in{\mathbb R}$, scale parameter $\sigma>0$ and $\nu>0$ degrees of freedom. Th
Fitting t distribtution to financial data The estimators correspond to $(\mu,\sigma,\nu)$, the parameters of a Student-$t$ distribution with location parameter $\mu\in{\mathbb R}$, scale parameter $\sigma>0$ and $\nu>0$ degrees of freedom. This density is simply given by $$f(x;\mu,\sigma,\nu)=\dfrac{1}{\sigma}\dfrac{\Gamma \left(\frac{\nu+1}{2} \right)} {\sqrt{\nu\pi}\,\Gamma \left(\frac{\nu}{2} \right)} \left(1+\dfrac{(x-\mu)^2}{\nu \sigma^2} \right)^{-\frac{\nu+1}{2}}.$$ There seems to be no closed expression for these estimators. The warnings in this case are harmless. You can check this by finding the MLE using the command optim as follows # log-likelihood function loglik <-function(par){ if(par[2]>0 & par[3]>0) return(-sum(log(dt((alvsloss-par[1])/par[2],df=par[3])/par[2]))) else return(Inf) } # optimisation step optim(c(0,0.1,2.5),loglik) The following code shows how to plot the fitted density together with a kernel density estimator. # fitted density param = optim(c(0,0.01,2.5),loglik)$par fit.den <- function(x) dt((x-param[1])/param[2],df=param[3])/param[2] curve(fit.den,-0.15,0.15) points(density(alvsloss),type="l",col="red")
Fitting t distribtution to financial data The estimators correspond to $(\mu,\sigma,\nu)$, the parameters of a Student-$t$ distribution with location parameter $\mu\in{\mathbb R}$, scale parameter $\sigma>0$ and $\nu>0$ degrees of freedom. Th
41,221
Which are differences between the hypergeometric distribution and chi-square distribution
Take care to note you're discussing two different statistics here. Let's set up the sampling situation in detail first so we can be clear: We have red balls and not-red balls (for simplicity I will call them all 'black', but they could be a mix of non-red colors - it's irrelevant to this set up since they all are simply categorized as not-red). You have a population (your 'universe') of 18840 balls, 6680 red and 12160 black. You draw a random sample of 382 balls without replacement, and obtain 160 red and 222 black. That is, your example data are like so: Drawn Not drawn Total Red 160 6520 6680 Black 222 11938 12160 Total 382 18458 18840 Looking at the number of reds drawn as a random variable, that has a hypergeometric distribution (though there formulated in terms of white and black balls drawn from an urn rather than red and black balls drawn from a universe). [Conditioning on the margins gives the hypergeometric - this is also the situation used for Fisher's exact test based on the hypergeometric, and one of the situations for which the usual 2x2 chi-square test of association/test of independence applies. If you don't condition on both margins, you don't have a hypergeometric; but that's what you normally do in the specific balls-in-urns model you describe.] If $O_{ij}$ is the observed count in cell $(i,j)$ in the above $2\times 2$ table, then your statistics are $O_{11}$ in the first case (assuming red is first) and $X^2 = \sum \sum {(O_{ij} - E_{ij})^2 \over E_{ij}}$ in the second. Both statistics are actually discrete, but you can approximate either by a continuous distribution - the first by a normal approximation, the second by a chi-square. With random sampling, the distribution of the number of red balls in the sample ($O_{11}$) is hypergeometric - that is, given the usual assumptions it's exactly correct. Given the universe details and the sample size, the usual 'chi-square' statistic, though discrete, will be quite well approximated by a chi-square distribution when the number of red balls in the sample is hypergeometric. It's not exact, but it will be quite close in this case.
Which are differences between the hypergeometric distribution and chi-square distribution
Take care to note you're discussing two different statistics here. Let's set up the sampling situation in detail first so we can be clear: We have red balls and not-red balls (for simplicity I will ca
Which are differences between the hypergeometric distribution and chi-square distribution Take care to note you're discussing two different statistics here. Let's set up the sampling situation in detail first so we can be clear: We have red balls and not-red balls (for simplicity I will call them all 'black', but they could be a mix of non-red colors - it's irrelevant to this set up since they all are simply categorized as not-red). You have a population (your 'universe') of 18840 balls, 6680 red and 12160 black. You draw a random sample of 382 balls without replacement, and obtain 160 red and 222 black. That is, your example data are like so: Drawn Not drawn Total Red 160 6520 6680 Black 222 11938 12160 Total 382 18458 18840 Looking at the number of reds drawn as a random variable, that has a hypergeometric distribution (though there formulated in terms of white and black balls drawn from an urn rather than red and black balls drawn from a universe). [Conditioning on the margins gives the hypergeometric - this is also the situation used for Fisher's exact test based on the hypergeometric, and one of the situations for which the usual 2x2 chi-square test of association/test of independence applies. If you don't condition on both margins, you don't have a hypergeometric; but that's what you normally do in the specific balls-in-urns model you describe.] If $O_{ij}$ is the observed count in cell $(i,j)$ in the above $2\times 2$ table, then your statistics are $O_{11}$ in the first case (assuming red is first) and $X^2 = \sum \sum {(O_{ij} - E_{ij})^2 \over E_{ij}}$ in the second. Both statistics are actually discrete, but you can approximate either by a continuous distribution - the first by a normal approximation, the second by a chi-square. With random sampling, the distribution of the number of red balls in the sample ($O_{11}$) is hypergeometric - that is, given the usual assumptions it's exactly correct. Given the universe details and the sample size, the usual 'chi-square' statistic, though discrete, will be quite well approximated by a chi-square distribution when the number of red balls in the sample is hypergeometric. It's not exact, but it will be quite close in this case.
Which are differences between the hypergeometric distribution and chi-square distribution Take care to note you're discussing two different statistics here. Let's set up the sampling situation in detail first so we can be clear: We have red balls and not-red balls (for simplicity I will ca
41,222
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why?
Apparently you are using the NOMREG procedure. From the SPSS NOMREG help. Note that you can also use the newer GENLIN procedure to fit a logistic model. All three will give the same coefficients and standard errors but may differ in other outputs. Binary logistic regression models can be fitted using either the Logistic Regression procedure or the Multinomial Logistic Regression procedure. Each procedure has options not available in the other. An important theoretical distinction is that the Logistic Regression procedure produces all predictions, residuals, influence statistics, and goodness-of-fit tests using data at the individual case level, regardless of how the data are entered and whether or not the number of covariate patterns is smaller than the total number of cases, while the Multinomial Logistic Regression procedure internally aggregates cases to form subpopulations with identical covariate patterns for the predictors, producing predictions, residuals, and goodness-of-fit tests based on these subpopulations. If all predictors are categorical or any continuous predictors take on only a limited number of values—so that there are several cases at each distinct covariate pattern—the subpopulation approach can produce valid goodness-of-fit tests and informative residuals, while the individual case level approach cannot.
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why?
Apparently you are using the NOMREG procedure. From the SPSS NOMREG help. Note that you can also use the newer GENLIN procedure to fit a logistic model. All three will give the same coefficients an
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why? Apparently you are using the NOMREG procedure. From the SPSS NOMREG help. Note that you can also use the newer GENLIN procedure to fit a logistic model. All three will give the same coefficients and standard errors but may differ in other outputs. Binary logistic regression models can be fitted using either the Logistic Regression procedure or the Multinomial Logistic Regression procedure. Each procedure has options not available in the other. An important theoretical distinction is that the Logistic Regression procedure produces all predictions, residuals, influence statistics, and goodness-of-fit tests using data at the individual case level, regardless of how the data are entered and whether or not the number of covariate patterns is smaller than the total number of cases, while the Multinomial Logistic Regression procedure internally aggregates cases to form subpopulations with identical covariate patterns for the predictors, producing predictions, residuals, and goodness-of-fit tests based on these subpopulations. If all predictors are categorical or any continuous predictors take on only a limited number of values—so that there are several cases at each distinct covariate pattern—the subpopulation approach can produce valid goodness-of-fit tests and informative residuals, while the individual case level approach cannot.
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why? Apparently you are using the NOMREG procedure. From the SPSS NOMREG help. Note that you can also use the newer GENLIN procedure to fit a logistic model. All three will give the same coefficients an
41,223
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why?
I did some research after posting my question and basically figured it out. @JKP is right, basically. There is a detailed discussion of this in McCullagh and Nelder, Generalized Linear Models. The subpopulation model assumes that the number of categories remains constant as the population increases. Think of a contingency table where the rows and columns are constant but the cell counts tend to infinity. The degrees of freedom involve an adjustment for the number of cells. That seems to be what SPSS implements under the Generalized Linear Model menu. This explains why I got incompatible results when I added a variable. The categories changed. The two-parameter model is no longer nested in the one-parameter model, as it would be when the analysis is done by case. SPSS's Regression -> Binary Logistic menu allows you to enter variables one by one (in what it calls Blocks), and then does the analysis of deviance chi-squared tests for you. Using that menu I was able to get the same results as in R. In my sample data set, the number of categories is accidental (a result of rounding off a potentially continuous variable), and would probably increase with increased sample size. I am not sure that the subpopulation model would be appropriate here. It's not the one done by the textbook, I might add, which seems to ignore the issue.
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why?
I did some research after posting my question and basically figured it out. @JKP is right, basically. There is a detailed discussion of this in McCullagh and Nelder, Generalized Linear Models. The sub
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why? I did some research after posting my question and basically figured it out. @JKP is right, basically. There is a detailed discussion of this in McCullagh and Nelder, Generalized Linear Models. The subpopulation model assumes that the number of categories remains constant as the population increases. Think of a contingency table where the rows and columns are constant but the cell counts tend to infinity. The degrees of freedom involve an adjustment for the number of cells. That seems to be what SPSS implements under the Generalized Linear Model menu. This explains why I got incompatible results when I added a variable. The categories changed. The two-parameter model is no longer nested in the one-parameter model, as it would be when the analysis is done by case. SPSS's Regression -> Binary Logistic menu allows you to enter variables one by one (in what it calls Blocks), and then does the analysis of deviance chi-squared tests for you. Using that menu I was able to get the same results as in R. In my sample data set, the number of categories is accidental (a result of rounding off a potentially continuous variable), and would probably increase with increased sample size. I am not sure that the subpopulation model would be appropriate here. It's not the one done by the textbook, I might add, which seems to ignore the issue.
Generalized Linear Model in SPSS with common values among predictors treated as subpopulations. Why? I did some research after posting my question and basically figured it out. @JKP is right, basically. There is a detailed discussion of this in McCullagh and Nelder, Generalized Linear Models. The sub
41,224
Normal distributed random numbers in time - expected behaviour - askew distributions?
This is a random walk with drift. Each step in the first scenario goes through two stages. Initially, there is an array of zeros. Because there appears to be no use of the geometry of the array, we may think of this simply as a (fixed-length) vector of values. Stage 1: Add independent Gaussian values to each entry of the vector. Stage 2: Project the vector onto the vector of its mean values. If we inspect the state only after Stage 2 each time, we have no need to look at the entire vector: a single component will do, because all components are the same. This component is obtained as the value from the previous step plus the mean of the values added at Stage 1. But that mean--as is well known--is itself Gaussian, with expectation and variance easily computed from the properties of the Gaussians in Stage 1. Thus, writing $x_t$ for the (common) value of all the vector components after Stage 2 in step $t$, we find that $$x_{t+1} = x_{t} + \varepsilon_t$$ where $\varepsilon_t$ are iid Gaussian (with, say, common variance $\sigma^2$): that's the random walk. When the mean $\mu$ of these $\varepsilon_t$ is nonzero, it's a random walk with drift, but that's easily reduced to a random walk because then $$x_{t+1} = (t+1)\mu + y_{t+1}; \quad y_{t+1} = y_t + \delta_t $$ with $\delta_t = \varepsilon_t + \mu$ having zero mean. Understanding this, it's easy to characterize the process after Stage 1 of step $t+1$: the vector looks like $$(y_{t,1}, y_{t,2}, \ldots) = (x_t + \gamma_{t,1}, x_t + \gamma_{t,2}, \ldots)$$ where the $\gamma_{t,i}$ are the independent Gaussians added at that stage. We now have all the information needed to compute properties of this process: $$E[y_{t,i}] = E[x_t + \gamma_{t,i}] = E[x_t] + E[\gamma_{t,i}] = (t-1)\mu + E[\gamma_{t,i}].$$ $$\text{Var}(y_{t,i}) = \text{Var}(x_t + \gamma_{t,i}) = \text{Var}(x_t) + \text{Var}(\gamma_{t,i}) = (t-1)\sigma^2 + \text{Var}(\gamma_{t,i}).$$ Now let $i \ne j$: $$\text{Cov}(y_{t,i}, y_{t,j}) = \text{Cov}(x_t + \gamma_{t,i}, x_t + \gamma_{t,j}) = (t-1)\sigma^2$$ For the general covariance calculation we exploit the symmetry of covariance and assume $s \gt t$. Recall that $x_s$ is obtained from $x_t$ by adding random variates independent of $x_t$, whence $\text{Cov}(x_s, x_t) = \text{Var}(x_t)$. Let the size of the array be $n$ and note that one (additive) component of $x_s$ is $\gamma_{t,i}/n$; besides this, the only things $x_s$ and $x_t$ have in common are $x_t$ itself. (That is, $x_s - (x_t + \gamma_{t,i})$ is the sum of variates independent of both $x_t$ and $\gamma_{t,i}$.) Thus $$\text{Cov}(y_{t,i}, y_{s,j}) = \text{Cov}(x_t + \gamma_{t,i}, x_s + \gamma_{s,j}) = (t-1)\sigma^2 + \text{Var}(\gamma_{t,i})/n^2.$$ By virtue of Kolmogorov's Extension Theorem and the fact that multivariate Gaussian distributions are completely determined by their means and covariance matrices--which we have just fully computed--this is a complete characterization of the first scenario. The second scenario (no relaxation) is simpler: each component of the vector independently is a random walk with drift. This exposition has not assumed that the random variates added to the components have a common mean or common variance. Moreover, the calculations can be generalized so that all the random ingredients of the process have arbitrary means and variances, potentially varying from one point to another and from one step to another. This complicates the notation somewhat but the result is essentially the same (a random walk with drift and possible heteroscedasticity). Similar calculations can be applied when the relaxation is performed on local neighborhoods of a grid. The computations of covariances become more complicated, because now we have to account for the geometric structure of the grid, but there are no new ideas introduced. The upshot is that you obtain a collection of correlated heteroscedastic random walks with drift, one per grid cell. To illustrate, here is an R simulation where all the $\gamma_{t,i}$ are iid. sim <- function(n.steps=20, n=1, mu=1, sigma=1) { gamma <- array(rnorm(n.steps * n, mu, sigma), dim=c(n.steps, n)) epsilon <- rowSums(gamma) x <- cumsum(epsilon) y <- x + gamma list(x=x, y=y) } iter <- function(a) { n.steps <- dim(a$y)[1]; n <-dim(a$y)[2] plot(a$x, type="l", col="Gray", frame.plot=FALSE, xaxp=c(0,n.steps,ceiling(n.steps/5))) col <- palette(terrain.colors(n)) i <- 0 tmp <- apply(a$y, 2, function(z) {i <<- i+1; points(z, pch=19, col=col[i])}) } set.seed(17) par(mfrow=c(4,1), mai=c(0.4,0.4,0.0,0.1)) tmp <- replicate(4, iter(sim(20, n=9, mu=0.1))) Here are four independent realizations of the process: The step $t$ is on the $x$-axis and the $y$-axis denotes values in the array. The values of $x$ are joined and the corresponding values of $y$ are shown scattered around these values, with colors distinguishing the array components. This array has $9$ values, the drift is $0.1$ per step, and the common variance of the $\gamma_{t,i}$ is $1$.
Normal distributed random numbers in time - expected behaviour - askew distributions?
This is a random walk with drift. Each step in the first scenario goes through two stages. Initially, there is an array of zeros. Because there appears to be no use of the geometry of the array, we
Normal distributed random numbers in time - expected behaviour - askew distributions? This is a random walk with drift. Each step in the first scenario goes through two stages. Initially, there is an array of zeros. Because there appears to be no use of the geometry of the array, we may think of this simply as a (fixed-length) vector of values. Stage 1: Add independent Gaussian values to each entry of the vector. Stage 2: Project the vector onto the vector of its mean values. If we inspect the state only after Stage 2 each time, we have no need to look at the entire vector: a single component will do, because all components are the same. This component is obtained as the value from the previous step plus the mean of the values added at Stage 1. But that mean--as is well known--is itself Gaussian, with expectation and variance easily computed from the properties of the Gaussians in Stage 1. Thus, writing $x_t$ for the (common) value of all the vector components after Stage 2 in step $t$, we find that $$x_{t+1} = x_{t} + \varepsilon_t$$ where $\varepsilon_t$ are iid Gaussian (with, say, common variance $\sigma^2$): that's the random walk. When the mean $\mu$ of these $\varepsilon_t$ is nonzero, it's a random walk with drift, but that's easily reduced to a random walk because then $$x_{t+1} = (t+1)\mu + y_{t+1}; \quad y_{t+1} = y_t + \delta_t $$ with $\delta_t = \varepsilon_t + \mu$ having zero mean. Understanding this, it's easy to characterize the process after Stage 1 of step $t+1$: the vector looks like $$(y_{t,1}, y_{t,2}, \ldots) = (x_t + \gamma_{t,1}, x_t + \gamma_{t,2}, \ldots)$$ where the $\gamma_{t,i}$ are the independent Gaussians added at that stage. We now have all the information needed to compute properties of this process: $$E[y_{t,i}] = E[x_t + \gamma_{t,i}] = E[x_t] + E[\gamma_{t,i}] = (t-1)\mu + E[\gamma_{t,i}].$$ $$\text{Var}(y_{t,i}) = \text{Var}(x_t + \gamma_{t,i}) = \text{Var}(x_t) + \text{Var}(\gamma_{t,i}) = (t-1)\sigma^2 + \text{Var}(\gamma_{t,i}).$$ Now let $i \ne j$: $$\text{Cov}(y_{t,i}, y_{t,j}) = \text{Cov}(x_t + \gamma_{t,i}, x_t + \gamma_{t,j}) = (t-1)\sigma^2$$ For the general covariance calculation we exploit the symmetry of covariance and assume $s \gt t$. Recall that $x_s$ is obtained from $x_t$ by adding random variates independent of $x_t$, whence $\text{Cov}(x_s, x_t) = \text{Var}(x_t)$. Let the size of the array be $n$ and note that one (additive) component of $x_s$ is $\gamma_{t,i}/n$; besides this, the only things $x_s$ and $x_t$ have in common are $x_t$ itself. (That is, $x_s - (x_t + \gamma_{t,i})$ is the sum of variates independent of both $x_t$ and $\gamma_{t,i}$.) Thus $$\text{Cov}(y_{t,i}, y_{s,j}) = \text{Cov}(x_t + \gamma_{t,i}, x_s + \gamma_{s,j}) = (t-1)\sigma^2 + \text{Var}(\gamma_{t,i})/n^2.$$ By virtue of Kolmogorov's Extension Theorem and the fact that multivariate Gaussian distributions are completely determined by their means and covariance matrices--which we have just fully computed--this is a complete characterization of the first scenario. The second scenario (no relaxation) is simpler: each component of the vector independently is a random walk with drift. This exposition has not assumed that the random variates added to the components have a common mean or common variance. Moreover, the calculations can be generalized so that all the random ingredients of the process have arbitrary means and variances, potentially varying from one point to another and from one step to another. This complicates the notation somewhat but the result is essentially the same (a random walk with drift and possible heteroscedasticity). Similar calculations can be applied when the relaxation is performed on local neighborhoods of a grid. The computations of covariances become more complicated, because now we have to account for the geometric structure of the grid, but there are no new ideas introduced. The upshot is that you obtain a collection of correlated heteroscedastic random walks with drift, one per grid cell. To illustrate, here is an R simulation where all the $\gamma_{t,i}$ are iid. sim <- function(n.steps=20, n=1, mu=1, sigma=1) { gamma <- array(rnorm(n.steps * n, mu, sigma), dim=c(n.steps, n)) epsilon <- rowSums(gamma) x <- cumsum(epsilon) y <- x + gamma list(x=x, y=y) } iter <- function(a) { n.steps <- dim(a$y)[1]; n <-dim(a$y)[2] plot(a$x, type="l", col="Gray", frame.plot=FALSE, xaxp=c(0,n.steps,ceiling(n.steps/5))) col <- palette(terrain.colors(n)) i <- 0 tmp <- apply(a$y, 2, function(z) {i <<- i+1; points(z, pch=19, col=col[i])}) } set.seed(17) par(mfrow=c(4,1), mai=c(0.4,0.4,0.0,0.1)) tmp <- replicate(4, iter(sim(20, n=9, mu=0.1))) Here are four independent realizations of the process: The step $t$ is on the $x$-axis and the $y$-axis denotes values in the array. The values of $x$ are joined and the corresponding values of $y$ are shown scattered around these values, with colors distinguishing the array components. This array has $9$ values, the drift is $0.1$ per step, and the common variance of the $\gamma_{t,i}$ is $1$.
Normal distributed random numbers in time - expected behaviour - askew distributions? This is a random walk with drift. Each step in the first scenario goes through two stages. Initially, there is an array of zeros. Because there appears to be no use of the geometry of the array, we
41,225
Tools to detect jumps in a linear time series
A "Jump" in a time series is a permanent change in the equation's implied intercept. Consider a series 1,1,1,1,4,4,4,4,4 where the basic model is y(t)=1 + 3*x(t) and x is the level shift/step shift series 0,0,0,0,1,1,1,1,1 . Thus suggests an intercept change at period 5 from a "1" to a "4" . If a second series is 1,2,3,4,8,9,10,11,12 then the model is [1-B]y(t)=1 + 3*[1-B]x(t) where x is the series 0,0,0,0,1,1,1,1,1 suggesting an intercept change at period 5 from a "1" to a '4". Detecting a jump in a time series is called Intervention Detection. A pulse intervention is a one period change in the equation's implied intercept. The series 1,1,1,1,4,1,1,1,1 is y(t)=1+3*z(t) where z(t) =0,0,0,0,1,0,0,0,0 and if z=x[1-B] we have y(t)=1+3*[1-B]x ; x being 0,0,0,0,1,1,1,1,1. A Seasonal Pulse is pulse that appears at fixed seasonal points in time e.g. a June effect. Pursuing the identification of the level shift and it's duration ,one might review Tsay's paper "Outliers, level shifts, and variance changes in time series" and then pursue some of my previous posts on this subject along with what other responders have said. Identifciation of the "jump points" should not be done without taking into account necessary ARIMA structure or the effect of needed causal variables. Furthermore since both ARIMA parameters and the error variance may change over time consideration needs to be taken in these regards. Commercial software is available to perform this ientification. SAS , SPSS and AUTOBOX ( which I am involved with ) come to mind as places for you to investigate. I would start by simulating some time series and then testing out various "automated" solutions by actually using their free downloadable software. Hope this helps. P.S. The term "CHANGE POINT" is purposely vague. A change point may have a number of causes Pulse/level shift/seasonal pulse/local time trend starts A change in parameters has been detected ( possibly via the Chow Test http://en.wikipedia.org/wiki/Chow_test as IMA pointed out below ). Note that some software actually searches for the breakpoint as compared to the user having to suggest it. A change in the variance of the errors has been detected A change in the way a predictor series (x) impacts the series of interest (y)
Tools to detect jumps in a linear time series
A "Jump" in a time series is a permanent change in the equation's implied intercept. Consider a series 1,1,1,1,4,4,4,4,4 where the basic model is y(t)=1 + 3*x(t) and x is the level shift/step shift se
Tools to detect jumps in a linear time series A "Jump" in a time series is a permanent change in the equation's implied intercept. Consider a series 1,1,1,1,4,4,4,4,4 where the basic model is y(t)=1 + 3*x(t) and x is the level shift/step shift series 0,0,0,0,1,1,1,1,1 . Thus suggests an intercept change at period 5 from a "1" to a "4" . If a second series is 1,2,3,4,8,9,10,11,12 then the model is [1-B]y(t)=1 + 3*[1-B]x(t) where x is the series 0,0,0,0,1,1,1,1,1 suggesting an intercept change at period 5 from a "1" to a '4". Detecting a jump in a time series is called Intervention Detection. A pulse intervention is a one period change in the equation's implied intercept. The series 1,1,1,1,4,1,1,1,1 is y(t)=1+3*z(t) where z(t) =0,0,0,0,1,0,0,0,0 and if z=x[1-B] we have y(t)=1+3*[1-B]x ; x being 0,0,0,0,1,1,1,1,1. A Seasonal Pulse is pulse that appears at fixed seasonal points in time e.g. a June effect. Pursuing the identification of the level shift and it's duration ,one might review Tsay's paper "Outliers, level shifts, and variance changes in time series" and then pursue some of my previous posts on this subject along with what other responders have said. Identifciation of the "jump points" should not be done without taking into account necessary ARIMA structure or the effect of needed causal variables. Furthermore since both ARIMA parameters and the error variance may change over time consideration needs to be taken in these regards. Commercial software is available to perform this ientification. SAS , SPSS and AUTOBOX ( which I am involved with ) come to mind as places for you to investigate. I would start by simulating some time series and then testing out various "automated" solutions by actually using their free downloadable software. Hope this helps. P.S. The term "CHANGE POINT" is purposely vague. A change point may have a number of causes Pulse/level shift/seasonal pulse/local time trend starts A change in parameters has been detected ( possibly via the Chow Test http://en.wikipedia.org/wiki/Chow_test as IMA pointed out below ). Note that some software actually searches for the breakpoint as compared to the user having to suggest it. A change in the variance of the errors has been detected A change in the way a predictor series (x) impacts the series of interest (y)
Tools to detect jumps in a linear time series A "Jump" in a time series is a permanent change in the equation's implied intercept. Consider a series 1,1,1,1,4,4,4,4,4 where the basic model is y(t)=1 + 3*x(t) and x is the level shift/step shift se
41,226
Tools to detect jumps in a linear time series
You can use mcp for this kind of models. Time series often exhibit autocorrelation, so let's just to an AR(1) model with three linear segments. First, let's specify the model: model = list( y ~ 1 + x + ar(1), # Linear segment. Initiate AR(1) ~ 1 + x, # linear ~ 1 + x ) Now fit it: library(mcp) fit = mcp(model, df) As an extra trick, if the slope is identical between segments, you can set this identity using a prior. This fits one slope parameter instead of three: prior = list(x_2 = "x_1", x_3 = "x_1") fit = mcp(model, data = df, prior = prior) Read more on the mcp website. Disclaimer: I am the developer.
Tools to detect jumps in a linear time series
You can use mcp for this kind of models. Time series often exhibit autocorrelation, so let's just to an AR(1) model with three linear segments. First, let's specify the model: model = list( y ~ 1 +
Tools to detect jumps in a linear time series You can use mcp for this kind of models. Time series often exhibit autocorrelation, so let's just to an AR(1) model with three linear segments. First, let's specify the model: model = list( y ~ 1 + x + ar(1), # Linear segment. Initiate AR(1) ~ 1 + x, # linear ~ 1 + x ) Now fit it: library(mcp) fit = mcp(model, df) As an extra trick, if the slope is identical between segments, you can set this identity using a prior. This fits one slope parameter instead of three: prior = list(x_2 = "x_1", x_3 = "x_1") fit = mcp(model, data = df, prior = prior) Read more on the mcp website. Disclaimer: I am the developer.
Tools to detect jumps in a linear time series You can use mcp for this kind of models. Time series often exhibit autocorrelation, so let's just to an AR(1) model with three linear segments. First, let's specify the model: model = list( y ~ 1 +
41,227
Tools to detect jumps in a linear time series
Some things to toy with: A 1 dimensional fused LASSO. This will fit piece wise constant lines to the data, with jumps when the mean has changed. More info here: https://cran.r-project.org/web/packages/genlasso/vignettes/article.pdf a BFAST model (breaks for additive season and trend) seems appropriate for this task. More info here: http://bfast.r-forge.r-project.org/ a MARS model also (multivariate adaptive regression splines). Simply look for the location of the knots. See https://en.m.wikipedia.org/wiki/Multivariate_adaptive_regression_splines Note that these methods can only detect changes/jumps and have no ability to predict a jump.
Tools to detect jumps in a linear time series
Some things to toy with: A 1 dimensional fused LASSO. This will fit piece wise constant lines to the data, with jumps when the mean has changed. More info here: https://cran.r-project.org/web/package
Tools to detect jumps in a linear time series Some things to toy with: A 1 dimensional fused LASSO. This will fit piece wise constant lines to the data, with jumps when the mean has changed. More info here: https://cran.r-project.org/web/packages/genlasso/vignettes/article.pdf a BFAST model (breaks for additive season and trend) seems appropriate for this task. More info here: http://bfast.r-forge.r-project.org/ a MARS model also (multivariate adaptive regression splines). Simply look for the location of the knots. See https://en.m.wikipedia.org/wiki/Multivariate_adaptive_regression_splines Note that these methods can only detect changes/jumps and have no ability to predict a jump.
Tools to detect jumps in a linear time series Some things to toy with: A 1 dimensional fused LASSO. This will fit piece wise constant lines to the data, with jumps when the mean has changed. More info here: https://cran.r-project.org/web/package
41,228
Find the limiting distribution of Sum over Sum of Squares
Notice that $\frac{X_1 + X_2 + \ldots+ X_n}{\sqrt n}$ is a a standard gaussian variable. Then apply Slutsky's theorem.
Find the limiting distribution of Sum over Sum of Squares
Notice that $\frac{X_1 + X_2 + \ldots+ X_n}{\sqrt n}$ is a a standard gaussian variable. Then apply Slutsky's theorem.
Find the limiting distribution of Sum over Sum of Squares Notice that $\frac{X_1 + X_2 + \ldots+ X_n}{\sqrt n}$ is a a standard gaussian variable. Then apply Slutsky's theorem.
Find the limiting distribution of Sum over Sum of Squares Notice that $\frac{X_1 + X_2 + \ldots+ X_n}{\sqrt n}$ is a a standard gaussian variable. Then apply Slutsky's theorem.
41,229
Find the limiting distribution of Sum over Sum of Squares
The numerator is normally distributed with mean $0$ and variance $n$, and the denominator is distributed $\chi^2$ with $n$ degrees of freedom. Start there.
Find the limiting distribution of Sum over Sum of Squares
The numerator is normally distributed with mean $0$ and variance $n$, and the denominator is distributed $\chi^2$ with $n$ degrees of freedom. Start there.
Find the limiting distribution of Sum over Sum of Squares The numerator is normally distributed with mean $0$ and variance $n$, and the denominator is distributed $\chi^2$ with $n$ degrees of freedom. Start there.
Find the limiting distribution of Sum over Sum of Squares The numerator is normally distributed with mean $0$ and variance $n$, and the denominator is distributed $\chi^2$ with $n$ degrees of freedom. Start there.
41,230
Find the limiting distribution of Sum over Sum of Squares
We can find the result with law of large numbers and central limit theorem, writing $$W_n=\color{blue}{\frac n{\sum_{j=1}^nX_j^2}}\cdot\color{red}{\frac 1{\sqrt n}\sum_{j=1}^nX_j}.$$ The blue term converges to $E(X_1^2)^{-1}$ in probability by the law of large numbers.
Find the limiting distribution of Sum over Sum of Squares
We can find the result with law of large numbers and central limit theorem, writing $$W_n=\color{blue}{\frac n{\sum_{j=1}^nX_j^2}}\cdot\color{red}{\frac 1{\sqrt n}\sum_{j=1}^nX_j}.$$ The blue term co
Find the limiting distribution of Sum over Sum of Squares We can find the result with law of large numbers and central limit theorem, writing $$W_n=\color{blue}{\frac n{\sum_{j=1}^nX_j^2}}\cdot\color{red}{\frac 1{\sqrt n}\sum_{j=1}^nX_j}.$$ The blue term converges to $E(X_1^2)^{-1}$ in probability by the law of large numbers.
Find the limiting distribution of Sum over Sum of Squares We can find the result with law of large numbers and central limit theorem, writing $$W_n=\color{blue}{\frac n{\sum_{j=1}^nX_j^2}}\cdot\color{red}{\frac 1{\sqrt n}\sum_{j=1}^nX_j}.$$ The blue term co
41,231
What is the difference between 'Laplace approximation' and 'Modified harmonic mean'?
I assume, you are refering to the estimation of marginal likelihood. Laplace approximation is used to approximate a marginal likelihood based on normal distribution. Resulting estimate is as follows: $$f(y)\approx (2\pi)^{d}|\widetilde{\Sigma}|^{1/2}f(y|\widetilde{\theta})f(\widetilde{\theta})$$ Where $\widetilde{\theta}$ is a posterior mode (can be estimated from MCMC output) and $\widetilde{\Sigma}$ is inverse of Hessian matrix based on log-likelihood and evaluated at posterior mode (this can be evaluated from MCMC output as well), $f(y|\theta)$ your likelihood and $f(\theta)$ is prior distribution. This approximation works well if your posterior distribution is similar to normal distribution. The second estimator, modified (generalized) harmonic mean estimator is derived by the following identity: $$\frac{1}{f(y)}=\int \frac{1}{f(y)}g(\theta)d \theta=\int \frac{1}{f(y|\theta)f(\theta)}f(\theta|y)g(\theta)d \theta=\int \frac{g(\theta)}{f(y|\theta)f(\theta)}f(\theta|y)d \theta=E_{f(\theta|y)}\left [ \frac{g(\theta)}{f(y|\theta)f(\theta)} \right ]$$ Here $g(\theta)$ is any "importance" density and has to be close to the posterior. So these two, Laplace and generalized harmonic mean, estimators are for marginal likelihood value estimation. However, they are of different origins and behave differently: Laplace estimator is approximation-based estimator and will not work if your posterior is not bell-shaped distribution (multimodal or highly skewd). Otherwise it works quite well. Generlized harmonic mean estimator is based on exact identity and theoretically it should provided accurate estimates, however, as its close relative harmonic mean estimator, it is quite sensitive. Do not know more about its performance, but its relative harmonic mean estimator is usually very badly-behaved estimator. I do not use it in my work. Hope I answered your question.
What is the difference between 'Laplace approximation' and 'Modified harmonic mean'?
I assume, you are refering to the estimation of marginal likelihood. Laplace approximation is used to approximate a marginal likelihood based on normal distribution. Resulting estimate is as follows:
What is the difference between 'Laplace approximation' and 'Modified harmonic mean'? I assume, you are refering to the estimation of marginal likelihood. Laplace approximation is used to approximate a marginal likelihood based on normal distribution. Resulting estimate is as follows: $$f(y)\approx (2\pi)^{d}|\widetilde{\Sigma}|^{1/2}f(y|\widetilde{\theta})f(\widetilde{\theta})$$ Where $\widetilde{\theta}$ is a posterior mode (can be estimated from MCMC output) and $\widetilde{\Sigma}$ is inverse of Hessian matrix based on log-likelihood and evaluated at posterior mode (this can be evaluated from MCMC output as well), $f(y|\theta)$ your likelihood and $f(\theta)$ is prior distribution. This approximation works well if your posterior distribution is similar to normal distribution. The second estimator, modified (generalized) harmonic mean estimator is derived by the following identity: $$\frac{1}{f(y)}=\int \frac{1}{f(y)}g(\theta)d \theta=\int \frac{1}{f(y|\theta)f(\theta)}f(\theta|y)g(\theta)d \theta=\int \frac{g(\theta)}{f(y|\theta)f(\theta)}f(\theta|y)d \theta=E_{f(\theta|y)}\left [ \frac{g(\theta)}{f(y|\theta)f(\theta)} \right ]$$ Here $g(\theta)$ is any "importance" density and has to be close to the posterior. So these two, Laplace and generalized harmonic mean, estimators are for marginal likelihood value estimation. However, they are of different origins and behave differently: Laplace estimator is approximation-based estimator and will not work if your posterior is not bell-shaped distribution (multimodal or highly skewd). Otherwise it works quite well. Generlized harmonic mean estimator is based on exact identity and theoretically it should provided accurate estimates, however, as its close relative harmonic mean estimator, it is quite sensitive. Do not know more about its performance, but its relative harmonic mean estimator is usually very badly-behaved estimator. I do not use it in my work. Hope I answered your question.
What is the difference between 'Laplace approximation' and 'Modified harmonic mean'? I assume, you are refering to the estimation of marginal likelihood. Laplace approximation is used to approximate a marginal likelihood based on normal distribution. Resulting estimate is as follows:
41,232
Generalized Least Squares: Estimation of Variance-Covariance matrix
From what you've written, it appears that you know $\mathbf V$ already. Usually, if you write your covariance matrix as $\sigma^2 \mathbf V$, it means that you know the structure given by $\mathbf V$ (e.g., exchangeable for cluster correlations, or something like that), and you only need to estimate the scale $\sigma^2$. If you don't know $\sigma^2\mathbf V$, but (i) have a good idea about the structure that $\mathbf V$ should have, and (ii) expect the effects to be pretty strong (e.g., difference in variance for different $y_i$'s by a factor of 5, and/or correlations greater than 0.5), then you can proceed via the feasible GLS path (a random econometrics handout from the first page of Google): estimate your model by OLS, construct an estimate $\hat {\mathbf V}$, and plug that estimate in. To do that though does require some sort of a model for $\mathbf V$ so as to be able to describe it with at most a handful of parameters (e.g., correlation coefficient for exchangeable structure; an autoregression correlation or two for time series; a smoothed model for variance with heteroskedastic but uncorrelated errors; etc.). No good at all will come from forming $\hat{\mathbf V}={\mathbf e}{\mathbf e'}$, as this matrix won't even be invertible. If you don't know much about this covariance at all, and potentially it may not affect results much, and may not provide any worthwhile efficiency gains, you would be better off leaving things as they are: if you are overdoing any sort of corrections on i.i.d. data, you are just unnecessarily increasing the variance of the estimates. Amemiya's Advanced Econometrics treats the subject of generalized least squares and FGLS in and out.
Generalized Least Squares: Estimation of Variance-Covariance matrix
From what you've written, it appears that you know $\mathbf V$ already. Usually, if you write your covariance matrix as $\sigma^2 \mathbf V$, it means that you know the structure given by $\mathbf V$
Generalized Least Squares: Estimation of Variance-Covariance matrix From what you've written, it appears that you know $\mathbf V$ already. Usually, if you write your covariance matrix as $\sigma^2 \mathbf V$, it means that you know the structure given by $\mathbf V$ (e.g., exchangeable for cluster correlations, or something like that), and you only need to estimate the scale $\sigma^2$. If you don't know $\sigma^2\mathbf V$, but (i) have a good idea about the structure that $\mathbf V$ should have, and (ii) expect the effects to be pretty strong (e.g., difference in variance for different $y_i$'s by a factor of 5, and/or correlations greater than 0.5), then you can proceed via the feasible GLS path (a random econometrics handout from the first page of Google): estimate your model by OLS, construct an estimate $\hat {\mathbf V}$, and plug that estimate in. To do that though does require some sort of a model for $\mathbf V$ so as to be able to describe it with at most a handful of parameters (e.g., correlation coefficient for exchangeable structure; an autoregression correlation or two for time series; a smoothed model for variance with heteroskedastic but uncorrelated errors; etc.). No good at all will come from forming $\hat{\mathbf V}={\mathbf e}{\mathbf e'}$, as this matrix won't even be invertible. If you don't know much about this covariance at all, and potentially it may not affect results much, and may not provide any worthwhile efficiency gains, you would be better off leaving things as they are: if you are overdoing any sort of corrections on i.i.d. data, you are just unnecessarily increasing the variance of the estimates. Amemiya's Advanced Econometrics treats the subject of generalized least squares and FGLS in and out.
Generalized Least Squares: Estimation of Variance-Covariance matrix From what you've written, it appears that you know $\mathbf V$ already. Usually, if you write your covariance matrix as $\sigma^2 \mathbf V$, it means that you know the structure given by $\mathbf V$
41,233
Nonparametric equivalent of ANCOVA for continuous dependent variables
Turning my comment to an answer, the sm package offers non-parametric ANCOVA as sm.ancova. Here is a toy example: data(anorexia, package="MASS") anorexia$Treat <- relevel(anorexia$Treat , ref="Cont") # visual check for the parallel group assumption xyplot(Postwt ~ Prewt, data=anorexia, groups=Treat, aspect="iso", type=c("p","r"), auto.key=list(space="right", lines=TRUE, points=FALSE)) # fit two nested models (equal and varying slopes across groups) anorex.aov0 <- aov(Postwt ~ Prewt + Treat, data=anorexia) # ≈ lm(Postwt ~ Prewt + Treat + offset(Prewt), data=anorexia) anorex.aov1 <- aov(Postwt ~ Prewt * Treat, data=anorexia) # check if we need the interaction term anova(anorex.aov0, anorex.aov1) summary.lm(anorex.aov1) The above shows that the parallel group assumption is not realistic and that we must account for the interaction (p=0.007) between the factor group and continuous covariate. Here is what we would get with sm.ancova, with default smoothing parameter and equal-group as the reference model: > with(anorexia, ancova.np <- sm.ancova(Prewt, Postwt, Treat, model="equal")) Test of equality : h = 1.90502 p-value = 0.0036 Band available only to compare two groups. There is another R package for non-parametric ANCOVA (I haven't tested it, though): fANCOVA, with T.aov allowing to test for the equality of nonparametric curves or surfaces based on an ANOVA-type statistic.
Nonparametric equivalent of ANCOVA for continuous dependent variables
Turning my comment to an answer, the sm package offers non-parametric ANCOVA as sm.ancova. Here is a toy example: data(anorexia, package="MASS") anorexia$Treat <- relevel(anorexia$Treat , ref="Cont")
Nonparametric equivalent of ANCOVA for continuous dependent variables Turning my comment to an answer, the sm package offers non-parametric ANCOVA as sm.ancova. Here is a toy example: data(anorexia, package="MASS") anorexia$Treat <- relevel(anorexia$Treat , ref="Cont") # visual check for the parallel group assumption xyplot(Postwt ~ Prewt, data=anorexia, groups=Treat, aspect="iso", type=c("p","r"), auto.key=list(space="right", lines=TRUE, points=FALSE)) # fit two nested models (equal and varying slopes across groups) anorex.aov0 <- aov(Postwt ~ Prewt + Treat, data=anorexia) # ≈ lm(Postwt ~ Prewt + Treat + offset(Prewt), data=anorexia) anorex.aov1 <- aov(Postwt ~ Prewt * Treat, data=anorexia) # check if we need the interaction term anova(anorex.aov0, anorex.aov1) summary.lm(anorex.aov1) The above shows that the parallel group assumption is not realistic and that we must account for the interaction (p=0.007) between the factor group and continuous covariate. Here is what we would get with sm.ancova, with default smoothing parameter and equal-group as the reference model: > with(anorexia, ancova.np <- sm.ancova(Prewt, Postwt, Treat, model="equal")) Test of equality : h = 1.90502 p-value = 0.0036 Band available only to compare two groups. There is another R package for non-parametric ANCOVA (I haven't tested it, though): fANCOVA, with T.aov allowing to test for the equality of nonparametric curves or surfaces based on an ANOVA-type statistic.
Nonparametric equivalent of ANCOVA for continuous dependent variables Turning my comment to an answer, the sm package offers non-parametric ANCOVA as sm.ancova. Here is a toy example: data(anorexia, package="MASS") anorexia$Treat <- relevel(anorexia$Treat , ref="Cont")
41,234
Nonparametric equivalent of ANCOVA for continuous dependent variables
If relation between both regression models are linear, the function sen.adichie from NSM3 package (https://cran.r-project.org/web/packages/NSM3/) test the parallelism of several regression lines. And a Kruskal-Wallis test of aligned observations (ao_ij = y_ij - b x_ij) can to test the elevations (intercepts) of parallel lines.
Nonparametric equivalent of ANCOVA for continuous dependent variables
If relation between both regression models are linear, the function sen.adichie from NSM3 package (https://cran.r-project.org/web/packages/NSM3/) test the parallelism of several regression lines. And
Nonparametric equivalent of ANCOVA for continuous dependent variables If relation between both regression models are linear, the function sen.adichie from NSM3 package (https://cran.r-project.org/web/packages/NSM3/) test the parallelism of several regression lines. And a Kruskal-Wallis test of aligned observations (ao_ij = y_ij - b x_ij) can to test the elevations (intercepts) of parallel lines.
Nonparametric equivalent of ANCOVA for continuous dependent variables If relation between both regression models are linear, the function sen.adichie from NSM3 package (https://cran.r-project.org/web/packages/NSM3/) test the parallelism of several regression lines. And
41,235
Generalizing Add-one/Laplacian Smoothing
The "uniform" in uniform prior doesn't just mean that hits and misses are equally likely. It means that you assume that you have a probability measure on the rates $[0,1]$ and this measure is the uniform measure. For example, it means the chance the true rate is between $0.9$ and $1.0$ is $0.1$. There are other measures on $[0,1]$ which have mean value $1/2$. For example, if you start with the uniform prior and then observe $1$ hit and $1$ miss, the updated distribution is more concentrated around a rate of $1/2$ than the uniform prior. Instead of a probability of $\Delta r $ for the rate to be between $r$ and $r+\Delta r$, you would estimate the probability to be about $6 r (1-r) \Delta r$. (The factor of $6$ makes the total measure $1$.) This new distribution would also predict that the probability of getting a hit next time is $1/2$. If you observe an additional $h$ hits and $m$ misses, the expected probability of a hit is $$\frac{h+2}{h+m+4}.$$ This is closer to $1/2$ than $\frac{h+1}{h+m+2}$. This agrees with the fact that you started with a distribution which was more concentrated near $1/2$. Of course, if you include that first hit and miss then there have been $h+1$ hits and $m+1$ misses in total. The distribution you get from the uniform prior by observing some number of hits and misses is called a beta distribution. The uniform distribution on $[0,1]$ is $\text{Beta}(1,1)$. Beta distributions have the nice property that if you update a beta distribution with an observation, the result is still in that family. From one observation, the $\text{Beta}(a,b)$ distribution is updated either to $\text{Beta}(a+1,b)$ or $\text{Beta}(a,b+1)$. The mean of a $\text{Beta}(a,b)$ distribution is $\frac{a}{a+b}$. It is perfectly reasonable to have a prior distribution which is not a beta distribution, but the answers might not come out as nicely. If I'm very confident that the hit rates are 50/50, I could add 2 instead of 1 to the hits and misses. Or if I'm less confident, I could add 1/2. That might or might not agree with confidence. That is about whether you think it is likely that the rate is close to $1/2$. In some situations, you may believe the rate should be close to $0$ or close to $1$, and the first trial should be very informative. You might believe that half of your students know how to solve a type of problem, and that if you give a random student $5$ of these problems, the student is very likely to solve all $5$ or fail to solve any. This might be approximated by a $\text{Beta}(\epsilon,\epsilon)$ distribution so that after $h$ correct and $m$ incorrect, the average value is $$\frac{h+\epsilon}{h+m+2\epsilon},$$ which is close to $0$ or $1$ after one observation.
Generalizing Add-one/Laplacian Smoothing
The "uniform" in uniform prior doesn't just mean that hits and misses are equally likely. It means that you assume that you have a probability measure on the rates $[0,1]$ and this measure is the unif
Generalizing Add-one/Laplacian Smoothing The "uniform" in uniform prior doesn't just mean that hits and misses are equally likely. It means that you assume that you have a probability measure on the rates $[0,1]$ and this measure is the uniform measure. For example, it means the chance the true rate is between $0.9$ and $1.0$ is $0.1$. There are other measures on $[0,1]$ which have mean value $1/2$. For example, if you start with the uniform prior and then observe $1$ hit and $1$ miss, the updated distribution is more concentrated around a rate of $1/2$ than the uniform prior. Instead of a probability of $\Delta r $ for the rate to be between $r$ and $r+\Delta r$, you would estimate the probability to be about $6 r (1-r) \Delta r$. (The factor of $6$ makes the total measure $1$.) This new distribution would also predict that the probability of getting a hit next time is $1/2$. If you observe an additional $h$ hits and $m$ misses, the expected probability of a hit is $$\frac{h+2}{h+m+4}.$$ This is closer to $1/2$ than $\frac{h+1}{h+m+2}$. This agrees with the fact that you started with a distribution which was more concentrated near $1/2$. Of course, if you include that first hit and miss then there have been $h+1$ hits and $m+1$ misses in total. The distribution you get from the uniform prior by observing some number of hits and misses is called a beta distribution. The uniform distribution on $[0,1]$ is $\text{Beta}(1,1)$. Beta distributions have the nice property that if you update a beta distribution with an observation, the result is still in that family. From one observation, the $\text{Beta}(a,b)$ distribution is updated either to $\text{Beta}(a+1,b)$ or $\text{Beta}(a,b+1)$. The mean of a $\text{Beta}(a,b)$ distribution is $\frac{a}{a+b}$. It is perfectly reasonable to have a prior distribution which is not a beta distribution, but the answers might not come out as nicely. If I'm very confident that the hit rates are 50/50, I could add 2 instead of 1 to the hits and misses. Or if I'm less confident, I could add 1/2. That might or might not agree with confidence. That is about whether you think it is likely that the rate is close to $1/2$. In some situations, you may believe the rate should be close to $0$ or close to $1$, and the first trial should be very informative. You might believe that half of your students know how to solve a type of problem, and that if you give a random student $5$ of these problems, the student is very likely to solve all $5$ or fail to solve any. This might be approximated by a $\text{Beta}(\epsilon,\epsilon)$ distribution so that after $h$ correct and $m$ incorrect, the average value is $$\frac{h+\epsilon}{h+m+2\epsilon},$$ which is close to $0$ or $1$ after one observation.
Generalizing Add-one/Laplacian Smoothing The "uniform" in uniform prior doesn't just mean that hits and misses are equally likely. It means that you assume that you have a probability measure on the rates $[0,1]$ and this measure is the unif
41,236
Does it make sense to apply a chi-squared test on a contingency table when the whole population has been surveyed?
If the whole population of interest has been surveyed, then there's really no statistical analysis to do - any differences you see are differences in the population by definition.
Does it make sense to apply a chi-squared test on a contingency table when the whole population has
If the whole population of interest has been surveyed, then there's really no statistical analysis to do - any differences you see are differences in the population by definition.
Does it make sense to apply a chi-squared test on a contingency table when the whole population has been surveyed? If the whole population of interest has been surveyed, then there's really no statistical analysis to do - any differences you see are differences in the population by definition.
Does it make sense to apply a chi-squared test on a contingency table when the whole population has If the whole population of interest has been surveyed, then there's really no statistical analysis to do - any differences you see are differences in the population by definition.
41,237
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0
The problem you have is that you are using the estimated standard error in the denominator of the weight. The population standard deviation is not likely to be 0 in real situations. I do not think there is a standard way that applies this particular weighting scheme and some other weight when to estimated standard error is 0. The solution is to take a different weighting scheme. There is no law that says that you must take the reciprocal of the standard errors as the weights. Under certain assumptions those would be the optimal weights. But that is not the case here.
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0
The problem you have is that you are using the estimated standard error in the denominator of the weight. The population standard deviation is not likely to be 0 in real situations. I do not think t
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0 The problem you have is that you are using the estimated standard error in the denominator of the weight. The population standard deviation is not likely to be 0 in real situations. I do not think there is a standard way that applies this particular weighting scheme and some other weight when to estimated standard error is 0. The solution is to take a different weighting scheme. There is no law that says that you must take the reciprocal of the standard errors as the weights. Under certain assumptions those would be the optimal weights. But that is not the case here.
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0 The problem you have is that you are using the estimated standard error in the denominator of the weight. The population standard deviation is not likely to be 0 in real situations. I do not think t
41,238
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0
In other cases when I have tricky zeros that make my calculations hard, such as on the diagonal of a matrix I need to invert, I was taught something that was called regularisation: that is, adding a small value uniformly to the offending variable. For instance, in my case where I had a covariance matrix that I need to invert, Q, I set Qhat = I*q for q = 10e-x for some x and for I the identity matrix of same size as Q. In your case, you could add a small value to the variance.
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0
In other cases when I have tricky zeros that make my calculations hard, such as on the diagonal of a matrix I need to invert, I was taught something that was called regularisation: that is, adding a s
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0 In other cases when I have tricky zeros that make my calculations hard, such as on the diagonal of a matrix I need to invert, I was taught something that was called regularisation: that is, adding a small value uniformly to the offending variable. For instance, in my case where I had a covariance matrix that I need to invert, Q, I set Qhat = I*q for q = 10e-x for some x and for I the identity matrix of same size as Q. In your case, you could add a small value to the variance.
Calculating weight as 1/(stnd error) for weighted regression if stnd error = 0 In other cases when I have tricky zeros that make my calculations hard, such as on the diagonal of a matrix I need to invert, I was taught something that was called regularisation: that is, adding a s
41,239
Is principal component regression (PCR) using principal component scores for regression?
I think the wikipedia article is being a little sloppy in saying "uses principal component analysis when estimating regression coefficients". Better might be something like "uses principal component analysis to create explanatory variables before estimating regression coefficients." There's nothing objectionable in the subsequent sentence "In PCR instead of regressing the dependent variable on the independent variables directly, the principal components of the independent variables are used." I also don't see anything wrong with your quote from Jolliffe's book (which I haven't read). It is correct that PCR uses principal components of variables as the predictor variables in a regression model. I don't quite understand what you mean by "regression on PC scores but not PC". You first conduct principal component analysis to create the scores and then use those scores in the regression.
Is principal component regression (PCR) using principal component scores for regression?
I think the wikipedia article is being a little sloppy in saying "uses principal component analysis when estimating regression coefficients". Better might be something like "uses principal component
Is principal component regression (PCR) using principal component scores for regression? I think the wikipedia article is being a little sloppy in saying "uses principal component analysis when estimating regression coefficients". Better might be something like "uses principal component analysis to create explanatory variables before estimating regression coefficients." There's nothing objectionable in the subsequent sentence "In PCR instead of regressing the dependent variable on the independent variables directly, the principal components of the independent variables are used." I also don't see anything wrong with your quote from Jolliffe's book (which I haven't read). It is correct that PCR uses principal components of variables as the predictor variables in a regression model. I don't quite understand what you mean by "regression on PC scores but not PC". You first conduct principal component analysis to create the scores and then use those scores in the regression.
Is principal component regression (PCR) using principal component scores for regression? I think the wikipedia article is being a little sloppy in saying "uses principal component analysis when estimating regression coefficients". Better might be something like "uses principal component
41,240
Is principal component regression (PCR) using principal component scores for regression?
The other answers use a different terminology than what the author may be familiar with. Below, I refer to the scores matrix and use principal components to refer to the unit variance eigenvectors. If you consider the answer as applied to the general case of in-sample and out-of-sample regression, then knowing the principal components matrix is sufficient to perform PCR, but knowing the scores matrix is not. Principal component analysis Given $X$, an $m \times n$ matrix, in PCA we find $T$, $P$ such that $T = PX$ where $t_1,\dots ,t_n$ are uncorrelated and arranged in order of decreasing variance. $T$ is called the “scores” and $P$ is called the “principal components.” Principal component regression To regress design matrix $X$ onto response vector $y$ using PCR, first find the principal components of $X$ using PCA. Then, using the first $k$ principal components from $X$, perform ordinary least squares of $P_{k}$ onto $y$. Algorithm overview Using ordinary least squares, solve $Y=PXB$, where $B$ is the matrix of coefficients. So in the sense that in regression we do operations on $X$, you just need the principal components (i.e. eigenvectors) and design matrix ($X$) but obviously $PX=T$ is the score matrix. Now suppose you evaluate your $B$ on new data $X'$. You still need the principal component matrix $P$ (up to $k$ components), but do not need $T$. Thus, PCR uses the PC matrix but not the scores matrix in the general case. Answer sourced from A Simple Explanation of Partial Least Squares, by Kee Siong Ng (2013). Thanks to @amoeba for help clarifying this answer.
Is principal component regression (PCR) using principal component scores for regression?
The other answers use a different terminology than what the author may be familiar with. Below, I refer to the scores matrix and use principal components to refer to the unit variance eigenvectors. If
Is principal component regression (PCR) using principal component scores for regression? The other answers use a different terminology than what the author may be familiar with. Below, I refer to the scores matrix and use principal components to refer to the unit variance eigenvectors. If you consider the answer as applied to the general case of in-sample and out-of-sample regression, then knowing the principal components matrix is sufficient to perform PCR, but knowing the scores matrix is not. Principal component analysis Given $X$, an $m \times n$ matrix, in PCA we find $T$, $P$ such that $T = PX$ where $t_1,\dots ,t_n$ are uncorrelated and arranged in order of decreasing variance. $T$ is called the “scores” and $P$ is called the “principal components.” Principal component regression To regress design matrix $X$ onto response vector $y$ using PCR, first find the principal components of $X$ using PCA. Then, using the first $k$ principal components from $X$, perform ordinary least squares of $P_{k}$ onto $y$. Algorithm overview Using ordinary least squares, solve $Y=PXB$, where $B$ is the matrix of coefficients. So in the sense that in regression we do operations on $X$, you just need the principal components (i.e. eigenvectors) and design matrix ($X$) but obviously $PX=T$ is the score matrix. Now suppose you evaluate your $B$ on new data $X'$. You still need the principal component matrix $P$ (up to $k$ components), but do not need $T$. Thus, PCR uses the PC matrix but not the scores matrix in the general case. Answer sourced from A Simple Explanation of Partial Least Squares, by Kee Siong Ng (2013). Thanks to @amoeba for help clarifying this answer.
Is principal component regression (PCR) using principal component scores for regression? The other answers use a different terminology than what the author may be familiar with. Below, I refer to the scores matrix and use principal components to refer to the unit variance eigenvectors. If
41,241
Estimating a sparse inverse covariance matrix with known sparsity
Estimation of the covariance matrix with given restrictions on the inverse covariance matrix is of course a well studied problem. Restricting some entries to be 0 is an example of a linear restriction in the cone of positive semidefinite matrices. If the distribution is multivariate normal, the inverse covariance matrix is the canonical parameter in the framework of exponential families and methods for estimation of parameters under linear hypotheses on the canonical parameter for exponential families can be used for this specific example. For decomposable graphs the estimation equations are recursively solvable and otherwise an iterative algorithm will work. The Graphical Models book by Steffen Lauritzen (in particular, Chapter 5) provides all the details, but perhaps also too many details if the interest is only in the estimation of the (inverse) covariance matrix. The paper Gaussian Markov Distributions over Finite Graphs by Speed and Kiiviri is more directly targeting the question by the OP, and I believe it is very readable.
Estimating a sparse inverse covariance matrix with known sparsity
Estimation of the covariance matrix with given restrictions on the inverse covariance matrix is of course a well studied problem. Restricting some entries to be 0 is an example of a linear restriction
Estimating a sparse inverse covariance matrix with known sparsity Estimation of the covariance matrix with given restrictions on the inverse covariance matrix is of course a well studied problem. Restricting some entries to be 0 is an example of a linear restriction in the cone of positive semidefinite matrices. If the distribution is multivariate normal, the inverse covariance matrix is the canonical parameter in the framework of exponential families and methods for estimation of parameters under linear hypotheses on the canonical parameter for exponential families can be used for this specific example. For decomposable graphs the estimation equations are recursively solvable and otherwise an iterative algorithm will work. The Graphical Models book by Steffen Lauritzen (in particular, Chapter 5) provides all the details, but perhaps also too many details if the interest is only in the estimation of the (inverse) covariance matrix. The paper Gaussian Markov Distributions over Finite Graphs by Speed and Kiiviri is more directly targeting the question by the OP, and I believe it is very readable.
Estimating a sparse inverse covariance matrix with known sparsity Estimation of the covariance matrix with given restrictions on the inverse covariance matrix is of course a well studied problem. Restricting some entries to be 0 is an example of a linear restriction
41,242
Updating ARIMA models at frequent intervals
Suppose x contains the first series of observations and y contains the second series of observations, where there is a gap between them consisting of m time periods. Let z be the complete time series, given by z <- ts(c(x,rep(NA,m),y), frequency=??, start=??) I assume you will set the start and frequency to suitable values. Then you fit the first model using fit <- auto.arima(x) After you have obtained the additional observations, you can update the model in several ways. First, you might just compute the residuals on the new observations without revising the parameters or model order: fit1 <- Arima(z,model=fit) Alternatively, you might not revise the model order, but you do update the parameter estimates. In that case: fit2 <- Arima(z,order=fit$arma[c(1,6,2)]) (Here I have assumed it is a non-seasonal ARIMA model. For seasonality, you would need to add a seasonal argument.) Lastly, you might revise both the model order and the parameter estimates. Then fit3 <- auto.arima(z)
Updating ARIMA models at frequent intervals
Suppose x contains the first series of observations and y contains the second series of observations, where there is a gap between them consisting of m time periods. Let z be the complete time series,
Updating ARIMA models at frequent intervals Suppose x contains the first series of observations and y contains the second series of observations, where there is a gap between them consisting of m time periods. Let z be the complete time series, given by z <- ts(c(x,rep(NA,m),y), frequency=??, start=??) I assume you will set the start and frequency to suitable values. Then you fit the first model using fit <- auto.arima(x) After you have obtained the additional observations, you can update the model in several ways. First, you might just compute the residuals on the new observations without revising the parameters or model order: fit1 <- Arima(z,model=fit) Alternatively, you might not revise the model order, but you do update the parameter estimates. In that case: fit2 <- Arima(z,order=fit$arma[c(1,6,2)]) (Here I have assumed it is a non-seasonal ARIMA model. For seasonality, you would need to add a seasonal argument.) Lastly, you might revise both the model order and the parameter estimates. Then fit3 <- auto.arima(z)
Updating ARIMA models at frequent intervals Suppose x contains the first series of observations and y contains the second series of observations, where there is a gap between them consisting of m time periods. Let z be the complete time series,
41,243
How to perform pooled cross-sectional time series analysis?
For each of the 86 companies , identify an appropriate ARMAX model which should incorporate the effects ( both contemporaneous and lag ) of the two user-suggested predictor variables and any necessary ARIMA structure. Incorporate any needed ( and empirically identifiable ) structure reflecting unspecified deterministic effects via Intervention Detection. Use these empirically identified intervention variables to cleanse the output series and remodel using the cleansed series as an ARMAX model. Now review the results for each of these 86 case studies and conclude about a common model. Estimate the common model both locally ( i.e. for each of the 86 companies ) and then estimate it globally ( all using the cleansed output series). Form an F test according to Gregory Chow http://en.wikipedia.org/wiki/Chow_test to test the null hypothesis of a common set of parameters across the 86 groups. If you reject the hypothesis then carefully examine the individual results ( 86 ) and conclude about which companies DIFFER from which companies. We have recently added this functionality to a new release of AUTOBOX, a piece of software that I am involved with as a developer. We are currently researching a formal way to find out ala Scheffe which companies differ from the others. AFTER RECEIPT OF DATA: The complete data enter link description hereset can be found at , I selected the first 3 companies (AA,AAPL,ABT). I selected trading volume (column S) as the dependent and the two predictors tweet (Z) and wiki (V) per the OP's suggestion. This selection can be found at enter link description here. Simple plots of the three dependent series suggest anomalies and and . Since anomalies are present the appropriate regression needs to take into account these effects. Following are the three models ( including any necessary lag structures in the two inputs ) and the appropriate ARIMA structure obtained from an automatic transfer function run using AUTOBOX ( a piece of software I have been developing for the last 42 years ) and and . We now take the three cleansed series returned from the modelling process and estimate a minimally sufficient common model which in this case would be a comtemporary and 1 lag PDL on tweets and a contemporary PDL on wiki with an ARIMA of (1,0,0)(0,0,0). Estimating this model locally and globally provides insight as to the commonality of coefficients . with coefficients . The test for commonality is easily rejected with an F value of 79 with 3,291 df. Note that the DW statistic is 2.63 from the composite analysis. The summary of coeffficients is presented here. The OP poster reflected that the only software he has access to is insufficient to be able to answer this thorny research question.
How to perform pooled cross-sectional time series analysis?
For each of the 86 companies , identify an appropriate ARMAX model which should incorporate the effects ( both contemporaneous and lag ) of the two user-suggested predictor variables and any necessary
How to perform pooled cross-sectional time series analysis? For each of the 86 companies , identify an appropriate ARMAX model which should incorporate the effects ( both contemporaneous and lag ) of the two user-suggested predictor variables and any necessary ARIMA structure. Incorporate any needed ( and empirically identifiable ) structure reflecting unspecified deterministic effects via Intervention Detection. Use these empirically identified intervention variables to cleanse the output series and remodel using the cleansed series as an ARMAX model. Now review the results for each of these 86 case studies and conclude about a common model. Estimate the common model both locally ( i.e. for each of the 86 companies ) and then estimate it globally ( all using the cleansed output series). Form an F test according to Gregory Chow http://en.wikipedia.org/wiki/Chow_test to test the null hypothesis of a common set of parameters across the 86 groups. If you reject the hypothesis then carefully examine the individual results ( 86 ) and conclude about which companies DIFFER from which companies. We have recently added this functionality to a new release of AUTOBOX, a piece of software that I am involved with as a developer. We are currently researching a formal way to find out ala Scheffe which companies differ from the others. AFTER RECEIPT OF DATA: The complete data enter link description hereset can be found at , I selected the first 3 companies (AA,AAPL,ABT). I selected trading volume (column S) as the dependent and the two predictors tweet (Z) and wiki (V) per the OP's suggestion. This selection can be found at enter link description here. Simple plots of the three dependent series suggest anomalies and and . Since anomalies are present the appropriate regression needs to take into account these effects. Following are the three models ( including any necessary lag structures in the two inputs ) and the appropriate ARIMA structure obtained from an automatic transfer function run using AUTOBOX ( a piece of software I have been developing for the last 42 years ) and and . We now take the three cleansed series returned from the modelling process and estimate a minimally sufficient common model which in this case would be a comtemporary and 1 lag PDL on tweets and a contemporary PDL on wiki with an ARIMA of (1,0,0)(0,0,0). Estimating this model locally and globally provides insight as to the commonality of coefficients . with coefficients . The test for commonality is easily rejected with an F value of 79 with 3,291 df. Note that the DW statistic is 2.63 from the composite analysis. The summary of coeffficients is presented here. The OP poster reflected that the only software he has access to is insufficient to be able to answer this thorny research question.
How to perform pooled cross-sectional time series analysis? For each of the 86 companies , identify an appropriate ARMAX model which should incorporate the effects ( both contemporaneous and lag ) of the two user-suggested predictor variables and any necessary
41,244
How to perform pooled cross-sectional time series analysis?
There are a few things that I would do differently. First, because each stock has a different overall level, you should include a set of ticker fixed effects, which is a set of dummy variables for whether a particular observation belongs to a particular ticker. Second, stock prices are (almost?) always assumed to have a unit root. This would mean that the coefficient on your lagged variable would be 1. It is already pretty close (0.876); without fixed effects we can't be sure (because there could be bias), but it is pretty suggestive of a unit root. For proper inference, you must look at the change in stock prices or the change in the log of the stock price (the latter is roughly equal to the % change or the return and is what is typically used). Otherwise you can get spurious results. As an added bonus, this differencing actually removes the need for ticker fixed effects. Third, your standard errors are likely too small. You should employ standard errors that are clustered at the ticker level. This helps account for remaining serial correlation in the error terms. These issues should be discussed in any reference to panel data, the usual moniker for data of the type that you are using. Wooldridge's Introductory Econometrics textbook for undergrads or Econometric Analysis of Cross Section and Panel Data for graduate students are common references.
How to perform pooled cross-sectional time series analysis?
There are a few things that I would do differently. First, because each stock has a different overall level, you should include a set of ticker fixed effects, which is a set of dummy variables for whe
How to perform pooled cross-sectional time series analysis? There are a few things that I would do differently. First, because each stock has a different overall level, you should include a set of ticker fixed effects, which is a set of dummy variables for whether a particular observation belongs to a particular ticker. Second, stock prices are (almost?) always assumed to have a unit root. This would mean that the coefficient on your lagged variable would be 1. It is already pretty close (0.876); without fixed effects we can't be sure (because there could be bias), but it is pretty suggestive of a unit root. For proper inference, you must look at the change in stock prices or the change in the log of the stock price (the latter is roughly equal to the % change or the return and is what is typically used). Otherwise you can get spurious results. As an added bonus, this differencing actually removes the need for ticker fixed effects. Third, your standard errors are likely too small. You should employ standard errors that are clustered at the ticker level. This helps account for remaining serial correlation in the error terms. These issues should be discussed in any reference to panel data, the usual moniker for data of the type that you are using. Wooldridge's Introductory Econometrics textbook for undergrads or Econometric Analysis of Cross Section and Panel Data for graduate students are common references.
How to perform pooled cross-sectional time series analysis? There are a few things that I would do differently. First, because each stock has a different overall level, you should include a set of ticker fixed effects, which is a set of dummy variables for whe
41,245
How to perform pooled cross-sectional time series analysis?
In some ways the models seem to agree quite a bit. The standard error of the estimates and the Durbin-Watson statistic are very similar between the two models. Also the constant term and the regressors hbVolLog and wikiLog are significant in both models. The main difference seems to be that the first model includes the lagged value of the dependent variable and that seems to account for the large increase in R square. So I see nothing strange about the results. it just points to the strength of the lagged variable in predicting StockVol0. What does puzzle me is why the adjusted R square is the same as the unadjusted rather than being somewhat lower.
How to perform pooled cross-sectional time series analysis?
In some ways the models seem to agree quite a bit. The standard error of the estimates and the Durbin-Watson statistic are very similar between the two models. Also the constant term and the regresso
How to perform pooled cross-sectional time series analysis? In some ways the models seem to agree quite a bit. The standard error of the estimates and the Durbin-Watson statistic are very similar between the two models. Also the constant term and the regressors hbVolLog and wikiLog are significant in both models. The main difference seems to be that the first model includes the lagged value of the dependent variable and that seems to account for the large increase in R square. So I see nothing strange about the results. it just points to the strength of the lagged variable in predicting StockVol0. What does puzzle me is why the adjusted R square is the same as the unadjusted rather than being somewhat lower.
How to perform pooled cross-sectional time series analysis? In some ways the models seem to agree quite a bit. The standard error of the estimates and the Durbin-Watson statistic are very similar between the two models. Also the constant term and the regresso
41,246
How to perform pooled cross-sectional time series analysis?
There are several possibilities in this problem, and really the best discussion I can cite is The Theory and Practice of Econometrics, 2nd edition, George Judege, W.E. Griffiths, R. Carter Hill, Helmut Lutkepohl, and Tsoung-Chao Lee, Wiley Series in Probability and Mathematical Statistics 1985, Chapter 13, Inference in Models That Combine Time Series and Cross-Sectional Data. Sounds dated, but I have been doing research with ridge regression that dips back into this resource. This was a big, very comprehensive book. Sorry I don't have more time to specifically analyse this, but I may do a post on this type of problem in my blog www.businessforecastblog.com
How to perform pooled cross-sectional time series analysis?
There are several possibilities in this problem, and really the best discussion I can cite is The Theory and Practice of Econometrics, 2nd edition, George Judege, W.E. Griffiths, R. Carter Hill, Helmu
How to perform pooled cross-sectional time series analysis? There are several possibilities in this problem, and really the best discussion I can cite is The Theory and Practice of Econometrics, 2nd edition, George Judege, W.E. Griffiths, R. Carter Hill, Helmut Lutkepohl, and Tsoung-Chao Lee, Wiley Series in Probability and Mathematical Statistics 1985, Chapter 13, Inference in Models That Combine Time Series and Cross-Sectional Data. Sounds dated, but I have been doing research with ridge regression that dips back into this resource. This was a big, very comprehensive book. Sorry I don't have more time to specifically analyse this, but I may do a post on this type of problem in my blog www.businessforecastblog.com
How to perform pooled cross-sectional time series analysis? There are several possibilities in this problem, and really the best discussion I can cite is The Theory and Practice of Econometrics, 2nd edition, George Judege, W.E. Griffiths, R. Carter Hill, Helmu
41,247
Is the sample variance a useful measure for non-normal data?
Does it ever make sense? I don't know. It depends on what you are trying to do. But you say you aren't trying to do anything, so there's no good answer. I can't think of a case where the variance of a bimodal distribution makes much sense. But you say (e.g.) bimodal. If the data are non-normal, but not all that non-normal, variance can make sense. My general rule is that, if the mean makes sense, the variance makes sense. If the median makes sense then either the mean absolute deviation or interquartile range makes sense. For bimodal distributions, neither the mean nor the median makes all that much sense. A density plot is a good method here, or a table of percentiles.
Is the sample variance a useful measure for non-normal data?
Does it ever make sense? I don't know. It depends on what you are trying to do. But you say you aren't trying to do anything, so there's no good answer. I can't think of a case where the variance of a
Is the sample variance a useful measure for non-normal data? Does it ever make sense? I don't know. It depends on what you are trying to do. But you say you aren't trying to do anything, so there's no good answer. I can't think of a case where the variance of a bimodal distribution makes much sense. But you say (e.g.) bimodal. If the data are non-normal, but not all that non-normal, variance can make sense. My general rule is that, if the mean makes sense, the variance makes sense. If the median makes sense then either the mean absolute deviation or interquartile range makes sense. For bimodal distributions, neither the mean nor the median makes all that much sense. A density plot is a good method here, or a table of percentiles.
Is the sample variance a useful measure for non-normal data? Does it ever make sense? I don't know. It depends on what you are trying to do. But you say you aren't trying to do anything, so there's no good answer. I can't think of a case where the variance of a
41,248
Is the sample variance a useful measure for non-normal data?
We frequently use scaling relationships between central moments to ascertain the most likely underlying generative process of biological data. I studied the dynamics of the HIV promoter and it produces very non-Gaussian distributions that are wide and highly skewed. The Var~Mean relationship was the first step in determining candidate stochastic models. Moment analysis is never an end in itself, without interpretation they're of limited use.
Is the sample variance a useful measure for non-normal data?
We frequently use scaling relationships between central moments to ascertain the most likely underlying generative process of biological data. I studied the dynamics of the HIV promoter and it produce
Is the sample variance a useful measure for non-normal data? We frequently use scaling relationships between central moments to ascertain the most likely underlying generative process of biological data. I studied the dynamics of the HIV promoter and it produces very non-Gaussian distributions that are wide and highly skewed. The Var~Mean relationship was the first step in determining candidate stochastic models. Moment analysis is never an end in itself, without interpretation they're of limited use.
Is the sample variance a useful measure for non-normal data? We frequently use scaling relationships between central moments to ascertain the most likely underlying generative process of biological data. I studied the dynamics of the HIV promoter and it produce
41,249
Normality of residuals in a regression model with a categorical IV
(Note that a regression model with only 1 explanatory variable that is categorical and has just 2 levels is equivalent to a t-test; there's nothing wrong with calling it a regression, but it would most commonly be discussed / referred to as a t-test.) You check the distribution of all the residuals simultaneously. There are tests for normality, but I'm not a huge fan of them (I listed some in my answer to your previous question). I think the best option is to make a qq-plot. You can find a really nice version (qq.plot) in John Fox's car package. Among other features, it'll give you a 95% confidence band, which can help you interpret the plot. On a different note, from looking at your plot, I don't know if you have more data in the second group, but you should also check to ensure you have homogeneity of variance.
Normality of residuals in a regression model with a categorical IV
(Note that a regression model with only 1 explanatory variable that is categorical and has just 2 levels is equivalent to a t-test; there's nothing wrong with calling it a regression, but it would mos
Normality of residuals in a regression model with a categorical IV (Note that a regression model with only 1 explanatory variable that is categorical and has just 2 levels is equivalent to a t-test; there's nothing wrong with calling it a regression, but it would most commonly be discussed / referred to as a t-test.) You check the distribution of all the residuals simultaneously. There are tests for normality, but I'm not a huge fan of them (I listed some in my answer to your previous question). I think the best option is to make a qq-plot. You can find a really nice version (qq.plot) in John Fox's car package. Among other features, it'll give you a 95% confidence band, which can help you interpret the plot. On a different note, from looking at your plot, I don't know if you have more data in the second group, but you should also check to ensure you have homogeneity of variance.
Normality of residuals in a regression model with a categorical IV (Note that a regression model with only 1 explanatory variable that is categorical and has just 2 levels is equivalent to a t-test; there's nothing wrong with calling it a regression, but it would mos
41,250
Dealing with a categorical variable that can take multiple levels simultaneously
Two models come to mind: the revenue may have a contribution from the presence of each speaker or it may have a contribution from the speaker's presence, weighted by their participation in the event. In either case the coding would be similar: to each speaker corresponds a variable that is zero when the speaker is not involved and is nonzero when they are. In the first model the variable's value would be one whenever a speaker is involved in an event and zero otherwise. In the second model, those ones might be reweighted a priori. You can try several models with several weighting schemes to see what might work the best: after all, this problem has somewhat of an exploratory nature to it. That leaves us the practical issue of coding the models. Creating one column for each speaker is straightforward, but the concerns expressed in comments have to do with the length and complexity of the resulting formula expressions. Fortunately, formulas can be created dynamically. Here is an illustration. First, let's create some simulated data. In each row at least one speaker and usually two or three speakers are involved: set.seed(17) n.records <- 1000 n.speakers <- 154 i <- c(rep(1,3), rep(0, n.speakers-2)) x.matrix <- sapply(1:n.records, function(j) sample(i, n.speakers)) x <- as.data.frame(t(x.matrix)) Let's name the columns "Speaker1", "Speaker2", etc (and retain this list of names for later): colnames(x) <- colnames <- lapply(1:n.speakers, function(i) sprintf("Speaker%d",i)) Throw in a response variable: x$y <- rnorm(n.records) Let's see how this response depends on the speaker data. To do this, we create a formula from the column names we retained earlier: formula <- as.formula(paste("y ~", paste(colnames, collapse="+")) fit <- lm(formula, data=x) summary(fit) There's no problem: R handles a formula of this length with aplomb. Extending this formula to include other variables is simple; e.g., hard-code the remainder and paste it on to the end of this computed formula.
Dealing with a categorical variable that can take multiple levels simultaneously
Two models come to mind: the revenue may have a contribution from the presence of each speaker or it may have a contribution from the speaker's presence, weighted by their participation in the event.
Dealing with a categorical variable that can take multiple levels simultaneously Two models come to mind: the revenue may have a contribution from the presence of each speaker or it may have a contribution from the speaker's presence, weighted by their participation in the event. In either case the coding would be similar: to each speaker corresponds a variable that is zero when the speaker is not involved and is nonzero when they are. In the first model the variable's value would be one whenever a speaker is involved in an event and zero otherwise. In the second model, those ones might be reweighted a priori. You can try several models with several weighting schemes to see what might work the best: after all, this problem has somewhat of an exploratory nature to it. That leaves us the practical issue of coding the models. Creating one column for each speaker is straightforward, but the concerns expressed in comments have to do with the length and complexity of the resulting formula expressions. Fortunately, formulas can be created dynamically. Here is an illustration. First, let's create some simulated data. In each row at least one speaker and usually two or three speakers are involved: set.seed(17) n.records <- 1000 n.speakers <- 154 i <- c(rep(1,3), rep(0, n.speakers-2)) x.matrix <- sapply(1:n.records, function(j) sample(i, n.speakers)) x <- as.data.frame(t(x.matrix)) Let's name the columns "Speaker1", "Speaker2", etc (and retain this list of names for later): colnames(x) <- colnames <- lapply(1:n.speakers, function(i) sprintf("Speaker%d",i)) Throw in a response variable: x$y <- rnorm(n.records) Let's see how this response depends on the speaker data. To do this, we create a formula from the column names we retained earlier: formula <- as.formula(paste("y ~", paste(colnames, collapse="+")) fit <- lm(formula, data=x) summary(fit) There's no problem: R handles a formula of this length with aplomb. Extending this formula to include other variables is simple; e.g., hard-code the remainder and paste it on to the end of this computed formula.
Dealing with a categorical variable that can take multiple levels simultaneously Two models come to mind: the revenue may have a contribution from the presence of each speaker or it may have a contribution from the speaker's presence, weighted by their participation in the event.
41,251
Which weighting factor to use for text categorization
Have you thought about storing the term frequency and the document frequency separately for the trained set, then when you add a new document you can update the document frequency of the new trained set, i.e. including the new document, and calculate tf-idf. Or am I missing something?
Which weighting factor to use for text categorization
Have you thought about storing the term frequency and the document frequency separately for the trained set, then when you add a new document you can update the document frequency of the new trained
Which weighting factor to use for text categorization Have you thought about storing the term frequency and the document frequency separately for the trained set, then when you add a new document you can update the document frequency of the new trained set, i.e. including the new document, and calculate tf-idf. Or am I missing something?
Which weighting factor to use for text categorization Have you thought about storing the term frequency and the document frequency separately for the trained set, then when you add a new document you can update the document frequency of the new trained
41,252
Which weighting factor to use for text categorization
The same as simmmons clarified, we can store a term frequency vector for all terms in the training vocabulary. Then we can easily survive in this incremental context, by assuming the new document is also in the training corpus, and then update this vector with newly added files, and finally re-calculate the idf (tf-idf) values for this doc. For simplicity, I think it's not wise to re-train the model for the "out-of-date" training corpus, if the size of training corpus is too large, 1 million for instance. I found a similar thread as my question, but with more detailed explanations and some maths formulas. You may refer to it.
Which weighting factor to use for text categorization
The same as simmmons clarified, we can store a term frequency vector for all terms in the training vocabulary. Then we can easily survive in this incremental context, by assuming the new document is a
Which weighting factor to use for text categorization The same as simmmons clarified, we can store a term frequency vector for all terms in the training vocabulary. Then we can easily survive in this incremental context, by assuming the new document is also in the training corpus, and then update this vector with newly added files, and finally re-calculate the idf (tf-idf) values for this doc. For simplicity, I think it's not wise to re-train the model for the "out-of-date" training corpus, if the size of training corpus is too large, 1 million for instance. I found a similar thread as my question, but with more detailed explanations and some maths formulas. You may refer to it.
Which weighting factor to use for text categorization The same as simmmons clarified, we can store a term frequency vector for all terms in the training vocabulary. Then we can easily survive in this incremental context, by assuming the new document is a
41,253
How to be sure about the distribution of a discrete and limited stochastic variable?
If you have a Bernoulli variable (0 or 1) with probability $p$, its variance is $p(1-p)$ which is always less than or equal to $1/4$. The mean of $n$ independent Bernoulli variables tends to a Gaussian of variance $p(1-p)/n$ which is always less than or equal to $1/4n$. You can use the fact that a Gaussian variable has a 99% chance of being within plus or minus 2.58 standard deviations, so you have to set your upper bound so that $2.58/(2\sqrt{n}) < .01$ which gives you $n \geq 16641$. Because each of your three outcomes individually behaves as a Bernoulli variable and because this is a global upper bound you can also apply this number to your discrete variable with three outcomes.
How to be sure about the distribution of a discrete and limited stochastic variable?
If you have a Bernoulli variable (0 or 1) with probability $p$, its variance is $p(1-p)$ which is always less than or equal to $1/4$. The mean of $n$ independent Bernoulli variables tends to a Gaussia
How to be sure about the distribution of a discrete and limited stochastic variable? If you have a Bernoulli variable (0 or 1) with probability $p$, its variance is $p(1-p)$ which is always less than or equal to $1/4$. The mean of $n$ independent Bernoulli variables tends to a Gaussian of variance $p(1-p)/n$ which is always less than or equal to $1/4n$. You can use the fact that a Gaussian variable has a 99% chance of being within plus or minus 2.58 standard deviations, so you have to set your upper bound so that $2.58/(2\sqrt{n}) < .01$ which gives you $n \geq 16641$. Because each of your three outcomes individually behaves as a Bernoulli variable and because this is a global upper bound you can also apply this number to your discrete variable with three outcomes.
How to be sure about the distribution of a discrete and limited stochastic variable? If you have a Bernoulli variable (0 or 1) with probability $p$, its variance is $p(1-p)$ which is always less than or equal to $1/4$. The mean of $n$ independent Bernoulli variables tends to a Gaussia
41,254
How to be sure about the distribution of a discrete and limited stochastic variable?
The Bayesian way of doing this loses no information: Your variable $X$ is categorically distributed with probability vector $\mathbf p$. The conjugate prior of the categorical distribution is the Dirichlet distribution, so let $\mathbf p$ be Dirichlet-distributed with shape parameter vector $\boldsymbol\phi$. With every observation, you update $\boldsymbol\phi$ by incrementing the realized component. You can then check to see if your maximum likelihood probability $\mathbf p^\star$ is within 0.01 of the true probability by integrating the ball with radius 0.01 centered at $\mathbf p^\star$.
How to be sure about the distribution of a discrete and limited stochastic variable?
The Bayesian way of doing this loses no information: Your variable $X$ is categorically distributed with probability vector $\mathbf p$. The conjugate prior of the categorical distribution is the Dir
How to be sure about the distribution of a discrete and limited stochastic variable? The Bayesian way of doing this loses no information: Your variable $X$ is categorically distributed with probability vector $\mathbf p$. The conjugate prior of the categorical distribution is the Dirichlet distribution, so let $\mathbf p$ be Dirichlet-distributed with shape parameter vector $\boldsymbol\phi$. With every observation, you update $\boldsymbol\phi$ by incrementing the realized component. You can then check to see if your maximum likelihood probability $\mathbf p^\star$ is within 0.01 of the true probability by integrating the ball with radius 0.01 centered at $\mathbf p^\star$.
How to be sure about the distribution of a discrete and limited stochastic variable? The Bayesian way of doing this loses no information: Your variable $X$ is categorically distributed with probability vector $\mathbf p$. The conjugate prior of the categorical distribution is the Dir
41,255
Bayesian mixed model regression with a between subjects factor
I eventually figured this one out with much help from Doing Bayesian Data Analysis (Kruschke) and Data Analysis Using Regression and Multilevel/Hierarchical Models (Gelman). This model gives varying intercepts and slopes and the correlation between them. y = dependent variable sLvl = participant id at each data point aLvlx = between subjects factor for each id NaLvl = Number of levels for the between subject's factor Ntotal = total length of data in long form modelstring = " model { for( r in 1 : Ntotal ) { y[r] ~ dnorm( mu[r] , tau ) mu[r] <- b0[ sLvl[r] ] + b1[ sLvl[r] ] * x[r] } #General priors tau ~ dgamma( sG , rG ) sG <- pow(m,2)/pow(d,2) rG <- m/pow(d,2) m ~ dgamma(1, 0.001) d ~ dgamma(1, 0.001) #Subject level priors for ( s in 1 : NsLvl ) { b0[s] <- B[s,1] b1[s] <- B[s,2] B[s, 1:2] ~ dmnorm( B.hat[s, ], Tau.B[ , ] ) B.hat[s,1] <- hix1[aLvlx[s]] B.hat[s,2] <- hix2[aLvlx[s]] } Tau.B[1:2 , 1:2] <- inverse(Sigma.B[,]) Sigma.B[1,1] <- pow(tau0G, 2) Sigma.B[2,2] <- pow(tau1G, 2) Sigma.B[1,2] <- rho * tau0G * tau1G Sigma.B[2,1] <- Sigma.B[1,2] tau0G ~ dunif(0.001,100) tau1G ~ dunif(0.001,100) rho ~ dunif(-1,1) #Between subjects level priors for ( k in 1:NaLvl ) { hix1[k] ~ dnorm( 0 , 0.0000001 ) hix2[k] ~ dnorm( 0 , 0.0000001 ) } }" writeLines(modelstring,con="model.txt")
Bayesian mixed model regression with a between subjects factor
I eventually figured this one out with much help from Doing Bayesian Data Analysis (Kruschke) and Data Analysis Using Regression and Multilevel/Hierarchical Models (Gelman). This model gives varyi
Bayesian mixed model regression with a between subjects factor I eventually figured this one out with much help from Doing Bayesian Data Analysis (Kruschke) and Data Analysis Using Regression and Multilevel/Hierarchical Models (Gelman). This model gives varying intercepts and slopes and the correlation between them. y = dependent variable sLvl = participant id at each data point aLvlx = between subjects factor for each id NaLvl = Number of levels for the between subject's factor Ntotal = total length of data in long form modelstring = " model { for( r in 1 : Ntotal ) { y[r] ~ dnorm( mu[r] , tau ) mu[r] <- b0[ sLvl[r] ] + b1[ sLvl[r] ] * x[r] } #General priors tau ~ dgamma( sG , rG ) sG <- pow(m,2)/pow(d,2) rG <- m/pow(d,2) m ~ dgamma(1, 0.001) d ~ dgamma(1, 0.001) #Subject level priors for ( s in 1 : NsLvl ) { b0[s] <- B[s,1] b1[s] <- B[s,2] B[s, 1:2] ~ dmnorm( B.hat[s, ], Tau.B[ , ] ) B.hat[s,1] <- hix1[aLvlx[s]] B.hat[s,2] <- hix2[aLvlx[s]] } Tau.B[1:2 , 1:2] <- inverse(Sigma.B[,]) Sigma.B[1,1] <- pow(tau0G, 2) Sigma.B[2,2] <- pow(tau1G, 2) Sigma.B[1,2] <- rho * tau0G * tau1G Sigma.B[2,1] <- Sigma.B[1,2] tau0G ~ dunif(0.001,100) tau1G ~ dunif(0.001,100) rho ~ dunif(-1,1) #Between subjects level priors for ( k in 1:NaLvl ) { hix1[k] ~ dnorm( 0 , 0.0000001 ) hix2[k] ~ dnorm( 0 , 0.0000001 ) } }" writeLines(modelstring,con="model.txt")
Bayesian mixed model regression with a between subjects factor I eventually figured this one out with much help from Doing Bayesian Data Analysis (Kruschke) and Data Analysis Using Regression and Multilevel/Hierarchical Models (Gelman). This model gives varyi
41,256
Disease forecasting - counts or rates?
I've been pondering this question myself a lot recently, especially in the context of hospital epidemiology. My thoughts below: The Case for Counts: The real core of the strength for counts is that they're a more meaningful number on a practical scale. Tell a nurse they're going to see 0.20 cases/patient-day more infections and they'll give you an odd look. Tell them they're going to see 17 more cases this month? That's a meaningful number for them to work off of. This ties into a general undercurrent in Epidemiology at the moment focusing on an interest in absolute numbers, because our currently reliance on relative effect measures does some funny things, including exaggerating small effects at times. For example, if your rate doubles is that a crisis? Probably depends on if the counts are 1 and 2, 100 and 200 or 100,000 and 200,000. The Case for Rates: That being said, there's a reason people like rates. Counts only really make sense if your denominator is fixed, or relatively so. For example, if your clinic sees 1,000 patients each month, then a change in cases from Month X to Month X+1 is a genuine change in cases. But if you saw 1,200 the second month? Are your increase in cases an increase, or just having more opportunity to see cases? Or in the case of hospital acquired infections, if you had more patients staying for more time in a given month, you had more opportunities to get them sick, and should probably adjust for that. So the answer I think, sadly, is it depends. If you're confident that your denominator is stable, and each time point represents the same "opportunity" to see cases, you can probably get away with cases. But if it moves around, and one time point has more patients, staying for more time, etc. then you should probably use rates, unless you don't think you can get a good denominator. And on a practical note, clinicians are trained, in my experience, to expect rates. If you want to publish or distribute your count-based findings, expect some push-back.
Disease forecasting - counts or rates?
I've been pondering this question myself a lot recently, especially in the context of hospital epidemiology. My thoughts below: The Case for Counts: The real core of the strength for counts is that th
Disease forecasting - counts or rates? I've been pondering this question myself a lot recently, especially in the context of hospital epidemiology. My thoughts below: The Case for Counts: The real core of the strength for counts is that they're a more meaningful number on a practical scale. Tell a nurse they're going to see 0.20 cases/patient-day more infections and they'll give you an odd look. Tell them they're going to see 17 more cases this month? That's a meaningful number for them to work off of. This ties into a general undercurrent in Epidemiology at the moment focusing on an interest in absolute numbers, because our currently reliance on relative effect measures does some funny things, including exaggerating small effects at times. For example, if your rate doubles is that a crisis? Probably depends on if the counts are 1 and 2, 100 and 200 or 100,000 and 200,000. The Case for Rates: That being said, there's a reason people like rates. Counts only really make sense if your denominator is fixed, or relatively so. For example, if your clinic sees 1,000 patients each month, then a change in cases from Month X to Month X+1 is a genuine change in cases. But if you saw 1,200 the second month? Are your increase in cases an increase, or just having more opportunity to see cases? Or in the case of hospital acquired infections, if you had more patients staying for more time in a given month, you had more opportunities to get them sick, and should probably adjust for that. So the answer I think, sadly, is it depends. If you're confident that your denominator is stable, and each time point represents the same "opportunity" to see cases, you can probably get away with cases. But if it moves around, and one time point has more patients, staying for more time, etc. then you should probably use rates, unless you don't think you can get a good denominator. And on a practical note, clinicians are trained, in my experience, to expect rates. If you want to publish or distribute your count-based findings, expect some push-back.
Disease forecasting - counts or rates? I've been pondering this question myself a lot recently, especially in the context of hospital epidemiology. My thoughts below: The Case for Counts: The real core of the strength for counts is that th
41,257
Sorting answers, given overvotes and undervotes
I recently learned about Bayesian rating. Bayesian rating computes a weighted average of the naive uncorrected rating for this answer and the average rating for all answers. The fewer the votes for this answer, the more we weight things towards the average rating. The intuition is that if we have no votes on this answer, then the average rating (across all answers) is our best guess at the rating of this answer; as we gain more votes on this answer, they start to move our estimate away from the average rating. The scheme apparently works like this. The naive uncorrected rating for an answer is $r = u/n$, where $u$ is the number of upvotes and $n$ the total number of votes for that answer (i.e., $n=u+d$, where $d$ is the number of downvotes). Let $r^*$ denote the average uncorrected rating, averaged over all answers, i.e., the average of $r$ over all answers. Also, let $n^*$ the average number of votes per answer, over all answers, i.e., the average value of $n$. With these definitions, the Bayesian rating for an answer is $r'$, defined as follows: $$ r' = \frac{n}{n+n^*} r + \frac{n^*}{n+n^*} r^*. $$ Notice how if we have no votes on this answer, then $r'=r^*$ (the Bayesian rating is the average rating across all answers); whereas as $n \to \infty$, we have $r' \to r$ (the Bayesian rating for an answer converges to the naive uncorrected rating, as the number of votes on the answer becomes large). These seem like appealing properties. For a generalization that can be used if items can be rated from 1-5 stars, instead of upvoted/downvoted, see the answers to How to find confidence intervals for ratings?, the essay Bayesian sorting by rank (which appears to use a slightly different formula), and Bayesian Ratings: Your Salvation for User-Generated Content.
Sorting answers, given overvotes and undervotes
I recently learned about Bayesian rating. Bayesian rating computes a weighted average of the naive uncorrected rating for this answer and the average rating for all answers. The fewer the votes for
Sorting answers, given overvotes and undervotes I recently learned about Bayesian rating. Bayesian rating computes a weighted average of the naive uncorrected rating for this answer and the average rating for all answers. The fewer the votes for this answer, the more we weight things towards the average rating. The intuition is that if we have no votes on this answer, then the average rating (across all answers) is our best guess at the rating of this answer; as we gain more votes on this answer, they start to move our estimate away from the average rating. The scheme apparently works like this. The naive uncorrected rating for an answer is $r = u/n$, where $u$ is the number of upvotes and $n$ the total number of votes for that answer (i.e., $n=u+d$, where $d$ is the number of downvotes). Let $r^*$ denote the average uncorrected rating, averaged over all answers, i.e., the average of $r$ over all answers. Also, let $n^*$ the average number of votes per answer, over all answers, i.e., the average value of $n$. With these definitions, the Bayesian rating for an answer is $r'$, defined as follows: $$ r' = \frac{n}{n+n^*} r + \frac{n^*}{n+n^*} r^*. $$ Notice how if we have no votes on this answer, then $r'=r^*$ (the Bayesian rating is the average rating across all answers); whereas as $n \to \infty$, we have $r' \to r$ (the Bayesian rating for an answer converges to the naive uncorrected rating, as the number of votes on the answer becomes large). These seem like appealing properties. For a generalization that can be used if items can be rated from 1-5 stars, instead of upvoted/downvoted, see the answers to How to find confidence intervals for ratings?, the essay Bayesian sorting by rank (which appears to use a slightly different formula), and Bayesian Ratings: Your Salvation for User-Generated Content.
Sorting answers, given overvotes and undervotes I recently learned about Bayesian rating. Bayesian rating computes a weighted average of the naive uncorrected rating for this answer and the average rating for all answers. The fewer the votes for
41,258
Sorting answers, given overvotes and undervotes
I found an essay (How Not To Sort By Average Rating) which argues that you should compute a 95% confidence interval for the true fraction of people who would vote positively, and then sort ratings by the lower end of the confidence interval. This is an interesting approach. It is hard for me to judge whether this is in some sense the "right" way to do it, but it seems to behave better than some of the more naive alternatives. Worth noting: @raegtin gives a cogent criticism of this approach, in his answer to a related question. The short version of the criticism is that using the lower limit of a confidence interval pushes items with few ratings towards a very low rating, where it's probably better to push them towards the average rating over all items (as Bayesian rating does).
Sorting answers, given overvotes and undervotes
I found an essay (How Not To Sort By Average Rating) which argues that you should compute a 95% confidence interval for the true fraction of people who would vote positively, and then sort ratings by
Sorting answers, given overvotes and undervotes I found an essay (How Not To Sort By Average Rating) which argues that you should compute a 95% confidence interval for the true fraction of people who would vote positively, and then sort ratings by the lower end of the confidence interval. This is an interesting approach. It is hard for me to judge whether this is in some sense the "right" way to do it, but it seems to behave better than some of the more naive alternatives. Worth noting: @raegtin gives a cogent criticism of this approach, in his answer to a related question. The short version of the criticism is that using the lower limit of a confidence interval pushes items with few ratings towards a very low rating, where it's probably better to push them towards the average rating over all items (as Bayesian rating does).
Sorting answers, given overvotes and undervotes I found an essay (How Not To Sort By Average Rating) which argues that you should compute a 95% confidence interval for the true fraction of people who would vote positively, and then sort ratings by
41,259
Equivalent mixed models yielding different results in SAS
By default, SAS uses a very simple method to compute the degrees of freedom; it looks to see if the fixed effect appears in a term in the random effects; if so, it uses that random effect as the degrees of freedom. In this case, the model with random effects of TUBE and TUBE*POSITION do the right thing as this method can tell that POSITION should use TUBE*POSITION. But the model with POSITION / subject=TUBE cannot. Instead, one should tell it to compute the degrees of freedom using another method, usually the Satterthwaite (satterth) for models with only random effects and the Kenward-Roger method (kr) for models with repeated effects structures. PROC MIXED DATA=dat ; CLASS POSITION TUBE ; MODEL y = POSITION /s ddfm=satterth; RANDOM POSITION / subject=TUBE type=CS; RUN;
Equivalent mixed models yielding different results in SAS
By default, SAS uses a very simple method to compute the degrees of freedom; it looks to see if the fixed effect appears in a term in the random effects; if so, it uses that random effect as the degre
Equivalent mixed models yielding different results in SAS By default, SAS uses a very simple method to compute the degrees of freedom; it looks to see if the fixed effect appears in a term in the random effects; if so, it uses that random effect as the degrees of freedom. In this case, the model with random effects of TUBE and TUBE*POSITION do the right thing as this method can tell that POSITION should use TUBE*POSITION. But the model with POSITION / subject=TUBE cannot. Instead, one should tell it to compute the degrees of freedom using another method, usually the Satterthwaite (satterth) for models with only random effects and the Kenward-Roger method (kr) for models with repeated effects structures. PROC MIXED DATA=dat ; CLASS POSITION TUBE ; MODEL y = POSITION /s ddfm=satterth; RANDOM POSITION / subject=TUBE type=CS; RUN;
Equivalent mixed models yielding different results in SAS By default, SAS uses a very simple method to compute the degrees of freedom; it looks to see if the fixed effect appears in a term in the random effects; if so, it uses that random effect as the degre
41,260
Geometric distribution without replacement
I am going to interpret the question as follows: Find the expected number of white balls drawn before a black one is seen among $j$ draws without replacement, where if no black ball is seen, then the observation takes the value $j$. If this is not what you intend, please advise and I will revise accordingly. We can use a nice, handy trick to find the expected value. First, let's set out some notation. Let $X$ be the number of white balls seen before the first black ball is drawn in a sample of size $n$ taken without replacement from $n = w + b$ balls. Obviously $X \in \{0,1,\ldots,w\}$ with probability 1. Now, define $\newcommand{\Zj}{Z^{(j)}}\Zj$ to be the number of white balls seen before the first black ball from the first $j$ draws, or $j$ otherwise. Hence $\Zj = \min(X,j)$. We seek $\newcommand{\E}{\mathbb E}\renewcommand{\Pr}{\mathbb P}\E \Zj$. We need only consider $j \leq w$, since $\E \Zj = \E X$ for $j \geq w$. Fact: If $Y$ is a nonnegative integer-valued random variable, then $$\E Y = \sum_{k=1}^\infty \Pr(Y \geq k) \>.$$ The proof is relatively easy and is omitted. It is a special case of the more general result that if $Y \geq 0$ almost surely, then $\E Y = \int_0^\infty \Pr(Y > y) \,\mathrm d y$. Now, back to business. The key is to recognize the following equivalence of events, valid for $k \in \{0,\ldots,j\}$: $$ \{ \Zj \geq k\} = \{ X \geq k\} \>. $$ Hence we have $$ \E \Zj = \sum_{k=1}^j \Pr(\Zj \geq k) = \sum_{k=1}^j \Pr(X \geq k) = \sum_{k=1}^j \frac{{w \choose k}}{{n \choose k}} \>, $$ where the last equality follows from the fact that $X \geq k$ if and only if the first $k$ balls drawn are white. Some binomial-coefficient manipulations yield $$ \E \Zj = \sum_{k=1}^j \frac{{w \choose k}}{{n \choose k}} = \frac{w}{n-w+1}\left(1 - \frac{{{w-1} \choose j}}{{n \choose j}} \right) \>. $$ Post scriptum: In case the last equality looks at all mysterious, we can give a short sketch of the proof. Let $S_k = \Pr(X \geq k)$ and $p_k = \Pr(X = k) = S_k - S_{k+1}$. Then, $$ \mu = \E\Zj = \sum_{k=1}^j S_k = \sum_{k=1}^{j-1} k p_k + j S_j \>. $$ Now, note that $k p_k = w S_k - n S_{k+1}$. All that is left to do is to sum over $k$, rearrange, and solve for $\mu$.
Geometric distribution without replacement
I am going to interpret the question as follows: Find the expected number of white balls drawn before a black one is seen among $j$ draws without replacement, where if no black ball is seen, then the
Geometric distribution without replacement I am going to interpret the question as follows: Find the expected number of white balls drawn before a black one is seen among $j$ draws without replacement, where if no black ball is seen, then the observation takes the value $j$. If this is not what you intend, please advise and I will revise accordingly. We can use a nice, handy trick to find the expected value. First, let's set out some notation. Let $X$ be the number of white balls seen before the first black ball is drawn in a sample of size $n$ taken without replacement from $n = w + b$ balls. Obviously $X \in \{0,1,\ldots,w\}$ with probability 1. Now, define $\newcommand{\Zj}{Z^{(j)}}\Zj$ to be the number of white balls seen before the first black ball from the first $j$ draws, or $j$ otherwise. Hence $\Zj = \min(X,j)$. We seek $\newcommand{\E}{\mathbb E}\renewcommand{\Pr}{\mathbb P}\E \Zj$. We need only consider $j \leq w$, since $\E \Zj = \E X$ for $j \geq w$. Fact: If $Y$ is a nonnegative integer-valued random variable, then $$\E Y = \sum_{k=1}^\infty \Pr(Y \geq k) \>.$$ The proof is relatively easy and is omitted. It is a special case of the more general result that if $Y \geq 0$ almost surely, then $\E Y = \int_0^\infty \Pr(Y > y) \,\mathrm d y$. Now, back to business. The key is to recognize the following equivalence of events, valid for $k \in \{0,\ldots,j\}$: $$ \{ \Zj \geq k\} = \{ X \geq k\} \>. $$ Hence we have $$ \E \Zj = \sum_{k=1}^j \Pr(\Zj \geq k) = \sum_{k=1}^j \Pr(X \geq k) = \sum_{k=1}^j \frac{{w \choose k}}{{n \choose k}} \>, $$ where the last equality follows from the fact that $X \geq k$ if and only if the first $k$ balls drawn are white. Some binomial-coefficient manipulations yield $$ \E \Zj = \sum_{k=1}^j \frac{{w \choose k}}{{n \choose k}} = \frac{w}{n-w+1}\left(1 - \frac{{{w-1} \choose j}}{{n \choose j}} \right) \>. $$ Post scriptum: In case the last equality looks at all mysterious, we can give a short sketch of the proof. Let $S_k = \Pr(X \geq k)$ and $p_k = \Pr(X = k) = S_k - S_{k+1}$. Then, $$ \mu = \E\Zj = \sum_{k=1}^j S_k = \sum_{k=1}^{j-1} k p_k + j S_j \>. $$ Now, note that $k p_k = w S_k - n S_{k+1}$. All that is left to do is to sum over $k$, rearrange, and solve for $\mu$.
Geometric distribution without replacement I am going to interpret the question as follows: Find the expected number of white balls drawn before a black one is seen among $j$ draws without replacement, where if no black ball is seen, then the
41,261
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms
I recommend partial residual plots using the rms package's lrm and residuals.lrm functions. You can also fit a series of binary models using different cutoffs for $Y$ and plot the log odds ratios vs. cutoff.
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms
I recommend partial residual plots using the rms package's lrm and residuals.lrm functions. You can also fit a series of binary models using different cutoffs for $Y$ and plot the log odds ratios vs.
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms I recommend partial residual plots using the rms package's lrm and residuals.lrm functions. You can also fit a series of binary models using different cutoffs for $Y$ and plot the log odds ratios vs. cutoff.
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms I recommend partial residual plots using the rms package's lrm and residuals.lrm functions. You can also fit a series of binary models using different cutoffs for $Y$ and plot the log odds ratios vs.
41,262
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms
Are there robust standard errors available in the package? or will the sandwich package calculate them for you? The dirty secret about model checking is there is almost never good statistical power to detect meaningful violations of your model. You can still check them, but more as post-hoc sensitivity analysis. The best is to use methods that are agnostic as to whether your the assumptions under which your model is 'optimal' are correct. E.g. proportional hazards are almost always violated in cox models, and linear models likely never correspond to some true underlying linear structure. Yet, with robust standard errors, it doesn't matter, and we can still make statements about trends.
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms
Are there robust standard errors available in the package? or will the sandwich package calculate them for you? The dirty secret about model checking is there is almost never good statistical power to
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms Are there robust standard errors available in the package? or will the sandwich package calculate them for you? The dirty secret about model checking is there is almost never good statistical power to detect meaningful violations of your model. You can still check them, but more as post-hoc sensitivity analysis. The best is to use methods that are agnostic as to whether your the assumptions under which your model is 'optimal' are correct. E.g. proportional hazards are almost always violated in cox models, and linear models likely never correspond to some true underlying linear structure. Yet, with robust standard errors, it doesn't matter, and we can still make statements about trends.
Proportional odds assumption in ordinal logistic regression in R with the packages VGAM and rms Are there robust standard errors available in the package? or will the sandwich package calculate them for you? The dirty secret about model checking is there is almost never good statistical power to
41,263
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform
If $Y_i$ are independent $\mathrm{Gamma}(\alpha_i,\beta)$, for $i=1,\dots,k$, then $$ (X_1,\dots,X_k) = \left(\frac{Y_1}{\sum_{j=1}^k Y_j}, \dots, \frac{Y_k}{\sum_{j=1}^k Y_j} \right) \sim \mathrm{Dirichlet}(\alpha_1,\dots,\alpha_k) \, .$$ So, in R just do something like rdirichlet <- function(a) { y <- rgamma(length(a), a, 1) return(y / sum(y)) } And use it uniformily > rdirichlet(c(1, 1, 1, 1)) [1] 0.40186737 0.03924152 0.37070316 0.18818796 or non-uniformily > rdirichlet(c(3, 2.5, 9, 7)) [1] 0.1377426 0.1043081 0.4701179 0.2878314 The proof is given on page 594 of Luc Devroye's beautiful book: http://luc.devroye.org/rnbookindex.html P.S. Thanks to @cardinal for the R hacking tips.
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform
If $Y_i$ are independent $\mathrm{Gamma}(\alpha_i,\beta)$, for $i=1,\dots,k$, then $$ (X_1,\dots,X_k) = \left(\frac{Y_1}{\sum_{j=1}^k Y_j}, \dots, \frac{Y_k}{\sum_{j=1}^k Y_j} \right) \sim \mathrm{Dir
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform If $Y_i$ are independent $\mathrm{Gamma}(\alpha_i,\beta)$, for $i=1,\dots,k$, then $$ (X_1,\dots,X_k) = \left(\frac{Y_1}{\sum_{j=1}^k Y_j}, \dots, \frac{Y_k}{\sum_{j=1}^k Y_j} \right) \sim \mathrm{Dirichlet}(\alpha_1,\dots,\alpha_k) \, .$$ So, in R just do something like rdirichlet <- function(a) { y <- rgamma(length(a), a, 1) return(y / sum(y)) } And use it uniformily > rdirichlet(c(1, 1, 1, 1)) [1] 0.40186737 0.03924152 0.37070316 0.18818796 or non-uniformily > rdirichlet(c(3, 2.5, 9, 7)) [1] 0.1377426 0.1043081 0.4701179 0.2878314 The proof is given on page 594 of Luc Devroye's beautiful book: http://luc.devroye.org/rnbookindex.html P.S. Thanks to @cardinal for the R hacking tips.
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform If $Y_i$ are independent $\mathrm{Gamma}(\alpha_i,\beta)$, for $i=1,\dots,k$, then $$ (X_1,\dots,X_k) = \left(\frac{Y_1}{\sum_{j=1}^k Y_j}, \dots, \frac{Y_k}{\sum_{j=1}^k Y_j} \right) \sim \mathrm{Dir
41,264
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform
Let $U_{(1)},U_{(2)}, \ldots, U_{(n)}$ be the order statistics from $U(0,1)$ distribution. Let $W_0 = U_{(1)},W_i = U_{(i+1)}-U{(i)}$, $1 \leq i \leq n-1$. Then $(W_0, W_1, \ldots, W_{n-1}) \sim \cal{D}(\alpha)$, a dirichlet distribution with parameter $\alpha_{n+1,1} = (1,1,\ldots,1)$. That is, $(W_0, W_1, \ldots, W_{n-1})$ is uniformly distributed in the n-dimensional simplex.
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform
Let $U_{(1)},U_{(2)}, \ldots, U_{(n)}$ be the order statistics from $U(0,1)$ distribution. Let $W_0 = U_{(1)},W_i = U_{(i+1)}-U{(i)}$, $1 \leq i \leq n-1$. Then $(W_0, W_1, \ldots, W_{n-1}) \sim \cal{
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform Let $U_{(1)},U_{(2)}, \ldots, U_{(n)}$ be the order statistics from $U(0,1)$ distribution. Let $W_0 = U_{(1)},W_i = U_{(i+1)}-U{(i)}$, $1 \leq i \leq n-1$. Then $(W_0, W_1, \ldots, W_{n-1}) \sim \cal{D}(\alpha)$, a dirichlet distribution with parameter $\alpha_{n+1,1} = (1,1,\ldots,1)$. That is, $(W_0, W_1, \ldots, W_{n-1})$ is uniformly distributed in the n-dimensional simplex.
Generating from Dirichlet distribution with the differences in a sequence of ordered uniform Let $U_{(1)},U_{(2)}, \ldots, U_{(n)}$ be the order statistics from $U(0,1)$ distribution. Let $W_0 = U_{(1)},W_i = U_{(i+1)}-U{(i)}$, $1 \leq i \leq n-1$. Then $(W_0, W_1, \ldots, W_{n-1}) \sim \cal{
41,265
R knn variable selection
knnFit1$results is actually a data.frame, so you can print all of the R-squared results with: knnFit1$results$Rsquared Or the R-squared result for just the best model: knnFit1.sorted <- results[order(results$Rsquared),] knnFit1.sorted[1,'Rsquared'] Does this answer your question?
R knn variable selection
knnFit1$results is actually a data.frame, so you can print all of the R-squared results with: knnFit1$results$Rsquared Or the R-squared result for just the best model: knnFit1.sorted <- results[order
R knn variable selection knnFit1$results is actually a data.frame, so you can print all of the R-squared results with: knnFit1$results$Rsquared Or the R-squared result for just the best model: knnFit1.sorted <- results[order(results$Rsquared),] knnFit1.sorted[1,'Rsquared'] Does this answer your question?
R knn variable selection knnFit1$results is actually a data.frame, so you can print all of the R-squared results with: knnFit1$results$Rsquared Or the R-squared result for just the best model: knnFit1.sorted <- results[order
41,266
How to find quantiles for multivariate data using R?
I would try here (mvnormtest, mvoutlier, mvtnorm): http://cran.r-project.org/web/views/Multivariate.html
How to find quantiles for multivariate data using R?
I would try here (mvnormtest, mvoutlier, mvtnorm): http://cran.r-project.org/web/views/Multivariate.html
How to find quantiles for multivariate data using R? I would try here (mvnormtest, mvoutlier, mvtnorm): http://cran.r-project.org/web/views/Multivariate.html
How to find quantiles for multivariate data using R? I would try here (mvnormtest, mvoutlier, mvtnorm): http://cran.r-project.org/web/views/Multivariate.html
41,267
How to find quantiles for multivariate data using R?
Why don't you try my package cepp. It can compute PC's quantiles for you! http://cran.r-project.org/web/packages/cepp/index.html You need the function $evaluator$ in this package. It takes two arguments which correspond to the number of rows and columns in the data. It returns a function which can be optimized to get the spatial quantiles. For a minimal example, see this snippet from the package documentation. x <- rnorm(500) dim(x) <- c(250,2) ev <- evaluator(250,2) ##The Spatial Median trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0,0), rinit=0.5, rmax=2e5, samp = x) ##Quantile for vector (0.2,0.3) trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0.2,0.3), rinit=0.5, rmax=2e5, samp = x)
How to find quantiles for multivariate data using R?
Why don't you try my package cepp. It can compute PC's quantiles for you! http://cran.r-project.org/web/packages/cepp/index.html You need the function $evaluator$ in this package. It takes two argumen
How to find quantiles for multivariate data using R? Why don't you try my package cepp. It can compute PC's quantiles for you! http://cran.r-project.org/web/packages/cepp/index.html You need the function $evaluator$ in this package. It takes two arguments which correspond to the number of rows and columns in the data. It returns a function which can be optimized to get the spatial quantiles. For a minimal example, see this snippet from the package documentation. x <- rnorm(500) dim(x) <- c(250,2) ev <- evaluator(250,2) ##The Spatial Median trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0,0), rinit=0.5, rmax=2e5, samp = x) ##Quantile for vector (0.2,0.3) trust(ev, parinit=c(median(x[1,]), median(x[2,])), u=c(0.2,0.3), rinit=0.5, rmax=2e5, samp = x)
How to find quantiles for multivariate data using R? Why don't you try my package cepp. It can compute PC's quantiles for you! http://cran.r-project.org/web/packages/cepp/index.html You need the function $evaluator$ in this package. It takes two argumen
41,268
How to find quantiles for multivariate data using R?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. You need to compute the CDF of the joint distribution f(x1,x2,...,xn). The CDF will give you the quantiles you seek.
How to find quantiles for multivariate data using R?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
How to find quantiles for multivariate data using R? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. You need to compute the CDF of the joint distribution f(x1,x2,...,xn). The CDF will give you the quantiles you seek.
How to find quantiles for multivariate data using R? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
41,269
Combining the results of two surveys
To be able to estimate to a population from a survey, the sampling method needs to be understood. The sampling method is used to create the sampling weights, which are then used to basically multiply up the survey estimates to be population estimates. There are all sorts of ways of creating weights, but they need to be based on the survey design. If you don't have the survey design information and/or you don't know how the weights were constructed, the key pieces of information you need to create the population-level estimates are missing. In particular for the two surveys, you need to be confident that the sampling method was appropriate, e.g. no quotas were used to stop sampling people of a particular age/sex combination, a convenience sample wasn't used. If either survey had these particular characteristics in the design, any population estimates (and even subpopulation estimates) are going to be wrong. There are some aspects of your question that I don't understand. For example, why do you wish to combine the two surveys - did they ask different questions? And surveys don't routinely sample the entire population - when that happens, we call it a census, so I don't understand your comment about the second survey. Can you give any more information about the survey design, and also if there are weights in the datasets and what these weights look like? Update for clarity: I am not sure that survey 2 will add anything other than bias to survey 1. In your question you state that survey 2 was not meant to estimate anything - that makes it sound like survey 2 has a convenience sample design. When dealing with convenience samples, it is not possible to weight up to the population because the sampling method used is biased rather than random. For example, a survey of supermarket shoppers at 10am on a weekday is biased (it will undercount full-time workers and overcount adult females, for example). With a biased sample it is not possible to weight the data to take account of the bias because the probability of being sampled is unknown for some groups, and may even be zero for others, but you don't know what these probabilities are. Therefore it is impossible to construct weights to account for the sampling when a biased sample has been used. Because it sounds like survey 1 has the better design for population estimation, I recommend that you use survey 1 for your estimates.
Combining the results of two surveys
To be able to estimate to a population from a survey, the sampling method needs to be understood. The sampling method is used to create the sampling weights, which are then used to basically multiply
Combining the results of two surveys To be able to estimate to a population from a survey, the sampling method needs to be understood. The sampling method is used to create the sampling weights, which are then used to basically multiply up the survey estimates to be population estimates. There are all sorts of ways of creating weights, but they need to be based on the survey design. If you don't have the survey design information and/or you don't know how the weights were constructed, the key pieces of information you need to create the population-level estimates are missing. In particular for the two surveys, you need to be confident that the sampling method was appropriate, e.g. no quotas were used to stop sampling people of a particular age/sex combination, a convenience sample wasn't used. If either survey had these particular characteristics in the design, any population estimates (and even subpopulation estimates) are going to be wrong. There are some aspects of your question that I don't understand. For example, why do you wish to combine the two surveys - did they ask different questions? And surveys don't routinely sample the entire population - when that happens, we call it a census, so I don't understand your comment about the second survey. Can you give any more information about the survey design, and also if there are weights in the datasets and what these weights look like? Update for clarity: I am not sure that survey 2 will add anything other than bias to survey 1. In your question you state that survey 2 was not meant to estimate anything - that makes it sound like survey 2 has a convenience sample design. When dealing with convenience samples, it is not possible to weight up to the population because the sampling method used is biased rather than random. For example, a survey of supermarket shoppers at 10am on a weekday is biased (it will undercount full-time workers and overcount adult females, for example). With a biased sample it is not possible to weight the data to take account of the bias because the probability of being sampled is unknown for some groups, and may even be zero for others, but you don't know what these probabilities are. Therefore it is impossible to construct weights to account for the sampling when a biased sample has been used. Because it sounds like survey 1 has the better design for population estimation, I recommend that you use survey 1 for your estimates.
Combining the results of two surveys To be able to estimate to a population from a survey, the sampling method needs to be understood. The sampling method is used to create the sampling weights, which are then used to basically multiply
41,270
Combining the results of two surveys
It looks like your survey 2 is a convenience sample. I don't know what it can be useful for. Without a clear sampling strategy, you cannot generalize to the population in any meaningful way. At best, you might be able to utilize Survey 2 to build a model of how variables are interrelated, and then try to improve your estimates from Survey 1 using some sort of generalized regression estimation but to get there, you need to make sure your sample is not biased. For instance, suppose you want to predict how much income taxes can be collected in the economy. Suppose you use something like the US Current Population Survey as your survey 1. This is a very well designed survey, with weights, poststratification, bells and whistles, whatever have you. Then you also have a survey that you hand out in the local unemployment offices, and only hope that most people will write something in. This is your survey 2. You don't know how well it reaches to your population -- in all likelihood, you are more likely to reach those who are seeking jobs more actively, and show up in the local offices more often. You won't reach the frustrated workers who quit looking for a job, or those who are not eligible for the unemployment benefits but would be looking for a job otherwise, some seasonal workers, and a number of other people. You don't know any of that though: somebody just handed you Survey 2 and said, "This is our rich data base, make sense out of it". Well, this is a biased sample to begin with. If you fit a regression model of individual's earnings using this data set, you will likely get wrong estimates: the sample censors out those with higher earnings in full time, permanent jobs, and probably has way more people with low education than there are in general population. So what's the use of Survey 2 for you? As I said, I doubt it has much value in this purpose. It is not helping at all that you give zero background information about what the survey is about, what sampling units are, etc. I understand that you are probably bound by your employer, or your client, or whatever form of supervisor you have. But without more detail, all we can give you is some sort of handwaving advice. I can point you to technical literature about combining information from several surveys (using Bayesian or empirical likelihood methods), but I am not sure it will help much at this point.
Combining the results of two surveys
It looks like your survey 2 is a convenience sample. I don't know what it can be useful for. Without a clear sampling strategy, you cannot generalize to the population in any meaningful way. At best,
Combining the results of two surveys It looks like your survey 2 is a convenience sample. I don't know what it can be useful for. Without a clear sampling strategy, you cannot generalize to the population in any meaningful way. At best, you might be able to utilize Survey 2 to build a model of how variables are interrelated, and then try to improve your estimates from Survey 1 using some sort of generalized regression estimation but to get there, you need to make sure your sample is not biased. For instance, suppose you want to predict how much income taxes can be collected in the economy. Suppose you use something like the US Current Population Survey as your survey 1. This is a very well designed survey, with weights, poststratification, bells and whistles, whatever have you. Then you also have a survey that you hand out in the local unemployment offices, and only hope that most people will write something in. This is your survey 2. You don't know how well it reaches to your population -- in all likelihood, you are more likely to reach those who are seeking jobs more actively, and show up in the local offices more often. You won't reach the frustrated workers who quit looking for a job, or those who are not eligible for the unemployment benefits but would be looking for a job otherwise, some seasonal workers, and a number of other people. You don't know any of that though: somebody just handed you Survey 2 and said, "This is our rich data base, make sense out of it". Well, this is a biased sample to begin with. If you fit a regression model of individual's earnings using this data set, you will likely get wrong estimates: the sample censors out those with higher earnings in full time, permanent jobs, and probably has way more people with low education than there are in general population. So what's the use of Survey 2 for you? As I said, I doubt it has much value in this purpose. It is not helping at all that you give zero background information about what the survey is about, what sampling units are, etc. I understand that you are probably bound by your employer, or your client, or whatever form of supervisor you have. But without more detail, all we can give you is some sort of handwaving advice. I can point you to technical literature about combining information from several surveys (using Bayesian or empirical likelihood methods), but I am not sure it will help much at this point.
Combining the results of two surveys It looks like your survey 2 is a convenience sample. I don't know what it can be useful for. Without a clear sampling strategy, you cannot generalize to the population in any meaningful way. At best,
41,271
Spatial econometrics -- computing residuals
The residuals that each of them calculating are different. Here is why: The model is as follows: $y = \rho Wy + xb + e$ with $e \sim n(0,1)$ Now if we play arround with it we get: $y = (I - \rho W)^{-1}(xb + e)$ Now what Prof. LeSage does is: $y - (I-\hat{\rho} \cdot W)^{-1} \cdot x\hat{b} = (I-\rho W)^{-1}\cdot e$ So what you are getting it the residual with the auto correlation. On the other hand, by transforming y: $y - \hat{\rho}\cdot W \cdot y = xb + e$ Estimating, $xb$ and calculation the residuals, what Bivand is doing is giving you $e$ instead of $(I-\rho W)^{-1}\cdot e$ Which one is preferred will depend on your application! Here is some code to prove it. I am not using SPDEP directly because i am not sure how to create random maps... But that is ok the code is pretty simple anyway: #------------------ GENERATE SAMPLE DATA rm(list=ls()) #clean require(igraph) #random graphs require(AER) #get ivreg ... n<-700 #700 locations p=0.2 g <- erdos.renyi.game(n=n, p.or.m=p, type="gnp", directed=F, loops=F) graph.density(g) w <- get.adjacency(g) #get an adjacency matrix w <- w/rowSums(w) #row standardize because of eigen vectors and eigen values sum(rowSums(w)==0) rho <- 0.5 intercept <- rep(1,n) rvariable <- rnorm(n) y <- solve(diag(n) - rho*w) %*% ( 2*intercept + 3*rvariable + rnorm(n)) After the data is generated according to a SAR LAG model we will estimated it via 2SLS (as i told you we could). #------------------ GENERATE INSTRUMENTS #get some instrumental variables z0 <- w%*%rvariable z1 <- w%*%w%*%rvariable #check to see if there is a minimum of correlation cor(z0, w%*%y) cor(z1, w%*%y) The instruments work because rvariable is exogenous. So as long as w is exogenous we have a game! #------------------ NOW ONTO ESTIMATION #The wrong way ... summary(out<-lm(y ~ rvariable)) confint(out) #The not so bad, but still very wrong way summary(out<-lm(y ~ w%*%y + rvariable)) confint(out) #ok now this should do it ... not perfect beacuse 2sls is not efficient. #I am doing it this way because i did not want to generate random maps... #Plus random graphs are easily available ! summary(out<-ivreg( y ~ w%*%y + rvariable, instruments=~ z0 + z1 + rvariable )) confint(out) Now to what really matters, the computation of residuals: #residuals LeSage way y_hat0 <- solve(diag(n) - coef(out)[2]*w ) %*% ( coef(out)[1]*intercept + coef(out)[3]*rvariable ) u_hat0 <- y - y_hat0 #residuals BiVand way y_tilda <- y - coef(out)[2]*w%*%y summary(out_biv <- lm( y_tilda ~ rvariable )) #ok they are not the same due to rounding error ... coef(out)[3] == coef(out_biv)[2]; round(coef(out)[3],5) == round(coef(out_biv)[2],5) u_hat1 <- residuals(out_biv) u_hat1 <- solve(diag(n) - coef(out)[2]*w)%*%u_hat1 #If we give Bivand some taste of autocorrelation it is the same as LeSage ... round( u_hat0 - u_hat1, 5) In the end you should see the residuals difference == 0 ! A cautionary note here is that depending on the structure of $W$ the effect might not be identifiable so the strategy of using the random graph generator might be bogus some times ! Anyway I hope this really solved your question
Spatial econometrics -- computing residuals
The residuals that each of them calculating are different. Here is why: The model is as follows: $y = \rho Wy + xb + e$ with $e \sim n(0,1)$ Now if we play arround with it we get: $y = (I - \rho W)^{
Spatial econometrics -- computing residuals The residuals that each of them calculating are different. Here is why: The model is as follows: $y = \rho Wy + xb + e$ with $e \sim n(0,1)$ Now if we play arround with it we get: $y = (I - \rho W)^{-1}(xb + e)$ Now what Prof. LeSage does is: $y - (I-\hat{\rho} \cdot W)^{-1} \cdot x\hat{b} = (I-\rho W)^{-1}\cdot e$ So what you are getting it the residual with the auto correlation. On the other hand, by transforming y: $y - \hat{\rho}\cdot W \cdot y = xb + e$ Estimating, $xb$ and calculation the residuals, what Bivand is doing is giving you $e$ instead of $(I-\rho W)^{-1}\cdot e$ Which one is preferred will depend on your application! Here is some code to prove it. I am not using SPDEP directly because i am not sure how to create random maps... But that is ok the code is pretty simple anyway: #------------------ GENERATE SAMPLE DATA rm(list=ls()) #clean require(igraph) #random graphs require(AER) #get ivreg ... n<-700 #700 locations p=0.2 g <- erdos.renyi.game(n=n, p.or.m=p, type="gnp", directed=F, loops=F) graph.density(g) w <- get.adjacency(g) #get an adjacency matrix w <- w/rowSums(w) #row standardize because of eigen vectors and eigen values sum(rowSums(w)==0) rho <- 0.5 intercept <- rep(1,n) rvariable <- rnorm(n) y <- solve(diag(n) - rho*w) %*% ( 2*intercept + 3*rvariable + rnorm(n)) After the data is generated according to a SAR LAG model we will estimated it via 2SLS (as i told you we could). #------------------ GENERATE INSTRUMENTS #get some instrumental variables z0 <- w%*%rvariable z1 <- w%*%w%*%rvariable #check to see if there is a minimum of correlation cor(z0, w%*%y) cor(z1, w%*%y) The instruments work because rvariable is exogenous. So as long as w is exogenous we have a game! #------------------ NOW ONTO ESTIMATION #The wrong way ... summary(out<-lm(y ~ rvariable)) confint(out) #The not so bad, but still very wrong way summary(out<-lm(y ~ w%*%y + rvariable)) confint(out) #ok now this should do it ... not perfect beacuse 2sls is not efficient. #I am doing it this way because i did not want to generate random maps... #Plus random graphs are easily available ! summary(out<-ivreg( y ~ w%*%y + rvariable, instruments=~ z0 + z1 + rvariable )) confint(out) Now to what really matters, the computation of residuals: #residuals LeSage way y_hat0 <- solve(diag(n) - coef(out)[2]*w ) %*% ( coef(out)[1]*intercept + coef(out)[3]*rvariable ) u_hat0 <- y - y_hat0 #residuals BiVand way y_tilda <- y - coef(out)[2]*w%*%y summary(out_biv <- lm( y_tilda ~ rvariable )) #ok they are not the same due to rounding error ... coef(out)[3] == coef(out_biv)[2]; round(coef(out)[3],5) == round(coef(out_biv)[2],5) u_hat1 <- residuals(out_biv) u_hat1 <- solve(diag(n) - coef(out)[2]*w)%*%u_hat1 #If we give Bivand some taste of autocorrelation it is the same as LeSage ... round( u_hat0 - u_hat1, 5) In the end you should see the residuals difference == 0 ! A cautionary note here is that depending on the structure of $W$ the effect might not be identifiable so the strategy of using the random graph generator might be bogus some times ! Anyway I hope this really solved your question
Spatial econometrics -- computing residuals The residuals that each of them calculating are different. Here is why: The model is as follows: $y = \rho Wy + xb + e$ with $e \sim n(0,1)$ Now if we play arround with it we get: $y = (I - \rho W)^{
41,272
Plot a generalised mixed effects model with binomial errors
The issue is that the mer class in R, and the lmer etc commands in lme4 all produce mer objects, and these are not compatible with some "normal" R commands. You can get the fits out by using fitted but amending your code to ndf$fit <- fitted(glmerb, ndf, type="response") gave me the error Error in `$<-.data.frame`(`*tmp*`, "fit", value = c(0.213527879025905, : replacement has 60 rows, data has 51 But this worked: > fit <- fitted(glmerb, ndf, type="response") > str(fit) num [1:60] 0.214 0.282 0.335 0.154 0.335 ... Is that what you were after?
Plot a generalised mixed effects model with binomial errors
The issue is that the mer class in R, and the lmer etc commands in lme4 all produce mer objects, and these are not compatible with some "normal" R commands. You can get the fits out by using fitted bu
Plot a generalised mixed effects model with binomial errors The issue is that the mer class in R, and the lmer etc commands in lme4 all produce mer objects, and these are not compatible with some "normal" R commands. You can get the fits out by using fitted but amending your code to ndf$fit <- fitted(glmerb, ndf, type="response") gave me the error Error in `$<-.data.frame`(`*tmp*`, "fit", value = c(0.213527879025905, : replacement has 60 rows, data has 51 But this worked: > fit <- fitted(glmerb, ndf, type="response") > str(fit) num [1:60] 0.214 0.282 0.335 0.154 0.335 ... Is that what you were after?
Plot a generalised mixed effects model with binomial errors The issue is that the mer class in R, and the lmer etc commands in lme4 all produce mer objects, and these are not compatible with some "normal" R commands. You can get the fits out by using fitted bu
41,273
Plot a generalised mixed effects model with binomial errors
Take a look at the ez package, particularly at ezPredict. ps. if you would like to use 'to_predict' parameter, you'll need the dev version, see the instructions here: https://github.com/mike-lawrence/ez
Plot a generalised mixed effects model with binomial errors
Take a look at the ez package, particularly at ezPredict. ps. if you would like to use 'to_predict' parameter, you'll need the dev version, see the instructions here: https://github.com/mike-lawrence
Plot a generalised mixed effects model with binomial errors Take a look at the ez package, particularly at ezPredict. ps. if you would like to use 'to_predict' parameter, you'll need the dev version, see the instructions here: https://github.com/mike-lawrence/ez
Plot a generalised mixed effects model with binomial errors Take a look at the ez package, particularly at ezPredict. ps. if you would like to use 'to_predict' parameter, you'll need the dev version, see the instructions here: https://github.com/mike-lawrence
41,274
Plot a generalised mixed effects model with binomial errors
To plot curves of fixed effects, I typically use code like this: model.coefs <- fixef(model) curve( invlogit( cbind(1, x) %*% model.coefs ), add=TRUE ) Note that invlogit is in the arm package.
Plot a generalised mixed effects model with binomial errors
To plot curves of fixed effects, I typically use code like this: model.coefs <- fixef(model) curve( invlogit( cbind(1, x) %*% model.coefs ), add=TRUE ) Note that invlogit is in the arm package.
Plot a generalised mixed effects model with binomial errors To plot curves of fixed effects, I typically use code like this: model.coefs <- fixef(model) curve( invlogit( cbind(1, x) %*% model.coefs ), add=TRUE ) Note that invlogit is in the arm package.
Plot a generalised mixed effects model with binomial errors To plot curves of fixed effects, I typically use code like this: model.coefs <- fixef(model) curve( invlogit( cbind(1, x) %*% model.coefs ), add=TRUE ) Note that invlogit is in the arm package.
41,275
Why is the variance of my random effect negative?
When you use ANOVA or MINQUE method of variance components estimation the estimate for the variance of a random factor may indeed occasionally be negative. There may be several causes, and it is not easy to detect the actual one. See Hocking R. R. (1985) The analysis of linear models. For example outliers and small sample size may be guilty. Try to delete a pair of extreme values and/or enlarge sample and see what you get. Addition. Some of possible reasons: Variation of obsevations may be too large for the sample size. Larger sample is needed. Outliers The true variance of the random factor is 0 Groups in the random or fixed factor is too unbalanced (unequal sized) Variance components is not a right model for covariance structure for the data
Why is the variance of my random effect negative?
When you use ANOVA or MINQUE method of variance components estimation the estimate for the variance of a random factor may indeed occasionally be negative. There may be several causes, and it is not e
Why is the variance of my random effect negative? When you use ANOVA or MINQUE method of variance components estimation the estimate for the variance of a random factor may indeed occasionally be negative. There may be several causes, and it is not easy to detect the actual one. See Hocking R. R. (1985) The analysis of linear models. For example outliers and small sample size may be guilty. Try to delete a pair of extreme values and/or enlarge sample and see what you get. Addition. Some of possible reasons: Variation of obsevations may be too large for the sample size. Larger sample is needed. Outliers The true variance of the random factor is 0 Groups in the random or fixed factor is too unbalanced (unequal sized) Variance components is not a right model for covariance structure for the data
Why is the variance of my random effect negative? When you use ANOVA or MINQUE method of variance components estimation the estimate for the variance of a random factor may indeed occasionally be negative. There may be several causes, and it is not e
41,276
Why is the variance of my random effect negative?
When you delete nobound from the code of SAS the variance of group=0. Also when you use the following code you can get the same results; PROC VARCOMP METHOD=REML; CLASSES group; MODEL response= group/FIXED=0; run; I think these results confirm that the variance of group =0 despite some methods gave negative value such as Mivque.
Why is the variance of my random effect negative?
When you delete nobound from the code of SAS the variance of group=0. Also when you use the following code you can get the same results; PROC VARCOMP METHOD=REML; CLASSES group; MODEL response= group
Why is the variance of my random effect negative? When you delete nobound from the code of SAS the variance of group=0. Also when you use the following code you can get the same results; PROC VARCOMP METHOD=REML; CLASSES group; MODEL response= group/FIXED=0; run; I think these results confirm that the variance of group =0 despite some methods gave negative value such as Mivque.
Why is the variance of my random effect negative? When you delete nobound from the code of SAS the variance of group=0. Also when you use the following code you can get the same results; PROC VARCOMP METHOD=REML; CLASSES group; MODEL response= group
41,277
Why is the variance of my random effect negative?
When you doubled your data and perform the analysis you will get also negative value but less. For each increasing in data size the negative variance decrease. The second factor is the differences among three means of groups was close. These two factors are responsible about the negative value.
Why is the variance of my random effect negative?
When you doubled your data and perform the analysis you will get also negative value but less. For each increasing in data size the negative variance decrease. The second factor is the differences amo
Why is the variance of my random effect negative? When you doubled your data and perform the analysis you will get also negative value but less. For each increasing in data size the negative variance decrease. The second factor is the differences among three means of groups was close. These two factors are responsible about the negative value.
Why is the variance of my random effect negative? When you doubled your data and perform the analysis you will get also negative value but less. For each increasing in data size the negative variance decrease. The second factor is the differences amo
41,278
Quasibinomial vs negative binomial and hurdles
While both "negative binomial" and "quasibinomial" have the word "binomial" in them, they are very different. The negative binomial is an actual parametric distribution, and it has an infinite range, so you should think of it as a generalization of the Poisson distribution, not the binomial distribution. If your data are counts of "successes" out of 30 (so there is an upper limit), then negative binomial is simply not appropriate whether it is augmented with a hurdle or not. On the other hand, the "quasibinomial" model does not correspond to any actual distribution, so it is difficult to compare it to distribution-based models. If you want to get insight into the process generating the data, you might consider other parametric generalizations of the binomial distribution, such as the beta-binomial model (of which you could probably make a hurdle version too).
Quasibinomial vs negative binomial and hurdles
While both "negative binomial" and "quasibinomial" have the word "binomial" in them, they are very different. The negative binomial is an actual parametric distribution, and it has an infinite range,
Quasibinomial vs negative binomial and hurdles While both "negative binomial" and "quasibinomial" have the word "binomial" in them, they are very different. The negative binomial is an actual parametric distribution, and it has an infinite range, so you should think of it as a generalization of the Poisson distribution, not the binomial distribution. If your data are counts of "successes" out of 30 (so there is an upper limit), then negative binomial is simply not appropriate whether it is augmented with a hurdle or not. On the other hand, the "quasibinomial" model does not correspond to any actual distribution, so it is difficult to compare it to distribution-based models. If you want to get insight into the process generating the data, you might consider other parametric generalizations of the binomial distribution, such as the beta-binomial model (of which you could probably make a hurdle version too).
Quasibinomial vs negative binomial and hurdles While both "negative binomial" and "quasibinomial" have the word "binomial" in them, they are very different. The negative binomial is an actual parametric distribution, and it has an infinite range,
41,279
Quantile regression in JAGS
I used a data augmentation procedure suggested here with the following model: model{ for(i in 1:length(y)){ mu[i] <- alpha + beta*x[i] w[i] ~ dexp(tau) me[i] <- (1-2*p)/(p*(1-p))*w[i] + mu[i] pe[i] <- (p*(1-p)*tau)/(2*w[i]) y[i] ~ dnorm(me[i],pe[i]) } #priors for regression alpha ~ dnorm(0,1E-6) beta ~ dnorm(0,1E-6) lsigma ~ dunif(-5,15) sigma <- exp(lsigma/2) tau <- pow(sigma,-2) } This works reasonably well.
Quantile regression in JAGS
I used a data augmentation procedure suggested here with the following model: model{ for(i in 1:length(y)){ mu[i] <- alpha + beta*x[i] w[i] ~ dexp(tau) me[i] <- (1-2*p)/(p*(1-p))*w[i] + mu[i
Quantile regression in JAGS I used a data augmentation procedure suggested here with the following model: model{ for(i in 1:length(y)){ mu[i] <- alpha + beta*x[i] w[i] ~ dexp(tau) me[i] <- (1-2*p)/(p*(1-p))*w[i] + mu[i] pe[i] <- (p*(1-p)*tau)/(2*w[i]) y[i] ~ dnorm(me[i],pe[i]) } #priors for regression alpha ~ dnorm(0,1E-6) beta ~ dnorm(0,1E-6) lsigma ~ dunif(-5,15) sigma <- exp(lsigma/2) tau <- pow(sigma,-2) } This works reasonably well.
Quantile regression in JAGS I used a data augmentation procedure suggested here with the following model: model{ for(i in 1:length(y)){ mu[i] <- alpha + beta*x[i] w[i] ~ dexp(tau) me[i] <- (1-2*p)/(p*(1-p))*w[i] + mu[i
41,280
Test to prove two means do not have a difference
Normally in a statistical hypothesis test, you are seeking to reject the null hypothesis in favour of the alternative hypothesis, so the precautionary principle suggests that the onus is on us to show that the null hypothesis is likely false, so we require $\alpha$, the false-positive rate (the probability of rejecting the null hypothesis when it is true) to be low. It is also possible to run the test the other way round, where the experimental hypothesis is the null hypothesis. In this case the onus is on us to show that $\beta$ the false-negative rate (the probability of accepting the null hypothesis when it is false) is low. This amounts to showing that the test has sufficient statistical power. Essentially if we are unable to reject the null hypothesis it is because the null hypothesis actually is true, or it can be because the null hypothesis is false, but we don't have enough data to be sure that it is false. We can be confident it is the former, rather than the latter, if the test has good statistical power. Caveat: I find frequentist statistical tests conceptually rather complicated, so I may well have written something that would make a purist wince, but hopefully the point about the need for statistical power of the t-test will be helpful.
Test to prove two means do not have a difference
Normally in a statistical hypothesis test, you are seeking to reject the null hypothesis in favour of the alternative hypothesis, so the precautionary principle suggests that the onus is on us to show
Test to prove two means do not have a difference Normally in a statistical hypothesis test, you are seeking to reject the null hypothesis in favour of the alternative hypothesis, so the precautionary principle suggests that the onus is on us to show that the null hypothesis is likely false, so we require $\alpha$, the false-positive rate (the probability of rejecting the null hypothesis when it is true) to be low. It is also possible to run the test the other way round, where the experimental hypothesis is the null hypothesis. In this case the onus is on us to show that $\beta$ the false-negative rate (the probability of accepting the null hypothesis when it is false) is low. This amounts to showing that the test has sufficient statistical power. Essentially if we are unable to reject the null hypothesis it is because the null hypothesis actually is true, or it can be because the null hypothesis is false, but we don't have enough data to be sure that it is false. We can be confident it is the former, rather than the latter, if the test has good statistical power. Caveat: I find frequentist statistical tests conceptually rather complicated, so I may well have written something that would make a purist wince, but hopefully the point about the need for statistical power of the t-test will be helpful.
Test to prove two means do not have a difference Normally in a statistical hypothesis test, you are seeking to reject the null hypothesis in favour of the alternative hypothesis, so the precautionary principle suggests that the onus is on us to show
41,281
Test to prove two means do not have a difference
You cannot prove that there is absolutely no change unless you have infinite data/information. However you can show that the amount of change is limited. The best approach is probably the Bland-Altman methods, see the links on this page for more detail. The traditional Bland-Altman method deals with 2 different measurements on the same subjects, but would work equally well for other paired data cases such as you describe.
Test to prove two means do not have a difference
You cannot prove that there is absolutely no change unless you have infinite data/information. However you can show that the amount of change is limited. The best approach is probably the Bland-Altm
Test to prove two means do not have a difference You cannot prove that there is absolutely no change unless you have infinite data/information. However you can show that the amount of change is limited. The best approach is probably the Bland-Altman methods, see the links on this page for more detail. The traditional Bland-Altman method deals with 2 different measurements on the same subjects, but would work equally well for other paired data cases such as you describe.
Test to prove two means do not have a difference You cannot prove that there is absolutely no change unless you have infinite data/information. However you can show that the amount of change is limited. The best approach is probably the Bland-Altm
41,282
Test to prove two means do not have a difference
When you said that you made a change, I assume that you meant that you made a change that may impact the outcome that you are measuring. In this case you should consider trying to measure a treatment effect, which can be recovered by difference-in-differences. You are correct that you cannot simply compare differences in means before and after the change since unobserved variables may influence your outcome variable over time. To control for these time effects, you would want to keep measuring one group (the control group) without the treatment and then measure a treatment group that receives the change. If the two groups are statistically similar then we can consider the control groups outcome after the treatment period to be a proxy for the counterfactual outcome. However, with all of this being said, you really cannot prove "no effect" but rather simply fail to reject that there is no effect.
Test to prove two means do not have a difference
When you said that you made a change, I assume that you meant that you made a change that may impact the outcome that you are measuring. In this case you should consider trying to measure a treatment
Test to prove two means do not have a difference When you said that you made a change, I assume that you meant that you made a change that may impact the outcome that you are measuring. In this case you should consider trying to measure a treatment effect, which can be recovered by difference-in-differences. You are correct that you cannot simply compare differences in means before and after the change since unobserved variables may influence your outcome variable over time. To control for these time effects, you would want to keep measuring one group (the control group) without the treatment and then measure a treatment group that receives the change. If the two groups are statistically similar then we can consider the control groups outcome after the treatment period to be a proxy for the counterfactual outcome. However, with all of this being said, you really cannot prove "no effect" but rather simply fail to reject that there is no effect.
Test to prove two means do not have a difference When you said that you made a change, I assume that you meant that you made a change that may impact the outcome that you are measuring. In this case you should consider trying to measure a treatment
41,283
Test to prove two means do not have a difference
To show that 2 groups are eqivalent you can run an equivalence test where you compare the confidence limits against a predefined equivalence boundary. This test is similar to a t-test but the hypothesis are reversed. Instead of the null hypothesis being no difference and the alternative hypothesis being that there is a significant difference in a t test, the null hypothesis in an equivalence analysis is that the samples are not equivalent and the alternative hypothesis is that the samples are equivalent. An equivalence test thus places the burden of proof on proving equivalence. Equivalence is proved if both the lower and upper confidence bound is inside an equivalence boundary, if one of the confidence bounds is outside the equivalence limits, then equivalence cannot be concluded. The equivalence test is available in a lot of statistical software like Minitab and SAS.
Test to prove two means do not have a difference
To show that 2 groups are eqivalent you can run an equivalence test where you compare the confidence limits against a predefined equivalence boundary. This test is similar to a t-test but the hypothes
Test to prove two means do not have a difference To show that 2 groups are eqivalent you can run an equivalence test where you compare the confidence limits against a predefined equivalence boundary. This test is similar to a t-test but the hypothesis are reversed. Instead of the null hypothesis being no difference and the alternative hypothesis being that there is a significant difference in a t test, the null hypothesis in an equivalence analysis is that the samples are not equivalent and the alternative hypothesis is that the samples are equivalent. An equivalence test thus places the burden of proof on proving equivalence. Equivalence is proved if both the lower and upper confidence bound is inside an equivalence boundary, if one of the confidence bounds is outside the equivalence limits, then equivalence cannot be concluded. The equivalence test is available in a lot of statistical software like Minitab and SAS.
Test to prove two means do not have a difference To show that 2 groups are eqivalent you can run an equivalence test where you compare the confidence limits against a predefined equivalence boundary. This test is similar to a t-test but the hypothes
41,284
Why efficiency matters?
By definition, an inefficient estimator will have larger risk for quadratic losses. Under some additional assumptions and simplifications, I suppose one might equate larger risk with inadmissibility, which would imply there is no need ever to use inefficient estimators, because there are uniformly superior estimators available. Better accounts of frequentist inference eschew such assumptions and focus on admissibility, leaving it to the user to choose an appropriate loss function and compare risk functions among the available admissible estimators. This unifies frequentist and Bayesian theory (there's nothing in the frequentist theory that precludes adopting a prior probability and in fact many admissible procedures have been discovered by doing precisely that) and allows for minimax estimation as well. As a practical matter, as you surely know, one can equate loss of efficiency with cost of data collection: to achieve a given power in a study where the variance of the estimator scales like $1/n$, a reduction in efficiency by a factor $t \lt 1$ typically requires collecting $1/t$ times as much data. For example, the statistician who can find an estimator that is twice as efficient as one proposed by a client has (caeteris paribus) just halved the cost of the client's data collection. There are subtleties involving asymptotic efficient estimators. For example, an AEE can be inefficient for all finite values of $n$. But I hope your question isn't bearing on this issue.
Why efficiency matters?
By definition, an inefficient estimator will have larger risk for quadratic losses. Under some additional assumptions and simplifications, I suppose one might equate larger risk with inadmissibility,
Why efficiency matters? By definition, an inefficient estimator will have larger risk for quadratic losses. Under some additional assumptions and simplifications, I suppose one might equate larger risk with inadmissibility, which would imply there is no need ever to use inefficient estimators, because there are uniformly superior estimators available. Better accounts of frequentist inference eschew such assumptions and focus on admissibility, leaving it to the user to choose an appropriate loss function and compare risk functions among the available admissible estimators. This unifies frequentist and Bayesian theory (there's nothing in the frequentist theory that precludes adopting a prior probability and in fact many admissible procedures have been discovered by doing precisely that) and allows for minimax estimation as well. As a practical matter, as you surely know, one can equate loss of efficiency with cost of data collection: to achieve a given power in a study where the variance of the estimator scales like $1/n$, a reduction in efficiency by a factor $t \lt 1$ typically requires collecting $1/t$ times as much data. For example, the statistician who can find an estimator that is twice as efficient as one proposed by a client has (caeteris paribus) just halved the cost of the client's data collection. There are subtleties involving asymptotic efficient estimators. For example, an AEE can be inefficient for all finite values of $n$. But I hope your question isn't bearing on this issue.
Why efficiency matters? By definition, an inefficient estimator will have larger risk for quadratic losses. Under some additional assumptions and simplifications, I suppose one might equate larger risk with inadmissibility,
41,285
Fitting data based on an unobserved variable
Here is a solution that is close to least squares, using a Gaussian mixture model. We use a family of probability distributions with PDFs that capture both centers of the conditional distribution of $y|x$: $$p(y,x; (a,b,\delta,\pi, \sigma)) =(1-\pi)\phi_\sigma(y-a x^b)+\pi\phi_\sigma(y - a x^b(1+\delta)).$$ In this notation $\phi_\sigma$ is the density function for a Normal$(0, \sigma)$ distribution. The weighted linear combination captures the idea of two vertically separated bands (as a mixture, with the chance of being in the upper band being $\pi$). There is Normal variation around the centers at $a x^b$ and $a x^b(1+\delta)$. This family depends on three parameters of interest, $a$ and $b$ (describing the functional form) and $\delta$ (expressing the separation between the two bands). It uses two ancillary parameters, $\pi$ (the proportions in each band, assumed constant across $x$) and $\sigma$ (the residual standard deviation). To illustrate, here are plots of $p(y, 1/6; (1/2, 1, 1, 1/3, 1/3))$ (blue, to the left) and $p(y, 1/2; (2, 1/2, 1, 1/3, 1/3))$ (red, to the right): Fitting these with maximum likelihood is the best analog of least squares available. As an example, consider these data generated by evaluating $a x_i^b(1 + \delta u_i)+\varepsilon_i$ for $a=2$, $b=1/2$, and $\delta=1$ at $x_i = 1/64, 2/64, \ldots, 1$ where $u_i$ were drawn independently from a Bernoulli$(1/3)$ distribution and, independently of those, $\varepsilon_i$ were independently drawn from a Normal$(0, \sigma)$ distribution, $\sigma = 1/3$: This is not a lot of data and the separation into two bands is not completely clear, so it forms a moderately severe test of the method. The MLE gives $$\hat{a} = 1.99, \hat{b} = 0.509, \hat{\delta} = 1.07, \hat{\pi} = 0.27, \hat{\sigma} = 0.33$$ compared to $$a = 2.00, b = 0.50, \delta = 1.00, \pi = 0.33, \sigma = 0.33.$$ Apart from $\pi$, which will be difficult to estimate with such few data and is of little consequence, these estimates are extremely close to the actual values used to generate the data, and this is no accident: repeated simulations continue to get good estimates. These fits agree nicely with the data:
Fitting data based on an unobserved variable
Here is a solution that is close to least squares, using a Gaussian mixture model. We use a family of probability distributions with PDFs that capture both centers of the conditional distribution of
Fitting data based on an unobserved variable Here is a solution that is close to least squares, using a Gaussian mixture model. We use a family of probability distributions with PDFs that capture both centers of the conditional distribution of $y|x$: $$p(y,x; (a,b,\delta,\pi, \sigma)) =(1-\pi)\phi_\sigma(y-a x^b)+\pi\phi_\sigma(y - a x^b(1+\delta)).$$ In this notation $\phi_\sigma$ is the density function for a Normal$(0, \sigma)$ distribution. The weighted linear combination captures the idea of two vertically separated bands (as a mixture, with the chance of being in the upper band being $\pi$). There is Normal variation around the centers at $a x^b$ and $a x^b(1+\delta)$. This family depends on three parameters of interest, $a$ and $b$ (describing the functional form) and $\delta$ (expressing the separation between the two bands). It uses two ancillary parameters, $\pi$ (the proportions in each band, assumed constant across $x$) and $\sigma$ (the residual standard deviation). To illustrate, here are plots of $p(y, 1/6; (1/2, 1, 1, 1/3, 1/3))$ (blue, to the left) and $p(y, 1/2; (2, 1/2, 1, 1/3, 1/3))$ (red, to the right): Fitting these with maximum likelihood is the best analog of least squares available. As an example, consider these data generated by evaluating $a x_i^b(1 + \delta u_i)+\varepsilon_i$ for $a=2$, $b=1/2$, and $\delta=1$ at $x_i = 1/64, 2/64, \ldots, 1$ where $u_i$ were drawn independently from a Bernoulli$(1/3)$ distribution and, independently of those, $\varepsilon_i$ were independently drawn from a Normal$(0, \sigma)$ distribution, $\sigma = 1/3$: This is not a lot of data and the separation into two bands is not completely clear, so it forms a moderately severe test of the method. The MLE gives $$\hat{a} = 1.99, \hat{b} = 0.509, \hat{\delta} = 1.07, \hat{\pi} = 0.27, \hat{\sigma} = 0.33$$ compared to $$a = 2.00, b = 0.50, \delta = 1.00, \pi = 0.33, \sigma = 0.33.$$ Apart from $\pi$, which will be difficult to estimate with such few data and is of little consequence, these estimates are extremely close to the actual values used to generate the data, and this is no accident: repeated simulations continue to get good estimates. These fits agree nicely with the data:
Fitting data based on an unobserved variable Here is a solution that is close to least squares, using a Gaussian mixture model. We use a family of probability distributions with PDFs that capture both centers of the conditional distribution of
41,286
Fitting data based on an unobserved variable
This looks like a 'mixture of regressions' problem, where z is an unobserved random indicator variable denoting which curves each x-y observation belongs to. You would then, as F. Tusell suggests, use an EM algorithm to maximise the likelihood of all the regression parameters. Here, EM would work by alternating the computation of the expected posterior probability of z for each x-y pair and then fitting the coefficients of the individual regressions on the assumption that these expectations were in fact the observed values of z. The regmixEM function from the R package mixtools will do this out of the box. There are other options if linear regression is not a good base model class. The remaining task is to specify the individual regressions right. For this, you might fit the whole thing in log space as F. Tusell suggests, or add quadratic terms, or do whatever else makes sense in the context of the problem. This task is not obviously harder (or easier) than if z were observed and explicitly conditioned on.
Fitting data based on an unobserved variable
This looks like a 'mixture of regressions' problem, where z is an unobserved random indicator variable denoting which curves each x-y observation belongs to. You would then, as F. Tusell suggests, us
Fitting data based on an unobserved variable This looks like a 'mixture of regressions' problem, where z is an unobserved random indicator variable denoting which curves each x-y observation belongs to. You would then, as F. Tusell suggests, use an EM algorithm to maximise the likelihood of all the regression parameters. Here, EM would work by alternating the computation of the expected posterior probability of z for each x-y pair and then fitting the coefficients of the individual regressions on the assumption that these expectations were in fact the observed values of z. The regmixEM function from the R package mixtools will do this out of the box. There are other options if linear regression is not a good base model class. The remaining task is to specify the individual regressions right. For this, you might fit the whole thing in log space as F. Tusell suggests, or add quadratic terms, or do whatever else makes sense in the context of the problem. This task is not obviously harder (or easier) than if z were observed and explicitly conditioned on.
Fitting data based on an unobserved variable This looks like a 'mixture of regressions' problem, where z is an unobserved random indicator variable denoting which curves each x-y observation belongs to. You would then, as F. Tusell suggests, us
41,287
Fitting data based on an unobserved variable
I'm not sure that you conceptually can fit a parametrized curve directly on unobserved data. Maybe a two-step approach would help. but I admit, I have never seen or done such a thing: First fit the curve only for 2 variables $x$ and $y$. If the bands of points you mentioned do not cross then the fitted curve should lie somewhere in between the two bands. Then use the residuals to "reconstruct" the third variable $z$ by setting it to 0 if the residual is negative, say, and setting it to 1 if the residual is positive. Then use the variable $z$ together with $x$ and $y$ in your proposed equation. In the case of a linear regression this R code could demonstrate this procedure: # x-values x1<-seq(0,10,by=0.1) # the two groups of values lying around two lines y1<-2+3*x1+rnorm(101,0,1) y2<-6+3*x1+rnorm(101,0,1) # plot all points x<-c(x1,x1) y<-c(y1,y2) plot(x,y) # one model for both groups of points lm.forboth<-lm(y~x) # plot the fitted values lines(x,lm.forboth$fitted.values) # find those points whose residuals are >0 and let z be zero for them # this is the reconstruction of z posresid<-lm.forboth$residuals>0 z<-as.numeric(posresid) # now use z to fit two lines lm.separate<-lm(y~x+z) # plot the fit of the two lines obtained by z=0,1 lines(x[posresid],lm.separate$fitted.values[posresid]) lines(x[!(posresid)],lm.separate$fitted.values[!(posresid)]) I hope this helps...
Fitting data based on an unobserved variable
I'm not sure that you conceptually can fit a parametrized curve directly on unobserved data. Maybe a two-step approach would help. but I admit, I have never seen or done such a thing: First fit the cu
Fitting data based on an unobserved variable I'm not sure that you conceptually can fit a parametrized curve directly on unobserved data. Maybe a two-step approach would help. but I admit, I have never seen or done such a thing: First fit the curve only for 2 variables $x$ and $y$. If the bands of points you mentioned do not cross then the fitted curve should lie somewhere in between the two bands. Then use the residuals to "reconstruct" the third variable $z$ by setting it to 0 if the residual is negative, say, and setting it to 1 if the residual is positive. Then use the variable $z$ together with $x$ and $y$ in your proposed equation. In the case of a linear regression this R code could demonstrate this procedure: # x-values x1<-seq(0,10,by=0.1) # the two groups of values lying around two lines y1<-2+3*x1+rnorm(101,0,1) y2<-6+3*x1+rnorm(101,0,1) # plot all points x<-c(x1,x1) y<-c(y1,y2) plot(x,y) # one model for both groups of points lm.forboth<-lm(y~x) # plot the fitted values lines(x,lm.forboth$fitted.values) # find those points whose residuals are >0 and let z be zero for them # this is the reconstruction of z posresid<-lm.forboth$residuals>0 z<-as.numeric(posresid) # now use z to fit two lines lm.separate<-lm(y~x+z) # plot the fit of the two lines obtained by z=0,1 lines(x[posresid],lm.separate$fitted.values[posresid]) lines(x[!(posresid)],lm.separate$fitted.values[!(posresid)]) I hope this helps...
Fitting data based on an unobserved variable I'm not sure that you conceptually can fit a parametrized curve directly on unobserved data. Maybe a two-step approach would help. but I admit, I have never seen or done such a thing: First fit the cu
41,288
Fitting data based on an unobserved variable
If you take logs, you would have $$\log(y) = \log(a) + b\log(x) + \log(1+cz) + \epsilon.$$ Consider $\log(1+cz) + \epsilon$ as a random perturbation: call it $\eta$. If you regress $\log(y)$ on a column of "ones" and $\log(x)$, you get estimates of $\log(a)$, $b$ and the residuals $\hat\eta = \log(y) - \widehat\log(a) -\hat{b}x$. If $\epsilon$ could be thought to have, for instance, a normal distribution, $\hat\eta$ would be roughly distributed as a mixture of normals with means $\log(1+c)$ apart. Then, you could use the EM algorithm as in here to obtain an estimate of the two means and their difference, along with the probabilities that $z$ takes value 0 or 1 conditional on the observed value of each residual. Not given much thought, not tested: might be complete nonsense, please excuse me if it is.
Fitting data based on an unobserved variable
If you take logs, you would have $$\log(y) = \log(a) + b\log(x) + \log(1+cz) + \epsilon.$$ Consider $\log(1+cz) + \epsilon$ as a random perturbation: call it $\eta$. If you regress $\log(y)$ on a colu
Fitting data based on an unobserved variable If you take logs, you would have $$\log(y) = \log(a) + b\log(x) + \log(1+cz) + \epsilon.$$ Consider $\log(1+cz) + \epsilon$ as a random perturbation: call it $\eta$. If you regress $\log(y)$ on a column of "ones" and $\log(x)$, you get estimates of $\log(a)$, $b$ and the residuals $\hat\eta = \log(y) - \widehat\log(a) -\hat{b}x$. If $\epsilon$ could be thought to have, for instance, a normal distribution, $\hat\eta$ would be roughly distributed as a mixture of normals with means $\log(1+c)$ apart. Then, you could use the EM algorithm as in here to obtain an estimate of the two means and their difference, along with the probabilities that $z$ takes value 0 or 1 conditional on the observed value of each residual. Not given much thought, not tested: might be complete nonsense, please excuse me if it is.
Fitting data based on an unobserved variable If you take logs, you would have $$\log(y) = \log(a) + b\log(x) + \log(1+cz) + \epsilon.$$ Consider $\log(1+cz) + \epsilon$ as a random perturbation: call it $\eta$. If you regress $\log(y)$ on a colu
41,289
Density of a quadratic transformation of a normal random variable
The moments of such transformation can probably be found in Sec. 2.2.3 of Kollo and von Rosen (2005). Transformations of this kind have been used in some multivariate simulations. I understand there's a book on polynomials of multivariate distributions, but I have not seen it, and don't know if you'd be able to find the closed form expressions for the density of this transformation there. In a univariate case, you get a (scaled and shifted) non-central $\chi^2$ distribution, and the density expression for it is somewhat unwieldy (Bessel and hypergeometric functions, or infinite series of Poisson-weighted gamma distributions).
Density of a quadratic transformation of a normal random variable
The moments of such transformation can probably be found in Sec. 2.2.3 of Kollo and von Rosen (2005). Transformations of this kind have been used in some multivariate simulations. I understand there's
Density of a quadratic transformation of a normal random variable The moments of such transformation can probably be found in Sec. 2.2.3 of Kollo and von Rosen (2005). Transformations of this kind have been used in some multivariate simulations. I understand there's a book on polynomials of multivariate distributions, but I have not seen it, and don't know if you'd be able to find the closed form expressions for the density of this transformation there. In a univariate case, you get a (scaled and shifted) non-central $\chi^2$ distribution, and the density expression for it is somewhat unwieldy (Bessel and hypergeometric functions, or infinite series of Poisson-weighted gamma distributions).
Density of a quadratic transformation of a normal random variable The moments of such transformation can probably be found in Sec. 2.2.3 of Kollo and von Rosen (2005). Transformations of this kind have been used in some multivariate simulations. I understand there's
41,290
Density of a quadratic transformation of a normal random variable
A related question was answered here. For that question the focus was on a particular quadratic form (the squared Euclidean norm), but this must also be one of the first things to consider. A recommended reference is the book "Quadratic forms in random variables" by Mathai and Provost (1992, Marcel Dekker, Inc.), but I can't remember exactly how general it gets, I don't have the book, and there is no Google preview. The results for the norm with general $\mu$ and $\Sigma$ clearly suggest that there is no simple closed form expression for the density.
Density of a quadratic transformation of a normal random variable
A related question was answered here. For that question the focus was on a particular quadratic form (the squared Euclidean norm), but this must also be one of the first things to consider. A recomme
Density of a quadratic transformation of a normal random variable A related question was answered here. For that question the focus was on a particular quadratic form (the squared Euclidean norm), but this must also be one of the first things to consider. A recommended reference is the book "Quadratic forms in random variables" by Mathai and Provost (1992, Marcel Dekker, Inc.), but I can't remember exactly how general it gets, I don't have the book, and there is no Google preview. The results for the norm with general $\mu$ and $\Sigma$ clearly suggest that there is no simple closed form expression for the density.
Density of a quadratic transformation of a normal random variable A related question was answered here. For that question the focus was on a particular quadratic form (the squared Euclidean norm), but this must also be one of the first things to consider. A recomme
41,291
Does PCA have any advantages or usages in the frequency domain?
The advantage of using PCA in the frequency domain is to choose a set of weights by exploiting the cross-correlations between the signals at particular cycles. For example, (depending on the field of application) the behaviour of the variables under study can be different in the short, medium and long run. Using PCA in the frequency domain will allow to choose weights depending on the frequency. The difference between PCA in the time domain and frequency domain can be understood in terms of how the eigenvalues are computed. In time domain, the correlation matrix is used. In the frequency domain, the fourier transform of the correlation matrix or the spectral density matrix is used to compute the eigenvalues. For technical applications of using PCA in frequency domain, there is a description in book by Jolliffe,I.T(2002), Principal Component Analysis, 2nd Edition. Here is a link to the relevant page. Regarding your second question, I have understood PCA by itself to be a method of finding combinations of variables which extract the maximum information in the data by maximizing the variance of the principal components. Therefore, it does not seem to be dealing with any cyclic or frequency information in the data.
Does PCA have any advantages or usages in the frequency domain?
The advantage of using PCA in the frequency domain is to choose a set of weights by exploiting the cross-correlations between the signals at particular cycles. For example, (depending on the field of
Does PCA have any advantages or usages in the frequency domain? The advantage of using PCA in the frequency domain is to choose a set of weights by exploiting the cross-correlations between the signals at particular cycles. For example, (depending on the field of application) the behaviour of the variables under study can be different in the short, medium and long run. Using PCA in the frequency domain will allow to choose weights depending on the frequency. The difference between PCA in the time domain and frequency domain can be understood in terms of how the eigenvalues are computed. In time domain, the correlation matrix is used. In the frequency domain, the fourier transform of the correlation matrix or the spectral density matrix is used to compute the eigenvalues. For technical applications of using PCA in frequency domain, there is a description in book by Jolliffe,I.T(2002), Principal Component Analysis, 2nd Edition. Here is a link to the relevant page. Regarding your second question, I have understood PCA by itself to be a method of finding combinations of variables which extract the maximum information in the data by maximizing the variance of the principal components. Therefore, it does not seem to be dealing with any cyclic or frequency information in the data.
Does PCA have any advantages or usages in the frequency domain? The advantage of using PCA in the frequency domain is to choose a set of weights by exploiting the cross-correlations between the signals at particular cycles. For example, (depending on the field of
41,292
Does PCA have any advantages or usages in the frequency domain?
There was a paper at the recent ICML by Li and Prakash. It is about a complex linear dynamical system, which turns out to be a model of which Fourier transform and PCA are special cases. Have a look at Time Series Cluster: complex is simpler.
Does PCA have any advantages or usages in the frequency domain?
There was a paper at the recent ICML by Li and Prakash. It is about a complex linear dynamical system, which turns out to be a model of which Fourier transform and PCA are special cases. Have a look a
Does PCA have any advantages or usages in the frequency domain? There was a paper at the recent ICML by Li and Prakash. It is about a complex linear dynamical system, which turns out to be a model of which Fourier transform and PCA are special cases. Have a look at Time Series Cluster: complex is simpler.
Does PCA have any advantages or usages in the frequency domain? There was a paper at the recent ICML by Li and Prakash. It is about a complex linear dynamical system, which turns out to be a model of which Fourier transform and PCA are special cases. Have a look a
41,293
Does PCA have any advantages or usages in the frequency domain?
If you accept spectroscopy as frequency-domain: PCA is used a lot there. E.g. a pubmed search on principal component analysis and spectroscopy yields more than 2500 results. On the other hand, spectroscopists rarely look at the time domain (Fourier-transform spectroscopy does use a spatial domain as "intermediate" but for data analysis the frequency/wavelength/wavenumber domain is generally used and interpreted). If you do a PCA in the frequency domain, the first PCs will tell you which frequencies contribute most to the variance in the data set and moreover which frequencies vary together (with pos. or neg. correlation): they end up in the same PC or independent of each other (end up in different PCs). Whether this coincides with most contributing frequencies depends on whether/where your data is centered (by its nature or by centering). I'd say whether PCA should be done in time or frequency domain depends on the interpretation of these domains. If you want to find things that happen at the same time or times where the same things happen, then the time domain should be appropriate. IF you want to find things that happen with the same frequency or frequencies where the same things happen, then use frequency domain.
Does PCA have any advantages or usages in the frequency domain?
If you accept spectroscopy as frequency-domain: PCA is used a lot there. E.g. a pubmed search on principal component analysis and spectroscopy yields more than 2500 results. On the other hand, spectro
Does PCA have any advantages or usages in the frequency domain? If you accept spectroscopy as frequency-domain: PCA is used a lot there. E.g. a pubmed search on principal component analysis and spectroscopy yields more than 2500 results. On the other hand, spectroscopists rarely look at the time domain (Fourier-transform spectroscopy does use a spatial domain as "intermediate" but for data analysis the frequency/wavelength/wavenumber domain is generally used and interpreted). If you do a PCA in the frequency domain, the first PCs will tell you which frequencies contribute most to the variance in the data set and moreover which frequencies vary together (with pos. or neg. correlation): they end up in the same PC or independent of each other (end up in different PCs). Whether this coincides with most contributing frequencies depends on whether/where your data is centered (by its nature or by centering). I'd say whether PCA should be done in time or frequency domain depends on the interpretation of these domains. If you want to find things that happen at the same time or times where the same things happen, then the time domain should be appropriate. IF you want to find things that happen with the same frequency or frequencies where the same things happen, then use frequency domain.
Does PCA have any advantages or usages in the frequency domain? If you accept spectroscopy as frequency-domain: PCA is used a lot there. E.g. a pubmed search on principal component analysis and spectroscopy yields more than 2500 results. On the other hand, spectro
41,294
Does PCA have any advantages or usages in the frequency domain?
Principal component analysis (PCA) is a mathematical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of uncorrelated variables called principal components. This transformation is defined in such a way that the first principal component has as high a variance as possible (that is, accounts for as much of the variability in the data as possible), and each succeeding component in turn has the highest variance possible under the constraint that it be orthogonal to (uncorrelated with) the preceding components. Principal components are guaranteed to be independent only if the data set is jointly normally distributed. I am not much knowledge about frequency analysis or signal processing. But PCA has application in this field. Check literature.
Does PCA have any advantages or usages in the frequency domain?
Principal component analysis (PCA) is a mathematical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of uncorrel
Does PCA have any advantages or usages in the frequency domain? Principal component analysis (PCA) is a mathematical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of uncorrelated variables called principal components. This transformation is defined in such a way that the first principal component has as high a variance as possible (that is, accounts for as much of the variability in the data as possible), and each succeeding component in turn has the highest variance possible under the constraint that it be orthogonal to (uncorrelated with) the preceding components. Principal components are guaranteed to be independent only if the data set is jointly normally distributed. I am not much knowledge about frequency analysis or signal processing. But PCA has application in this field. Check literature.
Does PCA have any advantages or usages in the frequency domain? Principal component analysis (PCA) is a mathematical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of uncorrel
41,295
Does PCA have any advantages or usages in the frequency domain?
PCA, like wave transformations, is an orthogonal transformation. It tries to rotate data to maximize certain metric (i.e. the variance). Interestingly, if the data is sufficiently random (isotropic), no rotation will help to enlarge variance. In this case, PCA will basically turn to a wave transformation.
Does PCA have any advantages or usages in the frequency domain?
PCA, like wave transformations, is an orthogonal transformation. It tries to rotate data to maximize certain metric (i.e. the variance). Interestingly, if the data is sufficiently random (isotropic),
Does PCA have any advantages or usages in the frequency domain? PCA, like wave transformations, is an orthogonal transformation. It tries to rotate data to maximize certain metric (i.e. the variance). Interestingly, if the data is sufficiently random (isotropic), no rotation will help to enlarge variance. In this case, PCA will basically turn to a wave transformation.
Does PCA have any advantages or usages in the frequency domain? PCA, like wave transformations, is an orthogonal transformation. It tries to rotate data to maximize certain metric (i.e. the variance). Interestingly, if the data is sufficiently random (isotropic),
41,296
When the population has a known fixed size, are tables for the t statistic wrong?
When you have a finite population and the sample size is more than 5-10% of the population then you should use the Finite Population Correction, that is you multiply your standard error times $\sqrt{\frac{N-n}{N-1}}$, see this link. You should still use the t-distribution, but the standard error will be smaller to account for the large portion of the population in the sample.
When the population has a known fixed size, are tables for the t statistic wrong?
When you have a finite population and the sample size is more than 5-10% of the population then you should use the Finite Population Correction, that is you multiply your standard error times $\sqrt{\
When the population has a known fixed size, are tables for the t statistic wrong? When you have a finite population and the sample size is more than 5-10% of the population then you should use the Finite Population Correction, that is you multiply your standard error times $\sqrt{\frac{N-n}{N-1}}$, see this link. You should still use the t-distribution, but the standard error will be smaller to account for the large portion of the population in the sample.
When the population has a known fixed size, are tables for the t statistic wrong? When you have a finite population and the sample size is more than 5-10% of the population then you should use the Finite Population Correction, that is you multiply your standard error times $\sqrt{\
41,297
When the population has a known fixed size, are tables for the t statistic wrong?
The difference between Z-statistics and t-statistics is that Z statistic is asymptoticaly normal, when t-statistic has exact Student's distribution (with appropriate degrees of freedom) if we assume that the errors are normal. In small sample sizes the difference can be quite substantial (actually this is why Student "invented" t-statistic, he had very small sample sizes to work with). If the sample sizes are larger the critical values for Z statistic and t-statistic are closer, since Student's distribution tends to normal when degrees of freedom goes to infinity. But z-statistic is still only an approximation, so it is still beneficial to use the exact distribution. Of course if normality assumption does not hold, then Z statistic should be used, since then Student's distribution is exactly not the distribution of the statistic.
When the population has a known fixed size, are tables for the t statistic wrong?
The difference between Z-statistics and t-statistics is that Z statistic is asymptoticaly normal, when t-statistic has exact Student's distribution (with appropriate degrees of freedom) if we assume t
When the population has a known fixed size, are tables for the t statistic wrong? The difference between Z-statistics and t-statistics is that Z statistic is asymptoticaly normal, when t-statistic has exact Student's distribution (with appropriate degrees of freedom) if we assume that the errors are normal. In small sample sizes the difference can be quite substantial (actually this is why Student "invented" t-statistic, he had very small sample sizes to work with). If the sample sizes are larger the critical values for Z statistic and t-statistic are closer, since Student's distribution tends to normal when degrees of freedom goes to infinity. But z-statistic is still only an approximation, so it is still beneficial to use the exact distribution. Of course if normality assumption does not hold, then Z statistic should be used, since then Student's distribution is exactly not the distribution of the statistic.
When the population has a known fixed size, are tables for the t statistic wrong? The difference between Z-statistics and t-statistics is that Z statistic is asymptoticaly normal, when t-statistic has exact Student's distribution (with appropriate degrees of freedom) if we assume t
41,298
Infinite p-value when checking normality of distribution
You have a very large data set (looks like over a million cases). With N this large, even the tiniest variation from normality will be highly significant. The key here is the QQ plot. It shows, as Nick pointed out, that your data are truncated. Why is this the case? (added) I tried this: library(nortest) x <- rnorm(1000000) ad.test(x) and the p value was 0.03! But the qqnorm was very close to a straight line. I will trust my eyes over the test.
Infinite p-value when checking normality of distribution
You have a very large data set (looks like over a million cases). With N this large, even the tiniest variation from normality will be highly significant. The key here is the QQ plot. It shows, as Ni
Infinite p-value when checking normality of distribution You have a very large data set (looks like over a million cases). With N this large, even the tiniest variation from normality will be highly significant. The key here is the QQ plot. It shows, as Nick pointed out, that your data are truncated. Why is this the case? (added) I tried this: library(nortest) x <- rnorm(1000000) ad.test(x) and the p value was 0.03! But the qqnorm was very close to a straight line. I will trust my eyes over the test.
Infinite p-value when checking normality of distribution You have a very large data set (looks like over a million cases). With N this large, even the tiniest variation from normality will be highly significant. The key here is the QQ plot. It shows, as Ni
41,299
Do you include a covariate because of baseline group difference or if correlated with DV or both?
You might want to read the following article Pocock, S.J. and Assmann, S.E. and Enos, L.E. and Kasten, L.E. (2002). Subgroup analysis, covariate adjustment and baseline comparisons in clinical trial reporting: current practice and problems. FREE PDF Check out the discussion of answers to this question on best practice in analysing pre-post intervention designs A few thoughts, although I confess I'm not an expert on this: If you had perfect randomisation, then the significance test without covariates would be fair, although there might be power benefits in including covariates. The more strongly the covariate is related to the DV, in general, the more it will reduce your error variance (which can increase statistical power assuming an true effect exists). This in combination with base-line group differences on the covariates will lead to greater differences between covariate adjusted and non-adjusted estimates of the intervention effect. It sounds like you have some mild departures from randomisation, in that randomisation happened at a group-level, and there may have been some differences in the uptake of the experiment. I'd be particularly interested to know whether there are reasons to expect the groups to differ in their means on the DV at baseline. The degree to which departures from randomisation in the protocol are a problem is related to the degree to which it leads to systematically different groups. In most applications that I've seen, pre-test measurements are likely to capture most of the potential effects of any baseline covariates. I think the big issue is that if there are substantial baseline differences on the dependent variable, then it can be difficult to assess the effect of the intervention.
Do you include a covariate because of baseline group difference or if correlated with DV or both?
You might want to read the following article Pocock, S.J. and Assmann, S.E. and Enos, L.E. and Kasten, L.E. (2002). Subgroup analysis, covariate adjustment and baseline comparisons in clinical trial
Do you include a covariate because of baseline group difference or if correlated with DV or both? You might want to read the following article Pocock, S.J. and Assmann, S.E. and Enos, L.E. and Kasten, L.E. (2002). Subgroup analysis, covariate adjustment and baseline comparisons in clinical trial reporting: current practice and problems. FREE PDF Check out the discussion of answers to this question on best practice in analysing pre-post intervention designs A few thoughts, although I confess I'm not an expert on this: If you had perfect randomisation, then the significance test without covariates would be fair, although there might be power benefits in including covariates. The more strongly the covariate is related to the DV, in general, the more it will reduce your error variance (which can increase statistical power assuming an true effect exists). This in combination with base-line group differences on the covariates will lead to greater differences between covariate adjusted and non-adjusted estimates of the intervention effect. It sounds like you have some mild departures from randomisation, in that randomisation happened at a group-level, and there may have been some differences in the uptake of the experiment. I'd be particularly interested to know whether there are reasons to expect the groups to differ in their means on the DV at baseline. The degree to which departures from randomisation in the protocol are a problem is related to the degree to which it leads to systematically different groups. In most applications that I've seen, pre-test measurements are likely to capture most of the potential effects of any baseline covariates. I think the big issue is that if there are substantial baseline differences on the dependent variable, then it can be difficult to assess the effect of the intervention.
Do you include a covariate because of baseline group difference or if correlated with DV or both? You might want to read the following article Pocock, S.J. and Assmann, S.E. and Enos, L.E. and Kasten, L.E. (2002). Subgroup analysis, covariate adjustment and baseline comparisons in clinical trial
41,300
Do you include a covariate because of baseline group difference or if correlated with DV or both?
If your goal is to show group differences on an outcome (Y), there's no benefit to including a covariate unless it's relevant to (correlated with) Y. But you have to carefully think things through. There are times when controlling for a covariate serves to "equalize," making for a fairer comparison (in addition to increasing the precision of an analysis). There are other times when, regardless of any purely statistical results, attempting to equalize creates a bizarre scenario (and this relates to @Jeromy's last point). Suppose we simplify by saying that controlling for a covariate entails adjusting each group so that it is treated as if it were average with respect to the covariate. But what if Group A could never be average on that variable without losing something that is essential to "Group A-ness"? This is a tricky area of statistics and a controversial one. Recipe-oriented textbooks--those that focus on procedures at the expense of concepts--tend to gloss over it. I'll bet the Pocock et al. article is a good one; I'd search around for others, or look into books by reflective authors like James Davis, Geoffrey Keppel or Elazar Pedhazur. There's also good info on this topic at this thread
Do you include a covariate because of baseline group difference or if correlated with DV or both?
If your goal is to show group differences on an outcome (Y), there's no benefit to including a covariate unless it's relevant to (correlated with) Y. But you have to carefully think things through.
Do you include a covariate because of baseline group difference or if correlated with DV or both? If your goal is to show group differences on an outcome (Y), there's no benefit to including a covariate unless it's relevant to (correlated with) Y. But you have to carefully think things through. There are times when controlling for a covariate serves to "equalize," making for a fairer comparison (in addition to increasing the precision of an analysis). There are other times when, regardless of any purely statistical results, attempting to equalize creates a bizarre scenario (and this relates to @Jeromy's last point). Suppose we simplify by saying that controlling for a covariate entails adjusting each group so that it is treated as if it were average with respect to the covariate. But what if Group A could never be average on that variable without losing something that is essential to "Group A-ness"? This is a tricky area of statistics and a controversial one. Recipe-oriented textbooks--those that focus on procedures at the expense of concepts--tend to gloss over it. I'll bet the Pocock et al. article is a good one; I'd search around for others, or look into books by reflective authors like James Davis, Geoffrey Keppel or Elazar Pedhazur. There's also good info on this topic at this thread
Do you include a covariate because of baseline group difference or if correlated with DV or both? If your goal is to show group differences on an outcome (Y), there's no benefit to including a covariate unless it's relevant to (correlated with) Y. But you have to carefully think things through.