ppmdat: Prepare data for model fitting

View source: R/ppmlasso_functions.R

ppmdatR Documentation

Prepare data for model fitting


This function prepares the data for model fitting. In particular, it determines observation weights and sets up the design matrix required for fitting a regularisation path.


ppmdat(sp.xy, sp.scale, back.xy, coord = c("X","Y"), sp.dat = getEnvVar(sp.xy = sp.xy, 
env.scale = sp.scale, env.grid = back.xy, coord = coord, writefile = writefile), 
sp.file = NA, quad.file = NA, datfilename = "PPMDat", writefile = TRUE)



A matrix of species locations containing at least one column representing longitude and one column representing latitude.


The spatial resolution at which to sample quadrature points.


The geo-referenced matrix of environmental grids.


A vector containing the names of the longitude and latitude coordinates, as in sampleQuad.


A matrix of species presence locations and the corresponding environmental data, as generated by getEnvVar.


The name of a saved file containing a matrix of species presence locations and the corresponding environmental data, as generated by getEnvVar.


The name of a fie containing the quadrature points created from the sampleQuad function.


An optional argument containing the name of the saved file. Setting datfilename = "PPMDat" will save a matrix dat.ppm containing the species presence locations and quadrature points, the environmental data, as well as an indicator for whether the locations correspond to presence locations or quadrature points and the corresponding quadrature weights to the file "PPMDat.RData".


A logical argument to determine whether the output should be written to a file or not. If TRUE (the default), the output will be saved with the file name as described in the datfilename argument.


This function will call the sampleQuad and getEnvVar functions to generate a quadrature scheme and interpolate environmental data to presence locations. Alternatively, the quadrature scheme may be directly supplied to the quad.file argument, and the matrix of presence locations and associated environmental data may be directly supplied to either the sp.dat argument (as an object in the workspace) or to the sp.file argument (as the name of a saved file containing this matrix).


A matrix dat.ppm with columns representing the latitude and longitude of presence locations and quadrature points along with the associated environmental data, as well as a column Pres indicating whether either point corresponds to a presence location or a quadrature point, and a column wt of observation weights.


Ian W. Renner

See Also

sampleQuad for generating a regular grid of quadrature points.

getEnvVar for interpolating environmental data to species presence locations.


## Do not run because of NOTE Examples with CPU time > 2.5 times elapsed time
#species.ppm = ppmdat(sp.xy = BlueMountains$eucalypt, back.xy = BlueMountains$env, 
#sp.scale = 1, datfilename = NA, writefile = FALSE)

ppmlasso documentation built on Dec. 1, 2022, 5:09 p.m.