1

I am estimating a large number of models (-type, but possibly others) in . I do this ion a secure server, from which data export is restricted. I am allowed to export the results from models (coefficients, statistics) but not the individual-level data.

I could prepare an object that only includes relevant statistics from the objects and export this. However, it would be very useful if I could export the model objects themselves without the data but at the same time retaining functionality to predict new data, tidy results with broom etc.

I have tried to run, given m being an lm-type object: m$model <- NULL but this does not let me use e.g. broom::confint_tidy afterwards.

Is there way possible to make my objects data-free and at the same time preserve functionality?

I use version 3.6, packages. Thank you.

massisenergy
  • 1,764
  • 3
  • 14
  • 25
torkildl
  • 168
  • 8
  • When I do a str() on an `lm`-object, I find the individual-level data for the model variables under $model, so I think I need to remove that part of the object to export it. – torkildl Apr 02 '20 at 08:51
  • 1
    Your proposed approach is a security nightmare. For example, with an `nls` object you can find data in `nlsfit$m$getEnv()`, but there are also bits and pieces elsewhere that allow reconstructing (parts of) the data. It is extremely difficult to find for different model objects where data might be stored and methods often don't work if you remove it. You'll have to do your work the hard (manual) way. Forget broom. – Roland Apr 02 '20 at 08:58
  • 1
    Note that you can exclude the "model" part from the outset using lm's argument `model=FALSE`, and `confint(m)` will still work. Of course, residuals and fitted values are part of an "lm" object, so the observed response can be reconstructed. If data privacy is an issue, make sure to only export the summary statistics you need. – bastistician Apr 02 '20 at 14:08

0 Answers0