Logarithmic logarithm curve in R

If I have a set of points in R that are linear, I can do the following to build the points, put a line in them, then display the line:

x=c(61,610,1037,2074,3050,4087,5002,6100,7015)
y=c(0.401244, 0.844381, 1.18922, 1.93864, 2.76673, 3.52449, 4.21855, 5.04368, 5.80071)

plot(x,y)    
Estimate = lm(y ~ x)    
abline(Estimate)

Now, if I have a set of points that look like a logarithmic fit of a curve, more suitable, for example, the following:

x=c(61,610,1037,2074,3050,4087,5002,6100,7015)        
y=c(0.974206,1.16716,1.19879,1.28192,1.30739,1.32019,1.35494,1.36941,1.37505)

I know that I can get standard regression according to the log of x values ​​with the following:

logEstimate = lm(y ~ log(x))

But how do I convert this logEstimate back to normal scaling and plot my linear curve earlier?

+5
source share
2 answers

Hmmm, I'm not quite sure what you mean by "curve graphics against my linear curve before."

d <- data.frame(x,y)  ## need to use data in a data.frame for predict()
logEstimate <- lm(y~log(x),data=d)

:

(1) predict:

plot(x,y)
xvec <- seq(0,7000,length=101)
logpred <- predict(logEstimate,newdata=data.frame(x=xvec))
lines(xvec,logpred)

(2) :

coef(logEstimate)
## (Intercept)      log(x) 
##  0.6183839   0.0856404 
curve(0.61838+0.08564*log(x),add=TRUE,col=2)

(3) with() ( , )

with(as.list(coef(logEstimate)),
      curve(`(Intercept)`+`log(x)`*log(x),add=TRUE,col=4))

,

est1 <- predict(lm(y~x,data=d),newdata=data.frame(x=xvec))
plot(est1,logpred)

... , ...

+10

, ... . , , . . :

x=c(61,610,1037,2074,3050,4087,5002,6100,7015)
y=c(0.974206,1.16716,1.19879,1.28192,1.30739,1.32019,1.35494,1.36941,1.37505)

Estimate = lm(y ~ x)
logEstimate = lm(y ~ log(x))

plot(x,predict(Estimate),type='l',col='blue')
lines(x,predict(logEstimate),col='red')
points(x,y)

enter image description here


, , . , log: ,

y = log(x)

,

exp(y) = x

, x , y , "". , x , .

+9

All Articles