开发者

log transform in linear model and exporting output to office

I have the following code for doing a linear regression:

data<-read.csv("File.csv",header=T)
trans<-log(data)
attach(trans)
outdata<-summary(lm(Y~A + B + C))

In the output what I have es开发者_C百科sentially is log(y)=b0+b1*log(A)+b2*log(B)+b3*log(C). In the summary output, R gives me coefficients for the log(A), log(B), and log(C). However, I would like the coefficients for A, B, and C. Is there a way to get R to give the output as 10^(b0), 10^(b1), and 10^(b2)?


A couple of things here:

  • The log function in R uses base e by default, so you really don't want to exponentiate the coefficients using base 10 after transforming the data using base e.
  • The coefficients are accessible via coef() or the less recommended outdata$coefficients[,1]. You can extract them directly and then transform them if you like.
  • Don't transform everything in outdata$coefficients and then print it. Most of the other information will end up nonsensical.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜