Created
May 6, 2021 15:48
-
-
Save mw55309/7bf8f159efadfedbdf81ae7202d2fe7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d <- data.frame(frac=seq(0.1,1.0,by=0.1), total=c(116,175,215,246,271,291,308,323,336,348)) | |
plot(d$frac, d$total, pch=16, xlim=c(0,3), ylim=c(0,400)) | |
fit <- lm(formula = total ~ I(1/frac), data=d) | |
nd <- data.frame(frac=seq(0.1,3.0,by=0.1)) | |
nd$pred <- predict(fit, newdata=nd) | |
lines(nd$frac,nd$pred) |
Much better but still a wee bit off
d <- data.frame(frac=seq(0.1,1.0,by=0.1), total=c(116,175,215,246,271,291,308,323,336,348))
plot(d$frac, d$total, pch=16, xlim=c(0,3), ylim=c(0,400))
fit <- lm(formula = total ~ I(log(frac)), data=d)
nd <- data.frame(frac=seq(0.1,3.0,by=0.1))
nd$pred <- predict(fit, newdata=nd)
lines(nd$frac,nd$pred)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually
lm(formula = total ~ I(1/(frac+0.5)), data=d)
is a far better fit, so how do I get R to learn the 0.5 bit?