has.intercept {pim} | R Documentation |
Check whether formula has an explicit intercept
Description
This function checks whether an intercept is present in a formula of
some form. It works for a formula
, a
terms.object
a pim.formula
object or
a character vector representing a formula.
Usage
has.intercept(x)
## S4 method for signature 'character'
has.intercept(x)
## S4 method for signature 'formula'
has.intercept(x)
## S4 method for signature 'terms'
has.intercept(x)
## S4 method for signature 'pim.formula'
has.intercept(x)
## S4 method for signature 'pim'
has.intercept(x)
Arguments
x |
either a |
Details
In case of a terms.object
, this function only checks whether the
intercept
attribute is larger than 0. In all other cases, the
function checks whether it can find a + 1
somewhere in the formula,
indicating that an intercept has to be fit in a pim
.
Value
a single logical value
WARNING
This function will return FALSE
for a standard formula
that is used in the context of a marginal model. Keep in mind that when
specifying model = 'marginal'
in a call to pim
, the model
will contain an intercept regardless of the outcome of has.intercept
Note
This function is meant to be used in the context of a pim
call. Although the function should work for standard formulas as well,
correct results are not guaranteed when used outside a pim context.
Examples
data("FEVData")
# Create the "model frame"
FEVenv <- new.pim.env(FEVData, compare="unique")
# create the formula and bind it to the pim.environment.
FEVform <- new.pim.formula(
Age ~ I(L(Height) - R(Height)) ,
FEVenv
)
has.intercept(FEVform)
FEVform2 <- new.pim.formula(Age ~ Height + 1, FEVData)
has.intercept(FEVform2)