Esteban Castro
Esteban Castro

Reputation: 1

how do you update a R model, choosing the covariate with a list O vector with names of covariate

ac0=c("WEIGHT","PREMENO","SMOKE") #this is the vector with names
ac1=glm(FRACTURE~PRIORFRAC+AGE+HEIGHT+MOMFRAC+RATERISK, data=glow, family='binomial')
ac2=update(ac1, formula.=~.+ac0[1])

Error is this:

Error in model.frame.default(formula = FRACTURE ~ PRIORFRAC + AGE + HEIGHT +  : 
  invalid type (list) for variable 'ac0[1]'

Upvotes: 0

Views: 32

Answers (1)

thothal
thothal

Reputation: 20399

You could create the formula and then pass it to update:

mF <- formula(paste(". ~ . +", ac0[1]))
update(ac1, mF)

Upvotes: 2

Related Questions