ramasamy at cancer.org.uk
Thu Jul 15 18:06:07 CEST 2004
If you want to fit "y = a + bx", then you use "lm(y ~ x)" instead of "lm(y ~ A + bx)".
'A' is not a parameter but coefficient and you do not need to specify coefficients,
which is what the linear model is trying to do anyway !
See the details section of help("formula").
> x <- 1:5
> y <- c(0, 1.0, 1.7, 2.0, 2.1)
> lm(x ~ y)
lm(formula = x ~ y)
If A was already defined, and you are trying to multiply the y-values, then use the I() operator.
This protects the term/calculation and inhibits the usual term interpretation in linear models.
> lm(x ~ I(2*y) )
lm(formula = x ~ I(2 * y))
(Intercept) I(2 * y)
PS : I think there is a typo in the y input as there is no such number as 2.1.4
On Thu, 2004-07-15 at 16:28, solares at unsl.edu.ar wrote:
> Hi, i 'dont understand how to take a general formula, view this:
> Error in eval(expr, envir, enclos) : Object "A" not found
> but A is the parameter of fitting, why is this?Thanks Ruben
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help