[R] sampling and gini index

Cesar Ortega cortega at unitec.edu
Mon Mar 10 12:17:28 CET 2003


Hi there,


I am new in R, and I was wondering if I could do the following in R, 
since I have tried in SPSS and I have only done part of it.  I 
would appreciate any help to build this routine in R, if possible:



I have a column of 284 elements Y, [...]
> 
> Iam reading these as 284 cases with a single 
> variable, which I will call Y
> 
>> 
> >  where first I need to calculate:
> >
> >GINP=[SUMi SUMj {|Yi - Yj|}]/[2(N**2)*MEAN(Y)], where Yi and Yj 
> are 
> >the 284 elements, 0<Y1<=Y2...<=Y284.  j: is the next position of i.
> 
> Here, I am doing a calculation to yield a single number. 
> Calculating 
 (I assume that N=284) 

> 
> 
> >Next, I need to take the 284 numbers and resampling them in 
> [groups 
> >of] n data (like 3, 4, 5,  etc) for M number of samples ( like 
> 1000, 
> >2000, etc, one at a time) in 3 sampling methods:
> >
> >1. Simple sampling without replacing.
> >2. Fixed systematic sampling.
> >3. Proportional sampling Madow.
> 

SIMPLE SAMPLING WITHOUT REPLACING THE POSITION VALUE, FOR INTANCE 3, IF 
WE HAVE THE POSITION 3,7,9 WITH ITS VALUES, WE COULD HAVE 3,7,10, BUT 
WE COULD NOT HAVE THE POSITIONS 9,3,7 AGAIN.  SO THIS IS A COMBINATION, 
AND IF WE TAKE 3 COMBINATIONS OUT 284 WE HAVE 284!/(3!*281!). AND WE 
NEED TO START FROM 1000 GROUPS OF COMBINATIONS. IT IS LIKE 
IF WE HAVE 1,2,3,4,5 AND WE WANT COMBINATIONS OF 2, WE COULD HAVE IN 
1,2 AND 1,3 AND 1,4 AND 1,5 AND 2,3 AND 2,4, ETC, BUT IN RANDOM ORDER.


 
> 



> >After I have the M(1000, 2000) samples of n ( 3,4, 5)elements in 
> a column,
> 
>
> 
> >I need to take one by one each of the 1000 samples of each n 
> elements 
> >and calculate:
> >
> >PI(i)=n/N in simple and fixed sampling and i belogns to the 
> sample. In 
> >MADOW  PI(i) is proprortional to an auxiliary variable Xi:PI(i)= 
> RXi, 
> >where r= MOD(TN,R), and TN=SUMi(Xi), i to N.
> 

WE KNOW r, AND TN, BUT WE NEED TO FIND R FROM THE MODAL AND r.


AND CALCULATE:
> >ESTIMATED N= SUM {1/PI(i)};
> >ESTIMATED T(Y)= SUM {Yi/PI(i)};  i belongs to the sample.
 

GINMi=[SUMi{(Yi/PI(i))*[1/PI(i)+SUMj(2/PI(j)]}]/[(2*ESTIMATED 
N*ESTIMATED T)].     i belongs to  M (1000) times, WHERE j=i+1

WE HAVE ONLY ONE VARIABLE Y, BUT WITH THE FIRST POSITION i AND THE NEXT 
j, IN THE ASCENDING ORDER.

> >And last to get the errors as:
> >
> >E1=  [SUMi {|GINP-GINMi |}]/[M] ; i belongs M
> >
> >E2= SQRT[SUMi {|GINP-GINMi |}]/[M]; i belongs TO M



More information about the R-help mailing list