Learn R Programming

CLME (version 1.0-1)

resid.boot: Obtain Residual Bootstrap

Description

Generates bootstrap samples of the data vector.

Usage

resid.boot(Y, X1, X2 = NULL, U = NULL, 
        Nks = dim(X1)[1], Qs = dim(U)[2], constraints,
        nsim = 1000, mq.phi = NULL , seed=NULL)

Arguments

Y
$N \times 1$ vector of response data.
X1
$N \times p_1$ design matrix.
constraints
list of constraints. Attempts to call create.constraints if element A is NULL.
X2
optional. $N \times p_2$ matrix of covariates.
U
optional. $N \times c$ matrix of random effects.
Nks
optional. $K \times 1$ vector of group sizes.
Qs
optional. $Q \times 1$ vector of group sizes for random effects.
nsim
optional. Number of bootstrap samples to generate.
mq.phi
MINQUE estimates of variance parameters. Automatically estimated if mq.phi=NULL.
seed
optional. Set the seed for the RNG.

Value

  • Output is $N \ times nsim$ matrix, where each column is a bootstrap sample of the response data Y.

References

Farnan, L., Ivanova, A., and Peddada, S. D. (2014). Linear Mixed Efects Models under Inequality Constraints with Applications. PLOS ONE, 9(1). e84778. doi: 10.1371/journal.pone.0084778 http://www.plosone.org/article/info:doi/10.1371/journal.pone.0084778

See Also

CLME-package, constrained.lme

Examples

Run this code
set.seed( 42 )

n  <- 5
P1 <- 5

X1 <- diag(P1) %x% rep(1,n)
X2 <- as.matrix( rep(1,P1) %x% runif(n , 0,2) )
U  <- rep(1,P1) %x% diag(n)
X  <- as.matrix( cbind(X1,X2) )

tsq <- 1
ssq <- 0.7

Nks <- dim(X1)[1]
Qs  <- dim(U)[2]

xi <- rnorm( sum(Qs)  , 0 , rep(sqrt(tsq) , Qs)  )
ep <- rnorm( sum(Nks) , 0 , rep(sqrt(ssq) , Nks) )  

thetas <- c(2 , 3 , 3, 3 , 4 , 2 )
Y      <- X%*%thetas + U%*%xi + ep
const  <- create.constraints( X1=X1 , X2=X2 ,
          constraints=list(order='simple' , decreasing=FALSE) )

boot.sample <- resid.boot( Y=Y, X1=X1, X2=X2, U=U, nsim=10 , constraints=const  )

Run the code above in your browser using DataLab