pbreheny/visreg

error in parse

Closed this issue · 2 comments

Hi,

I have a little problem!
I want to use the dataset "freMTPL2fre" from the package CASdatasets and I want to run this code...

m1 <- glm(ClaimNb ~ (offset(log(Exposure)))+ VehGas + VehBrand , data = freMTPLfre,family=poisson(link = log))
visreg(m1,"VehGas", type="contrast", scale="response", gg=TRUE, rug=FALSE, partial=FALSE) + theme_bw()

I have an error:

Erreur dans parse(text = c("cond=c(cond, list(", names(f)[j], "=factor(mode, levels=levels(f[, names(f)[j]]))))")) :
:3:1: '=' inattendu(e)
2: NA
3: =

But for example, if I take the dataset "freMTPLfre" from the same package and I want run the same code...

m1 <- glm(ClaimNb ~ (offset(log(Exposure)))+ Gas + Brand , data = freMTPLfreq,family=poisson(link = log))
visreg(m1,"Brand", type="contrast", scale="response", gg=TRUE, rug=FALSE, partial=FALSE) + theme_bw()

I don't have any problem

Can someone help me?

I don't understand what you're asking. Gas and Brand are variables in the data set "freMTPL2freq". VehGas and VehBrand are not. You can't fit models on variables that don't exist, let alone plot them.

If there are extra steps you're not showing where these variables are created, no one can help you unless you supply a reproducible example.

Closing this issue since I never heard back from you.