Jump to content


Photo

Randomly select covariate values

test

  • Please log in to reply
8 replies to this topic

#1 Nathan Teuscher

Nathan Teuscher

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 09 September 2014 - 08:01 PM

I have a PK/PD model that I would like to use for some simulations. The model has a variety of covariates and I want to explore the response across that range. For argument sake, let's say I have the following covariates:

 

PK covariate: Body weight (BW), Age (AGE)

PD covariate: Baseline Response (BResp)

 

I would like to run a simulation where BW, AGE, and BResp are randomly selected from a distribution for each covariate (for example BW values between 55 and 100).

 

My model is a text model in Phoenix NLME. I suspect I would need to input a data file with the timepoints of interest and dosing profiles of interest. But how do I randomly select the set of covariates? I'm guessing it is a line of code in the model text ...

 

Thanks in advance for the guidance!

Nathan



#2 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 10 September 2014 - 08:54 AM

You just need to define these continuous covariate as structural parameters and then the program will simulate BW, age, etc..

 

for example

 

stparm(BW=tvBW*exp(nBW)

 

fixef(tvBW=c(,70,))

 

ranef(diag(nBW)=c(0.1))

 

0;.1 is about 30% variability from which you can know the range of BW you will get.

 

best

Serge



#3 Samer Mouksassi

Samer Mouksassi

    Advanced Member

  • Val_Members
  • PipPipPip
  • 90 posts

Posted 10 September 2014 - 01:47 PM

in addition to what Serge mentioned you can try a transformation that will truncate the values into the range you want.

 

another idea would be to use a sequence statement and initialize the "covariate" values when the subject begins but we need to do some tests



#4 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 10 September 2014 - 02:03 PM

One way of truncating would be to use for example if BW must be between 40 and 90

 

BW=40+50*iogit(para)

 

para is a model parameter for example normally distributed where you give the mean and variance. ilogit (para) is between 0 and 1 and therefore BW will be between 40 and 90.

 

You can check with different means and variances for para to see how the BW distribution looks like.

 

Best

Serge



#5 Nathan Teuscher

Nathan Teuscher

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 10 September 2014 - 05:59 PM

Serge,

 

I'm getting the following error in the Compiler Output: undefined reference to `logit'

 

Here are snippets of my code:

test(){

        PK MODEL IS HERE

 

    C = A1 / V

 

        DMWEIGHT = 15+70*logit(para1)

    E0 = 20 + 35*logit(para2)

 

        PD MODEL IS HERE

 

    stparm(para1 = tvpara1*exp(npara1))

    stparm(para2 = tvpara2*exp(npara2))

 

    fixef(tvbwpara = c(0,0.5,1))

    fixef(tvskamppara = c(0,0.5,1))

    ranef(diag(nbwpara)=c(0.1))

    ranef(diag(nskamppara)=c(0.1))

 

        OTHER PARAMETERS DEFINED HERE

}

 

I also tried the function "iogit" with the same results. I must be defining the logit function incorrectly.

 

Thanks in advance.

Nathan



#6 Nathan Teuscher

Nathan Teuscher

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 10 September 2014 - 06:05 PM

Problem solved ... I misspelled the function ... it is "ilogit"

 

Nathan



#7 serge guzy

serge guzy

    Advanced Member

  • Members
  • PipPipPip
  • 485 posts

Posted 10 September 2014 - 06:07 PM

Yes ilogit or you can try also iprobit.

It will change the look of the distribution.

Best

Serge



#8 Samer Mouksassi

Samer Mouksassi

    Advanced Member

  • Val_Members
  • PipPipPip
  • 90 posts

Posted 10 September 2014 - 06:08 PM

I also got a response from our main developer Mike: " You can have a sequence block, and make up a random number in there. For a truncated uniform: double(u) sequence { u = low_limit + unif()*(high_limit - low_limit); } For a truncated normal, the code below samples from a standard normal, where the limits are in standard normal units. (When there's a mean and sd, they can transform the limits.) The user can transform it as needed. This is the rejection method. It uses a "while" statement to keep drawing numbers until it gets one that falls within the limits. (Note this can produce an inifinite loop.) double(u) double(x) sequence { x = low_limit - 1 while(x < low_limit || x > high_limit){ x = norm() } } Another way to get a truncated normal is to use iprobit to transform the limits to a uniform scale, then draw a uniform, and then transform it back to normal with the probit function. double(u) double(ulow) double(uhigh) double(x) sequence { ulow = iprobit(low_limit) uhigh = iprobit(high_limit) u = ulow + unif() * (uhigh - ulow) x = probit(u) } note that I did not test the above and it will be good if you can test it and report back to us note this require the latest 1.3 NLME that is not yet officially released but it is about to be very soon !
  • Vijay Ivaturi likes this

#9 Nathan Teuscher

Nathan Teuscher

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 12 September 2014 - 06:00 PM

The truncated uniform method (1st one presented) worked well.

I did not try the exclusion method (2nd one presented) ... I don't like to risk infinite loops :)

The third method didn't work for me. I may have coded it wrong, but since the first method appeared to work, I didn't troubleshoot it any further.

 

Thanks for the suggestions.

 

Nathan







Also tagged with one or more of these keywords: test

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users