GeNetIt (version 0.1-4)

gravity: Gravity model

Description

Implements Murphy et al., (2010) gravity model

Usage

gravity(y, x, d, group, data, ln = TRUE, constrained = TRUE, ...)

Value

formula Model formula

gravity Gravity model

AIC AIC value for selected model

log.likelihood Restricted log-likelihood at convergence

x data.frame of independent variables

y Vector of dependent variable

groups Ordered factor vector of grouping variable

fit Model Fitted Values

Arguments

y

Name of dependent variable

x

Character vector of independent variables

d

Name of column containing distance

group

Name of grouping column (from or to)

data

data.frame object containing model data

ln

Natural log transform data (TRUE/FALSE)

constrained

Specify constrained model, if FALSE a linear model (lm) is run (TRUE/FALSE)

...

Additional argument passed to nlme or lm

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie Murphy <melanie.murphy@uwyo.edu>

Details

The "group" factor defines the singly constrained direction (from or to) and the grouping structure for the origins. To specify a null (distance only or IBD) model just omit the x argument.

By default constrained models are fit by maximizing the restricted log-likelihood (REML), for maximum likelihood use the type="ML" argument which is passed to the lme function. If ln=TRUE the input data will be log transformed

References

Murphy, M. A. & J.S. Evans. (in prep). GenNetIt: graph theoretical gravity modeling for landscape genetics

Murphy M.A., R. Dezzani, D.S. Pilliod & A.S. Storfer (2010) Landscape genetics of high mountain frog metapopulations. Molecular Ecology 19(17):3634-3649

See Also

groupedData for how grouping works in constrained model

lme for constrained model ... options

lm for linear model ... options

Examples

Run this code
library(nlme)
data(ralu.model)
str(ralu.model)

# Gravity model	
x = c("DEPTH_F", "HLI_F", "CTI_F", "cti", "ffp")
( gm <- gravity(y = "DPS", x = x, d = "DISTANCE", group = "FROM_SITE", 
                data = ralu.model, ln = FALSE) )

# Plot gravity results
 par(mfrow=c(2,3))
   for (i in 1:6) { plot(gm, type=i) } 

# log likelihood of competing models 
 x = c("DEPTH_F", "HLI_F", "CTI_F", "cti", "ffp")
 for(i in x[-1]) {
   x1 = c(x[1], x[-which(x %in% i)])  
   ll <- gravity(y = "DPS", x = x1, d = "DISTANCE", group = "FROM_SITE", 
                data = ralu.model, ln = FALSE)$log.likelihood
  cat("log likelihood for parameter set:", "(",x1,")", "=", ll, "\n")				 
 }

# Distance only (IBD) model
gravity(y = "DPS", d = "DISTANCE", group = "FROM_SITE", 
        data = ralu.model, ln = FALSE)

Run the code above in your browser using DataCamp Workspace