# \donttest{
## Example 1:
## This example involves finding an A-optimal design for a functional logistic
## model of 12 runs depending on one profile factor. The settings of the profile
## factor are represented by a B-spline basis of degree zero and a three interior knots
## at (0.25, 0.50, 0.75). The single functional parameter is represented with a linear
## power series basis. The method of approximation is Monte Carlo with the prior
## specified by the function prmc. Three random starts are chosen.
set.seed(100) ## Set seed to achieve reproducibility.
prmc <- function(B,Q) {
matrix(rnorm(B*Q, mean=0, sd=sqrt(2)), nrow=B, ncol=Q)
}
## A function which specifies the prior. This function returns a
## B by Q matrix of randomly generated values from the prior
## distribution for the model parameters.
example1 <- pfglm(formula = ~ 1 + x1, nsd = 3, mc.cores = 1, npf = 1,
tbounds = c(0,1), nruns = 12, startd = NULL,
dx = c(0), knotsx = list(c(0.25,0.50,0.75)),
pars = c("power"), db = c(1), knotsb = list(c()),
lambda = 0, criterion = "A", family = binomial,
method=c("MC"), level = 6, B = 10000, prior = prmc,
dlbound = -1, dubound = 1, tol = 0.0001, progress = FALSE)
print(example1) ## prints the output of example1.
##
## The number of profile factors is: 1
##
## The number of runs is: 12
##
## The objective criterion is: A-optimality
##
## The objective value is: 20.23283
##
## The number of iterations is: 5
##
## The method of approximation is: MC
##
## The family distribution and the link function are: binomial and logit
##
## The computing elapsed time is: 00:00:12
##
## plot(example1)
## then give the number of profile factor to plot
# }
## Example 2:
## This example involves finding a A-optimal design for a functional logistic
## model of 8 runs depending on one profile factor. The settings of the profile
## factor are represented by a B-spline basis of degree zero and a single interior knot
## at 0.50. The single functional parameter is represented with a linear
## power series basis. The method of approximation is Quadrature with Normal prior
## distribution, with all parameters having mean 0 and variance 2.
## Five random starts are chosen.
example2 <- pfglm(formula = ~ 1 + x1, nsd = 5, mc.cores = 1, npf = 1,
tbounds = c(0,1), nruns = 8, startd = NULL,
dx = c(0), knotsx = list(c(0.25,0.50,0.75)),
pars = c("power"), db = c(1), knotsb = list(c()),
lambda = 0, criterion = "A", family = binomial,
method = c("quadrature"), level = NULL, B = NULL,
prior = list(mu = c(0), sigma2 = c(2)),
dlbound = -1, dubound = 1, tol = 0.0001,
progress = FALSE)
## The number of profile factors is: 1
##
## The number of runs is: 8
##
## The objective criterion is: A-optimality
##
## The objective value is: 31.32342
##
## The number of iterations is: 9
##
## The method of approximation is: quadrature
##
## The family distribution and the link function are: binomial and logit
##
## The computing elapsed time is: 00:00:00
Run the code above in your browser using DataLab