D. Smel
D. Smel

Reputation: 13

How to make log function in both sides of linear model

I'm trying to make regression and need logarithmic transformation for dependent and independent variables.

model.conv <- lm(data=reg.conv, log(GINF)~log(INFt2014))
x<-log(reg.conv$GINF)
y<-log(reg.conv$INFt2014)
plot(x, y, pch=19, cex=1.5, ylim=c(0,10), xlab="LN_INFt2014", ylab="LN_GINF", main ="Scatter plot between regional inflation in the 2016 and the Growth of regional inflation from 2014 to 2016")

Computer gave me an error "In log(reg.conv$GINF) : NaNs produced" What to do?

Upvotes: 1

Views: 126

Answers (1)

Melissa Key
Melissa Key

Reputation: 4551

That suggests that some values of reg.conf$GINF are below 0. You need to decide the correct way to handle those values, but you can start by finding them:

reg.conf[reg.conf$GINF < 0,]

or, using dplyr (prettier notation):

reg.conf %>%
  filter(GINF < 0)

Upvotes: 2

Related Questions