# Optimizing parameters for an oscillator – Video

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**Nicebread » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Here’s a video how the modFit function from the FME package optimizes parameters for an oscillation. A Nelder-Mead-optimizer (R function optim) finds the best fitting parameters for an undampened oscillator. Minimum was found after 72 iterations, true parameter eta was -.05:

Evolution of parameters in optimization process from Felix Schönbrodt on Vimeo.

More on estimating parameters of differential equations is coming later on this blog!

Things I’ve learned:

- ffmpeg does not like pngs. They are internally converted to jpg in a very low quality and I could not find a way to improve this quality. Lesson learned: Export high quality
**jpgs**from your R function - Use a standard frame rate for the output file (i.e., 24, 25, or 30 fps)
- My final ffmpeg command:
`ffmpeg -r 10 -i modFit%03d.jpg -r 25 -b:v 5000K modelFit.avi`

- -r 10: Use 10 pictures / second as input
- -i modFit%03d.jpg: defines the names of the input files, modFit001.jpg, modFit002.jpg, …
- -r 25: Set framerate of output file to 25 fps
- -b:v 5000K: set bitrate of video to a high value
- modelFit.mp4: video name and encoding type (mp4)

To

**leave a comment**for the author, please follow the link and comment on their blog:**Nicebread » R**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.