[R] Plot fit of a "generic" function

From: Gregor Gorjanc <gregor.gorjanc_at_gmail.com>
Date: Wed 19 Jul 2006 - 09:16:17 EST


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. ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jul 19 09:20:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 19 Jul 2006 - 12:18:18 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.