fillNASVDSer: SVD to Interpolate the Missing Values in the Time Series Data

Description Usage Arguments Details Value Examples

View source: R/fillNASVDSer.R

Description

Function to Use SVD to Interpolate the Missing Values in the Time Series Data

Usage

1
fillNASVDSer(dset, idF, dateF, valF, k)

Arguments

dset

The data frame for time series. Data format: siteid, date, obs dataframe.

idF

The unique location id like siteid.

dateF

The time column name.

valF

The target variable column name.

k

the priciple component, default 1

Details

This function can be used to fill the missing values in time series for many locations.

Value

The data frame similar to the input dset's structure but with filled values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#Using the 2014 PM2.5 time series as an example
data("shdSeries2014")
n=nrow(shdSeries2014)
p=0.1 # Set the proportion of missing values
np=as.integer(n*p)
index=sample(n,np)
shdSeries2014missed=shdSeries2014
shdSeries2014missed[index,"obs"]=NA
shdSeries2014filled=fillNASVDSer(shdSeries2014missed,"siteid","date","obs",k=1)

#Exmine the accuracy:
cor(shdSeries2014filled[index,"obs"],shdSeries2014[index,"obs"])
rmse(shdSeries2014filled[index,"obs"],shdSeries2014[index,"obs"])

lspatial/sptemUS documentation built on May 29, 2019, 3:42 a.m.