#' Negative Log-Likelihood for a Generalized Linear Model
#'
#' @param b a matrix where each row represents a point at which Negative Log-Likelihood is to be calculated
#' @param y A vector
#' @param x A matrix
#' @param alpha A vector
#' @param wt A vector
#' @param family A family
#' @return The sum of \code{x} and \code{y}
#' @keywords internal
#' @examples
#' 1+1
#' 10+1
Neg_logLik<-function(b, y, x, alpha, wt,family){
## Add required checks on other inputs at the top
if (is.character(family))
family <- get(family, mode = "function", envir = parent.frame())
if (is.function(family))
family <- family()
if (is.null(family$family)) {
print(family)
stop("'family' not recognized")
}
okfamilies <- c("gaussian","poisson","binomial","quasipoisson","quasibinomial","Gamma")
if(family$family %in% okfamilies){
if(family$family=="gaussian") oklinks<-c("identity")
if(family$family=="poisson"||family$family=="quasipoisson") oklinks<-c("log")
if(family$family=="binomial"||family$family=="quasibinomial") oklinks<-c("logit","probit","cloglog")
if(family$family=="Gamma") oklinks<-c("log")
if(family$link %in% oklinks){
## This may be the R version of these files so may not be using the efficiency of C++
## This may be safer
famfunc<-glmbfamfunc(family)
f1<-famfunc$f1
f2<-famfunc$f2
f3<-famfunc$f3
# f5<-famfunc$f5
# f6<-famfunc$f6
}
else{
stop(gettextf("link \"%s\" not available for selected family; available links are %s",
family$link , paste(sQuote(oklinks), collapse = ", ")),
domain = NA)
}
}
else {
stop(gettextf("family \"%s\" not available in glmb; available families are %s",
family$family , paste(sQuote(okfamilies), collapse = ", ")),
domain = NA)
}
return(f1(b, y, x, alpha, wt))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.