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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:38:10+00:00 2026-06-11T04:38:10+00:00

I am not sure what I am doing wrong here. ee <- eigen(crossprod(X))$values for(i

  • 0

I am not sure what I am doing wrong here.

ee <- eigen(crossprod(X))$values
for(i in 1:length(ee)){
if(ee[i]==0:1e^-9) stop("singular Matrix")}

Using the eigen value approach, I am trying to determine if the matrix is singular or not. I am attempting to find out if one of the eigen values of the matrix is between 0 and 10^-9. How can I use the if statement (as above) correctly to achieve my goal? Is there any other way to approach this?

what if I want to concatenate the zero eigen value in vector

zer <-NULL
ee <- eigen(crossprod(X))$values 
for(i in 1:length(ee)){ 
if(abs(ee[i])<=1e-9)zer <- c(zer,ee[i])} 

Can I do that?

  • 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-11T04:38:12+00:00Added an answer on June 11, 2026 at 4:38 am

    @AriBFriedman is quite correct. I can, however see a couple of other issues

    • 1e^-9 should be 1e-9.
    • 0:1e-9 returns 0, (: creates a sequence by one between 0 and 1e-9, therefore returns just 0. See ?`:` for more details
    • Using == with decimals will cause problems due to floating point arithmetic

    In the form written, your code checks (individually) whether the elements ee[i] == 0, which is not what you want (nor does it make sense in terms floating point arithmetic)

    You are looking for cases where the eigen value is less than this small number, so use less than (<).

    What you are looking for is something like

    if(any(abs(ee) < 1e-9))  stop('singular matrix')
    

    If you want to get the 0 (or small) eigen vectors, then use which

    # this will give the indexs (which elements are small)
    small_values <- which(abs(ee) < 1e-9))
    # and those small values
    ee[small_values]
    

    There is no need for the for loop as everything being done is vectorized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure what I'm doing wrong here. The extension method is not recognized. using
I'm not sure what I'm doing wrong here, I have a file in lib/acts_as_votable.rb
Im not quite sure what I am doing wrong here, I have folloed the
ok not sure what i'm doing wrong here: $(#list).jqGrid({ url: --URL--, datatype: 'json', mtype:
I'm not sure what exactly i'm doing wrong here...but i noticed that my File.Move()
I am not sure what i am doing wrong here, or even how to
Okay I'm really not sure what I'm doing wrong here but the div is
I'm not sure what I am doing wrong here. I have some basic markup.
Not sure what I'm doing wrong here. Just trying to make it a modal
I'm not sure what i'm doing wrong here. I've set up the environment variables...

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.