
R version 2.15.0 (2012-03-30)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (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.

> date()
[1] "Wed Mar 06 18:58:58 2013"
> ## See R20.15a
> npg <- 20 # No of subjects per group
> subject <- 1:(2*npg) # Subjects' ids
> treat.f <- gl(2, npg, labels = c("Placebo", "Active"))
> dts <- data.frame(subject, treat.f) # Subject-level data
> dtL <-
+   list(time = c(4, 12, 24, 52),
+   subject = subject)
>   dtLong <- expand.grid(dtL) # "Long" format
>   mrgDt <- merge(dtLong, dts, sort = FALSE) # Merged
>   exmpDt <-
+   within(mrgDt,
+   {
+   m0 <- 75 - 0.1 * time # Under H0                      # Changed from 65 to 75 (Feb. 2013)
+   mA <- 85 - 0.1 * time # Under HA
+   mA <- ifelse(treat.f %in% "Active", mA, m0)
+   })
> 
> ## See R20.16a
> data(armd, package = "nlmeU")
> library(nlme)
> D0 <- diag(c(100, 0.09)) 
> sgma <- 5 
> (D <- D0/(sgma*sgma)) # D
     [,1]   [,2]
[1,]    4 0.0000
[2,]    0 0.0036
> (pd1 <- pdDiag(D, form = ~time, data = armd))
Positive definite matrix structure of class pdDiag representing
            (Intercept)   time
(Intercept)           4 0.0000
time                  0 0.0036
> (vF <- varPower(form = ~time, fixed = 0.15))
Variance function structure of class varPower representing
power 
 0.15 
> 
> ## See R20.16b
> cntrl <-
+   lmeControl(maxIter = 0, msMaxIter = 0, niterEM = 0,
+              returnObject = TRUE, opt = "optim")
> fmA <-
+    lme(mA ~ time + treat.f,
+        random = list(subject = pd1),
+        weights = vF,
+        data = exmpDt,
+        control = cntrl)
> fixef(fmA)
  (Intercept)          time treat.fActive 
         75.0          -0.1          10.0 
> 
> detach(package:nlme)      
> 
> library(nlmeU)
> sigma(fmA)
[1] 9.974941e-15
> Pwr(fmA, sigma = sgma, L = c("treat.fActive" = 1)) 
Power calculations for a linear combination: 
treat.fActive 
            1 
  numDF denDF  F-value       nc  Power
1     1    38 8.043445 8.043445 0.7892
> 
> dif <- 10
> dim(dif) <- c(length(dif), 1)
> colnames(dif) <- "treat.fActive"
> dtF <- Pwr(fmA, sigma = sgma,
+     L = c("treat.fActive" = 1), altB = dif)
> dtF
  (Intercept) time treat.fActive     Power       nc    Fcrit   Fvalue denDF
1          75 -0.1            10 0.7892477 8.043445 4.098172 8.043445    38
  numDF
1     1
> 
> 
> packageVersion("nlme")
[1] '3.1.103'
> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=C                          
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] nlmeU_0.30-7

loaded via a namespace (and not attached):
[1] grid_2.15.0    lattice_0.20-6 nlme_3.1-103   tools_2.15.0  
> detach(package:nlmeU)
> 
> 
> 
> 
> proc.time()
   user  system elapsed 
   0.48    0.04    0.51 
