lrtest_removeTerm: Likelihood ratio p-values for full model vs model with one...

Description Usage Arguments Value Methods (by class) See Also Examples

View source: R/lrtest_removeTerm.R

Description

Runs model without 'removeTerm' and performs likelihood ratio test for full model vs nested model. 'function(variable)' - eg, 'rcs(age, 3)' - is considered one term, as are all levels of a categorical variable.

Usage

1
2
3
4
5
6
7
lrtest_removeTerm(orgModel, removeTerm, ...)

## Default S3 method:
lrtest_removeTerm(orgModel, removeTerm)

## S3 method for class 'mira'
lrtest_removeTerm(orgModel, removeTerm, miceObjName)

Arguments

orgModel

Model object containing full model.

removeTerm

Character string of term(s) to be removed.

...

Additional arguments specific to method.

miceObjName

Character string; name of 'mice' object.

orgModel

Model object containing full model.

removeTerm

Character string of term(s) to be removed.

orgModel

Model object containing full model.

removeTerm

Character string of term(s) to be removed.

Value

List with following values from lrtest() or pool.compare(): test degrees of freedom, X^2^ value, and p-value.

Methods (by class)

See Also

lrtest_removeTerm.default, lrtest_removeTerm.mira.

lrtest.

pool.compare.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Fit full model using iris data
fullModel <- lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width, data = iris)

## What about just the effect of Petal.Length?
lrtest_removeTerm(fullModel, 'Petal.Length')

## What about the effect of both Petal variables?
lrtest_removeTerm(fullModel, 'Petal.Length + Petal.Width')


## Add missingness to iris data
iris_missing <- iris
iris_missing[sample(1:nrow(iris), size = round(nrow(iris_missing) / 10)), 'Sepal.Width'] <- NA

## Create mice object
iris_mice <- mice(iris_missing)

#' ## Fit full model using iris data
fullModel <- with(iris_mice, lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width))

## What about just the effect of Petal.Length?
lrtest_removeTerm(fullModel, 'Petal.Length', 'iris_mice')

## What about the effect of both Petal variables?
lrtest_removeTerm(fullModel, 'Petal.Length + Petal.Width', 'iris_mice')

jenniferthompson/JTHelpers documentation built on May 19, 2019, 4:04 a.m.