Edit – Rewrote question since the original did not makes sense:
In R – how would I go about getting a lm fit model that is a quotient of sums for two variables grouped by a third factor variable, but that weights some entries more than others? Data looks like:
Browser Visits Clicks
Chrome 100 25
Chrome 89 40
Chrome 10 0
Safari 40 10
Safari 30 2
From the comments this is the command for the WLS regression weighted by visits, but I don’t think I’m using the weight function right since I don’t know how the errors are correlated with visits, just that they are.
fit <- lm(Clicks/Visits ~ Browser, weights=(visits/sum(visits)))
You are asking for a rate model, i.e. events per number at risk. This is usually implemented by modeling the process as a Poisson distributed set of events: