LPower: Calculates either the power, sample size, or detectable...

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/powslopes_new2.R View source: R/powslopes_new1.R

Description

Provide two of three parameters (power, sample size, detectable effect) and it supplies the third in a design with repeated measures. It requires the design matrix, and the variance covariance matrix of the repeated measures. It can also take into account of attrition at each of the time points in the model.

Usage

1
2
3
4
LPower(rx_effect = NULL, sample_size = NULL, allocationRatio = c(1, 1), power = NULL,
          contrast=c(rep(0,dim(xMatrix[[1]])[2]-1),1), xMatrix, vMatrix,
          attritionRates = 0, alpha = 0.025,
          simulate=FALSE,nsims=1000,betas=c(rep(0,dim(xMatrix[[1]])[2]-1),1))

Arguments

rx_effect

The size of the effect to be detected. Set to Null if this is the parameter to be calculated.

sample_size

The total sample size of the study.

allocationRatio

The allocation ratio, the allocation to each arm in the study or to each group of patients that have a distinct design matrix.

power

The desired power. Null if the power is to be computed.

contrast

The contrast to be estimated, the default value, which is valid if the xMatrix paramter is a list is c(0,...1). That is the last parameter is the effect of interest.

xMatrix

A list of matricies giving the regression coefficients for each patient group, note that the all must have the same dimensions.

vMatrix

A list of variance covariance matricies for each patient group. A single matrix also will work if all patients groups have the same variance covariance matrix. All must have the same dimensions.

attritionRates

A vector which is the rate of attrition between each visit. Attrition is considered to be exponential between visits.

alpha

The significance level

simulate

Logical, indicating that you also want to run a simulation to calculate the power given the calculated sample size or detectable difference.

nsims

Number of simulations to use

betas

Coefficient value for simulations. Note that betas is rescaled so that the value of the contrast is rx_effect. The code is betas=rep(rx_effect/(matrix(betas,1,m[2])%*%mcontrast),m[2])*betas

Value

A vector giving the detectable difference, sample size and power.

Note

The code to analyse the model used in the simulation is something like mod2 = nlme::gls(y~X1+X2+X3, correlation = corSymm(form = ~visits|subject), weights = varIdent(form =~1|visits), na.action = na.omit, data = df) with test statistic. sum(contrast * mod2$coefficients)/sqrt(t(mcontrast) mod2$varBeta %*% mcontrast)

Author(s)

David A. Schoenfeld

References

Diggle, P., Liang, K.Y. and Zeger, S.L., 1994. Longitudinal data analysis. New York: Oxford University Press, 5, pp 59, ISBN:9780198522843

See Also

randomEffectsMatrix, randomSlopesMatrix

Examples

1
2
3
4
5
#This would be what would be used for an analysis of covariance assuming
#a correlation of 0.3 and a standard deviation of 5.46.
LPower(sample_size=60,power=.8,
     xMatrix=list(matrix(c(1,1,0,1,0,0),2,3),matrix(c(1,1,0,1,0,1),2,3)),
     vMatrix=5.46^2*matrix(c(1,0.3,0.3,1),2,2),attritionRates=0.1)

LPower documentation built on Dec. 12, 2019, 1:06 a.m.

Related to LPower in LPower...