Description Usage Arguments Details Value Note Author(s) See Also
View source: R/loglikelihood.R
These functions calculate different loglikelihoods in the context of regression analyses. The different loglikelihoods are all calculated by using the function loglikelihood
. Depending on the information that serves as input in the function different loglikelihood will be calculated. In the usage section, the first two ways to use loglikelihood
allows the user to calculate the loglikelihood of the mean regression parameters whereas the third way calculates the loglikelihood of the sigma (the models variancecovariance matrix).
1 2 3 4 5 6  ## S3 method for class 'formula'
loglikelihood(formula,paramX,data,likelihoodtype="logit",..., prior)
## Default S3 method:
loglikelihood(y, X, paramX,Random=NULL,paramRandom=NULL, likelihoodtype = "logit",..., prior)
## S3 method for class 'matrix'
loglikelihood(mat,param,means,likelihoodtype="sigma",...)

formula 
Model formula. The left side presents the response matrix and the right side gives the descriptors with their parameters. (See details) 
y 
Vector defining a single response variable. 
X 
Matrix where the descriptors are columns. 
paramX 
Vector of regression parameters associated to the fixed effect (X). 
param 
Vector of regression parameters. (May potentially change !) 
Random 
Matrix defining the random effect. Each column contains either 1s (effect) or 0s (absence of effect) of the random effect. 
paramRandom 
Vector of regression parameters associated to the random effect. 
data 
A data.frame including the variables used to calculate the loglikelihood. 
mat 
A symmetric positive definite matrix. 
means 
Vector of the regression parameter averaged over the response variables. This vectors should have the same length as 
likelihoodtype 
Character string defining how the likelihood should be calculated. Any unambiguous variation of wording used in this argument is accepted. (See details) 
... 
Parameters passed to other functions. 
prior 
Numeric. A value defining a prior for specific likelihood functions (e.g. Normal likelihood). (See details) 
The formula
was designed so that it is necessary to include the parameters and the descriptors. This function is thus capable of carrying out nonlinear regression analyses.
The prior
is used only in likelihood functions that require additional prior information for the estimation of the likelihood. For example, when estimating the likelihood of the mean of a normal distribution, prior information on the variance of the normal distribution is required.
So far, the following loglikelihood have been implemented. In the formulas bellow, the inverse link functions are represented by "l", the model is presented by "m", the response variable (typically a single species) is defined by "y" and "n" defines the number of samples:
logit
 sum(log((l*y)+((1l)*(1y)))) 
Poisson
 sum(log(l)*y)n*l 
normal
 1/(2*sigma^2) * sum((ymodel)^2) 
sigma
 (β_i \bar{β_j}_i) σ^{i}(β_i \bar{β_j}_i)/2 
R
 (p/2)*log(det(R))(sum_{i=1}^p W_i R^{1} W_i)(2)(p+1)/2*log(det(W))sum(diag(W^{1}))/2 
For the sigma and R likelihood, the input needs to be a matrix. Note that the R likelihood used is designed for each nondiagonal values in the matrix to follow a uniform distribution ranging from 1 to 1.
A vector of loglikelihood values.
These functions are meant to be used within scam
.
F. Guillaume Blanchet
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.