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 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

I use JavaScript for rendering 20 tables of 100 rows each. The data for
I have 100 years of monthly data where each month is a file and
I have the list with like 100,000 site link strings Each link is unique,
I have 100 sets of A objects, each set corresponding to a query point
My data is as follows: grp = rep(1:2, each = 100) chr = c(rep(1:10,
Lets say I have 100 servers each running a daemon - lets call it
i have a list 1 column and 100 rows each with a number the
Let's say that we have 100 objects of type User and each user has
I have an ASP.NET application where i have more than 100 pages.In each pages
I have a list view with over 100 items. Each of these items show

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.