[R] GLM with Numeric and Factor as an Input

Lorenzo Isella lorenzo.isella at gmail.com
Tue Feb 25 13:40:31 CET 2014


Dear All,
Please consider the snippet at the end of the email.
It is representative of the problems I am experiencing.
I am trying to use glm (without using the formula interface because the  
original data is quite large) to model the response in a case where the  
predictors are a mix of numbers and factors.
In the end, I always end up with an error message, despite having tried  
different choices for the "family" parameter.
Maybe I am missing the obvious, but can anyone run glm with a combination  
of numbers and factors?
Any help is appreciated.
Cheers

Lorenzo




###############################################################
set.seed(1234)

x <- rnorm(1000)
dim(x) <- c(100,10)
x <- as.data.frame(x)
names(x) <- LETTERS[seq(10)]

x$J <- round(x$J)

x$J <- as.factor(x$J)

y <- x$A
x <- subset(x, select=-c(A))

model <- glm.fit(x,y## , family=gaussian
                                )



More information about the R-help mailing list