# Example: How to use od.REX.D for a quadratic model on [-1,1]x[-1,1] # First, we will use the function F.cube of the package OptimalDesign # to easily generate the matrix of all permissible regressors: library(OptimalDesign) Fq <- F.cube(~x1+x2+I(x1^2)+I(x2^2)+I(x1*x2), c(-1,-1), c(1,1), c(101, 101)) # Let n be the size of the design space and m the number of parameters: n <- dim(Fq)[1]; m <- dim(Fq)[2] # Compute the D-optimal approximate design using od.REX.D: resR <- od.REX.D(Fq, sample(1:n, m), gam=4, eff=1-1e-10, t.max=Inf) # Extract the indices of the support of the design: supp <- (1:n)[resR$w.best > 1e-12] # Print a compact table of the D-optimal design: cbind(Fq[supp, 2:3], weight=resR$w.best[supp]) # Print the time-profile of the computation: print(cbind(format(round(resR$prof[,1], 2), nsmall = 2), format(round(resR$prof[,2], 12), nsmall = 12)), quote=FALSE)