Description of job
You should use SAS program only to write the code
What I am going to have you work on is Moses technique for testing for variances. We can start off on using this for two samples and then extend it to k samples where k is greater than 2. We will start off assuming samples of size 18 from each population and then samples of size 36 from each population. We will apply the Moses technique to test for differences in variances of the two populations. We will first use the Moses technique using subsamples of size 3 and then subsamples of size 6. We want to compare the alpha values and powers of these tests for subsamples of size 3 and then for subsamples of size 6 when are initial samples sizes are of size 18, and then when they are of size 36. We will be finding these when the underlying populations are normal, and then when they are exponential. We will compare the powers of the Moses (both with 3 and 6 subsample size) with the powers of the F test for two populations. (Eventually, we will expand to more than two populations.)
You can start by sampling from normal populations. Let’s first estimate the alpha levels – have both populations be normal with mean 10 and variance 25. We would have samples of size 18 from each – using Moses technique – break these into subsamples of size 3 each, and then of size 6 each. Calculate the Moses test for subsamples of size 3 each and then subsamples of size 6 each. Also, calculate the F test. Do this for 5000 samples and keep track of when you get a rejection from each test. The estimated type 1 error for each of the tests will be the number of times each test rejected divided by 5000. We then want to start estimating powers. We can begin this by keeping the means the same for both populations and then changing the variances. Say population 1 is normal with mean 10 and variance 25 and population 2 is normal with mean 10 and variance 36. Again, generate 5000 sets of samples of size 18 each from the two populations and keep track of the numbers of times each test rejects divided by 5000. We would then try to estimate power when the mean changes as well as the variance. Say, the first population has mean 10 and variance 25, an the second population has mean 15 and variance 36. Estimate the powers of all 3 tests.
We will then extend the above to samples of size 36, then also look at exponential populations, and then extend the number of populations. This is a start.
You should the code include :
1- generate data for Normal Dist. and generate data for Exponential Dist.
2- Moses’ test for variance
3- The Mann-Whitney test.
1. Using the functions penudigit and iseven (defined in Exercises 5 and 6) define a function to
determine whether the penultimate digit of a given number is even. [5 marks]
2. Write a function with two integer parameters which will determine whether the larger integer is
odd. [5 marks]
3. Using the functions defined in Exercises 25 and 27, write a function sumbig to add together all
numbers in a list which are bigger than 100. [10 marks]
4. Write the sequences of reductions when the input is the first three letters of your surname for the
function precedes1(defined in Task B). [15 marks]
5. The following function (isone) returns true, if the number of elements in a list is two. The function
isone calls the function length to determine the number of elements in a list. Redefine the function
isone without the function length and recursion. [10 marks]
dec isone : list num -> truval;
— isone ( alsit ) <= length (alist) = 2 ;
6. Using the functions take and drop (Exercise 38) define a polymorphic function take_drop. This
function returns lists of the first n elements, and the remaining elements when the first n elements
are removed. [10 marks]
>: take_drop (3, “abcd”) ;
>> ( “abc” , “d” ) : ( list char # list char)
7. Write the sequences of reductions for take_drop (3, ‘your surname’). [15 marks]
8. Define a polymorphic function palindrome to form a palindrome from an arbitrary list. [10 marks]
>: palindrome “mad”; >: palindrome “abcd”;
>> “madam”: list char >> “abcdcba” : list char
9. (a) Define a polymorphic function insert that inserts a single element into its correct position in a
>: insert ( ‘c’, “abde” ); >: insert (4 , [1 , 3, 5, 9]);
>> “abcde” : list char >> [1, 3, 4, 5, 9]: list num
(b) Write the sequences of reductions for the following application of the higher-order function
reduce, where alist is the first three characters of your surname:
reduce(insert, nil, alist) [10 marks]
10. Explain in your own words how the functions defined in question 9 part (a) evaluates the input.