Gapfill_ann: Gap-fill using ANN

Description Usage Arguments Value Examples

View source: R/Gapf_ANN.R

Description

This function automatically gap-fills the missing data points (marked as "NA") in the flux dataset using artificial neural networks (ANN) that take up to three variables as inputs. The ANN algorithms are based on the package 'neuralnet'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Gapfill_ann(
  data,
  Flux = "Flux",
  var1,
  var2 = NULL,
  var3 = NULL,
  win = 5,
  interval = 10,
  threshold = 1,
  hidden = 2,
  fail = "ave",
  ...
)

Arguments

data

a data frame that includes the flux (with NA indicating the missing data) and independent variables

Flux

a string indicates the column name for the flux variable to be gap-filled

var1

a string indicates the column name for the first variable

var2

a string indicates the column name for the second variable, default: NULL

var3

a string indicates the column name for the third variable, default: NULL

win

a number indicates the required sampling window length around each gap (total number in two sides), unit: days (default: 5)

interval

a number indicates the temporal resolution of the measurements in the dataset, unit: minutes (default: 10)

threshold

a number specifies the threshold for the partial derivatives of the error function as stopping criteria for the ANN model (default: 1)

hidden

a vector of integers specifies the number of hidden neurons (vertices) in each layer in the ANN model (default: c(2), i.e. one layer with 2 neurons)

fail

a string or a number indicates what to do when model fails to converge: 1. use the mean value in the sampling window to fill the gap ("ave", default), or 2. use any value assigned here to fill the gap (e.g., 9999, NA, etc.)

...

other arguments pass to 'neuralnet'

Value

A data frame that includes the original data, gap-filled data ("filled") and a "mark" column that indicates the value in each row of the "filled" is either: 1. original, 2. gap-filled, or 3. failed to converge

Examples

1
2
3
4
5
6
# read example data
df <- read.csv(file = system.file("extdata", "Soil_resp_example.csv", package = "FluxGapsR"),header = T)
df_filled <- Gapfill_ann(data = df,var1 = "Ts",var2 = "Ta",var3 = "Moist")
# visualize the gapfilled results
plot(df_filled$filled,col="red")
points(df_filled$Flux)

junbinzhao/FluxGapsR documentation built on March 29, 2020, 2:25 p.m.