Package {bild}


Type: Package
Title: A Package for BInary Longitudinal Data
Version: 1.3-0
Date: 2026-10-14
Description: Performs logistic regression for binary longitudinal data, allowing for serial dependence among observations from a given individual and a random intercept term. Estimation is via maximization of the exact likelihood of a suitably defined model. Missing values and unbalanced data are allowed, with some restrictions. M. Helena Goncalves et al. (2012) <doi:10.18637/jss.v046.i09>.
Encoding: UTF-8
NeedsCompilation: yes
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
LazyData: true
Depends: R (≥ 3.1.0), stats, graphics, grDevices, utils, methods
Imports: ggplot2, tibble, generics
Suggests: patchwork
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
Collate: 'autoplot.bild.R' 'bild_main.R' 'classes_and_generics.R' 'data.R' 'gradlogL_bin0.R' 'gradlogL_bin0I.R' 'gradlogL_bin1.R' 'gradlogL_bin1I.R' 'gradlogL_bin2.R' 'gradlogL_bin2I.R' 'logL_bin0.R' 'logL_bin0I.R' 'logL_bin0I_aux.R' 'logL_bin0_aux.R' 'logL_bin1.R' 'logL_bin1I.R' 'logL_bin1I_aux.R' 'logL_bin1_aux.R' 'logL_bin2.R' 'logL_bin2I.R' 'logL_bin2I_aux.R' 'logL_bin2_aux.R' 'methods_complex.R' 'methods_getters.R' 'num_InfoI.R' 'num_info.R' 'plot_bild_missing.R' 'predict.bild.R' 'zzz.R'
Packaged: 2026-10-14 17:17:06 UTC; PC
Author: M. Helena Goncalves ORCID iD [aut, cre], M. Salome Cabral [aut], Adelchi Azzalini [aut], R. Piessens [ctb] (Author of Fortran-77 subroutines from Quadpack), E. de Doncker [ctb] (Author of Fortran-77 subroutines from Quadpack)
Maintainer: M. Helena Goncalves <mhgoncal@ualg.pt>
Repository: CRAN
Date/Publication: 2026-10-14 18:12:07 UTC

bild: A Package for BInary Longitudinal Data

Description

Performs logistic regression for binary longitudinal data, allowing for serial dependence among observations from a given individual and a random intercept term. Estimation is via maximization of the exact likelihood of a suitably defined model. Missing values and unbalanced data are allowed, with some restrictions. M. Helena Goncalves et al. (2012) doi: 10.18637/jss.v046.i09.

Author(s)

Maintainer: M. Helena Goncalves mhgoncal@ualg.pt (ORCID)

Authors:

Other contributors:


Airpollution dataset

Description

This example is a subset of data from the Six Cities study, a longitudinal study of the health effects of air pollution (Ware, J. H. et al., 1984).

Usage

airpollution

Format

A data frame with 128 observations on the following 5 variables:

id

identifies the number of the individual profile, containing 32 individual profiles.

wheeze

a numeric vector that identifies the wheezing status (1="yes", 0="no").

age

a numeric vector corresponding to the age in years since the child's 9th birthday.

smoking

a factor that identifies if the mother smokes (1="smoke", 0="no smoke").

counts

a numeric vector corresponding to the replications of each individual profile.

Details

The data set presented by Fitzmaurice and Laird (1993) contains complete records on 537 children from Steubenville, Ohio. The repeated binary response is the wheezing status of a child. Maternal smoking status was determined in the first interview and treated as a time-independent covariate.

Source

Fitzmaurice, G. M. and Laird, N. M. (1993). A Likelihood-Based Method for analyzing Longitudinal Binary Response. Biometrika, 80, 141-51.

Examples

data(airpollution)
str(airpollution)

# Dependence="MC2"
air2 <- bild(wheeze~age+smoking, data=airpollution, time="age",
             aggregate=smoking, dependence="MC2")
summary(air2)
getAIC(air2)
getLogLik(air2)

# Base graphics diagnostics
plot(air2)

# ggplot2-based diagnostics
library(ggplot2)
autoplot(air2, which = 1) # Residuals vs Fitted values
autoplot(air2, which = 2) # Standardized Residuals vs Time
autoplot(air2, which = 5) # Estimated Parametric Profiles


# Multi-panel diagnostic plots using patchwork
library(patchwork)
(autoplot(air2, which = 5) + autoplot(air2, which = 2)) /
  (autoplot(air2, which = 1) + autoplot(air2, which = 3))

# Dependence="MC2R"
air2r <- bild(wheeze~age+smoking, data=airpollution, time="age",
              aggregate=smoking, dependence="MC2R")
summary(air2r)

# Compare base plot with autoplot for individual profiles
plot(air2r, which=6, subSET=smoking=="0", main="smoking==0", ident=TRUE) 
autoplot(air2r, which=6, subSET=smoking=="0", ident=TRUE)


Analysis of Deviance for 'bild' objects

Description

Computes an analysis of deviance table for two or more fitted model objects of class bild.

Usage

## S4 method for signature 'bild'
anova(object, ..., test = TRUE, correct = FALSE)

Arguments

object

An object of class bild.

...

Additional objects of class bild.

test

Logical. If TRUE, the likelihood ratio test is performed. Default is TRUE.

correct

Logical. If TRUE, a correction for the likelihood ratio test is applied (e.g., for mixture models). Default is FALSE.

Details

Setting correct = TRUE is used to test the presence of a random intercept term; the solution proposed by Self and Liang (1987) is adopted for the p-value.

Note

The comparison between two models by anova will only be valid if they are fitted to the same dataset.

References

Self, Steven G. and Liang, Kung-Yee (1987). Asymptotic properties of maximum likelihood estimators and likelihood ratio tests under nonstandard conditions. Journal of the American Statistical Association, 82, 605-610.

Examples


data(locust)
loc1 <- bild::bild(move~(time+I(time^2))*feed*sex, data=locust, dependence="MC1")
loc2 <- bild::bild(move~(time+I(time^2))*feed, data=locust, dependence="MC1")
anova(loc1, loc2)

data(muscatine)
muscatine$time1 <- c(-1, 0, 1)
musc1 <- bild::bild(obese~time1, data=muscatine, time="time1", dependence="MC1")
musc1r <- bild::bild(obese~time1, data=muscatine, time="time1", dependence="MC1R")
anova(musc1, musc1r, correct=TRUE)


Autoplot Method for bild Objects using ggplot2

Description

Generates ggplot2-based diagnostic and profile plots for a fitted bild longitudinal model object.

Usage

## S3 method for class 'bild'
autoplot(object, which = 5, add.unadjusted = FALSE, subSET, ident = FALSE, ...)

Arguments

object

A fitted model object of class bild.

which

A numeric value from 1 to 6 specifying the plot type.

add.unadjusted

Logical.

subSET

An optional logical expression to subset individuals in plot 6.

ident

Logical.

...

Further arguments passed.

Value

A ggplot object.

Examples


library(ggplot2)
library(patchwork)
library(bild)
data(airpollution)

air1R <- bild::bild(wheeze ~ age + smoking, data = airpollution, time = "age",
               aggregate = smoking, dependence = "MC1R")

# Single diagnostic plot (Standardized Residuals vs Time)  
autoplot(air1R, which = 2)

# Multi-panel diagnostic plots using patchwork
(autoplot(air1R, which = 5) + autoplot(air1R, which = 2)) /
   (autoplot(air1R, which = 1) + autoplot(air1R, which = 3))

# Individual mean profiles for the smoker group
autoplot(air1R, which = 6, subSET = smoking == "1", ident = TRUE)


Fit of Parametric Models for Binary Longitudinal Data via Likelihood Method

Description

Performs the fit of parametric models via likelihood method. Serial dependence and random intercept are allowed according to the stochastic model chosen. Missing values and unbalanced data are automatically accounted for computing the likelihood function.

Usage

bild(
  formula = formula(data),
  data,
  time,
  id,
  subSET,
  aggregate = FALSE,
  start = NULL,
  trace = FALSE,
  dependence = "ind",
  method = "BFGS",
  control = bildControl(),
  integrate = bildIntegrate()
)

Arguments

formula

a description of the model to be fitted of the form response ~ predictors.

data

a data frame containing the variables in the formula.

time

a string that matches the name of the time variable in data.

id

a string that matches the name of the id variable in data.

subSET

an optional expression indicating a subset of the rows of data to be used.

aggregate

a string that permits the user to identify the factor to be used in plot methods.

start

a vector of initial values for the nuisance parameters.

trace

logical; if TRUE, details of the nonlinear optimization are printed.

dependence

a character string stating which dependence structure to use: "ind", "MC1", "MC2", "indR", "MC1R", "MC2R". Default is "ind".

method

the optimization method used by optim. Default is "BFGS".

control

a list of control parameters for optim.

integrate

a list of algorithmic constants for numerical integration (Fortran-77/QUADPACK).

Details

The underlying methodology builds a logistic regression model for the probability that the response variable takes value 1 as a function of the covariates, taking into account that successive observations from the same individual cannot be assumed to be independent.

Value

An object of class bild.

References

Azzalini, A. (1994). Logistic regression for autocorrelated data with application to repeated measures. Biometrika, 81, 767-775. Goncalves, M. H., Cabral, M. S., and Azzalini, A. (2012). The R Package bild for the Analysis of Binary Longitudinal Data. Journal of Statistical Software, 46(9), 1-17.

Examples


# Example with airpollution data
data(airpollution)
air2r <- bild(wheeze~age+smoking, data=airpollution, trace=TRUE,
        time="age", aggregate=smoking, dependence="MC2R")
summary(air2r)



Class "bild" for Results of a Maximum Likelihood Estimation

Description

This class encapsulates results of a maximum likelihood procedure and is usually created as the result of a call to bild.

Slots

coefficients

Matrix. Estimated parameters.

se

Matrix. Standard errors of estimated parameters.

covariance

Matrix. Covariance of estimated parameters.

correlation

Matrix. Correlation of estimated parameters.

log.likelihood

Numeric. The value of the log likelihood.

message

Integer. Information returned by the optimizer.

n.cases

Numeric. Number of individual profiles used in the optimization.

ni.cases

Numeric. Number of individual profiles in the dataset.

aic

Numeric. The Akaike information criterion.

residuals

Numeric. The residuals of estimated parameters.

s.residuals

Numeric. The residuals summed over the individual profile.

ind.probability

Numeric. The transition probabilities.

prob.matrix

Matrix. The matrix of transition probabilities.

Fitted

Numeric. The fitted values for the estimated parameters.

bi.estimate

Matrix. The estimated values for the individual random effects.

Fitted.av

Numeric. The average fitted values.

Time

Numeric. Vector of time points.

model.matrix

Matrix. The model matrix.

y.matrix

Matrix. The matrix of response values.

subset.data

Data.frame. The data subset if considered.

y.av

Numeric. The average of the response value over an individual profile.

f.value

Factor. Indicates the aggregation factor if present.

call

Language. The call to "bild".

See Also

bild-class, show


Auxiliary for Controlling "bild" Fitting

Description

Auxiliary function as user interface for bild fitting.

Usage

bildControl(maxit = 100, abstol = 1e-06, reltol = 1e-06)

Arguments

maxit

maximum number of iterations.

abstol

absolute convergence tolerance.

reltol

relative convergence tolerance.

Details

See R documentation of optim for details of standard default values for the remaining options not considered in bildControl.

Value

A list with the arguments as components.

See Also

bild-class, optim


Auxiliary for Controlling "bild" Fitting

Description

Auxiliary function as user interface for bild fitting to set integration constants used in numerical integration.

Usage

bildIntegrate(
  li = -4,
  ls = 4,
  epsabs = .Machine$double.eps^0.25,
  epsrel = .Machine$double.eps^0.25,
  limit = 100,
  key = 6,
  lig = -4,
  lsg = 4
)

Arguments

li

lower limit of integration for the log-likelihood.

ls

upper limit of integration for the log-likelihood.

epsabs

absolute accuracy requested.

epsrel

relative accuracy requested.

limit

integer that gives an upperbound on the number of subintervals.

key

integer from 1 to 6 for choice of local integration rule (Gauss-Kronrod).

lig

lower limit of integration for the gradient.

lsg

upper limit of integration for the gradient.

Details

bildIntegrate returns a list of constants used to compute integrals based on a Fortran-77 subroutine dqage from the QUADPACK package.

The numerical integration is performed over the interval (li * \sigma, ls * \sigma), where \sigma = \exp(\omega)/2. If integration produces errors or NaNs in the information matrix, users should adjust li, ls, lig, or lsg.

For datasets with a high number of time points (> 30), it is recommended to set integration limits to smaller values than the default.

Value

A list with the arguments as components.

See Also

bild-class

Examples


library(bild)
data(locust)
# Example using locust data
Integ <- bildIntegrate(li = -2.5, ls = 2.5, lig = -2.5, lsg = 2.5)
locust2r_feed1 <- bild(move ~ (time + I(time^2)) * sex, data = locust,  
                      subSET = feed == "1", aggregate = sex,  
                      dependence = "MC2R", integrate = Integ)



Fitted values for 'bild' objects

Description

Fitted values for 'bild' objects

Usage

## S4 method for signature 'bild'
fitted(object, ...)

Arguments

object

an object of class bild.

...

Additional arguments.

Value

A numeric vector of the fitted values.

See Also

bild-class, fitted


Extract fixed effects estimates

Description

Extract fixed effects estimates

Usage

## S4 method for signature 'bild'
fixeff(object)

Arguments

object

an object of class bild.

Value

A matrix or vector containing the fixed effects estimates.

See Also

bild-class


Extract the Akaike Information Criterion

Description

Extract the Akaike Information Criterion

Usage

## S4 method for signature 'bild'
getAIC(object)

Arguments

object

an object of class bild.

Value

Returns a numeric value corresponding to the AIC of the fitted model.

See Also

bild-class


Extract Log-Likelihood

Description

Extract Log-Likelihood

Usage

## S4 method for signature 'bild'
getLogLik(object)

Arguments

object

an object of class bild.

Value

Returns a numeric value corresponding to the log-Likelihood of the fitted model.

See Also

bild-class


Extract variance estimates of random effects

Description

These functions extract the variance estimate of the random effect (\sigma^2 = \exp(\omega)) from an object of class bild.

Usage

## S4 method for signature 'bild'
getVariance(object, se = FALSE)

Arguments

object

an object of class bild.

se

logical; if TRUE, includes the standard error of the variance If se = TRUE, it also includes the standard error calculated via the Delta method. vareff is a wrapper for getVariance with se = FALSE for backward compatibility.

Value

A data frame containing the variance estimate.


Extract the coefficient estimates

Description

Extract the coefficient estimates

Usage

## S4 method for signature 'bild'
getcoef(object)

Arguments

object

an object of class bild.

Value

Returns the coefficient estimates of the fitted model (a matrix).

See Also

bild-class


Extract variance-covariance matrix

Description

Extract variance-covariance matrix

Usage

## S4 method for signature 'bild'
getvcov(object)

Arguments

object

an object of class bild.

Value

Returns a numeric matrix corresponding to the variance-covariance matrix of the fitted model.

See Also

bild-class


Glance at a bild object

Description

Glance at a fitted longitudinal model object of class bild to extract a single-row summary tibble with key statistics.

Usage

## S3 method for class 'bild'
glance(x, ...)

Arguments

x

A fitted model object of class bild.

...

Additional arguments. Not used.

Value

A tibble::tibble with summary statistics (number of observations, degrees of freedom/parameters, log-likelihood, AIC, and BIC).

Examples


library(bild)
library(generics)
data(airpollution)
air1R <- bild::bild(wheeze ~ age + smoking, data = airpollution, time = "age",
               aggregate = smoking, dependence = "MC1R")
glance(air1R)



Locust dataset

Description

This data set was presented by MacDonald and Raubenheimer (1995) and analyzes the effect of hunger on locomotory behaviour of 24 locusts (Locusta migratoria) observed at 161 time points.

Usage

locust

Format

A data frame with 3864 observations on the following 5 variables:

id

a numeric vector that identifies the number of the individual profile.

move

a numeric vector representing the response variable (1="moving", 0="not moving").

sex

a factor with levels 1 for "male" and 0 for "female".

time

a numeric vector that identifies the number of the time points observed.

feed

a factor with levels 0 "no" and 1 "yes".

Source

MacDonald, I. and Raubenheimer, D. (1995). Hidden Markov models and animal behaviour. Biometrical Journal, 37, 701-712.

Examples

data(locust)
str(locust)


# Dependence="MC2" (Fast computation)
locust2_feed1 <- bild(move ~ (time + I(time^2)) * sex, data = locust, 
     subSET = feed == "1", aggregate = sex, dependence = "MC2")
summary(locust2_feed1)

# Base plot diagnostics (Standard)
plot(locust2_feed1, which = 5, ylab = "probability of locomoting", 
      main = "Feed=1", add.unadjusted = TRUE)

# ggplot2-based diagnostic plots (New)
library(ggplot2)
# Comparing which=5 with the base plot above
autoplot(locust2_feed1, which = 5) 

# Other diagnostic plots
autoplot(locust2_feed1, which = 1)
autoplot(locust2_feed1, which = 2)


Extract the fixed effects model matrix

Description

Extract the fixed effects model matrix

Usage

## S4 method for signature 'bild'
model.mat(object)

Arguments

object

an object of class bild.

Value

Returns the fixed effects model matrix of the fitted model.

See Also

bild-class


Muscatine dataset

Description

This example is a subset of data from the Muscatine Coronary Risk Factor Study, a longitudinal study of coronary risk factors in school children from Muscatine (Iowa, USA).

Usage

muscatine

Format

A data frame with 156 observations on the following 5 variables:

id

identifies the number of the individual profile.

obese

a numeric vector that identifies the obesity status (1="yes", 0="no").

sex

a factor with levels 1 for "female" and 0 for "male".

time

a numeric vector (1,2,3) indicating the observed time points.

counts

a numeric vector indicating the number of times that each profile is replicated.

Source

Fitzmaurice, G. M., Laird, N. M. and Lipsitz, S. R. (1994). Analyzing incomplete longitudinal binary responses: a likelihood based approach. Biometrics, 38, 602-612.

Examples

data(muscatine)
str(muscatine)

# we decompose the time effect in orthogonal components
muscatine$time1 <- c(-1, 0, 1)
muscatine$time2 <- c(1, -2, 1)


# second order Markov Chain without random effects
musc2 <- bild(obese~(time1+time2)*sex, data=muscatine,  
     time="time1", aggregate=sex, trace=TRUE, dependence="MC2")

summary(musc2)
getAIC(musc2)
getLogLik(musc2)
fitted(musc2)


Plot Diagnostics for 'bild' Objects (Base Graphics)

Description

Diagnostic and profile plots for a fitted bild longitudinal model object using standard R base graphics. Six plots (selectable by which) are currently available. By default, the first five are provided.

Usage

## S4 method for signature 'bild,missing'
plot(
  x,
  y,
  which = c(1:5),
  ylab = NULL,
  main = NULL,
  ask = prod(par("mfcol")) < length(which) && dev.interactive(),
  subSET,
  add.unadjusted = FALSE,
  ident = FALSE,
  caption = c("Residuals vs Fitted", "Residuals vs Time", "ACF residuals",
    "PACF residuals", "Individual mean profiles"),
  cex.caption = 1
)

Arguments

x

An object of class bild.

y

Not used. Must be missing.

which

If a subset of the plots is required, specify a subset of the numbers 1:6:

  • 1: A plot of residuals against fitted values.

  • 2: A plot of standardized residuals against time.

  • 3: A plot of the autocorrelation function (ACF) of the residuals.

  • 4: A plot of the partial autocorrelation function (PACF) of the residuals.

  • 5: A plot for the fitted parametric model.

  • 6: A plot for the individual mean profile.

ylab

Label to some plots (which=5 and 6).

main

Title to some plots in addition to the caption (which=5 and 6).

ask

Logical expression; if TRUE, the user is asked before each plot. Defaults to prod(par("mfcol")) < length(which) && dev.interactive().

subSET

Logical expression indicating elements to keep in individual mean profile plots: missing values are taken as FALSE. The subSET argument is only for option which=6.

add.unadjusted

Logical expression indicating whether or not to add the unadjusted fit for plot in which=5.

ident

Logical expression indicating whether or not to add the number of the subject to individual mean profile plots. The ident argument is only for option which=6.

caption

Captions to appear above the plots. Defaults to a vector of standard labels.

cex.caption

Controls the font size expansion factor for the caption.

Details

The option which=5 provides the parametric fitted model if the dependence structure is "ind" (independence), "MC1" (first order Markov Chain) or "MC2" (second order Markov Chain).

When the dependence structure is "indR" (independence with random intercept), "MC1R" (first order Markov Chain with random intercept) or "MC2R" (second order Markov Chain with random intercept), the parametric adjusted fit is provided and the user can set add.unadjusted=TRUE to provide the unadjusted fitted curves.

The option which=6 is used only if the random intercept is present (models ending in "R") and provides the individual mean profile plots.

Value

No return value, called for side effects (generating plots).

Methods

signature(x="ANY", y="ANY")

Generic function.

signature(x="bild", y="missing")

Plot diagnostics for bild object.

Examples


library(bild)
data(locust)
# It takes a very long time to run
str(locust)

# dependence="MC2R"
Integ <- bild::bildIntegrate(li=-2.5, ls=2.5, lig=-2.5, lsg=2.5)    
locust2r_feed1 <- bild::bild(move~(time+I(time^2))*sex, data=locust, 
     subSET=feed=="1", aggregate=sex, dependence="MC2R",  
     integrate=Integ)
     
summary(locust2r_feed1)

plot(locust2r_feed1, which=5, ylab="probability of locomoting",
     add.unadjusted=TRUE)

plot(locust2r_feed1, which=6, subSET=sex=="1", 
     main="sex==1 & Feed=1", ident=TRUE)

locust2r <- bild::bild(move~(time+I(time^2))*feed, data=locust, 
     trace=TRUE, aggregate=feed, dependence="MC2R", 
     integrate=Integ)

par(mfrow=c(2,2))
plot(locust2r, which=1)
plot(locust2r, which=2)
plot(locust2r, which=3)
plot(locust2r, which=4)
par(mfrow=c(1,1))

plot(locust2r, which=5, ylab="probability of locomoting", 
     main="Feed & Unfeed groups", add.unadjusted=TRUE)

plot(locust2r, which=6, ylab="probability of locomoting",
     main="Fed & Unfed groups", ident=TRUE)


Predict Method for bild Objects

Description

Obtains predictions (link, response, or dynamic transition probabilities) from a fitted bild model object for existing or new data structures.

Usage

## S3 method for class 'bild'
predict(
  object,
  newdata = NULL,
  type = c("link", "response", "transition"),
  ...
)

Arguments

object

A fitted model object of class bild-class.

newdata

Optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors or probabilities from the original fit are returned.

type

The type of prediction required. Use "link" for the linear predictor scale, "response" for the marginal population probability scale, and "transition" for the dynamic Markov transition probabilities conditional on the recent lag history.

...

Additional arguments passed to or from other methods.

Value

A numeric vector of predicted values or probabilities matching the data rows.

See Also

bild, bild-class

Examples


library(bild)

# First-order Markov dependence (MC1)  
data(airpollution)

air1 <- bild(wheeze ~ age + smoking, data = airpollution, 
             time = "age", aggregate = smoking, dependence = "MC1")

# Standard marginal response prediction on original data
pred_mar <- predict(air1, type = "response")
head(pred_mar)

# Dynamic transition probabilities on new data (requires y_prev1)
new_data_air <- data.frame(
  age = c(9, 10, 11, 9, 10, 11),
  smoking = factor(c("0", "0", "0", "1", "1", "1")),
  y_prev1 = c(0, 1, 0, 1, 1, 0))

dynamic_pred_air <- predict(air1, newdata = new_data_air, type = "transition")
print(cbind(new_data_air, Prob_Transition = dynamic_pred_air))

# Second-order Markov with random effects (MC2R) 
data(muscatine)
muscatine$time1 <- c(-1, 0, 1)
muscatine$time2 <- c(1, -2, 1)

Integ <- bildIntegrate(lig = -3.95, lsg = 3.95)
musc2r <- bild(obese ~ (time1 + time2) * sex, data = muscatine, 
               time = "time1", start = c(1, 1, 1), dependence = "MC2R", integrate = Integ)

# Dynamic transition probabilities for second-order model (requires y_prev1 and y_prev2)
new_data_musc <- data.frame(
  time1 = c(0, 1),
  time2 = c(-2, 1),
  sex = factor(c("0", "1")),
  y_prev1 = c(1, 0),
  y_prev2 = c(0, 1))

dynamic_pred_musc <- predict(musc2r, newdata = new_data_musc, type = "transition")
print(cbind(new_data_musc, Prob_Transition = dynamic_pred_musc))



Extract conditional random effects

Description

Extract conditional random effects

Usage

## S4 method for signature 'bild'
randeff(object)

Arguments

object

an object of class bild.

Value

A data frame containing the random effects estimates, if the model contains random effects. Otherwise, it issues a warning.

See Also

bild-class


Show a 'bild' object

Description

show displays a brief summary of a fitted bild model object, including the function call, the number of profiles used in the fit, the number of estimated coefficients, the maximized log-likelihood, and any convergence message.

Usage

## S4 method for signature 'bild'
show(object)

Arguments

object

An object of class bild.

Value

No return value, called for side effects (printing to the console).

See Also

bild-class


Summary of a 'bild' object

Description

Summary method for class bild. Computes and prints summary statistics for a fitted bild object.

Usage

## S4 method for signature 'bild'
summary(object, cov = FALSE, cor = FALSE)

Arguments

object

an object of class bild.

cov

logical. If TRUE, prints the covariance matrix of coefficients.

cor

logical. If TRUE, prints the correlation matrix of coefficients.

Value

Returns the summary object (invisibly).

See Also

bild, bild-class


Class "summary.bild"

Description

Summary of bild objects. Extracted from a bild object, it contains values meant for printing by the show method.

Slots

coefficients

Matrix. Estimated parameters.

se

Matrix. Standard errors of estimated parameters.

covariance

Matrix. Covariance of estimated parameters.

correlation

Matrix. Correlation of estimated parameters.

log.likelihood

Numeric. The value of the log likelihood.

message

Integer. Information returned by the optimizer.

n.cases

Numeric. Number of individual profiles used in the optimization procedure.

ni.cases

Numeric. Number of individual profiles in the dataset.

aic

Numeric. The Akaike information criterion.

call

Language. The call that generated the bild object.

See Also

bild, show


Tidy a bild object into a tibble

Description

Tidy a bild object into a tibble

Usage

## S3 method for class 'bild'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

Arguments

x

A fitted model object of class bild.

conf.int

Logical. Whether or not to include a confidence interval in the tidied output. Defaults to FALSE.

conf.level

The confidence level to use for the confidence interval if conf.int = TRUE. Defaults to 0.95.

...

Additional arguments. Not used.

Details

For parameters estimated on the log-scale (such as dependence parameters log.psi1, log.psi2) and the random effect variance parameter omega, tidy.bild automatically transforms the estimates to their natural scale (psi1, psi2, sigma2) via the exponential function. Consequently, their standard errors are adjusted using the Delta method, and confidence intervals are computed accordingly.

Value

A tibble::tibble containing columns: term, estimate, std.error, statistic, p.value, conf.low, conf.high.

Examples


library(bild)
library(generics)
data(airpollution)
air1R <- bild::bild(wheeze ~ age + smoking, data = airpollution, time = "age",
               aggregate = smoking, dependence = "MC1R")
tidy(air1R, conf.int = TRUE)


Extract variance estimates of random effects (wrapper)

Description

Extract variance estimates of random effects (wrapper)

Usage

## S4 method for signature 'bild'
vareff(object)

Arguments

object

an object of class bild.

Value

A data frame containing the variance estimate.

See Also

getVariance