Re: Logarithmische Regression
Verfasst: Fr Mär 29, 2019 2:07 pm
Code: Alles auswählen
Konz_x <- c(47143480, 4714348, 4714, 2357, 1179, 471)
CT_Wert_y <- c(18.68, 22.595, 33.004, 34.290, 35.369, 35.271)
fm <- lm(CT_Wert_y ~ log(Konz_x))
summary (fm)
fm
plot(Konz_x, CT_Wert_y, xlim = c(300, 50000000), ylim = c(0, 40), log="x", xlab = "Copies/ml patient sample",
ylab = "Ct-Values", main ="Linear regression CAP Kit", pch = 19)
# abline(fm, col = "red",lwd=2, untf = FALSE)
b <- coef(fm); b0 <- b[1]; b1 <- b[2]
mycurve <- function(x) b0 + b1*log(x)
curve(mycurve, 300, 50000000, add=TRUE, col="green")
Code: Alles auswählen
b <- coef(fm); b0 <- b[1]; b1 <- b[2]
curve(b0 + b1*log(x), 300, 50000000, add=TRUE, col="blue")
# oder
curve(cbind(1, log(x)) %*% coef(fm), 300, 50000000, add=TRUE, col="yellow")
# oder
curve(tcrossprod(coef(fm), cbind(1, log(x))), 300, 50000000, add=TRUE, col="brown")
Code: Alles auswählen
lines(Konz_x, fitted(fm), col="orange")
Das Problem, dass man sich gelegentlich verzappelt, wenn man eine Regression auf transformierten Daten rechnet, ist unabhängig von der verwendeten Software.Sorry aber ich bin irgendwie noch nicht richtig warm geworden mit R. :(
Gruß, Jörg