CInLPN: Causal Inference in a Latent Processes Network

View source: R/CInLPN.formula.R

CInLPNR Documentation

Causal Inference in a Latent Processes Network

Description

This function estimates a dynamic model based on D latent processes observed through K longitudinal markers (K >= D) which includes temporal relationships between latent processes. The structural model for the D latent processes combines a multivariate linear mixed model and system of difference equations to model trajectories of the processes and their temporal influences other time. The temporal influences between processes are captured through a time-dependent transition matrix that can be adjusted for covariates. The model includes as a special case, a standard multivariate mixed model in which associations between processes are not captured by temporal influences but by correlated random effects. Longitudinal markers are related to their latent processes through equations of observation that involve parameterized link functions (parameters are estimated simultaneously with those of the structural model). The link function can be linear for Gaussian marker or non linear (using a basis of I-splines) for non Gaussian markers. All parameters are estimated simultaneously in a maximum likelihood framework See the methodological paper available at :http://arxiv.org/abs/1806.03659

Usage

CInLPN(structural.model, measurement.model, parameters, option, Time,
  subject, data, TimeDiscretization = TRUE, ...)

Arguments

structural.model

a list of 5 arguments used to specify the structural model:

structural.model$fixed.LP0 allows to specify the fixed effects in the submodel for the baseline level of processes. Note that there is no need to specify a random effect model for the baseline level of processes as we systematically set a process-specific random intercept (with variance fixed to 1 for identifiability purpose). For identifiability purposes, the mean intercepts are fixed to 0 (not estimated).

structural.model$fixed.DeltaLP a two-sided linear formula object for specifying the response outcomes (one the left part of ~ symbol) and the covariates with fixed-effects (on the right part of ~ symbol) in the submodel for change over time of latent processes.

structural.model$random.DeltaLP allow to specify the random effects in the submodel for change over time of latent processes.

structural.model$trans.matrix allow to specify a model for elements of the transition matrix, which captures the temporal influences between latent processes.

structural.model$delta.time indicates the discretisation step to be used for latent processes

measurement.model

is a list of arguments detailed below used to specify the measurement model:

measurement.model$link indicates the link functions to be used to transform the outcomes. It takes values in "linear" for a linear transformation and "n-type-d" for a I-splines transformation where "n" indicates the number of nodes, "type" (which takes values in "quant", "manual", "equi") indicates where the nodes are placed, and "d" indicates the degree of the I-splines.

measurement.model$knots argument indicates if necessary the place of knots (when placed manually with "manual"), default value is NULL

parameters

a list of 3 arguments about parameters of the models (e.g., initial paremeters, parameters one would like to fix, etc.)

parameters$paras.ini indicates initial values for parameters, default values is NULL.

parameters$Fixed.para.indix indicates the positions of parameters to be constrained.

parameters$Fixed.para.values indicates the values associated to the index of parameters to be constrained.

option

a list of 4 arguments for the optimization procedure:

option$epsa threshold for the convergence criterion on the parameters

option$epsb threshold for the convergence criterion on the likelihood

option$epsc threshold for the convergence criterion on the derivatives

option$MCnr number of replicates to compute the predictions in the real scales of the outcomes (backward transformation because of the link functions)

Time

indicates the name of the covariate representing the time

subject

indicates the name of the covariate representing the grouping structure

data

indicates the data frame containing all the variables for estimating the model.

TimeDiscretization

a boolean indicating if the inital time have to be discretized. When setting to FALSE, It allows to avoid discretization when running univarite model during parameter initialization.

...

other optional arguments

Value

Examples

        
### example 1
Delta <- 1
paras.ini <- c(0.000, 0.059, 0.000, 0.163, -0.050, -0.153, 1.000, 0.000, 0.322, 0.000, 1.000, 
               0.000, 0.077, 0.139, 0.000, 0.177, -0.354, 0.114, 0.116, -0.090, 0.287, 0.554,
               1.107, 1.889, 0.881, 1.329)
indexparaFixeUser <- c(1,3, 6+c(1, 2, 4, 5, 6, 9))
paraFixeUser <- c(0, 0, 1, 0, 0, 1, 0, 0)
mod1 <- CInLPN(structural.model = list(fixed.LP0 = ~ 1 + C2 | 1 + C2,
                                      fixed.DeltaLP = L2 | L3  ~ 1 | 1 ,
                                      random.DeltaLP = ~ 1|1,
                                      trans.matrix = ~ 1,
                                      delta.time = Delta),
              measurement.model = list(link.functions = list(links = c(NULL,NULL),
                                                             knots = list(NULL, NULL))),
              
              parameters = list(paras.ini = paras.ini, Fixed.para.index = indexparaFixeUser, 
                                Fixed.para.values = paraFixeUser),
              option = list(nproc = 1, print.info = TRUE, makepred = TRUE, MCnr = 10, 
                            univarmaxiter = 7, epsa = 1e-5, epsb = 1e-4, epsd = 1e-2),
              Time = "time",
              subject = "id",
              data = data
)

summary(mod1)

 ### example 2
 library(splines)
 Delta <- 0.5
 paras.ini <- c(0.000,0.065, 0.000, 0.168, -0.054, 0.000, -0.119, -0.009, 1.000, 0.000,
                0.473, 0.000, 1.000, 0.000, 0.057, -0.182, 0.000, 0.174, -0.523, 0.000,
                0.000, 0.000, 0.073, 0.083, 0.119,  0.106, 0.015,  0.157,  0.054, 0.087,
                -0.079, 0.000, 0.000, 0.000, 8.876, 0.287, 0.546, 0.531, 0.256, 1.100,
                1.891,  0.846, 1.345)
indexparaFixeUser <- c(1,3, 8+c(1, 2, 4, 5, 6, 9,10+c(2:4,14:16)))
paraFixeUser <- c(0, 0, 1, 0, 0, 1, 0, 0, rep(0,6))
mod2 <- CInLPN(structural.model = list(fixed.LP0 = ~ 1 + C2 | 1 + C2,
                                     fixed.DeltaLP = L1 + L2| L3  ~ 1 + time| 1 + time,
                                     random.DeltaLP = ~ 1|1,
                                     trans.matrix = ~ 1 + bs(x = time, knots =c(2), 
                                                             intercept = F, degree = 2),
                                     delta.time = Delta),
             measurement.model = list(link.functions = list(links = c(NULL,NULL, NULL),
                                                            knots = list(NULL, NULL, NULL))),
             
             parameters = list(paras.ini = paras.ini, Fixed.para.index = indexparaFixeUser, 
                               Fixed.para.values = paraFixeUser),
             option = list(nproc = 2, print.info = TRUE, makepred = TRUE, MCnr = 10, 
                           univarmaxiter = 7, epsa = 1e-5, epsb = 1e-4, epsd = 1e-2),
             Time = "time",
             subject = "id",
             data = data
)

summary(mod2)

#' 
## Not run: 
### example 3
Delta <- 1
paras.ini <- NULL
indexparaFixeUser <- c(1,4,10+c(1,2,4,5,6,9, 10+c(1:4)))
paraFixeUser <- c(0,0,1,0,0,1,0,0, rep(0,4))
mod <-  CInLPN(structural.model = list(fixed.LP0 = ~ 1 + C1 + C2|1 + C1 + C2,
                                   fixed.DeltaLP = L1 + L2 | L3 ~1 + time|1 + time,
                                   random.DeltaLP = ~ 1|1,
                                   trans.matrix = ~ 1,
                                   delta.time = Delta),
           measurement.model = list(link.functions = list(links = c("4-equi-2", "linear",
                                                                    "4-equi-2"),
                                                          knots = list(NULL, NULL, NULL))),
           parameters = list(paras.ini = paras.ini, Fixed.para.index = indexparaFixeUser, 
                             Fixed.para.values = paraFixeUser),
           option = list(nproc = 1, print.info = FALSE, makepred = TRUE, MCnr = 10, 
                         univarmaxiter = 7, epsa = 1e-5, epsb = 1e-5, epsd = 1e-5),
           Time = "time",
           subject = "id",
           data = data
         )
         
### example 4
library(splines)
Delta <- 0.5
paras.ini <- NULL
indexparaFixeUser <- c(1,3, 8+c(1, 2, 4, 5, 6, 9,10+c(2:4,14:16)))
paraFixeUser <- c(0, 0, 1, 0, 0, 1, 0, 0, rep(0,6))
res <- CInLPN(structural.model = list(fixed.LP0 = ~ 1 + C2 | 1 + C2,
                                 fixed.DeltaLP = L1 | L2  ~ 1 + time| 1 + time,
                                 random.DeltaLP = ~ 1|1,
                                 trans.matrix = ~ 1 + bs(x = time, knots =c(2), 
                                                         intercept = F, degree = 2),
                                 delta.time = Delta),
         measurement.model = list(link.functions = list(links = c(NULL,NULL),
                                                        knots = list(NULL, NULL))),
         
         parameters = list(paras.ini = paras.ini, Fixed.para.index = indexparaFixeUser, 
                           Fixed.para.values = paraFixeUser),
         option = list(nproc = 2, print.info = TRUE, makepred = TRUE, MCnr = 10, 
                       univarmaxiter = 7, epsa = 1e-5, epsb = 1e-4, epsd = 1e-2),
         Time = "time",
         subject = "id",
         data = data
  )

## End(Not run)
      

bachirtadde/CInLPN documentation built on June 30, 2023, 11:47 a.m.