Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
7 views
in R Programming by (330 points)

I am working with this data set: 

u <- c(31,63,95,117,127,143,151.5,157)  

v <- c(98.5,103.8,107.5,101,85,63,34.3,14)

I want to fit a model to these data so that u = f(v). I want it to be a 3rd order polynomial model.

How can I do that in R?

Additionally, can R help me to find the best fitting model?

1 Answer

+2 votes
by (10.9k points)
edited by

To get a third order polynomial in x -

model<- lm(v~ poly(u,3))

Or

model<- lm(v~ u+ I(u^2) + I(u^3))

poly(u,3) is preferable.

Hope this answer helps.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...