Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balanceTest() should work without explicit data argument #30

Open
benthestatistician opened this issue Aug 5, 2014 · 4 comments
Open
Assignees
Labels

Comments

@benthestatistician
Copy link
Collaborator

data(nuclearplants)
with(nuclearplants, xBalance(pr~cap+ pt))

Doesn't work. It may be that some minor adjustments would get it to work, namely:

  1. Changing R/xBalance.R:L2 from
data,

over to

data=NULL,

and
2. inserting a switch around R/xBalance.make.stratwts.R:L31-36 so that, in the event that data is NULL, sweights is evaluated as

        do.call(swt.ls[[nn]],
                args=list(data=data.frame(Tx.grp=zz[goodstrat.df[[nn]]],

                              stratum.code=factor(ss.df[goodstrat.df[[nn]],nn])

                              )
),
                envir=parent.frame())

ie, the code ,data[goodstrat.df[[nn]],,drop=FALSE] is removed.

@benthestatistician
Copy link
Collaborator Author

Cross-linking w/ #15, which may be easier pickings once this can of worms has been opened. (And vice versa.)

@benthestatistician benthestatistician self-assigned this Feb 27, 2016
@benthestatistician
Copy link
Collaborator Author

in light of d8bf73c , this may be working now on the clusters branch. Remains to be tested.

@benthestatistician
Copy link
Collaborator Author

benthestatistician commented Jun 11, 2018

I think this is basically enabled for balanceTest(), but w/ some gaps. E.g., the following doesn't work:

  set.seed(20180207)
  n <- 100
  x1 <- rnorm(n)
  x2 <- rnorm(n)
  x3 <- 0.5 + 0.25 * x1 - 0.25 * x2 + rnorm(n)
  y <- sample(rep(c(1,0), n/2), prob = exp(x3) / (1 + exp(x3)))

  xy <- data.frame(x1, x2, x3, y)
  wts <- rpois(n, 7)
  balanceTest(y ~ x1 + x2 + x3, data = xy, unit.weights = wts)

rather you have to do

xy.wts <- data.frame(xy, wts)
balanceTest(y ~ x1 + x2 + x3, data = xy.wts, unit.weights = wts)

oughta fix this.

@benthestatistician benthestatistician changed the title xBalance should work without explicit data argument balanceTest() should work without explicit data argument Jul 12, 2018
@benthestatistician
Copy link
Collaborator Author

The counterexample in my last comment seems to have been fixed (in proj1-balT) somewhere along the way. OTOH

> balanceTest(y ~ x1 + x2 + x3)
Error in terms.formula(formula, data = data) : 
  argument is not a valid model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant