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)
β”‚ 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))
  ID: 1
  Events: 4
  Covariates: (isPM = 1, wt = 70)

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

julia> ## create a population
       pop = [s1,s2]
  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))
  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],
                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.