For a newspaper to be financially viable, it has to capture more than 15% of the Toronto market. In a survey conducted among 400 randomly selected prospective readers, 58 participants indicated that they would subscribe to the newspaper. Can the publisher conclude that the proposed newspaper will be financially viable at the 10% significance level?
What is the relevant point estimate? What is the value of the test statistic?
What is the p-value for this test?
Allowing a 10% chance of Type I error, what is your conclusion for this test?
What is the relevant point estimate?
#### Ho p<=.15
#### Ha p>.15
p<-0.15
### Sample with 400 observations
n<-400
##### The point estimate
phat<-58/400
phat ## phat=.145
## [1] 0.145
What is the value of the test statistic?
##### Use the formula to calculate z
z<-(phat-p)/sqrt(p*(1-p)/n)
z
## [1] -0.280056
Using the test statistics (\(z=-.28\)), one can compare it to the critical value associated to the level of significance adopted (10%) and see if \(z\) is inside or outside of the critical region.
##### The critical value associated with the level of significance (.10). Remember NORMSINV? Check the lab session #2
zc<-qnorm(0.9)
zc
## [1] 1.281552
###### Is your z>zc? If yes, reject Ho. Let's play with ifelse statements!
what_to_do_1<-ifelse(z>zc, "reject", "don't")
what_to_do_1
## [1] "don't"
So you do not reject the null. Finding the p-value you should get the same answer: do not reject the null. That means your p-value will be greater than .1. Let’s check it.
##### Getting the p-value (try to compare with your excel file - pnorm is analogous to NORMSDIST)
pnorm(z)
## [1] 0.3897173
pvalue<-1-pnorm(z) ## why your p-value is 1-pnorm(z)?
pvalue
## [1] 0.6102827
############## Is your p-value<.10? Let's play with ifelse statements!
what_to_do2<-ifelse(pvalue<0.1, "reject", "don't")
what_to_do2
## [1] "don't"
So you do not reject the null: p-value (\(.61\)) is greater than \(\alpha=.1\).
New banking standards require the mean debt-to-equity ratio for a bank’s portfolio of investment to be 1.5. On behalf of the bank’s president, staff took a random sample of the loans and listed them in the Excel file.
The 99% confidence interval for the debt-to-equity ratio, based on the sample, is given by ?
What if you obtained the same sample information (that is, the same sample mean and standard deviation), but from a sample of 200 loans? The 99% confidence interval would then be given by ?
Therefore, in both cases, would the bank president find the bank’s portfolio to meet the new standards?
Assume that you are interested in being 90% confident in your interference and want the endpoints of the confidence interval to be no more than 0.01 away from the point estimate. How large a sample would you need (use the sample standard deviation as your estimate for \(\sigma\))?
Using getwd() you can see your current directory - you can change that if you want it.
############# Identify your directory!
getwd()
## [1] "C:/Users/User/Desktop/labmd"
#### Setting the desktop as your directory.
setwd("C:/Users/User/Desktop")
After this, you should put your data file in the Desktop of your computer - or add more “/”. For example, you can create a file on Desktop named Lab2 and use it as directory with the following: setwd(“C:/Users/User/Desktop/Lab2”). If so, put everything that you are planning to use inside of the file Lab2 (in our case, the Excel file “debtequityv3”).
Using the code below you import the data to R. If you don’t have a package, you need to install it first.
#### The package xlsx gets the work done. First step is to install the new package in R
# install.packages("xlsx")
#### You just need to install a package once. After this, just call it using the function require() or library()
#### Every time that you are using a package you gotta call them using require(nameofthepackage)
# require(xlsx)
Then you read the file “debtequityv3.xls” and give it a name (debteq).
The column that contains the data is named as X1. Let’s change that name:
Now you are working with the column ratio in your dataframe. First step is to get \(\bar{X}\) (mean) and the standard deviation (\(s\)).
############### You gotta be specific about what variable you are working on. So, use $variable's name
mean<-mean(debteq$Ratio)
mean
## [1] 1.012
sd<-sd(debteq$Ratio)
sd
## [1] 0.3035081
Getting the critical value associated to \(\dfrac{\alpha}{2}\) and \(df\).
####### 99% interval
####### abs function - returns the absolute value
####### qt function - returns the critical value for a t(alfa, df).
####### Remember TINV(alfa,df) on excel? What is the difference here?
tc<-abs(qt(0.01/2, 14))
tc
## [1] 2.976843
The first interval is:
############ Your interval is:
min<-mean-tc*(sd/sqrt(15))
min
## [1] 0.7787184
max<-mean+tc*(sd/sqrt(15))
max
## [1] 1.245282
Now you need to change \(n\). Instead of \(n=15\), use \(n=450\). So you have \(df=449\) and the respective (new) \(t_{\alpha/2, df}\). Redo the steps above and get the upper and lower bound of your new confidence interval.
Finally, to get n
zc<-qnorm(0.95)
zc
## [1] 1.644854
w<-0.015
n<-(sd)^2*(zc)^2/w^2
n
## [1] 1107.675
(ALWAYS) Rounding up, you get 1108.