Displaying 20 results from an estimated 7000 matches similar to: "How does logLik(lm(...)) find the maximum log likelihoods"
2012 Jan 10
1
importing S3 methods with importFrom
In my own package, I want to use the default S3 method of the generic
function lrtest() from the lmtest package. Since I need only one
function from lmtest, I tried to use importFrom in my NAMESPACE:
importFrom(lmtest, lrtest)
However, this fails R CMD check in the examples:
Error in UseMethod("lrtest") :
no applicable method for 'lrtest' applied to an object of class
2009 Apr 03
1
Trouble extracting graphic results from a bootstrap
Hi,
I'm trying to extract a histogram over the results from a bootstrap. However
I keep receiving the error message "Error in hist.default(boot.lrtest$ll,
breaks = "scott") : 'x' must be numeric".
The bootstrap I'm running looks like:
> boot.test <- function(data, indeces, maxit=20) {
+ y1 <- fit1+e1[indeces]
+ mod1 <- glm(y1 ~ X1-1, maxit=maxit)
+
2009 Jul 13
3
How to perform a Likelihood-ratio test?
Hi.
I would like to use a likelihood-ratio test to compare a linear model (lm()) to another linear model containing the first one to see if the extra factors are needed - but I was unable to find any help on how to do that.
Could you help me and tell me what to do? Or tell me where to find help on this topic?
Many thanks in advance!
Lars
2010 Jul 20
1
Servreg $loglik
Dear R-experts:
I am using survreg() to estimate the parameters of a Weibull density having
right-censored observations. Some observations are weighted. To do that I
regress the weighed observations against a column of ones.
When I enter the data as 37 weighted observations, the parameter estimates
are exactly the same as when I enter the data as the corresponding 70
unweighted observations.
2004 Jul 01
2
Individual log likelihoods of nlsList objects.
Hello all.
I was wondering if the logLike.nls() and logLike.nlme() functions are still
being used. Neither function seems to be available in the most recent
release of R (1.9.1). The following is contained in the help file for
logLik(): "classes which already have methods for this function include:
'glm', 'lm', 'nls' and 'gls', 'lme' and others in
2008 Mar 20
1
logLik calculations
Does the ?logLik? function applied to a ?glm? and ?glm.nb? (from MASS
package) calculate the complete log-likelihoods, or does it drop the
constant terms of the equation? (It?s not clear from the associated help
pages, and I?ve found no reference from searching the R help mailing list)
Thank you,
Kelly Young
2007 Jan 03
1
problem with logLik and offsets
Hi,
I'm trying to compare models, one of which has all parameters fixed
using offsets. The log-likelihoods seem reasonble in all cases except
the model in which there are no free parameters (model3 in the toy
example below). Any help would be appreciated.
Cheers,
Jarrod
x<-rnorm(100)
y<-rnorm(100, 1+x)
model1<-lm(y~x)
logLik(model1)
sum(dnorm(y, predict(model1),
2009 Jun 29
5
Help
Hi group,
I found a module for adaptive kernel density estimation for Stata users, but unfortunetly I don't have access to Stata, can I find a similar approach using R?
Thank u so much 4 ur time.
[[alternative HTML version deleted]]
2002 Sep 27
2
question regarding lm and logLik in R
It appears that the degrees of freedom reported by logLik changed between R
1.4.1 and R 1.5.1. Is this true?
Detail:
> I have been using the lm and logLik functions in R to develop code using
> version 1.4.1. When I run it on version 1.5.1, I'm getting different
> degrees of freedom with the logLik function. Version 1.5.1 seems to give
> one extra degree of freedom than
2008 Mar 07
1
confused about CORREP cor.LRtest
After some struggling with the data format, non-standard in
BioConductor, I have gotten cor.balance in package CORREP to work. My
desire was to obtain maximum-likelihood p-values from the same data
object using cor.LRtest, but it appears that this function wants
something different, which I can't figure out from the documentation.
Briefly, my dataset consists of 36 samples from 12
2009 Jul 15
1
GLM Gamma Family logLik formula?
Hello all,
I was wondering if someone can enlighten me as to the difference
between the logLik in R vis-a-vis Stata for a GLM model with the gamma
family.
Stata calculates the loglikelihood of the model as (in R notation)
some equivalent function of
-1/scale * sum(Y/mu+log(mu)+(scale-1)*log(Y)+log(scale)+scale*lgamma(1/scale))
where scale (or dispersion) = 1, Y = the response variable, and mu
2008 Jun 16
1
Error in maximum likelihood estimation.
Dear UseRs,
I wrote the following function to use MLE.
---------------------------------------------
mlog <- function(theta, nx = 1, nz = 1, dt){
beta <- matrix(theta[1:(nx+1)], ncol = 1)
delta <- matrix(theta[(nx+2):(nx+nz+1)], ncol = 1)
sigma2 <- theta[nx+nz+2]
gamma <- theta[nx+nz+3]
y <- as.matrix(dt[, 1], ncol = 1)
x <- as.matrix(data.frame(1,
2013 Apr 19
2
NAMESPACE and imports
I am cleaning up the rms package to not export functions not to be called
directly by users. rms uses generic functions defined in other packages.
For example there is a latex method in the Hmisc package, and rms has a
latex method for objects of class "anova.rms" so there are anova.rms and
latex.anova.rms functions in rms. I use:
2003 Jun 25
3
logLik.lm()
Hello,
I'm trying to use AIC to choose between 2 models with
positive, continuous response variables and different error
distributions (specifically a Gamma GLM with log link and a
normal linear model for log(y)). I understand that in some
cases it may not be possible (or necessary) to discriminate
between these two distributions. However, for the normal
linear model I noticed a discrepancy
2009 Feb 02
2
logLik for poisson models
Dear all,
I have a very basic question:
how does the logLik function work for poisson models?
Example:
I simulate 20 observations from a Poisson distribution with mean 800.
y <- rpois(20,800)
model <- glm(y ~ 1, family=poisson())
logLik(model)
I would like to know what's the exact formula the function logLik uses.
I looked at ?extractAIC but I cannot sort it out.
Can you please
2005 Feb 01
3
polynomials REML and ML in nlme
Hello everyone,
I hope this is a fair enough question, but I don’t have access to a copy
of Bates and Pinheiro. It is probably quite obvious but the answer might
be of general interest.
If I fit a fixed effect with an added quadratic term and then do it as
an orthogonal polynomial using maximum likelihood I get the expected
result- they have the same logLik.
2012 Apr 30
2
The constant part of the log-likelihood in StructTS
Dear all,
I'd like to discuss about a possible bug in function StructTS of stats
package. It seems that the function returns wrong value of the
log-likelihood, as the added constant to the relevant part of the
log-likelihood is misspecified. Here is an simple example:
> data(Nile)
> fit <- StructTS(Nile, type = "level")
> fit$loglik
[1] -367.5194
When computing the
2007 Mar 19
1
likelihoods in SAS GENMOD vs R glm
List: I'm helping a colleague with some Poisson regression modeling. He
uses SAS proc GENMOD and I'm using glm() in R. Note on the SAS and R
output below that our estimates, standard errors, and deviances are
identical but what we get for likelihoods differs considerably. I'm
assuming that these must differ just by some constant but it would be nice
to have some confirmation
2011 Mar 28
1
Degrees of freedom for lm in logLik and AIC
I have a question about the computation of the degrees of freedom in a linear
model:
x <- runif(20); y <- runif(20)
f <- lm(y ~ x)
logLik(f)
'log Lik.' -1.968056 (df=3)
The 3 is coming from f$rank + 1. Shouldn't it be f$rank? This affects
AIC(f).
Thanks
Frank
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context:
2003 Jan 15
2
Bug or Feature? LogLik.nls and non-central F distribution.
I have a dataset that I am running non-linear regression on via the
following code:
Hill <- function(E0,Em,C50,g,C){
#
# Hill is the hill interaction function.
#
# E0 Represents the minimum interaction Effect
#
# Em Represents the Maximum Interaction Effect
#
# C50 represents the concentration at which 50% of the effect occurs.
#
# gamma represents the cooperativity of the