Activities
Student Organizations
Math Club
BingAWM
Actuarial Association
Read solutions to previous computing homework.
Due: 8 pm, November 5.
Each of you will receive two rows of 0 or 1's. Each row has 31 observations (0 or 1's). It is assumed that the two rows correspond to two samples from two populations, and each observation follows Bernoulli distribution with probability $p_1$ for Population 1 or $p_2$ for Population 2. We will conduct a hypothesis test to tell whether $p_1\neq p_2$. Define a new parameter $\theta=p_1-p_2$.
If you use the following R code you can extract the two rows and save them as two vectors.
####Set the R working directory### setwd("C:/") ###read in the data file, make sure your data file is under the working directory## dat = read.csv('data_6.csv',header=FALSE) ### the "dat" you just read into R is a data frame, need to convert it into a matrix dat <- as.matrix(dat) ##dat now is a 2x31 matrix x1 <- dat[1,] ##take the first row of this matrix as your sample 1 x2 <- dat[2,] ##take the second row of this matrix as your sample 2
Due: 8 pm, October 18.
Each of you receive 20 numbers. It is known that they are from an exponential distribution with mean parameter $\theta$. Answer the following questions.
In Questions 3 and 6, you need to derive the sufficient statistic for the parameter ($\theta$ or $\psi$), calculate its bias, and correct the bias by applying some transformations to the sufficient statistics if necessary.
Note: in practice, we discourage people from using the method in Questions 2 and 5, compared to that in Questions 1 and 4. This exercise is merely for an illustration why would this be the case.
Due: 8 pm, September 27.
Each of you receive 255 numbers, denoted as $X_1,\dots,X_{255}$, all of which follow a normal distribution with an unknown mean and an unknown variance. Please read following questions carefully. Note that not all numbers will be used!!!
The goals include finding a point estimator and a confidence interval for $\mu$ with good accuracy.
x
and save them as a new vector y
.y=x[1:10]
Recall Computing Homework 2 on how to calculate the sample variance. Parts (2)-(4) in that homework gave you the numerator of the sample variance formula.
x[1:n]
.
To find the percentile point of a standard normal distribution, do not use the SOA normal table or Table 4 in the text book. Instead, you can use command z=qnorm(0.995)
, z=qnorm(0.975)
, z=qnorm(0.95)
, etc, to find the percentile point. This request is to help us grade your answer numerically. For example, qnorm(0.975)
gives 1.959964, which corresponds to 1.96 in the normal tables. If you use 1.96 instead of 1.959964, your answer may be mistakenly graded as incorrect. Type in ?qnorm
in R for more information on the function qnorm()
.
Each of you receive 200 numbers, denoted as $X_1,\dots,X_{n}$ where $n=200$. It is known that $X_i\sim Unif(0,\theta)$ for $\theta$ unknown.
Each of you receive 1000 numbers, denoted as $X_1,\dots,X_{n}$ where $n=1000$
var(x)
to calculate the following: var(x)*(n-1)
, where x
is the vector of your sample (the 1000 numbers in the data file).Here are some R codes which might help you
Please install R before the beginning of the semester. In addition to R, some may find RStudio to be handy. Downloads:
####Set the R working directory### setwd("C:/") ###read in the data file, make sure your data file is under the working directory## dat = read.csv('data_2.csv',header=FALSE) ### the "dat" you just read into R is a data frame, need to convert it into a matrix dat <- as.matrix(dat) ##dat now is a 1000x1 matrix x <- dat[1,] ##take the first row of this matrix as your sample
—At this point, you have loaded the data into your R program, whose name is “x”. You can start manipulating the data–
###Assign a value to a variable "n" n <- 1000 ###Find the length of a vector "x" n <- length(x) #### find the average of all elements in vector "x" and assign this value to "xbar" ###### xbar <- mean(x) #### find the summation of all data points in vector "x" and assign this value to "Sx" Sx <- sum(x) #### define a new vector "y" whose elements are square of all elements in "x" y <- x^2 #### subtract a number "z" from a vector x and define this new vector as "xsz" z <- 10 xsz <- x-z #####Compute the sample variance of data points in vector "x" var(x) #####multiply "*" 3*2
—You should read this book for more detailed explanations An Introduction to R (Chapters 2.1,2.2,2.3 are most relevant to this homework)