Regression gives an error on one of the input variables "contrasts can only be applied to factors with 2 or more levels"

I am running a logit regression in R with a lot of input variables.

newlogit <- glm(install. ~ SIZES + GROSSCONSUMPTION.... + 
                NETTCONSUMPTION..... + NETTGENERATION....... + 
                GROSSGENERATION.... + Variable. + Fixed + 
                Cost.of.gross.cons + Cost.of.net.cons + Cons.savings + 
                generation.gains + Total.savings + Cost.of.system + 
                Payback + Self.consumption + Total.consumption.as.solar + 
                Owner.occupied + postcode + Suburb + Market.penetration + 
                X..green.vote, data = newdata, family = "binomial")

I get this error:

Error in contrasts <- (tmp, value = contr.funs [1 + isOF [nn]]): contrasts can only be applied to factors with 2 or more levels

Could you tell us why this error occurs, and is there a way to trigger this regression?

-1
source share
2 answers

It points to one of your variables (as gvrocha said); you can have a coefficient with only one level or row.

, () (-), , / col , .

( ) glm (glm(data[,'install.'] ~ data[,2:40]), . [1])

glm(install. ~ var1 + var2 + ...:

[1] R?

+1

, , .

, , , .

+2

Source: https://habr.com/ru/post/1607131/


All Articles