Skip to content

Commit

Permalink
estimator='glm' works with formulas only with intercepts
Browse files Browse the repository at this point in the history
  • Loading branch information
kkholst committed Feb 8, 2024
1 parent d132dde commit 2a8e431
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/glmest.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GLMest <- function(m,data,control=list(),...) {

for (y in yvar) {
count <- count+1
xx <- parents(m,y)
xx <- parents(m, y)
fam <- attributes(distribution(m)[[y]])$family
if (is.null(fam)) fam <- stats::gaussian()
if (!is.null(fam$link)) {
Expand All @@ -63,17 +63,19 @@ GLMest <- function(m,data,control=list(),...) {
} else {
g <- glm(f,family=fam,data=data,...)
}

p <- pars(g)
ii <- IC(g)
V0 <- attr(ii, "bread")
ics <- cbind(ics,ii)
y <- y0
names(p)[1] <- y
if (length(p)>1) {
nn <- paste(y,xx,sep=lava.options()$symbol[1])
names(p)[seq_along(nn)+1] <- nn0
if (length(p)>length(nn)+1) names(p)[length(p)] <- paste(y,y,sep=lava.options()$symbol[2])
xx0 <- setdiff(xx, 1)
if (length(xx0) > 0) {
nn0 <- paste(y, xx0, sep = lava.options()$symbol[1])
names(p)[seq_along(nn0) + 1] <- nn0
}
if (length(p)>length(xx0)+1) names(p)[length(p)] <- paste(y,y,sep=lava.options()$symbol[2])
}
if (tolower(fam$family)%in%c("gaussian","gamma","inverse.gaussian") && !isSurv) {
ics <- cbind(ics,0)
Expand Down

0 comments on commit 2a8e431

Please sign in to comment.