Announcement

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

  • Running ANCOVA with model assumptions testing across multiple random samples

    I would be most grateful if you could advise me on the availability of pre-existing code that will allow me to run the model assumptions for ANCOVA in addition to running the ANCOVA process itself. I normally use SPSS for ANCOVA but I would like to run an ANCOVA and corresponding model assumptions testing over multiple random samples taken from a single sample. I had initially assumed that the bootstrap approach may be correct for this but I should clarify that the end I have in mind is not to obtain a summary result from bootstrapping. I simply wish to compare results from running an ANCOVA and corresponding model assumptions testing across multiple random samples of a fixed size. Therefore, I am also interested to know if a better approach would be to generate the random samples first, save them in separate columns of a spreadsheet and then run the ANCOVA and model assumptions testing across each column separately. I would welcome advice on the most efficient approach to take.

    Many thanks!

  • #2
    Margaret:
    welcome to this forum.
    First, I would suggest to consider -regress- for your analysis.
    That said, what follows can hopefully give you some clues:
    Code:
    . use "C:\Program Files (x86)\Stata15\auto.dta", clear
    (1978 Automobile Data)
    
    . g random=runiform()*100
    
    . sum random
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
          random |         74    43.90097    27.03618   .4866534   98.38661
    
    . g sample=1 if random<30
    (45 missing values generated)
    
    . replace sample=0 if random>=30 & random<60
    (23 real changes made)
    
    . replace sample=2 if sample==.
    (22 real changes made)
    
    . tab sample
    
         sample |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              0 |         23       31.08       31.08
              1 |         29       39.19       70.27
              2 |         22       29.73      100.00
    ------------+-----------------------------------
          Total |         74      100.00
    
    . bysort sample: regress price mpg i.foreign
    
    --------------------------------------------------------------------------------------------------------
    -> sample = 0
    
          Source |       SS           df       MS      Number of obs   =        23
    -------------+----------------------------------   F(2, 20)        =     14.14
           Model |   169990639         2  84995319.3   Prob > F        =    0.0001
        Residual |   120205454        20   6010272.7   R-squared       =    0.5858
    -------------+----------------------------------   Adj R-squared   =    0.5444
           Total |   290196093        22  13190731.5   Root MSE        =    2451.6
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -420.7267   79.21507    -5.31   0.000    -585.9664    -255.487
                 |
         foreign |
        Foreign  |   1975.368   1155.156     1.71   0.103    -434.2441     4384.98
           _cons |   15669.87   1760.153     8.90   0.000     11998.25    19341.48
    ------------------------------------------------------------------------------
    
    --------------------------------------------------------------------------------------------------------
    -> sample = 1
    
          Source |       SS           df       MS      Number of obs   =        29
    -------------+----------------------------------   F(2, 26)        =      6.56
           Model |  56658630.1         2    28329315   Prob > F        =    0.0049
        Residual |   112342433        26  4320862.81   R-squared       =    0.3353
    -------------+----------------------------------   Adj R-squared   =    0.2841
           Total |   169001063        28  6035752.25   Root MSE        =    2078.7
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -298.3938   88.26338    -3.38   0.002    -479.8218   -116.9658
                 |
         foreign |
        Foreign  |   1980.213   977.9651     2.02   0.053    -30.02253    3990.449
           _cons |   11379.99   1746.977     6.51   0.000     7789.023    14970.95
    ------------------------------------------------------------------------------
    
    --------------------------------------------------------------------------------------------------------
    -> sample = 2
    
          Source |       SS           df       MS      Number of obs   =        22
    -------------+----------------------------------   F(2, 19)        =      0.28
           Model |  4564409.37         2  2282204.69   Prob > F        =    0.7599
        Residual |   155681742        19  8193775.89   R-squared       =    0.0285
    -------------+----------------------------------   Adj R-squared   =   -0.0738
           Total |   160246151        21  7630769.11   Root MSE        =    2862.5
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -100.2819   134.8743    -0.74   0.466    -382.5769    182.0132
                 |
         foreign |
        Foreign  |   501.2302   1491.968     0.34   0.741    -2621.495    3623.956
           _cons |   7813.903   2794.605     2.80   0.012     1964.729    13663.08
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo

      Thank you for kind reply. I am sorry for not being aware of it earlier. It seems that I didn't get an email alert. After doing some model assumptions testing, I decided to focus on the t-test. As I have a separate query arising from this and other work, I shall open up a new post.

      Best wishes
      Margaret

      Comment

      Working...
      X