circAngles: Convert standard direction angles (in radians relative to the...

View source: R/circAngles.R

circAnglesR Documentation

Convert standard direction angles (in radians relative to the x-axis) to turning angle covariates suitable for circular-circular regression on the angle mean

Description

This function can be used to convert angular covariates (e.g., ocean currents, wind direction) measured in radians relative to the x-axis to turning angle covariates sutiable for circular-circular regression in fitHMM or MIfitHMM.

Usage

circAngles(refAngle, data, coordNames = c("x", "y"))

Arguments

refAngle

Numeric vector of standard direction angles (in radians) relative to the x-axis, where 0 = east, pi/2 = north, pi = west, -pi/2 = south

data

data frame containing fields for the x- and y-coordinates (identified by coordNames) and 'ID' (if more than one individual)

coordNames

Names of the columns of coordinates in data. Default: c("x","y").

Value

A vector of turning angles between the movement direction at time step t-1 and refAngle at time t

Examples

# extract data from momentuHMM example
data<-example$m$data

# generate fake angle covariates
u <- rnorm(nrow(data)) # horizontal component
v <- rnorm(nrow(data)) # vertical component
refAngle <- atan2(v,u)

# add turning angle covariate to data
data$cov3 <- circAngles(refAngle=refAngle,data=data)


bmcclintock/momentuHMM documentation built on Oct. 26, 2022, 1 a.m.