FE515_MIDEXAM_Shashank-6-7

pdf

School

Stevens Institute Of Technology *

*We aren’t endorsed by this school

Course

515

Subject

Statistics

Date

Jan 9, 2024

Type

pdf

Pages

2

Uploaded by CoachMoleMaster1909

Report
## Multiple R-squared: 0.6342, Adjusted R-squared: 0.634 ## F-statistic: 4795 on 1 and 2766 DF, p-value: < 2.2e-16 1.7 Draw a regression line on the scatter plot using the fitted model above. Make sure use a different color to draw the regression line. plot (jpm.returns, wfc.returns, xlab = "WFC Daily Returns" , ylab = "JPM Daily Returns" , main = "JPM Daily Returns vs WFC Daily Returns" , abline (fit, col= "black" ) -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 -0.15 -0.05 0.05 JPM Daily Returns vs WFC Daily Returns WFC Daily Returns JPM Daily Returns Question 2 : (50 points) 2.1 Without using packages, create a function of 2 variables “x” and “adjusted” that calculates the sample skewness of “x” using the formulas on Lecture 6 page 20 and page 21. When “adjusted” = TRUE, it returns the adjusted skewness of “x”, and FALSE returns the unadjusted one. sample_skewness <- function (x, adjusted = TRUE ) { n <- length (x) mean_x <- mean (x) sd_x <- sd (x) 6
if (adjusted) { skewness_adj <- ( sum ((x - mean_x) ˆ 3 ) / (n * sd_x ˆ 3 )) return (skewness_adj) } else { skewness_unadj <- ( sum ((x - mean_x) ˆ 3 ) / ((n - 1 ) * sd_x ˆ 3 )) return (skewness_unadj) } } x <- c ( 1 , 2 , 3 , 4 , 5 , 6 , 12 , 71 ) # Calculate the adjusted and unadjusted skewness of daily log returns adjusted_skewness <- sample_skewness (x, adjusted = TRUE ) unadjusted_skewness <- sample_skewness (x, adjusted = FALSE ) cat ( "Adjusted Skewness:" , adjusted_skewness, " \n " ) ## Adjusted Skewness: 1.78443 cat ( "Unadjusted Skewness:" , unadjusted_skewness, " \n " ) ## Unadjusted Skewness: 2.039348 2.2 Without using packages, create a function of 2 variables “x” and “adjusted” that calculates the sample kurtosis of “x” using the formulas on Lecture 6 page 20 and page 23. When “adjusted” = TRUE, it returns the adjusted kurtosis of “x”, and FALSE returns the unadjusted one. sample_kurtosis <- function (x, adjusted = TRUE ) { n <- length (x) mean_x <- mean (x) sd_x <- sd (x) if (adjusted) { kurtosis_adj <- ( sum ((x - mean_x) ˆ 4 ) / n) / (sd_x ˆ 4 ) - 3 return (kurtosis_adj) } else { kurtosis_unadj <- ( sum ((x - mean_x) ˆ 4 ) / n) / (sd_x ˆ 4 ) return (kurtosis_unadj) } } x <- c ( 1 , 2 , 3 , 4 , 5 , 6 ) adjusted_kurt <- sample_kurtosis (x, adjusted = TRUE ) unadjusted_kurt <- sample_kurtosis (x, adjusted = FALSE ) cat ( "Adjusted Kurtosis:" , adjusted_kurt, " \n " ) ## Adjusted Kurtosis: -1.797619 7
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help