Module 7 Assignment
Module 7 Assignment
R Code:
# Module 7 Assignment
#1.1
#First define the data set required, I/O values
x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
#Then we must create the relationship (correlation)
cor(x,y)
#This value 0.728 that is in the console tells us a few things
#This relationship is correlated and is increasing linearly
#I may choose to plot these findings using plot()
plot(x,y)
#See the lower righthand window for a composite plot for this data, as the regression trednline would positively increase through the points
#1.2
#This settion of code will get the value for the coefficients of the linear regression for this data
Regression_model=lm(y~x)
Regression_model$coefficients
#2.1
#This problem will go over the aquisition of similar values with a different data set
discharge <- c(3.600,1.800,3.333,2.283,4.533,2.883)
waiting <- c(79,54,74,62,85,55)
plot(discharge,waiting)
#2.1
Regression_model_1=lm(waiting~discharge)
Regression_model_1$coefficients
#2.2
#Had to consult the help menu, but a little elbow grease never hurt right?
#Get the coefficients and view them in the console below
?coefficients
coefficients(Regression_model_1)
#2.3
#I am not sure by what is meant by the fit but if it is line of best fit
#then the equation for that would be x = 0.0676y - 4.608
#3.1 mtcars
#get and print the head for the mtcars librarry file whih is already preloaded in the RStudio
input <- mtcars[,c("mpg","disp","hp","wt")]
print(head(input))
#What does the below multiple regression tell us about the data that we have in our possession
input <- mtcars[,c("mpg","disp","hp","wt")]
lm(formula = mpg ~ disp + hp + wt, data = input)
#This result provides the coefficients and the intercepts for the multiple regression model for these entities against a singular (mpg)
#4
library(ISwR)
plot(metabolic.rate~body.weight,data=rmr)
#the predicted metabolic rate for the data set shown for a 70 kg individual
## may sit between 1200-1600 based on the four values that are centered around 70 kg
Console Outputs:
# Module 7 Assignment
>
> #1.1
>
>
> #First define the data set required, I/O values
> x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10)
> y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
>
> #Then we must create the relationship (correlation)
> cor(x,y)
[1] 0.7282365
>
> #This value 0.728 that is in the console tells us a few things
> #This relationship is correlated and is increasing linearly
>
> #I may choose to plot these findings using plot()
>
> plot(x,y)
>
> #See the lower righthand window for a composite plot for this data, as the regression trednline would positively increase through the points
>
>
> #1.2
> #This settion of code will get the value for the coefficients of the linear regression for this data
>
> Regression_model=lm(y~x)
>
> Regression_model$coefficients
(Intercept) x
19.205597 3.269107
>
> #2.1
> #This problem will go over the aquisition of similar values with a different data set
>
>
> discharge <- c(3.600,1.800,3.333,2.283,4.533,2.883)
>
> waiting <- c(79,54,74,62,85,55)
>
> plot(discharge,waiting)
>
> #2.1
>
> Regression_model_1=lm(waiting~discharge)
>
> Regression_model_1$coefficients
(Intercept) discharge
31.22636 12.02484
>
> #2.2
> #Had to consult the help menu, but a little elbow grease never hurt right?
> #Get the coefficients and view them in the console below
>
>
> ?coefficients
>
> coefficients(Regression_model_1)
(Intercept) discharge
31.22636 12.02484
>
> #2.3
> #I am not sure by what is meant by the fit but if it is line of best fit
> #then the equation for that would be x = 0.0676y - 4.608
>
> #3.1 mtcars
> #get and print the head for the mtcars librarry file whih is already preloaded in the RStudio
>
>
> input <- mtcars[,c("mpg","disp","hp","wt")]
> print(head(input))
mpg disp hp wt
Mazda RX4 21.0 160 110 2.620
Mazda RX4 Wag 21.0 160 110 2.875
Datsun 710 22.8 108 93 2.320
Hornet 4 Drive 21.4 258 110 3.215
Hornet Sportabout 18.7 360 175 3.440
Valiant 18.1 225 105 3.460
>
> #What does the below multiple regression tell us about the data that we have in our possession
> input <- mtcars[,c("mpg","disp","hp","wt")]
>
> lm(formula = mpg ~ disp + hp + wt, data = input)
Call:
lm(formula = mpg ~ disp + hp + wt, data = input)
Coefficients:
(Intercept) disp hp wt
37.105505 -0.000937 -0.031157 -3.800891
>
> #This result provides the coefficients and the intercepts for the multiple regression model for these entities against a singular (mpg)
>
> #4
>
> library(ISwR)
>
> plot(metabolic.rate~body.weight,data=rmr)
>
> #the predicted metabolic rate for the data set shown for a 70 kg individual
> ## may sit between 1200-1600 based on the four values that are centered around 70 kg
>
Comments
Post a Comment