Description Usage Arguments Note Author(s) References See Also Examples
View source: R/GA4StratificationP1fit.R
This is the fitness function in GA that calculates the variance of the estimate according to the boundaries obtained with GA and sample sizes obtained with Equal Allocation.
| 1 | GA4StratificationP1fit(randomGeneration, dataName, numberOfStrata, sampleSize, cumTotal, sumSquares, c, dd, nocrom, fitp1, fit, N, means, s, n, vars, mas, NN, k, p, t)
 | 
| randomGeneration | The generation which a fitness function will be applied and a fitness value will be calculated. This is initially a random generation and after each iteration it is the mutated, crossovered and selected generation. | 
| dataName | A string: The name of any type of numeric data containing the values of a univariate stratification variable. | 
| numberOfStrata | An integer: The number of strata. | 
| sampleSize | An integer: The total sample size. | 
| cumTotal | An array: The cumulative total of the data elements from i=1 to i=N | 
| sumSquares | An array: The cumulative total of the squares of the data elements from i=1 to i=N | 
| c | An integer: The length of the data. | 
| dd | An array (nocrom X 1): The minimum of the difference in between the size of each stratum and the sample size to be drawn from that stratum. | 
| nocrom | An integer: The number of the chromosomes in the generation. | 
| fitp1 | An array (1 X nocrom): The fitness value for each chromosome in the generation. | 
| fit | An array (nocrom X 1): The fitness value for each chromosome in the generation. | 
| N | An array (nocrom X nofstrata): The number of the elements in each stratum for each chromosome in the generation. | 
| means | An array (nocrom X nofstrata): The mean of the elements in each stratum for each chromosome in the generation. | 
| s | An array (nocrom X nofstrata): The standart deviation of the elements in each stratum for each chromosome in the generation. | 
| n | An array (nocrom X nofstrata): The number of the sample size to be drawn from each stratum for each chromosome in the generation. | 
| vars | An array (nocrom X nofstrata): The variance of the estimate in each stratum for each chromosome in the generation. | 
| mas | An array (nocrom X nofstrata): The indice of each stratum for each chromosome in the generation. | 
| NN | An array (nocrom X nofstrata): The cumulative sum of the number of the elements in each stratum. | 
| k | An array (nocrom X nofstrata): The difference between the number of the elements and the sample sizes in each stratum. | 
| t | An array (nocrom X nofstrata): The maximum of the  | 
| p | An array (nocrom X nofstrata): The indice of the element where  | 
This study is part of a project supported by the Scientific and Technological Research Council of Turkey (TUBITAK).
Sebnem Er, Timur Keskinturk, Charlie Daly
Maintainer: Sebnem Er <er.sebnem@gmail.com>
http://ideas.repec.org/a/eee/csdana/v52y2007i1p53-67.html
http://www.sciencedirect.com/science/article/B6V8V-4NHM520-1/2/a21e0295aa1616ff56da1ddf2c0ba1ac
GA4StratificationP1
GA4StratificationP1fitt
GA4StratificationP1m
GA4StratificationP1x
GA4StratificationSelection
randomnumGenerator
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ## The function is currently defined as
function(randomGeneration,dataName,numberOfStrata,sampleSize,cumTotal,sumSquares,c,dd,nocrom,fitp1,fit,N,means,s,n,vars,mas,NN,k,p,t)
{
   for ( i in 1:nocrom )
   {
   	mas[i,]=which(randomGeneration[i,]==1,arr.ind=TRUE)
    	N[i,1]=min(mas[i,])
    	means[i,1]=cumTotal[mas[i,1],]/N[i,1]
	if(N[i,1]==1)
	{s[i,1]=0
	} else
	{
    	s[i,1]=((N[i,1]/(N[i,1]-1))*(sumSquares[N[i,1]]/N[i,1]-means[i,1]^2))^.5
	}
    	for ( j in 2:numberOfStrata )
		{    
    		N[i,j]=mas[i,j]-mas[i,(j-1)]
	      	means[i,j]=(cumTotal[mas[i,j],]-cumTotal[mas[i,j-1],])/N[i,j]
				if(N[i,j]==1)
				{s[i,j]=0
				} else
      			{s[i,j]=((N[i,j]/(N[i,j]-1))*((sumSquares[mas[i,j]]-sumSquares[mas[i,j-1]])/N[i,j]-means[i,j]^2))^.5
				}
		}   
    	for ( j in 1:numberOfStrata )
		{
      	n[i,j]=sampleSize/numberOfStrata
		}
		for ( j in 1:numberOfStrata )
		{
        	vars[i,j]=((N[i,j]-n[i,j])*s[i,j]^2*N[i,j]^2)/(c^2*n[i,j]*N[i,j])
		}
    	kl=0
   		fit[i,]=sum(vars[i,])
	dd[i,]=min(N[i,]-n[i,])
    	if ( dd[i]<0 ) 
	{
			fit[i]= 999999999999999999999
	}
    	p1fit=array(-fit,dim=c(nocrom,1))
   }
   return(p1fit)
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.