wtobjfun: An objective function to minimize plus weighted regression...

View source: R/wtobjfun.R

wtobjfunR Documentation

An objective function to minimize plus weighted regression for finding optimal window widths

Description

An objective function to minimize plus weighted regression for finding optimal window widths

Usage

wtobjfun(
  wins,
  dat_in,
  tz,
  lat,
  long,
  metab_obs,
  strt = NULL,
  vls = c("meanPg", "sdPg", "anomPg", "meanRt", "sdRt", "anomRt"),
  parallel = F,
  progress = T
)

Arguments

wins

list of half-window widths to use in the order specified by wtfun (i.e., days, hours, tide height).

dat_in

input data frame

tz

chr string specifying timezone of location, e.g., 'America/Jamaica' for EST, no daylight savings, must match the time zone in dat_in$DateTimeStamp

lat

numeric for latitude of location

long

numeric for longitude of location (negative west of prime meridian)

metab_obs

A metab object returned by ecometab based on the observed DO time series in dat_in, used as comparison for the objective function

strt

a POSIXct object returned by Sys.time

vls

chr vector of summary evaluation object to optimize, see details for objfun

parallel

logical if regression is run in parallel to reduce processing time, requires a parallel backend outside of the function

progress

logical if progress saved to a txt file names 'log.txt' in the working directory

Value

A single numeric value to minimize, as output from objfun

See Also

objfun, winopt

Examples

## Not run: 

library(foreach)
library(doParallel)

data(SAPDC)

tz <- 'America/Jamaica'
lat <- 31.39
long <- -81.28

metobs <- ecometab(SAPDC, DO_var = 'DO_obs', tz = tz, lat = lat, long = long)

ncores <- detectCores()
cl <- makeCluster(ncores)
registerDoParallel(cl)

wtobjfun(SAPDC, tz = tz, lat = lat, long = long, metab_obs = metobs, strt = Sys.time(),
   wins = list(6, 6, 0.5), parallel = T)

stopCluster(cl)

## End(Not run)

fawda123/WtRegDO documentation built on March 18, 2024, 9:04 p.m.