wgdev | R Documentation |
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.
wgdev(covar, groupvar)
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). |
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.
Martijn van de Pol and Jonathan Wright
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.