Simulation of a dose-response curve with user-specified dose values and error distribution.

rdrm(nosim, fct, mpar, xerror, xpar = 1, yerror = "rnorm", ypar = c(0, 1),
  onlyY = FALSE)

Arguments

nosim

numeric. The number of simulated curves to be returned.

fct

list. Any built-in function in the package drc or a list with similar components.

mpar

numeric. The model parameters to be supplied to fct.

xerror

numeric or character. The distribution for the dose values.

xpar

numeric vector supplying the parameter values defining the distribution for the dose values. If xerror is a distribution then remember that the number of dose values also is part of this argument (the first argument).

yerror

numeric or character. The error distribution for the response values.

ypar

numeric vector supplying the parameter values defining the error distribution for the response values.

onlyY

logical. If TRUE then only the response values are returned (useful in simulations). Otherwise both dose values and response values (and for binomial data also the weights) are returned.

Details

The distribution for the dose values can either be a fixed set of dose values (a numeric vector) used repeatedly for creating all curves or be a distribution specified as a character string resulting in varying dose values from curve to curve.

The error distribution for the response values can be any continuous distribution like rnorm or rgamma. Alternatively it can be the binomial distribution rbinom.

Value

A list with up to 3 components (depending on the value of the onlyY argument).

References

~put references to the literature/web site here ~

Examples

## Simulating normally distributed dose-response data ## Model fit to simulate from ryegrass.m1 <- drm(rootl~conc, data = ryegrass, fct = LL.4()) ## 10 random dose-response curves based on the model fit sim10a <- rdrm(10, LL.4(), coef(ryegrass.m1), xerror = ryegrass$conc) sim10a
#> $x #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] #> [1,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [2,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [3,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [4,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [5,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [6,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [7,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [8,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [9,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [10,] 0 0 0 0 0 0 0.94 0.94 0.94 1.88 1.88 1.88 3.75 #> [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] #> [1,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [2,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [3,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [4,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [5,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [6,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [7,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [8,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [9,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> [10,] 3.75 3.75 7.5 7.5 7.5 15 15 15 30 30 30 #> #> $y #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] #> [1,] 6.504645 6.326134 5.334205 7.721202 9.280034 8.953097 8.703807 7.333097 #> [2,] 6.420938 9.161273 6.536564 7.337932 8.386111 7.967100 6.042894 8.796776 #> [3,] 7.414667 7.698021 7.028222 9.195544 6.626636 7.150189 7.447056 7.527533 #> [4,] 7.017743 7.495155 7.560129 9.241746 8.414481 7.207792 6.760996 6.809115 #> [5,] 9.183904 7.089027 7.374186 6.748351 6.399402 7.604708 7.790634 6.241715 #> [6,] 6.134385 7.303266 7.847950 8.040487 9.282043 8.071802 7.753336 5.879548 #> [7,] 8.490428 7.052179 7.388594 7.561643 8.870711 6.718094 7.597215 7.018335 #> [8,] 5.947482 7.518250 7.690510 7.762480 7.360530 7.197111 7.051964 7.325444 #> [9,] 7.275794 7.330922 8.238051 8.001791 7.889586 8.739220 6.651174 7.463123 #> [10,] 8.675090 7.771790 8.066295 9.090500 6.165093 5.745235 9.189518 6.900071 #> [,9] [,10] [,11] [,12] [,13] [,14] [,15] #> [1,] 6.570567 5.612329 8.439093 5.725059 4.6255186 4.136818 2.847341 #> [2,] 8.912928 5.837975 5.809030 5.885423 1.2847168 2.656616 4.135515 #> [3,] 6.975992 6.776143 5.970530 7.495005 1.3256084 2.932646 5.392964 #> [4,] 6.955902 6.197190 6.544389 4.809748 4.5259949 3.442191 2.201608 #> [5,] 7.766050 6.081771 6.320336 6.096133 0.8870236 2.843685 3.247255 #> [6,] 7.702998 6.966522 7.664001 6.077113 3.7001785 3.243735 2.575318 #> [7,] 8.607236 7.167234 6.508569 5.501808 3.3235976 3.972992 2.751160 #> [8,] 10.278203 7.473212 6.522847 6.964712 3.1802275 2.223553 3.608103 #> [9,] 6.822510 5.916967 5.559288 5.928278 2.1638781 1.529925 4.733718 #> [10,] 7.467960 6.556054 5.234875 5.667755 5.0065202 2.121485 3.979983 #> [,16] [,17] [,18] [,19] [,20] [,21] #> [1,] -0.1772826 1.4946823 1.07618626 0.5701545 -0.79956605 0.8410635 #> [2,] 1.8225973 2.4251136 1.35403261 1.5643747 -0.19840579 0.4945068 #> [3,] 2.4672549 -0.3663400 1.21427588 -0.8536887 0.18719848 1.3170112 #> [4,] 2.6203378 0.5224968 0.78408026 1.6771057 1.32744970 0.7337417 #> [5,] 0.4195733 -1.4093856 1.65943262 1.5170427 0.02742336 -0.2350584 #> [6,] 1.3925381 0.2880446 0.52271382 0.6178868 0.56556894 1.3782432 #> [7,] 1.1363785 2.0036613 0.07354404 1.1129297 0.95959186 0.9374834 #> [8,] 0.6957562 1.8322343 2.42254184 0.3288058 1.27139695 0.3331472 #> [9,] 0.1789984 1.2700344 1.41729933 0.8824420 0.78596437 1.4537650 #> [10,] 1.0334706 -0.0352803 3.65460642 -0.5870528 -1.25933144 2.1941271 #> [,22] [,23] [,24] #> [1,] 1.64332715 0.8393622 1.1101611 #> [2,] 0.40815097 -0.5670276 1.1362685 #> [3,] -0.34331827 1.6551181 -0.6208794 #> [4,] -1.13885533 0.9022009 2.3675480 #> [5,] -0.03425121 0.9520896 0.3430201 #> [6,] 0.18861683 0.2546174 1.2096681 #> [7,] 0.95328850 0.4604991 -1.0384838 #> [8,] 0.01987101 -0.6476905 0.2563355 #> [9,] 1.81413736 -0.3708223 -0.9416715 #> [10,] -0.18689642 -0.3632936 1.1226729 #>
## Simulating binomial dose-response data ## Model fit to simulate from deguelin.m1 <- drm(r/n~dose, weights=n, data=deguelin, fct=LL.2(), type="binomial") ## 10 random dose-response curves sim10b <- rdrm(10, LL.2(), coef(deguelin.m1), deguelin$dose, yerror="rbinom", ypar=deguelin$n) sim10b
#> $x #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [2,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [3,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [4,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [5,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [6,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [7,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [8,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [9,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> [10,] 5.128614 10 20.41738 30.19952 40.73803 50.11872 #> #> $w #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 49 48 48 49 50 48 #> [2,] 49 48 48 49 50 48 #> [3,] 49 48 48 49 50 48 #> [4,] 49 48 48 49 50 48 #> [5,] 49 48 48 49 50 48 #> [6,] 49 48 48 49 50 48 #> [7,] 49 48 48 49 50 48 #> [8,] 49 48 48 49 50 48 #> [9,] 49 48 48 49 50 48 #> [10,] 49 48 48 49 50 48 #> #> $y #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 7 17 35 44 45 46 #> [2,] 18 30 41 45 47 46 #> [3,] 14 26 37 41 48 48 #> [4,] 9 27 37 41 46 45 #> [5,] 9 16 41 46 48 47 #> [6,] 8 18 39 49 45 47 #> [7,] 12 21 32 42 49 47 #> [8,] 17 26 38 47 48 45 #> [9,] 10 27 34 42 47 47 #> [10,] 12 22 37 45 46 47 #>