[R] Problem with LM

rsherry8 r@herry8 @ending from comc@@t@net
Wed Dec 19 00:31:43 CET 2018


The values read into z2 came from a CSV file. Please consider this R 
session:

 > length(x2)
[1] 1632
 > length(x)
[1] 1632
 > length(z2)
[1] 1632
 > head(z2)
[1] 28914.0 28960.5 28994.5 29083.0 29083.0 29083.0
 > tail(z2)
[1] 32729.65 32751.85 32386.05 32379.75 32379.15 31977.15
 > lm ( y ~ x2 + x, z2 )
Error in eval(predvars, data, env) :
   numeric 'envir' arg not of length one
 > lm ( y ~ x2 + x, as.data.frme(z2) )
Error in as.data.frme(z2) : could not find function "as.data.frme"
 > lm ( y ~ x2 + x, as.data.frame(z2) )
Error in eval(predvars, data, env) :
   numeric 'envir' arg not of length one
lm(formula = y ~ x2 + x, data = as.data.frame(z2))

Coefficients:
(Intercept)           x2            x
  -1.475e-09    1.000e+00    6.044e-13

 > min(z2)
[1] 24420
 > max(z2)
[1] 35524.85
 > class(z2)
[1] "numeric"
 >

where x is set to x = seq(1:1632)
and x2 is set to x^2

I am looking for an interpolating polynomial of the form:
     Ax^2 + Bx + C
I do not think the results I got make sense. I believe that I have a 
data type error.  I do not understand why
I need to convert z2 to a data frame if it is already numeric.

Thanks,
Bob



More information about the R-help mailing list