[R] Problems using predict with GEE

Sorkin, John j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Wed Apr 1 00:46:58 CEST 2020


I am running gee with a an offset followed by predict to get predicted values. The GEE analysis runs without error. When I run the predict function, I get the following error message:

Error in seq_len(p) : argument must be coercible to non-negative integer
In addition: Warning messages:
1: In predict.lm(object, newdata, se.fit, scale = 1, type = if (type ==  :
  calling predict.lm(<fake-lm-object>) ...
2: In seq_len(p) : first element used of 'length.out' argument

The error does not appear to be related to the offset values.

I hope someone can help me correct the error. Reproducible code follows:

Thank you,
John


install.packages("gee")
library(gee)

myData2 <- structure(list(HG = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3, 0, 0, 0, 0),
                          Group = structure(c(1L,
                                              1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
                                              1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
                                              1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
                                              2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
                                              2L, 2L, 2L, 2L, 2L, 2L, 2L),
                                            .Label = c("Group1", "Group2"), class = "factor")),
                     class = "data.frame", row.names = c(NA,-72L))
myData2
# Define offset
FU <- 1
# Run GEE wiht offset
fitGEE <- gee(HG+offset(log(FU))~Group,family=quasi,
              data=myData2,id=AllData$"Subject ID",corstr="exchangeable",subset=subset)
print(summary(fitGEE))

# Create a dataframe with data used in predict.
# FU =1
new.data <- data.frame(Group=c("Group1","Group2"),FU=1)
cat("These are the data used by predict\n")
print(new.data)
# This predict fails
LogPtEst <- predict(fitGEE,newdata=new.data)

# Create a dataframe with data used in predict.
# FU =0
new.data <- data.frame(Group=c("Group1","Group2"),FU=0)
cat("These are the data used by predict\n")
print(new.data)
# This predict also fails
LogPtEst <- predict(fitGEE,newdata=new.data)

Many thanks,
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


	[[alternative HTML version deleted]]



More information about the R-help mailing list