如何在线性模型的两侧制作对数函数
How to make log function in both sides of linear model
我正在尝试进行回归,需要对因变量和自变量进行对数变换。
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")
电脑报错"In log(reg.conv$GINF) : NaNs produced"
怎么办?
这表明 reg.conf$GINF
的某些值低于 0。您需要确定处理这些值的正确方法,但您可以从找到它们开始:
reg.conf[reg.conf$GINF < 0,]
或者,使用 dplyr
(更漂亮的表示法):
reg.conf %>%
filter(GINF < 0)
我正在尝试进行回归,需要对因变量和自变量进行对数变换。
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")
电脑报错"In log(reg.conv$GINF) : NaNs produced" 怎么办?
这表明 reg.conf$GINF
的某些值低于 0。您需要确定处理这些值的正确方法,但您可以从找到它们开始:
reg.conf[reg.conf$GINF < 0,]
或者,使用 dplyr
(更漂亮的表示法):
reg.conf %>%
filter(GINF < 0)