Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:18:29+00:00 2026-06-02T06:18:29+00:00

I like to extract the coefficients and standard errors of each lm object and

  • 0

I like to extract the coefficients and standard errors of each lm object and combine them into a data.frame with NA fill in for the missing predictors.

    set.seed(12345)
    x<-matrix(rnorm(1000),nrow=100,ncol=10)
    colnames(x)<-paste("x",1:10,sep="")
    df<-data.frame(y=rnorm(100),x)
    m1<-vector('list', 10)
    for ( i in 2:11){
    eqn <- as.formula(paste("y ~", paste(colnames(df)[2:i], collapse='+')))
    m1[[i-1]] <- lm(eqn, df)
    }

Any suggestions would be much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:18:30+00:00Added an answer on June 2, 2026 at 6:18 am

    This should do the trick:

    cList <- lapply(m1, coef)
    nms  <- names(cList[[11]])
    
    cMat <- do.call(rbind, lapply(cList, function(X) X[nms]))
    cDF  <- as.data.frame(cMat); names(cDF) <- nms   # Pretty up the results
    
    cDF[1:5, 1:6]
    #   (Intercept)        x1          x2         x3         x4       x5
    # 1  -0.2345084 0.2027485          NA         NA         NA       NA
    # 2  -0.2334043 0.2074812 -0.05006297         NA         NA       NA
    # 3  -0.2299977 0.2099620 -0.03892985 0.09777829         NA       NA
    # 4  -0.2095798 0.2221179 -0.02710201 0.06403695 -0.1184191       NA
    # 5  -0.2060406 0.2180674 -0.01062671 0.06632922 -0.1045128 0.130937
    

    Edit:

    To collect the standard errors into a similar structure, just do something like this:

    seList <- lapply(m1, function(X)  coef(summary(X))[,2])
    seMat <- do.call(rbind, lapply(cList, function(X) X[nms]))
    seDF  <- as.data.frame(cMat); names(seDF) <- nms
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to extract the data groups from the PHP arrays depending on
I'd like to extract data from a .csv file. I cannot use OpenRowSet on
I would like to extract elements from a deeply embedded list into an array.
I would like to extract specific data form a known Url : from html
I'd like to extract the metadata of the iPod Library into a file. Currently,
I would like to extract the data and event name from a google calendar
I'd like to extract all the properties of a homogeneous JSON collection into it's
The manual on extract shows you can extract an array like: extract(array('one'=>1,'two'=>2)); into $one,$two...
I would like to extract some data from three tables in a SQL Server
I would like to extract the data from this website: http://webcharts.fxserver.com/pairs/activePairs.php?profile=CMSForexWebQuotes1-D I obtained the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.