response_function_flexgam: Predicts values for the object of class flexgam In FlexGAM: Generalized Additive Models with Flexible Response Functions

Description

Predicts values for the given object, if a new predictor is given.

Usage

 ```1 2 3``` ```## S3 method for class 'flexgam' response(object, linear.predictor = NULL, ...) response(object, ...) ```

Arguments

 `object` Object of class flexgam. `linear.predictor` New predictor, which has to be centered and scaled properly. `...` Currently not used

Details

Calculates predicted values for the given model. Used to get the estimated response function separately from the covariate effects. For the same predictor `predict.flexgam(...,type="response")` and `response(...)` are equal.

Value

Numeric vector of fitted values.

Elmar Spiegel

References

Spiegel, Elmar, Thomas Kneib and Fabian Otto-Sobotka. Generalized additive models with flexible response functions. Statistics and Computing (2017). https://doi.org/10.1007/s11222-017-9799-6

`flexgam`, `deviance.flexgam`, `predict.flexgam`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```set.seed(1) n <- 1000 x1 <- runif(n) x2 <- runif(n) x3 <- runif(n) eta_orig <- -1 + 2*sin(6*x1) + exp(x2) + x3 pi_orig <- pgamma(eta_orig, shape=2, rate=sqrt(2)) y <- rbinom(n,size=1,prob=pi_orig) Data <- data.frame(y,x1,x2,x3) formula <- y ~ s(x1,k=20,bs="ps") + s(x2,k=20,bs="ps") + x3 # Fix smoothing parameters to save computational time. control2 <- list("fix_smooth" = TRUE, "quietly" = TRUE, "sm_par_vec" = c("lambda" = 100, "s(x1)" = 2000, "s(x2)" = 9000)) set.seed(2) model_2 <- flexgam(formula=formula, data=Data, type="FlexGAM2", family=binomial(link=logit), control = control2) set.seed(2) n <- 1000 x1 <- runif(n) x2 <- runif(n) x3 <- runif(n) eta_orig <- -1 + 2*sin(6*x1) + exp(x2) + x3 pi_orig <- pgamma(eta_orig, shape=2, rate=sqrt(2)) y <- rbinom(n,size=1,prob=pi_orig) newData <- data.frame(y,x1,x2,x3) fitted_1 <- predict(model_2, newdata=newData, type="response") predictor1 <- predict(model_2, newdata=newData, type="linear.predictor") fitted_2 <- response(model_2, linear.predictor=predictor1) all.equal(fitted_1,fitted_2) ```