CausalQueries icon indicating copy to clipboard operation
CausalQueries copied to clipboard

create function to handle non linear operators on types?

Open macartan opened this issue 5 years ago • 4 comments

Currently this is possible:

get_estimands(M1, using = "posteriors", queries = "(Y[X=1]>Y[X=0])-(Y[X=1]<Y[X=0])")

And it returns ATE: lambda^Y_01 - lambda^Y_10

But this is not:

get_estimands(M1, using = "posteriors", queries = "(Y[X=1]>Y[X=0]) / (Y[X=1]<Y[X=0])")

Should we generalize by (a) having get_types do operations as with the ATE. Or b having get_estimand allow for functions over multiple queries, something like

get_estimands(M1, using = "posteriors", queries = mean(types("(Y[X=1]>Y[X=0]") / types("Y[X=1]<Y[X=0])"))

macartan avatar Jul 05 '19 19:07 macartan

Gathering @lilymedina's and my thoughts on this:

  1. Currently get_types()$types returns both logical vector or integer vector depending on the query. So get_estimands(M1, using = "posteriors", queries = "(Y[X=1]>Y[X=0])-(Y[X=1]<Y[X=0])") works through get_types but shouldn't. My sense is get_types should only return logical vector indicating types that satisfy a logical query.
  2. Unclear from the examples but the queries in get_estimands are ratios of type counts? So something like count_types() , for example:
get_estimands(M1, inquiry = list(ATE = count_types(M1, "(Y[X=1]>Y[X=0]") /
                                       count_types(M1, "Y[X=1]<Y[X=0])")))
  1. We could also implement a more general operate_types() helper allowing (non-logical) operations on types beyond ratios, like the sort of query in 1. that is supposed to return integers rather than a logical vector ("(Y[X=1]>Y[X=0])-(Y[X=1]<Y[X=0])").

PS 2. and 3. could definitely go together because they're doing slightly different things. Does that make sense?

clarabicalho avatar Jul 10 '19 16:07 clarabicalho

On Wed, Jul 10, 2019 at 9:00 AM Clara Bicalho [email protected] wrote:

Gathering @lilymedina https://github.com/lilymedina's and my thoughts on this:

  1. Currently get_types()$types returns both logical vector or integer vector depending on the query. So get_estimands(M1, using = "posteriors", queries = "(Y[X=1]>Y[X=0])-(Y[X=1]<Y[X=0])") works through get_types but shouldn't. My sense is get_types should only return logical vector indicating types that satisfy a logical query.

I can see the reasoning to keep it logical (though I do love that this ATE example generates a kind of "net" type: 1 if Y1>Y0; -1 if Y1 < Y0, 0 otherwise. So neat. But to diambiguate am ok if this returns generically types.

  1. Unclear from the examples but the queries in get_estimands are ratios of type counts? So something like count_types() , for example:

get_estimands(M1, inquiry = list(ATE = count_types(M1, "(Y[X=1]>Y[X=0]") / count_types(M1, "Y[X=1]<Y[X=0])")))

Yes I think you are thinking about it correctly. Though this ^ is not an ATE. And think we should have tight syntax if at all possible.

For the ratio:

get_estimands(M1, query = list(Q = mean("(Y[X=1]>Y[X=0]") /mean(M1, "Y[X=1]<Y[X=0])")))

For the ATE:

get_estimands(M1, query = list(ATE = mean("(Y[X=1]>Y[X=0]") - mean(M1, "Y[X=1]<Y[X=0])")))

however this is quite different to the current set up where the "mean" operator is actually given in the "stats" argument

I wonder if the stats argument should just be turned into a general function.

get_estimands(M1, query1 = "(Y[X=1]>Y[X=0]", query2 = mean(M1, "Y[X=1]<Y[X=0])", stats = mean(query1 - query2))) get_estimands(M1, query1 = "(Y[X=1]>Y[X=0]", query2 = mean(M1, "Y[X=1]<Y[X=0])", stats = mean(query1) / mean(query2)))

We could also implement a more general operate_types() helper allowing (non-logical) operations on types beyond ratios, like the sort of query in

  1. that is supposed to return integers rather than a logical vector ( "(Y[X=1]>Y[X=0])-(Y[X=1]<Y[X=0])").

and 3. could definitely go together because they're doing slightly different things. Does that make sense?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/macartan/gbiqq/issues/69?email_source=notifications&email_token=ADBE57J6GTB3ELNF5P3WLXTP6YBTXA5CNFSM4H6NOTC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZT56AQ#issuecomment-510123778, or mute the thread https://github.com/notifications/unsubscribe-auth/ADBE57K7RVB5OXUNVCD3CATP6YBTXANCNFSM4H6NOTCQ .

macartan avatar Jul 10 '19 16:07 macartan

in our last discussion on this we thought about having an internal function that handles non-linear operators over types. As opposed to having get_types doing this type of operations.

lilymedina avatar Mar 25 '20 00:03 lilymedina

I think havingthe stats function handle this is the right approach:

query_distribution(model, list(query1 = "(Y[X=1]>Y[X=0]", query2 = mean(M1,
"Y[X=1]<Y[X=0])"), stats = mean(query1) / mean(query2)))
  • this requires though changing when stats is used; currently at the end of each query calculation
  • default behavior would become means for each query in the list, but others possible

it soudns conceptually right to me and I think from a user facing perspective this could be done later without a change to arguments?

macartan avatar Mar 25 '20 07:03 macartan