Below is a number of exercises to play around with data structures in R. Some of them can be "solved" using the material we have just discussed in the last tutorial session. For others, explore! Ways to learn and find out about useful R commands are using the inbuilt help function, but also using internet search to find tutorials and help from the R community.
Exercises II
- Load the usedcars data set we just discussed in the tutorial. Build analyze the impact of all variables on price building linear regression models and determine which model is the best description of the data using AIC analysis.
- Generate a vector X of 100 normally distributed random variates. Write an R program to find another vector Y of 100 random variates such that the regression coefficient for the slope when building a linear regression model Y ~ X is close to 0.5 and the variation explained by the regression (adjusted R-squared) is also close to 50%.
- By calculating estimates of the standard deviation of samples of varying size from a normal distribution, show that the population version of calculating SD's (i.e. without Bessel's correction) is a biased estimator.
- Write a function that produces the following sine-wave-like output of 0's and 1's on your screen: