FLXMRmgcv.RdThis is a driver which allows fitting of mixtures of GAMs.
A formula which is interpreted relative to the formula
specified in the call to flexmix using
update.formula. Default is to use the original
flexmix model
formula.
A character string naming a glm
family function.
This can be used to specify an a priori known component to be included in the linear predictor during fitting.
A list of fit control parameters returned by
gam.control.
An array specifying the numerical optimization method
to use to optimize the smoothing parameter estimation criterion; for
more details see gam.
Optional list for initializing outer iteration; for more
details see gam.
Observations with an a-posteriori probability smaller or
equal to eps are omitted in the M-step.
Additional arguments to be pased to the GAM fitter.
Returns an object of class FLXMRmgcv inheriting from FLXMRglm.
set.seed(2012)
x <- seq(0, 1, length.out = 100)
z <- sample(0:1, length(x), replace = TRUE)
y <- rnorm(length(x), ifelse(z, 5 * sin(x * 2 * pi), 10 * x - 5))
fitted_model <- flexmix(y ~ s(x), model = FLXMRmgcv(),
cluster = z + 1,
control = list(tolerance = 10^-3))
#> Error in eval(inp, data, parent.frame()): object 'x' not found
plot(y ~ x, col = clusters(fitted_model))
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'clusters': object 'fitted_model' not found
matplot(x, fitted(fitted_model), type = "l", add = TRUE)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'fitted': object 'fitted_model' not found