final Q2.docx - Final Q2#Capture a Regression Model with...

This preview shows page 1 - 2 out of 3 pages.

Final Q2 12/5/2020 #Capture a Regression Model with Only Significant Variables. Set the dependent variable to 'Species'. Even though the variable is categorical and regression is not the proper model to use we will ignore this fact for the purpose of the assignment. data = read.csv ( "iris_exams.csv" ) str (data) ## 'data.frame': 300 obs. of 6 variables: ## $ id : chr "S001" "S002" "S003" "S004" ... ## $ Species : chr "setosa" "setosa" "setosa" "setosa" ... ## $ Sepal.Length: num 4.75 5.07 5.24 5.48 4.9 ... ## $ Sepal.Width : num 3.3 3.68 3.44 3.96 2.81 ... ## $ Petal.Length: num 1.44 1.21 1.59 1.53 1.49 ... ## $ Petal.Width : num 0.235 0.111 0.405 0.272 0.345 ... ## 'data.frame': 300 obs. of 6 variables: ## $ id : chr "S001" "S002" "S003" "S004" ... ## $ Species : chr "setosa" "setosa" "setosa" "setosa" ... ## $ Sepal.Length: num 4.75 5.07 5.24 5.48 4.9 ... ## $ Sepal.Width : num 3.3 3.68 3.44 3.96 2.81 ... ## $ Petal.Length: num 1.44 1.21 1.59 1.53 1.49 ... ## $ Petal.Width : num 0.235 0.111 0.405 0.272 0.345 ... data $ Species = as.numeric ( as.factor (data $ Species)) model = lm (Species ~ Petal.Width, data = data) summary (model) ## ## Call: ## lm(formula = Species ~ Petal.Width, data = data) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.68016 -0.12698 -0.00481 0.12121 0.77207 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.78346 0.02362 33.17 <2e-16 *** ## Petal.Width 1.01522 0.01655 61.33 <2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ##

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture