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/statistics.r

View File Source Download File No help file available

Function: llike.GaussModel

Function Description: llike.GaussModel

This is for model.xy. It takes the model function, its parameters, x values, observed values of the dependent variable obs, and sd values, to generate a likelihood. One of the parameters is passed as testparam, for use with metrop1step. This requires a badparam function for testing parameters. The standdard deviation is passed as an argument, not calculated from sdmodel.

Function Arguments:

ArgumentDefault Value
testparam
allparam
whichtest
x
obs
model
badpred
SD
...

Function Source:

llike.GaussModel=function(testparam,allparam,whichtest,x,obs,model,badpred,SD,...)
{
param=arrangeParam.llike(testparam,allparam,whichtest)

pred=model(x=x,param=param,...)

# Passing ... to badpred. I added that Sept 2013 so that growthfit.bin could pass MINBINSAMPLE from
         command line. This now forces all if(badpred(x,param,pred,...)) return(-Inf)

llike=dnorm(obs,mean=pred,sd=SD,log=TRUE)

total=sum(llike)
if(is.na(total) | is.infinite(total) | is.null(total))
{

cat('Something wrong with llike calculation from observed and predicted; check right now SD, obs,
         x, and pred\n') browser()
}

return(total)
}