question
stringlengths 37
38.8k
| group_id
int64 0
74.5k
|
---|---|
<p>I am trying to estimate parameters of a two dimensional Normal distribution using Gibbs sampling. While it was very easy transform the posterior equation for mean vector to a single dimension normal function for sampling, I am not able to same for sigma(covariance).</p>
<p>Do I need to use the Wishart distribution as prior and then convert the posterior into a single dimensional gamma function ? </p>
| 47,934 |
<p>This question might be too naive, but I need to understand this point. Suppose I ran a survey for a product for 1000 individuals & collected the data for various aspects of it. Let's say the categories are X1, X2, X3, X4, X5 and X6.</p>
<p>So, now I have 6 variables. I want to know the type of the distribution of the sample. </p>
<p>My question is how to know the distribution of this sample. </p>
| 37,452 |
<p>I found that learning how MCMC and HMM work went best by writing the code of simple examples myself. I would now like to learn how <strong>random forests</strong> work, but it's again not that trivial to transform the theoretical texts and pseudocode to real scripts (well... for me at least).</p>
<p>Could anybody point me to simple examples of random forests? I know of the R package and so on (and I have used it already) but instead of an interface I really would prefer to have some code of a specific example that I can imitate to learn how random forests are constructed.</p>
| 73,842 |
<p>I have a time series $X_t$ (shown below) with a structure break. The stationary test <code>kpss.test()</code> says it has a unit root. How to explain this? Why does $X_t$ have a unit root? Sure it is not constant in mean, so it is non-stationary. But I can not relate its non-stationarity to the concept of unit-root. </p>
<pre><code>x=c(rnorm(1000,0,1),rnorm(1000,10,1))
kpss.test(x)
</code></pre>
<p>The $p$-value of the test is 0.01, so we reject the null hypothesis of a stationary process. </p>
<p>For example, a random walk has a unit root but it is constant in mean. So any relationship between unit root and constant-in-mean? Any comments about this?</p>
<p><img src="http://i.stack.imgur.com/llF9c.png" alt="enter image description here"></p>
| 73,843 |
<p>I am looking for resources (tutorials, textbooks, webcast, etc) to learn about Markov Chain and HMMs. My background is as a biologist, and I'm currently involved in a bioinformatics-related project. </p>
<p>Also, what are the necessary mathematical background I need to have a sufficient understanding of Markov models & HMMs?</p>
<p>I've been looking around using Google but so far I have yet to find a good introductory tutorial -- but I'm sure somebody here knows better :).</p>
| 37,965 |
<p>I have a pretty large data set (~300 cases with ~40 continuous attributes, binary labeled) which I used to create several alternative predictive models. To do this, the set was divided to training and validation subsets (~60:40% respectively). </p>
<p>I have noticed that there are several samples (both in the training and the validation subsets) that are being misclassified by all or most of the alternative models that I test. </p>
<p>I suspect that there is something special about these "trouble making" samples. What are the general guidelines for discovering the possible reasons behind the misbehavior of the models on specific samples?</p>
<p><strong>Update 1</strong> I'm using logistic regression for this task. The parameter selection is done by exhaustively searching combinations of up to 4 predictors with 10-fold cross valiation. It is worth mentioning that the P values that is calculated by the model for the misclassified samples are usually very different from the default classification threshold of 0.5. In other words, not only is the model wrong about those cases, it is also very confident about itself </p>
<p><strong>Update 2 -- what I have already done</strong></p>
<p>I agree that insights from the study domain are crucial, but to date we have failed to discover anything significant. Also, I tried to remove the "bad" samples from the training set, and keeping the validation set and the parameter selection algorithm untouched. This led to better performance on the training set (naturally), but also improved significantly the performance on the validation set. Is this an indication that the "bad" samples were actually "bad"?</p>
| 36,360 |
<p>Suppose you had $200 US to build a (very) small library of statistics books. What would your choices be? You may assume free shipping from Amazon, and any freely available texts from the internet are fair game, but assume a 5 cent charge per page to print.</p>
<p>(I was inspired by a mailing from Dover books, but most of their offerings seem a bit out of date)</p>
| 73,844 |
<p>I know that this is probably a question that's been asked plenty of times, but i haven't seen an answer that's both accurate and simple. How do you estimate the appropriate forecast model for a time series by visual inspection of the ACF and PACF plots? Which one, ACF or PACF, tells the AR or the MA (or do they both?) Which part of the graphs tell you the seasonal and non seasonal part for a seasonal ARIMA?</p>
<p>Take for instance these functions:</p>
<p><img src="https://i.imgur.com/E64Sd7p.png" alt="enter image description here"></p>
<p>They show the ACF and PCF of a log transformed series that's been differenced twice, one simple difference and one seasonal.</p>
<p>How would you caracterize it? What model best fits it?</p>
<p>Thanks in advance!</p>
<p><strong>EDIT:</strong> Added raw data</p>
<p>Original data: <a href="http://pastebin.com/KRJnXzXp" rel="nofollow">here</a></p>
<p>Log transformed data: <a href="http://pastebin.com/JR3bkctv" rel="nofollow">here</a></p>
<p><strong>EDIT:</strong> Corrected ACF and PACF functions (previous ones were overdifferentiated)</p>
| 73,845 |
<p>Consider two simple linear models. </p>
<p>$y_{1j}=\alpha _1+\beta_{1}x_{1j}+\epsilon_{1j}$ and<br>
$y_{2j}=\alpha _2+\beta_{2}x_{2j}+\epsilon_{2j}$ , $ j=1,2,...,n>2$ where $ \epsilon_{ij}$~$N(0,\sigma^2)$<br>
I have two questions.</p>
<p>1 ) Show that the point on the x-axis where the two lines intersect is given by $x_0$=${\alpha_1-\alpha_2}\over \beta_2-\beta_1$<br>
2)Obtain the maximum likelihood estimators of $\sigma^2$ and $x_0$ </p>
<p>For question 1) what I did was,<br>
Supposing at $x_0,y_0$ the two lines intersect I substituted $x_0,y_0$ to the two equations.But then what happens to the error terms.Can I suppose that the errors in estimating $x_0,y_0$ from both equations are the same? </p>
<p>For 2) </p>
<p>$y_{ij}$ has a Normal distribution.<br>
I calculated $E(y_{1,j})$ and $E(y_{2,j})$ separately.Can I say that $E(X_{1j})$ =$E(X_{2j})$<br>
and $E(y_{1,j})$ = $E(y_{2,j})$.<br>
Thereby I obtained $E(y_{ij})$=${\beta_2\alpha_1-\beta_1\alpha_2}\over\beta_2-\beta_1$ </p>
<p>Similarly $V(y_{ij})=\sigma^2$ </p>
<p>Then joint probability density function for $y_{ij}$ is $\prod_{i=1}^2\prod_{j=1}^n $$1\over\sqrt {2\pi\sigma^2}$$
e^{{-(y_{ij}-\mu})^2} / 2\sigma^2$ where $\mu=$${\beta_2\alpha_1-\beta_1\alpha_2}\over\beta_2-\beta_1$ .Is this a correct joint p.d.f for y? </p>
<p>Does $x_0$ also has a normal distribution.Is <strong>$V(x_0)=0$</strong>.I don't understand how to obtain <strong>MLE for $x_0$</strong> . </p>
<p>Can someone please help me to do this please</p>
| 36,366 |
<p>I am asking for your help because I'm not sure whether the procedure I'm using is correct. </p>
<p>I have two models, M1 and M2, and for each of them I have ten instances (ensemble members). For each model I calculate the output mean of all the members inside the ensemble. Then I compute the correlation between this ensemble mean and the observations (28 time samples).
I'd like to know if the difference between the two correlations, i.e. the two models, is "significant", i.e. it's due to the difference between the two models' parameters and structure. </p>
<p>I am using a bootstrap procedure. For each iteration:</p>
<ol>
<li>I create two new ensembles resampling with replacement from the 10+10 initial instances</li>
<li>I calculate the new ensemble means and the correlations with the observations</li>
<li>I calculate the difference between the two correlations</li>
</ol>
<p>At the end, I have a vector of correlation differences that I use to get the 5-95% percentiles. Then I check whether the original difference (the real one) is inside or outside the percentiles' range. </p>
<p>That's the whole story. </p>
<p>Thank you for any comment about it. </p>
| 73,846 |
<p>The data is measured in two biological replicates with two technical replicates, each. </p>
<ul>
<li>Each variable might be detected only in one or more replicates, in the others it is considered missing at random. </li>
<li>Each variable is measured with zero (missing) to dozens of data points in each experiment.</li>
<li>Each measurement comes with its own estimated variance</li>
</ul>
<p>The question for each variable (which was detected at least once): Does its mean deviate from 0? We can assume that the data is normally distributed.</p>
<p>What would be an appropriate test to apply to this data with randomness on many levels?</p>
| 73,847 |
<p>This is a pretty simple question but I haven't been able to find a clear answer to it. I have some data from a behavioral experiment taken under two conditions (A and B); within each condition, each trial could have one of two outcomes (correct or error). Moreover I repeated the experiment on many subjects.</p>
<p>If I consider only correct trials, I know that for some subjects the response is significantly higher during A than it is during B, and for other subjects the effect is reversed. This effect is quite strong for individual subjects and I'm convinced it's real; it's just that the direction can go either way.</p>
<p>I'm interested in making a statement like: the response on correct trials is significantly different across conditions A and B, but this effect is diminished (or absent, or reversed) for error trials. This could be either a statement about each individual subject, or the population.</p>
<p>The problem is this: once I specify whether A or B is greater for each subject based on the correct trials, I am pretty sure that the effect will tend to be less on the error trials simply because of regression to the mean. That is, even if correct trials and error trials are actually identical, if I select the direction of the effect based on the correct trials, it will tend to be less on the error trials.</p>
<p>First I am interested to hear if you think this is a real thing to worry about. Secondly I am interested in what I should do about it.</p>
<p>This feels like a "planned contrast" problem to me although I've never done this. I think it would be something like abs(A_hit - B_hit) > abs(A_error - B_error). One problem is that I usually like to use Mann-Whitney U-test for my data because it isn't very normal, but if the only tools for this problem rely on normality assumption I'm willing to let it slide.</p>
| 73,848 |
<p>In a two sided test, assume the test statistic has been chosen to be $T(X)$ and the distribution of $T(X)$ under null hypothesis is also known to be $F$. Let the significance level be $\alpha$.</p>
<p>I can come up with two different ways to determine the rejection region:</p>
<ol>
<li><p>$\{|T(x) - \mu| > c\}$. $\mu$ is the mean of the distribution $F$ of $T(X)$under null, and $c$ is determined by solving $$\inf_{c \geq 0} c$$ subject to $$P_{T(X) \sim F} (|T(X) - \mu| > c) \leq \alpha.$$ So the rejection region is symmetric around $\mu$.</p></li>
<li><p>$\{T(x) > c_1\} \cup \{T(x) < c_2\}$. $c_1$ and $c_2$ are determined by solving $$\inf_{c_1 \in \mathbb R} c_1$$ subject to $$P_{T(X) \sim F} (T(X) > c_1) \leq \alpha/2$$ and $$\sup_{c_2 \in \mathbb R} c_2$$ subject to $$P_{T(X) \sim F} (T(X) < c_2) \leq \alpha/2.$$ So the rejection region evenly split $\alpha$ to both sides.</p></li>
</ol>
<p><strong>Questions:</strong></p>
<ol>
<li><p>Am I correct that those two methods will agree when the null distribution $F$of $T(X)$ is symmetric around its mean $\mu$, and may not agree when $F$ isn't symmetric around $\mu$?</p></li>
<li><p>I was wondering what advantage and disadvantages these two methods have? Which one is recommended and when?</p></li>
<li><p>Are both methods used in some textbooks? If yes, references?</p></li>
<li><p>What are some other methods for two-sided tests? For example, can we generalized the second method by splitting $\alpha$ arbitrarily unevenly to the two sides?</p></li>
<li><p>Consider the relation between rejection region in testing and confidence interval. Are the above discussions also apply to confidence intervals?</p></li>
</ol>
<p>Thanks and regards!</p>
| 36,372 |
<p>I am composing a regression tree to determine corporate dividends with dividends as the determinant and 13 predictor variables. To check the accuracy of the tree I am using RMSE values computed using a random sample set. The problem is my RMSE values are <strong>huge</strong> since the range of dividends (the determinant) is so large. </p>
<p>I was wondering if I should scale the determinant or maybe all of the input data? If I scale the data I get a smaller RMSE but the tree is difficult to read since it has scaled values. Thanks.</p>
| 47,948 |
<p>I have to compute the LCL95% and UCL95% using Land's "exact" method. I computed the LCL and UCL for this lognormal distribution using another technique and I cant find anything for Land's Exact procedure.</p>
<p><code>My data set x = {0.043, 0.236, 0.057, 0.016}</code></p>
<p>here is what i tried</p>
<p>y = mean of ln{x}</p>
<p>s^2 = standard deviation of ln{x}</p>
<p><code>o = exp(y + s^2/2 +- (z*(sqrt(s^2/n + s^4/2(n-1)))</code></p>
<p>and i got UCL:2.98 and LCL: 0.139
but the answer using lands exact is UCL95%:11.6 and LCL95%: 0.039</p>
<p>Here is what i have calculated already: </p>
<p><code>Mean: 0.088</code></p>
<p><code>Standard deviation: 0.1</code></p>
<p><code>Geometric mean: 0.0552</code></p>
<p><code>Geometric standard deviation: 3.04</code></p>
<p><code>Estimated arithmetic mean using MVUE: 0.085</code></p>
<p><code>95th percentile: 0.343</code></p>
<p><code>Upper limit of tolerance: 16.8</code></p>
<p><code>mean of ln{x} = -2.898</code></p>
<p><code>standard deviation of ln{x} = 1.112</code></p>
<p>Can anyone please help me sketch out an algorithm for the formula when using Land's exact method?</p>
| 73,849 |
<p>What is the relationship between (first) principal component(s) and the correlation matrix or the average correlation of the data. For example, in an empirical application I observe that the average correlation is almost the same as the ratio of the variance of the first principal component (first eigenvalue) to the total variance (sum of all eigenvalues).</p>
<p>Is there a mathematical relationship?</p>
<p>Below is the chart of the empirical results. Where correlation is the average correlation between DAX stock index component returns computed over 15-day rolling window and the explained variance is the share of the variance explained by the first principal component, also computed over the 15-day rolling window.</p>
<p>Could this be explained by a common risk factor model such as CAPM?</p>
<p><img src="http://i.stack.imgur.com/pkCzD.png" alt="enter image description here"></p>
| 73,850 |
<p>I am doing a research validating a new questionnaire, which has 156 items divided up in 12 scales. I have run a factor analysis at scale level, which gives me two nice constructs (consistent with theory).</p>
<p>My tutor however is insisting this is no good as according to her I need to run an exploratory factor analysis at item level. I have done this and found 43 factors (only a couple of values in this huge table have an absolute square value greater than 0.4, which is the value suggested by Field (2005) as being meaningful.</p>
<p>Is it possible that when running such an analysis with a questionnaire with 100+ items, a factor analysis is really not that appropriate? </p>
<p>I have also been reading the PAI manual – PAI Structure chapter of the PAI questionnaire development (pp. 275-289), as this is a questionnaire that has been developed with lots of funds for research and it is now widely used. No factor analysis has been done on the items, but just at scale level. Several subsequent factor analysis carried out by other authors have also just included scales (not items). </p>
<p>I hope to hear some other thoughts on this, ideally with references to study/theories.</p>
| 73,851 |
<p>I'm wondering how to interpret the coefficient standard errors of a regression when using the display function in R.</p>
<p>For example in the following output:</p>
<pre><code>lm(formula = y ~ x1 + x2, data = sub.pyth)
coef.est coef.se
(Intercept) 1.32 0.39
x1 0.51 0.05
x2 0.81 0.02
n = 40, k = 3
residual sd = 0.90, R-Squared = 0.97
</code></pre>
<p>Does a higher standard error imply greater significance? </p>
<p>Also for the residual standard deviation, a higher value means greater spread, but the R squared shows a very close fit, isn't this a contradiction?</p>
| 73,852 |
<p>I have data on two processes, where the process assigns elements into ordered bins. I am interested in testing for agreement between the processes. What is the best way to do this (R code)? Here is the dummy data with counts for the 2 processes and 4 categories). I am not familiar with weighted kappa (which I have seen argued by some as the test to use) - so if that is correct, can anyone explain the way to use this method? </p>
<p><img src="http://i.stack.imgur.com/UBtEU.jpg" alt="enter image description here"></p>
<p>EDIT:
Adding to this question, I have the following R code. Is this proper and is this value suggestive of agreement?</p>
<pre><code>table<-matrix(c(35,2,10,7,6,15,8,6,4,5,12,8,1,0,0,5),4,4, byrow=TRUE)
Kappa(table,weights="Fleiss-Cohen")
</code></pre>
<p>With result:</p>
<pre><code> value ASE
Unweighted 0.3630137 0.06201821
Weighted 0.3854999 0.09886236
</code></pre>
| 73,853 |
<p>I have four letters: A B C D, I need to calculate all the combinations on the follow type:</p>
<pre><code>A - B
A - C
A - D
A - BC
A - BD
A - CD
A - BCD
AB - C
AB - CD
AB - D
ABC - D
</code></pre>
<p>As you can see no letters are repeated LEFT - RIGHT, IF the letter is on the left it is not repeated on the right again.
I need a method to generate all those possible combinations. </p>
<p><strong>AND</strong> </p>
<p>the order of the combinations is not important, If I use ABC I don't need other combinations with CBA or BAC, as you cann see I wrote:</p>
<pre><code>A - BC
</code></pre>
<p>and <strong>NOT</strong> </p>
<pre><code>A - CB
</code></pre>
<p>indeed.</p>
<p>I Need all the combinations that 4 letters could generate without repeating the same letter on left and on the right.</p>
<p>Could someone help me?</p>
| 38,150 |
<p>I have used 20 variables to extract 4 factors in a factor analysis. Now I want to use the extracted factors (factor scores) as IVs on an outcome variable. Besides I want to include 4 other variables as IVs in the regression which were not used in the factor analysis. That means I want to regress 4 factors and 4 variables (from outside of the FA) as IVs on a DV. Is there any problem in it statistically? </p>
<p>Secondly, if I want to run a separate regression on another DV by using only 2 of the factors (factor scores) and 3 other variables as IVs, is there any problem?</p>
<p>Just to know, if I extracted 4 components from a PCA (Principal Component Analysis) instead, what would be the answers to the same two questions? </p>
<p>Grateful for any help. </p>
| 47,955 |
<p>I suspect that a series of observed sequences are a Markov chain...</p>
<p>$$X=\left(\begin{array}{c c c c c c c}
A& C& D&D & B & A &C\\
B& A& A&C & A&D &A\\
\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\
B& C& A&D & A & B & E\\
\end{array}\right)$$</p>
<p>However how could I check that they indeed respect the memoryless property of $$P(X_i=x_i|X_j=x_j)?$$</p>
<p>Or at the very least prove that they are Markov in nature? Note these are empirically observed sequences. Any thoughts?</p>
<p><strong>EDIT</strong></p>
<p>Just to add, the aim is to compare a predicted set of sequence from the observed ones. So we'd appreciate comments on as to how best to compare these.</p>
<p><strong>First Order Transition matrix $$M_{ij}=\displaystyle \frac{x_ij}{\sum^mx_{ik}}$$</strong> where m=A..E states</p>
<p>$$
M=\left(\begin{array}{c c c c c c c}
0.1834& 0.3077 & 0.0769& 0.1479 & 0.2840\\
0.4697& 0.1136 & 0.0076 & 0.2500 & 0.1591\\
0.1827& 0.2404& 0.2212 & 0.1923 & 0.1635\\
0.2378 & 0.1818& 0.0629& 0.3357 & 0.1818\\
0.2458 & 0.1788& 0.1173 & 0.1788 & 0.2793\end{array}\right)$$</p>
<p><strong>Eigenvalues of M</strong>
$$E =\left(\begin{array}{c c c c c c c}
0.4472& -0.5852 & -0.4219 & -0.2343 - 0.0421i & -0.2343 + 0.0421i\\
0.4472 & 0.7838 & -0.4211 & -0.4479 - 0.2723i & -0.4479 + 0.2723i\\
0.4472 & -0.2006 & 0.3725 & 0.6323 & 0.6323 \\
0.4472 & -0.0010 & 0.7089 & 0.2123 - 0.0908i & 0.2123 + 0.0908i\\
0.4472 & 0.0540 & 0.0589 & 0.2546 + 0.3881i & 0.2546 - 0.3881i\\
\end{array}\right)$$</p>
<p><strong>Eigenvectors of M</strong></p>
<p>$$V =\left(\begin{array}{c c c c c c c}
1.0000 & 0 & 0 & 0 & 0 \\
0 & -0.2283 & 0 & 0 & 0 \\
0 & 0 & 0.1344 & 0 & 0\\
0 & 0 & 0 & 0.1136 - 0.0430i & 0 \\
0 & 0 & 0 & 0 & 0.1136 + 0.0430i\\
\end{array}\right)$$</p>
| 73,854 |
<p>If i want to be Data Scientist in future,
can somebody advise me <strong>sites/books/courses</strong> and other good things to learn?</p>
<p>Thanks!</p>
<p>P.S: i know statistical analysis and R/Matlab/Excel/SAS on different levels, but want to rise my skills in it.</p>
| 73,855 |
<p>Given a couple of measurements I get by running an experiment, I need to express the fact that they are similar to some extent. So, I computed their coefficient of variation, i.e., stdev/mean.</p>
<p>Here is a sample:</p>
<pre><code>3.76025 2.98375 3.78946 3.72195 3.11426 3.60366
</code></pre>
<p>and CV = 10.12%</p>
<p>Now I am confused, I don't know how to interpret that number, obviously the lower the better, but what is low? <em>E.g.</em>, is 20% and below considered low? </p>
<p>Here is some more of my results:
<a href="http://pastebin.com/raw.php?i=sg5S05rM" rel="nofollow">http://pastebin.com/raw.php?i=sg5S05rM</a><br>
I have thousands of such lines, and all I want to say is that numbers within each line are always more or less similar.</p>
<p>Should I use another measure?</p>
| 36,378 |
<p>This is a long-winded question but I'll try to paint the picture. I'm using structural equation modeling using Amos software to study relationships between brain and behaviour. I have three condition types - 1, 2, 3 (for simplicity). Within each condition, I have 2 variables that are bidirectionally connected. the variables (brain regions) are the same across conditions but the correlation between the 2 variables are different for each condition. In a stacked model, I'm comparing pairwise the connections between 1 and 2. In a separate model, I compare 1 and 3. Since the betas are semi-partial correlation coefficients, I should obtain similar values for comparison 1 (1 and 2) and 2 (1 and 3) for condition 1 but these are different. I fix the error variances or residuals for each variable in a particular condition. I'm not obtaining similar betas, I'm wondering what may be the cause of this?</p>
| 31,163 |
<p>I have a data set of 11,000+ distinct items, each of which was classified on a nominal scale by at least 3 different raters on Amazon's <a href="http://mturk.com" rel="nofollow">Mechanical Turk</a>. </p>
<p>88 different raters provided judgments for the task, and no one rater completed more about 800 judgments. Most provided significantly fewer than that.</p>
<p>My question is this:</p>
<p>I would like to calculate some measure of inter-rater reliability for the ratings, something better than a simply looking at consensus. I believe, however, that Fleiss Kappa, which is the measure I know best, would require a consistent group of raters for the entire set of items, and so I cannot use Fleiss Kappa to check IRR with my data. Is this correct? Is there another method I could use?</p>
<p>Any advice would be much appreciated!</p>
| 37,611 |
<p>I am using the <a href="http://cran.r-project.org/web/packages/np/index.html" rel="nofollow">np</a> package in R with the <code>npregiv</code> command. The program is in beta, and I cannot call ordered(var) on one of my instruments (a bug in the program I am pretty sure, the help file says this is allowed). The variable in question is the number of a particular type of institutions in a district, and all districts are on the [0,13] interval. If I do not call <code>ordered()</code>, what are the consequences? In a parametric setting it is a question of whether the increments of the ordinal variable are linear or not - I am not sure how to interpret this in the non parametric regression setting.</p>
<p>Otherwise I could call <code>factor()</code> and convert the variable to an indicator of whether or not there exists an institution in a particular district, but then I am throwing away information.</p>
| 73,856 |
<p>Goal: I want to visually depict the difference between experimental treatments while controlling for a continuous covariate in Poisson regression.</p>
<p>In my experiment, I am seeking to explain the number of species of insect on plants (richness) with a 3-level treatment factor and the size of the plant as a continuous covariate. My model is:</p>
<pre><code>glm(rich ~ tmnt + size, family=poisson)
</code></pre>
<p>Furthermore, I have contrast coded my treatment factor to compare treatments 1&2 to treatment 3, using the following code:</p>
<pre><code>1.2vs3 <- cbind(1vs2.3=c(1,1,2), 2vs3=c(-1,1,0))
contrasts(tmnt) <- 1vs2.3
</code></pre>
<p>(However, I don't think my contrast coding scheme will make a difference for my question here.) </p>
<p>I'm looking to make a bar plot of the species richness across treatments <em>while controlling for the covariate</em>. In multiple regression with Gaussian errors and <em>two</em> continuous variables, one would create a partial plot, by graphing the following residuals:</p>
<pre><code>richRes <- residuals(lm(rich ~ size))
contRes <- residuals(lm(cont ~ size))
plot(contRes, richRes)
</code></pre>
<p>And the following two models would produce parameter estimates for the treatment effect that are identical:</p>
<pre><code>lm(rich ~ cont + size)
lm(richRes ~ contRes )
</code></pre>
<p>However, I don't know how to extract values for plotting the effect of a factor when controlling for a covariate, and I also think that the Poisson errors make things more complicated. I thought that I could simply take the residuals of the full model lacking the tmnt and plot them against tmnt like this:</p>
<pre><code>richRes <- residuals(glm(rich ~ size, family=poisson)
plot(tmnt, richRes)
</code></pre>
<p>which works, but the models:</p>
<pre><code>glm(rich ~ tmnt + size, family=poisson)
lm(richRes ~ tmnt, family=poisson)
</code></pre>
<p>give different parameter estimates, so something is not quite right. </p>
<p>Can anybody please provide me with a procedure that will allow me to plot richness against treatment in way that accurately reflects the difference between and variance within (error bars) treatments from the full Poisson regression, i.e., accounting for size?</p>
<p>Here are some made up data with which to play, if you so choose. These variables will fit into my code (contrasts excepted):</p>
<pre><code>set.seed(8082)
rich <- rpois(50, 10)
tmnt <- as.factor(c(rep(1, 25), rep(2, 25)))
set.seed(8083)
size <- rnorm(50, 10, 3)
set.seed(8084)
cont <- rnorm(50, 10, 3)
</code></pre>
| 36,380 |
<p>If $x$ and $y$ are two series, is there any relation between $\sum{(x,y)}$ that can be expressed in terms of mean of these two. Specifically, I want to know if any sort of relation exists between $\sum(x,y)$ and $\sum{(\bar{x}, \bar{y})}$.</p>
| 73,857 |
<p>I have four nested models.Every of them learned from different data sets. now I want to compare these models together.normally people try to compute the F-satistics. But for my case, it's bit harder, because each of these modeles comes from diffrent data.
Does someone have idea how can I compare modeles together in this case ? </p>
| 73,858 |
<p>Let $X,A,B,C,D$ be time-series variables and the covariance between any two pairs of these are known.</p>
<p>Suppose we want to find $\textrm{cov}(X,aA + bB + cC + dD)$, where $a,b,c,d$ are constants.</p>
<p>Is there any way of doing this without expanding out $E[(X-E[X])(aA+......)]$? </p>
| 36,383 |
<p>Is there any way to estimate the bias of the estimate of the betas in a linear regression model when the actual beta values are unknown?</p>
<p>The well known Mean Square Error (MSE) criterion is used to quantify the performance of different biased estimators but to calculate the bias you need to know what the correct value of the Betas should be.</p>
<p>$MSE= var^2 +bias^2$</p>
<p>What can you do when you don't know what the correct value is? </p>
<p>I wonder if you can use the OLS value as a proxy (as it is unbiased)? However the very situations in which biased estimators are likely to be used are those in which OLS is likely to struggle, just wondered if there were any other methods to estimate the bias?</p>
| 36,385 |
<p>A jar has 50 balls 1 to 50 each one having distinct number written on it. Bob, owner of the jar,each day he takes out one ball out of the jar randomly ( with equal probability) and put it back.</p>
<p>Q1. How many days on average will it take until all 50 balls are taken out? (Note that the same ball can be picked on more than one days)</p>
<p>Q2. Assume that 3 months after Bob started this activity, how many distinct balls will have been taken out by Bob?</p>
| 19,031 |
<p>I have a feature x, that I use to predict a probability y.</p>
<hr>
<p><strong>Some background on (x,y)</strong></p>
<p>I can't go into too much details, but hopefully the following should be enough to explain what x and y are, at least conceptually <em>[square and circles are NOT the actual label I am working with]</em>:</p>
<p><strong>y</strong></p>
<p>y is the probability of an image being of Class 0 or 1, with: </p>
<ul>
<li>Class 0 means that the image contains a <em>square</em>.</li>
<li>Class 1 means that the image contains a <em>circle</em>.</li>
</ul>
<p>100 people watched the training images, and classified them.
y is the result probability, so y=0 means there is definitely a square, y=1 means there is definitely a round.</p>
<p><strong>x</strong></p>
<p>x is a feature derived from the images, by <em>trying to fit them to a model of a circle</em>, and calculating the error.
So for example when x is very low, the probability of the image having a circle is high (relatively).</p>
<hr>
<p>plot(x,y)</p>
<p><img src="http://i.stack.imgur.com/05230.png" alt="enter image description here"></p>
<p>x,y (1000 values for each) pasted here:
<a href="http://tny.cz/c320180d" rel="nofollow">http://tny.cz/c320180d</a></p>
<p>Using mean(y) as a predictor, I get <strong>RMSE = 0.285204</strong>:</p>
<pre><code>N = length(x)
average = mean(y)
RMSE = sqrt( 1/N * sum( (average-y)^2 ) )
RMSE
[1] 0.285204
</code></pre>
<p>Then using a linear regression on log(x), I could improve a little bit the <strong>RMSE = 0.2694513</strong>:</p>
<pre><code>log_x = log(x)
plot(log_x,y)
lm.result = lm(formula = y ~ log_x)
abline(lm.result, col="blue") # not working very well
linear_prediction = predict( lm.result, new, se.fit = TRUE)
prediction_linear_regression = matrix(0,N,1)
prediction_linear_regression = linear_prediction$fit
RMSE_linear_regression = sqrt( 1/N * sum( (prediction_linear_regression-y)^2 ) )
RMSE_linear_regression
[1] 0.2694513
</code></pre>
<p><img src="http://i.stack.imgur.com/59Etc.png" alt="enter image description here"></p>
<p>Can the RMSE be further improved? What should I try?</p>
| 73,859 |
<p>I am an epidemiologist trying to understand GEEs in order to properly analyze a cohort study (using Poisson regression with a log link, to estimate Relative Risk). I have a few questions about the "working correlation" that I would like someone more knowledgable to clarify:</p>
<p>(1) If I have repeated measurements in the same individual, is it usually most reasonable to assume an exchangeable structure? (Or an autoregressive if measurements show a trend)? What about independence - are there any cases where one could assume independence for measurements in the same individual?</p>
<p>(2) Is there any (reasonably simple) way to assess the proper structure by examining the data?</p>
<p>(3) I noticed that, when choosing an independence structure, I get the same point estimates (but lower standard errors) as when running a simple Poisson regression (using R, function <code>glm()</code> and <code>geeglm()</code> from package <code>geepack</code>). Why is this happening? I understand that with GEEs you estimate a population-averaged model (in contrast to subject-specific) so you should get the same point estimates only in the linear regression case.</p>
<p>(4) If my cohort is at multiple location sites (but one measurement per individual), should I choose an independence or an exchangeable working correlation, and why? I mean, individuals in each site are still independent from each other, right?? Thus for a subject-specific model, for example, I would specify the site as a random effect. With GEE however, independence and exchangeable give different estimates and I am not sure which one is better in terms of underlying assumptions.</p>
<p>(5) Can GEE handle a 2-level hierarchical clustering, i.e. a multi-site cohort with repeated measures per individual? If yes, what should I specify as a clustering variable in <code>geeglm()</code> and what should be the working correlation if one assumes for example "independence" for the first level (site) and "exchangeable" or "autoregressive" for the second level (individual)?</p>
<p>I understand these are quite a few questions, and some of them may be fairly basic, but still very difficult for me (and maybe other novices?) to grasp. So, any help is greatly and sincerely appreciated, and to show this I have started a bounty.</p>
| 73,860 |
<p>I am trying to fit to a long series of data about tide to a sinusoid function. I would like to have on the y axis the height of the tide (from $-$2 m to 5 m) and on the x axis the time in hours 24h.I do not know how to do it. I want to fit a sine wave, and my period is actually every six hours, when the tide changes from high to low tide.
I have 4 measures per day as follow:</p>
<pre><code>High 18h31 2.8
Low 12h37 1.1
High 06h02 3.0
Low 00h07 1.0
</code></pre>
<p>My code for the moment looks like that just tried with 1 day data: </p>
<pre><code>y <- c(3.2,0.9,3.0,0.9)
t <- seq(3,21,6)
#sequence from 3 to 21 with a step every 6 hours
</code></pre>
<p>And now I simply want to fit a sine wave $y(t) = A \sin(\omega t + \phi)+C$
with the four unknowns $A, \omega, \phi$ and $C$ to it.</p>
<pre><code>#trying to set omega to 6
res <- nls(y ~ A*sin(omega*t+phi)+C, data=data.frame(t,y), start=list(A=1,omega=6,phi=1,C=1))
co <- coef(res)
fit <- function(x, a, b, c, d) {a*sin(b*x+c)+d}
# Plot result
plot(x=t, y=y)
curve(fit(x, a=co["A"], b=co["omega"], c=co["phi"], d=co["C"]), add=TRUE ,lwd=2, col="steelblue")
</code></pre>
| 73,861 |
<p>I had trouble coming up with a title, so hopefully I can explain it better here.</p>
<p>I'm working on a classification problem and I'm doing some pre-analysis of variables. I'm looking for some nice ways to visualise the distribution of the target variable within each independent variable.</p>
<p>As an example for categorical variables I can look at a plot like this, The one on the left gives an idea of the distribution of the different categories, whereas the one on the right shows that B has a much higher proportion of the target variable.</p>
<p><img src="http://i.stack.imgur.com/7t9IB.png" alt="Categorical Variables"></p>
<p>If I want to do the same for a numeric variable I have to bin the variable and get something like below. Here's an example of some numerical data, the same data with different bin sizes.</p>
<p><img src="http://i.stack.imgur.com/8wgyr.png" alt="enter image description here"></p>
<p>This is not as good... it isn't as clear since the binning is pretty arbitrary and each column isn't exactly a different category. Different bin sizes seem to tell different stories.</p>
<p>Are there any good ways to visualise numeric variables to get a similar overview without having to bin?</p>
| 73,862 |
<p>My experiment is a completely randomized block design. The objective is to find whether a variable is different between species $a$, $b$, $c$. The measurement was taken 2 times (June, July) in each year (2011, 2012). I was wondering whether repeated measures ANOVA is a correct method to use? If it is, would you please help me to write up the syntax for the ANOVA and post-hoc analysis? </p>
<p>My data are like the following: </p>
<pre><code>dat <- read.table(text = "species block year time variable
a 1 2011 June 1
a 2 2011 June 2
a 3 2011 June 3
b 1 2011 June 4
b 2 2011 June 5
b 3 2011 June 6
c 1 2011 June 7
c 2 2011 June 8
c 3 2011 June 9
a 1 2011 July 10
a 2 2011 July 11
a 3 2011 July 12
b 1 2011 July 13
b 2 2011 July 14
b 3 2011 July 15
c 1 2011 July 16
c 2 2011 July 17
c 3 2011 July 18
a 1 2012 June 19
a 2 2012 June 20
a 3 2012 June 21
b 1 2012 June 22
b 2 2012 June 23
b 3 2012 June 24
c 1 2012 June 25
c 2 2012 June 26
c 3 2012 June 27
a 1 2012 July 28
a 2 2012 July 29
a 3 2012 July 30
b 1 2012 July 31
b 2 2012 July 32
b 3 2012 July 33
c 1 2012 July 34
c 2 2012 July 35
c 3 2012 July 36", header=TRUE)
</code></pre>
| 47,966 |
<p>I have a small pilot dataset containing experimental measurements for 12 samples, 4 numeric predictors and 1 numeric outcome variable. The goal is to obtain a first rough estimate on the extent to which the outcome variable can be predicted using one or more of the 4 predictors, before deciding on whether it's worthwile to collect more data. With the lm-function in R, I obtain a linear fit with p < 0.05, if I include only the best predictor in the model. However, given that this is only pilot data with a very small sample size, and that all 2^4-1 = 15 feature subsets were tried, is it sufficient to adjust the p-value for the best predictor for multiple hypothesis testing (e.g. using Benjamini-Hochberg adjustments) to gain confidence in this model?</p>
<p>Would it make sense to apply any other modelling techniques to obtain more confidence that the data has significant predictive information content (non-linear approaches will most likely lead to over-fitting on such a small dataset, but maybe other linear models, e.g. ridge regression, linear SVM, could still be informative) - or is this not worhtwile due to the worsening of the multiple testing problem?
Many thanks for your suggestions.</p>
| 73,863 |
<p>I have some questions regarding the usage of CATPCA in SPSS. I hope the answers to these questions will be helpful for others too who are planning to work on it.</p>
<p>1) In my <a href="http://www.4shared.com/file/U0kF2JRK/4factoranalysis.htm" rel="nofollow">data</a> (on this data I want to run a CATPCA), there are some variables that are in proportions. But CATPCA treats the values with less than 1 as missing. So, I was planning to recode the scale variables that are in proportions into 10 categories (i.e. 0.00-0.10, 0.10-0.20, ..., 0.90-1.00). If I do this, then which optimal scaling level should I choose? Ordinal? </p>
<p>2) Other than the variables that are in proportions, the variables are categorical (both yes-no type and ordinal) with maximum 4 categories. So, if I split the proportion-type variables into 10 categories, will that be any problem? Or, do you think I should split them into 5 categories (i.e. 0.00-0.20, 0.20-0.40, ..., 0.80-1.00)? </p>
<p>3) My yes-no type variables are coded as 0-1. To avoid treating 0 as missing, I am planning to recode them as 1-2. Now, for my study, 'yes' means good and 'no' means bad/not good. So, which optimal scaling level should I choose for them? Ordinal or Nominal? </p>
<p>4) What to do if the same quantification comes for different categories of an ordinal variable? Should we merge the categories or use different optimal scaling level?</p>
<p>5) I had actually 4 factors associated with the questionnaire. So, I guess I should use 4 dimensions in solution. But how can I visualize the grouping of the variables (loadings plot) with this 4 dimensions? I actually need to know which dimension belongs to which factor. How do I check this?</p>
<p>6) When do we use 'multiple nominal' as the optimal scaling level? Any example? </p>
| 73,864 |
<p>Does this probability distribution have a name?</p>
<p>$$f_a(x) dx = \frac{a}{e^a-(a+1)} \left(e^{a x} - 1\right) dx, \quad 0 \le x \le 1.$$</p>
<p>Edit:
I want $a$ to be positive. I don't think this is what is usually called a truncated exponential distribution.</p>
<p>Edit 2:
Here's an
<a href="http://www.wolframalpha.com/input/?i=2%2a%28exp%282%2ax%29+-+1%29+%2F+%28exp%282%29+-+2+-+1%29%2C+x+in+%280%2C+1%29" rel="nofollow">example</a>
where $a=2$.</p>
<p>Edit 3:
This seems to be an unnamed distribution.</p>
| 73,865 |
<p>I have a multi-class short text classification task with a minor wrinkle: I'd like to also detect when the texts don't fit any of the classes well. I've tried to do it by simply adding unrelated texts into a separate class and learning an SVM, but with little success so far. Unsurprisingly, since 1) there are very many ways in which texts may not fit my classes, and 2) if I use too many examples for the "unrelated" class, the algorithm will simply learn to (nearly) always return it (and resampling reduces this to the previous problem).</p>
<p>I.e. this is a multi-class version of the problem solved by One-class SVMs. Are there standard solutions?</p>
<p>EDIT: I've come up with a possible solution (but not implemented or tested it yet).</p>
<p>Stage 1: a <a href="http://stats.stackexchange.com/questions/35917/how-to-do-one-class-text-classification?rq=1">one-class classifier</a> learned on the union of my classes (i.e. classify between relevant and irrelevant texts).</p>
<p>Stage 2: the usual multi-class classification if stage 1 says it's relevant.</p>
| 73,866 |
<p>After attempting to produce a linear mixed model, I was left with a great deal of heterogeneity.</p>
<pre><code>lme1 <- lme(Average.payoff ~ Game + Type + Others.Type + Game:Type +
Game:Others.Type + Type:Others.Type, random=~1|Subjects, method="REML",
data=Subjectsm1)
</code></pre>
<p>The response term <code>Average.payoff</code> is continuous, whilst all explanatory variables are binary.</p>
<p>When I look to validate, I can clearly see that the spread of the residuals decreases with the larger fitted values.</p>
<p>I decided alternatively to see what would happen if I just fit using <code>gls()</code>.</p>
<pre><code>gls1 <- gls(Average.payoff ~ Game + Type + Others.Type + Game:Type +
Game:Others.Type + Type:Others.Type, method="REML", data=Subjectsm1)
anova(lme1, gls1)
#
# Model df AIC BIC logLik Test L.Ratio p-value
# lme1 1 9 67.81805 81.28662 -24.90902
# gls1 2 8 66.14661 78.11867 -25.07330 1 vs 2 0.3285588 0.5665
</code></pre>
<p>As you can see the <code>gls()</code> model gives a better fit than the <code>lme()</code> model. Even though I know from the experimental design that I have random effects, am I justified to remove them from the model if the fit is better without them?</p>
| 113 |
<p>I want to use Hidden Markov Models for an unsupervised sequence tagging problem. Due to the peculiarities of my application domain (recognition of dialogue acts in conversations), I would like to use multiple emissions for each state (that is, multiple features). Graphically, the model would therefore look like this:
<img src="http://i.stack.imgur.com/nGZ3S.png" alt="HMM with multiple observations"></p>
<p>Both the hidden states and the observation variables are discrete. The emissions probabilities $P(O_{ij} \ | \ S_i)$ are assumed to be independent and modelled via standard categorical distributions.</p>
<p>My question is the following: are there any publicly available toolkits or algorithm that would allow me to learn the parameters of such type of multiple-emissions HMM through a variant of Baum-Welch? From what I could gather, it seems that the only type of multiple emissions supported by classical HMM toolkits are multivariate Gaussians, but I could not find anything about independent categorical distributions of the type above.</p>
<p>Of course, I am aware I could "bypass" the problem by considering each observation to be a vector of values (with each dimension in this vector corresponding to a particular feature) and estimating emission probabilities on this vector space through classical Baum-Welch, but that would introduce a lot of unnecessary data sparsity. </p>
<p>Does anybody have a suggestion to solve this issue? I'm sure I'm not the first person that tried to apply HMMs for unsupervised learning with multiple features! (or maybe I should use another type of model? I considered using CRFs as well, but they seem tricker to apply to unsupervised learning problems).</p>
| 36,396 |
<p>Can somebody point me in the right direction for a treatment of the following problem? I imagine this should be a fairly common problem in medical statistics...</p>
<p>Given two binomial random variables $X_1\sim Bin(n_1,\pi_1)$ and $X_2\sim Bin(n_2,\pi_2)$ I am looking for the posterior distribution of $\pi_1-\pi_2$.</p>
<p>In case this is relevant for simplifying approximations, in my problem both $\pi$ are approximately 2%, their difference about 0.1%. Both $n$ are of the order of $1000$.</p>
| 73,867 |
<p>I often use the instance weights with Libsvm for classification problems.
<a href="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#weights_for_data_instances" rel="nofollow">http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#weights_for_data_instances</a></p>
<p>Does anyone know the details of the algorithm that is implemented when one uses instance weighing in libsvm? The standard SVM model learning algorithm assigns equal weights to all training instances, and thus to the error on the training instances. I believe that the algorithm that Libsvm uses would be different. Upon searching online, I do find some papers that do something similar. For example [1] but I need to confirm with someone who may be sure about this. </p>
<p>Thanks! </p>
<p>ps: i have also posted asked this on stackoverflow. Will update if I get any answer there. </p>
<p>[1] Yang, Xulei, Qing Song, and Yue Wang. "A weighted support vector machine for data classification." International Journal of Pattern Recognition and Artificial Intelligence 21.05 (2007): 961-976.</p>
| 73,868 |
<p>I have a time series (shown below) that comes from a sensor whose calibration was changed in the middle of last year. As part of this change, the sensor's reading of the variance (or volatility) of the observations increased, although actually, this volatility did occur before the change in calibration, but it was not being fully detected.</p>
<p>As the data the sensor detects is highly seasonal (at both the weekly and yearly level), I want to create an accurate forecast of what the future readings will be, using the new level of calibration. I don't want to throw out the data from before the calibration, as we have only collected a little more than a year's worth of data.</p>
<p>I've tried traditional transformations (like Box-Cox) and a seasonal decomposition using <code>stl()</code> in R's <code>forecast</code> package, but the transformation does not solve this variance issue, as there's different variances at the same level of the data (say at 0.0, for example).</p>
<p>Are there any other techniques are there (that are available in the <code>R</code> programming language) that allow me to transform the data from before mid-2013 to match the variance of the data that comes later? </p>
<p><img src="http://i.stack.imgur.com/WXBSg.png" alt="time series"></p>
| 36,399 |
<p>I'm working with bird songs. A song is composed of many vocal parameters [highest frequency (Hz), lower frequency(Hz), bandwidth(Hz), duration (s), number of notes, and son on....]</p>
<p><strong>I'm interested in exploring the relationship between geographical distance and bird songs, to see if some pattern of variation exist in this relationship.</strong></p>
<p><strong>Here is what I did to analyse these songs:</strong></p>
<p>I calculated the distance between each value sampled for each parameter and than generated a matrix of dissimilarity for each parameter measured using euclidean distance. Than I performed a Mantel's Test for each parameter, using a matrix of geographical distance between sampling points and a matrix of distance between values sampled at each point for a given vocal parameter.</p>
<p><strong>My question is:
Is this data analyses correct? Some os these parameters are correlated (like number of notes and song duration, and high frequency with bandwidth), so am I falling into the problem of dependence and pseudoreplication?</strong></p>
| 73,869 |
<p>The probability that a certain radioactive mass emits no particles in a one-minute time period is 0.1353. What is the mean number of particles emitted per minute?</p>
<p>From the above I was able to deduce that P(X>=1) is 1 - 0.1353 = 0.8647.</p>
<p>0.8647 chance of at least 1 particle being emitted in a minute.</p>
<p>I'm not sure how to calculate the mean number of particles per minute though.</p>
| 73,870 |
<p>What motivates, justifies, gives rise to the differences between the Gumbel, Fréchet, and Weibull distributions? Glen_b's comment indicates that they are distributions for extreme values generated by different kinds of distributions in IID sequences. What are those different kinds? [EDITed in response to Glen_b's comment.]</p>
<p>Feel free to point me to other sources.</p>
<p>[Background: I'm just beginning to learn a little bit of extreme value theory (mostly by working through early sections Reiss & Thomas's <em>Statistical Analysis of Extreme Values</em> 2nd ed.). I understand the mathematical definitions of the fully parameterized Gumbel, Fréchet, and Weibull distributions, how they can all be viewed as special cases of a generalized Extreme Value distribution, and that for some parameter combinations a Fréchet or Weibull distribution can be close to a Gumbel distribution. I'm trying to get insight into these distributions' differences at a more conceptual level.]</p>
<p>[I have no reason to doubt that Glen_b is right, but just in case, here are parts of the original question that no longer seem relevant: Are there real-world examples or mathematical contexts that help to motivate, for example, the use of a Fréchet distribution as opposed to a Gumbel distribution? (cf. radioactive particle emissions as motivation for the Poisson distribution.) Or might it be useful to see the three distributions as derived from some other distributions, perhaps as a limit as some parameters go to 0 or $\infty$? (cf. Poisson distribution as a limit of a binomial distribution.) A closely related question: Why would you choose to model extreme values with one of the three distributions rather than the other two (other than simply thinking that the data look like they'd fit one distribution better)?]</p>
| 73,871 |
<p>Background: I'm giving a presentation to colleagues at work on hypothesis testing, and understand most of it fine but there's one aspect that I'm tying myself up in knots trying to understand as well as explain it to others.</p>
<p>This is what I think I know (please correct if wrong!)</p>
<ul>
<li>Statistics that would be normal if variance was known, follow a $t$-distribution if the variance is unknown</li>
<li>CLT: The sampling distribution of the sample mean is approximately normal for sufficiently large $n$ (could be $30$, could be up to $300$ for highly skewed distributions)</li>
<li>The $t$-distribution can be considered Normal for degrees of freedom $> 30$</li>
</ul>
<p>You use the $z$-test if:</p>
<ol>
<li>Population normal and variance known (for any sample size)</li>
<li>Population normal, variance unknown and $n>30$ (due to CLT)</li>
<li>Population binomial, $np>10$, $nq>10$</li>
</ol>
<p>You use the $t$-test if:</p>
<ol>
<li>Population normal, variance unknown and $n<30$</li>
<li>No knowledge about population or variance and $n<30$, but sample data looks normal / passes tests etc so population can be assumed normal</li>
</ol>
<p>So I'm left with: </p>
<ul>
<li>For samples $>30$ and $<\approx 300$(?), no knowledge about population and variance known / unknown.</li>
</ul>
<p>So my questions are:</p>
<ol>
<li><p>At what sample size can you assume (where no knowledge about population distribution or variance) that the sampling distribution of the mean is normal (i.e. CLT has kicked in) when the sampling distribution looks non-normal? I know that some distributions need $n>300$, but some resources seem to say use the $z$-test whenever $n>30$...</p></li>
<li><p>For the cases I'm unsure about, I presume I look at the data for normality. Now, if the sample data does looks normal do I use the $z$-test (since assume population normal, and since $n>30$)?</p></li>
<li><p>What about where the sample data for cases I'm uncertain about don't look normal? Are there any circumstances where you'd still use a $t$-test or $z$-test or do you always look to transform / use non-parametric tests? I know that, due to CLT, at some value of $n$ the sampling distribution of the mean will approximate to normal but the sample data won't tell me what that value of $n$ is; the sample data could be non-normal whilst the sample mean follows a normal / $t$. Are there cases where you'd be transforming / using a non-parametric test when in fact the sampling distribution of the mean was normal / $t$ but you couldn't tell? </p></li>
</ol>
| 73,872 |
<p>I am trying to figure out if value-at-risk (VaR, a quantile) type tests could capture if expected shortfall (expectations above a quantile) point forecast generated from a type of model could be regarded as accurate or not. </p>
<p>I base my curiosity from this quote from <a href="http://www.bis.org/publ/bcbs_wp19.pdf" rel="nofollow">a document by the Basel Committee</a>: </p>
<blockquote>
<p>Whether specialised ES backtests are good or not, one simple option is always available: during an ES calculation, the VaR at the same can be generated as a by-product with low additional effort. One can backtest this VaR with traditional methods; if the VaR is rejected, the corresponding ES calculation can hardly be correct.</p>
</blockquote>
<p>Since it is possible to define expected shortfall as the average of all the value-at-risk estimates exceeding a risk level, this logic could be extended as to saying: if it is likely that the expected shortfall is correct, then we could validate some value-at-risk estimates included in expected shortfall; if they are accepted, then we have increased confidence in the expected shortfall estimate. Assume I have such a test called X. </p>
<p>My question is now, if I wanted to test the quality of my test from my knowledge, it is possible to use Monte Carlo simulations to determine the power of X, but are there any statistical tools/procedures that could tell me if X could tell me anything about expected shortfall?</p>
| 73,873 |
<p>I am looking for a research paper that basically describes a hidden markov model that has multiple observations, and some observations that have conditional dependencies. For example, please consider the following figure that shows two latent states with 5 observed variables. Here the variable obs5 is dependent on it's parent obs1-obs4. I am aware of HMMs that have single level of observed variables. However, I am not able to find any literature that has the following graphical model structure. So my question is, are there any works/ research papers that model such HMMs?
<img src="http://i.stack.imgur.com/TTrke.jpg" alt="enter image description here"></p>
| 16,691 |
<p>I have a nested model with the following effects</p>
<ul>
<li>fixed: treatments</li>
<li>random: experiment_date</li>
</ul>
<p>I used <code>lme()</code> to model the data</p>
<pre><code>mod1 <- lme(N_cells ~treatments-1, random=~1|experiment_date, method='ML')
</code></pre>
<p>Then I want to compare all the other treatments to the control (included in
the "treatments" in <code>mod1</code>). After a fair amount of searching around, I
decided to use <code>glht()</code> from the <a href="http://cran.r-project.org/web/packages/multcomp/index.html" rel="nofollow">multcomp</a> package (any other suggestions?).</p>
<pre><code>lvl.treatments=table(treatments)
K = contrMat(lvl.treatments,type='Dunnett',base=1)
mc<-glht(mod1, linfct=mcp(treatments=K),alternative='greater')
</code></pre>
<p>But I got the following error:</p>
<blockquote>
<p>Error in contr.treatment(n = 0L) : not enough degrees of freedom to
define contrasts</p>
</blockquote>
<p>I tried to extract the df parameter using <code>modelparm()</code>, but the function
couldn't be applied to lme</p>
<blockquote>
<p>Error in UseMethod("modelparm") : no applicable method for
'modelparm' applied to an object of class "lme"</p>
</blockquote>
<p>The degree of freedom of the fixed effect was 194. I tried to specify the
number in <code>glht()</code>, but got the same error as "not enough degrees of freedom to
define contrasts".</p>
<p>Does anyone know what's happening and how I could possibly solve the
problem? Thank you so much.</p>
| 73,874 |
<p>I have a naive Bayes classifier with two classes (target and non-target) and distributions for a number of features (the same for both classes). </p>
<p>I know that some features contribute more, or less to the overall classification accuracy.
I can use KL-divergence to measure the information gain from feature distributions, but how could I use it to weight features? </p>
<p>Say I have features f1, and f2. I have a KL value for the two features and the class. </p>
<p>$KL(f_1, C_1), KL(f_2, C_1)$ </p>
<p>$KL(f_1, C_2), KL(f_2, C_2)$</p>
<p>Where do I go from here?</p>
| 36,404 |
<p>I have a nested repeated measures question. I have 20 individuals grouped into 5 families. For each individual I have measurements on subsequent days pre, during, and post-treatment for a total of 6 measurements per individual (on days 1 and 2 pre-treatment, on days 4 and 5 during treatment, and days 7 and 8 post-treatment). </p>
<p>I previously used a model with composited pre, during and post-treatment level that looked like this:</p>
<pre><code>lme(log(X)~t1+t2, random=~1|family/participant, data=data)
</code></pre>
<p>where <code>t1 = -1</code> for pre-treatment and <code>t2 = 1</code> for post-treatment</p>
<p>This allowed me to interpret the slopes on <code>t1</code> and <code>t2</code> to evaluate the treatment effect.</p>
<p>How do I incorporate the repeated measures within pre-treatment, during and post-treatment? Visualizing the data suggests correlation between these measurements on subsequent days and there may be a trend (slight up-tick).</p>
<p>Any suggestions on coding in R would be much appreciated!</p>
| 73,875 |
<p>I have a question. </p>
<blockquote>
<p>In a two sample t test, a confidence interval for $\mu_2-\mu_1$ is constructed based on the hypothesis test $H_0: \mu = \mu_0$ versus $H_{a}: \mu \neq \mu_0$? </p>
</blockquote>
| 73,876 |
<p>I have used Mixture Density Networks for probability density function prediction. I am wondering how I can calculate Root Mean Square Error (RMSE) of predicted pdf in MATLAB.</p>
<p>Thanks.</p>
| 36,406 |
<p>i was asked to describe a non-trivial data (n not equal to =/1) example where the leverages would all be equal for QR decomposition question. could someone help?</p>
| 31,272 |
<p>I have a series of measurements in which something is sampled and placed into either category 1 or category 2. I have 3x2x3 factors for each set of measurements, and each set of measurements is done independently 3 times. </p>
<p>What is a good statistical test to look examine the combined effects of each factor, both independently and interactively with each other?</p>
| 73,877 |
<p>I was running some timing simulations on a computer. As is often done with low latency things like this, I was running the relevant block in a loop $k$ times and then recording the total time over $k$ (average time). I repeated this thing $100$ times for $k=10000$ and $k=100000$ respectively and computed a mean and standard deviation for both sets of $100$ data points (so a sample mean of means and it's standard deviation). I noticed that this sample standard error was actually larger for the case of $k=100000$ than it was for the case of $k=10000$. I found this very perplexing as I am accustomed to thinking the sample mean estimator is distributed as $\sigma/ \sqrt{n}$. I therefore took this to mean that the draws (i.e. every run of the relevant block) were not i.i.d. Thinking about this I reasoned that varying system loads on a computer as well as changes in caches due to context switching and what not could mean the draws are most likely not identically distributed. I thought of using a runs test as well to test for independence but I don't have enough time measuring resolution to accurately observe individual iterations although I believe independence is less of an issue than the identically distributed assumption.</p>
<p>In any case, given this problem, I am not sure how to proceed from a statistical point of view when trying to provide a latency metric of qualitative value. (There seems to be no point to a sample mean if there is no population mean right?)</p>
<p>Perhaps this is an issue where only relative performance may be useful? (i.e. A is on average twice as fast as B but nothing can really be said about B because it's average latency is not well defined due to lack of environment control) Or is there some statistical tool (estimator, test, or adjustment) that can be made in a situation like this?</p>
| 47,979 |
<p>I am trying to understand what the reported intercept is showing when I use <code>arima()</code> with <code>xreg=</code>. The documentation says</p>
<p>"If am xreg term is included, a linear regression (with a constant term if include.mean is true and there is no differencing) is fitted with an ARMA model for the error term."</p>
<p>Thus I expect the intercept shown to come from the regression using <code>xreg=</code> as the X variables, before any arima model is done on those residuals. </p>
<p>However I tried to double check this by actually doing the regression with <code>lm()</code> and the intercept from that does not match what is reported from <code>arima()</code> (although the slope coefficient is pretty close). </p>
<p>Here is my example:</p>
<pre><code>set.seed(456)
v = rnorm(100,1,1)
x = cumsum(v) ; x = as.xts(ts(x))
# Fit AR(1) after taking out a time trend (aka, drift)
model5 = arima(x, order=c(1,0,0), xreg=1:length(x), include.mean=TRUE)
# Coefficients:
# ar1 intercept 1:length(x)
# 0.8995 0.8815 1.1113
# s.e. 0.0422 1.6193 0.0265
# Double check
MyTime = 1:length(x)
model5_Part1 = lm(x ~ MyTime )
# Coefficients:
# (Intercept) MyTime
# 1.856 1.096
</code></pre>
<p>The intercepts do not match, thus I do not know what the intercept is showing from the arima with xreg.</p>
<p>Note the example shown is based on "Issue 2" shown here <a href="http://www.stat.pitt.edu/stoffer/tsa3/Rissues.htm" rel="nofollow">http://www.stat.pitt.edu/stoffer/tsa3/Rissues.htm</a></p>
<p>Also note that this isn't a problem particular to modeling drift. Here is another example, where in addition to the intercept not matching, even the slope coefficient on the <code>xreg=</code> variable doesn't match what is shown from using <code>lm()</code>. This example has nothing to do with drift and uses the cars dataset as if it were time series data.</p>
<pre><code>data(cars)
cars = as.xts(ts(cars, start=c(1980,1), freq=12))
model6 = arima(cars$speed, xreg=cars$dist, order=c(1,0,0), include.mean=TRUE)
# Coefficients:
# ar1 intercept dist
# 0.9979 15.2890 -0.0172
# s.e. 0.0030 10.5452 0.0055
model6_Part1 = lm(cars$speed ~ cars$dist)
# Coefficients:
# (Intercept) cars$dist
# 8.2839 0.1656
</code></pre>
<p>Intercepts do not match, slope coefficient does not match.</p>
| 73,878 |
<p>I have read this link.</p>
<p><a href="http://stats.stackexchange.com/questions/3730/pearsons-or-spearmans-correlation-with-non-normal-data">Pearson's or Spearman's correlation with non-normal data</a></p>
<p>I cannot comment on the original post. Therefore I ask here:</p>
<p>I have two variables are <strong>not normally distributed</strong>. I implement different methods to calculate the first variables in different formats, and calculate the Pearson's correlation between the first and the second variables.</p>
<ol>
<li><p>If the Pearson's correlation calculated by Method A, is much higher than Method B. Can I say Method A is better than Method B?</p></li>
<li><p>If the Pearson correlation is very high between two <strong>not</strong> normally distributed variables, 0.8, for example. Can I say these two variables are linearly related?</p></li>
</ol>
<p>06-12-14:50</p>
<p>More details</p>
<p>This is my project for measuring the sense relatedness between synonyms</p>
<p>I extract sentences containing those synonyms, transfer the neighbouring words appearing in those sentences to vectors by different methods (e.g. TF-IDF, using PMI to do feature selection), calculate the cosine distance between different vectors. These are the first variables.</p>
<p>The second variables are the sense relatedness from this paper (Page 628)</p>
<p>Rubenstein, Herbert, and John B. Goodenough. "Contextual correlates of synonymy." Communications of the ACM 8.10 (1965): 627-633.</p>
| 73,879 |
<p>I would like to perform an individual-level multivariate analysis at small levels of geographic aggregation (Australian census collection districts). Clearly, the census isn't available at these small levels of aggregation for privacy reasons so I am investigating other alternatives. Almost all the variables of interest are categorical. I have two datasets at my disposal:</p>
<ul>
<li><p>The 1% census sample is available at a much greater level of spatial aggregation (an area with a population of ~190,000 and vast spatial segregation of demographics). </p></li>
<li><p>Frequency tables for the variables I am interested in at the small area level (500 small areas, mean pop = 385, sd = 319, median = 355).</p></li>
</ul>
<p>How can I use these two datasets to simulate a population distribution at the small area level that is as close as possible to the actual population of the small area?</p>
<p>I appreciate that there may well be routine methods for doing this; if so a pointer to a textbook or relevant journal articles would be vastly appreciated.</p>
| 47,981 |
<p>Here is my example. Supose we evaluate a characteristic using two different methods (a and b) and we want to study if both methods performs in a same way. We also know that these two measures have been recorded from two different groups, and the mean values for each one of these groups are highly different. Our data set could be as follows:</p>
<pre><code>a <- c(22,34,56,62,27,53)
b <- c(42.5,43,58.6,55,31.2,51.75)
group <- factor(c(1,1,2,2,1,2), labels=c('bad','good'))
dat <- data.frame(a, b, group)
</code></pre>
<p>The association between a and b could be calculated as:</p>
<pre><code>lm1 <- lm(a ~ b, data=dat)
summary(lm1)
Call:
lm(formula = a ~ b, data = dat)
Residuals:
1 2 3 4 5 6
-13.810 -2.533 -3.106 8.103 7.541 3.806
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -25.6865 19.7210 -1.302 0.2627
b 1.4470 0.4117 3.514 0.0246 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 9.271 on 4 degrees of freedom
Multiple R-squared: 0.7554, Adjusted R-squared: 0.6942
F-statistic: 12.35 on 1 and 4 DF, p-value: 0.02457
</code></pre>
<p>As we can see, it seems to be a high association between both measures. However, if we perform the same analysis for each group separately, this association disappears. </p>
<pre><code>lm2 <- lm(a ~ b, data=dat, subset=dat$class=='bad')
summary(lm2)
Call:
lm(formula = a ~ b, data = dat, subset = dat$group == "bad")
Residuals:
1 2 5
-6.0992 5.8407 0.2584
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.9931 35.1657 0.654 0.631
b 0.1201 0.8953 0.134 0.915
Residual standard error: 8.449 on 1 degrees of freedom
Multiple R-squared: 0.01769, Adjusted R-squared: -0.9646
F-statistic: 0.01801 on 1 and 1 DF, p-value: 0.915
</code></pre>
<p>and,</p>
<pre><code>lm3 <- lm(a ~ b, data=dat, subset=dat$class=='good')
summary(lm3)
Call:
lm(formula = a ~ b, data = dat, subset = dat$group == "good")
Residuals:
3 4 6
-2.394 5.047 -2.652
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.9361 70.4238 0.496 0.707
FIV 0.4003 1.2761 0.314 0.806
Residual standard error: 6.184 on 1 degrees of freedom
Multiple R-squared: 0.08959, Adjusted R-squared: -0.8208
F-statistic: 0.09841 on 1 and 1 DF, p-value: 0.8065
</code></pre>
<p>How should we assess the association between the two methods? We should take into account the group factor? Maybe it is a trivial question, but I have doubts about how to deal with this problem.</p>
| 36,411 |
<h3>Context</h3>
<p>I have two sets of data that I want to compare. Each data element in both sets is a vector containing 22 angles (all between $-\pi$ and $\pi$). The angles relate to a given human pose configuration, so a pose is defined by 22 joint angles.</p>
<p>What I am ultimately trying to do is determine the "closeness" of the two sets of data. So for each pose (22D vector) in one set, I want to find its nearest neighbour in the other set, and create a distance plot for each of the closest pairs.</p>
<h3>Questions</h3>
<ul>
<li>Can I simply use Euclidean distance?
<ul>
<li>To be meaningful, I assume that the distance metric would need to be defined as: $\theta = |\theta_1 - \theta_2| \quad mod \quad \pi$, where $|...|$ is absolute value and mod is modulo. Then using the resulting 22 thetas, I can perform the standard Euclidean distance calculation, $\sqrt{t_1^2 + t_2^2 + \ldots + t_{22}^2}$.</li>
<li>Is this correct?</li>
</ul></li>
<li>Would another distance metric be more useful, such as chi-square, or Bhattacharyya, or some other metric? If so, could you please provide some insight as to why.</li>
</ul>
| 73,880 |
<p><a href="http://www.biomedcentral.com/1471-2105/10/318" rel="nofollow">Kavosh</a> is a recent package designed for <a href="http://en.wikipedia.org/wiki/Network_motif" rel="nofollow">network motif</a> discovery. To give a comparison, Kavosh generates a collection of similar networks using an MCMC process.</p>
<p>The networks in consideration are directed graphs without loops or multiple edges. <em>Similar</em> networks have the same vertex set and the same in-degrees and out-degrees. Ideally we want to sample uniformly at random from the set of similar graphs.</p>
<p>As I understand it, network motif detection programs typically use a well-studied switching process: take two directed edges (a,c) and (b,d) uniformly at random, then replace with (a,d) and (b,c). Reject if a loop or multiple edge is formed. (see e.g. <a href="http://arxiv.org/abs/cond-mat/0312028" rel="nofollow">http://arxiv.org/abs/cond-mat/0312028</a>)</p>
<p>Judging from its source code, Kavosh seems to speed-up this process in the following way. For all vertices v do:</p>
<ul>
<li>Let a=v.</li>
<li>b is a random vertex b<>a.</li>
<li>c is a random out-neighbour of a.</li>
<li>d is a random out-neighbour of c.</li>
</ul>
<p>And as before, replace edges (a,c) and (b,d) with (a,d) and (b,c). Reject if a loop or multiple edge is formed. Repeat this whole process three times (so there can be up to 3|V| switches applied in total, where |V| is the number of vertices). [For some reason I'm unsure of, the last two steps are also repeated up to three times.]</p>
<blockquote>
<p><strong>Question</strong>: What effects could one expect to see as a result of this change? How concerned should one be about this change?</p>
</blockquote>
<p>The Kavosh paper does not say much about it:</p>
<blockquote>
<p>In our approach, similar to Milo's
random model [17,18] switching
operations are applied on the edges of
the input network repeatedly, until
the network is well randomized.</p>
</blockquote>
| 36,412 |
<p>I have been using $r = \mu \ln(1 - n)$ to obtain pseudo-random numbers from an exponential distribution, where $\mu$ is the distribution mean and $n$ is a pseudo-random number from 0 to 1. Now I want to do the same thing, but use a distribution that has a scale parameter. Can I simply scale the result of the above equation?</p>
<p>Also, why does my source recommend using $\ln(1 - n)$? Isn't $\ln(n)$ effectively the same?</p>
<p>Thanks</p>
| 31,503 |
<p>i use e1071 package in R for SVM regression prediction and tried the same test in C# libsvm and got different results. All the parameters (gamma,cost,eps) are the same and so is the scaling method. The predictions differences average is about 0.015 (850 test samples). Is that a reasonable difference? What may be the reason?</p>
| 73,881 |
<p>I am learning about ridge regression, so I am implementing it in MATLAB as practice. However, I am having trouble finding a structure of data where ridge regression performs better than an ordinary least squares.</p>
<p>Reading up I've found that data that is collinear is often better to be regularized. However when I implemented this in the below code least squares is performing just a well as ridge regression (the best lambda parameter is in the range e-10, almost non-existent!). MATLAB tells me that X is rank deficient (rank=2) when using the built in function for least squares, however it still performs well?</p>
<p>I was wondering if anyone knew why this was performing this way, is my data perhaps not collinear enough to show a real performance difference, or have I misunderstood something?</p>
<pre><code>% Generate data;
clear;
Nt = 100;
X(:,1) = randn(Nt,1);
X(:,2) = 2*X(:,1) + 6;
X(:,3) = 12*X(:,2) + 16;
p=[0.74,3,4.5];
y = X*p' + randn(Nt,1);
% Least Squares;
pLS = X\y;
%pLS = pinv(X'*X)*(X'*y);
nmseN = sum((X*pLS-y).^2)/length(y)/var(y);
% Tikhonov;
lspace = logspace(-10,-1,1000);
bestNMSE = inf;
bestLambda = -1;
I=eye(size(X, 2));
for lambda=1:length(lspace)
prLS = pinv(X'*X + lspace(lambda)*(I'*I))*(X'*y);
nmse = sum((X*prLS-y).^2)/length(y)/var(y);
if nmse<bestNMSE
bestNMSE=nmse;
bestLambda=lspace(lambda);
end
end
prLS = pinv(X'*X + bestLambda*(I'*I))*(X'*y);
nmseR = sum((X*prLS-y).^2)/length(y)/var(y);
</code></pre>
| 73,882 |
<p><a href="http://www.cs.toronto.edu/~hinton/adi/index.htm" rel="nofollow" title="DBN Generation Demo">This demo</a> shows the DBNs capability to associate different input modalities ("images of digits" and "labels").</p>
<p>By clamping one modality at the top layer, the network can infer the other via (Gibbs) sampling. So the top level RBM works as an associative memory.</p>
<p>In <a href="http://www.youtube.com/watch?v=AyzOUbkUf3M" rel="nofollow">this video</a> Hinton says something like: By setting a label neuron in the top layer, the model lowers the energy for this digit and raises it for all the other classes. This creates a valley in which all accepted digits are located. </p>
<p>This kind of association does not seem to work with my RBM when I feed in continuous data instead of labels.
It seems that the Gibbs sampling procedure, which I use to infer the other modality, gets stuck in local minima and is not able to settle in the right <em>valley</em>. I suspect that clamping continuous data in the top layer input does not create the same kind of <em>ravines</em> which are needed to infer the correct data.</p>
<p>My questions are:</p>
<ol>
<li>Does a DBN/RBM have the capability to associate, say, images with another continuous modality? This is some kind of regression in an unsupervised/associative way.</li>
<li>If so, do i need other kinds of hidden units like rectified linear units or gaussian units or should it be possible with regular binary hidden units?</li>
</ol>
<p>I hope it is clear what I am trying to achieve. Please ask if something is still unclear.</p>
| 36,416 |
<p>I could really use a hit as to which statistical test I need to use to address the following problem:</p>
<p>I have three different species: A, B and C.
I have compared the quantitative overlap of Species A and B, respectively, with that of 'Species C' (using a Fisher's test for each of the two cross-species comparisons).</p>
<p>In order to be more specific:
When 'Species A' is compared to 'Species C' I get a p-value of 4.2e-08 (overlap of 17; 13 specific to A; 25 specific to Species C)</p>
<p>When 'Species B' is compared to 'Species C' I get a p-value of 0.014 (overlap of 7; 11 specific to B; 35 specific to Species C).</p>
<p>Now I want to determine whether 'Species A' mimics/replicates 'Species C' significantly more than 'Species B' does in terms of overlap. I'm assuming that a direct comparison between the p-values (from the two Fisher tests) isn't sufficient. So my question is which test I can use to address my problem?</p>
<p>Hits are much appreciated.</p>
| 36,418 |
<p>I have a regression problem with 5-6k variables. I divide my data into 3 non-overlapping sets: training, validation, and testing. I train using only the training set, and generate a lot of different linear regression models by choosing a different set of 200 variables for each model (I try about 100k such subsets). I score a model as $\min(R^2_{\text{training data}}, R^2_{\text{validation data}})$. Using this criterion, I end up choosing a model. It turns out that the model chosen has very similar $R^2$ on the training and the validation data. However, when I try this model on the testing data, it has much lower $R^2$. So it seems I am somehow overfitting on both the training and the validation data. Any ideas on how can I get a more robust model? </p>
<p>I tried increasing the training data size, but that didn't help. I am thinking of perhaps shrinking the size of each subset.</p>
<p>I have tried using regularization. However, the models I obtain using the lasso or the elastic net have much lower $R^2$ on the training set as well as the validation set, as compared to the model I obtain by doing the subset selection approach. Therefore, I don't consider these models, since I assume that if Model A performs better than Model B on both the training set as well as the validation set, Model A is clearly better than Model B. I would be very curious if you disagree with this.</p>
<p>On a related note, do you think $R^2$ is a bad criteria for choosing my models?</p>
| 73,883 |
<p>This is actually part of a problem from <em>All of Statistics</em>:</p>
<p>$X_1, X_2, \ldots, X_n \sim \text{Uniform}(0, \Theta)$. And $Y = \text{Max}\{X_1,\ldots, X_n\}$.</p>
<p>If you're given that $Y > c$, can you estimate the probability of $\Theta>1/2$?</p>
<p>Of course if $c\ge1/2$ the probability is 100%.</p>
<p>Any hint or direction is appreciated.</p>
<p>BTW, is there anywhere I can find answers to the book <em>All of Statistics</em>? It's really a good book except there's no solution to the problems, even part of them.</p>
| 6,866 |
<p>I have been thoroughly confused by a bunch of online resources regarding this issue. I would really like a simple explanation about the differences between generative and discriminative approaches, and where "discriminant functions" figure in all this. I would especially appreciate any explanation or a pointer toward a resource without any of the "generative models generate random data according to some distribution..." standard explanation. This explanation is very vague to grasp for someone unfamiliar with this area and especially this explanation does nothing to describe the motivation for using generative vs. discriminative models. </p>
| 36,421 |
<p>We've got a 524*40 data frame of responses to a likert-type scale questionnaire (7 response categories on 40 items). We want to do exploratory multidimensional IRT using the MHRM method to identify the latent structure. When we run </p>
<pre><code>mirt(SAQdata3, 4, method = 'MHRM')
</code></pre>
<p>we get the following error message:</p>
<pre><code>Stage 1: Cycle = 1, Log-Lik = -46764.0, Max Change = 0.2500
Stage 1: Cycle = 2, Log-Lik = -45091.4, Max Change = 0.2500
Error in solve.default(ave.h, grad) :
system is computationally singular: reciprocal condition number = 7.06167e-20
</code></pre>
<p>We understand that there's something going wrong with the optimization method due to the structure of the data but are unclear exactly what is wrong and if there is any way to fix it?</p>
| 73,884 |
<p>My panel regression model is as follows:
$$Y_{it}=PS_{it}+PF_{it}+EF_{it}+ \mathbf X_{it}+e_{it}$$
where </p>
<ul>
<li><p>$i$ : country, </p></li>
<li><p>$t$ : year, </p></li>
<li><p>$Y_{it}$ : GDP per capita, </p></li>
<li><p>$PS_{it}$ : Political stability, </p></li>
<li><p>$PF_{it}$ : Political Freedom, </p></li>
<li><p>$EF_{it}$ : Economic Freedom, </p></li>
<li><p>$e_{it}$ : error term.</p></li>
</ul>
<p>There are other independent variables as well in equation ($\mathbf X_{it}$). My question is that we normally check stationary for time series data and I want to know do I need to check stationarity for the panel-data case?. I further explain that I am using heritage foundation aggregate economic freedom index and freedom House political freedom index as independent variable in my analysis. Do I also need to check both indexes stationary?</p>
| 73,885 |
<p><strong>Hello</strong>,</p>
<p>first of all I've got to confess that I'm not a statistician and therefore wouldn't mind if an answer is a bit more explicit than it usually would be among statisticians.</p>
<h2>The Context</h2>
<p>To predict energies of arbitrary patterns of a certain physical system, I settled to use the MAPS code (as it is described in detail in <a href="http://arxiv.org/pdf/cond-mat/0201511v2.pdf" rel="nofollow">this paper</a>).</p>
<p>This code iteratively constructs a data set of <em>known energies</em> $E_i$, which provide the <em>dependent variable</em>. Those should be explained by the <em>independent variables</em>, given by the so called "correlations" $\langle \prod_{j \in \alpha^\prime}\sigma_j \rangle_{\alpha^\prime}$ (which are $\in \left[-1,1\right]$) averaged over all "clusters" $\alpha^\prime$ which are symmetrically equivalent to a specific cluster $\alpha$ included in a specific truncation. The set of all "clusters" $\alpha$ included in the cluster expansion define the truncation by limiting $\sum_\alpha$. That way, each energy of a structure described completely by $\vec{\sigma}_i$ contributes a row to the problem as per
$$
E_i = E\left\lbrace\vec{\sigma}_i\right\rbrace = \sum\limits_\alpha J_\alpha m_\alpha \langle \prod_{j \in \alpha^\prime}\sigma_j \rangle_{\alpha^\prime},
$$
such that $J_\alpha m_\alpha$ is the set of <em>regression coefficients</em>.</p>
<p>As the aforementioned paper describes, to prevent overfitting to our finite set of known energies, (a weighted version of) the cross validation score as given by
$$
CV^2 = \frac{1}{n}\sum\limits_{i=1}^n\left(\frac{E_i - \hat E_i}{1-X_{i\cdot}\left(X^TX\right)^{-1}X_{i\cdot}^T}\right)^2
$$
is calculated/minimized to measure/maximize the prediction power of the truncation. Here, $\hat E_i$ is the estimation of $E_i$ using a specific truncation, and $X$ the $n\times c$ regression matrix for $n$ known energies/structures (rows) and their $c$ "correlations"/clusters (columns).</p>
<h2>The Problem</h2>
<p>However, iteratively adding structures and testing truncations leads to a system that suspiciously often (as in "the vast majority of tested truncations") yields $CV^2 \rightarrow \infty$ becaucse $X_{i\cdot}\left(X^TX\right)^{-1}X_{i\cdot}^T \rightarrow 1$ in contributions from several different structures i.</p>
<p>In some sense, $X$ seems to become "orthogonal" at some point in the sense that $X^TX = \lVert X_{i\cdot} \rVert^2\cdot\mathbb{1}$ but I fail to make real sense of that currently.</p>
<h2>The Question(s)</h2>
<p>Now, I assume the predictive power of a given truncation isn't estimated in a useful way by such a diverged CV score and I suspect there is a deeper, statistical reason for this to happen so often. Therefore I'd like to ask:</p>
<ul>
<li>Does such a divergent CV score signal something statistically important and, if so, what would that be?</li>
<li>Is there another way to access the predictive power of a truncation aside from the CV score?</li>
</ul>
<hr>
<p>Please find a problematic regression matrix $X \in \left[-1,1\right]^{71\times 15}$ and the corresponding dependent variable vector $\vec{E} \in \mathbb{R}^{71\times 1}$ <a href="https://gist.github.com/anonymous/b2e7151e8e59edc43107" rel="nofollow">here</a>.</p>
<p>In case there are any additional information of interest missing in the post above, please don't hesitate to ask me - I'll gladly provide them then.</p>
<p>Thank you very much in advance!</p>
| 73,886 |
<p>How do you calculate (1.4) below?</p>
<p>From "Distribution of Residual Autocorrelations in Autoregressive-Integrated-Moving Average Time Series Models" (Box and Pierce 1970):</p>
<p><img src="http://i.stack.imgur.com/ui1hB.jpg" alt="enter image description here"></p>
<p><a href="http://www.jstor.org/stable/2284333" rel="nofollow">http://www.jstor.org/stable/2284333</a></p>
| 73,887 |
<p>I've have a variable that has a regression coefficient of 5 using OLS, but when I use quantile regression (examining every 5th percentile, 5, 10, 15, etc.), I find a coefficient that is anywhere from 1/100th to 1/5th of the size of the OLS coefficient. It never really approaches the OLS coefficient. What is causing that? Does that indicate problems with either the quantile regression or OLS approach?</p>
<p>Furthermore, I have another variable that has a significantly positive OLS coefficient, but at pretty much each percentile (again, by 5ths), the coefficient is negative. What could be driving this?</p>
| 31,423 |
<p>I have used scaling on features of a model which contains 40 features (all columns are numbers) and a binary output variable. </p>
<p>This is the Kaggle contest <a href="http://www.kaggle.com/c/data-science-london-scikit-learn" rel="nofollow">here</a> I've scaled the features assuming it would deliver better performance, but with a rbf kernel SVM, the accuracy with 10 fold CV fell from 0.92 to 0.87</p>
<p>Here is a box plot of features before and after scaling:</p>
<p><img src="http://i.stack.imgur.com/fqoB6.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/sGHcZ.png" alt="enter image description here"></p>
<p>What I would like to know is why scaling decreases classifier performance? I have not seen any discussions that point at this type of outcome.</p>
| 73,888 |
<p>I have to determine periodicity of the states of the chain and I think that the chain is aperiodic but I don't know how to argument it. Is it correct and mabye there is some calculation that I can do to prove it? I also think that state one can have a period 2 because it can be visited only at the multiple of two moves. Is that correct reasoning?</p>
<p>To determine stationary distribution should I first reduce the chain to states 2, 5, 6? Without such a reduction I cannot solve balanced equations?</p>
<p>Can somebody help me with the problems described above?</p>
<p><img src="http://i.stack.imgur.com/uzqme.png" alt="enter image description here"></p>
<p><img src="http://i.stack.imgur.com/jlCkU.png" alt="enter image description here"></p>
| 73,889 |
<p>Given the joint density $f_{12}(x_1,x_2)$ of two (dependent) random variables $X_1$ and $X_2$, each defined on $\mathbb{R}$. Suppose that $f_{12}$ is differentiable everywhere on $\mathbb{R}^2$. Now define the event </p>
<p>$Y=\{(x_1,x_2) : x_2 - x_1 \leq d\}$ </p>
<p>for some real $d$. </p>
<blockquote>
<p>What is the <i>conditional</i> density $f_{12}(x_1,x_2|Y )$ ? </p>
</blockquote>
<p>In other words, I need the joint density when event points are restricted to the subspace $Y$ of $\mathbb{R}^2$.</p>
<p>More generally, given a $Y \subsetneq \mathbb{R}^2$, defined by one or more "algebraic" constraints (like the one given above), is there an algorithm to compute the conditional joint density?</p>
<p>I don't know if "conditional joint density" is the right term. I'd also appreciate any references on this. </p>
| 73,890 |
<p>I am having a little trouble understanding the concept and derivation of the likelihood of truncated data.</p>
<p>For example, if I want to find the likelihood function based on a sample from a distribution, but when taking a sample from the distribution, I observe the truncated values (where there is a cut-off of $M$, i.e. any $x_{i}>M$ is recorded as $M$):</p>
<p>$ x_{1}, x_{2}, M, x_{3}, M, x_{4}, x_{5}, ..., x_{10}$</p>
<p>where the number of $M$ values is $m$. Then, the likelihood is supposedly given by:</p>
<p>$L(x;\theta) = \prod_{i=1}^{10}f(x_{i};\theta)*[P(X>M)]^{m}$</p>
<p>I would very much appreciate an explanation/proof of why this is so, importantly why the second factor is as it is. Intuitively and mathematically if possible. Thanks very much in advance.</p>
| 36,430 |
<p>I would like to implement (in R) an instrumental variable (IV) estimator, that takes the most general form (here not 2SLS or GMM!):
$$ \beta_{IV} = (Z'X)^{-1}Z'Y $$</p>
<p>I could code this in the naive way, inverting $Z'X$, and computing the rest, but I remember that this is very inefficient in term of computing, and that in the similar case of OLS $(X'X)^{-1}X'Y$, one should use rather a QR decomposition rather than inverting $X'X$. </p>
<p>However, in the case of my IV estimator, I guess the standard QR won't apply, so I am not sure whether there is any similar technique/decomposition that could be applied in this case? </p>
<p>Any idea of an efficient technique to compute $(Z'X)^{-1}Z'Y$ without inverting $(Z'X)^{-1}$? </p>
<p>Thanks!</p>
| 73,891 |
<p>I have an item for which I slowly collect rating values on a website. It is a movie item on a website and at the beginning it has no rating but I assign it a Gaussian prior $N(\mu_0, \sigma_0^2)$. A person comes on the website and gives it 4 out of 5 (note that I have only discrete ratings 1, 2, 3, 4 and 5 stars) </p>
<p>My question is how can I update my prior now and get a posterior distribution for the mean of stars.</p>
<p>My second question is that let's say I consider the median of the scores as the final score that I want to show to people for that movie how can I do my updating then? I imagine I have to form a discrete prior as well.</p>
<p>And my last question is that if I wanted to assign a weight to each rating and find the weighted mean and median how can I do that?</p>
<p>These might be easy questions but I am very confused about these. If you know a book or paper that might have discussed a similar problem I appreciate if you could refer me to that too. </p>
| 73,892 |
<p>I am coding a questionnaire on STATA and there is a question about Father Education with the option "Don't know" at the end. I am not sure how to code it, because I don't want to count it as missing variable, since the students that answer the questionnaire might have been raised by single moms, etc, and the "don't know" is a valid answer. </p>
<p>I am wondering if I should code it close to "No Education" as follow:</p>
<pre><code> recode father_educ2 (3=0 "No schooling")(11=1 "Don't Know")(4=2 "Elementary") ///
(5=3 "Middle_School")(6=4 "High_School Incomplete")(7=5 "High_School Graduate") ///
(8=6 "Some College")(9=7 "Bachelor Degree")(10=8 "Graduate Degree") ///
(1 2 12 13=. "Missing data"), gen(father_educ)
</code></pre>
<p>or should I include it after Graduate Degree? any thoughts?</p>
<p>Thanks anyone!</p>
| 48,023 |
<p>I have a model with variables (financial ratios) and some of them are in percentages, some in days and some just ratios (negative and positive). I ran an ANOVA and the results were not so good. When I applied the Shapiro test, 24 out of the 26 variables were not normally distributed. So I log-transformed every variable and the results went exactly as I wanted. But firstly I do not know if this is mathematically correct and secondly how I could justify this transformation.</p>
| 38,154 |
<p>I have conducted a repeated measures ANOVA, with 2 factors: </p>
<ul>
<li>One between factor (<code>Ex_control</code>: exercise intervention versus control) </li>
<li>One within factor (<code>time</code>: pre/post intervention). </li>
</ul>
<h3>Questions</h3>
<ul>
<li>Should I first refer to the table labelled <code>within-subject effect</code> and specifically the box labelled <code>time*Ex_control</code>? </li>
<li>Does this table show whether or not there was a significant between or within group change as a result of the intervention?</li>
</ul>
| 1,025 |
<p>Let's say I fit an ARIMA model on a time series up to date t.</p>
<p>I want to forecast the 10 next values without refitting the model but also using the latest data available for each date.</p>
<p>So
forecast for (t+1) uses the model fitted from 1 to t and the time serie from 1 to t</p>
<p>forecast for (t+2) uses the model fitted from 1 to t and the time serie from 1 to t+1</p>
<p>forecast for (t+3) uses the model fitted from 1 to t and the time serie from 1 to t+2</p>
<p>...</p>
<p>This is not the same as simply using "forecast" with an horizon of 5, as I want to take into account all data points prior to the forecasted point. (e.g. a shock on t+2 woudl have an effect on the forecast for t+3, even though we do not refit the entire model)</p>
<p>One way would be to fit the model using data from 1 to t, and then apply this model to all the data and take the fitted values as forecasts.</p>
<p>However this does not work.
Even for an horizon of 1, the two methods produces different results.</p>
<pre><code>library(forecast)
data<-c(1,4,3,5,7,8,1,2,6,7,2,3,4,4);
mymodel<-Arima(data[1:10], order=c(1,1,1)) # Fitting the model using data from 1 to 10
forecast(mymodel, h=1)$mean[1] # Forecasting point 11
[1] 5.263669
fitted(Arima(data[1:11], model = mymodel))[11] # Applying the model estimated from 1 to 10 to data from 1 to 11 and taking fitted values
[1] 5.125379
</code></pre>
| 73,893 |
<p>Disclaimer: I understand that this question is specific to the types of data, the end goal, etc. but I just wanted to get some quick tips regarding calculating dissimilarity between different types of data. This/clustering is probably the area of ML in which I am least comfortable.</p>
<p>Let's say I have a dataset with 3 features: Age (integer), location(lat, long) and #posts (integer). What's one simple way I can calculate the 'distance' between two members of this dataset besides the most naive implementation of Euclidean distance (all I can meaningfully think of at the moment)?</p>
| 73,894 |
<p>I saw a famous review paper about intelligence, and the authors introduced a way to adjust the regression coefficient for predictor error.</p>
<p>As many of you might know, if the predictor has a measurement error or if it has reliability less than 1, the regression coefficient estimate(OLS) is biased towards 0.(less than the true regression coefficient). But I haven't seen the same method applied among the papers published recently.</p>
<p>So, I wonder if it is still valid method to adjust the biased regression coefficient from measurement error(which is using estimates of variance of error term).</p>
<p>If not, why is it not?</p>
| 36,439 |
<p>I want to plot a ROC for my detection algorithm which is used to detect features
in image. I had obtained true positive, false positive and false negative from
the algorithm. There is no true negative in my case. </p>
<pre><code> I had run the algorithm for 6 images so i got 6 number of TP,FP and FN. With
</code></pre>
<p>this how can i plot the ROC curve.</p>
<p>Threshold 1</p>
<pre><code>TP FP FN
1066 70 116
1176 67 201
890 42 129
1040 69 74
677 88 94
1284 73 123
</code></pre>
<p>Threshold 2</p>
<pre><code>TP FP FN
446 41 55
180 15 42
221 16 62
304 23 56
170 39 23
310 31 74
</code></pre>
<p>I am new to ‘R’, so I also need to know how to plot it in R? </p>
| 73,895 |
<p>If time series is tested for Unit Root, (by ADF, PP, KPSS,...) problem is detected with some tests and not found by others. which one is preferred? For example if ADF says us that Unit root is existed and PP says that is not problem, Which one of them would be preferred?</p>
| 73,896 |
<p>I have some trouble interpreting R's <em>RandomForest</em> variable importance measures when using multiple polytomous dummy variables. </p>
<p>Take the following example: I have paired country data, e.g. representing two different parties in conflict ("attacker" and "defender"), with each party representing one of 100+ (<strong><em>n</em></strong>) countries. Given <em>RandomForest</em>'s restriction of 32 levels in categorical variables, I have no other option but to convert the corresponding fields to <strong><em>n-1</em></strong> dummy variables each.</p>
<p>Variable importance is accordingly split by level - being an "attacker" of country X may be more important than being a "defender" of country Y, followed by being an attacker of country Z, and so forth. Add dummies for case grounds and other polytomous properties of interest, and you get a jolly mix of variable levels of varying importance.</p>
<p>However, I'd like to assess variable importance at the level of the original variable, i.e. I'd like to know if (for instance) the "attacker" country of origin <em>as a whole</em> is more or less important to the outcome (win/lose, number of wins/losses, etc.) than the case grounds.</p>
<p>Any suggestion of how I'd best go about that? Can the default "IncNodePurity" (for continuous responses) and "MeanDecreaseGini" (for classifications) be meaningfully summarised, e.g. by computing their means? As I write this explanation I'd be willing to bet they can, though I still have doubts about the impact of only assessing <strong><em>n-1</em></strong> dummies... Any academic publications suggesting preferable options for doing what I'm after? Many thanks!</p>
| 73,897 |
<p>Can one please refer me to a formalism and optimization algorithms of SVM which outputs not only 0/1 but a vector of 0/1's, i.e. I'd like to train multiple classifiers at once for the same input.</p>
<p>Thanks!</p>
| 36,443 |
<p>I have a model where time is the response variable. I'd like to generate confidence intervals for the estimates. I have established that the error in the estimation is roughly normally distributed (it may be more cauchy). The Mean and Median are very different, with the median more accurately representing the middle of the data. Am I allowed to use the median for my confidence interface and if so is there a different method for doing so?</p>
<p>I have reviewed this question: <a href="http://stats.stackexchange.com/questions/21103/confidence-interval-for-median">Confidence interval for median</a> but it is not clear if they are trying to accomplish the same thing I am.</p>
<p>EDIT
The model is for an estimation of the amount of time a process takes to complete. I performed a linear regression and established that the model has a relatively good fit. I then took repeatedly (2000 times) took a random sample of 75% of the original sample and rebuilt the model. I then predicted the time for the remaining 25%, and stored the error in each case. This led to ~90000 results, which roughly follow a normal distribution (or possibly cauchy) I would like to find an estimate for the confidence interval of an individual result, e.g. for one specific process the actual time taken was 46 seconds, and the predicted time taken was 1 minute. I'd like to be able to say with 95% certainty that my estimate is accurate within +- 15 seconds (for example).</p>
| 73,898 |
<p>I have monthly sales data of 500 restaurants for one year. </p>
<p>For the same restaurants, I also have customer defection or dissatisfaction rates. </p>
<p>I want to create a composite score that can rank restaurants based on their performance on sales and customer satisfaction. Something similar to customer life-time value, but as my unit is customer and the time series is only 12 months, I am wondering if there is any suitable technique to derive a composite score to rank restaurants. </p>
| 73,899 |
<p>Given a classifier (SVM) classifying in 2 'classes' (+1 or -1) for prediction purposes. It has an AUC score of 0.28, meaning its success rate is lower than just random predictions.</p>
<p>If I just do the opposite (ie: classifier says it'll be -1, so I'll assume it'll be +1 instead), does that mean my success rate in predicting will be about 72% (1-0.28)?</p>
<p>That doesn't seem very logical to me. Please explain to me how I should interpret this instead and why I can't just do the opposite of the classifier's predictions to get a higher success rate.</p>
| 31,514 |
<p>Inspired by <a href="http://stats.stackexchange.com/questions/1194/practical-thoughts-on-explanatory-vs-predictive-modeling">this post</a> on the difference between explaining and predicting. I want to ask </p>
<ul>
<li>is mixed model <em>primarily</em> used to get better explanation (such as, but not limited to, getting better coefficients and standard errors, or being able to decompose the variation), or is it <em>primarily</em> used to get better prediction?</li>
</ul>
<p>I imagine the answer would be the former (explaining), and if that's the case, </p>
<ul>
<li>does it add any value to prediction?</li>
</ul>
<p>(would appreciate any form of discussion, but would also be delighted to see published references on the issue)</p>
| 73,900 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.