anova.SSN2 {SSN2} | R Documentation |
Compute analysis of variance and likelihood ratio tests of fitted model objects
Description
Compute analysis of variance tables for a fitted model object or a likelihood ratio test for two fitted model objects.
Usage
## S3 method for class 'ssn_lm'
anova(object, ..., test = TRUE, Terms, L)
## S3 method for class 'ssn_glm'
anova(object, ..., test = TRUE, Terms, L)
## S3 method for class 'anova.ssn_lm'
tidy(x, ...)
## S3 method for class 'anova.ssn_glm'
tidy(x, ...)
Arguments
object |
|
... |
An additional fitted model object from |
test |
A logical value indicating whether p-values from asymptotic Chi-squared
hypothesis tests should be returned. Defaults to |
Terms |
An optional character or integer vector that specifies terms in the model
used to jointly compute test statistics and p-values (if |
L |
An optional numeric matrix or list specifying linear combinations
of the coefficients in the model used to compute test statistics
and p-values (if |
x |
An object from |
Details
When one fitted model object is present, anova()
performs a general linear hypothesis test corresponding to some hypothesis
specified by a matrix of constraints. If Terms
and L
are not specified,
each model term is tested against zero (which correspond to type III or marginal
hypothesis tests from classical ANOVA). If Terms
is specified and L
is not specified, all terms are tested jointly against zero. When L
is
specified, the linear combinations of terms specified by L
are jointly
tested against zero.
When two fitted model objects are present, one must be a "reduced"
model nested in a "full" model. Then anova()
performs a likelihood ratio test.
Value
When one fitted model object is present, anova()
returns a data frame with degrees of
freedom (Df
), test statistics (Chi2
), and p-values
(Pr(>Chi2)
if test = TRUE
) corresponding
to asymptotic Chi-squared hypothesis tests for each model term.
When two fitted model objects are present, anova()
returns a data frame
with the difference in degrees of freedom between the full and reduced model (Df
), a test
statistic (Chi2
), and a p-value corresponding to the likelihood ratio test
(Pr(>Chi2)
if test = TRUE
).
Whether one or two fitted model objects are provided,
tidy()
can be used
to obtain tidy tibbles of the anova(object)
output.
Examples
# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, overwrite = TRUE)
ssn_mod <- ssn_lm(
formula = Summer_mn ~ ELEV_DEM,
ssn.object = mf04p,
tailup_type = "exponential",
additive = "afvArea"
)
anova(ssn_mod)
tidy(anova(ssn_mod))