Topic: Utilities

Topic Description:

Basic R utilities used in many packages and functions, such as date and string manipulations, statistical distributions, geometry of lines and distances. The R package date is required for the two data functions.



File: utilities/distributions.r

View File Source Download File No help file available

Function: fit.beta.normal

Function Description: fit.beta.normal

Finding a normal distribution which most closely fits a given beta distribution. Parameters for a beta function are submitted, and the best fit mean and SD of a normal distribution returned.

Function Arguments:

ArgumentDefault Value
x
par1
xmin
par2
xmax

Function Source:

fit.beta.normal=function(x,par1,xmin,par2,xmax)
{
y=beta.normalized(x,par1,xmin,par2,xmax)
plot(x,y,type="l")

fit=optim(c((xmax-xmin)/2,(xmax-xmin)/2),minum.beta.normal,x=x,y=y)

pred=dnorm(x,mean=fit$par[1],sd=fit$par[2])
lines(x,pred,col="red")

return(fit$par)
}