Polynomial Fit in R Projectile Data Fit from

  • Slides: 11
Download presentation
Polynomial Fit in R

Polynomial Fit in R

Projectile Data & Fit from Excel Time (s) 0 0. 0244 0. 0489 0.

Projectile Data & Fit from Excel Time (s) 0 0. 0244 0. 0489 0. 0734 0. 0979 0. 1226 0. 1472 0. 1719 0. 1966 0. 2214 0. 2462 0. 271 0. 2959 0. 3208 0. 3457 0. 3707 0. 3957 0. 4207 0. 4459 Height (m) 0 0. 0667 0. 1207 0. 168 0. 2088 0. 2365 0. 2624 0. 282 0. 2955 0. 3029 0. 3044 0. 2977 0. 2874 0. 27 0. 2451 0. 2198 0. 1857 0. 1413 0. 0875

Data in R #copy and paste times = c(0, 0. 0244, 0. 0489, 0.

Data in R #copy and paste times = c(0, 0. 0244, 0. 0489, 0. 0734, 0. 0979, 0. 1226, 0. 1472, 0. 1719, 0. 1966, 0. 2214, 0. 2462, 0. 271, 0. 2959, 0. 3208, 0. 3457, 0. 3707, 0. 3957, 0. 4207, 0. 4459) heights = c(0, 0. 0667, 0. 1207, 0. 168, 0. 2088, 0. 2365, 0. 2624, 0. 282, 0. 2955, 0. 3029, 0. 3044, 0. 2977, 0. 2874, 0. 27, 0. 2451, 0. 2198, 0. 1857, 0. 1413, 0. 0875) proj = data. frame(times, heights)

Plot Data in R

Plot Data in R

Note that the “x^2” term is inside I() Compare the coefficients to the fit

Note that the “x^2” term is inside I() Compare the coefficients to the fit equation from Excel

Isolating the coefficients Recall we are fitting to the form y(t) = y 0

Isolating the coefficients Recall we are fitting to the form y(t) = y 0 + v 0 t + a t 2 /2 So for us a (the acceleration) is twice the value from the fit

Displaying the equation

Displaying the equation

Displaying the curve

Displaying the curve

Another approach

Another approach

Raw=TRUE • Without the raw=TRUE option in poly, the R program will not use

Raw=TRUE • Without the raw=TRUE option in poly, the R program will not use simple linear and quadratic powers of the variable, but will introduce “orthogonal” combinations of the variables. • This makes for better statistics – to have “independent” variables, but it makes the results harder to read and interpret.

Isolating the coefficients in version 2

Isolating the coefficients in version 2