質問

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!

役に立ちましたか?

解決

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)))
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top