getTSF: getTSF

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/fct01_frameBuildingFuncs.R

Description

get the TSF ('time-stock-factor') or TSFR('time-stock-factor-rtn') object,by adding the factor score to a TS or TSR object.If necessary,cleaning and stardizing the factor score.

Usage

1
2
3
4
5
6
7
8
9
getTSF(TS, factorFun, factorPar = list(), factorDir = 1,
  factorRefine = refinePar_default("none"), FactorList, splitbin = 100000L)

getRawFactor(TS, factorFun, factorPar, FactorList)

getMultiFactor_lcfs(TS, FactorIDs, dir_adj = TRUE, factorRefine = NULL,
  wgts, fname_out = c("name", "ID"))

gf_lcfs(TS, factorID, dir_adj = FALSE, factorRefine = NULL)

Arguments

TS

a TS or TSR objectobject(See detail in getTS and getTSR)

factorFun

a character string naming the function to get the factor scores.

factorPar

either a list or a character string, containing the parameters of the factorFun. If a character string, parameters are seprated by commas and the character parameters must quoted by "\""s, see examples for details.

factorDir

a integer,should be 1 or -1 (1 for the positive factor,-1 for the negative one).

factorRefine

a list.

splitbin

a integer or a charactor string of 'year','month',...

Details

getRawFactor return a TSF object, with 'raw' factorscore, which has not been standardized and not been deal with missing values and outliers. Function getRawFactor is often called intermediately by function getTSF.

Value

given a TS object,return a TSF object,a dataframe containing cols:

given a TSR object,return a TSFR object,a dataframe containing cols:

getRawFactor return a TSF object, with 'raw' factorscore.

Author(s)

Ruifei.Yin

See Also

Other frame building functions: getRebDates, getTSR, getTS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -- get the TSF step by step --

# - get a TSF object
RebDates <- getRebDates(as.Date('2011-03-17'),as.Date('2012-04-17'),'month')
TS <- getTS(RebDates,'EI000300')
factorFun <- "gf_demo"
factorPar <- list(mean=0,sd=1)
TSF <- getTSF(TS,factorFun,factorPar)
# - get a TSFR object
TSR <- getTSR(TS)
TSFR <- getTSF(TSR)

# -- you can also get the TSF through the modelPar object directively --
modelPar <- modelPar.default()
modelPar <- modelPar.factor(modelPar,factorFun="gf_demo",factorPar=list(0,1))
TSF <- Model.TSF(modelPar)

# -- factorPar as character string
TSF2 <- getTSF(TS,"gf_demo","0,1")
TSF2 <- getTSF(TS,"gf_demo","mean=0,sd=1")
TSF2 <- getTSF(TS,"gf.foo","2,3")
TSF2 <- getTSF(TS,"gf.bar","20,\"IF00\"")
# -- get 'raw' factorscore
TSF_raw <- getRawFactor(TS,"gf.pct_chg_per","20")
# - 3. get multifactor through lcfs
factorIDs <- c("F000001","F000002","F000005")
# -- 3.1 getMultiFactor_lcfs
mTSF <- getMultiFactor_lcfs(TS,factorIDs,factorRefine = refinePar_default("reg"))
# -- 3.2 getRawMultiFactor_lcfs
mTSF <- getMultiFactor_lcfs(TS,factorIDs,dir_adj=FALSE,factorRefine = NULL)

raphael210/QDataGet documentation built on May 26, 2019, 11:02 p.m.