Announcement

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

  • How do you create a mata function that accepts vectors and scalars as arguments

    Hello, I have had trouble writing a Mata function that accepts two arguments: (1) a real vector A and (2) a real scalar p. If the scalar p contains decimal places, the function should round the scalar to the nearest integer. The function should then take vector A and calculate (element- wise) 𝐴^2, 𝐴^3, ... , 𝐴^p-1, 𝐴^p (all in separate columns). The result should be displayed in a matrix which should also be exported to Stata’s return list. The code must declare the type of input and all variables used in the function.
    I am a beginner in stata and this task may be beyond my expertise so any help would be appreciated.


    Best regards,

    Juan
    Last edited by JuanA Samper; 17 Nov 2018, 15:42.

  • #2
    Hi! Did you manage to do this? I'm trying to do something very similar but I can't figure out how to do it. It would be very helpful if you could share how you solve it.

    Comment


    • #3
      #1 sound like a homework assignment to me. Nothing wrong with that but see the respective FAQ.

      #2 does not provide nearly enough detail. How is your problem similar to #1? What do you want, exactly? What did you try, exactly? How/why is what you have tried different from what you want?

      Comment

      Working...
      X