computer oriented and statistical technique practical Q & A









note - use computer, laptop, tab for better viewing quality.

notes by - Hemant Mehra



 1). Suppose the manufacturer claims that the mean lifetime of a light bulb is more than 10,000 hours. In a sample of 30 light bulbs, it was found that they only last 9,900 hours on average. Assume the population standard deviation is 120 hours. At .05 significance level, can we reject the claim by the manufacturer?


Solution


The null hypothesis is that μ ≥ 10000. We begin with computing the test statistic.


> xbar = 9900            # sample mean 

> mu0 = 10000            # hypothesized value 

> sigma = 120            # population standard deviation 

> n = 30                 # sample size 

> z = (xbar−mu0)/(sigma/sqrt(n)) 

> z                      # test statistic 

[1] −4.5644

We then compute the critical value at .05 significance level.


> alpha = .05 

> z.alpha = qnorm(1−alpha) 

> −z.alpha               # critical value 

[1] −1.6449


Answer-

The test statistic -4.5644 is less than the critical value of -1.6449. Hence, at .05 significance level, we reject the claim that mean lifetime of a light bulb is above 10,000 hours.



2). Suppose the food label on a cookie bag states that there is at most 2 grams of saturated fat in a single cookie. In a sample of 35 cookies, it is found that the mean amount of saturated fat per cookie is 2.1 grams. Assume that the population standard deviation is 0.25 grams. At .05 significance level, can we reject the claim on food label?


The null hypothesis is that Î¼ ≤ 2. We begin with computing the test statistic.

> xbar = 2.1             # sample mean 
> mu0 = 2                # hypothesized value 
> sigma = 0.25           # population standard deviation 
> n = 35                 # sample size 
> z = (xbarmu0)/(sigma/sqrt(n)) 
> z                      # test statistic 
[1] 2.3664

We then compute the critical value at .05 significance level.

> alpha = .05 
> z.alpha = qnorm(1alpha) 
> z.alpha                # critical value 
[1] 1.6449

Answer

The test statistic 2.3664 is greater than the critical value of 1.6449. Hence, at .05 significance level, we reject the claim that there is at most 2 grams of saturated fat in a cookie.



3). Suppose the mean weight of King Penguins found in an Antarctic colony last year was 15.4 kg. In a sample of 35 penguins same time this year in the same colony, the mean penguin weight is 14.6 kg. Assume the sample standard deviation is 2.5 kg. At .05 significance level, can we reject the null hypothesis that the mean penguin weight does not differ from last year?

Solution

The null hypothesis is that Î¼ = 15.4. We begin with computing the test statistic.

> xbar = 14.6            # sample mean 
> mu0 = 15.4             # hypothesized value 
> s = 2.5                # sample standard deviation 
> n = 35                 # sample size 
> t = (xbarmu0)/(s/sqrt(n)) 
> t                      # test statistic 
[1] 1.8931

We then compute the critical values at .05 significance level.

> alpha = .05 
> t.half.alpha = qt(1alpha/2, df=n1) 
> c(t.half.alpha, t.half.alpha) 
[1] 2.0322  2.0322

Answer

The test statistic -1.8931 lies between the critical values -2.0322, and 2.0322. Hence, at .05 significance level, we do not reject the null hypothesis that the mean penguin weight does not differ from last year.





4). Suppose a coin toss turns up 12 heads out of 20 trials. At .05 significance level, can one reject the null hypothesis that the coin toss is fair?

Solution

The null hypothesis is that = 0.5. We begin with computing the test statistic.

> pbar = 12/20           # sample proportion 
> p0 = .5                # hypothesized value 
> n = 20                 # sample size 
> z = (pbarp0)/sqrt(p0(1p0)/n) 
> z                      # test statistic 
[1] 0.89443

We then compute the critical values at .05 significance level.

> alpha = .05 
> z.half.alpha = qnorm(1alpha/2) 
> c(z.half.alpha, z.half.alpha) 
[1] 1.9600  1.9600

Answer

The test statistic 0.89443 lies between the critical values -1.9600 and 1.9600. Hence, at .05 significance level, we do not reject the null hypothesis that the coin toss is fair.


5). import the data from excel / csv and perform 
the chi-square test. we will take the
cars93 data n the 'MASS'  library which
represent the sales of different models of 
car in the year 1993.









6. Using R perform the binomial and normal distribution on the data.
solve for dnorm and pnorm

















7. Using R perform the binomial and normal distribution on the data.
solve for qnorm and norm for histogram



















8. Using R perform the binomial and normal distribution on the data.
solve for pbinorm and qbinorm and rbinorm 












10. Perform the Linear Regression using R.
 Create Relationship Model & get the Coefficients Values of 
height-151, 174, 138, 186, 128, 136, 179, 163, 152, 131,Values
 of weight.-63, 81, 56, 91, 47, 57, 76, 72, 62, 48







 Compute the Linear Least
 Square Regression for attributes and coefficient














13. Find the
 mean of 12, 7, 3, 4, 2, 18, 2, 54, -21, 8,- 5 applying NA option. 







14. Find the median of 12, 7, 3, 4, 2, 18, 2, 54, -21, 8, -5











15. Find the mode of 2, 1, 2, 3, 1, 2, 3, 4, 1, 5, 5, 3, 2, 2,3










16. Create vectors, list, matrices and arrays






















































Comments

Popular Posts