Announcement

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

  • Assigning more weight to a category of a variable

    Dear all,

    I would like to know your opinion about the following issue: I need to create (starting from my original dataset) a series of 'fictious datasets' in which I simulate another scenario changing the distribution of a given characteristics, and then calculating (for each 'fictious dataset') the correlation matrix to see if it consistent with the one I have in the original dataset

    For example, In my date I have the 20% of female and 80% of male, and I want to obtain that they are 50% and 50%.

    I proceeded as follows:
    - calculating the weight (50/80 for male, 50/20 for female)
    - creating a new variable that assigns the value 50/80 to male and 50/20 to female
    - running the code "corr soldi donna [fweight=weight]", with weight being the variable which contains the weights for male and female

    Anyway, Stata gives me an error stating "may not use noninteger frequency weights", where I am wrong? Is not that the kind of weight I need to do this procedure?

    Thanks a lot, best, G.

  • #2
    Giorgio:
    elaborating a bit on your example, why not using -regress-?:
    Code:
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . g id=_n
    
    . g female=1 in 1/2
    (8 missing values generated)
    
    . replace female=0 if female==.
    (8 real changes made)
    
    . label define female 0 "male" 1 "female"
    
    . label values female female
    
    . g money=runiform()*1000
    
    . g iw=50/20 if female==1
    (8 missing values generated)
    
    . replace iw=50/80 if female==0
    (8 real changes made)
    
    . regress money i.female [iw=iw]
    
          Source |       SS           df       MS      Number of obs   =        10
    -------------+----------------------------------   F(1, 8)         =      0.35
           Model |  21828.1041         1  21828.1041   Prob > F        =    0.5727
        Residual |   504835.68         8    63104.46   R-squared       =    0.0414
    -------------+----------------------------------   Adj R-squared   =   -0.0784
           Total |  526663.784         9  58518.1982   Root MSE        =    251.21
    
    ------------------------------------------------------------------------------
           money |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          female |
         female  |  -93.44111   158.8766    -0.59   0.573    -459.8113    272.9291
           _cons |   401.3198   112.3427     3.57   0.007      142.257    660.3827
    ------------------------------------------------------------------------------
    Last edited by Carlo Lazzaro; 27 Jul 2019, 11:23.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X