Closed c-silos closed 2 years ago
Hi, Can you provide a minimal working example? Just from looking at your code, the as.matrix() in the model formula looks like it might cause the problem.
c-silos @.***> schrieb am Fr., 18. Feb. 2022, 02:03:
Hello,
I am using the glmboost function with the following formula: mb1 <- glmboost(y ~ as.matrix(brandom(id)) + ctime + time_squared + x1ctime + x1time_squared, data = merged_data) And I get the following error: Error in model.frame.default(object, data, xlev = xlev) : invalid type (list) for variable 'brandom(id)'
I have tried unlisting the variable as follows:
`merged_data$id <- factor(merged_data$id)
merged_data$id <- unlist(merged_data$id)`
Any help would be appreciated.
Thanks.
— Reply to this email directly, view it on GitHub https://github.com/boost-R/mboost/issues/116, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCWY7RRWXGPXDJIHMFHY6LU3WLHTANCNFSM5OWLCEAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi,
See below the minimal working example:
set.seed(101)
df <- data.frame(replicate(154,runif(90, 1, 2.5)))
set.seed(101)
df2 <- data.frame(replicate(5,runif(90, 300, 20000)))
colnames(df2) <- c('C1','C2','C3', 'C4', 'C5')
set.seed(101)
df3 <- data.frame(replicate(5,sample(0:1,90,rep=TRUE)))
colnames(df3) <- c('D1','D2','D3', 'D4', 'D5')
set.seed(101)
df$time <- rep(c(1,6,12), each = 1)
df$ID <- rep(c(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,30), each = 3)
df_complete <- cbind(df,df2,df3)
df_complete$time_squared <- df_complete$time*df_complete$time
df_complete$ID <- factor(df_complete$ID)
library(mboost)
mb1 <- glmboost(X30 ~ brandom(ID) + time + time_squared + X15*time + X15*time_squared, data = df_complete,control = boost_control(mstop = 1000))
coef(mb1)
@c-silos
glmboost
fits a generalized linear model via boosting, you can't specify any baselearners in its formula (it always uses bols
for all covariates)
Use mboost
for the general case with random or non-linear spline effects etc:
mb1 <- mboost(X30 ~ brandom(ID) + time + time_squared + X15*time + X15*time_squared, data = df_complete,control = boost_control(mstop = 1000))
(still won't work because your reprex-data is weird, but the formula gets parsed correctly, at least.)
Hello,
I am using the glmboost function with the following formula:
mb1 <- glmboost(y ~ as.matrix(brandom(id)) + ctime + time_squared + x1*ctime + x1*time_squared, data = merged_data)
And I get the following error: Error in model.frame.default(object, data, xlev = xlev) : invalid type (list) for variable 'brandom(id)'I have tried unlisting the variable as follows:
`merged_data$id <- factor(merged_data$id)
merged_data$id <- unlist(merged_data$id)`
Any help would be appreciated.
Thanks.