Description Usage Arguments Details Value Author(s) Examples
compute a gaussian log likelihood criterion for a GEE fit
1 |
gmod |
a gee or yagsResult instance |
response |
the response data vector for the instance |
x |
the design matrix (will typically need an intercept column) for the instance |
id |
the cluster discriminator |
tim |
the time coordinates when relevant for time series models |
invlink |
transformation of Xbeta to generate mean response |
hetfac |
function of estimated mean to multiply variance function for heteroskedasticity |
Note that yags now computes the m2LG value as a matter of course for several working structures. This code is simply called after yags has converged before returning the yagsResult instance.
a scalar
VJ Carey
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | set.seed(2340)
y = rnorm(200,10)
x = runif(200)
id = as.numeric(rep(1:50, each=4))
require(gee)
require(yags)
f1 = gee(y~x, id=id, corstr="exchangeable")
f2 = yags(y~x, id=id, corstr="exchangeable", alphainit=.2)
require(nlme)
f3 = gls(y~x, cor=corCompSymm(.2, form=~1|id), method="ML")
m2LG(f1, y, cbind(1,x), id, id ) # tim variable irrelevant
m2LG(f2, y, cbind(1,x), id, id ) # tim variable irrelevant
-2*f3$logLik # for ML estimate of correlation
f4 = gls(y~x, cor=corCompSymm(f2@alpha, form=~1|id,fixed=TRUE), method="ML")
-2*f4$logLik
# relate m2LG to deviance in simple case
f5 = yags(y~x, id=id, corstr="independence")
summary(f5)
f5@m2LG
f5@phi*(f5@m2LG-200*log(2*pi*f5@phi))
f6 = glm(y~x)
f6
# generate heteroskedastic data and check
y2 = rnorm(200,25,(1+2*x)^2)
f7 = yags(y2~x, id=id, corstr="independence", family=quasi(var="mu^2"), betainit=c(25,.03))
f7@m2LG
f7@phi*(f7@m2LG-200*log(2*pi*f7@phi))
f8 = glm(y2~x, family=quasi(var="mu^2"))
summary(f8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.