0

I have a response variable (A) which I transformed (logA) and predictor (B) from data (X) which are both continuous. How do I check the linearity between the two variables using Generalized Additive Model (GAM) in R. I use the following code

model <- gamlss(logA ~ pb(B) , data = X, trace = F)

but I am not sure about it, can I add "family=Poisson" in the code when logA is continuous in GLM? Any thoughts on this?

Thanks in advance

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
Tristan
  • 13
  • 4
  • I think you are asking a statistical question. Better for https://stats.stackexchange.com/ , I try to answer your question below – StupidWolf Nov 08 '21 at 08:24

1 Answers1

0

If your dependent variable is a count variable, you can use family=PO() without log transformation. With family=PO() a log link is already applied to transform the variable. See help page for gamlss family and also vignette on count regression section 2.1.

So it will go like:

library(gamlss)
fit = gamlss(gear ~ pb(mpg),data=mtcars,family=PO())

You can see that the predictions are log transformed and you need to take the exponential:

with(mtcars,plot(mpg,gear))
points(mtcars$mpg,exp(predict(fit,what="mu")),col="blue",pch=20)

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72