$p$-value for non-standard asymptotics Suppose I have an asymptotic result like 
$$\sqrt{n}(T_n - \theta) \overset{D}{\to} \sum_{i=1}^k \lambda_i X_i$$
where $X_i$ are independent $\chi^2_1$. i.e. some test statistics $T_n$ is asymptotically the linear combination of weighted $\chi_1^2$ variables. Can I get $p$-values from such a result? 
 A: Assuming you know the $\lambda_i$, simulation is feasible.
Consider
library(MASS)
k <- 3
lambda <- c(.2,.3,.4) # pick your lambdas here

reps <- 100000
distr <- rep(NA,reps)
for (i in 1:reps){
     distr[i] <- sum(lambda*rchisq(k,1))
}
distr <- sort(distr)

teststat <- 2 # pick your teststat here
pvalue <- which.min(abs(teststat-distr))/reps # assuming a left-tailed test

So effectively, we "plug" the test statistic teststat into the empirical cdf, i.e., find the proportion of realizations from the simulation that (which, for reps large, precisely estimates the probability that) a random variable from the null distribution takes a value less (we consider a left-tailed test here, with obvious modifications to other alternatives) than the test statistic - i.e., the $p$-value:

A: There are two useful approximations and at least three computations that would be exact with infinite precision arithmetic. 
Let's call the distribution $Q(\lambda)$. And write $\bar\lambda$ for the mean of $\lambda$ and $\tau$ for the mean of $\lambda^2$.
The two approximations are implemented in pchisqsum in the R survey package
The Satterthwaite approximation is overwhelmingly the most common way this distribution is evaluated in practice.  It approximates $Q(\lambda)$ by $a\chi^2_d$ where $a$ and $d$ are chosen to get the right mean and variance. Specifically, $a=\tau/\bar\lambda$, and $d=k\bar\lambda^2/\tau$.  Until you get far out in the right tail, the Satterthwaite approximation is far more accurate than it has any right to be. Also, in the common scenario where the $\lambda$ are eigenvalues of a matrix, you don't need the eigendecomposition: you can compute the Satterthwaite approximation in $O(k^2)$ time for general matrices and faster for specially structured matrices.
The saddlepoint approximation is less accurate for modest tail probabilities, but much more accurate for small ones -- it has uniformly bounded relative error, and the error decreases as $k$ increases.  It's the only one that works for very small tail probabilities with ordinary double-precision arithmetic.
There are two fairly old computational methods that work well. These are both impemented in the CompQuadForm package for R.  They both get catastrophic rounding error as the right tail probability approaches machine epsilon and they slow down for large $k$.


*

*Farebrother's method represents the probability as an infinite series in Beta functions. It requires the $\lambda$s to be positive, and for large $k$ the biggest one can't be that much larger than the rest. You might think negative $\lambda$ isn't important, but it lets you do the same trick with $F$ distributions having the same denominator

*Davies's method takes advantage of the fact that you can just write down the characteristic function, which can then be inverted by numerical integration 

*There's a third computational method, due to Bausch, that has very good error/effort bounds in extreme settings as long as you have arbitrary precision arithmetic. He invented it for a problem in string theory. It really needs multiple-precision arithmetic.
There are also some improvements on the Satterthwaite approximation


*

*matching more than two moments.  In my opinion these aren't terribly appealing: if you have all the $\lambda$s you might as well use Davies's or Farebrother's methods.  If $k$ is large and you  only have the matrix whose eigenvalues are the $\lambda$s,  these methods are no faster than a full eigendecomposition.

*leading-eigenvalue approximation. When $k$ is large,  approximate the sum as $\left(\sum_{i<m}\lambda_i Z_i\right)+a_m\chi^2_{d_m}$, where the last term is a Satterthwaite approximation with the $k-m$ smallest eigenvalues. 
A student and I reviewed these in the large $k$ case; we have a blog post and a paper.
