Skip to contents

A wrapper for lm() for use in nadir::super_learner().

Usage

lnr_lm(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).

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

See also

learners

Examples

lnr_lm(mtcars, mpg ~ hp + disp + am + wt)(mtcars)
#>           Mazda RX4       Mazda RX4 Wag          Datsun 710      Hornet 4 Drive 
#>           24.458980           23.682060           25.912053           20.730852 
#>   Hornet Sportabout             Valiant          Duster 360           Merc 240D 
#>           17.743239           20.098866           14.594537           22.417470 
#>            Merc 230            Merc 280           Merc 280C          Merc 450SE 
#>           21.226986           19.309094           19.309094           15.417569 
#>          Merc 450SL         Merc 450SLC  Cadillac Fleetwood Lincoln Continental 
#>           16.453463           16.301125           11.327738           10.374500 
#>   Chrysler Imperial            Fiat 128         Honda Civic      Toyota Corolla 
#>            9.975558           27.266451           29.591855           28.398918 
#>       Toyota Corona    Dodge Challenger         AMC Javelin          Camaro Z28 
#>           23.183832           18.378027           18.602149           13.747022 
#>    Pontiac Firebird           Fiat X1-9       Porsche 914-2        Lotus Europa 
#>           16.608881           28.074586           26.569732           27.552200 
#>      Ford Pantera L        Ferrari Dino       Maserati Bora          Volvo 142E 
#>           17.202961           21.408619           13.067847           23.913739