NKnots: AIC and BIC selection of number of spline knots

Description Usage Arguments Value Author(s) Examples

View source: R/DAMisc_functions.R

Description

Calculates AIC and BIC for the selection of knots in a spline over values (potentially including polynomials) up to a user-defined maximum.

Usage

1
2
3
    NKnots(form, var, data, degree=3, min.knots=1, 
       max.knots=10, includePoly = FALSE, plot=FALSE, 
       criterion=c("AIC", "BIC", "CV"), cvk=10)

Arguments

form

A formula detailing the model for which smoothing is to be evaluated.

var

A character string identifying the variable for which smoothing is to be evaluated.

data

Data frame providing values of all variables in form.

degree

Degree of polynomial in B-spline basis functions.

min.knots

Minimum number of internal B-spline knots to be evaluated.

max.knots

Maximum number of internal B-spline knots to be evaluated.

includePoly

Include linear and polynomial models up to, and including degree-th order polynomials.

plot

Logical indicating whether a plot should be returned.

criterion

Statistical criterion to minimize in order to find the best number of knots - AIC, BIC or Cross-validation.

cvk

Number of groups for cross-validation

Value

A plot, if plot=TRUE, otherwise a data frame with the degrees of freedom and corresponding fit measure.

Author(s)

Dave Armstrong (UW-Milwaukee, Department of Political Science)

Examples

1
2
library(car)
NKnots(prestige ~ education + type, var="income", data=na.omit(Prestige), plot=FALSE)

Example output

Loading required package: car
Loading required package: effects
Loading required package: carData

Attaching package: 'carData'

The following objects are masked from 'package:car':

    Guyer, UN, Vocab

lattice theme set by effectsTheme()
See ?effectsTheme for details.
Warning message:
system call failed: Cannot allocate memory 

DAMisc documentation built on May 30, 2017, 8:12 a.m.