tot.rss: Total Residual Sum of Squares for Broken Stick Model

Description Usage Arguments Value Author(s) See Also Examples

View source: R/rMR.R

Description

Calculates the total residual sum of squares for broken stick model (2 part)

Usage

1
tot.rss(data, break.pt, xvar, yvar)

Arguments

data

data frame for calculating total residual sum of squares.

break.pt

This is the data point at which the data are split for a broken stick model.

xvar

The x-variable in the data frame for broken stick model.

yvar

The y-variable in the data frame for broken stick model.

Value

The residual sum of squares of a broken stick model with a specified break point.

Author(s)

Tyler L. Moulton

See Also

codesumsq codeget.pcrit

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
26
27
## load data ##
data(fishMR)

## subset data to appropriate region ##

data<-fishMR[fishMR$DO.mgL < 4,] 
data$times <- data$times-min(data$times)
data<-data[data$times< 6800,]

## calculate total RSS for different breakpoints ##

a1 <- tot.rss(data, break.pt = 4000,
xvar = "times", yvar = "DO.mgL") 
a2 <- tot.rss(data, break.pt = 4250,
xvar = "times", yvar = "DO.mgL")
a3 <- tot.rss(data, break.pt = 4500,
xvar = "times", yvar = "DO.mgL")
a4 <- tot.rss(data, break.pt = 4750,
xvar = "times", yvar = "DO.mgL") 
a5 <- tot.rss(data, break.pt = 5000,
xvar = "times", yvar = "DO.mgL")
a6 <- tot.rss(data, break.pt = 5250,
xvar = "times", yvar = "DO.mgL")

# a5 represents the break point for the 
# best broken stick linear model of the
# above 6 options.

rMR documentation built on May 2, 2019, 6:51 a.m.