anova_nlslist: Anova for nlsList

Description Usage Arguments Examples

View source: R/anova_nlslist.R

Description

Applies an F-test to a non-linear regression model that includes a grouping variable (fit with nlsList), comparing it to a model without a grouping variable. This is a convenient way to test whether there is an overall effect of the grouping variable on the non-linear relationship.

Usage

1
anova_nlslist(nlsfull, nlsreduc)

Arguments

nlsfull

The full model, an object returned by nlsList

nlsreduc

The reduced model, which is identical to the full model except the grouping variable has been removed, and it was fit with nls

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
chick <- as.data.frame(ChickWeight)

# Fit a simple model with nls
fit0 <- nls(weight ~ a*Time^b, data=chick, start=list(a=10, b=1.1))

# Fit an nlsList model, with a grouping variable (Diet)
fit1 <- nlsList(weight ~ a*Time^b | Diet, data=chick, start=list(a=10, b=1.1))

# Using an F-test, test whether the fit is significantly better when adding
# a grouping variable
anova_nlslist(fit1, fit0)

Example output

Loading required package: nlme
Loading required package: broom
Loading required package: dplyr

Attaching package: 'dplyr'

The following object is masked from 'package:nlme':

    collapse

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

    filter, lag

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

    intersect, setdiff, setequal, union

Loading required package: mgcv
This is mgcv 1.8-20. For overview type 'help("mgcv-package")'.
Loading required package: magicaxis
Loading required package: MASS

Attaching package: 'MASS'

The following object is masked from 'package:dplyr':

    select

Loading required package: plotrix
Loading required package: sm
Package 'sm', version 2.2-5.4: type help(sm) for summary information

Attaching package: 'sm'

The following object is masked from 'package:MASS':

    muscle

Loading required package: mapproj
Loading required package: maps
Loading required package: celestial
Loading required package: RANN
Loading required package: NISTunits
Loading required package: pracma

Attaching package: 'pracma'

The following object is masked from 'package:sm':

    nile

The following object is masked from 'package:mgcv':

    magic

Analysis of Variance Table

Model 1: weight ~ a * Time^b
Model 2: weight ~ a * Time^b | Diet
  Res.Df Res.Sum Sq Df Sum Sq F value    Pr(>F)    
1    576     962777                                
2    570     747641  6 215137  27.337 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

nlshelper documentation built on May 2, 2019, 10:22 a.m.