Announcement

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

  • Logistic model with multiple independent variables

    I'm trying to create a logistic model looking at several demographic variables predicting outcome - some are categorical and some are nominal.
    1) Is there a way to run this all at once to determine which predictors are statistically significant?
    2) One of my nominal variables will need to include decimals, but Stata is giving me an error message for including non-integer values. How do I get around this?
    3) I am able to open .dta files in Stata, but if I run commands and then Save, I start from scratch when I re-open Stata. Is there a way to save the tests that I run?
    Thank you for the help!

  • #2
    Originally posted by Theresa Rooney View Post
    some are categorical and some are nominal.
    You've lost me, there. What is it that you're trying to differentiate between categorical and nominal?

    1) Is there a way to run this all at once to determine which predictors are statistically significant?
    All or nearly all of Stata's estimation commands, including logit and logistic, will accept multiple predictors. See the command's help file or user's manual entry.

    2) One of my nominal variables will need to include decimals, but Stata is giving me an error message for including non-integer values. How do I get around this?
    Having a decimal point implies that the variable is continuous, and not nominal. If you've got something like an ICD-9 code, then it would be better to convert it to string (see the help file for the command tostring) and then create an encoded nominal variable using encode (again, see its help file) to be used with Stata's factor variable notation.

    3) I am able to open .dta files in Stata, but if I run commands and then Save, I start from scratch when I re-open Stata. Is there a way to save the tests that I run?
    save saves the dataset and not the contents of the Results window. Be careful that you don't unintentionally overwrite your original dataset. For your commands and their results, you can start a running log file that keeps both commands and output or or one that stores just the commands—and you can have both types of log file running simultaneously. See the help file and user's manual entry for log.

    Comment


    • #3
      duplicate reply (#2)

      If you share a sample of your data, people here can easier understand your issue and help you.
      1. As long as the independent variables do not create multicollinearity, you can add them to the regression.
      2. The most common cause of this error message is that you are trying to use a string variable with a logit command that only supports numeric variables. You must destring/encode any string variables before using them in the regression. See here (destring) and here (encode) for more info.
      3. You should use do-file and log-file. Do file: "Rather than typing commands at the keyboard, you can create a text file containing commands and instruct Stata to execute the commands stored in that file. Such files are called do-files because the command that causes them to be executed is do". Besides, Log file: “Stata can record your session into a file called a log file but does not start a log automatically; you must tell Stata to record your session. By default, the resulting log file contains what you type and what Stata produces in response”.

      Comment


      • #4
        Thank you for the replies!
        1) Sorry for the confusion - I am looking at variables, some of which are categorical (sex, farm, etc), some are continuous (packed cell volume, total solids, etc) and some are nominal (assigned numbers based on a ranking system). It sounds like I should be able to run these in the same model?
        2) How do I get Stata to recognize a continuous variable? What constitutes a string variable?
        3) So by using do-file and log-file, this will save the script that I've run? It would be great to be able to scroll up and see which commands I've used in the past, etc

        Comment


        • #5
          Also, is there a way to access the help file without Adobe?

          Comment


          • #6
            you do not need adobe to access the help files; just type, e.g.,
            Code:
            help fvvarlist
            adobe is important for accessing the pdf documentation files however

            you do not need to do anything special (unless you have interactions) to have Stata recognize quantitative variables (again see the help file in the code block above

            a string variable has entries that are not to be used in analysis (e.g., an actual string, such as "male" or an ID, etc.); Stata will tell you which variables are string variables:
            Code:
            help describe
            if one or more of the variables you want to use in an analysis are string variables, they need to be made into numeric variables; how you do this depends on whether the entries are actual numbers that should be a numeric variable any (use -destring-) or are something that needs to be encoded (e.g., names of religions); see
            Code:
            help destring
            help encode

            Comment

            Working...
            X