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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:24:04+00:00 2026-06-14T12:24:04+00:00

Suppose I have variables local a=10 local b=1 local c=0.25 where a necessarily is

  • 0

Suppose I have variables

local a=10
local b=1
local c=0.25

where a necessarily is an integer. Now, how do I create an a times a matrix whose diagonal elements are all equal to b and whose off-diagonal elements are all equal to c? I’m not very familiar with matrix in Stata language, so I’m hoping anyone can help me out here. Thanks in advance.

  • 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-14T12:24:06+00:00Added an answer on June 14, 2026 at 12:24 pm
    . local a = 10
    
    . local b = 1
    
    . local c = 0.25
    
    . matrix A = `b' * I(`a')
    
    . mat li A
    
    symmetric A[10,10]
         c1   c2   c3   c4   c5   c6   c7   c8   c9  c10
    r1    1
    r2    0    1
    r3    0    0    1
    r4    0    0    0    1
    r5    0    0    0    0    1
    r6    0    0    0    0    0    1
    r7    0    0    0    0    0    0    1
    r8    0    0    0    0    0    0    0    1
    r9    0    0    0    0    0    0    0    0    1
    r10    0    0    0    0    0    0    0    0    0    1
    
    . matmap A A , m(cond(@ == 0, 0.25, @))
    
    . mat li A
    
    symmetric A[10,10]
         c1   c2   c3   c4   c5   c6   c7   c8   c9  c10
    r1    1
    r2  .25    1
    r3  .25  .25    1
    r4  .25  .25  .25    1
    r5  .25  .25  .25  .25    1
    r6  .25  .25  .25  .25  .25    1
    r7  .25  .25  .25  .25  .25  .25    1
    r8  .25  .25  .25  .25  .25  .25  .25    1
    r9  .25  .25  .25  .25  .25  .25  .25  .25    1
    r10  .25  .25  .25  .25  .25  .25  .25  .25  .25    1
    

    Here matmap must be downloaded from SSC using ssc inst matmap.

    By the way, the locals are not needed here. You can just enter your constants as such.

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

Sidebar

Related Questions

Suppose we have these local variables: int a = 0; int b = 1;
I am confused between NSString and NSMutable string usage. Suppose I have instance variables
How do you use variables to access Object attributes? Suppose I have an Object
Suppose that I have an integer variable in a class, and this variable may
I have a rather general question regarding JavaScript and local variables. My question is
Suppose I have a variables in the global scope. Suppose I wish to define
Suppose I have: R> str(data) 'data.frame': 4 obs. of 2 variables: $ datetime: Factor
Suppose we have multiple threads all calling the same function: def foo # do
Suppose i have a LPSTR variable. How do i free the memory after using
Suppose I have a static variable declared inside a function in C. If 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.