I have a large population of books. Each book is either a hardback or softback (thus hardback and softback books are paired with one another by title), and can fall into two categorical genres - Action or Thriller. For each book, the sales volume is measured annually (hence it is a repeated measures design). Importantly, some books have sales measurements over many years, whilst for some books it was only possible to measure sales for the first year or two years.
Data are structured as followed, just as an example. There are approximately 10,000 books in the sample (5,000 hardback, 5,000 softback).
Title Type Genre SalesYear1 SalesYear2 SalesYear3 AAA Hardback Action 100 150 180 AAA Softback Action 80 105 125 BBB Hardback Thriller 50 90 110 BBB Softback Thriller 20 45 80 CCC Hardback Action 120 200 -- CCC Softback Action 120 245 -- DDD Hardback Action 75 -- -- DDD Softback Action 95 -- -- ... ... ... ... ... ...
I want to conduct a regression analysis to determine whether hardback books have higher sales than softback books, taking into account other variables, i.e. genre of the book, as well as time.
For a single year, I could potentially do this with a linear regression model assuming sales were normally distributed, as follows (with R):
lm(formula = SalesYear1 ~ Type + Genre, data=data) summary(lm)
However, this does not take into account the paired nature of the books, and ignores the repeated measures approach. How might I do this? I have read that the lmer function of the lme4 package would be suitable. In that case I would reorder my data into a long format, with a single column for Sales, and a column for Time, and then do something like:
lmer(Sales ~ Time + Type + Genre + (Type| Title), data = data)
This would seem to account for the nesting of Title in Type, but I don't know if another random effect is required for Time. Does this syntax look right? I'm very confused - any pointers to resources would be much appreciated.