## Not run:
# ### 1D functional predictor example ###
#
# data(gasoline)
#
# # input a single value of each tuning parameters
# gas.wnet1 <- wnet(gasoline$octane, xfuncs = gasoline$NIR[,1:256],
# nfeatures= 20, min.scale = 0, alpha = 1)
# gas.wpcr1 <- wcr(gasoline$octane, xfuncs = gasoline$NIR[,1:256], min.scale = 0,
# nfeatures = 20, ncomp = 15)
# gas.wpls1 <- wcr(gasoline$octane, xfuncs = gasoline$NIR[,1:256], min.scale = 0,
# nfeatures = 20, ncomp = 15, method = "pls")
# plot(gas.wnet1)
# plot(gas.wpcr1)
# plot(gas.wpls1)
#
# # input vectors of candidate tuning parameter values
# gas.wnet2 <- wnet(gasoline$octane, xfuncs = gasoline$NIR[,1:256],
# nfeatures= 20, min.scale = 0:3, alpha = c(0.9, 1))
# gas.wpcr2 <- wcr(gasoline$octane, xfuncs = gasoline$NIR[,1:256], min.scale = 0:3,
# nfeatures = c(16, 18, 20), ncomp = 10:15)
# gas.wpls2 <- wcr(gasoline$octane, xfuncs = gasoline$NIR[,1:256], min.scale = 0:3,
# nfeatures = c(16, 18, 20), ncomp = 10:15, method = "pls")
# plot(gas.wnet2)
# plot(gas.wpcr2)
# plot(gas.wpls2)
#
# ### 2D functional predictor example ###
#
# n = 200; d = 64
#
# # Create true coefficient function
# ftrue = matrix(0,d,d)
# ftrue[40:46,34:38] = 1
#
# # Generate random functional predictors, and scalar responses
# ii = array(rnorm(n*d^2), dim=c(n,d,d))
# iimat = ii; dim(iimat) = c(n,d^2)
# yy = iimat %*% as.vector(ftrue) + rnorm(n, sd=.3)
#
# mm.wnet <- wnet(yy, xfuncs = ii, min.scale = 4, alpha = 1)
#
# mm.wpls <- wcr(yy, xfuncs = ii, min.scale = 4, nfeatures = 20, ncomp = 6,
# method = "pls")
#
# plot(mm.wnet)
# plot(mm.wpls)
#
# ### 3D functional predictor example ###
#
# n = 200; d = 16
#
# # Create true coefficient function
# ftrue = array(0,dim = rep(d, 3))
# ftrue[10:16,12:15, 4:8] = 1
#
# # Generate random functional predictors, and scalar responses
# ii = array(rnorm(n*d^3), dim=c(n,rep(d,3)))
# iimat = ii; dim(iimat) = c(n,d^3)
# yy = iimat %*% as.vector(ftrue) + rnorm(n, sd=.3)
#
# mmm.wnet <- wnet(yy, xfuncs = ii, min.scale = 2, alpha = 1)
#
# mmm.wpls <- wcr(yy, xfuncs = ii, min.scale = 2, nfeatures = 20, ncomp = 6,
# method = "pls")
# plot(mmm.wnet)
# plot(mmm.wpls)
# ## End(Not run)
Run the code above in your browser using DataLab