Learn R Programming

DAMisc (version 1.7.2)

crTest: Test of linearity for Component + Residual Plots

Description

This function estimates a linear model and a loess model on the component-plus-residual plot (i.e., a partial residual plot) for each quantitative variable in the model. The residual sums of squares for each are used to calculate an F-test for each quantitative variable.

Usage

crTest(
  model,
  adjust.method = "none",
  cat = 5,
  var = NULL,
  span.as = TRUE,
  span = 0.75,
  ...
)

Arguments

model

A model object of class lm

adjust.method

Adjustment method for multiple-testing procedure, using p.adjust from stats.

cat

Number of unique values below which numeric variables are considered categorical for the purposes of the smooth.

var

Character string indicating the term desired for testing. If left NULL, the default value, all numeric variables will be tested.

span.as

Logical indicating whether the span should be automatically selected through AICC or GCV

span

Span to be passed down to the loess function if span.as=FALSE.

...

Other arguments to be passed down to the call to loess.

Value

A matrix with the following columns for each variable:

RSSp

Residual sum-of-squares for the parametric (linear) model.

RSSnp

Residual sum-of-squares for the non-parametric (loess) model.

DFnum

Numerator degrees of freedom for the F-test: tr(S)-(k+1).

DFdenom

Denominator degrees of freedom for the F-test: n-tr(S)

F

F-statistic

p

p-value, potentially adjusted for multiple comparisons.

Examples

Run this code
# NOT RUN {
data(Prestige, package="carData")
mod <- lm(prestige ~ income + education + women, data=Prestige)
crTest(mod)

# }

Run the code above in your browser using DataLab