conditional_inferences: Conditional inferences

Description Usage Arguments Examples

View source: R/conditional_inferences.R

Description

Calculate estimands conditional on observed data (currently, for single-case process tracing) together with data realization probabilities Realization probabilities are the probability of the observed data given data is sought on observed variables

Usage

1
conditional_inferences(model, query, parameters = NULL, given = NULL)

Arguments

model

A model generated by make_model.

query

A character vector of length 1L. Query for example 'Y[X=1]>Y[X=0]'

parameters

A numeric vector. Values of parameters may be specified. By default, it is drawn from priors.

given

A conditioning set as a character string that evaluates to a logical, for example 'Y==1'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
model <- make_model("X->Y")
model <- set_parameters(model, type = "flat")
conditional_inferences(model, query = "Y[X=1]>Y[X=0]")

# Example of posteriors given monotonic X -> M -> Y model
library(dplyr)
model <- make_model("X-> M -> Y")  %>%
  set_restrictions(node_restrict = list(M = "10", Y = "10")) %>%
  set_parameters(type = "flat")
conditional_inferences(model, query = "Y[X=1]>Y[X=0]", given = "Y==1")

# Running example
model <- make_model("S -> C -> Y <- R <- X; X -> C -> R") %>%
   set_restrictions(node_restrict =
   list(C = "C1110", R = "R0001", Y = "Y0001"), keep = TRUE)
conditional_inferences(model, query = list(COE = "(Y[S=0] > Y[S=1])"),
given = "Y==1 & S==0")

lilymedina/gbiqqtools documentation built on Nov. 4, 2019, 4:32 p.m.