# R-programming-statistics

R is a programming language possesses an extensive catalog of statistical and graphical methods. It includes machine learning algorithm, linear regression, time series, statistical inference to name a few. Most of the R libraries are written in R,but many large companies also use R programming language, including Uber, Google, Airbnb, Facebook and so on

## Email subscriptions

Delivered by FeedBurner

## we create the log-likelihood function

>  LL = function(params , rets ) {alpha = params [ 1 ] ; sigsq = params [ 2 ]
+     logf = −log(sqrt (2*pi*sigsq))
+     − ( rets−alpha )^2/(2*sigsq )
+      LL = −sum( logf ) }
We then go ahead and do the MLE using the nlm (non-linear minimization) package in R. It uses a Newton-type algorithm.
# create starting guess for par ameters
params = c(0.001, 0.001 )
> res = nlm( LL,params, rets )
> params = c(0.001, 0.001 )
> res = nlm( LL,params, rets )
There were 50 or more warnings (use warnings() to see the first 50)
> res
\$minimum
[1] -6.591566

\$estimate
[1] 1.000000e-03 2.995424e-07

[1]      0.0 733755.7

\$code
[1] 2

\$iterations
[1] 7
We now pick off the results and manipulate them to get the annualized parameters {Âµ, Ïƒ}.

>  alpha = res\$estimate [ 1 ]
>  sigsq = res\$estimate [ 2 ]
>  sigma = sqrt( sigsq/h )
> sigma
[1] 0.008688192
> mu = alpha/h+0.5*sigma^2
> mu
[1] 0.2520377