Practical g-methods examples of using R's gfoRmula package for causal inference with time varying covariates Does anyone have any experience with using g-methods when outcome and covariates vary with time?  I found the R package gfoRmula with this documentation https://www.cell.com/patterns/pdf/S2666-3899(20)30008-8.pdf but little details of what to look out for in the outputs or how to choose the models.  My questions are:
1. model specifications
In the first example in the documentation for instance, what is the justification for choosing these specific models:
  covparams = list(
    covmodels = c(
      L1 ~ lag1_A + lag_cumavg1_L1 + lag_cumavg1_L2 + L3 + t0,
      L2 ~ lag1_A + L1 + lag_cumavg1_L1 + lag_cumavg1_L2 + L3 + t0,
      A ~ lag1_A + L1 + L2 + lag_cumavg1_L1 + lag_cumavg1_L2 + L3 + t0
      )
  )

and:
  ymodel = Y ~ A + L1 + L2 + L3 + lag1_A + lag1_L2 + t0

Is this based on trial and error or on domain knowledge or anything else? and if so, what should we be looking out for when selecting a specific model? ie is there a metric summarising model performance in the output?
2. plots
In the plot output using plot(gform_basic), what does the "non-parametric" curve refer to?
How do we interpret these plots? Do we expect the lines to be the same as for the risk plot?
Also, what is dt_cov_plot and how do we plot it?
3. estimates for specific values of covariates
Can we use this same model to get estimates for different baseline strata, e.g. by age group? or do we have to run a separate model for each strata of interest?
If anyone has the answers or can point me to any detailed  tutorial of how to use the package in practice that would be much appreciated :)
And also... if anyone has over 1k credentials, could you add g-methods as a possible tag?

for anyone interested in this, i have now had the following answer from the package maintainer on git:

*

*model specifications
Is this based on trial and error or on domain knowledge or anything else? and if so, what should we be looking out for when selecting a specific model? ie is there a metric summarising model performance in the output?
Apart from considerations made for satisfying identifiability conditions which rely on domain knowledge, one (informal) approach for evaluating the presence of model misspecification is to compare the parametric vs nonparametric estimates of the natural course. Related, see the response to point 2.


*plots
In the plot output using plot(gform_basic), what does the "non-parametric" curve refer to?
How do we interpret these plots? Do we expect the lines to be the same as for the risk plot?
I'd suggest taking a look at Section 7 of the following paper for an introduction to the nonparametric estimates of the natural course risk and how to interpret these plots. Note that the nonparametric estimates are based on the observed data.
Young, J.G., Cain, L.E., Robins, J.M., O’Reilly, E.J., and Hernan, M.A. (2011). Comparative effectiveness of dynamic treatment regimes: an application of the parametric g-formula. Stat. Biosci. 3, 119–143.
We give more details in Appendix B of the Patterns paper for survival outcomes. The relevant paragraph is:
In addition to the parametric g-formula estimate of the natural course risk, a nonparametric estimate will also be computed automatically and reported in the output. When censoring events are present in the data, this is a completely unadjusted estimate of the natural course risk (i.e. it relies on marginal exchangeability for censoring).
When competing risks are absent or treated as censoring events, this is computed as the complement of a product-limit survival estimator in the observed data.
When competing risks are present and not treated as censoring events, this is computed using an Aalen Johansen estimator11. See Young et al and Logan et al for additional details.
Also, what is dt_cov_plot and how do we plot it?
dt_cov_plot is an object that is used internally in the package to support applying the plot function to the output of the gformula function (e.g., plot(gform_basic)). There is no need to work directly with dt_cov_plot unless you want to customize the plots of the parametric vs nonparametric estimates of covariate means under the natural course in a way that the package doesn't support.
Specifically, dt_cov_plot is a list where each component is a data table containing the nonparametric and parametric g-formula estimates of the means of the time-varying covariates under the natural course at each follow-up time point.


*estimates for specific values of covariates
Can we use this same model to get estimates for different baseline strata, e.g. by age group? or do we have to run a separate model for each strata of interest?
You would have to run the package separately for each baseline strata to obtain estimates of the counterfactual means for these strata
