Description Usage Arguments Value Examples
View source: R/plot_profile_function.R
Plots the previously calculated profiles of create.profile
.
1 | plotting.profile(which.par, homedir = getwd(), conf.level = 0.95, ...)
|
which.par |
Name of the parameter that a profile should be obtained for. If multiple profiles are supposed to be calculated, a vector can be passed along as well. Alternatively, supplying "all.par" calculates the profiles for all available parameters. |
homedir |
The directory to which the results should be saved to. Default to |
conf.level |
The confidence level used for calculating the confidence intervals. Default to 0.95. |
... |
Additional arguments that can be passed on to |
Plots the profiles and returns the confidence intervals
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #' #create data with standard deviation of 1
x.values <- 1:7
y.values <- 9 * x.values^2 - exp(2 * x.values)
sd.y.values <- rep(1,7)
#define initial parameter values
inits <- c(p1 = 3, p2 = 4, p3 = -2, p4 = 2, p5 = 0)
#define cost function that returns the negative log-likelihood
cost_function <- function(parms, x.vals, y.vals, sd.y){
# restrict the search range to -5 to +5
if(max(abs(parms)) > 5){
return(NA)
}
with(as.list(c(parms)), {
res <- p1*4 + p2*x.vals + p3^2*x.vals^2 + p4*sin(x.vals) - exp(p5*x.vals)
diff <- sum((res - y.vals)^2/sd.y)
})
}
#perform model selection
res <- create.profile(which.par = "all.par",
par.names = inits,
range = list(seq(0, 2, 0.1),
seq(0, 5, 1),
seq(2.9, 3.1, 0.01),
seq(0, 3, 0.1),
seq(1.999999, 2.000001, 0.0000001)),
fit.fn = cost_function,
optim.runs = 1,
delete.old = TRUE,
x.vals = x.values,
y.vals = y.values,
sd.y = sd.y.values)
plotting.profile("all.par")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.