get_query_types function

Look up query types

Look up query types

Find which nodal or causal types are satisfied by a query.

get_query_types(model, query, map = "causal_type", join_by = "|")

Arguments

  • model: A causal_model. A model object generated by make_model.
  • query: A character string. An expression defining nodal types to interrogate. An expression of the form "Y[X=1]" asks for the value of Y when X is set to 1
  • map: Types in query. Either nodal_type or causal_type. Default is causal_type.
  • join_by: A logical operator. Used to connect causal statements: AND ('&') or OR ('|'). Defaults to '|'.

Returns

A list containing some of the following elements - types: A named vector with logical values indicating whether a nodal_type or a causal_type satisfy query

  • query: A character string as specified by the user

  • expanded_query: A character string with the expanded query. Only differs from query if this contains wildcard '.'

  • evaluated_nodes: Value that the nodes take given a query

  • node: A character string of the node whose nodal types are being queried

  • type_list: List of causal types satisfied by a query

Examples

model <- make_model('X -> M -> Y; X->Y') query <- '(Y[X=0] > Y[X=1])' get_query_types(model, query, map="nodal_type") get_query_types(model, query, map="causal_type") get_query_types(model, query) # Examples with map = "nodal_type" query <- '(Y[X=0, M = .] > Y[X=1, M = 0])' get_query_types(model, query, map="nodal_type") query <- '(Y[] == 1)' get_query_types(model, query, map="nodal_type") get_query_types(model, query, map="nodal_type", join_by = '&') # Root nodes specified with [] get_query_types(model, '(X[] == 1)', map="nodal_type") query <- '(M[X=1] == M[X=0])' get_query_types(model, query, map="nodal_type") # Nested do operations get_query_types( model = make_model('A -> B -> C -> D'), query = '(D[C=C[B=B[A=1]], A=0] > D[C=C[B=B[A=0]], A=0])') # Helpers model <- make_model('M->Y; X->Y') query <- complements('X', 'M', 'Y') get_query_types(model, query, map="nodal_type") # Examples with map = "causal_type" model <- make_model('X -> M -> Y; X->Y') query <- 'Y[M=M[X=0], X=1]==1' get_query_types(model, query, map= "causal_type") query <- '(Y[X = 1, M = 1] > Y[X = 0, M = 1]) & (Y[X = 1, M = 0] > Y[X = 0, M = 0])' get_query_types(model, query, "causal_type") query <- 'Y[X=1] == Y[X=0]' get_query_types(model, query, "causal_type") query <- '(X == 1) & (M==1) & (Y ==1) & (Y[X=0] ==1)' get_query_types(model, query, "causal_type") query <- '(Y[X = .]==1)' get_query_types(model, query, "causal_type")