In: Statistics and Probability
input <- mtcars[,c("am","cyl","hp","wt")]
Write a few line of R code to conduct a regression analysis with am as the response variable, and
cyl, hp, wt as explanation variables.
The whole data contained mtcars is,we take subset of whole data using command,
input <- mtcars[,c("am","cyl","hp","wt")]
we want to take am as response variable and others are explanation variables then we use commands
a=lm(am~cyl+hp+wt,data=input) #linear model command am
as response and other are explanation variables
summary(a) #this gives anova table and other neccessary outputs
code:-
>mtcars
> input <- mtcars[,c("am","cyl","hp","wt")]
> input
> a=lm(am~cyl+hp+wt,data=input)
> summary(a)
result:- If p-value < alpha then we reject Ho.