GLM Model Summary

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

GLM Model Summary

Neslin, Scott A.
R-Help:

We are working with your GLM R package.  The Summary(Model) now gets printed by the program as one object and we want to put the coefficient columns into Excel.  We took an initial stab at this by counting the number of characters occupied by each column.  But we have now learned that the number of characters in a column depends on the length of the variable names, so is not a constant number (e.g., 54 characters to a line).

We therefore ask, is it possible for us to get the Summary(Model) column by column, i.e., a separate object for each column?  That way we could assemble an Excel table easily rather than having to count the number of characters.

Is this possible for us to do by ourselves?  Or could you modify the package in some way?

We appreciate your attention.  Thank you!

Scott Neslin
Prasad Vana

Dartmouth College

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: GLM Model Summary

Duncan Murdoch-2
On 16/10/2018 12:33 PM, Neslin, Scott A. wrote:
> R-Help:
>
> We are working with your GLM R package.  The Summary(Model) now gets printed by the program as one object and we want to put the coefficient columns into Excel.  We took an initial stab at this by counting the number of characters occupied by each column.  But we have now learned that the number of characters in a column depends on the length of the variable names, so is not a constant number (e.g., 54 characters to a line).

There is no GLM R package as far as I know.  There's a glm() function in
the stats package.  Is that what you meant?

What would probably be best is if you showed us a simple example of what
you are doing, and then referred to the results from that when saying
what you want to extract.

Duncan Murdoch

>
> We therefore ask, is it possible for us to get the Summary(Model) column by column, i.e., a separate object for each column?  That way we could assemble an Excel table easily rather than having to count the number of characters.
>
> Is this possible for us to do by ourselves?  Or could you modify the package in some way?
>
> We appreciate your attention.  Thank you!
>
> Scott Neslin
> Prasad Vana
>
> Dartmouth College
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: GLM Model Summary

plangfelder
In reply to this post by Neslin, Scott A.
The coefficients are best obtained as summary(Model)$coefficients.
This is a matrix can than be saved as a csv file and opened in excel
or other spreadsheet software.

HTH,

Peter
On Tue, Oct 16, 2018 at 9:44 AM Neslin, Scott A.
<[hidden email]> wrote:

>
> R-Help:
>
> We are working with your GLM R package.  The Summary(Model) now gets printed by the program as one object and we want to put the coefficient columns into Excel.  We took an initial stab at this by counting the number of characters occupied by each column.  But we have now learned that the number of characters in a column depends on the length of the variable names, so is not a constant number (e.g., 54 characters to a line).
>
> We therefore ask, is it possible for us to get the Summary(Model) column by column, i.e., a separate object for each column?  That way we could assemble an Excel table easily rather than having to count the number of characters.
>
> Is this possible for us to do by ourselves?  Or could you modify the package in some way?
>
> We appreciate your attention.  Thank you!
>
> Scott Neslin
> Prasad Vana
>
> Dartmouth College
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: GLM Model Summary

prof.amit.mittal
In reply to this post by Duncan Murdoch-2
You can just use

'slotNames(modelname)
This will return sub objects for which names can be extracted

Eg

slotNames(modelname)
[1] "mfit" "model"
names(modelname@mfit)
names(modelname@model)
Will return all objects within the model including coed car R cover vcov as
applicable and you can store per choice

However within the column they will still be text

BR

On Tue 16 Oct, 2018, 10:23 PM Duncan Murdoch, <[hidden email]>
wrote:

> On 16/10/2018 12:33 PM, Neslin, Scott A. wrote:
> > R-Help:
> >
> > We are working with your GLM R package.  The Summary(Model) now gets
> printed by the program as one object and we want to put the coefficient
> columns into Excel.  We took an initial stab at this by counting the number
> of characters occupied by each column.  But we have now learned that the
> number of characters in a column depends on the length of the variable
> names, so is not a constant number (e.g., 54 characters to a line).
>
> There is no GLM R package as far as I know.  There's a glm() function in
> the stats package.  Is that what you meant?
>
> What would probably be best is if you showed us a simple example of what
> you are doing, and then referred to the results from that when saying
> what you want to extract.
>
> Duncan Murdoch
>
> >
> > We therefore ask, is it possible for us to get the Summary(Model) column
> by column, i.e., a separate object for each column?  That way we could
> assemble an Excel table easily rather than having to count the number of
> characters.
> >
> > Is this possible for us to do by ourselves?  Or could you modify the
> package in some way?
> >
> > We appreciate your attention.  Thank you!
> >
> > Scott Neslin
> > Prasad Vana
> >
> > Dartmouth College
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--

______________________________

Amit Mittal
Pursuing Ph.D. in Finance and Accounting
Indian Institute of Management, Lucknow
Visit my SSRN author page:
http://ssrn.com/author=2665511
* Top 10% Downloaded Author on SSRN
Mob: +91 7525023664

This message has been sent from a mobile device. I may contact you again.

_________________

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: GLM Model Summary

R help mailing list-2
In reply to this post by Neslin, Scott A.


> On Oct 16, 2018, at 12:33 PM, Neslin, Scott A. <[hidden email]> wrote:
>
> R-Help:
>
> We are working with your GLM R package.  The Summary(Model) now gets printed by the program as one object and we want to put the coefficient columns into Excel.  We took an initial stab at this by counting the number of characters occupied by each column.  But we have now learned that the number of characters in a column depends on the length of the variable names, so is not a constant number (e.g., 54 characters to a line).
>
> We therefore ask, is it possible for us to get the Summary(Model) column by column, i.e., a separate object for each column?  That way we could assemble an Excel table easily rather than having to count the number of characters.
>
> Is this possible for us to do by ourselves?  Or could you modify the package in some way?
>
> We appreciate your attention.  Thank you!
>
> Scott Neslin
> Prasad Vana
>
> Dartmouth College


Hi,

Presuming that you are talking about the glm() function, as there is no GLM package as far as I can see, R model objects have a structure that can be viewed using the str() function. The help for this function can be viewed using:

   ?str

You can then use:

  str(summary(YourModelObject))

That will give you some insights into the model object components and that same str() function is valuable for investigating other objects as well.

That being said, R's model objects typically have 'extractor' functions to make it easy to obtain commonly used components of the model object, which can be complicated.

The R manual "An Introduction to R", has a section on some of these:

    https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Generic-functions-for-extracting-model-information <https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Generic-functions-for-extracting-model-information>

Thus, for example, using:

  coef(summary(YourModelObject))

will return the matrix of coefficients and related parameters from the summary model object.

Once you have that matrix object, you can write it out to a CSV file using ?write.csv, where the CSV file can then be opened with or imported into Excel.

So the steps might be along the lines of:

  my.coef <- coef(summary(YourModelObject))

  write.csv(my.coef, file = "MyCoefficients.csv")


The R Data Import/Export manual:

  https://cran.r-project.org/doc/manuals/r-release/R-data.html <https://cran.r-project.org/doc/manuals/r-release/R-data.html>

has some insights into pathways for getting data to and from R, including some packages that can directly write Excel files. You may wish to review that manual as well.

Regards,

Marc Schwartz



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.