Package 'nlmeU'

Title: Datasets and Utility Functions Enhancing Functionality of 'nlme' Package
Description: Datasets and utility functions enhancing functionality of nlme package. Datasets, functions and scripts are described in book titled 'Linear Mixed-Effects Models: A Step-by-Step Approach' by Galecki and Burzykowski (2013). Package is under development.
Authors: Andrzej Galecki [email protected], Tomasz Burzykowski [email protected]
Maintainer: Andrzej Galecki <[email protected]>
License: GPL (>=2)
Version: 0.70-9
Built: 2024-11-26 03:06:02 UTC
Source: https://github.com/agalecki/nlmeu

Help Index


Datasets and auxiliary functions for Galecki and Burzykowski book 2013.

Description

Datasets and auxiliary functions for Galecki and Burzykowski book (2013).

Details

Datasets and auxiliary functions for Galecki and Burzykowski book (2013). Package under development.

Author(s)

Andrzej Galecki [email protected], Tomasz Burzykowski [email protected]


armd Data (867 x 8)

Description

Data from Age-Related Macular Degeneration (ARMD) clinical trial

Format

The armd data frame has 867 rows and 8 columns. It contains data for n=234 subjects stored in a long format with up to four rows for one subject.

subject

a factor with 234 levels 1, 2, 3, 4, 6, ..., 240

treat.f

a factor with 2 levels Placebo, Active

visual0

an integer vector with values ranging from 20 to 85

miss.pat

a factor with 8 levels ----, ---X, --X-, --XX, -XX-, ..., X-XX

time.f

a factor with 4 levels 4wks, 12wks, 24wks, 52wks

time

a numeric vector with values 4, 12, 24, 52

visual

an integer vector with values ranging from 3 to 85

tp

a numeric vector with values 1, 2, 3, 4 corresponding to time points 4, 12, 24, 52, respectively

Details

The ARMD data arise from a randomized multi-center clinical trial comparing an experimental treatment (interferon-alpha) versus placebo for patients diagnosed with ARMD.

Source

Pharmacological Therapy for Macular Degeneration Study Group (1997). Interferon alpha-IIA is ineffective for patients with choroidal neovascularization secondary to age-related macular degeneration. Results of a prospective randomized placebo-controlled clinical trial. Archives of Ophthalmology, 115, 865-872.

See Also

armd0, armd.wide

Examples

summary(armd)

armd.wide Data (240 x 10)

Description

Data from Age-Related Macular Degeneration (ARMD) clinical trial

Format

The armd.wide data frame has 240 rows and 10 columns. Data are stored in wide format with each row corresponding to one subject.

subject

a factor with 240 levels 1, 2, 3, 4, 5, ..., 240

lesion

an integer vector with values 1, 2, 3, 4

line0

an integer vector with values ranging from 5 to 17

visual0

an integer vector with values of visual acuity measured at baseline ranging from 20 to 85

visual4

an integer vector with values of visual acuity measured at 4 weeks ranging from 12 to 84

visual12

an integer vector with values of visual acuity measured at 12 weeks ranging from 3 to 85

visual24

an integer vector with values of visual acuity measured at 24 weeks ranging from 5 to 85

visual52

an integer vector with values of visual acuity measured at 52 weeks from 4 to 85

treat.f

a factor with 2 levels Placebo, Active

miss.pat

a factor with 9 levels ----, ---X, --X-, --XX, -XX-, ...,XXXX

Details

The ARMD data arise from a randomized multi-center clinical trial comparing an experimental treatment (interferon-alpha) versus placebo for patients diagnosed with ARMD.

Source

Pharmacological Therapy for Macular Degeneration Study Group (1997). Interferon alpha-IIA is ineffective for patients with choroidal neovascularization secondary to age-related macular degeneration. Results of a prospective randomized placebo-controlled clinical trial. Archives of Ophthalmology, 115, 865-872.

See Also

armd, armd0

Examples

summary(armd.wide)

armd0 Data (1107 x 8)

Description

Data from Age-Related Macular Degeneration (ARMD) clinical trial

Format

The armd0 data frame has 1107 rows and 8 columns. It contains data for n=240 subjects stored in a long format with up to five rows for one subject.

subject

a factor with 240 levels 1, 2, 3, 4, 5, ...

treat.f

a factor with 2 levels Placebo, Active

visual0

an integer vector with values from 20 to 85

miss.pat

a factor with 9 levels ----, ---X, --X-, --XX, -XX-, ...

time.f

a factor with 5 levels Baseline, 4wks, 12wks, 24wks, 52wks

time

a numeric vector with values from 0 to 52

visual

an integer vector with values from 3 to 85

tp

a numeric vector with values from 0 to 4

Details

The ARMD data arise from a randomized multi-center clinical trial comparing an experimental treatment (interferon-alpha) versus placebo for patients diagnosed with ARMD.

Source

Pharmacological Therapy for Macular Degeneration Study Group (1997). Interferon alpha-IIA is ineffective for patients with choroidal neovascularization secondary to age-related macular degeneration. Results of a prospective randomized placebo-controlled clinical trial. Archives of Ophthalmology, 115, 865-872.

See Also

armd, armd.wide


fcat Data (4851 x 3)

Description

Data from Flemish Community Attainment-Targets (FCAT) Study

Format

The fcat data frame has 4851 rows and 3 columns

target

a factor with 9 levels T1(4), T2(6), T3(8), T4(5), T5(9), ..., T9(5)

id

a factor with 539 levels 1, 2, 3, 4, 5, ..., 539

scorec

an integer vector with values from 0 to 9

Details

An educational study, in which elementary school graduates were evaluated with respect to reading comprehension in Dutch. Pupils from randomly selected schools were assessed for a set of nine attainment targets. The dataset is an example of grouped data, for which the grouping factors are crossed.

Source

Janssen, R., Tuerlinckx, F., Meulders, M., & De Boeck, P. (2000). A hierarchical IRT model for criterion-referenced measurement. Journal of Educational and Behavioral Statistics. 25(3), 285.

Examples

summary(fcat)

Calculates contribution of one subject to the log-likelihood

Description

This function is generic; method functions can be written to handle specific classes of objects.

Usage

logLik1(modfit, dt1, dtInit)

Arguments

modfit

an object representing model fitted to data using ML estimation.

dt1

a data frame with data for one subject, for whom the log-likelihood function is to be evaluated

dtInit

an optional auxiliary data frame.

Value

numeric scalar value representing contribution of a given subject to the overall log-likelihood returned by logLik() function.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

References

???

Examples

require(nlme)
  logLik(fm1 <- lme(distance ~ age, data = Orthodont)) # random is ~ age
  dt1 <- subset(Orthodont, Subject == "M01")
  logLik1(fm1, dt1)

Calculates contribution of one subject to the log-likelihood for lme object

Description

This is method for logLik1() generic function.

Usage

## S3 method for class 'lme'
 logLik1(modfit, dt1, dtInit)

Arguments

modfit

an lme object representing model fitted using maximum likelihood.

dt1

a data frame with data for one subject, for whom the log-likelihood function is to be evaluated

dtInit

an optional auxiliary data frame.

Details

Calculates profile likelihood (with beta profiled out) for *one* subject. Data with *one* level of grouping only. correlation component in modelStruct not implemented.

Value

numeric scalar value representing contribution of a given subject to the overall log-likelihood returned by logLik() function applied to lme object defined by modfit argument.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

Examples

require(nlme)
lm3.form <- visual ~ visual0 + time + treat.f
(fm16.5ml <-                                # M16.5
   lme(lm3.form,
   random = list(subject = pdDiag(~time)),
   weights = varPower(form = ~time),
   data = armd, method = "ML"))
 df1 <- subset(armd, subject == "1")       # Panel R20.7
 logLik1(fm16.5ml, df1)

Extract pattern of missing data

Description

This function allows to compactly present pattern of missing data in a given vector/matrix/data frame or combination of thereof.

Usage

missPat(..., symbols = c("X", "-"), collapse = "",
    missData = FALSE)

Arguments

...

one or more vectors/matrices/data frames. They need to be compatible for columnwise binding.

symbols

vector containing two single characters used to indicate NA and remaining values. By defualt it has values: X and -.

collapse

an optional character string. It is used in the internal call paste() function to separate the results. Rarely used. By default set to NULL

missData

logical. If TRUE data frame with pattern of missing values is saved in missData attribute of the vector returned by this function.

Value

character vector with as many elements as length of vectors(s)/number of rows in matrices and/or data frames in ...{} argument(s). Attribute cnames contains names of vectors/columns/variables. Optional attribute missData contains data frame with missing pattern.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

Examples

dtf <- subset(armd.wide,
             select = c(visual12, visual24, visual52))
missPat(dtf, symbols = c("?","+"))

prt Data (2471 x 9)

Description

Data from a Progressive Resistance Randomized Trial.

Format

The prt data frame has 2471 rows and 9 columns. It contains data for n = 63 subjects. Each subject underwent muscle biopsy before and after intervention. Data are stored in a long format with each record corresponding to one muscle fiber. There are two types of muscle fibers: Type 1 and Type 2. Dependent variables: specific force and isometric force are measured pre- and post intervention.

id

a factor with 63 levels 5, 10, 15, 20, 25, ..., 520 (subject id)

prt.f

a factor with 2 levels High, Low, i.e. training (intervention) intensity

age.f

a factor with 2 levels Young, Old (stratifying variable)

sex.f

a factor with 2 levels Female, Male (stratifying variable)

bmi

a numeric vector with values of BMI at baseline ranging from 18.36 to 32.29

iso.fo

a numeric vector with values of isometric force ranging from 0.16 to 2.565

spec.fo

a numeric vector with values of specific force ranging from 80.5 to 290

occ.f

a factor with 2 levels Pre, Pos, i.e. pre- and post-intervention.

fiber.f

a factor with 2 levels Type 1, Type 2, i.e. Type 1 and Type 2 muscle fiber.

Details

Data frame prt was obtained by merging prt.subjects and prt.fiber.

Source

Claflin, D.R., Larkin, L.M., Cederna, P.S., Horowitz, J.F., Alexander, N.B., Cole, N.M., Galecki, A.T., Chen, S., Nyquist, L.V., Carlson, B.M., Faulkner, J.A., & Ashton-Miller, J.A. (2011) Effects of high- and low-velocity resistance training on the contractile properties of skeletal muscle fibers from young and older humans. Journal of Applied Physiology, 111, 1021-1030.

See Also

prt.fiber, prt.subjects

Examples

summary(prt)

prt.fiber Data (2471 x 5)

Description

Data from a Progressive Resistance Randomized Trial.

Format

The prt.fiber data frame has 2471 rows and 5 columns. Each row in the data corresponds to one muscle fiber collected during muscle biopsy. See prt data frame for the description of the study design.

id

a factor with 63 levels 5, 10, 15, 20, 25, ..., 520

iso.fo

a numeric vector with values of isometric force ranging from 0.16 to 2.565

spec.fo

a numeric vector with values of specific force ranging from 80.5 to 290

occ.f

a factor with 2 levels Pre, Pos, i.e. pre- and post- intervention

fiber.f

a factor with 2 levels Type 1, Type 2, i.e. Type 1 and Type 2 muscle fiber.

Details

PRT trial was aimed for devising evidence-based methods for improving and measuring the mobility and muscle power of elderly men and women

Source

Claflin, D.R., Larkin, L.M., Cederna, P.S., Horowitz, J.F., Alexander, N.B., Cole, N.M., Galecki, A.T., Chen, S., Nyquist, L.V., Carlson, B.M., Faulkner, J.A., & Ashton-Miller, J.A. (2011) Effects of high- and low-velocity resistance training on the contractile properties of skeletal muscle fibers from young and older humans. Journal of Applied Physiology, 111, 1021-1030.

See Also

prt, prt.subjects

Examples

summary(prt.fiber)

prt.subjects Data (63 x 5)

Description

Data prt.subjects ...

Format

The prt.subjects data frame has 63 rows and 5 columns

id

a factor with 63 levels 5, 10, 15, 20, 25, ...

prt.f

a factor with 2 levels High, Low

age.f

a factor with 2 levels Young, Old

sex.f

a factor with 2 levels Female, Male

bmi

a numeric vector with values from 18.4 to 32.3

Details

The working hypothesis was that a 12-week program of PRT would increase: (a) the power output of the overall musculature associated with movements of the ankles, knees, and hips; (b) the cross-sectional area and the force and power of permeabilized single fibers obtained from the vastus lateralis muscle; and (c) the ability of young and elderly men and women to safely arrest standardized falls. The training consisted of repeated leg extensions by shortening contractions of the leg extensor muscles against a resistance that was increased as the subject trained using a specially designed apparatus

Source

Claflin, D.R., Larkin, L.M., Cederna, P.S., Horowitz, J.F., Alexander, N.B., Cole, N.M., Galecki, A.T., Chen, S., Nyquist, L.V., Carlson, B.M., Faulkner, J.A., & Ashton-Miller, J.A. (2011) Effects of high- and low-velocity resistance training on the contractile properties of skeletal muscle fibers from young and older humans. Journal of Applied Physiology, 111, 1021-1030.

Examples

summary(prt.subjects)

Calculates power based on a model fit

Description

This function is generic; method functions can be written to handle specific classes of objects.

Usage

Pwr(object, ...)

Arguments

object

an object containing the results returned by a model fitting function (e.g., lme).

...

some methods for this generic function may require additional arguments.

Value

numeric scalar value.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

See Also

Pwr.lme

Examples

## Not run: 
  Pwr (fm1)

## End(Not run)

Performs power calculations

Description

This is method for Pwr() generic function. It works fine for an example given in the book. It may require additional testing, especially for post-hoc power analysis

Usage

## S3 method for class 'lme'
 Pwr(object, ...,
    type = c("sequential", "marginal"), Terms, L,
    verbose = FALSE, sigma, ddf = numeric(0), alpha = 0.05,
    altB = NULL, tol = 1e-10)

Arguments

object

an object containing lme fit, which provides information needed for power calculations

...

some additional arguments may be required.

type

an optional character string specifying the type of sum of squares to be used in F-tests needed for power calculations. Syntax is the same as for anova.lme() in nlme package.

Terms

an optional integer or character vector specifying which terms in the model should be jointly tested to be zero using a Wald F-test. See anova.lme in nlme package for details.

L

an optional numeric vector or array specifying linear combinations of the coefficients in the model that should be tested to be zero. See anova.lme in nlme package for details.

verbose

an optional logical value. See anova.lme in nlme package for details.

sigma

numeric scalar value.

ddf

numeric scalar value. Argument can be used to redefine default number of denominator degrees of freedom

alpha

numeric scalar value. By default 0.05.

altB

matrix/vector containing alternative values for beta parameters

tol

numeric scalar value.

Value

a data frame inheriting from class Pwr.lme

Author(s)

Andrzej Galecki and Tomasz Burzykowski

See Also

anova.lme


Executes scripts from GB book

Description

Default call of the function without arguments, prints a list of available scripts.

Usage

runScript(script = NA, package = "nlmeU",
    subdir = "scriptsR2.15.0", echo = TRUE)

Arguments

script

character string containing name of the script to be executed. By default is set to NA.

package

character string containing package name. By default nlmeU.

subdir

subdirectory containing scripts. By default: scriptsR15.0.

echo

logical. Used by source function. By default set to TRUE.

Value

Script is executed and results are printed.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

Examples

runScript()

Extract scale parameter sigma from a model fit

Description

This function is generic; method functions can be written to handle specific classes of objects.

Usage

sigma(object, ...)

Arguments

object

an object for which scale parameter can be extracted.

...

some methods for this generic function may require additional arguments.

Value

numeric scalar value.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

Examples

## sigma (fm1)

SIIdata Data (1190 x 12)

Description

Data from Study of Instructional Improvement Project

Format

The SIIdata data frame has 1190 rows and 12 columns. The dataset includes results for 1190 first grade pupils sampled from 312 classrooms in 107 schools.

sex

a factor with 2 levels M, F,i.e. males and females, resepectively

minority

a factor with 2 levels Mnrt=No, Mnrt=Yes. An indicator variable for the minority status

mathkind

an integer vector with values from 290 to 629. This is pupil's math score in the spring of the kindergarten year

mathgain

an integer vector with values from -110 to 253. Number represents pupil's gain in the math achievement score from the spring of kindergarten to the spring of first grade

ses

a numeric vector with values from -1.61 to 3.21. Value represents socioeconomical status

yearstea

a numeric vector with values from 0 to 40. It is number of years of teacher's experience in teaching in the first grade

mathknow

a numeric vector with values from -2.5 to 2.61. Number represents teacher's knowledge of the first-grade math contents (higher values indicate a higher knowledge of the contents)

housepov

a numeric vector containing proportion of households in the nneighborhood of the school below the poverty level with values ranging from 0.012 to 0.564

mathprep

a numeric vector with values from 1 to 6. Contains the number of preparatory courses on the first-grade math contents and methods followed by the teacher.

classid

a factor with 312 levels 1, 2, 3, 4, 5, ..., 312. Classroom's id

schoolid

a factor with 107 levels 1, 2, 3, 4, 5, ..., 107. School's id

childid

a factor with 1190 levels 1, 2, 3, 4, 5, ..., 1190. Pupil's id

Details

The SII Project was carried out to assess the math achievement scores of first- and third-grade pupils in randomly selected classrooms from a national US sample of elementary schools (Hill et al, 2005). Data were also analyzed in West et al, 2007. The outcome of interest is mathgain variable. Data were created based on classroom data from WWGbook package

Source

Hill, H., Rowan, B., and Ball, D. (2005). Effect of teachers mathematical knowledge for teaching on student achievement. American Educational Research Journal, 42, 371-406.

West, B. T.,Welch, K. B., and Galecki, A. T. (2007). Linear Mixed Models: A Practical Guide Using Statistical Software. Chapman and Hall/CRC.

Examples

summary(SIIdata)

Simulates values of the dependent variable based on a model fit

Description

This function is generic; method functions can be written to handle specific classes of objects.

Usage

simulateY(object, nsim = 1, seed = NULL, ...,
    verbose = FALSE, sigma)

Arguments

object

an object with a model fit for which dependent variable is to be simulated.

nsim

number of simulations. nsim = 1 by default.

seed

integer scalar used to initiate random numbers generator.

...

some methods for this generic function may require additional arguments.

verbose

logical. If TRUE basic information about arguments is provided. By default set to FALSE.

sigma

numeric scalar. Allows to perform simulations employing alternative value of the scale parameter.

Value

numeric matrix. Number of columns determined by nsim argument.

Author(s)

Andrzej Galecki and Tomasz Burzykowski

Examples

## simulateY (fm1)