w.stat {CLME} | R Documentation |
Calculates a Williams' type test statistic for a constrained linear mixed effects model.
w.stat(theta, cov.theta, B, A, ...) w.stat.ind(theta, cov.theta, B, A, ...)
theta |
estimated coefficients. |
cov.theta |
covariance matrix of the (unconstrained) coefficients. |
B |
matrix to obtain the global contrast. |
A |
matrix of linear constraints. |
... |
additional arguments, to enable custom test statistic functions. |
See create.constraints
for an example of A
. Argument B
is similar, but defines the global contrast for a Williams' type test statistic. This is the largest hypothesized difference in the constrained coefficients. So for an increasing simple order, the test statistic is the difference between the two extreme coefficients, theta_1 and theta_p1, divided by the standard error (unconstrained). For an umbrella order order, two contrasts are considered, theta_1 to theta_s, and theta_p1 to theta_s, each divided by the appropriate unconstrained standard error. A general way to express this statistic is:
W = max theta_{B[i,2]} - theta_{B[i,1]} / sqrt( VAR( theta_{B[i,2]} - theta_{B[i,1]} ) )
where the numerator is the difference in the constrained estimates, and the standard error in the denominator is based on the covariance matrix of the unconstrained estimates.
The function w.stat.ind
does the same, but uses the A
matrix which defines all of the individual constraints, and returns a test statistic for each constraints instead of taking the maximum.
Output is a numeric value.
See lrt.stat
for information on creating custom test statistics.
theta <- exp(1:4/4) th.cov <- diag(4) X1 <- matrix( 0 , nrow=1 , ncol=4 ) const <- create.constraints( P1=4 , constraints=list(order='simple' , decreasing=FALSE) ) w.stat( theta , th.cov , const$B , const$A ) w.stat.ind( theta , th.cov , const$B , const$A )