wgdev {climwin}R Documentation

Calculate within group deviance.

Description

Calculate within group deviance of a variable. Used to test for 'within individual effects'. See methods outlined in van de Pol and Wright 2009 for more detail.

Usage

wgdev(covar, groupvar)

Arguments

covar

Continuous variable for which within group deviance will be calculated. Please specify the dataset in which the variable is found (i.e. data$var).

groupvar

Grouping variable within which deviance will be calculated. For example, individual ID or site/plot ID. Please specify the dataset in which the variable is found (i.e. data$var).

Value

Returns a vector containing numeric values. This can be used to differentiate within and between group effects in a model. See function wgmean to calculate within group means. See van de Pol and Wright 2009 for more detail.

Author(s)

Martijn van de Pol and Jonathan Wright

Examples

# Calculate within year deviance in temperature from the MassClimate dataset.  

data(MassClimate)

#Calculate year column
library(lubridate)
MassClimate$Year <- year(as.Date(MassClimate$Date, format = "%d/%m/%Y"))

#Calculate within year deviance of temperature
within_yr_dev <- wgdev(MassClimate$Temp, MassClimate$Year)

#Add this variable to the original dataset
MassClimate$Within_yr_dev <- within_yr_dev
             

[Package climwin version 1.2.3 Index]