title: Visualizing the output for Mean() and Lm() [logit, two tailed t-test, and ordinary least squares]
body: <p>New to R and struggling on how best to visualize my results. I'm also new to stack overflow so I apologize if my formatting is incorrect or distasteful.</p>
  <p>Four relationships (or lack there of) I'd like to visualize.</p>
  <p>I've made whisker plots, bar graphs, and scatter plots before; but I haven't needed to solve these particular problems before. I've posted my code and the returns under each question.</p>
  <p>I've used mean() to compare the averages of the entire sample, as well as the control and experimental group.</p>
  <p>The functions used were mean(), lm().</p>
  <p>I have reviewed the various graphs in R in the man pages, but I've had trouble figuring out how to apply those to my findings. Any help of guidance is greatly appreciated.</p>
  <p><em>Visualizing no difference in means between control and treatment mean()</em></p>
  <pre><code>#treatment/control variable
  &gt; clean$treatment &lt;- NA
  &gt; clean$treatment[clean$prime_Page.Submit &gt;= 0] &lt;- 1
  &gt; clean$treatment[clean$control_Page.Submit &gt;= 0] &lt;- 0
  &gt;
  &gt; table(clean$treatment, useNA = &quot;ifany&quot;)
  
  0    1 &lt;NA&gt;
  23   20  220
  &gt;
  &gt;
  &gt; #1) Did the experimental group have higher attrition
  &gt; #subset for difference in progress
  &gt;
  &gt; #this creates a table
  &gt; table(clean$Progress, useNA = &quot;ifany&quot;)
  
  2    3    4    7   18   45   66  100 &lt;NA&gt;
  3    5    3    1    1    2    1   43  204
  &gt;
  &gt; #only treated people
  &gt; treated &lt;- subset(clean, treatment == 1)
  &gt; table(treated$treatment)
  
  1
  20
  &gt;
  &gt; #only control people
  &gt; control &lt;- subset(clean, treatment == 0)
  &gt; table(control$treatment)
  
  0
  23
  &gt;
  &gt; #run mean testing
  &gt; mean(clean$Progress)
  [1] NA
  &gt; mean(control$Progress)
  [1] 100
  &gt; mean(treated$Progress)
  [1] 100
  &gt;
  &gt; #they are the same!
  </code></pre>
  <p><em>Do people self report being in a particular group have a increased attrition rate?&quot; using lm() and lm() after recoding to increase visibility of any effect (none found)</em></p>
  <pre><code>table(clean$Progress, useNA = &quot;ifany&quot;)
  
  2    3    4    7   18   45   66  100 &lt;NA&gt;
  3    5    3    1    1    2    1   43  204
  &gt; clean$dropped_out &lt;- NA
  &gt; clean$dropped_out[clean$Progress &gt;= 87] &lt;- 1
  &gt; clean$dropped_out[clean$Progress &lt;= 86] &lt;- 0
  &gt; table(clean$dropped_out, useNA = &quot;ifany&quot;)
  
  0    1 &lt;NA&gt;
  16   43  204
  &gt; #
  &gt;
  &gt;
  &gt; #Logit predicting dropping out with Q162
  &gt; Logit_1 &lt;- lm(dropped_out ~ Q162, data = clean, family = &quot;binomial&quot;)
  Warning message:
  In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  extra argument ‘family’ will be disregarded
  &gt; summary(Logit_1)
  
  Call:
  lm(formula = dropped_out ~ Q162, data = clean, family = &quot;binomial&quot;)
  
  Residuals:
  Min       1Q   Median       3Q      Max
  -0.93010  0.08111  0.09232  0.09232  0.10352
  
  Coefficients:
  Estimate Std. Error t value Pr(&gt;|t|)
  (Intercept)  0.79562    0.33665   2.363   0.0226 *
  Q162         0.01121    0.03187   0.352   0.7268
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Residual standard error: 0.2877 on 44 degrees of freedom
  (217 observations deleted due to missingness)
  Multiple R-squared:  0.002801,  Adjusted R-squared:  -0.01986
  F-statistic: 0.1236 on 1 and 44 DF,  p-value: 0.7268
  
  &gt;
  &gt; #did not have an effect on the drop our rate
  &gt;
  &gt;
  &gt; #Recoding 162 to binary to increase effect if any exists
  &gt; table(clean$Q162, useNA = &quot;ifany&quot;)
  
  9   10   11   12   13   15 &lt;NA&gt;
  10   19    9    3    4    1  217
  &gt; clean$m_o &lt;- NA
  &gt; clean$m_o[clean$Q162 &gt;= 13] &lt;- 1
  &gt; clean$m_o[clean$Q162 &lt;= 11] &lt;- 0
  &gt; table(clean$m_o, useNA = &quot;ifany&quot;)
  
  0    1 &lt;NA&gt;
  38    5  220
  
  </code></pre>
  <pre><code>&gt; LOgit_2 &lt;- lm(dropped_out ~ m_o, data = clean, family = &quot;binomial&quot;)
  Warning message:
  In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  extra argument ‘family’ will be disregarded
  &gt; summary(LOgit_2)
  
  Call:
  lm(formula = dropped_out ~ m_o, data = clean, family = &quot;binomial&quot;)
  
  Residuals:
  Min       1Q   Median       3Q      Max
  -0.92105  0.07895  0.07895  0.07895  0.07895
  
  Coefficients:
  Estimate Std. Error t value Pr(&gt;|t|)
  (Intercept)       0.92105    0.04211  21.871   &lt;2e-16 ***
  m_o  0.07895    0.12350   0.639    0.526
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Residual standard error: 0.2596 on 41 degrees of freedom
  (220 observations deleted due to missingness)
  Multiple R-squared:  0.009868,  Adjusted R-squared:  -0.01428
  F-statistic: 0.4086 on 1 and 41 DF,  p-value: 0.5262
  
  </code></pre>
  <p><em>OSL test and Welch Two Sample T-test using lm()</em></p>
  <pre><code>#OLS and T.test 
  &gt; OLS_Results_1 &lt;- lm(Progress ~ Q162, data = clean)
  &gt; summary(OLS_Results_1)
  
  Call:
  lm(formula = Progress ~ Q162, data = clean)
  
  Residuals:
  Min      1Q  Median      3Q     Max
  -76.775   4.573   5.225   5.225   5.876
  
  Coefficients:
  Estimate Std. Error t value  Pr(&gt;|t|)
  (Intercept)  88.2599    19.9466   4.425 0.0000627 ***
  Q162          0.6515     1.8884   0.345     0.732
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  Residual standard error: 17.05 on 44 degrees of freedom
  (217 observations deleted due to missingness)
  Multiple R-squared:  0.002698,  Adjusted R-squared:  -0.01997
  F-statistic: 0.119 on 1 and 44 DF,  p-value: 0.7317
  
  &gt;
  &gt; t.test(clean$Progress ~ clean$m_o, alternative = c(&quot;two.sided&quot;))
  
  Welch Two Sample t-test
  
  data:  clean$Progress by clean$m_o
  t = -1.676, df = 37, p-value = 0.1022
  alternative hypothesis: true difference in means is not equal to 0
  95 percent confidence interval:
  -9.9401469  0.9401469
  sample estimates:
  mean in group 0 mean in group 1
  95.5           100.0
  </code></pre>