Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • pinv function is unknown?

    mat A = (1,2\2,4\4,8)
    mat B = pinv(A)

    I'm not familiar with Stata, so this might be a silly question.

    If I run this command, I don't know why it says that pinv() is an unknown function.

    . mat B = pinv(A)
    unknown function pinv()
    r(133);

    What is wrong with this one? Do I have to install a certain package?

  • #2
    pinv() is a Mata function, not a Stata function.

    You can call Mata line by line

    or enter Mata and leave when done.

    .
    Code:
     mata: A = (1,2\2,4\4,8)
    
    . mata: B = pinv(A)
    
    . mata: B 
                     1             2             3
        +-------------------------------------------+
      1 |  .0095238095    .019047619   .0380952381  |
      2 |   .019047619   .0380952381   .0761904762  |
        +-------------------------------------------+
    
    . 
    . mata 
    ------------------------------------------------- mata (type end to exit) ------------------------
    : A = (1,2\2,4\4,8)
    
    : B = pinv(A)
    
    : B 
                     1             2             3
        +-------------------------------------------+
      1 |  .0095238095    .019047619   .0380952381  |
      2 |   .019047619   .0380952381   .0761904762  |
        +-------------------------------------------+
    
    : end

    Comment

    Working...
    X