R: Summarize inside an nlsLM() statement
I'm using nlsLM() to make a model of a power function, but I need to summarize my data within the function call to find the appropriate coefficient and exponent. More specifically, here is what my model code looks like: Jmod = nlsLM(value~(a)*summarise(funs(mean), (MW)^b), start = list(a=100000, b = 1/3), data = mod_data, upper = c(Inf,1), lower = c(0,1/5)) where MW is the data I am trying to use to predict value . The data for MW is already grouped by month based off a variable called datetime , so I would like to take the monthly average of MW^b where b is found by the nlsLM() statement. I