代码之家  ›  专栏  ›  技术社区  ›  D. Smel

如何在线性模型的两侧生成对数函数

  •  1
  • D. Smel  · 技术社区  · 8 年前

    我正在做回归,需要对因变量和自变量进行对数变换。

    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")
    

    计算机给了我一个错误“在日志中(注册转换$GINF):NaNs生成” 怎么办?

    1 回复  |  直到 8 年前
        1
  •  2
  •   Melissa Key    8 年前

    这表明 reg.conf$GINF 低于0。您需要确定处理这些值的正确方法,但可以从查找它们开始:

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

    或者,使用 dplyr (更漂亮的符号):

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