Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/flexgam_start.R
Main function to estimate generalized additive models with flexible response function. Currently the response must be binomial, Poisson, Gaussian or Gamma distributed.
1 2 
formula 
Formula of the covariate effects. The formula must be in the design of the 
data 
Data to fit the model. 
type 
Should the response function be estimated completely flexible ( 
family 
Family of the data. Currently only 
control 
Control parameters to fit the model. The default values are described in 
To reduce the bias of missspecified response functions the function estimates the response function jointly with the covariate effects. The covariate effects are build similar to the standard mgcv::gam, while the response function is either estimated as a strictly monotone Pspline or a combination of the canonical link and a transformation of the "linear"predictor. In the outer loop the response function is estimated, while in the inner loop a modified version of the FisherScoring algorithm is applied to get the covariate effects. In the algorithm stephalving is applied. Identifiability is achieved due to at least two smooth effects and scaling of the predictors.
Object of class flexgam
. The list includes the
f_k
: The estimated response function.
gam_temp
: The final step of the FisherScoring algorithm, so the weighted linear model based on the mgcvpackage.
sm_par_vec
: The estimated smoothing parameters.
coefficients
: The coefficients of the predictor as well as of the response function.
se
: The standard deviation of the coefficients.
mean_eta_k
, sd_eta_k
: Some information about the scaling of the predictor.
control
: The applied control parameters.
control_input
: The control parameters in the input
details
: Information about the occurrence of modifications due to extreme values and the convergence. As well as information of the steps done in the algorithm (if saved).
As well as other stuff for internal usage
Elmar Spiegel
Spiegel, Elmar, Thomas Kneib and Fabian OttoSobotka. Generalized additive models with flexible response functions. Statistics and Computing (2017). https://doi.org/10.1007/s1122201797996
predict.flexgam
, plot.flexgam
, deviance.flexgam
, match_flexgam_control
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  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)
print(model_2)
summary(model_2)
plot(model_2, type = "response")
plot(model_2, type = "covariate")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.