exponentialq_ function(n,pi1,pi2,beta1,beta2,beta0) { # Test for homogeneity in a two-component exponential sacle mixture. # This is a QUICK test, not requiring the underlying data set itself, # but estimates of the mixture parameters must be in hand. # # Scenario: # H_0: There exists beta_0 such that # p_1 f(x | beta_1) + p_2 f(x | beta_2) # may be written as f(x | beta_0). # H_1: There is no such beta_0. # # Required Inputs: # n is the size of the underlying data set ("sample size"). # pi1, pi2, beta1, beta2 are estimates of the mixture parameters, # which could have been obtained in any way (e.g., method # of moments, unpenalized maximum likelihood, penalized # maximum likelihood). # # Outputs: # dk D-Test statistic, no weighting function # dk.w1 weighting function w_1(x) = x # dk.w2 weighting function w_2(x) = x^2 # pvalue large-sample p-value: # penalized maximum likelihood estimation scheme, no weighting function # pvalue.w1 weighting function w_1(x) = x # pvalue.w2 weighting function w_2(x) = x^2 # If the mixture parameter estimates were obtained by unpenalized # maximum likelihood, use exponentialc.S to get estimated critical values. # # Caveat: # The p-values are based on asymptotic theory that, although presumed # applicable, has not been rigorously justified in the exponential scale # case. The principal difficulty is that one of the regularity conditions # (uniform boundedness) is violated in the exponential scale case, unless # the parameter space is severely restricted. dk0_ beta0/2 + pi1*pi1*beta1/2 + pi2*pi2*beta2/2 dk1_ 2*pi1*beta0*beta1/(beta0+beta1)+2*pi2*beta0*beta2/(beta0+beta2) dk2_ 2*pi1*pi2*beta1*beta2/(beta1+beta2) dk_ dk0 - dk1 + dk2 # weighting function w_1(x) = x dknew0_ 1/4 + pi1*pi1/4 + pi2*pi2/4 dknew1_ 2*pi1*beta0*beta1/((beta0+beta1)^2)+2*pi2*beta0*beta2/((beta0+beta2)^2) dknew2_ 2*pi1*pi2*beta1*beta2/((beta1+beta2)^2) dk.w1_ dknew0 - dknew1 + dknew2 # weighting function w_2(x) = x^2 dk00_ -1*-1*beta0*beta0/(beta0+beta0)^3 dk01_ -1*pi1*beta0*beta1/(beta0+beta1)^3 dk02_ -1*pi2*beta0*beta2/(beta0+beta2)^3 dk10_ pi1*-1*beta1*beta0/(beta1+beta0)^3 dk11_ pi1*pi1*beta1*beta1/(beta1+beta1)^3 dk12_ pi1*pi2*beta1*beta2/(beta1+beta2)^3 dk20_ pi2*-1*beta2*beta0/(beta2+beta0)^3 dk21_ pi2*pi1*beta2*beta1/(beta2+beta1)^3 dk22_ pi2*pi2*beta2*beta2/(beta2+beta2)^3 dk.w2_ 2*(dk00+dk01+dk02+dk10+dk11+dk12+dk20+dk21+dk22) pvalue_ 'LARGE' s_ (16/3)*(1/beta0)*n*dk if (s > .2749959) pvalue_ 0.5-0.5*pchisq(s,1) pvalue.w1_ 'LARGE' s.w1_ (32/3)*n*dk.w1 if (s.w1 > .2749959) pvalue.w1_ 0.5-0.5*pchisq(s.w1,1) pvalue.w2_ 'LARGE' s.w2_ (32/5)*beta0*n*dk.w2 if (s.w2 > .2749959) pvalue.w2_ 0.5-0.5*pchisq(s.w2,1) return(dk,dk.w1,dk.w2,pvalue,pvalue.w1,pvalue.w2) result }