Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
60 views

Assignment 1

This document provides instructions for an assignment involving R code to: 1) Create vectors and matrices from sample data and perform operations on them like transposition, inversion, and element multiplication. 2) Solve a system of linear equations using matrices. 3) Perform linear regression on height and weight data, including diagnostics, plotting, and prediction intervals. Multiple regression is also performed using height and its square as independent variables, with forward and backward selection to determine the best model.

Uploaded by

Gs1995
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Assignment 1

This document provides instructions for an assignment involving R code to: 1) Create vectors and matrices from sample data and perform operations on them like transposition, inversion, and element multiplication. 2) Solve a system of linear equations using matrices. 3) Perform linear regression on height and weight data, including diagnostics, plotting, and prediction intervals. Multiple regression is also performed using height and its square as independent variables, with forward and backward selection to determine the best model.

Uploaded by

Gs1995
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Introduction to R- Application to Decision Sciences

Assignment 1
General Instructions:

You must create a R Script/file by the name “YourName_Assignment-1”. Send me the file
along with a pdf copy of the codes. The graphs must be saved as different files and sent to
me along with the assignment.

Please do not copy. You are free to discuss among yourselves but each one of you must write
your own code and send it to me.
You must interpret the results in Part II. The R script that you send should run on my laptop
as it is.

1. Create a vector named GMP. The size of the vector should be 10 and the elements in
the vector are multiples of 7 starting from 21.
2. Randomly select 5 numbers from the vector. Repeat the process 5 times and name
them GMP_vector_i, where i refers to the sample number. Create a matrix
GMP_matrix by combining these vectors. Name the rows as Student_i, where I refers
to the row number.
3. Transpose the matrix, find the inverse of the matrix and also the product of the
principal diagonal elements.
4. Create two matrices named Row Matrix and Column Matrix. The elements of these
matrices are the GMP_matrix elements sorted row-wise and column-wise respectively.
5. Compute the column-wise and row-wise mean and variances for the GMP_matrix.
6. Plot the means obtained above. (Use Scatter-Plot and Bar Charts with appropriate
names). Also create two pie-charts (one each for Column Mean and Row-mean).
7. Transform the elements in the GMP_matrix using the following transformation:

𝑓 (𝑥) = λ * e-λ / x!

You must use the for loop.

8. Plot x and f(x).


Part-II

Consider the following system of linear equations:

Solve the system of equations using Matrices.

Consider the dataset Women. Name the columns as Height and Weight respectively.
 Check whether the mean height =65 and mean weight =115. Also check if the
variance of height and weight are same.
 Perform a linear regression with Weight as the dependent variable. Name the
regression object as Regress. Carry out the regression diagnostics.

 Plot the variables and also the best fit line.

 Create prediction intervals (90, 95 and 99%) and plot them along with the best fit line.

 Create a new variable HSquare= Height2. Repeat the regression now using two
independent variables Height and HSquare.
 Use forward and backward regression to arrive at the best model.

You might also like