federicovegetti / 2stageML

Functions for 2 step multilevel regressions
0 stars 0 forks source link

l2_reg() miscellaneous #3

Open federicovegetti opened 3 years ago

federicovegetti commented 3 years ago

These are possible features that can be implemented in the level-2 function l2_reg()

cmbosancianu commented 3 years ago

It's a weak preference, but I thought the easiest way in the beginning is to actually never bring in l1_reg() to the surface. Rather, it becomes a background "helper" function for l2_reg() and plot_l1().

So a user would specify in l2_reg() a data frame, a l1_model, a l2_model, and a l1_outcome (kind of like focal_var does in l1_reg()). And then l2_reg() would pass the l1_model to l1_reg() in the background, and take back from l1_reg() the data frame with coefficients and SEs (for the l1_outcome), and group-level indicator.

Then, based on the l2_model specification, it would subset only country-level aggregates, merge with the data frame of coefficients and SEs and, run the estimation.

Maybe because it allows things to proceed quickly, I would suggest that l2_reg() takes B (the coefficients), and that it accepts as input a data frame with both level-1 and level-2 predictors, like lmer().

How does that sound for you?

cmbosancianu commented 3 years ago

@federicovegetti , what do you think of maybe piggybacking on a function that Lewis and Linzer (2005) already wrote for this? see here