0

I have made a polynomial model from 2 vectors:

tint <- c(12, 18.8, 25.5, 21.6)
text <- c(11.4, 17.1, 22.1, 14.0)
dT <- tint - text

func.dT2 <- lm(dT[1:3] ~ poly(text[1:3],2,raw=TRUE) )

now, i'd like to use that model to predict dT from other variavbels, whose number is much larger than 3:

predict(func.dT2, text=seq(min(text)-1, max(text)+1, 0.01))

but I only get the first three values.

how can I use func.dT2 to calculate dT from all the values in seq(min(text)-1, max(text)+1, 0.01) ?

thanks!

Alex Caseiro
  • 403
  • 1
  • 4
  • 9
  • Hope you're aware that fitting to a mere three points is risky, and that extrapolating from same is even more risky? – Carl Witthoft Feb 14 '14 at 12:45
  • thanks Carl for the comment. I am very well aware indeed, but that's all the data I have and for this particular case it will be reasonable. Nice advice though, remembeing the basics is very important;) – Alex Caseiro Feb 17 '14 at 09:41

1 Answers1

2

Put your data in data.frames:

func.dT2 <- lm(dT ~ poly(text,2,raw=TRUE), 
               data=data.frame(dT, text)[1:3,])

predict(func.dT2, 
        newdata=data.frame(text=seq(min(text)-1, max(text)+1, 0.01)))
Roland
  • 127,288
  • 10
  • 191
  • 288