dspline.RdUsed to fit B-splines and natural cubic splines(Perperoglu et al. 2019) .
dspline(type = "bs", knots = NULL, degree = 3, df = NULL, betas = "rel")The type of spline. Can take "bs" (B-spline),
or "ns" (natural cubic spline).
Piecewise linear splines can be fitted using "bs" with degree=1.
Indicates the number/location of internal knots. If a single whole number >=1 is given
it indicates the number of equally-spaced internal knots. Otherwise (a vector, or a non-integer value)
the values are treated as the quantile locations of the knots as a proportion of the maximum dose in the
dataset. For example, if the maximum dose in the dataset is 100mg/d for a particular agent, knots=c(0.1,0.5)
would indicate knots should be fitted at 10mg/d and 50mg/d.
a positive integer giving the degree of the polynomial from which the spline function is composed
(e.g. degree=3 represents a cubic spline).
degrees of freedom. One can supply df rather than
knots; ns() then chooses df - 1 - intercept knots at
suitably chosen quantiles of x (which will ignore missing
values). The default, df = NULL, sets the number of
inner knots as length(knots).
A vector of beta parameters corresponding to each spline coefficient. The length must be equal
to the number of dose-response parameters generated by the spline function. If a single value is given then this
specification will be applied to all beta paramters in the model. Can take "rel", "common", "random" or be
assigned a numeric value (see details).
An object of class("dosefun")
| Argument | Model specification |
"rel" | Implies that relative effects should be pooled for this dose-response parameter separately for each agent in the network. |
"common" | Implies that all agents share the same common effect for this dose-response parameter. |
"random" | Implies that all agents share a similar (exchangeable) effect for this dose-response parameter. This approach allows for modelling of variability between agents. |
numeric() | Assigned a numeric value, indicating that this dose-response parameter should not be estimated from the data but should be assigned the numeric value determined by the user. This can be useful for fixing specific dose-response parameters (e.g. Hill parameters in Emax functions) to a single value. |
When relative effects are modelled on more than one dose-response parameter,
correlation between them is automatically estimated using a vague inverse-Wishart prior.
This prior can be made slightly more informative by specifying the scale matrix omega
and by changing the degrees of freedom of the inverse-Wishart prior
using the priors argument in mbnma.run().
Perperoglu A, Sauerbrei W, Abrahamowicz M, Schmid M (2019). “A review of spline function procedures in R.” BMC Medical Research Methodology, 19(46), 1-16. doi:10.1186/s12874-019-0666-3 .
# Natural cubic spline with 1 knot
dspline(type="bs", knots=1,
betas="rel")
#> $name
#> [1] "bs"
#>
#> $fun
#> ~beta.1 * spline.1 + beta.2 * spline.2 + beta.3 * spline.3 +
#> beta.4 * spline.4
#> <environment: 0x5594ebde16a0>
#>
#> $params
#> [1] "beta.1" "beta.2" "beta.3" "beta.4"
#>
#> $nparam
#> [1] 4
#>
#> $df
#> NULL
#>
#> $knots
#> $knots[[1]]
#> [1] 1
#>
#>
#> $degree
#> [1] 3
#>
#> $jags
#> [1] "s.beta.1[agent[i,k]] * spline[i,k,1] + s.beta.2[agent[i,k]] * spline[i,k,2] + s.beta.3[agent[i,k]] * spline[i,k,3] + s.beta.4[agent[i,k]] * spline[i,k,4]"
#>
#> $apool
#> beta.1 beta.2 beta.3 beta.4
#> "rel" "rel" "rel" "rel"
#>
#> $bname
#> beta.1 beta.2 beta.3 beta.4
#> "beta.1" "beta.2" "beta.3" "beta.4"
#>
#> attr(,"class")
#> [1] "dosefun"
# Piecewise linear B-spline with knots at 0.1 and 0.5 quantiles
# Single parameter independent of treatment estimated for 1st coefficient
#with random effects
dspline(type="bs", degree=1, knots=c(0.1,0.5),
betas=c("random", "rel", "rel"))
#> $name
#> [1] "bs"
#>
#> $fun
#> ~beta.1 * spline.1 + beta.2 * spline.2 + beta.3 * spline.3
#> <environment: 0x5594eb05f220>
#>
#> $params
#> [1] "beta.1" "beta.2" "beta.3"
#>
#> $nparam
#> [1] 3
#>
#> $df
#> NULL
#>
#> $knots
#> $knots[[1]]
#> [1] 0.1 0.5
#>
#>
#> $degree
#> [1] 1
#>
#> $jags
#> [1] "s.beta.1[agent[i,k]] * spline[i,k,1] + s.beta.2[agent[i,k]] * spline[i,k,2] + s.beta.3[agent[i,k]] * spline[i,k,3]"
#>
#> $apool
#> beta.1 beta.2 beta.3
#> "random" "rel" "rel"
#>
#> $bname
#> beta.1 beta.2 beta.3
#> "beta.1" "beta.2" "beta.3"
#>
#> attr(,"class")
#> [1] "dosefun"