Coder Social home page Coder Social logo

smartutils's Issues

Coefficient of beta 2

Right now, it seems as if beta[2] is providing the effect estimate of the the effect of A_2 given non-response rather than just the effect of A_2. If you run 1000 simulations, then the mean effect estimate of beta[2] = true beta[2]/(1 - r) where r denotes the probability of response. I can't seem to figure out why this is occurring. The other three coefficients seem to be correct.
Code:
Screenshot 2023-05-09 at 7 15 28 PM

Results:
Screenshot 2023-05-09 at 7 17 00 PM

True Betas:
Screenshot 2023-05-09 at 7 17 22 PM

Specification of outcome variable in cSMART.mm

I'm currently trying to specify a particular variable, y_adj, as my outcome variable in cSMART.mm() and I think there's something off with how the function handles the argument Y = "y_adj". I specify it as follows:

report <- cSMART.mm(Y ~ A1 + A2 + I(A1 * A2), df1, verbose = TRUE, covstr = 'IND', i = "school", Y = "y_adj")

but that provides the same output as when I use:

report <- cSMART.mm(Y ~ A1 + A2 + I(A1 * A2), df1, verbose = TRUE, covstr = 'IND', i = "school", Y = "Y")

(and note that it provides an error when I start with cSMART.mm(y_adj ~ ...). When I instead recode y_adj as simply Y, I obtain different (and presumably, correct) output.

Nullify A2 when R=1

      if (R == 1) {
        treat_code <- "-1,1,."
        A2 <- 1
      }

and

     if (R == 1) {
        treat_code <- "1,1,."
        A2 <- 1
      }

Wrong probability for the Bernoulli random variable

    if (A1 == 1) {
      R <-  rbinom(1, 1, p_1)
      if (R == 1) {
        treat_code <- "1,1,."
        A2 <- 1
      } else if (R == 0) {
        A2 <-  (2 * rbinom(1, 1, p_A2)) - 1
        treat_code <- sprintf("1,0,%d", A2)
      }
    } else if (A1 == -1) {
      R <-  rbinom(1, 1 , p_1)
      if (R == 1) {
        treat_code <- "-1,1,."
        A2 <- 1
      }
      else if (R == 0) {
        A2 <-  (2 * rbinom(1, 1, p_A2)) - 1
        treat_code <- sprintf("-1,0,%d", A2)
      }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.