Specific Covariate values

Hi ,
Can anyone help me how to assign specific covariate values for subjects?
I am trying a simulation exercise, where i have n number of subjects. I need to assign a specific covariate value for each of these n subjects.

I created n number of subjects and assigned the covariates individually.
Is there any other way of assigning specific covariate values to the population?

Welcome to the community @Aarun. see if this helps below


julia> ev = DosageRegimen(100, time=0, addl=3, ii=24)
DosageRegimen
│ Row │ time    │ cmt   │ amt     │ evid │ ii      │ addl  │ rate    │ duration │ ss   │
│     │ Float64 │ Int64 │ Float64 │ Int8 │ Float64 │ Int64 │ Float64 │ Float64  │ Int8 │
├─────┼─────────┼───────┼─────────┼──────┼─────────┼───────┼─────────┼──────────┼──────┤
│ 1   │ 0.0     │ 1     │ 100.0   │ 1    │ 24.0    │ 3     │ 0.0     │ 0.0      │ 0    │

julia> ##Create a Subject
       s1 = Subject(id=1,  evs=ev, cvs=(isPM=1, wt=70))
Subject
  ID: 1
  Events: 4
  Covariates: (isPM = 1, wt = 70)


julia> s2 = Subject(id=2,  evs=ev, cvs=(isPM=0, wt=50))
Subject
  ID: 2
  Events: 4
  Covariates: (isPM = 0, wt = 50)


julia> ## create a population
       pop = [s1,s2]
Population
  Subjects: 2
  Covariates: isPM, wt


julia> #A small function to randomly choose covariates
       choose_covariates() = (isPM = rand([1, 0]),
                     wt = rand(55:80))
choose_covariates (generic function with 1 method)

julia> # generate a simple population using map
       pop_with_covariates = Population(map(i -> Subject(id=i, evs=ev, cvs=choose_covariates()),1:10))
Population
  Subjects: 10
  Covariates: isPM, wt

In my understanding…
In the above codes, for the 2 subjects specific covariate values were assigned (wt = 50 and wt = 70). These individual subjects are then pooled to form a population.
For the population of 10, covariates were randomly assigned (wt ranging from 55 to 80).

My question is, whether do we have a specific code to assign specific covariates (not random) for a population, other than creating n number of subjects(with specific covariates) and combining them to a population.

I am not sure I understand, but if you want more control, you can create a dataset outside, using your favorite tool and then call read_pumas. See for example below

df1 = DataFrame(id = [1,1,1,1,1,2,2,2,2,2],
                time = [0,1,2,3,4,0,1,2,3,4],
                amt=[10,0,0,0,0,10,0,0,0,0],
                cmt=[1,2,2,2,2,1,2,2,2,2],
                evid=[1,0,0,0,0,1,0,0,0,0],
                dv=[missing,8,6,4,2,missing,8,6,4,2],
                age=[45,45,45,45,45,50,50,50,50,50],
                sex = ["M","M","M","M","M","F","F","F","F","F"],
                crcl =[90,85,75,72,70,110,110,110,110,110])

Then, I create a population out of this using read_pumas

df1_r = read_pumas(df1, cvs=[:age,:sex,:crcl])

I can now pass this into a simobs or a fit function

1 Like

I will try this out. Thanks.