Package 'Mmcsd'

Title: Modeling Complex Longitudinal Data in a Quick and Easy Way
Description: Matching longitudinal methodology models with complex sampling design. It fits fixed and random effects models and covariance structured models so far. It also provides tools to perform statistical tests considering these specifications as described in : Pacheco, P. H. (2021). "Modeling complex longitudinal data in R: development of a statistical package." <https://repositorio.ufjf.br/jspui/bitstream/ufjf/13437/1/pedrohenriquedemesquitapacheco.pdf>.
Authors: Pedro Pacheco [aut, cre] , Marcel Vieira [aut] , Gustavo Silva [aut]
Maintainer: Pedro Pacheco <[email protected]>
License: GPL (>= 3)
Version: 1.0.0
Built: 2025-02-19 04:15:43 UTC
Source: https://github.com/cran/Mmcsd

Help Index


Fit covariance structered longitudinal model.

Description

Responsible for performing the modeling of the model's covariance matrix through the use of covariance structures.

Usage

cov_mmcsd(fit, fittingType, sigmaThetaExpr, optimParams)

Arguments

fit

A fit model with class 'mmcsd'

fittingType

A character with the fitting function type. See optins above

sigmaThetaExpr

A character with the covariance structure type or a list of expressions

optimParams

A list with configuration for optim function. 'Par' is required.

Value

The fit model with class 'mmcsd.theta'.

Examples

fit <- mmcsd(
 score ~ wave + ageg + ecacg + qualifg,
 waves = wave, ids = id,
 weights = weight, stratum = strata, cluster = cluster,
 data = example_data, sigma = "exchangeable"
)
fitTheta_ucm <- cov_mmcsd(fit,
 fittingType = "PML", sigmaThetaExpr = "UCM",
 optimParams = list(par = c(7, 5))
)

A longitudinal example dataset.

Description

An example dataset containing the individuals scores for certain subject.

Usage

example_data

Format

A data frame with 6700 rows and 9 variables:

id

respondent id

wave

wave number

score

respondent score

weight

sampling weight

strata

strata variable

cluster

cluster variable

ageg

cathegorical age

ecacg

educational level

qualifg

economic activity


Fit fixed and random effects longitudinal model.

Description

Estimate the fixed effects of the model, also known as B parameters of the regression,taking into account the sampling plan of the research, and also estimating the covariance matrix of the model considering the estimates of B

Usage

mmcsd(formula, waves, ids, weights, stratum, cluster, data, sigma = "identity")

Arguments

formula

A formula

waves

a dataframe column or an array

ids

a dataframe column or an array

weights

a dataframe column or an array

stratum

a dataframe column or an array

cluster

a dataframe column or an array

data

A dataframe or tibble

sigma

A character or a square matrix

Value

The fit model with class 'mmcsd'.

Examples

fit <- mmcsd(
 score ~ wave + ageg + ecacg + qualifg,
 waves = wave, ids = id,
 weights = weight, stratum = strata, cluster = cluster,
 data = example_data, sigma = "exchangeable"
)

covariance structure viewer to preview sigmaThetaExpr to be used in 'cov_mmcsd'.

Description

Knowing the difficulty of visualizing the covariance structure, especially when the user chooses to determine his own structure. This function was developed,that allows the user to view the provided structure even before it is evaluated, that is, through mathematics symbolic.

Usage

sigmaThetaExpr_viewer(sigmaThetaExpr, numWaves = NULL)

Arguments

sigmaThetaExpr

A character with the covariance structure type or a list of expressions

numWaves

An integer with the size of the square matrix to be printed.

Value

Return NULL and print in terminal the sigmaThetaExpr.

Examples

sigmaThetaExpr_viewer("UCM", 5)

Summarise the results of 'mmcsd' fit.

Description

Summarise the results of 'mmcsd' fit.

Usage

## S3 method for class 'mmcsd'
summary(object, ...)

Arguments

object

A mmcsd fitted model

...

Additional params passed to summary

Value

Return NULL and print in terminal the results.

Examples

fit <- mmcsd(
 score ~ wave + ageg + ecacg + qualifg,
 waves = wave, ids = id,
 weights = weight, stratum = strata, cluster = cluster,
 data = example_data, sigma = "exchangeable"
)
summary(fit)

Summarise the results of 'cov_mmcsd' fit.

Description

Summarise the results of 'cov_mmcsd' fit.

Usage

## S3 method for class 'mmcsd.theta'
summary(object, ...)

Arguments

object

A mmcsd.theta fitted model

...

Additional params passed to summary

Value

Return NULL and print in terminal the results.

Examples

fit <- mmcsd(
 score ~ wave + ageg + ecacg + qualifg,
 waves = wave, ids = id,
 weights = weight, stratum = strata, cluster = cluster,
 data = example_data, sigma = "exchangeable"
)
fitTheta_ucm <- cov_mmcsd(fit,
 fittingType = "PML", sigmaThetaExpr = "UCM",
 optimParams = list(par = c(7, 5))
)
summary(fitTheta_ucm)