| remove_fixef | R Documentation |
As the Title says.
remove_fixef(formula, remove, nofixef = NULL, keep_intercept = TRUE, keep_offset = TRUE)
formula |
The model formula from which terms should be removed. |
remove |
The fixed-effect terms to be removed, specified either as a formula from which fixed-effect terms will be deduced (any random effet in such a formula will be ignored), or as a vector of character strings. The variable names should match those in the |
nofixef |
Optional |
keep_intercept |
Boolean: whether to keep an original intercept in the returned formula (does not add one if not originally present). |
keep_offset |
Boolean: whether to keep the offsets in the returned formula. |
The following toy example explains the results with a non-default nofixef:
form <- ~ offset() + a*b + (1|grp) remove_fixef(form, "a:b", nofixef=form)
which gives ~1 + a + b + offset(o) + a * b + (1 | grp).
First, fixed effect terms are extracted from the formula. Next, the terms implied by remove are removed, yielding an expression containing only other fixed-effect terms (here, 1 + a + b). Then, this expression is joined to the terms included in nofixef. The nofixef argument by default contains only the offset and random effect terms from the original formula (hence its name), but this example shows that anything in nofixef, including fixed effects, is included in the result.
A model formula. The response variable is retained in it if it was present in the input formula.
remove_fixef( y ~ a*b, ~ a*b) # y ~ 1, different from:
# remove_fixef(y ~ a*b, "a*b") # Warning and nothing removed
# (because a*b not in terms(formula), which instead contains a, b and a:b)
remove_fixef( y ~ a*b, ~ a*b) # => y ~ 1, same result as:
remove_fixef( y ~ a*b, ~ b*a)
remove_fixef( y ~ a*b, "a:b") # Same result as:
remove_fixef( y ~ a*b, "b:a") # a:b removed
# Remove all fixed effects term by setting 'remove' equal to 'formula':
form <- ~ offset() + a*b + (1|grp)
remove_fixef(form, form)
remove_fixef(form, form, keep_intercept = FALSE, keep_offset = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.