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 8517745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:47:28+00:00 2026-06-11T05:47:28+00:00

I have a (k x n) matrix. I have initially managed to linearly regress

  • 0

I have a (k x n) matrix. I have initially managed to linearly regress (using the lm function) column 1 with each and every other column and extracted only the coefficients.

fore.choose <- matrix(0, 1, NCOL(assets))
for(i in seq(1, NCOL(assets), 1))
{

  abc <- lm(assets[,1]~assets[,i])$coefficients
  fore.choose[1,i] <- abc[2:length(abc)]

}

The coefficients are placed in the fore.choose matrix.

What I now need to do is to linearly regress column 2 with each and every other column, and then column 3 and so on and so forth and extract only the coefficients.

The output will be a square matrix of OLS univariate coefficients. Kind of similar to a correlation matrix, but it is the beta coefficients I am interested in.

fore.choose <- matrix(0, 1, NCOL(assets))

will initially need to become

fore.choose <- matrix(0, NCOL(assets), NCOL(assets))
  • 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-11T05:47:29+00:00Added an answer on June 11, 2026 at 5:47 am

    I’d just compute the coefficients directly from the correlation matrix, using beta = cor(x,y)*sd(x)/sd(y), like this:

    # set up some sample data
    set.seed(1)
    d <- matrix(rnorm(50), ncol=5)
    
    # get the coefficients
    s <- apply(d, 2, sd)
    cor(d)*outer(s, s, "/")
    

    You could also use lsfit to get the coefficients of one term on all the others at once and then only have one loop to do:

    sapply(1:ncol(d), function(i) {
      coef(lsfit(d[,i], d))[2,]
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a matrix in SAS IML. For each pair of rows (say vectors
i have an application which has 3X4 matrix of images using arrow key(up,right,top,bottom) i
I have a javascript Matrix class for affine transforms, and a function to set
I have a N x K matrix in R, where each row is a
In Matlab 2011b, I have a multidimensional matrix which is to be initially presented
I have 12 matrices of 360 by 1000. For each matrix, I'm trying to
I have matrix (a) with (1:10),<10 x 1> double. I would like to copy
Have a matrix report now that has Position, Hours and Wages for a location
I have a matrix of data (the columns represent time, and the rows spectrum
I have the matrix m <- matrix(c(1, 0, 3, 4, 0, 6), 3) I

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.