#################################################### ### Optimality criterion for Home Assignment 3 ### ### Compare L3 of OASII, Stockholm University ### ### Frank Miller, 2021-04-21 ### #################################################### # Computation of information matrix M and optimality criterion # (D-optimality penalized for number of design points; to be minimised) # w is vector with possible design points ("design space") # x is a design in the form {0, 1}^(length of w) saying if w[i] is used in the design (1) or not (0) crit <- function(x, w){ xv <- w[x==1] n <- length(xv) X <- cbind(rep(1, n), xv, xv^2, xv^3) # nx4-design matrix M <- t(X) %*% X # 4x4-information matrix n*0.2 - log(det(M)) } # Example call of crit: w <- seq(-1, 1, by=0.05) # design space lw <- length(w) x <- rbinom(n=lw, size=1, prob=0.5) # a random design crit(x, w)