Skip to contents

A wrapper for lme4::lmer for use in nadir::super_learner().

Usage

lnr_lmer(data, formula, weights = NULL, ...)

Arguments

data

A dataframe to train a learner / learners on.

formula

A regression formula to use inside this learner.

weights

Observation weights; see ?lm

...

Any extra arguments that should be passed to the internal model for model fitting purposes.

Value

A prediction function that accepts newdata, which returns predictions (a numeric vector of values, one for each row of newdata).

See also

learners

Examples

# random intercepts for each level of cyl column:
lnr_lmer(mtcars, mpg ~ (1 | cyl) + disp + am + wt)(mtcars)
#>           Mazda RX4       Mazda RX4 Wag          Datsun 710      Hornet 4 Drive 
#>            21.65855            20.86347            26.33460            19.04361 
#>   Hornet Sportabout             Valiant          Duster 360           Merc 240D 
#>            16.90665            18.48289            16.50132            23.22732 
#>            Merc 230            Merc 280           Merc 280C          Merc 450SE 
#>            23.38836            18.89864            18.89864            15.46074 
#>          Merc 450SL         Merc 450SLC  Cadillac Fleetwood Lincoln Continental 
#>            16.52085            16.36495            10.57359            10.10495 
#>   Chrysler Imperial            Fiat 128         Honda Civic      Toyota Corolla 
#>            10.47440            26.88915            28.73162            28.07399 
#>       Toyota Corona    Dodge Challenger         AMC Javelin          Camaro Z28 
#>            25.65161            16.91580            17.26702            15.72104 
#>    Pontiac Firebird           Fiat X1-9       Porsche 914-2        Lotus Europa 
#>            15.39761            27.71356            26.82010            28.93021 
#>      Ford Pantera L        Ferrari Dino       Maserati Bora          Volvo 142E 
#>            17.96030            21.28321            17.02096            24.82030