# Saving LinearModel without data

**URL:** <https://discourse.julialang.org/t/saving-linearmodel-without-data/28889>\
**Category:** General Usage\
**Tags:** regression\
**Created:** [September 18, 2019, 12:08pm UTC](https://discourse.julialang.org/t/saving-linearmodel-without-data/28889 "2019-09-18T12:08:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 18, 2019, 12:08pm UTC](https://discourse.julialang.org/t/saving-linearmodel-without-data/28889/1 "2019-09-18T12:08:34Z")

</div>

My question:

How can I save the results of a regression (say a `LinearModel` from GLM.jl) without the data that are stored inside the object?

Context:

I run several regressions using GLM.jl. At some point after all the results are in, some of the regressions are combined into tables (perhaps using RegressionTables.jl). Until I know exactly how I want to display the results, I want to store the each regression in a file.

Options:

1. Delete the data inside the `LinearModel` object.  
Drawback: this would depend on the undocumented internal structure of the object, which could change at any time.
2. Save only the information that I want to display in a custom object.  
Drawback: RegressionTables.jl (and probably other packages) expect a `LinearModel` as input. So I would not be able to use those.

Are there better options?

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [April 24, 2022, 1:27pm UTC](https://discourse.julialang.org/t/saving-linearmodel-without-data/28889/2 "2022-04-24T13:27:20Z")

</div>

Also searching this. Do you have a solution now?

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 24, 2022, 3:19pm UTC](https://discourse.julialang.org/t/saving-linearmodel-without-data/28889/3 "2022-04-24T15:19:15Z")

</div>

> [@hendri54](#):
>
> Options:
> 
> 1. Delete the data inside the `LinearModel` object.  
> Drawback: this would depend on the undocumented internal structure of the object, which could change at any time.
> 2. Save only the information that I want to display in a custom object.  
> Drawback: RegressionTables.jl (and probably other packages) expect a `LinearModel` as input. So I would not be able to use those.

I would think OP decided between his two options, 1. being quick & dirty and 2. being able to adapt to changing internal representations over different versions of the package?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [May 4, 2022, 2:53pm UTC](https://discourse.julialang.org/t/saving-linearmodel-without-data/28889/4 "2022-05-04T14:53:52Z")

</div>

I went with option 2, but have not checked recently whether there is now an “official” solution.
