# 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?
I have tried out this code:
set.seed(12)
fx <- lm(log(St)~t+I(t^2))
fx
fy <- lm(log(Nt)~t+I(t^2))
fy
t <- 1:50
fx <- 0.32369+0.33647t-0.00531t^2

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. https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/optim

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

Are you working on a homework problem?

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