If you're after nonlinear regression, you should use the nls(...) procedure. The lm(...) procedure is for linear regression only.

It was hard to tell what the structure of you data set looks like, but in the nls call, make sure it includes 'data = nameofdataframe). Also you'll need a function like 'crimes~treatment + runningvariable + ...' and a 'start; list for the parameters you're trying to estimate.

All this said it looks like your model is actually a linear regression problem that is in the form

y ~ b0 + b1*x + b2*x^2 + b3*x^3

where you have inputs of x, x^2, and x^3 in your data frame. From the error message, it's possible your data subset excludes 'crime'. A more complete listing of the function and outputs, including the first few lines of the dataset would clarify these issues.

FYI, this might not be the right forum for this issue. This is a forum for POSIT/Quarto/RMarkdown and is mainly about publishing hybrid documents that include r code, text, tables, figures in either html or pdf format. I'd suggest [r-help@r-project.org] for r programming questions.