predict.GIC.compCL: Make predictions based on a '"GIC.compCL"' object.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/tools.R

Description

This function makes prediction based on a "GIC.compCL" model, using the stored "compCL.fit" object and the optimal value of lambda.

Usage

1
2
## S3 method for class 'GIC.compCL'
predict(object, Znew, Zcnew = NULL, s = "lam.min", ...)

Arguments

object

fitted "GIC.compCL" model.

Znew

z matrix as in compCL with new compositional data or categorical data.

Zcnew

Zc matrix as in compCL with new data for other covariates. Default is NULL

s

specify the lam at which prediction(s) is requested.

  • s = "lam.min" (default), lam that obtains the minimun value of GIC values.

  • if s is numeric, it is taken as the value(s) of lam to be used.

  • if s = NULL, uses the whole sequence of lam stored in the "GIC.compCL" object.

...

not used.

Details

s is the vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the predict function uses linear interpolation.

Value

predicted values at the requested values of s.

Author(s)

Zhe Sun and Kun Chen

References

Lin, W., Shi, P., Peng, R. and Li, H. (2014) Variable selection in regression with compositional covariates, https://academic.oup.com/biomet/article/101/4/785/1775476. Biometrika 101 785-979.

See Also

GIC.compCL and compCL, and coef and plot methods for "GIC.compCL".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
p = 30
n = 50
beta = c(1, -0.8, 0.6, 0, 0, -1.5, -0.5, 1.2)
beta = c(beta, rep(0, times = p - length(beta)))
Comp_data = comp_Model(n = n, p = p, beta = beta, intercept = FALSE)
test_data = comp_Model(n = 100, p = p, beta = beta, intercept = FALSE)
GICm1 <- GIC.compCL(y = Comp_data$y, Z = Comp_data$X.comp,
                    Zc = Comp_data$Zc, intercept = Comp_data$intercept)
y_hat = predict(GICm1, Znew = test_data$X.comp, Zcnew = test_data$Zc)
predmat = predict(GICm1, Znew = test_data$X.comp, Zcnew = test_data$Zc, s = c(1, 0.5, 1))
plot(test_data$y, y_hat, xlab = "Observed value", ylab = "Predicted value")
abline(a = 0, b = 1, col = "red")

Compack documentation built on July 1, 2020, 10:26 p.m.