| Title: | Build Network Based on Linear Mixed Models from EHRs | 
| Version: | 1.0.0 | 
| Description: | Analyzing longitudinal clinical data from Electronic Health Records (EHRs) using linear mixed models (LMM) and visualizing the results as networks. It includes functions for fitting LMM, normalizing adjacency matrices, and comparing networks. The package is designed for researchers in clinical and biomedical fields who need to model longitudinal data and explore relationships between variables For more details see Bates et al. (2015) <doi:10.18637/jss.v067.i01>. | 
| License: | GPL-3 | 
| Imports: | dplyr, lme4, qgraph | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| Suggests: | knitr, rmarkdown, BiocStyle | 
| VignetteBuilder: | knitr | 
| Depends: | R (≥ 3.5) | 
| LazyData: | true | 
| NeedsCompilation: | no | 
| Packaged: | 2025-03-19 15:26:54 UTC; marina | 
| Author: | Vargas-Fernández Marina [aut, cre], Martorell-Marugán Jordi [aut], Carmona-Sáez Pedro [aut] | 
| Maintainer: | Vargas-Fernández Marina <marina.vargas@genyo.es> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-03-21 16:00:06 UTC | 
Subtract Two Adjacency Matrices
Description
This function returns difference matrix between two networks. It is useful for comparing two networks represented by adjacency matrices.
Usage
differentiation(matrix1, matrix2)
Arguments
| matrix1 | The first adjacency matrix. | 
| matrix2 | The second adjacency matrix. | 
Value
a normalized matrix containing values between 0 and 1.
Example Dataset: Psychological and Behavioral Responses
Description
This dataset contains self-reported psychological and behavioral responses from individuals.
Usage
example_data
Format
A data frame with multiple rows and 17 variables:
- id
- Unique participant identifier (integer). 
- Relax
- Self-reported relaxation level (integer scale). 
- Irritable
- Self-reported irritability level (integer scale). 
- Worry
- Level of worry experienced (integer scale). 
- Nervous
- Self-reported nervousness (integer scale). 
- Future
- Concerns about the future (integer scale). 
- Anhedonia
- Self-reported lack of enjoyment (integer scale). 
- Tired
- Level of tiredness (integer scale). 
- Hungry
- Self-reported hunger level (integer scale). 
- Alone
- Feeling of loneliness (integer scale). 
- Angry
- Level of anger experienced (integer scale). 
- Social_offline
- Offline social interactions (integer scale). 
- Social_online
- Online social interactions (integer scale). 
- Music
- Time spent listening to music (integer scale). 
- Procrastinate
- Self-reported procrastination (integer scale). 
- Outdoors
- Time spent outdoors (integer scale). 
- C19_occupied
- Engagement in activities during COVID-19 (integer scale). 
- C19_worry
- Level of worry related to COVID-19 (integer scale). 
- Home
- Time spent at home (integer scale). 
- day
- Day number of the study (integer). 
- beep
- Moment within the day when data was collected (integer). 
- conc
- Self-reported concentration level (integer scale). 
Details
This dataset was collected from a study examining psychological and behavioral responses to various daily experiences. Each row represents a unique moment of self-reporting.
Source
Reproducible figure for Nature Methods primer paper, Borsboom et al. 2021. This examples contains a subset of variables collected and modeled in our covid19 paper. This paper, with full data is available on https://journals.sagepub.com/doi/10.1177/21677026211017839. Eiko Fried, March 14 2021
Examples
data(example_data)
head(example_data)
Perform Longitudinal Analysis with Linear Mixed Models (LMM)
Description
This function automates the analysis of longitudinal clinical data using linear mixed models. It models clinical variables and returns a weighted matrix of model coefficient scores.
Usage
lmm_analysis(
  clinical_data,
  variables_to_scale,
  random_effects = "(1 | participant_id)"
)
Arguments
| clinical_data | Dataframe containing clinical and metadata for participants, including identifier as  | 
| variables_to_scale | Character vector of variable names to be analyzed. | 
| random_effects | A character string specifying the random effects formula (default: "(1 | participant_id)"). | 
Value
A matrix of model coefficient scores, where rows represent dependent variables and columns represent independent variables.
Normalization of weighted linear mixed model network matrix.
Description
This function normalizes weighted adjacency matrix derived from lmm.
Usage
normalization(matrix)
Arguments
| matrix | The adjacency matrix (to be normalized). | 
Value
a normalized matrix containing values between 0 and 1.
Compute Score Matrix
Description
This function adjusts an original matrix by copying the lower triangular part from a shifted matrix.
Usage
score_matrix(original_matrix, shifted_matrix)
Arguments
| original_matrix | A numeric matrix representing the original data. | 
| shifted_matrix | A numeric matrix that has been transformed using  | 
Value
A new matrix with adjusted values in the lower triangular part.
Shifted Matrix Transformation
Description
This function modifies the shape of a model weights matrix by shifting its elements.
Usage
shift_matrix(mat)
Arguments
| mat | A numeric matrix to be transformed. | 
Value
A shifted version of the input matrix.