LinearGaussianSCM {R6causal} | R Documentation |
R6 Class for linear structural causal models where background variables have Gaussian distribution
Description
R6 Class for linear structural causal models where background variables have Gaussian distribution
R6 Class for linear structural causal models where background variables have Gaussian distribution
Details
Inherits R6 class SCM.
Super class
R6causal::SCM
-> LinearGausianSCM
Active bindings
linear_gaussian_B
Matrix of structural coefficients of the observed variables
linear_gaussian_A
Matrix of structural coefficients of the background variables
linear_gaussian_c
Vector of constants in structural coefficients
Methods
Public methods
Inherited methods
R6causal::SCM$add_variable()
R6causal::SCM$an()
R6causal::SCM$causal.effect()
R6causal::SCM$cfid()
R6causal::SCM$ch()
R6causal::SCM$de()
R6causal::SCM$dosearch()
R6causal::SCM$intervene()
R6causal::SCM$pa()
R6causal::SCM$plot()
R6causal::SCM$print()
R6causal::SCM$remove_variable()
R6causal::SCM$simulate()
R6causal::SCM$tikz()
Method new()
Create a new linear Gaussian SCM object.
Usage
LinearGaussianSCM$new( name = "A linear Gaussian SCM", linear_gaussian = NULL, random_linear_gaussian = NULL, rflist = NULL, rprefix = "R_", starsuffix = "_md" )
Arguments
name
Name.
linear_gaussian
A list with the following elements:
uflist: A named list containing the functions for the background variables.
vnames: A vector of names of the observed variables.
vcoefmatrix: A matrix of coefficients for observed variables in the structural equations.
ucoefvector: A vector of the coefficients of dedicated error terms in the structural equations.
ccoefvector: A vector of constant terms in the structural equations.
u2coefmatrix: A matrix of the coefficients of confounding background variables in the structural equations. The number of rows equals the number of the observed variables and the number of columns equals the number of confounding background variables.
random_linear_gaussian
A list with the following elements:
nv: The number of observed variables
edgeprob: The probability of an edge between a pair of observed variables (provide either edgeprob or avgneighbors)
avgneighbors: The average number of edges per a vertex (provide either edgeprob or avgneighbors)
u2prob: The probability of unobserved confounder between a pair of observed variables (provide either u2prob or avgu2)
avgu2: The average number of unobserved confounders per a vertex (provide either u2prob or avgu2)
vcoefdistr: A function that generates the coefficients of observed variables in the structural equations. The function must have argument 'n'.
ucoefdistr: A function that generates the coefficients of dedicated error terms in the structural equations. The function must have argument 'n'.
ccoefdistr: A function that generates the constants in the structural equations. The function must have argument 'n'.
u2coefdistr: A function that generates the coefficients of confounding background variables in the structural equations. The function must have argument 'n'.
rflist
A named list containing the functions for missingness indicators.
rprefix
The prefix of the missingness indicators.
starsuffix
The suffix for variables with missing data.
Returns
A new 'LinearGaussianSCM' object that also belongs to class 'SCM'.
Examples
lgbackdoor <- LinearGaussianSCM$new("Linear Gaussian Backdoor", linear_gaussian = list( uflist = list(ux = function(n) {rnorm(n)}, uy = function(n) {rnorm(n)}, uz = function(n) {rnorm(n)}), vnames = c("x","y","z"), vcoefmatrix = matrix(c(0,0.4,0,0,0,0,0.6,0.8,0),3,3), ucoefvector = c(1,1,1), ccoefvector = c(0,0,0))) randomlg <- LinearGaussianSCM$new("Random Linear Gaussian", random_linear_gaussian = list( nv = 10, edgeprob=0.5, vcoefdistr = function(n) {rnorm(n)}, ccoefdistr = function(n) {rnorm(n)}, ucoefdistr = function(n) {rnorm(n)}))
Method clone()
The objects of this class are cloneable with this method.
Usage
LinearGaussianSCM$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `LinearGaussianSCM$new`
## ------------------------------------------------
lgbackdoor <- LinearGaussianSCM$new("Linear Gaussian Backdoor",
linear_gaussian = list(
uflist = list(ux = function(n) {rnorm(n)},
uy = function(n) {rnorm(n)},
uz = function(n) {rnorm(n)}),
vnames = c("x","y","z"),
vcoefmatrix = matrix(c(0,0.4,0,0,0,0,0.6,0.8,0),3,3),
ucoefvector = c(1,1,1),
ccoefvector = c(0,0,0)))
randomlg <- LinearGaussianSCM$new("Random Linear Gaussian",
random_linear_gaussian = list(
nv = 10,
edgeprob=0.5,
vcoefdistr = function(n) {rnorm(n)},
ccoefdistr = function(n) {rnorm(n)},
ucoefdistr = function(n) {rnorm(n)}))