statistics – How do I find the parameters for a best-fit-model of a sine-function in R studio?

My professor is asking me to use fitModel and coef to find the best model for a data set. I’m trying to find the correct A, P, h and v value and then plot the line-of-best-fit over my conjectured model.

This is the code that I am trying in rStudio:

 plotPoints(People~Year,data=HispanicPopulation)
 plotFun(25*sin((2*pi/80)*(People-1990))+30~People, col="blue", add=TRUE)

and the picture is the result that I got out of it.
i.stack.imgur.com/OWMIo.png

This is the code that I am using to try to get the values of A,P,h, and v for the line-of-best-fit.
bestSinusoidalModel=fitModel(Year~25sin((2pi/80)*(People-1990))+30,data=HispanicPopulation,start = list(A=25,P=80,h=1990,v=30)(coefbestSinusoidalModel)

Read more here: Source link