Dear community,

The code below fits the following model: sales = b1 / ranks^b2.

Given that sales are observed on a weekly basis (w) and ranks on a daily basis (t), how can I modify my code to fit the following model: sales_w = Sum_(t belong to week w) [b1 / ranks_t^b2]

Thank you in advance for your help!

```
using DataFrames
using StatFiles #read stata file
using LsqFit #least-squares fitting
### load data
df = DataFrame(load("Data/AB.dta"))
rank = df.rank
sales = df.sales
week = df.week
### Model
# function to minimize
model(x, b) = b[1] ./ (x.^b[2])
# starting values
p0 = [10167, 0.45]
# fitting
fit = curve_fit(model, rank, sales, p0)
```