
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.

> 
> ###################################################
> ### code chunk: Chap8init
> ###################################################
> options(width = 65, digits = 5, show.signif.stars = FALSE)
> date()
[1] "Wed Mar 06 17:39:42 2013"
> packageVersion("nlmeU")
[1] '0.30.7'
> 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  
[7] base     
> data(armd, package = "nlmeU")
> 
> ## lm1.form was defined in Chapter 4
> lm1.form <- formula(visual ~ -1 + visual0 + time.f + treat.f:time.f )
> library(nlme)
> 
> ###################################################
> ### code chunk: R8.1
> ###################################################
> (val <- c("12wks" = 0.5, "24wks" = 2))  # delta1 = 1, delta2 = 0.5, delta3 = 2     
12wks 24wks 
  0.5   2.0 
> (fix <- c("52wks" = 3))                 # delta4 = 3 (fixed)
52wks 
    3 
> frm  <- formula(~1|time.f)              # time.f is a stratifying factor
> (vf0 <- 
+    varIdent(value = val,                # Var. function object defined... 
+             fixed = fix,
+             form  = frm)) 
Variance function structure of class varIdent with no parameters, or uninitialized
> (vf0i <- Initialize(vf0, armd))         # ... and initialized
Variance function structure of class varIdent representing
 4wks 12wks 24wks 52wks 
  1.0   0.5   2.0   3.0 
> 
> 
> ###################################################
> ### code chunk: R8.2a
> ###################################################
> coef(vf0i, unconstrained = FALSE, allCoef = TRUE) # All delta coefs
 4wks 12wks 24wks 52wks 
  1.0   0.5   2.0   3.0 
> coef(vf0i, unconstrained = FALSE, allCoef = FALSE)# Varying only
12wks 24wks 
  0.5   2.0 
> 
> 
> ###################################################
> ### code chunk: R8.2b
> ###################################################
> coef(vf0i, unconstrained = TRUE, allCoef = TRUE)  # All delta* coefs
[1] -0.69315  0.69315  1.09861
> coef(vf0i, unconstrained = TRUE, allCoef = FALSE) # Varying (default)
[1] -0.69315  0.69315
> coef(vf0i) <- c(-0.6, 0.7)                        # New coefs assigned   
> coef(vf0i, allCoef = TRUE)                        # All coefs printed
[1] -0.6000  0.7000  1.0986
> 
> 
> ###################################################
> ### code chunk: R8.3
> ###################################################
> summary(vf0i)               # Summary
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | time.f 
 Parameter estimates:
   4wks   12wks   24wks   52wks 
1.00000 0.54881 2.01375 3.00000 
> formula(vf0i)               # Variance function formula
~1 | time.f
> getCovariate(vf0i)          # Variance covariate
NULL
> getGroupsFormula(vf0i)      # Formula for variance strata
~time.f
<environment: 0x00000000053e57f8>
> length(stratum <-           # Length of stratum indicator
+          getGroups(vf0i)) 
[1] 867
> unique(stratum)             # Unique strata
[1] "4wks"  "12wks" "24wks" "52wks"
> stratum[1:6]                # First six observations
[1] "4wks"  "12wks" "4wks"  "12wks" "24wks" "52wks"
> varWeights(vf0i)[3:6]       # Variance weights 1/lambdai:(7.8)
   4wks   12wks   24wks   52wks 
1.00000 1.82212 0.49659 0.33333 
> logLik(vf0i)                # Contribution to the log-likelihood
'log Lik.' -227.83 (df=2)
> 
> ###### sessionInfo() with packages attached
> 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  
[7] base     

other attached packages:
[1] nlme_3.1-103

loaded via a namespace (and not attached):
[1] grid_2.15.0    lattice_0.20-6 tools_2.15.0  
> detach(package:nlme)
> 
> proc.time()
   user  system elapsed 
   0.39    0.04    0.42 
