Home > database >  How to model in r first time
How to model in r first time

Time:10-22

I have my function in R program:

I want to plot a dose response function

For any values of : X, c ,E , HS,

I'm new to R, so I am asking for help (and indulgence is my first question on this forum)

CodePudding user response:

First off, it's useful to recognise that V(c, E, HS, EC_50) has the form of a 3-parameter log-logistic dose-response function, where

  1. EC_50 is the log-transformed EC50 dose,
  2. HS is the Hill slope or slope factor,
  3. E is the lower asymptotic response limit,

and c is the log-transformed dose.

Note that exp^(...) is not valid R syntax; fixing this, we get the following form for V(c, E, HS, EC_50)

V <- function(c, E, HS, EC_50) E   (1 - E) / (1   exp(HS * (c - EC_50)))

We can now define some (sensible) values for the three parameters

HS <- 1
log_EC50 <- log(1e-3)
E <- 0

and then calculate the response for a range of (log-transformed dose) values c. We store values in a data.frame.

log_c <- seq(-12, 0, by = 0.1)
df <- data.frame(log_c = log_c, response = V(log_c, E, HS, log_EC50))

We can now plot the response as a function of log_c; I am using ggplot2 here to do the plotting.

library(ggplot2)
ggplot(df, aes(log_c, response))   
    geom_line()

enter image description here

  • Related