Announcement

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

  • simple question

    Hi I have a simple binary logistic regression model I would like to test on an independent dataset. How do i go about testing wether it categorizes my outcome variable successfuly in the independent dataset.
    Thank you

  • #2
    Mubeen:
    welcome to this forum.
    Do you mean something along the following lines?
    Code:
    . use "https://www.stata-press.com/data/r17/auto.dta"
    (1978 automobile data)
    
    . logistic foreign mpg
    
    Logistic regression                                     Number of obs =     74
                                                            LR chi2(1)    =  11.49
                                                            Prob > chi2   = 0.0007
    Log likelihood = -39.28864                              Pseudo R2     = 0.1276
    
    ------------------------------------------------------------------------------
         foreign | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |   1.173232   .0616975     3.04   0.002      1.05833    1.300608
           _cons |   .0125396   .0151891    -3.62   0.000     .0011674    .1346911
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds.
    
    . predict pr_positive_outcome, p
    
    . list foreign mpg pr_positive_outcome in 1/10
    
         +---------------------------+
         |  foreign   mpg   pr_pos~e |
         |---------------------------|
      1. | Domestic    22   .2964837 |
      2. | Domestic    17   .1593718 |
      3. | Domestic    22   .2964837 |
      4. | Domestic    20   .2344013 |
      5. | Domestic    15   .1210596 |
         |---------------------------|
      6. | Domestic    18   .1819565 |
      7. | Domestic    26   .4439737 |
      8. | Domestic    20   .2344013 |
      9. | Domestic    16   .1391136 |
     10. | Domestic    19   .2069539 |
         +---------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi carlos,
      Thanks for replying. I have one continuous variable used as a predictor and one categorical binary variable. After the first command, I want to test the model on another dataset? Do I have to delete the dataset and paste the new dataset. How do I use the model from the previous (train dataset) to check if it categorizes the test dataset?

      Comment


      • #4
        Mubeen:
        just check the very same code on the new dataset, that should be opened in a new .dta file.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X