Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Similar to (b), but now `x` may contain missing values. Write an Rcpp function `varC(x, na_rm)` that mimics the built in R function `var`: #####

image text in transcribedimage text in transcribed

Similar to (b), but now `x` may contain missing values. Write an Rcpp function `varC(x, na_rm)` that mimics the built in R function `var`:

##### (b) Write an Repp function 'varc(x) which computes the sample variance of a numeric vector x assume no missing values). Benchmark your function with a vector of length 1e5 and compare with var(x). Hint: 1. Use the computational formula of sample variance! 2. Sample variance is not defined if length(x)' is 1, return NON in this case. . ##### (C) Similar to (b), but now xmay contain missing values. Write an Repp function 'varccx, na_rm) that mimics the built in R function 'var: when x' contains missing values and na_rm is "FALSE", returns NA'; when * contains missing values and 'na_rm is "TRUE", ignores the missing values and computes the sample variance as is. Benchmark your function and compare with var(x, na.rm = TRUE) by considering vectors of different lengths 'n 100, 1000, 1e4 and 1e5 and different proportions of missingness p = 0.5, 0.05, and 09. ##### (b) Write an Repp function 'varc(x) which computes the sample variance of a numeric vector x assume no missing values). Benchmark your function with a vector of length 1e5 and compare with var(x). Hint: 1. Use the computational formula of sample variance! 2. Sample variance is not defined if length(x)' is 1, return NON in this case. . ##### (C) Similar to (b), but now xmay contain missing values. Write an Repp function 'varccx, na_rm) that mimics the built in R function 'var: when x' contains missing values and na_rm is "FALSE", returns NA'; when * contains missing values and 'na_rm is "TRUE", ignores the missing values and computes the sample variance as is. Benchmark your function and compare with var(x, na.rm = TRUE) by considering vectors of different lengths 'n 100, 1000, 1e4 and 1e5 and different proportions of missingness p = 0.5, 0.05, and 09

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

=+2. Who are its competitors?

Answered: 1 week ago