integrated-inferences / CausalQueries

Bayesian inference from binary causal models
Other
24 stars 7 forks source link

can't find get_type_prob #339

Open atcrank opened 2 months ago

atcrank commented 2 months ago

Using Windows distribution, R 4.4. I have installed and loaded CausalQueries_1.1.1 into my workspace, but ls("package:CausalQueries") doesn't include function "get_type_prob", and so I'm unable to the introductory activity here:

ls("package:CausalQueries") [1] "collapse_data" "complements"
[3] "data_type_names" "decreasing"
[5] "democracy_data" "draw_causal_type"
[7] "expand_data" "expand_wildcard"
[9] "get_all_data_types" "get_event_probabilities" [11] "get_query_types" "grab"
[13] "increasing" "institutions_data"
[15] "interacts" "interpret_type"
[17] "lipids_data" "make_data"
[19] "make_events" "make_model"
[21] "make_parameters" "make_parameters_df"
[23] "make_prior_distribution" "make_priors"
[25] "non_decreasing" "non_increasing"
[27] "observe_data" "plot_model"
[29] "query_distribution" "query_model"
[31] "realise_outcomes" "set_confound"
[33] "set_parameter_matrix" "set_parameters"
[35] "set_prior_distribution" "set_priors"
[37] "set_restrictions" "simulate_data"
[39] "substitutes" "te"
[41] "update_model"

macartan commented 1 month ago

Sorry not to have seen this sooner;

We stopped exporting this when we introduced the grab funciton though it is still available like this: CausalQueries:::get_type_prob see below

@till-tietz I think we should export this again to avoid this problem with the book version

> model <- make_model("X -> M -> Y") |>
+   set_restrictions("X[]==0") |>
+   set_restrictions("M[X=1] < M[X=0]") |>
+   set_restrictions("Y[M=1] < Y[M=0]")   
> 
> q1 <- "Y[X = 1] > Y[X = 0]"
> q2 <- "X == 1 & Y == 1"
> 
> df <- data.frame(
+   a1 = get_query_types(model, q1)$types,
+   a2 = get_query_types(model, q2)$types,
+   p  = CausalQueries:::get_type_prob(model))
> 
> df
              a1    a2         p
X1.M00.Y00 FALSE FALSE 0.1111111
X1.M01.Y00 FALSE FALSE 0.1111111
X1.M11.Y00 FALSE FALSE 0.1111111
X1.M00.Y01 FALSE FALSE 0.1111111
X1.M01.Y01  TRUE  TRUE 0.1111111
X1.M11.Y01 FALSE  TRUE 0.1111111
X1.M00.Y11 FALSE  TRUE 0.1111111
X1.M01.Y11 FALSE  TRUE 0.1111111
X1.M11.Y11 FALSE  TRUE 0.1111111
till-tietz commented 1 month ago

@atcrank @macartan thanks for flagging this and apologies on the delayed response here. Will push a patch release fixing this issue asap