Question

In: Statistics and Probability

Stet by step in R and attach R file and R codes too - Thanks Use...

Stet by step in R and attach R file and R codes too - Thanks

Use one of the real-world example data sets from R (not previously used in the R practice assignment) or a dataset you have found, and at least two of the tests and R functions covered in the practice assignment to conduct a hypothesis test then report your findings and give proper conclusion(s).

Use the following supporting materials for R syntax, data sets and tools, along with other resources found in this module or that you find on your own.

• Using T-Tests in R from the Department of Statistics at UC Berkley

• Test of equal or given proportions from R Documentation

• F-Test: Compare Two Variances in R from STHDA (Statistical tools for high-throughput data analysis)

Please answer step by step with R files attached and R codes

Solutions

Expert Solution

To Use one of the real-world example data sets from R

Using T-Tests in R from the Department of Statistics at UC Berkley

Let us import data from library MASS

We will use "Cats ' data ,

Total Row = 144 , Colums = 3

ibrary(MASS)
> D=(cats)         # to import data of "Cats"

> head(D,10)              # to show only first 10 values of data set
   Sex Bwt Hwt
1    F 2.0 7.0
2    F 2.0 7.4
3    F 2.0 9.5
4    F 2.1 7.2
5    F 2.1 7.3
6    F 2.1 7.6
7    F 2.1 8.1
8    F 2.1 8.2
9    F 2.1 8.3
10   F 2.1 8.5

> D[44:54,]           # between 44 and 54 observation
   Sex Bwt Hwt
44   F 2.9 10.1
45   F 2.9 10.1
46   F 3.0 10.6
47   F 3.0 13.0
48   M 2.0 6.5
49   M 2.0 6.5
50   M 2.1 10.1
51   M 2.2 7.2
52   M 2.2 7.6
53   M 2.2 7.9
54   M 2.2 8.5

In tese data set we have Gender of cat

Column 1 -    "Feamle" = F ,   Male =M

Column 2 -    "Weight of cats " = Bwt ,             

Column 3 -    "Height of cats " = Hwt ,  

Now we wish to cheak weater weight of Female cats is less than Meal cats or not

I.e let u1 be Weight of Female cats , and u2 be weight of Males cats

Hypothesis to test are

H0 : u1 = u2     ( weight of female and Male cat is same )

H1 : u1 < u2     ( weight of female is less than weight of Male cat )

R functions - t.test()

First we will sort data for Male and Female cats

> weight_Female=D[c(Female),2]          # only observation which represents Femal cats
> weight_Male=D[c(Male),2]                 # only observation which represents Femal cats


> weight_Female                # Weight of female cat
[1] 2.0 2.0 2.0 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.2 2.2 2.2 2.2 2.2 2.2 2.3
[20] 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.4 2.4 2.4 2.4 2.5 2.5 2.6 2.6
[39] 2.6 2.7 2.7 2.7 2.9 2.9 2.9 3.0 3.0


> weight_Male                       # Weight of male cat
[1] 2.0 2.0 2.1 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.3 2.4 2.4 2.4 2.4 2.4 2.5 2.5
[20] 2.5 2.5 2.5 2.5 2.5 2.5 2.6 2.6 2.6 2.6 2.6 2.6 2.7 2.7 2.7 2.7 2.7 2.7 2.7
[39] 2.7 2.7 2.8 2.8 2.8 2.8 2.8 2.8 2.8 2.9 2.9 2.9 2.9 2.9 3.0 3.0 3.0 3.0 3.0
[58] 3.0 3.0 3.0 3.0 3.1 3.1 3.1 3.1 3.1 3.1 3.2 3.2 3.2 3.2 3.2 3.2 3.3 3.3 3.3
[77] 3.3 3.3 3.4 3.4 3.4 3.4 3.4 3.5 3.5 3.5 3.5 3.5 3.6 3.6 3.6 3.6 3.7 3.8 3.8
[96] 3.9 3.9

# noww we will test our hypothesis

# to test alternative hypothsis " < " , use comand t.test (x,y, )

> t.test(weight_Female,weight_Male,)

        Welch Two Sample t-test

data: weight_Female and weight_Male
t = -8.7095, df = 136.84, p-value = 4.416e-15
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
       -Inf -0.4376663
sample estimates:
mean of x mean of y
2.359574 2.900000

Since P-value = 4.416e-15 is very small , i.e P-value <<<0.05 ,so we reject null hypothesis at 5% of level of significance .

Hence Mean weight of Female cats is less than Male cats

  • Test of equal or given proportions from R Documentation

Suppose we wish to test that in town the proportion of males cats in population 65%

Than is we wish to cheak that in every 100 cats there are 65 Male cats .

But someone says that Proportion of males cats is more than 65%

So ,

Hypothesis to test are

H0 : po = 0.65     ( proportion of male cats in town is 65% )

H1 : po > 0.65     ( proportion of male cats in town is more than 65% )

Now we have sample of size 144 , so we will test weater proportion of cats in sample is 65% or more than 65%

we will use here prop.test (x,n,po=)  

                                                                   

> n=length(D[,1])
> n                 # total samples
[1] 144
           

> x=length(D[c(Male),2])
> x                    # number of Male Cats in sample
[1] 97    
  

   

> prop.test(x,n,0.65,)

        1-sample proportions test with continuity correction

data: x out of n, null probability 0.65
X-squared = 0.25672, df = 1, p-value = 0.3062
alternative hypothesis: true p is greater than 0.65
95 percent confidence interval:
0.6030755 1.0000000
sample estimates:
        p
0.6736111

       

Here we have , p-value = 0.3062 > 0.05

So at 5% of level of significane we do not reject null hypothesis

Hence Proportion of Male cats in town may be equal to 65%

  •         F-Test: Compare Two Variances in R from STHDA (Statistical tools for high-throughput data analysis)                 

{ Note - In STHDA am not getting any usefull dataset since in testing F-Test: Compare Two Variances we requires two variable which have atrribute like gender , Height ect . So if any dataset like avilable you can use}

Since Here we are suppose to perform F-Test: Compare Two Variances we can use previous data set of cats only ,and can cheack weathere Feamle and Male Cats ahve same variability in their weight or not :

To test

H0 : 1 = 2    ( No varibility between weigths of diferent gender of cats )

H1 : 1 2   ( varibility between weigths of male and female cats differs)

    

> weight_Female        # already obtain in first part i.e weight of female cats
[1] 2.0 2.0 2.0 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.2 2.2 2.2 2.2 2.2 2.2 2.3
[20] 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.3 2.4 2.4 2.4 2.4 2.5 2.5 2.6 2.6
[39] 2.6 2.7 2.7 2.7 2.9 2.9 2.9 3.0 3.0


> weight_Male          # already obtain in first part i.e weight of male cats
[1] 2.0 2.0 2.1 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.2 2.3 2.4 2.4 2.4 2.4 2.4 2.5 2.5
[20] 2.5 2.5 2.5 2.5 2.5 2.5 2.6 2.6 2.6 2.6 2.6 2.6 2.7 2.7 2.7 2.7 2.7 2.7 2.7
[39] 2.7 2.7 2.8 2.8 2.8 2.8 2.8 2.8 2.8 2.9 2.9 2.9 2.9 2.9 3.0 3.0 3.0 3.0 3.0
[58] 3.0 3.0 3.0 3.0 3.1 3.1 3.1 3.1 3.1 3.1 3.2 3.2 3.2 3.2 3.2 3.2 3.3 3.3 3.3
[77] 3.3 3.3 3.4 3.4 3.4 3.4 3.4 3.5 3.5 3.5 3.5 3.5 3.6 3.6 3.6 3.6 3.7 3.8 3.8
[96] 3.9 3.9

# to Compare Two Variances we use var.test(x,y,conf.level="")

> var.test(weight_Female,weight_Male,conf.level=0.95)

        F test to compare two variances

data: weight_Female and weight_Male
F = 0.3435, num df = 46, denom df = 96, p-value = 0.0001157
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.2126277 0.5803475
sample estimates:
ratio of variances
         0.3435015

Conclusion - Since P-value = 0.0001157 < 0.05

We reject null hypothesis at 5% of level of significance.

Hence variability in weights of male and female cats may differ .


Related Solutions

Please attach the solution step by step, thanks! 1. An insurance company collected $31.0 million in...
Please attach the solution step by step, thanks! 1. An insurance company collected $31.0 million in premiums and disbursed $28 million in losses. Loss adjustment expenses amounted to $5.0 million. The firm is profitable A. if dividends paid to policyholders is $4 million and income generated on investments is $4 million. B. if dividends paid to policyholders is $10 million and income generated on investments is $14 million. C. if dividends paid to policyholders is $6 million and income generated...
Need R codes to compile and plots , no hand written. Step-1: Type the data in...
Need R codes to compile and plots , no hand written. Step-1: Type the data in R Step-2: Perform Least-Squares regression Step-3: Make a normal Probability Plot using rstudent residuals Step-4: Plotting residuals versus predicted response yhat Step-5: Plotting Residuals versus each regressor. Step-6: Partial regression plots of residuals vs. regressors Step-7: Partial regression plots of residuals vs. regressors data:  (p.555 y, x1 and x5). y <- c(271.8, 264,238.8,230.7,251.6,257.9,263.9,266.5,229.1,239.3,258, 257.6,267.3,267,259.6,240.4,227.2,196,278.7,272.3,267.4,254.5,224.7, 181.5,227.5,253.6,263,265.8,263.8) x1 <- c(783.35, 748.45,684.45,827.8,860.45,875.15,909.45,905.55,756,769.35,793.5,801.65,819.65,808.55,774.95,711.85,694.85,638.1,774.55,757.9,753.35,704.7, 666.8,568.55,653.1,704.05,709.6,726.9,697.15) x5 <- c(13.2, 14.11,15.68,10.53,11,11.31,11.96,12.58,10.66,10.85,11.41,11.91,12.85,13.58,14.21,15.56,15.83,16.41,13.1,13.63,14.51,15.38, 16.1,16.73,10.58,11.28,11.91,12.65,14.06)
USE R AND SHOW CODES!! 1.a. There is a theorem that the ratios of blood types...
USE R AND SHOW CODES!! 1.a. There is a theorem that the ratios of blood types O, A, B and AB are 49:38:9:4, respectively. A research team, investigating a small community and obtained the following frequencies of blood type. Blood type Blood Type O A B AB Frequency 87 59 20 4 Test the hypothesis that the proportions in this community do not differ significantly from those in the general theorem. 1.b. The severity of participants' migraines is clinically assessed....
USE R AND SHOW CODES!! 1.a. An investigator is interested in comparing the cardiovascular fitness of...
USE R AND SHOW CODES!! 1.a. An investigator is interested in comparing the cardiovascular fitness of elite runners on three different training courses. course one is at, course 2 has graded inclines, and course three includes steep inclines, Ten runners were involved for each course. Heart rates measured on each course are as the following table Course 1 Course 2 Course 3 132 135 138 143 148 148 135 138 141 128 131 139 141 141 150 150 156 161...
APPLIED STATISTICS 2 USE R CODE! SHOW R CODE Use data file RecordMath2526.txt, to produce a...
APPLIED STATISTICS 2 USE R CODE! SHOW R CODE Use data file RecordMath2526.txt, to produce a plot graph with Exam1 as x, Exam2 as y, use Gender as color, and Hw1 as pch. RecordMath2526 information Index Gender Hw1 Hw2 Hw3 Exam1 Hw4 Exam2 Hw5 Hw6 Hw7 Final 1 F 9 6 8 60 7 82 10 10 9 69 2 M 10 10 10 94 9 98 10 10 8 91 3 M 9 10 8 79 9 55 10...
Use R to load in the file “data.csv”. Assume that this is a random sample from...
Use R to load in the file “data.csv”. Assume that this is a random sample from some population with mean µ and variance σ 2 . (a) Plot a histogram of the data. (b) Compute a 95% confidence interval for the population mean µ using the formula X ± (S/√ n)tn−1,.975. (Hint: tn−1,.975 can be computed with qt(.975,df=n-1)) (c) Compute a p-value for the hypothesis H0 : µ = 5 versus HA : µ > 5, based on the test...
what is bahadur's 1961 representation r codes?
what is bahadur's 1961 representation r codes?
use r programming, details on the codes please. Consider an urn with 10 balls inside, 7...
use r programming, details on the codes please. Consider an urn with 10 balls inside, 7 of which are red and 3 of which are green. Select 3 balls successively from the urn. Let A = {1 st ball is red}, B = {2 nd ball is red}, and C = {3 rd ball is red}. Then P(all 3 balls are red) = P(A ∩ B ∩ C)      a) Calculate the Probability with R? (1)      b) Also, what is the...
USE R AND SHOW CODES!! 1.a. The following data represent the birth weights of siblings born...
USE R AND SHOW CODES!! 1.a. The following data represent the birth weights of siblings born to six different mothers Data Birth weight Mother Child 1 Child 2 Child 3 Child 4 1 6.4 6.9 6.7 7.1 2 8.5 7.8 7.8 8.3 3 7.6 8.7 9.9 8.2 4 5.3 6.7 7.5 6.4 5 6.2 5.6 6.4 5.5 6 7 7.8 8.6 6.6 Use an appropriate method to test if there is a significant difference in the birth weight of siblings....
USE R AND SHOW CODES 2. The following data were collected in a multisite observational study...
USE R AND SHOW CODES 2. The following data were collected in a multisite observational study of medical effectiveness in Type II diabetes. These sites were involved: a healthy maintenance organization (HMO), a university teaching hospital (UTH), and an independent practice assumption (IPA). The following data display the treatment regimens of patients measured at baseline by site. Use the data to test that no difference in treatment regimens across sites. (in addition, calculate the expected frequency for each cell.)                                                              ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT