One of the most fundamental concepts of modern statistics is that of likelihood. In each of the discrete random variables we have considered thus far, the distribution depends on one or more parameters that are, in most statistical applications, unknown.
In the binomial, the parameter of interest is p since n is typically fixed and known. Consequently, a graph of the likelihood usually looks very different from a graph of the probability distribution. In most cases, for various reasons, but often computational convenience, we work with the loglikelihood. In many problems of interest, we will derive our loglikelihood from a sample rather than from a single observation. R code in Canvas on how to produce these figures :.
For example, the loglikelihood for a normal-mean problem is exactly quadratic. The typical example is the log-likelihood function of a sample that is made up of independent and identically distributed draws from a normal distribution.
In this case, the sample is a vector whose entries are draws from a normal distribution. The probability density function of a generic draw is where and are the parameters mean and variance of the normal distribution.
With the notation used in the previous section, the parameter vector is The parametric family being considered is the set of all normal distributions that can be obtained by varying the parameters and. In order to stress the fact that the probability density depends on the two parameters, we write.
The joint probability density of the sample is because the joint density of a set of independent variables is equal to the product of their marginal densities see the lecture on Independent random variables.
The likelihood function is. The log-likelihood function is typically used to derive the maximum likelihood estimator of the parameter. The estimator is obtained by solving that is, by finding the parameter that maximizes the log-likelihood of the observed sample.
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.
It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search. The following reproducible R code fits the gnls model using x,y data and a random tree with 9 taxa:. I would like to calculate the log-likelihood "by hand" in R, but without use of the logLik function based on the estimated parameters obtained from gnls so it matches the output from logLik fit.
NOTE: I am not trying to estimate parameters; I just want to calculate log-likelihood of the parameters estimated by the gnls function although if someone has a reproducible example of how to estimate parameters without gnls , I would be very interested in seeing it! I'm not really sure how to go about doing this in R.
The linear algebra notation described in Mixed-Effects Models in S and S-Plus Pinheiro and Bates is very much over my head and none of my attempts have matched logLik fit.
Here are the details described by Pinheiro and Bates:. If all of these questions are answered, in theory, I think the log-likelihood should be calculable to match the output from logLik fit. Any help on any of these questions would be greatly appreciated. If anything needs clarification, please let me know. UPDATE : I have been experimenting with various possibilities for the calculation of the log-likelihood, and here is the best I have come up with so far.
Either I'm close to the actual solution, or this is purely by coincidence. Any thoughts? Since the residuals are independent, we can just use dnorm Alternatively, we could use:.
0コメント