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 basee
by default, so you really don't want to exponentiate the coefficients using base 10 after transforming the data using basee
. - The coefficients are accessible via
coef()
or the less recommendedoutdata$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.
精彩评论