As we have seen, bootstrap distributions are generally symmetric and bell-shaped and centered at the value of the original sample statistic.

statistics

Description

11) As we have seen, bootstrap distributions are generally symmetric and bell-shaped and centered at the value of the original sample statistic. However, strange things can happen when the sample size is small and there is an outlier present. Create a bootstrap distribution for the standard deviation based on the following data: 

    ```{r,echo=TRUE}

library(boot)

x=c(8,10,7,12,13,8,10,50)

#add code here

```

    Describe the shape of the distribution. Is it appropriate to construct a confidence interval from this distribution? Explain why the distribution might have the shape it does.


12) For this problem we are going to build our own normality test using the bootstrap. To do so, we first need to know how to extract the bootstrap confidence interval.


    We want to build a function called \texttt{mynormtest} that takes as input a vector of numbers and either returns "I think the data is normally distributed" or "I don't think the data is normally distributed". The general format of a function is as follows:

    

    ```{r}

myfun = function(x) {

  result = sum(x)

    if (result>0) cat("The sum is positive\n")

  if (result<0) cat("The sum is negative\n")

}

#an example run

myfun(rnorm(100))

```


    The `R` package \texttt{moments} gives us two very useful functions; \texttt{skewness} and \texttt{kurtosis}. If data is truly normal, it should have a skewness value of 0 and a kurtosis value of 3. Write an R function that conducts a normality test as follows: it takes as input a data set, calculates a bootstrap confidence interval for the skewness, calculates a bootstrap confidence interval for the kurtosis, then sees if 0 is in the skewness interval and 3 is in the kurtosis interval. If so, your routine prints that the data is normally distributed, otherwise your routine should print that the data is not normally distributed. Test your routine on random data from normal (rnorm), uniform (runif), and exponential (rexp) , with sample sizes of n=10,30,70 and 100. 


    An example code fragment is below:


    ```{r}

library(moments)

mynormtest = function(x){

  #find bootstrap CI for skewness of x

  # find bootstrap CI for kurtosis of x

  cat("Some otuput goes here\n")

}

```



Related Questions in statistics category