YRmisc0.1.6 package

Y&R Miscellaneous R Functions

cor.lag

Lag/Lead Correlation

cor.spearman

Spearman rank correlation

cv.annu.fv

Calculate future value of annuity

cv.annu.pv

Calculate present value of annuity

cv.axp

Create logarithm with a random base

cv.bondprice

Calculate the plain vanilla bond price

cv.diff

Calculating the difference of a time series

cv.drawdown

Largest draw down of returns

cv.lag

Create a lag variable

cv.lead

Create a lead variable

cv.logs

Create logarithm with a random base

cv.pctcng

Calculating rate of return of a vector

cv.powers

Create nth power variable

df.sortcol

Sort a data frame by a column

df.stack

Stack data frame by one classifier

ds.corm

Correlation matrix

ds.kurt

Calculating kurtosis for numeric data.

ds.mode

Calculating mode for numeric data

ds.skew

Calculating skewness for numeric data

ds.summ

Descriptive statistics of a data frame

pl.2ts

Time series plot for two variables

pl.2tsgg

Time series plot for two variables with ggplot2

pl.3smoothtxt

Scatter smooth plot with text overlay

pl.3smoothtxtgg

Scatter smooth plot with text overlay using ggplot2

pl.3txt

Scatter plot with text overlay

pl.3txtgg

Scatter plot with text overlay with ggplot2

pl.coplot

Scatter plot of x and y divided by z

pl.hist

Plot histograms for a data frame

pl.histgg

Plot histograms for a data frame with ggplot2

pl.hs

Plot histograms and scatter plots for a data frame

pl.hsd

Plot histogram with density line for a data frame

pl.hsdgg

Plot histograms for a data frame with ggplot2

pl.mv

Plot mean-variance simulation result

pl.s

Plot scatter plots for a data frame

pl.sgg

Plot scatter plots for a data frame using ggplot2

pl.sm

Plot scatter smooth plots for a data frame

pl.smgg

Plot scatter plots with smooth line for a data frame using ggplot2

pl.ts

Plot time series plots for a data frame

pl.tsgg

Plot times series plot for a data frame with ggplot2

pl.tss

Time series plot with multiple variables

pt.alpha

Stock return alpha

pt.annexrtn

Annualized excess return

pt.annrtn

Annualized return

pt.annsd

Annualized standard deviation

pt.beta

Stock return beta

pt.bias

Bias ratio

pt.btavg

Batting average

pt.cmexrtn

Cumulative excess return

pt.cmrtn

Cumulative return

pt.dalpha

Dual-alpha

pt.dbeta

Dual-beta

pt.exploss

Expected loss

pt.hismv

Mean-variance model with historical average returns and standard devia...

pt.info

Information ratio

pt.jalpha

Jensen's alpha

pt.m2

Modigliani risk-adjusted performance

pt.probloss

Probability of loss

pt.roy

Roy's safety-first criterion

pt.sdexrtn

Standard deviation of excess return

pt.semivar

Semivariance of loss

pt.sharp

Sharp ratio

pt.sortino

Sortino ratio

pt.te

Tracking error

pt.treynor

Treynor ratio

pt.udrtn

Average up and down returns

pt.updwcap

Up and down capture

reg.adj.r.squared

Adjusted R-squared for lm.fit

reg.aic

AIC for lm.fit

reg.bic

BIC for lm.fit

reg.dof

Degree of freedom for lim.fit

reg.dw

Durbin-Watson Test

reg.linreg

Linear regression processor

reg.model

Linear model generator

reg.r.squared

R-squared for lm.fit

reg.std.err

Standard error for lim.fit

tr.log

Sigmoid function

tr.logtb

Logistic function

tr.nd

Normal density function

tr.unli

Unit normal loss integral

xd.fred

Download data from Federal Reserve Bank of St. Louis

xd.fred.tickers

Federal Reserve Bank of St. Louis Economic Data Tickers

Miscellaneous functions for data analysis, portfolio management, graphics, data manipulation, statistical investigation, including descriptive statistics, creating leading and lagging variables, portfolio return analysis, time series difference and percentage change calculation, stacking data for higher efficient analysis.

  • Maintainer: Xuanhua (Peter) Yin
  • License: GPL (>= 2)
  • Last published: 2020-03-25