b1()

b1()

The b1() function will calculate the b1 value for a model.

Example 1:

Below are various methods for indexing the model in the argument of the b1() function (they will all produce the same output). 

# Method 1: Find the b1 value for the Sex model of Thumb
b1(Thumb ~ Sex, data = Fingers)

# Method 2: Save the model first
Sex_model <- lm(Thumb ~ Sex, data = Fingers)
b1(Sex_model)

# Method 3: Use the lm() function within the b1() function
b1(lm(Thumb ~ Sex, data = Fingers))

Example output:

Output of b1() function

Example 2:

Below is an example of using the b1() function to generate a sampling distribution of b1, then plotting the distribution, and plotting the sample b1 value on the graph.

# Generate 1000 b1s from randomized (shuffled) data
# and save them into an object called sdob1
sdob1 <- do(1000) * b1(shuffle(Thumb) ~ Sex, data = Fingers)

# Save and print out the sample b1 value
sample_b1 <- b1(Thumb ~ Sex, data = Fingers)
sample_b1

# Plot the sampling distribution with the sample b1
gf_histogram(~ b1, data = sdob1fill = ~middl(b1, .95)) %>%
    gf_point(0 ~ sample_b1, color = "red")

Example output:

Output of sdob1

    • Related Articles

    • intercept

      Intercept is the value where a line intersects with the y-axis; the value of y when the x is 0; for example, in the equation for a line, y = mx + b, the y-intercept is represented by b.
    • Appendix of Data Frames Used in Course Textbook

      All data frames listed below are automatically preloaded when you run library(coursekata). Link to full repository of R documentation: https://www.rdocumentation.org/ Data Frame Name and Link to R Documentation Ames BikeCommute FatMice18 Fingers ...
    • Page Won't Load or Button Doesn't Work

      Page Won't Load / Button Doesn't Work The problem:  You click on a page in CourseKata and the content won't load (page won't load) You click on a button in CourseKata and nothing happens (button doesn't work) What to try:  Note: the suggestions below ...
    • Printing Pages of the Book

      If you need to print pages of the book, you may find that printing them from Chrome results in oddly-formatted pages.  You will get better-formatted pages if you print using either Safari or Firefox as your browser. If using Safari, go the the Safari ...
    • Bonferroni Adjustment

      A Bonferroni adjustment (also known as a Bonferroni correction) is used when making simultaneous comparisons, to make sure that your overall error rate is reduced. You simply divide your acceptable alpha (e.g., .05) by the number of simultaneous ...