Announcement

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

  • opportunity to esitimate multilevel/hierachical beta regressions (rather than just simple beta regressions)

    Comment


    • Originally posted by Leonardo Guizzetti View Post

      I read the posted link and many of the stated "pitfalls" boil down to William's point about not being proficient in Stata (or failing to read the documentation). The list, I think, is intended for people with little or no experience coming to Stata from other languages, who may not have the same expectations about what code ouught or ought not to do.
      .
      If you think this is a beginner's problem, I beg you to search this forum and find out for yourself how often these kind of bysorts are suggested by very experienced users.
      Code:
       bysort id (time): gen temp = time[_N]
      I would say missing should be neither min nor max of the sort. I think other languages' NA is always false, so it would not be counted for these kind of bysort: gen exercises.
      Last edited by Henry Strawforrd; 19 Jan 2022, 04:04.

      Comment


      • Originally posted by Henry Strawforrd View Post
        ... I beg you to search this forum and find out for yourself how often these kind of bysorts are suggested by very experienced users.
        I have been a use here for many years and am familiar with the technique and that it is suggested. Those bysort strategies are often explained as intended to work (or not) with data with missing values, depending on the details shared by the person asking for help and the data example. Nevertheless, two strategies for missing values are often useful: drop them before performing a manipulation or summary, or (ii) ignore them after such an operation.


        Originally posted by Henry Strawforrd View Post
        I would say missing should be neither min nor max of the sort. I think other languages' NA is always false, so it would not be counted for these kind of bysort: gen exercises.
        Missing values are part of the data and must go somewhere when sorted. Where then should Stata put them if not treating them as either the min/max value? Stata treats missing as large, R does the same with "NA", and SAS treats them as small. How the programmer chooses o work with groups defined in part or in whole by such values is up to to the programmer to decide.

        Comment


        • The new telasso command is nice. I'd like to see it support flogit and fprobit, too, for fractional response variables -- just like teffects does.

          Comment


          • Originally posted by Bert Lloyd View Post
            An option for log to close when a do-file exits with error.
            @216

            Is that really needed? Just by putting the following line at the very top of any do file this can be done, is not it?

            Code:
             capture log close

            Comment


            • ability to read images and information stored in pixels

              Comment


              • Response to #258:
                Stata treats missing as large, R does the same with "NA"
                I don’t think that is correct. For R, missing is NA, i.e. not available - and neither lagre nor small.

                Code:
                if a > 2 // Stata
                and
                Code:
                if (a > 2) # R
                provide different results if variable a includes missing values.
                In base R, many operations even result in an error if you do not explicitely ask R to disregard missing values:

                Code:
                na.rm = TRUE
                ——————————————

                I have asked myself why I have moved to R. Apart from the open source aspect, I think there are two main reasons:

                - R Markdown
                - How R handles objects such as data frames, including output from analyses: very easy to manipulate/combine/subset (or convert to a different object class). So, surprisingly, I find writing code to develop a table showing results much easier and more intuitive in R than in Stata 17.

                What would make me buy yet another upgrade of Stata? I guess it would be integration with R and R Markdown (from within RStudio).

                I believe Stata has an excellent language (unless one needs to merge results from several “macros”) and Stata is overall strong as a statistical tool. I’m not sure it’s commercially the best solution, but for research it would be great if Stata and R could be integrated.

                (Those who would like to use both R and Stata without real integration might try the R package RStata or something similar. It helped me once.)

                Comment


                • Being able to define our own functions would be very useful (whether it is feasible for StataCorp to implement is another question, which I cannot answer).

                  We are currently able to define functions for egen, but these are limited for a number of reasons, including the facts that they cannot be nested and that they can only be used while generating variables, as opposed to, for instance, defining macros.

                  Comment


                  • Response to #262 -

                    The assertion from #258 disputed in #262

                    Stata treats missing as large, R does the same with "NA"
                    was taken out of context. It was in reference to sorting a Stata dataset - the equivalent of sorting an R data frame.
                    Code:
                    > df <- data.frame("Serial_number" = 1:5, "Age" = c(20, 21, NA, 18, 19), "Name" = c("Johnny","Dorian","Linda", "Cathy", "Rick"))
                    > df
                      Serial_number Age   Name
                    1             1  20 Johnny
                    2             2  21 Dorian
                    3             3  NA  Linda
                    4             4  18  Cathy
                    5             5  19   Rick
                    > 
                    > # Sort by age ascending order
                    > newdf <- df[order(df$Age),]
                    > newdf
                      Serial_number Age   Name
                    4             4  18  Cathy
                    5             5  19   Rick
                    1             1  20 Johnny
                    2             2  21 Dorian
                    3             3  NA  Linda
                    >

                    Comment


                    • Originally posted by Ali Atia View Post
                      Being able to define our own functions would be very useful (whether it is feasible for StataCorp to implement is another question, which I cannot answer).

                      We are currently able to define functions for egen, but these are limited for a number of reasons, including the facts that they cannot be nested and that they can only be used while generating variables, as opposed to, for instance, defining macros.
                      Mata allows you to pretty flexibly implement your own functions, and can push/pull data and macros (etc) from Stata. Would this satisfy your request?

                      Comment


                      • Partially, though as far as I am aware you cannot evaluate Mata functions on the fly within a Stata command, which is possible with Stata functions.

                        Comment


                        • Originally posted by Ali Atia View Post
                          Partially, though as far as I am aware you cannot evaluate Mata functions on the fly within a Stata command, which is possible with Stata functions.
                          You can evaluate Mata functions within a user-written command, and you can call Mata void functions (subroutines) on the fly from Stata's command line, but what I think you're referring to is having a Mata function perform vectorized operations on the dataset, as in something like
                          Code:
                          mata:
                          real scalar myfunction(real scalar input) {
                              // Stuff here
                          }
                          end
                          
                          generate double b = myfunction(a)
                          You're right, but there are other ways of achieving this programmatic need from within Mata, itself, and you can pass arguments (including variable names) directly to a Mata void function from the Stata command line.

                          Comment


                          • This may have been suggested already, but a custom display format for percentages, perhaps with optional percent sign.

                            For example, the following might yield

                            Code:
                            . display strofreal(0.1254, "$5.1p")
                             12.5
                            
                            . display strofreal(0.1254, "$5.1ps")
                            12.5%

                            Comment


                            • In Mata, if one uses the if () structure below, Mata exits with the vague error "unexpected end of line" and quits, because it expected to see an -else- (or else if) block. The existence of else-blocks should be optional, as they are for the one-line cases in Mata, and as they are fully optional in Stata's -ifcmd-.

                              Code:
                              mata:
                                if (cond) {
                                  // do something
                                }
                              end
                              result

                              Code:
                              unexpected end of line
                              (# lines skipped)

                              Comment


                              • Originally posted by Leonardo Guizzetti View Post
                                In Mata, if one uses the if () structure below, Mata exits with the vague error "unexpected end of line" and quits, because it expected to see an -else- (or else if) block. The existence of else-blocks should be optional, as they are for the one-line cases in Mata, and as they are fully optional in Stata's -ifcmd-.

                                Code:
                                mata:
                                if (cond) {
                                // do something
                                }
                                end
                                result

                                Code:
                                unexpected end of line
                                (# lines skipped)
                                This is a really interesting finding I was not aware of. To complete, the following works:

                                Code:
                                mata:
                                if (cond) {
                                // do something
                                }
                                (any other code)
                                end
                                To me it looks almost mata skips something at the end of the code.

                                Comment

                                Working...
                                X