Pausal Zivference
@pausalz.bsky.social
2.2K followers 570 following 830 posts
Paul Zivich, Assistant (to the Regional) Professor Computational epidemiologist, causal inference researcher, amateur mycologist, and open-source enthusiast. https://github.com/pzivich #epidemiology #statistics #python #episky #causalsky
Posts Media Videos Starter Packs
pausalz.bsky.social
I haven't really paid attention to the lalonde data much, so what is the positivity violation that occurs?
pausalz.bsky.social
Feel free, I can also send any additional details you need
pausalz.bsky.social
Give it a read, there are some fun visualization in there, like this one
pausalz.bsky.social
Glad I get to continue my anti-R (and associated R products) persona
pausalz.bsky.social
The correct version would have instead re-sampled the age distribution form the data

This error is subtle (because it doesn't crash the program, I also missed it on my first glance) and anyone using LLMs like the quoted person is making these errors
pausalz.bsky.social
Now the trick is that the code it output is actually wrong in a subtle way. I actually hadn't noticed the error it introduce because it won't output an error. The red boxes are the error.

I won't get into the finer details, but this causes the whole procedure to under-estimate the variance
pausalz.bsky.social
and like the summary was fine. It was very basic and cursory, but no errors

It didn't highlight that I had code provided as part of the paper. So, I followed up by asking it for code. It generated a new example (using the details from the paper example)
pausalz.bsky.social
I wish he posted the code, so we could also see that it was just a bunch of regressions (which makes the mysticism of the blog post about it much funnier to me)

Whenever I ask for estimators with several steps (eg TMLE) from scratch, it doesn't work
pausalz.bsky.social
could be a cool mascot though
pausalz.bsky.social
lol it's so bad that bsky doesn't even want to show the screenshot
pausalz.bsky.social
Aptos is such a bad font, let along one to set as the default...
Microsoft Word document failing to render the default font, Aptos, in a legible way.
Reposted by Pausal Zivference
jamiecummins.bsky.social
Can large language models stand in for human participants?
Many social scientists seem to think so, and are already using "silicon samples" in research.

One problem: depending on the analytic decisions made, you can basically get these samples to show any effect you want.

THREAD 🧵
The threat of analytic flexibility in using large language models to simulate human data: A call to attention
Social scientists are now using large language models to create "silicon samples" - synthetic datasets intended to stand in for human respondents, aimed at revolutionising human subjects research. How...
arxiv.org
pausalz.bsky.social
The code above then fits the pooled logistic model, computes the censoring weights, and then estimates the risk function at the unique event times

This algorithm incorporates both aspects of computing IPCW

Finally, it gives us a consistent estimator of the variance without needing to bootstrap
pausalz.bsky.social
I do this with the following line from above. What is does is it takes the original risk set matrix (which includes events in their interval) and then I subtract off a matrix that indicates where the events happened in time

That zeroes out the contributions to the pooled logit model for events
pausalz.bsky.social
Okay so now we can look at how the elements from the EF are constructed. We construct 2 separate time design matrices (one for censoring times, the other for event times)

Here is where we exclude the events from contributing to the model (for the rows that correspond to the event times)
pausalz.bsky.social
Then a product-limit (discrete-time Kaplan-Meier) is applied using the IPCW
pausalz.bsky.social
For IPCW, we need to ensure they are aligned with the events times. To do this, I do a loop over the matrices and the unique event times. From the IPCW matrix, I create a new matrix that assigns the weights for each corresponding time by looking up the nearest time

(there is likely a better way)
pausalz.bsky.social
I'll skip ahead to defining the EF, so we can see the forest a bit before looking at trees

We fit a pooled logit model (given some input design matrices) and then generate predictions. To lag, we simply add a row of 1's at the top of the predicted Pr of uncensored and drop the last row
pausalz.bsky.social
The pooled logit algorithm in the pre-print thus needs to be modified so both of these are incorporated

The following is some Python code that does this process. First, is the setup
Python code that loads in packages and a few custom functions from a file called `efuncs`. That file simply contains some estimating functions that implement the pooled logistic procedure The second part creates a simple data set to implement this procedure with
pausalz.bsky.social
In long data sets, censoring usually happens at the end of the interval. Because of that, events happen before censoring, so they need to be excluded from the model

Further, the computed weights actually are important for the *next* interval since censoring is the last thing that happens
pausalz.bsky.social
By convention, we events are assumed to happen before censoring in survival analysis. This convention has a few important (but sometimes overlook) implications when constructing IPCW

1. events in an interval do not contribute to the risk set at the event time
2. weights need to be lagged
pausalz.bsky.social
A well-spent $10m per year on Bill Belichick. Glad our university leadership really knows where to invest wisely