romainkp / stremr

Streamlined Estimation for Static, Dynamic and Stochastic Treatment Regimes in Longitudinal Data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when running example code

micmart opened this issue · comments

Seems some definitions are missing in stratify_ if when following your example code.

> OData <- fitPropensity(OData, gform_CENS = gform_CENS, gform_TRT = gform_TRT, gform_MONITOR = gform_MONITOR, stratify_CENS = stratify_CENS)
Error in create_subset_expr(outvars = res$outvars, stratify.EXPRS = stratify.EXPRS) : 
  Could not locate the appropriate regression variable(s) within the supplied stratification list stratify_CENS, stratify_TRT or stratify_MONITOR.
The regression outcome variable(s) specified in gform_CENS, gform_TRT or gform_MONITOR were: ( 'C,TI,N' )
However, the item names in the matching stratification list were: ( 'C' )

Hi,

Thank you for reporting the issue. The error has been fixed. The previously provided example contained an error, which is now corrected, please try again. Please note that the example on the main page has been slightly expanded to provide description of the output as well as the example of the output from various estimators.

Hi, thanks for following up. I still get the same error though:

> OData <- fitPropensity(OData,
+                        gform_CENS = gform_CENS,
+                        gform_TRT = gform_TRT,
+                        stratify_CENS = stratify_CENS)
Error in create_subset_expr(outvars = res$outvars, stratify.EXPRS = stratify.EXPRS) : 
  Could not locate the appropriate regression variable(s) within the supplied stratification list stratify_CENS, stratify_TRT or stratify_MONITOR.
The regression outcome variable(s) specified in gform_CENS, gform_TRT or gform_MONITOR were: ( 'C,TI,N' )
However, the item names in the matching stratification list were: ( 'C' )

My apologies, I should have been a bit more clear. The example itself was incorrect -- the error displayed is correct. The example on the main page has been corrected, have you tried running the modified example?

The issue with this example is that the regression gform_CENS includes 3 outcome variables (the formula defines one regression but with 3 outcomes). However, the stratification criteria in stratify_CENS is only defined for one of these variables, namely, the variable C. The package currently requires you to define separate stratas for each outcome variable in each regression, if you are using the stratification at all. Please see the docs ?fitPropensity, the recent commit expands the description of how stratas work, see here: b4ee990