Title: | Financial Analysis and Regression Diagnostic Analysis |
---|---|
Description: | Functions for financial analysis and financial modeling, including batch graphs generation, beta calculation, descriptive statistics, annuity calculation, bond pricing and financial data download. |
Authors: | Xuanhua(Peter) Yin <[email protected]> |
Maintainer: | Xuanhua(Peter) Yin <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.2 |
Built: | 2025-02-13 03:25:37 UTC |
Source: | https://github.com/cran/FinAna |
Calculate future value of an ordinary annuity or an annuity due.
annu.fv(pmt,i,n,type = 0)
annu.fv(pmt,i,n,type = 0)
pmt |
:the equal amount of payment of each period |
i |
:interest rate accoding to the period |
n |
:number of periods |
type |
:type = 0 for ordinary annuity, type = 1 for annuity due |
#annu.fv(100,0.0248,10,0)
#annu.fv(100,0.0248,10,0)
Calculate present value of an ordinary annuity or an annuity due.
annu.pv(pmt,i,n,type = 0)
annu.pv(pmt,i,n,type = 0)
pmt |
:the equal amount of payment of each period |
i |
:interest rate accoding to the period |
n |
:number of periods |
type |
:type = 0 for ordinary annuity, type = 1 for annuity due |
#annu.pv(100,0.0248,10,0)
#annu.pv(100,0.0248,10,0)
Calculate present value of an ordinary annuity or an annuity due.
annu.pv.df(pmt,i,n,k)
annu.pv.df(pmt,i,n,k)
pmt |
:the equal amount of payment of each period |
i |
:interest rate accoding to the period |
n |
:number of periods |
k |
:number of periods deffered |
#annu.pv(100,0.0248,10,4,0)
#annu.pv(100,0.0248,10,4,0)
Calculating beta using common method or linear regression(OLS)
betaf(x,y,method)
betaf(x,y,method)
x |
:a vector or a data.frame of rate of return of companies |
y |
:name of the independent variable |
method |
:method of calculation; method = 1 for a common expression of beta(see detail); method = 2 using linear regression to estimate the beta |
#betaf(appl,sp500)
#betaf(appl,sp500)
Calculate the plain vanilla bond price
bond.price(par,c,n,yield,m)
bond.price(par,c,n,yield,m)
par |
:the face value of the bond |
c |
:the annual coupon rate of the bond |
n |
:number of years |
yield |
:the annual yield to maturity of a bond |
m |
:couponding period in a year |
#bond.price(1000,0.03,10,0.0248,2)
#bond.price(1000,0.03,10,0.0248,2)
Calculating the descriptive statistics of a data.frame and exporting in a data.frame
corm(x,n)
corm(x,n)
x |
:a data.frame |
n |
:number of decimal points |
#corm(sp1500,3) for correlation matrix of sp1500
#corm(sp1500,3) for correlation matrix of sp1500
Calculating the descriptive statistics of a data.frame and exporting in a data.frame
desc(x,n)
desc(x,n)
x |
:a data.frame |
n |
:number of decimal points |
#desc(sp1500,3) for descriptive statistics of sp1500
#desc(sp1500,3) for descriptive statistics of sp1500
Calculating mode for numeric data
get.mode(x)
get.mode(x)
x |
:a numeric variable(vector) |
# get.mode(return)
# get.mode(return)
Download stock prices for one company or a list of companies from google finance. And furthur application of rate of return function and beta function in the package for more analysis.
get.price.google(tkr, bg = "2001-01-01",ed = "today")
get.price.google(tkr, bg = "2001-01-01",ed = "today")
tkr |
:company ticker, e.g. "BABA","AMZN" |
bg |
:beginning date, e.g."2000-02-29" |
ed |
:ending date, e.g. "today", "2016-11-10" |
#get.price.google("GOOG") #get.price.google("GOOG", bg = "2001-01-01",ed = "today") # the two above are the same # # tkr <- c("AAPL", "IBM","YHOO") # pricelist <- get.price.google(tkr, bg = "2001-01-01",ed = "today") # aapl <- pricelist[1] # convert to single data.frame # ibm <- pricelist[2] # convert to single data.frame # yhoo <- pricelist[3] # convert to single data.frame
#get.price.google("GOOG") #get.price.google("GOOG", bg = "2001-01-01",ed = "today") # the two above are the same # # tkr <- c("AAPL", "IBM","YHOO") # pricelist <- get.price.google(tkr, bg = "2001-01-01",ed = "today") # aapl <- pricelist[1] # convert to single data.frame # ibm <- pricelist[2] # convert to single data.frame # yhoo <- pricelist[3] # convert to single data.frame
Download stock prices for one company or a list of companies from Yahoo finance. The function can download daily, weekly and monthly data. And furthur application of rate of return function and beta function in the package for more analysis.
get.price.yahoo(tkr, bg = "first",ed = "today", f = "d")
get.price.yahoo(tkr, bg = "first",ed = "today", f = "d")
tkr |
:company ticker, e.g. "BABA","AMZN" |
bg |
:beginning date, e.g. "first","2000-02-29" |
ed |
:ending date, e.g. "today", "2016-11-10" |
f |
:frequency, e.g. "d" for daily,"w" for weekly,"m" for monthly |
#get.price.yahoo("GOOG") #get.price.yahoo("GOOG", bg = "first",ed = "today", f = "d") # the two above are the same # # tkr <- c("AAPL", "IBM","YHOO") # pricelist <- get.price.yahoo(tkr, bg = "first",ed = "today", f = "m") # aapl <- pricelist[1] # convert to single data.frame # ibm <- pricelist[2] # convert to single data.frame # yhoo <- pricelist[3] # convert to single data.frame
#get.price.yahoo("GOOG") #get.price.yahoo("GOOG", bg = "first",ed = "today", f = "d") # the two above are the same # # tkr <- c("AAPL", "IBM","YHOO") # pricelist <- get.price.yahoo(tkr, bg = "first",ed = "today", f = "m") # aapl <- pricelist[1] # convert to single data.frame # ibm <- pricelist[2] # convert to single data.frame # yhoo <- pricelist[3] # convert to single data.frame
Kurtosis
kur(x)
kur(x)
x |
:a numeric variable |
#kur(return) for skewness of variable return
#kur(return) for skewness of variable return
Plotting histograms for a data.frame. Also the function will name the graphs and number the graphs.
ploth(x,c,l)
ploth(x,c,l)
x |
:a dataframe |
c |
:is there dummy variable in the data.frame; c = 0 when there is none; c = 1 when there is |
l |
: number of labeling starts at (default = 1) |
#ploth(sp500,0,20) for histograms of sp500 which does not has dummy variables
#ploth(sp500,0,20) for histograms of sp500 which does not has dummy variables
Plotting histograms or scatter plots of your choice for a data.frame. Also the function will name the graphs and number them.The purpose of the function is to save time when plotting graphs for a regression analysis or other usage. The function can plot, name and number the graphs at one step.
ploths(x,a,dependent,c,l)
ploths(x,a,dependent,c,l)
x |
:a dataframe |
a |
:the type of graph you want; a = 1 for histograms; a = 2 for scatter plots; a = 0 for both |
dependent |
:the dependent variable for scatterplots |
c |
:is there dummy variable in the dataframe; c = 0 when there is none; c = 1 when there is |
l |
: number of labeling starts at (default = 1) |
#ploths(sp500,0,"price",0,20)
#ploths(sp500,0,"price",0,20)
Plotting scatter smooth plots for a data.frame, with name, number and labels.
plotsm(x,dependent,c,l)
plotsm(x,dependent,c,l)
x |
:a dataframe |
dependent |
:the dependent variable |
c |
:is there dummy variable in the data.frame; c = 0 when there is none; c = 1 when there is |
l |
: number of labeling starts at (default = 1) |
# plotsm(JPM-ratios,"price"",0,20)
# plotsm(JPM-ratios,"price"",0,20)
Plotting time series plots for a data.frame, with name the graphs and number the graphs.
plotts(x,c,l)
plotts(x,c,l)
x |
:a dataframe |
c |
:is there dummy variable in the data.frame; c = 0 when there is none; c = 1 when there is |
l |
: number of labeling starts at (default = 1) |
#plotts(sp500,0,20)
#plotts(sp500,0,20)
Calculating the rate of return of a vector for further analysis, including calculating beta of companies, plotting to see the trend of the stock for technical analysis
rr(x,n)
rr(x,n)
x |
:a vector of company prices |
n |
: number of lags |
#rr(aapl,1)
#rr(aapl,1)
Calculating Pearson's skewness in three types: mode, median, and mean
sk(x, type = 3)
sk(x, type = 3)
x |
:a numeric variable |
type |
:type = 1 for mode skewness; type = 2 for median skewness; type = 3 for mean skewness |
#sk(return) for skewness of variable return
#sk(return) for skewness of variable return