ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

Error of love.plot and bal.tab with splines #37

Closed markdanese closed 1 year ago

markdanese commented 1 year ago

This previously worked fine a few months back, so I suspect it is an issue in the last update. I am using a natural spline in my propensity score formula and receive the following error:

Error in str2lang(termtext) : <text>:1:35: unexpected numeric constant
1: bleed_cause+gcs+ns(age, knots = 2)1
                                      ^

The summary of the model is given below

A weightit object
 - method: "ps" (propensity score weighting)
 - number of obs.: 500
 - sampling weights: none
 - treatment: 2-category
 - estimand: ATE
 - covariates: bleed_cause, gcs, ns(age, knots = 2)1, ns(age, knots = 2)2, sex, ns(sbp, knots = 2)1, ns(sbp, knots = 2)2, mental_status, dnr, liver, stroke, ckd, heart_failure, diabetes, time_since
 - by: bleed_cause

It is clear that the parsing syntax is having trouble with the "1" that comes at the end of the variable created by the ns formula (i.e., the number of the knot being created).

I will see if I can create a reproducible example, but I am hoping that it might be something obvious to the developers when they see the error.

UPDATE: I used the previous version of WeightIt and the problem still exists so I will see if I can create an example. While I just ran this last week with no errors, I may have updated another package or something else may have changed.

markdanese commented 1 year ago

My apologies -- this looks like it is a cobalt issue. I lost track of which package was doing what.