Open federicovegetti opened 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?
@federicovegetti , what do you think of maybe piggybacking on a function that Lewis and Linzer (2005) already wrote for this? see here
These are possible features that can be implemented in the level-2 function
l2_reg()
[ ] Write
l2_reg()
in a way that it accepts both(A) the full data, including level-1 and level-2 predictors.
(B) the coefficients resulting from
l1_reg()
. To do so, it should behave differently based on the input. We can save the output ofl1_reg()
with a specific object class, so it will recognize it right away.[ ] How to handle the level-2 predictors?
In version (A),
l2_reg()
should take a usual dataset with level-1 and level-2 predictors, as you would feed intolmer()
.How about version (B)? Should it ask for a data.frame containing the level-2 predictors and the key variable(s) to merge only if the input is an output from
l1_reg()
?[ ] Possibility to use the pipe
%>%
to concatenatel2_reg()
right afterl1_reg()
. Is that useful?