Skip to contents

Function to impose an change impact effect

Usage

genChangeData(
  pct.change,
  model,
  data,
  panels = NULL,
  eventsite.bnd = NULL,
  noneventcells = NULL,
  modelfits = NULL
)

Arguments

pct.change

percentage change to occur. e.g. 50% gives 50% site wide decline. If a redistribution effect (one of eventsite.bnd or noneventcells must be specified) then the change refers only to the event site cells. For an additional site-wide change when using a re-distribution, pct.change is a vector with the first number the event site re-distribution and the second, the site wide change.

model

A glm or gamMRSea model object. If specified, the fitted values from the model will be used to impose the change. Leave out if parameter modelfits is specified instead

data

Data frame used to fit model

panels

Character vector denoting the column of data containing the panel structure.

eventsite.bnd

A data frame containing the coordinates of a polygon defining the region of the defined event The variable names must match the coordinate system in the data.

noneventcells

logical (0/1) vector of length the same as the data indicating which cells the event did not occur (1).

modelfits

Character vector denoting the name of column in data containing the model fits.

Value

Returns a data frame twice the size of the original input with additional columns for panel id, eventphase and truth. The truth column represents the input data for the first half (pre-event; eventphase==0) and the second half has the change imposed (post-event; eventphase==1).

Author

Lindesay Scott-Hayward, University of St Andrews

Examples

data(nystedA_slim)
nysted$panelid <- paste0(nysted$yearmonth, ".t", nysted$TNO_ID)

initialModel<-MRSea::gamMRSea(response ~ 1 + as.factor(yearmonth)+depth +
                     x.pos + y.pos + offset(log(area)),  data=nysted,
                     family=quasipoisson)

# generate a 20% site-wide change:
changedata1<-genChangeData(pct.change=80, model=initialModel, data=nysted, panels="panelid")

# generate a 50% decline in the windfarm footprint:
data("nysted.bndwf")
changedata2<-genChangeData(pct.change=50, model=initialModel, data=nysted, panels="panelid",
                            eventsite.bnd=nysted.bndwf)
#> Loading required package: splancs
#> Loading required package: sp
#> 
#> Spatial Point Pattern Analysis Code in S-Plus
#>  
#>  Version 2 - Spatial and Space-Time analysis
#> Warning: List/data.frame components should be named x and y
#> Warning: List/data.frame components should be named x and y