Learn R Programming

wrMisc (version 1.2.3)

searchLinesAtGivenSlope: Search points forming lines at given slope

Description

searchLinesAtGivenSlope searchs among set of points (2-dim) those forming line(s) with user-defined slope ('coeff'), ie search optimal (slope-) offset parameter(s) for (regression) line(s) with given slope ('coef'). Note: larger data-sets : segment residuals to 'coeff' & select most homogenous

Usage

searchLinesAtGivenSlope(
  dat,
  coeff = 1.5,
  filtExtr = c(0, 1),
  minMaxDistThr = NULL,
  lmCompare = TRUE,
  indexPoints = TRUE,
  displHist = FALSE,
  displScat = FALSE,
  bestCluByDistRat = TRUE,
  neighbDiLim = NULL,
  silent = FALSE,
  debugM = FALSE,
  callFrom = NULL
)

Arguments

dat

matrix or data.frame

coeff

(numeric) slope to consider

filtExtr

(integer) lower & upper quantile values, remove points with extreme deviation to offset=0, (if single value: everything up to or after will be used)

minMaxDistThr

(logical) optional minumum and maximum distance threshold

lmCompare

(logical) add'l fitting of linear regression to best results, return offset AND slope based on lm fit

indexPoints

(logical) return results as list with element 'index' specifying retained points

displHist

(logical) display histogram of residues

displScat

(logical) display (simple) scatter plot

bestCluByDistRat

(logical) initial selection of decent clusters based on ratio overallDist/averNeighbDist (or by CV & cor)

neighbDiLim

(numeric) additional threshold for (trimmed mean) neighbour-distance

silent

(logical) suppress messages

debugM

(logical) for bug-tracking: more/enhanced messages

callFrom

(character) allow easier tracking of message(s) produced

Value

matrix of line-characteristics (or if indexPoints is TRUE then list (line-characteristics & index & lm-results)

Examples

Run this code
# NOT RUN {
set.seed(2016); ra1 <- runif(300)
 dat1 <- cbind(x=round(c(1:100+ra1[1:100]/5,4*ra1[1:50]),1),
  y=round(c(1:100+ra1[101:200]/5,4*ra1[101:150]),1))
(li1 <- searchLinesAtGivenSlope(dat1,coeff=1))
# }

Run the code above in your browser using DataLab