semireg_tmb | R Documentation |
Fit a semi parametric model based on glmmTMB.
semireg_tmb(formula, data, family = gaussian(), smoothZ = list(), ziformula = ~0,
dispformula = ~1, weights = NULL, offset = NULL, contrasts = NULL, na.action,
se = TRUE, verbose = FALSE, doFit = TRUE, control = glmmTMBControl(),
REML = TRUE, start = NULL, map = NULL, sparseX = NULL, prt=TRUE,
predict_info=TRUE)
formula |
A two-sided linear formula object describing both the fixed-effects and random-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. Random-effects terms are distinguished by vertical bars ("|") separating expressions for design matrices from grouping factors. |
data |
data frame (tibbles are OK) containing model variables. Not required, but strongly recommended; if |
family |
a family function, a character string naming a family function, or the result of a call to a family function (variance/link function) information. See |
smoothZ |
A list includes a set of smooth Z matrixs (called 'smooth term') used in the mixed effects model, the name of 'smooth term' should be different any variables in the model, each 'smooth term' is the result of function |
ziformula |
a one-sided (i.e., no response variable) formula for zero-inflation combining fixed and random effects: the default |
dispformula |
a one-sided formula for dispersion containing only fixed effects: the default |
weights |
weights, as in |
offset |
offset for conditional model (only). |
contrasts |
an optional list, e.g., |
na.action |
a function that specifies how to handle observations
containing |
se |
whether to return standard errors. |
verbose |
whether progress indication should be printed to the console. |
doFit |
whether to fit the full model, or (if FALSE) return the preprocessed data and parameter objects, without fitting the model. |
control |
control parameters, see |
REML |
whether to use REML estimation rather than maximum likelihood. |
start |
starting values, expressed as a list with possible components |
map |
a list specifying which parameter values should be fixed to a constant value rather than estimated. |
sparseX |
a named logical vector containing (possibly) elements named "cond", "zi", "disp" to indicate whether fixed-effect model matrices for particular model components should be generated as sparse matrices, e.g. |
prt |
Logical scalar - Should the info to be print on screen in the middle of the process or not? |
predict_info |
Logical scalar - Should provide the info for function semipred or not? In case of there is a correlation theta parameter appearing, you may set predict=FALSE. |
A semi parametric model can be parameterized as a linear (or generalized linear) mixed model in which its random effects are smooth functions of some covariates (named ‘smooth term’). semireg_tmb
follows the approach suggested by Wand and Ormerod (2008) and represents the 'smooth term' using O'Sullivan-type of Z.
semer |
A glmmTMB model used in the fitting. |
data |
A data.frame with generated variables in the fitting. |
fomul_vars |
Name of variables in the formula of semireg_tmb model. |
sm_vars |
Name of variables in the smoothZ list. |
smoothZ_call |
A call used to produce smooth terms in the fitting. |
knots_lst |
Knots used in each smooth term in the fitting. |
range_lst |
Range of covariate used in each smooth term in the fitting. |
cov_lst |
Covariance matrix list for each smooth term. |
u_lst |
Random effects list for each smooth term. |
type_lst |
Smooth type list of smooth terms. |
CovMat |
Covariance matrix for all smooth terms. |
Cov_ind |
Covariance matrix index for each smooth term. |
Cov_indN |
Covariance matrix index for each smooth term when |
df |
Degree of freedom of all random terms. |
tmbf |
The glmmTMB model result using doFit=FALSE. |
Dongwen Luo, Siva Ganesh and John Koolaard
Wand, M.P. and Ormerod, J.T. (2008). On semiparametric regression with O'Sullivan penalized splines. Australian and New Zealand Journal of Statistics. 50, 179-198.
## Not run
# library(predictmeans)
# library(HRW)
# data(WarsawApts)
# help(WarsawApts)
# str(WarsawApts)
# fit1 <- semireg_tmb(areaPerMzloty ~ construction.date,
# smoothZ=list(
# grp=smZ(construction.date, k=25)
# ),
# data = WarsawApts)
# sp_out1 <- semipred(fit1, "construction.date", "construction.date")
#
# WarsawApts$district <- factor(WarsawApts$district)
# fit2 <- semireg_tmb(areaPerMzloty ~ construction.date*district, resp_scale = TRUE,
# smoothZ=list(group=smZ(construction.date, k=15,
# by = district, group=TRUE)),
# data=WarsawApts)
# sp_out2_1 <- semipred(fit2, "district", "construction.date")
# sp_out2_2 <- semipred(fit2, "district", "construction.date", contr=c(2,1))
#
# data(indonRespir)
# help(indonRespir)
# str(indonRespir)
# fit3 <- semireg_tmb(respirInfec ~ age+vitAdefic + female + height
# + stunted + visit2 + visit3 + visit4 + visit5 + visit6+(1|idnum),
# smoothZ=list(
# grp=smZ(age)
# ),
# family = binomial,
# data = indonRespir)
# sp_out3 <- semipred(fit3, "age", "age")
# library(ggplot2)
# sp_out3$plt+
# geom_rug(data = subset(indonRespir, respirInfec==0), sides = "b", col="deeppink") +
# geom_rug(data = subset(indonRespir, respirInfec==1), sides = "t", col="deeppink")+
# ylim(0, 0.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.