Rstudio
R Project 1
Name: ___________
TU ID: ___________
Question 1.
Combine data file “Examscore_A” and “Examscore_B” into one data file, and name it “Examscore _AB”. Delete the repeated variable. Delete the second and third observation (i.e. second and third row). Calculate the sample mean and standard deviation of remaining observations’ math exam score.
1. The sample mean of remaining observations’ math exam score is __ ____
2. The sample standard deviation of remaining observations’ math exam score is __ ____
3. Please screenshot the R code you used and insert the image below (or copy and paste the code).
4. Please screenshot the final dataset in R and insert the image below
Question 2.
The dataset “Project1data_1” has information for a sample of stocks, which are randomly chosen from a large population (i.e. all the stocks in the stock market). Please use confidence interval to test if the population mean of stock price is different from $60 at the 5% significance level.
1. The alternative hypothesis is _
2. The confidence interval is ______
3. The hypothesized value is _________
4. We should ______ the null hypothesis, and conclude that _________
5. Please screenshot the R code you used for calculation, and insert the image below.
Question 3.
The dataset “Project1data_1” has information for a sample of stocks, which are randomly chosen from a large population (i.e. all the stocks in the stock market). Please use test-statistic and critical value(s) to test if the population mean of stock earnings is greater than $6 at the 5% significance level.
1. The alternative hypothesis is _________
2. The test-statistic is ________
3. The critical value(s) is(are) _ ______ (can be confirmed on T-chart)
4. We should _ _____ the null hypothesis, and conclude that ____________________
5. Please screenshot the R code you used for calculation, and insert the image below.
Question 4.
The dataset “Project1data_1” has information for a sample of stocks, which are randomly chosen from a large population (i.e. all the stocks in the stock market). Please use test-statistic and critical value(s) to test if the population variance of stock earnings is different from $2 at the 5% significance level.
1. The alternative hypothesis is ______
2. The test-statistic is _ ____
3. The critical value(s) is(are) _ ______ (can be confirmed on Chi-square-chart)
4. We should _ _____ the null hypothesis, and conclude that ____________________________
5. Please screenshot the R code you used for calculation, and insert the image below.
Question 5:
Use the dataset “project1data_2” and a simple linear regression model to analyze how the time spent on watching television shows can affect the quiz score. The data is created for you to practice and to understand how to do econometric analysis by using R. There are two variables in the data set. The first column is the independent variable, which represents the number of hours spent on watching television shows. The second column is the dependent variable, which represents the quiz score. There is no variable name in the data set, so you have to specify the header. The default names for the variables are X1 and X2, which have to be in the form of upper case. Assume the significance level is 5%.
1. Draw the scatter plot and the fitted straight line, and insert the image below
2. The regression equation is _ _ ___
3. Analyze the summary of regression results (i.e. state the estimated value of regression coefficients, interpret the use of t-value and R-squared, determine if each regression coefficient is different from zero by using t-value or P-value, and conclude whether and how watching TV show affects quiz score)
4. Please screenshot the R code you used for calculation, and insert the image below.
Question 6:
Use the dataset “project1data_3” and a simple linear regression model to calculate the beta of the stock. The data is created for you to practice and to understand how to do econometric analysis by using R. Please notice that you need to convert the stock price into the stock return. You can refer to the Excel document “CAPM.xlsx” to see the conversion. Assume the significance level is 5%.
1. Draw the scatter plot and the fitted straight line, and insert the image below
2. The regression equation is _____________________
3. Analyze the summary of regression results (i.e. state the estimated value of regression coefficients, interpret the use of t-value and R-squared, determine if each regression coefficient is different from zero by using t-value or P-value, and interpret the value of beta for this stock)
4. Please screenshot the R code you used for calculation, and insert the image below.