开发者

log transform in linear model and exporting output to office

开发者 https://www.devze.com 2023-03-26 20:59 出处:网络
I have the following code for doing a linear regression: data<-read.csv(\"File.csv\",header=T) trans<-log(data)

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

精彩评论

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