[R] Plot fit of a "generic" function
Gregor Gorjanc
gregor.gorjanc at gmail.com
Wed Jul 19 01:16:17 CEST 2006
Hello!
Say I have a function, which creates a design matrix i.e.
myFunc <- function(x)
{
ret <- cbind(x, x*x, x*x*x)
colnames(ret) <- 1:ncol(ret)
return(ret)
}
n <- 200
x <- runif(n=n, min=0, max=100)
y <- myFunc(x) %*% c(1, 0.2, -0.0002) + rnorm(n=n, sd=100)
then I can use this in formulae as here
(fit <- lm(y ~ myFunc(x)))
Now I would like to plot data and fitted function on the plot, but I do
not want to access each parameter estimate from object "fit" i.e. I
would like to use something similar to abline for linear regression but
in a generic way. Is there anything similar to my case?
plot(y=y, x=x)
???plotMyFunc???
Thanks!
--
Lep pozdrav / With regards,
Gregor Gorjanc
----------------------------------------------------------------------
University of Ljubljana PhD student
Biotechnical Faculty
Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si
SI-1230 Domzale tel: +386 (0)1 72 17 861
Slovenia, Europe fax: +386 (0)1 72 17 888
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
you have no certainty until you try." Sophocles ~ 450 B.C.
More information about the R-help
mailing list