selectCRSPandSPGMI: Select CRSP Stocks and SPGMI Factors

View source: R/selectCRSPandSPGMI.R

selectCRSPandSPGMIR Documentation

Select CRSP Stocks and SPGMI Factors

Description

Select and merge a set of CRSP stocks and SPGMI factors and SPGMI factors over a range of dates between January 1993 and December 2015

Usage

selectCRSPandSPGMI(
  stocks = stocksCRSP,
  factors = factorsSPGMI,
  dateSet = c("2006-01-31", "2010-12-31"),
  stockItems = c("Date", "TickerLast", "CapGroup", "Sector", "Return", "Ret13WkBill",
    "mktIndexCRSP"),
  factorItems = c("BP", "LogMktCap", "SEV"),
  capChoice = "SmallCap",
  Nstocks = 20
)

Arguments

stocks

A data.table of stock returns and related data

factors

A data.table of factors and related data

dateSet

A character vector providing a start data and an end date, having the same form as c("2006-01-31", "2010-12-31")

stockItems

A character vector that is a subset of the names of stocks data.table

factorItems

A character vector that is a subset of the names of factors data.table

capChoice

One of the market capitalization group names "Smallcap", "Smallcap", "MidCap", "LargeCap".

Nstocks

Number of stocks in one of the marketcap groups, not to exceed the number of stocks in the chosen group.

Details

The date range is specified by a beginning Date object and an ending Date object. Default values for the stocks and factors component names, marketcap group, and number of stocks in the marketcap group can be changed by the user

Value

A merged data.table consisting of selected stocks and factors

Examples


## Not run: 
data(stocksCRSP)
data(factorsSPGMI)

stocks_factors <- selectCRSPandSPGMI(stocks = stocksCRSP, factors = factorsSPGMI,
                                    dateSet = c("2006-01-31", "2010-12-31"),
                                    stockItems = c("Date", "TickerLast",
                                                   "CapGroup", "Sector",
                                                   "Return", "Ret13WkBill",
                                                   "mktIndexCRSP"),
                                    factorItems = c("BP", "LogMktCap", "SEV"),
                                    capChoice = "SmallCap",
                                    Nstocks = 20)

str(stocks_factors)

## End(Not run)

braverock/factorAnalytics documentation built on Dec. 16, 2024, 1:05 p.m.