Displaying 20 results from an estimated 256 matches for "loglik".

2011 Jan 24

2

how to get loglik parameter from splm package?

splm package is a r implemention of spatial panel data models.
and the loglik paremeter is most important infomation for splm methods.
but i found the loglik always been null ,it's craze to get right estimation
in splm with null loglik.
Any one knows the splm package and can get the right loglik ? please help
me.
thanks
--
View this message in context: http:/...

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

2008 Nov 28

2

AIC function and Step function

...og L + k * edf,
where L is the likelihood and edf the equivalent degrees of freedom (i.e.,
the number of free parameters for usual parametric models) of fit.
For linear models with unknown scale (i.e., for lm and aov), -2log L is
computed from the deviance and uses a different additive constant to logLik
and hence AIC. If RSS denotes the (weighted) residual sum of squares then
extractAIC uses for - 2log L the formulae RSS/s - n (corresponding to
Mallows' Cp) in the case of known scale s and n log (RSS/n) for unknown
scale. AIC only handles unknown scale and uses the formula n log (RSS...

2007 Mar 15

1

expm() within the Matrix package

Hi
Could anybody give me a bit of advice on some code I'm having trouble with?
I've been trying to calculate the loglikelihood of a function iterated over
a data of time values and I seem to be experiencing difficulty when I use
the function expm(). Here's an example of what I am trying to do
y<-c(5,10) #vector of 2 survival times
p<-Matrix(c(1,0),1,2) #1x2 matrix
Q<-Matrix(c(1,2,3,4),2,2)...

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...

2010 Sep 02

1

Help on glm and optim

...s a lot.
The following is the code:
# Step 1: fit the glm
clotting <- data.frame(
u = c(5,10,15,20,30,40,60,80,100),
lot1 = c(118,58,42,35,27,25,21,19,18),
lot2 = c(69,35,26,21,18,16,13,12,12))
fit1 <- glm(lot1 ~ log(u), data=clotting, family=Gamma)
# Step 2: use optim
# define loglikelihood function to be maximized over
# theta is a vector of three parameters: intercept, cofficient for log(u) and dispersion parameter
loglik <- function(theta,data){
E <- 1/(theta[1]+theta[2]*log(data$u))
V <- theta[3]*E^2
loglik <- sum(dgamma(data$lot1,sha...

2013 Jan 31

1

LogLik of nls

Hello there,
Can anyone point me to the code for logLik of an nls object? I found the
code for logLik of an lm but could not find exactly what function is used
for calculating the logLik of nls function?
I am using the nls to fit the following model to data -
Model 1: y ~ Ae^(-mx) + Be^(-nx) +c
and want to understand what is the likelihood function us...

2013 May 21

1

Calculating AIC for the whole model in VAR

Hello!
I am using package "VAR".
I've fitted my model:
mymodel<-VAR(mydata,myp,type="const")
I can extract the Log Liklihood for THE WHOLE MODEL:
logLik(mymodel)
How could I calculate (other than manually) the corresponding Akaike
Information Criterion (AIC)?
I tried AIC - but it does not take mymodel:
AIC(mymodel)
# numeric(0)
Thank you!
--
Dimitri Liakhovitski
[[alternative HTML version deleted]]

2004 Dec 04

1

AIC, AICc, and K

How can I extract K (number of parameters) from an AIC calculation, both to
report K itself and to calculate AICc? I'm aware of the conversion from AIC ->
AICc, where AICc = AIC + 2K(K+1)/(n-K-1), but not sure of how K is calculated
or how to extract that value from either an AIC or logLik calculation.
This is probably more of a basic statistics question than an R question, but I
thank you for your help.
-Ben Osborne
--
Botany Department
University of Vermont
109 Carrigan Drive
Burlington, VT 05405
benjamin.osborne at uvm.edu
phone: 802-656-0297
fax: 802-656-0440

2011 Oct 25

1

difficulties with MuMIn model generation with coxph

...ate subsets
of models from a global cox proportional hazards model, and rank them based
on AICc. These seems like it's possible, and the Mumin documentation says
that coxph is supported. However, when I run the code (see below), it gives
me the following error message:
Error in UseMethod("logLik") :
no applicable method for 'logLik' applied to an object of class "logical"
##RCode
#read in the data
>data1<-read.table('MaleData500.csv', sep=',', header=T)
survival<-Surv(data1$Wks.at.dth, data1$Died)
#create the full (global) model, a co...

2008 Mar 13

1

strange results from binomial lmer?

...t;http://www.ling.upenn.edu/~johnson4/strange.csv")
gs <- glm(outcome~gender+stress,binomial,dat)
g_s <- lmer(outcome~gender+(1|speaker),dat,binomial)
s_s <- lmer(outcome~stress+(1|speaker),dat,binomial)
gs_s <- lmer(outcome~gender+stress+(1|speaker),dat,binomial)
logLik(gs) # -1344 (df=3)
logLik(g_s) # -1342 (df=3)
logLik(s_s) # -1314 (df=3)
logLik(gs_s) # -11823 (df=4)
This seems like an error of some kind. The glm() model with both fixed effects
is well-behaved, but lmer() seems to be going haywire when confronted with the
same si...

2009 Jun 12

1

Function for AIC or logLIK for nlsList object

Dear R users,
Does anybody have a function to calculate logLik or AIC for nlsList objects? After receiving error messages, another user helped me ascertain that this function is not currently written into R.
Many thanks
Lindsay

2002 Apr 22

3

glm() function not finding the maximum

...hy I switched to R from Splus. The Splus analogue was very slow, and
didn't find the maximum.
The data set and code for the two methods of estimation are included
below. I don't think I am making a mistake here. Sorry if I have.
Thanks
Richard
> gamma1(data) #uses the glm() function
$loglik
[1] 875.4274
$par
[1] 9.572403e-02 4.345771e+03
> gamma2(data) #"by hand" using optim()
$loglik
[1] 793.3913
$par
[1] 0.518145 802.854297
#Data set
data_c(51.47, 210.19, 49.55, 61.93, 60.61, 744.57, 338.59, 133.93,
191.57, 111.43, 432.83, 185.23, 155.61, 84.72, 120.2, 15.33,
77.0...

2007 Sep 10

0

Loop and loop output [Cox model, for, function, loglik]

...winded manner due to my lack
of programming experience)
I then attach T1 T2 and T3 to a dataset KidneyT that contains other
variables i wish to use in a Cox regression model. I require the
log likelihood statistic of a Cox model when variables T1 T2 T3 and some
from KidneyT are fitted. ( coxmodel$loglik[2] )
########################################################################
##########
I can get this to work fine for specified values of tf1 and tf2, but
wish to get the loglikelihood value for many combinations of tf1 and tf2
which are times from 1 to 50 hours i.e I need loglik statistic whe...

2006 Dec 12

1

Calculating AICc using conditional logistic regression

I have a case-control study that I'm analysing using the conditional
logistic regression function clogit from the survival package.
I would like to calculate the AICc of the models I fit using clogit.
I have a variety of scripts that can calculate AICc for models with a
logLik method, but clogit does not appear to use this method.
Is there a way I can calculate AICc from clogit in R?
Many thanks,
Katherine Boughey
--
School of Environmental Sciences
University of East Anglia
Norwich
NR4 7TJ

2007 Aug 17

0

(Ben Bolker) AIC and logLik for logistic regression in R and S-PLUS

...e: 23.900 on 19 degrees of freedom
>> > AIC: 29.9
>> > --------------------------------------------------------------------
>> > 'R'
>> > -----------------
>> > > AIC(mydata.glm)
>> > [1] 29.89986
>> >
>> > > logLik(mydata.glm)
>> > 'log Lik.' -11.94993 (df=3)
>> > -----------------
>> >
>> > 'S-PLUS'
>> > -----------------
>> > > AIC(mydata.glm)
>> > [1] 71.03222
>> >
>> > > logLik(mydata.glm)
>> &...

2008 Jan 24

0

possible inconsistency in nlme logLik or me

...to fit the same model but with a correlation structure. I am comparing models using AIC, but I am getting results that don't seem to match. I get matching results for the model with no correlation structure, but non corresponding results for the model with a correlation structure. Below are logLik for the models along with additional information. Am I doing something wrong?????
Information for model 1
rss=sum(resid(mod1)^2)=1318.645
var=rss/n=1.654511
n=797
number of parameters (K) = 10 (this does include the variance estimate)
if I use logLik(mod1) I get -1331.541 with 10 d.f.
if...

2009 Apr 15

2

AICs from lmer different with summary and anova

...ata=datx); print(summary(fit1),corr=F)
#compare the models
anova(fit0,fit1)
Now, look at the output, below. You can see that the AIC from
"print(summary(fit0))" is 87.34, but the AIC for fit0 in "anova(fit0,fit1)"
is 73.965. There are similar changes for the values of BIC and logLik.
Am I doing something wrong, here? If not, which are the real AIC and logLik
values for the different models?
Thanks for your help,
Jonathan Williams
Output:-
> fit0=lmer(y~x1+x2+(1|id), data=datx); print(summary(fit0),corr=F)
Linear mixed model fit by REML
Formula: y ~ x1 + x2 + (1 | id)...

2008 Oct 28

2

Fitting weibull and exponential distributions to left censoring data

Dear R-users
I have some datasets, all left-censoring, and I would like to fit
distributions to (weibull,exponential, etc..). I read one solution using the
function survreg in the survival package. i.e
survreg(Surv(...)~1, dist="weibull") but it returns only the scale
parameter.
Does anyone know how to successfully fit the exponential, weibull etc...
distributions to left-censoring

2008 Jul 16

4

Likelihood ratio test between glm and glmer fits

...vorced+SINGLE+chronic+vigor_d+moderat_d+(1|munid),family=binomial(), data=mx.merge)
I cannot find a method in R that will do the LR test between a glm and a glmer fit, so I try to do it using the liklihoods from both models
#form the likelihood ratio test between the glm and glmer fits
x2<--2*(logLik(ph.fit.2)-logLik(ph.fit.3))
> ML
79.60454
attr(,"nobs")
n
45243
attr(,"nall")
n
45243
attr(,"df")
[1] 14
attr(,"REML")
[1] FALSE
attr(,"class")
[1] "logLik"
#Get the associated p-value
dchisq(x2,14)
ML
>...