Giter Site home page Giter Site logo

Comments (7)

kgoldfeld avatar kgoldfeld commented on June 26, 2024 1

Yes - that is indeed a bug. If you want a quick workaround while that is fixed, you can do this:


ydef <- defData(varname = "randomEffect", 
                dist = "normal", formula = 0, variance = sqrt(10))
ydef <- defData(ydef, varname = "T", 
                dist = "trtAssign", formula = "1;1")

genData(6, ydef)
#>    id randomEffect T
#> 1:  1    2.6744327 0
#> 2:  2    0.3138995 1
#> 3:  3   -0.9968553 0
#> 4:  4    0.2780552 1
#> 5:  5   -1.3009989 1
#> 6:  6    1.5663468 0

But great catch, I will certainly fix that bug.

from simstudy.

kgoldfeld avatar kgoldfeld commented on June 26, 2024 1

@hebaalhosainyTU This has been fixed in the current development version. Thanks again.

from simstudy.

hebaalhosainyTU avatar hebaalhosainyTU commented on June 26, 2024

After applying the trtAssign function, the values in randomEffect column changed and not anymore normally distributed.

from simstudy.

assignUser avatar assignUser commented on June 26, 2024

Hello @hebaalhosainyTU thanks for the report. Next time please consider using reprex (see below) as it makes it easier to reproduce issues.

@kgoldfeld Reprex below is rendered with cran version of simstudy and indeed looks problematic. I haven't had time to look deeoer into it though.

library(simstudy)
ydef <- defData(varname = "randomEffect", dist = "normal", formula = 0, variance = sqrt(3))

indData <- genData(24, ydef)
head(indData)
#>    id randomEffect
#> 1:  1    2.9851502
#> 2:  2    0.9825252
#> 3:  3   -0.3632496
#> 4:  4   -0.3291816
#> 5:  5    0.4210097
#> 6:  6    1.5862488
indData <- trtAssign(indData, nTrt = 2, balanced = TRUE, grpName = "T")
head(indData)
#>    id randomEffect T
#> 1:  1            2 1
#> 2:  2            0 1
#> 3:  3            0 1
#> 4:  4            0 1
#> 5:  5            0 1
#> 6:  6            1 0

Created on 2022-09-28 with reprex v2.0.2

from simstudy.

assignUser avatar assignUser commented on June 26, 2024

Running the code a few times shows that the randomEffect col is rounded to 0 decimal places...

from simstudy.

assignUser avatar assignUser commented on June 26, 2024

https://github.com/kgoldfeld/simstudy/blob/main/R/group_data.R#L401-L403
Converts ALL columns to integer ⚠️

from simstudy.

kgoldfeld avatar kgoldfeld commented on June 26, 2024

@assignUser It is really strange how those lines of code got in there - must have been added to facilitate testing. And yet, testing did not pick that up. It is particularly odd since the output from trtAssign (really trtObserve) is already integer. Not sure why it would have seemed like a good idea to convert even the treament variable to integer. I will remove the offending code.

from simstudy.

Related Issues (20)

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.