Last data update: 2014.03.03

R: Williams' Type Test Statistic.
w.statR Documentation

Williams' Type Test Statistic.

Description

Calculates a Williams' type test statistic for a constrained linear mixed effects model.

Williams' type statistic (individual)

Usage

w.stat(theta, cov.theta, B, A, ...)

w.stat.ind(theta, cov.theta, B, A, ...)

Arguments

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.

Details

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.

Value

Output is a numeric value.

Note

See lrt.stat for information on creating custom test statistics.

Examples

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 )

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(CLME)
Loading required package: shiny
Loading required package: lme4
Loading required package: Matrix

Attaching package: 'CLME'

The following object is masked from 'package:lme4':

    VarCorr

The following object is masked from 'package:stats':

    sigma

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CLME/w.stat.Rd_%03d_medium.png", width=480, height=480)
> ### Name: w.stat
> ### Title: Williams' Type Test Statistic.
> ### Aliases: w.stat w.stat.ind
> 
> ### ** Examples
> 
> 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 )
Theta 4 - Theta 1 
         1.014172 
> 
> w.stat.ind( theta , th.cov , const$B , const$A )
[1] 0.2578789 0.3311231 0.4251704
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>