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

  • Home
  • SEARCH
  • 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 3933514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:36:34+00:00 2026-05-19T23:36:34+00:00

For each of 100 data sets, I am using lm() to generate 7 different

  • 0

For each of 100 data sets, I am using lm() to generate 7 different equations and would like to extract and compare the p-values and adjusted R-squared values.

Kindly assume that lm() is in fact the best regression technique possible for this scenario.

In searching the web I’ve found a number of useful examples for how to create a function that will extract this information and write it elsewhere, however, my code uses paste() to label each of the functions by the data source, and I can’t figure out how to include these unique pasted names in the function I create.

Here’s a mini-example:

temp <- data.frame(labels=rep(1:10),LogPre= rnorm(10))
temp$labels2<-temp$labels^2
testrun<-c("XX")

for (i in testrun)
{
  assign(paste(i,"test",sep=""),lm(temp$LogPre~temp$labels))
  assign(paste(i,"test2",sep=""),lm(temp$LogPre~temp$labels2))
}

I would then like to extract the coefficients of each equation

But the following doesn’t work:

summary(paste(i,"test",sep="")$coefficients)

and neither does this:

coef(summary(paste(i,"test",sep="")))

Both generating the error :$ operator is invalid for atomic vectors
EVEN THOUGH

summary(XXtest)$coefficients

and

coef(summary(XXtest))

work just fine.

How can I use paste() within summary() to allow me to do this for AAtest, AAtest2, ABtest, ABtest2, etc.

Thanks!

  • 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-05-19T23:36:34+00:00Added an answer on May 19, 2026 at 11:36 pm

    Hard to tell exactly what your purpose is, but some kind of apply loop may do what you want in a simpler way. Perhaps something like this?

    temp <- data.frame(labels=rep(1:10),LogPre= rnorm(10))
    temp$labels2<-temp$labels^2
    
    testrun<-c("XX")
    names(testrun) <- testrun
    
    out <- lapply(testrun, function(i) {
      list(test1=lm(temp$LogPre~temp$labels),
           test2=lm(temp$LogPre~temp$labels2))
    })
    

    Then to get all the p-values for the slopes you could do:

    > sapply(out, function(i) sapply(i, function(x) coef(summary(x))[2,4]))
                    XX
    test1 0.02392516
    test2 0.02389790
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you work 100 days on a project. How many days would each
Ok so say I have 100 rows to insert and each row has about
I have at least 100 xml files each about 300 MB with email messages
I have a dataset that looks like so: id entry_id the_data 1 100 Z
EDITED QUESTION: I have 2500 rows x 100 columns data in variable named avg_data_models.
We use SDB to store lots of data and currently I'm using the RightAWS
Each time a python file is imported that contains a large quantity of static
Each year at Thanksgiving, my family has drawn names out of a hat to
Each of my clients can have many todo items and every todo item has
Each page of my site has 10 (almost) identical divs, varying only in 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.