winopt: Find the optimal half-window width combination

View source: R/winopt.R

winoptR Documentation

Find the optimal half-window width combination

Description

Find the optimal half-window width combination to use for weighted regression.

Usage

winopt(
  dat_in,
  tz,
  lat,
  long,
  wins,
  vls = c("meanPg", "sdPg", "anomPg", "meanRt", "sdRt", "anomRt"),
  parallel = F,
  progress = T,
  control = list(factr = 1e+07, parscale = c(50, 100, 50)),
  lower = c(0.1, 0.1, 0.1),
  upper = c(12, 12, 1)
)

Arguments

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)

wins

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

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,

control

A list of control parameters passed to optim (see details in optim help file). The value passed to factr controls the convergence behavior of the "L-BFGS-B" method. Values larger than the default will generally speed up the optimization with a potential loss of precision. parscale describes the scaling values of the parameters.

lower

vector of minimum half-window widths to evaluate

upper

vector of maximum half-window widths to evaluate

Details

This is a super sketchy function based on many assumptions, see details in objfun

Value

Printed text to the console showing progress. Output from optim will also be returned if convergence is achieved.

See Also

objfun, wtobjfun

Examples

## Not run: 

library(foreach)
library(doParallel)

data(SAPDC)

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

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

winopt(SAPDC, tz = tz, lat = lat, long = long, 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.