Geeglm дает ошибку "несовместимые типы (от языка к символу) в исправлении типа поднабора" - PullRequest
0 голосов
/ 07 февраля 2020

У меня проблема с использованием geeglm из библиотеки geepack. Я не понимаю, что не так:

df <- structure(list(ID = c(3, 3, 10, 11, 11, 13), 
                     VO2max = c(3584.2, 2235.7, 4191.6, 2025.1, 3184.6, 2134.9), 
                     HRR120 = c(56, 34, 60, 57, 30, 67), 
                     Age = c(16, 24, 29, 11, 27, 34), 
                     Weight = c(63.8, 72, 81, 41, 108, 55),
                     Height = c(176, 167, 178, 150, 176, 156 )), 
                class = c("data.frame"))

library(geepack)
geeglm(formula = "VO2max ~ HRR120  ",family = "gaussian",corstr = "independence",id = ID,data = df)

Ошибка в mcall $ формула [3] <- switch (match (length (sformula)), c (0, 2, 3) ),: несовместимые типы (от языка к символу) в fix типа subassignment </p>

Я безуспешно пытался

df<span class="math-container">$ID <- as.character(df$</span>ID)
df<span class="math-container">$ID <- as.factor(df$</span>ID)

. У кого-нибудь есть объяснение?

1 Ответ

1 голос
/ 07 февраля 2020

Просто удалите кавычки формулы и все работает:

geeglm(formula = VO2max ~ HRR120, family = "gaussian",corstr = "independence",id = ID,data = df)

Call:
geeglm(formula = VO2max ~ HRR120, family = "gaussian", 
    data = df, id = ID, corstr = "independence")

Coefficients:
(Intercept)      HRR120 
2764.311798    2.533649 

Degrees of Freedom: 6 Total (i.e. Null);  4 Residual

Scale Link:                   identity
Estimated Scale Parameters:  [1] 666987

Correlation:  Structure = independence  
Number of clusters:   4   Maximum cluster size: 2 
...