Minimzing a function by lm in R

I want to minimize this function by using lm function in R, but Im not sure it is the right way to do it, can someone help me out? :slight_smile:
I have tried out this code:
fx <- lm(log(St)~t+I(t^2))
fy <- lm(log(Nt)~t+I(t^2))
t <- 1:50
fx <- 0.32369+0.33647t-0.00531t^2

Skjermbilde 2020-05-05 kl. 21.26.21

I'm not sure lm is the best option since lm is for linear models of the form \sum_i \beta_i x_i. Look into the optim function.

Are you working on a homework problem?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Thanks for reply @StatSteph! I have only learnd about lm function in the R course at school, so I'm not sure how to use the optim function to solve the problem :confused: